[Mod] Updated examples to use buffered SPI (#776)

This commit is contained in:
jgromes 2023-06-26 19:39:10 +02:00
parent a01b02fae2
commit f4f11a35d3
2 changed files with 9 additions and 5 deletions

View file

@ -285,7 +285,7 @@ class EspHal : public RadioLibHal {
// repeats clock div, mode and bit order configuration // repeats clock div, mode and bit order configuration
} }
uint8_t spiTransfer(uint8_t b) { uint8_t spiTransferByte(uint8_t b) {
this->spi->mosi_dlen.usr_mosi_dbitlen = 7; this->spi->mosi_dlen.usr_mosi_dbitlen = 7;
this->spi->miso_dlen.usr_miso_dbitlen = 7; this->spi->miso_dlen.usr_miso_dbitlen = 7;
this->spi->data_buf[0] = b; this->spi->data_buf[0] = b;
@ -294,6 +294,12 @@ class EspHal : public RadioLibHal {
return(this->spi->data_buf[0] & 0xFF); return(this->spi->data_buf[0] & 0xFF);
} }
void spiTransfer(uint8_t* out, size_t len, uint8_t* in) {
for(size_t i = 0; i < len; i++) {
in[i] = this->spiTransferByte(out[i]);
}
}
void spiEndTransaction() { void spiEndTransaction() {
// nothing needs to be done here // nothing needs to be done here
} }

View file

@ -128,10 +128,8 @@ class PiHal : public RadioLibHal {
void spiBeginTransaction() {} void spiBeginTransaction() {}
uint8_t spiTransfer(uint8_t b) { void spiTransfer(uint8_t* out, size_t len, uint8_t* in) {
char ret; spiXfer(_spiHandle, (char*)out, in, len);
spiXfer(_spiHandle, (char*)&b, &ret, 1);
return(ret);
} }
void spiEndTransaction() {} void spiEndTransaction() {}