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)
84typedef struct i2c_s
i2c_t;
89 I2C_ERROR_NO_SLAVE = -1,
90 I2C_ERROR_BUS_BUSY = -2,
91 I2C_ERROR_INVALID_USAGE = -3
370void 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.
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 sending 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 reading 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.
DMAUsage
Enumeration of possible DMA usage hints.
Generic buffer structure.
Asynch I2C HAL structure.