hw/hal: Define a set of I2C error codes
HAL I2C implementations currently return MCU-specific status code.  This
commit introduces a generic set of I2C error codes for all
implementations to return.
@@ -62,6 +62,23 @@ extern "C" {
* :c:func:`hal_i2c_read()`; --- read back data, setting 'last_op' to '1'
*/
+/*** I2C status codes (0=success). */
+
+/** Unknown error. */
+#define HAL_I2C_ERR_UNKNOWN 1
+
+/** Invalid argument. */
+#define HAL_I2C_ERR_INVAL 2
+
+/** MCU failed to report result of I2C operation. */
+#define HAL_I2C_ERR_TIMEOUT 3
+
+/** Slave responded to address with NACK. */
+#define HAL_I2C_ERR_ADDR_NACK 4
+
+/** Slave responded to data byte with NACK. */
+#define HAL_I2C_ERR_DATA_NACK 5
+
/**
* When sending a packet, use this structure to pass the arguments.
*/
@@ -77,8 +94,8 @@ struct hal_i2c_master_data {
* writing a 0x81 in its protocol, you would pass
* only the top 7-bits to this function as 0x40
*/
- uint8_t address
- /** Number of buffer bytes to transmit or receive */;
+ uint8_t address;
+ /** Number of buffer bytes to transmit or receive */
uint16_t len;
/** Buffer space to hold the transmit or receive */
uint8_t *buffer;
