|
@@ -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
|