Skip to content

Commit 11d6f38

Browse files
committed
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).
1 parent aeabcc9 commit 11d6f38

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

drivers/I2C.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ class I2C {
117117
* @param repeated Repeated start, true - do not send stop at end
118118
*
119119
* @returns
120-
* 0 on success (ack),
121-
* non-0 on failure (nack)
120+
* 0 or non-zero - written number of bytes,
121+
* negative - I2C_ERROR_XXX status
122122
*/
123123
int write(int address, const char *data, int length, bool repeated = false);
124124

@@ -127,8 +127,9 @@ class I2C {
127127
* @param data data to write out on bus
128128
*
129129
* @returns
130-
* '1' if an ACK was received,
131-
* '0' otherwise
130+
* '0' - NAK was received
131+
* '1' - ACK was received,
132+
* '2' - timeout
132133
*/
133134
int write(int data);
134135

hal/i2c_api.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop);
117117
* @param data The buffer for sending
118118
* @param length Number of bytes to write
119119
* @param stop Stop to be generated after the transfer is done
120-
* @return Number of written bytes
120+
* @return
121+
* zero or non-zero - Number of written bytes
122+
* negative - I2C_ERROR_XXX status
121123
*/
122124
int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop);
123125

0 commit comments

Comments
 (0)