I2C - correct return values for write functions

The correction was made based on the i2c hal, and some target implementations
(early implementations like nxp 1768, freescale KLXX).
pull/3467/head
0xc0170 2016-11-21 11:26:02 +00:00 committed by Anna Bridge
parent ec29f2e3f2
commit 58bf08b688
2 changed files with 8 additions and 5 deletions

View File

@ -117,8 +117,8 @@ public:
* @param repeated Repeated start, true - do not send stop at end * @param repeated Repeated start, true - do not send stop at end
* *
* @returns * @returns
* 0 on success (ack), * 0 or non-zero - written number of bytes,
* non-0 on failure (nack) * negative - I2C_ERROR_XXX status
*/ */
int write(int address, const char *data, int length, bool repeated = false); int write(int address, const char *data, int length, bool repeated = false);
@ -127,8 +127,9 @@ public:
* @param data data to write out on bus * @param data data to write out on bus
* *
* @returns * @returns
* '1' if an ACK was received, * '0' - NAK was received
* '0' otherwise * '1' - ACK was received,
* '2' - timeout
*/ */
int write(int data); int write(int data);

View File

@ -117,7 +117,9 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop);
* @param data The buffer for sending * @param data The buffer for sending
* @param length Number of bytes to write * @param length Number of bytes to write
* @param stop Stop to be generated after the transfer is done * @param stop Stop to be generated after the transfer is done
* @return Number of written bytes * @return
* zero or non-zero - Number of written bytes
* negative - I2C_ERROR_XXX status
*/ */
int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop); int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop);