shave off some time when sending multiple bytes through SPI
This commit is contained in:
parent
ff9d1fb05c
commit
47babd2098
@ -642,9 +642,9 @@ void __spiTransferBytes(spi_t * spi, uint8_t * data, uint8_t * out, uint32_t byt
|
|||||||
uint8_t * bytesBuf = (uint8_t *) wordsBuf;
|
uint8_t * bytesBuf = (uint8_t *) wordsBuf;
|
||||||
|
|
||||||
if(data) {
|
if(data) {
|
||||||
for(i=0; i<bytes; i++) {
|
memcpy(bytesBuf, data, bytes);//copy data to buffer
|
||||||
bytesBuf[i] = data[i];//copy data to buffer
|
} else {
|
||||||
}
|
memset(bytesBuf, 0xFF, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
while(spi->dev->cmd.usr);
|
while(spi->dev->cmd.usr);
|
||||||
@ -662,9 +662,7 @@ void __spiTransferBytes(spi_t * spi, uint8_t * data, uint8_t * out, uint32_t byt
|
|||||||
for(i=0; i<words; i++) {
|
for(i=0; i<words; i++) {
|
||||||
wordsBuf[i] = spi->dev->data_buf[i];//copy spi fifo to buffer
|
wordsBuf[i] = spi->dev->data_buf[i];//copy spi fifo to buffer
|
||||||
}
|
}
|
||||||
for(i=0; i<bytes; i++) {
|
memcpy(out, bytesBuf, bytes);//copy buffer to output
|
||||||
out[i] = bytesBuf[i];//copy buffer to output
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user