32#if (HAL_USE_I2C == TRUE) || defined(__DOXYGEN__)
43#define I2C_NO_ERROR 0x00
44#define I2C_BUS_ERROR 0x01
45#define I2C_ARBITRATION_LOST 0x02
46#define I2C_ACK_FAILURE 0x04
47#define I2C_OVERRUN 0x08
48#define I2C_PEC_ERROR 0x10
50#define I2C_TIMEOUT 0x20
51#define I2C_SMB_ALERT 0x40
61#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
62#define I2C_USE_MUTUAL_EXCLUSION TRUE
69#if !defined(I2C_ENABLE_SLAVE_MODE)
70#define I2C_ENABLE_SLAVE_MODE FALSE
96#if !defined(I2C_SUPPORTS_SLAVE_MODE)
97#define I2C_SUPPORTS_SLAVE_MODE FALSE
100#if (I2C_SUPPORTS_SLAVE_MODE == FALSE) && (I2C_ENABLE_SLAVE_MODE == TRUE)
101#error "I2C slave mode not supported"
119#define _i2c_wakeup_isr(i2cp) do { \
120 osalSysLockFromISR(); \
121 osalThreadResumeI(&(i2cp)->thread, MSG_OK); \
122 osalSysUnlockFromISR(); \
132#define _i2c_wakeup_error_isr(i2cp) do { \
133 osalSysLockFromISR(); \
134 osalThreadResumeI(&(i2cp)->thread, MSG_RESET); \
135 osalSysUnlockFromISR(); \
142#define i2cMasterTransmit(i2cp, addr, txbuf, txbytes, rxbuf, rxbytes) \
143 (i2cMasterTransmitTimeout(i2cp, addr, txbuf, txbytes, rxbuf, rxbytes, \
150#define i2cMasterReceive(i2cp, addr, rxbuf, rxbytes) \
151 (i2cMasterReceiveTimeout(i2cp, addr, rxbuf, rxbytes, TIME_INFINITE))
153#if (I2C_ENABLE_SLAVE_MODE == TRUE) || defined(__DOXYGEN__)
165#define i2cSlaveIsAnswerRequired(i2cp) (((i2cp)->reply_required))
183 const uint8_t *txbuf,
size_t txbytes,
184 uint8_t *rxbuf,
size_t rxbytes,
188 uint8_t *rxbuf,
size_t rxbytes,
190#if I2C_USE_MUTUAL_EXCLUSION == TRUE
194#if I2C_ENABLE_SLAVE_MODE == TRUE
msg_t i2cSlaveTransmitTimeout(I2CDriver *i2cp, const uint8_t *txbuf, size_t txbytes, sysinterval_t timeout)
Transmits data via the I2C bus as slave.
msg_t i2cMasterReceiveTimeout(I2CDriver *i2cp, i2caddr_t addr, uint8_t *rxbuf, size_t rxbytes, sysinterval_t timeout)
Receives data from the I2C bus.
void i2cInit(void)
I2C Driver initialization.
void i2cObjectInit(I2CDriver *i2cp)
Initializes the standard part of a I2CDriver structure.
uint32_t i2cflags_t
Type of I2C Driver condition flags.
msg_t i2cStart(I2CDriver *i2cp, const I2CConfig *config)
Configures and activates the I2C peripheral.
struct hal_i2c_config I2CConfig
Type of a structure representing an I2C configuration.
i2cflags_t i2cGetErrors(I2CDriver *i2cp)
Returns the errors mask associated to the previous operation.
msg_t i2cSlaveReceiveTimeout(I2CDriver *i2cp, uint8_t *rxbuf, size_t rxbytes, sysinterval_t timeout)
Receive data via the I2C bus as slave and call handler.
msg_t i2cMasterTransmitTimeout(I2CDriver *i2cp, i2caddr_t addr, const uint8_t *txbuf, size_t txbytes, uint8_t *rxbuf, size_t rxbytes, sysinterval_t timeout)
Sends data via the I2C bus.
void i2cReleaseBus(I2CDriver *i2cp)
Releases exclusive access to the I2C bus.
i2cstate_t
Driver state machine possible states.
uint16_t i2caddr_t
Type representing an I2C address.
void i2cStop(I2CDriver *i2cp)
Deactivates the I2C peripheral.
msg_t i2cSlaveMatchAddress(I2CDriver *i2cp, i2caddr_t addr)
Listen I2C bus for address match.
void i2cAcquireBus(I2CDriver *i2cp)
Gains exclusive access to the I2C bus.
struct hal_i2c_driver I2CDriver
Type of a structure representing an I2C driver.
@ I2C_ACTIVE_TX
Transmitting.
@ I2C_UNINIT
Not initialized.
@ I2C_ACTIVE_RX
Receiving.
int32_t msg_t
Type of a message.
uint32_t sysinterval_t
Type of system time interval.
PLATFORM I2C subsystem low level driver header.