diff --git a/api/mraa/spi.h b/api/mraa/spi.h index 6902a6ed7..d53ec3ad2 100644 --- a/api/mraa/spi.h +++ b/api/mraa/spi.h @@ -111,13 +111,13 @@ mraa_result_t mraa_spi_frequency(mraa_spi_context dev, int hz); int mraa_spi_write(mraa_spi_context dev, uint8_t data); /** - *Write Two Bytes to the SPI device. + * Write Two Bytes to the SPI device. * * @param dev The Spi context * @param data Data to send * @return Data received on the miso line */ -uint16_t mraa_spi_write_word(mraa_spi_context dev, uint16_t data); +int mraa_spi_write_word(mraa_spi_context dev, uint16_t data); /** * Write Buffer of bytes to the SPI device. The pointer return has to be diff --git a/api/mraa/spi.hpp b/api/mraa/spi.hpp index e5ffb0903..80eaaaf9e 100644 --- a/api/mraa/spi.hpp +++ b/api/mraa/spi.hpp @@ -127,9 +127,9 @@ class Spi * Write single byte to the SPI device * * @param data the byte to send - * @return data received on the miso line + * @return data received on the miso line or -1 in case of error */ - uint16_t + int write_word(uint16_t data) { return mraa_spi_write_word(m_spi, (uint16_t) data); diff --git a/src/spi/spi.c b/src/spi/spi.c index cb2c6be6e..570c20765 100644 --- a/src/spi/spi.c +++ b/src/spi/spi.c @@ -267,7 +267,7 @@ mraa_spi_write(mraa_spi_context dev, uint8_t data) return (int) recv; } -uint16_t +int mraa_spi_write_word(mraa_spi_context dev, uint16_t data) { struct spi_ioc_transfer msg; @@ -286,7 +286,7 @@ mraa_spi_write_word(mraa_spi_context dev, uint16_t data) syslog(LOG_ERR, "spi: Failed to perform dev transfer"); return -1; } - return recv; + return (int) recv; } mraa_result_t