Skip to content

Commit

Permalink
I2C - correct return values for write functions
Browse files Browse the repository at this point in the history
The correction was made based on the i2c hal, and some target implementations
(early implementations like nxp 1768, freescale KLXX).
  • Loading branch information
0xc0170 committed Nov 21, 2016
1 parent aeabcc9 commit 11d6f38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions drivers/I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ class I2C {
* @param repeated Repeated start, true - do not send stop at end
*
* @returns
* 0 on success (ack),
* non-0 on failure (nack)
* 0 or non-zero - written number of bytes,
* negative - I2C_ERROR_XXX status
*/
int write(int address, const char *data, int length, bool repeated = false);

Expand All @@ -127,8 +127,9 @@ class I2C {
* @param data data to write out on bus
*
* @returns
* '1' if an ACK was received,
* '0' otherwise
* '0' - NAK was received
* '1' - ACK was received,
* '2' - timeout
*/
int write(int data);

Expand Down
4 changes: 3 additions & 1 deletion hal/i2c_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 length Number of bytes to write
* @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);

Expand Down

0 comments on commit 11d6f38

Please sign in to comment.