25#include "hal/buffer.h"
44#define I2C_EVENT_ERROR (1 << 1)
49#define I2C_EVENT_ERROR_NO_SLAVE (1 << 2)
54#define I2C_EVENT_TRANSFER_COMPLETE (1 << 3)
63#define I2C_EVENT_TRANSFER_EARLY_NACK (1 << 4)
68#define I2C_EVENT_ALL (I2C_EVENT_ERROR | I2C_EVENT_TRANSFER_COMPLETE | I2C_EVENT_ERROR_NO_SLAVE | I2C_EVENT_TRANSFER_EARLY_NACK)
94 I2C_ERROR_NO_SLAVE = -1,
95 I2C_ERROR_BUS_BUSY = -2,
96 I2C_ERROR_INVALID_USAGE = -3,
460void i2c_transfer_asynch(
i2c_t *obj,
const void *tx,
size_t tx_length,
void *rx,
size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event,
DMAUsage hint);
void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask)
Configure I2C address.
int i2c_slave_receive(i2c_t *obj)
Check to see if the I2C slave has been addressed.
int i2c_slave_write(i2c_t *obj, const char *data, int length)
Configure I2C as slave or master.
int i2c_slave_read(i2c_t *obj, char *data, int length)
Read specified number of bytes from an I2C master.
void i2c_slave_mode(i2c_t *obj, int enable_slave)
Configure I2C as slave or master.
uint8_t i2c_active(i2c_t *obj)
Attempts to determine if the I2C peripheral is already in use.
uint32_t i2c_irq_handler_asynch(i2c_t *obj)
The asynchronous IRQ handler.
void i2c_abort_asynch(i2c_t *obj)
Abort asynchronous transfer.
void i2c_transfer_asynch(i2c_t *obj, const void *tx, size_t tx_length, void *rx, size_t rx_length, uint32_t address, uint32_t stop, uint32_t handler, uint32_t event, DMAUsage hint)
Start I2C asynchronous transfer.
void i2c_init(i2c_t *obj, PinName sda, PinName scl)
Initialize the I2C peripheral.
i2c_capabilities_t const * i2c_get_capabilities()
Fills the given i2c_capabilities_t structure with the capabilities of the I2C peripheral.
const PinMap * i2c_slave_sda_pinmap(void)
Get the pins that support I2C SDA.
const PinMap * i2c_slave_scl_pinmap(void)
Get the pins that support I2C SCL.
void i2c_init_direct(i2c_t *obj, const i2c_pinmap_t *pinmap)
Initialize the I2C peripheral.
int i2c_byte_write(i2c_t *obj, int data)
Write one byte.
const PinMap * i2c_master_scl_pinmap(void)
Get the pins that support I2C SCL.
int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop)
Blocking write of data.
int i2c_start(i2c_t *obj)
Send START command.
int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
Blocking read of data.
int i2c_stop(i2c_t *obj)
Send STOP command.
void i2c_reset(i2c_t *obj)
Reset I2C peripheral.
void i2c_frequency(i2c_t *obj, int hz)
Configure the I2C frequency.
int i2c_byte_read(i2c_t *obj, int last)
Read one byte.
const PinMap * i2c_master_sda_pinmap(void)
Get the pins that support I2C SDA.
void i2c_free(i2c_t *obj)
Release a I2C object.
mbed_hal_i2c_state
Enumeration of states the I2C HAL can be in.
DMAUsage
Enumeration of possible DMA usage hints.
@ MBED_HAL_I2C_STATE_ASYNC_TRANSACTION
In an async transaction.
@ MBED_HAL_I2C_STATE_BYTE_READ
In the middle of a single-byte read.
@ MBED_HAL_I2C_STATE_ADDRESSED
write_byte() has been called after start()
@ MBED_HAL_I2C_STATE_IDLE
Not in the middle of a transaction.
@ MBED_HAL_I2C_STATE_STARTED
start() has been called but not write_byte() or read_byte()
@ MBED_HAL_I2C_STATE_BYTE_WRITE
In the middle of a single-byte read.
@ MBED_HAL_I2C_STATE_HOLDING_BUS
We just completed a transaction with the repeated option set, so we are still holding the bus.
@ I2C_ERROR_OTHER
Other internal error.
Generic buffer structure.
Describes the capabilities of an I2C peripheral.
bool supports_single_byte
If true, the single-byte API is implemented. Otherwise, it is a no-op.
bool supports_zero_length_transfer_single_byte
If true, the single-byte API supports a zero-length transfer (one that has only a start,...
bool single_byte_start_cond_delayed
If true, generation of the start condition in single-byte mode is delayed until the address is transm...
bool single_byte_address_delayed
If true, transmission of the address in single-byte mode is delayed until the first data byte is read...
bool supports_zero_length_transfer_transaction
If true, the transaction-based API supports a zero-length transfer (one that has only a start,...
enum mbed_hal_i2c_state state
I2C state. Managed by the I2C class, available for use by the HAL.