|
|
@ -132,11 +132,9 @@ static SPISettings spiConfig; |
|
|
|
* @details Only configures SS pin since stm32duino creates and initialize the SPI object |
|
|
|
*/ |
|
|
|
void spiBegin() { |
|
|
|
#if !PIN_EXISTS(SS) |
|
|
|
#error "SS_PIN not defined!" |
|
|
|
#endif |
|
|
|
|
|
|
|
#if PIN_EXISTS(SS) |
|
|
|
OUT_WRITE(SS_PIN, HIGH); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
// Configure SPI for specified SPI speed
|
|
|
@ -173,9 +171,7 @@ static SPISettings spiConfig; |
|
|
|
* @details |
|
|
|
*/ |
|
|
|
uint8_t spiRec() { |
|
|
|
SPI.beginTransaction(spiConfig); |
|
|
|
uint8_t returnByte = SPI.transfer(0xFF); |
|
|
|
SPI.endTransaction(); |
|
|
|
return returnByte; |
|
|
|
} |
|
|
|
|
|
|
@ -191,9 +187,7 @@ static SPISettings spiConfig; |
|
|
|
void spiRead(uint8_t* buf, uint16_t nbyte) { |
|
|
|
if (nbyte == 0) return; |
|
|
|
memset(buf, 0xFF, nbyte); |
|
|
|
SPI.beginTransaction(spiConfig); |
|
|
|
SPI.transfer(buf, nbyte); |
|
|
|
SPI.endTransaction(); |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
@ -204,9 +198,7 @@ static SPISettings spiConfig; |
|
|
|
* @details |
|
|
|
*/ |
|
|
|
void spiSend(uint8_t b) { |
|
|
|
SPI.beginTransaction(spiConfig); |
|
|
|
SPI.transfer(b); |
|
|
|
SPI.endTransaction(); |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
@ -219,10 +211,8 @@ static SPISettings spiConfig; |
|
|
|
*/ |
|
|
|
void spiSendBlock(uint8_t token, const uint8_t* buf) { |
|
|
|
uint8_t rxBuf[512]; |
|
|
|
SPI.beginTransaction(spiConfig); |
|
|
|
SPI.transfer(token); |
|
|
|
SPI.transfer((uint8_t*)buf, &rxBuf, 512); |
|
|
|
SPI.endTransaction(); |
|
|
|
} |
|
|
|
|
|
|
|
#endif // SOFTWARE_SPI
|
|
|
|