Browse Source

Fix SPI_SD Outside of HAL_STM32F1 (#14306)

3DSmitty 6 years ago
parent
commit
5b13abcacb

+ 0
- 8
Marlin/src/HAL/HAL_STM32F1/HAL_spi_STM32F1.cpp View File

113
  * @details
113
  * @details
114
  */
114
  */
115
 uint8_t spiRec(void) {
115
 uint8_t spiRec(void) {
116
-  WRITE(SS_PIN, LOW);
117
   uint8_t returnByte = SPI.transfer(0xFF);
116
   uint8_t returnByte = SPI.transfer(0xFF);
118
-  WRITE(SS_PIN, HIGH);
119
   return returnByte;
117
   return returnByte;
120
 }
118
 }
121
 
119
 
129
  * @details Uses DMA
127
  * @details Uses DMA
130
  */
128
  */
131
 void spiRead(uint8_t* buf, uint16_t nbyte) {
129
 void spiRead(uint8_t* buf, uint16_t nbyte) {
132
-  WRITE(SS_PIN, LOW);
133
   SPI.dmaTransfer(0, const_cast<uint8_t*>(buf), nbyte);
130
   SPI.dmaTransfer(0, const_cast<uint8_t*>(buf), nbyte);
134
-  WRITE(SS_PIN, HIGH);
135
 }
131
 }
136
 
132
 
137
 /**
133
 /**
142
  * @details
138
  * @details
143
  */
139
  */
144
 void spiSend(uint8_t b) {
140
 void spiSend(uint8_t b) {
145
-  WRITE(SS_PIN, LOW);
146
   SPI.send(b);
141
   SPI.send(b);
147
-  WRITE(SS_PIN, HIGH);
148
 }
142
 }
149
 
143
 
150
 /**
144
 /**
156
  * @details Use DMA
150
  * @details Use DMA
157
  */
151
  */
158
 void spiSendBlock(uint8_t token, const uint8_t* buf) {
152
 void spiSendBlock(uint8_t token, const uint8_t* buf) {
159
-  WRITE(SS_PIN, LOW);
160
   SPI.send(token);
153
   SPI.send(token);
161
   SPI.dmaSend(const_cast<uint8_t*>(buf), 512);
154
   SPI.dmaSend(const_cast<uint8_t*>(buf), 512);
162
-  WRITE(SS_PIN, HIGH);
163
 }
155
 }
164
 
156
 
165
 #if ENABLED(SPI_EEPROM)
157
 #if ENABLED(SPI_EEPROM)

+ 23
- 15
Marlin/src/HAL/HAL_STM32F1/spi_pins.h View File

23
  */
23
  */
24
 
24
 
25
 /**
25
 /**
26
- * Define SPI Pins: SCK, MISO, MOSI, SS
27
- *
28
- * Any PIN can be used for Chip Select (SS)
26
+ * STM32F1 Default SPI Pins
29
  *
27
  *
28
+ *         SS     SCK     MISO    MOSI
29
+ *       +-----------------------------+
30
+ *  SPI1 | PA4    PA5     PA6     PA7  |
31
+ *  SPI2 | PB12   PB13    PB14    PB15 |
32
+ *  SPI3 | PA15   PB3     PB4     PB5  |
33
+ *       +-----------------------------+
34
+ * Any pin can be used for Chip Select (SS_PIN)
30
  * SPI1 is enabled by default
35
  * SPI1 is enabled by default
31
  */
36
  */
37
+#ifndef SCK_PIN
38
+  #define SCK_PIN  PA5
39
+#endif
40
+#ifndef MISO_PIN
41
+  #define MISO_PIN PA6
42
+#endif
43
+#ifndef MOSI_PIN
44
+  #define MOSI_PIN PA7
45
+#endif
46
+#ifndef SS_PIN
47
+  #define SS_PIN   PA4
48
+#endif
49
+#undef SDSS
50
+#define SDSS       SS_PIN
51
+
32
 #if ENABLED(ENABLE_SPI3)
52
 #if ENABLED(ENABLE_SPI3)
33
   #define SPI_DEVICE 3
53
   #define SPI_DEVICE 3
34
-  #define SCK_PIN   BOARD_SPI3_SCK_PIN
35
-  #define MISO_PIN  BOARD_SPI3_MISO_PIN
36
-  #define MOSI_PIN  BOARD_SPI3_MOSI_PIN
37
-  #define SS_PIN    BOARD_SPI3_NSS_PIN
38
 #elif ENABLED(ENABLE_SPI2)
54
 #elif ENABLED(ENABLE_SPI2)
39
   #define SPI_DEVICE 2
55
   #define SPI_DEVICE 2
40
-  #define SCK_PIN   BOARD_SPI2_SCK_PIN
41
-  #define MISO_PIN  BOARD_SPI2_MISO_PIN
42
-  #define MOSI_PIN  BOARD_SPI2_MOSI_PIN
43
-  #define SS_PIN    BOARD_SPI2_NSS_PIN
44
 #else
56
 #else
45
   #define SPI_DEVICE 1
57
   #define SPI_DEVICE 1
46
-  #define SCK_PIN   BOARD_SPI1_SCK_PIN
47
-  #define MISO_PIN  BOARD_SPI1_MISO_PIN
48
-  #define MOSI_PIN  BOARD_SPI1_MOSI_PIN
49
-  #define SS_PIN    BOARD_SPI1_NSS_PIN
50
 #endif
58
 #endif

+ 11
- 2
Marlin/src/pins/pins_BIGTREE_SKR_MINI_V1_1.h View File

133
 //#define STM32_SD_LCD
133
 //#define STM32_SD_LCD
134
 
134
 
135
 #if ENABLED(STM32_SD_LCD)
135
 #if ENABLED(STM32_SD_LCD)
136
-  #define SD_DETECT_PIN    PB9
137
   #define ENABLE_SPI3
136
   #define ENABLE_SPI3
137
+  #define SD_DETECT_PIN PB9
138
+  #define SCK_PIN       PB3
139
+  #define MISO_PIN      PB4
140
+  #define MOSI_PIN      PB5
141
+  #define SS_PIN        PA15
138
 #else
142
 #else
139
-  #define SD_DETECT_PIN    PA3
143
+  #define ENABLE_SPI1
144
+  #define SD_DETECT_PIN PA3
145
+  #define SCK_PIN       PA5
146
+  #define MISO_PIN      PA6
147
+  #define MOSI_PIN      PA7
148
+  #define SS_PIN        PA4
140
 #endif
149
 #endif

Loading…
Cancel
Save