ソースを参照

Minor SPI fixes, systick_callback for STM32F1 HAL compatibility (#19565)

Victor Oliveira 4年前
コミット
ec5b78d18b
3個のファイルの変更14行の追加14行の削除
  1. 7
    2
      Marlin/src/HAL/STM32/HAL.cpp
  2. 5
    0
      Marlin/src/HAL/STM32/HAL.h
  3. 2
    12
      Marlin/src/HAL/STM32/HAL_SPI.cpp

+ 7
- 2
Marlin/src/HAL/STM32/HAL.cpp ファイルの表示

@@ -63,7 +63,7 @@ uint16_t HAL_adc_result;
63 63
 void HAL_init() {
64 64
   FastIO_init();
65 65
 
66
-  #if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT)
66
+  #if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT) && (defined(SDSS) && SDSS != -1)
67 67
     OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
68 68
   #endif
69 69
 
@@ -122,9 +122,14 @@ extern "C" {
122 122
 
123 123
 // TODO: Make sure this doesn't cause any delay
124 124
 void HAL_adc_start_conversion(const uint8_t adc_pin) { HAL_adc_result = analogRead(adc_pin); }
125
-
126 125
 uint16_t HAL_adc_get_result() { return HAL_adc_result; }
127 126
 
127
+// Reset the system (to initiate a firmware flash)
128 128
 void flashFirmware(const int16_t) { NVIC_SystemReset(); }
129 129
 
130
+// Maple Compatibility
131
+systickCallback_t systick_user_callback;
132
+void systick_attach_callback(systickCallback_t cb) { systick_user_callback = cb; }
133
+void HAL_SYSTICK_Callback() { if (systick_user_callback) systick_user_callback(); }
134
+
130 135
 #endif // ARDUINO_ARCH_STM32 && !STM32GENERIC

+ 5
- 0
Marlin/src/HAL/STM32/HAL.h ファイルの表示

@@ -177,3 +177,8 @@ uint16_t HAL_adc_get_result();
177 177
 
178 178
 #define PLATFORM_M997_SUPPORT
179 179
 void flashFirmware(const int16_t);
180
+
181
+// Maple Compatibility
182
+typedef void (*systickCallback_t)(void);
183
+void systick_attach_callback(systickCallback_t cb);
184
+void HAL_SYSTICK_Callback();

+ 2
- 12
Marlin/src/HAL/STM32/HAL_SPI.cpp ファイルの表示

@@ -132,11 +132,9 @@ static SPISettings spiConfig;
132 132
    * @details Only configures SS pin since stm32duino creates and initialize the SPI object
133 133
    */
134 134
   void spiBegin() {
135
-    #if !PIN_EXISTS(SS)
136
-      #error "SS_PIN not defined!"
135
+    #if PIN_EXISTS(SS)
136
+      OUT_WRITE(SS_PIN, HIGH);
137 137
     #endif
138
-
139
-    OUT_WRITE(SS_PIN, HIGH);
140 138
   }
141 139
 
142 140
   // Configure SPI for specified SPI speed
@@ -173,9 +171,7 @@ static SPISettings spiConfig;
173 171
    * @details
174 172
    */
175 173
   uint8_t spiRec() {
176
-    SPI.beginTransaction(spiConfig);
177 174
     uint8_t returnByte = SPI.transfer(0xFF);
178
-    SPI.endTransaction();
179 175
     return returnByte;
180 176
   }
181 177
 
@@ -191,9 +187,7 @@ static SPISettings spiConfig;
191 187
   void spiRead(uint8_t* buf, uint16_t nbyte) {
192 188
     if (nbyte == 0) return;
193 189
     memset(buf, 0xFF, nbyte);
194
-    SPI.beginTransaction(spiConfig);
195 190
     SPI.transfer(buf, nbyte);
196
-    SPI.endTransaction();
197 191
   }
198 192
 
199 193
   /**
@@ -204,9 +198,7 @@ static SPISettings spiConfig;
204 198
    * @details
205 199
    */
206 200
   void spiSend(uint8_t b) {
207
-    SPI.beginTransaction(spiConfig);
208 201
     SPI.transfer(b);
209
-    SPI.endTransaction();
210 202
   }
211 203
 
212 204
   /**
@@ -219,10 +211,8 @@ static SPISettings spiConfig;
219 211
    */
220 212
   void spiSendBlock(uint8_t token, const uint8_t* buf) {
221 213
     uint8_t rxBuf[512];
222
-    SPI.beginTransaction(spiConfig);
223 214
     SPI.transfer(token);
224 215
     SPI.transfer((uint8_t*)buf, &rxBuf, 512);
225
-    SPI.endTransaction();
226 216
   }
227 217
 
228 218
 #endif // SOFTWARE_SPI

読み込み中…
キャンセル
保存