1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

cpu/stm32f1: spi_transfer_bytes proper counting.

The transferred bytes were being counted more than once because of a +=
when calling spi_transfer_byte().

This patch should also handle errors from spi_transfer_byte() better
since it is now possible to detect errors _after_ the first byte has
been successfully sent.

Signed-off-by: Joakim Gebart <joakim@gebart.se>
This commit is contained in:
Joakim Gebart 2014-08-31 15:22:19 +02:00
parent 4287188f26
commit a12b879027

View File

@ -128,7 +128,7 @@ int spi_transfer_bytes(spi_t dev, char *out, char *in, unsigned int length)
if (out != NULL) {
DEBUG("out*: %p out: %x length: %x\n", out, *out, length);
while (length--) {
ret += spi_transfer_byte(dev, *(out)++, 0);
ret = spi_transfer_byte(dev, *(out)++, 0);
if (ret < 0) {
return ret;
}
@ -137,7 +137,7 @@ int spi_transfer_bytes(spi_t dev, char *out, char *in, unsigned int length)
}
if (in != NULL) {
while (length--) {
ret += spi_transfer_byte(dev, 0, in++);
ret = spi_transfer_byte(dev, 0, in++);
if (ret < 0) {
return ret;
}