summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2020-12-06 01:50:41 +0000
committerQMK Bot <hello@qmk.fm>2020-12-06 01:50:41 +0000
commitbb79fbaccf5a787f1d79c6e2d66b8765486d1969 (patch)
treed060b3f527a5039912efffae2970fe247500977b
parentaf8697c85b5d893187c7eb9f3e82997fa172a48a (diff)
parent5cf70f3993ceecf24dc46c6791552f268d82ae91 (diff)
Merge remote-tracking branch 'origin/master' into develop
-rw-r--r--drivers/avr/spi_master.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/avr/spi_master.c b/drivers/avr/spi_master.c
index f91baf70ba..cbec9f36e1 100644
--- a/drivers/avr/spi_master.c
+++ b/drivers/avr/spi_master.c
@@ -140,27 +140,33 @@ spi_status_t spi_read() {
}
spi_status_t spi_transmit(const uint8_t *data, uint16_t length) {
- spi_status_t status = SPI_STATUS_ERROR;
+ spi_status_t status;
for (uint16_t i = 0; i < length; i++) {
status = spi_write(data[i]);
+
+ if (status < 0) {
+ return status;
+ }
}
- return status;
+ return SPI_STATUS_SUCCESS;
}
spi_status_t spi_receive(uint8_t *data, uint16_t length) {
- spi_status_t status = SPI_STATUS_ERROR;
+ spi_status_t status;
for (uint16_t i = 0; i < length; i++) {
status = spi_read();
- if (status > 0) {
+ if (status >= 0) {
data[i] = status;
+ } else {
+ return status;
}
}
- return (status < 0) ? status : SPI_STATUS_SUCCESS;
+ return SPI_STATUS_SUCCESS;
}
void spi_stop(void) {