Skip to content

Commit

Permalink
spi: mraa_spi_write_word can now return -1 in error cases
Browse files Browse the repository at this point in the history
Signed-off-by: Brendan Le Foll <[email protected]>
  • Loading branch information
arfoll committed Apr 25, 2016
1 parent b258867 commit c524c3d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions api/mraa/spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions api/mraa/spi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/spi/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit c524c3d

Please sign in to comment.