ChibiOS/HAL 9.0.0
hal_i2c.h File Reference

I2C Driver macros and structures. More...

#include "hal_i2c_lld.h"

Go to the source code of this file.

Macros

#define I2C_USE_MUTUAL_EXCLUSION   TRUE
 Enables the mutual exclusion APIs on the I2C bus.
#define I2C_ENABLE_SLAVE_MODE   FALSE
 Slave mode API enable switch.
#define I2C_SUPPORTS_SLAVE_MODE   FALSE
I2C bus error conditions
#define I2C_NO_ERROR   0x00
 No error.
#define I2C_BUS_ERROR   0x01
 Bus Error.
#define I2C_ARBITRATION_LOST   0x02
 Arbitration Lost.
#define I2C_ACK_FAILURE   0x04
 Acknowledge Failure.
#define I2C_OVERRUN   0x08
 Overrun/Underrun.
#define I2C_PEC_ERROR   0x10
 PEC Error in reception.
#define I2C_TIMEOUT   0x20
 Hardware timeout.
#define I2C_SMB_ALERT   0x40
 SMBus Alert.
Macro Functions
#define _i2c_wakeup_isr(i2cp)
 Wakes up the waiting thread notifying no errors.
#define _i2c_wakeup_error_isr(i2cp)
 Wakes up the waiting thread notifying errors.
#define i2cMasterTransmit(i2cp, addr, txbuf, txbytes, rxbuf, rxbytes)
 Wrap i2cMasterTransmitTimeout function with TIME_INFINITE timeout.
#define i2cMasterReceive(i2cp, addr, rxbuf, rxbytes)
 Wrap i2cMasterReceiveTimeout function with TIME_INFINITE timeout.
#define i2cSlaveIsAnswerRequired(i2cp)
 Answer required.

Enumerations

enum  i2cstate_t {
  I2C_UNINIT = 0 , I2C_STOP = 1 , I2C_READY = 2 , I2C_ACTIVE_TX = 3 ,
  I2C_ACTIVE_RX = 4 , I2C_LOCKED = 5
}
 Driver state machine possible states. More...

Functions

void i2cInit (void)
 I2C Driver initialization.
void i2cObjectInit (I2CDriver *i2cp)
 Initializes the standard part of a I2CDriver structure.
msg_t i2cStart (I2CDriver *i2cp, const I2CConfig *config)
 Configures and activates the I2C peripheral.
void i2cStop (I2CDriver *i2cp)
 Deactivates the I2C peripheral.
i2cflags_t i2cGetErrors (I2CDriver *i2cp)
 Returns the errors mask associated to the previous operation.
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.
msg_t i2cMasterReceiveTimeout (I2CDriver *i2cp, i2caddr_t addr, uint8_t *rxbuf, size_t rxbytes, sysinterval_t timeout)
 Receives data from the I2C bus.
void i2cAcquireBus (I2CDriver *i2cp)
 Gains exclusive access to the I2C bus.
void i2cReleaseBus (I2CDriver *i2cp)
 Releases exclusive access to the I2C bus.
msg_t i2cSlaveMatchAddress (I2CDriver *i2cp, i2caddr_t addr)
 Listen I2C bus for address match.
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 i2cSlaveTransmitTimeout (I2CDriver *i2cp, const uint8_t *txbuf, size_t txbytes, sysinterval_t timeout)
 Transmits data via the I2C bus as slave.

Detailed Description

I2C Driver macros and structures.

Definition in file hal_i2c.h.