libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Access functions for the I2C Controller More...
Functions | |
void | i2c_enable (uint32_t i2c, uint32_t mode) |
Enable I2C peripheral. More... | |
void | i2c_disable (uint32_t i2c) |
Disable I2C peripheral. More... | |
void | i2c_start_tx (uint32_t i2c) |
Start I2C transmission. More... | |
void | i2c_start_rx (uint32_t i2c) |
Start I2C reception. More... | |
void | i2c_send_stop (uint32_t i2c) |
Signal stop on I2C line. More... | |
void | i2c_set_fast_mode (uint32_t i2c) |
Select Fast (400kHz) mode. More... | |
void | i2c_set_standard_mode (uint32_t i2c) |
Select Standard (100kHz) mode. More... | |
void | i2c_set_frequency (uint32_t i2c, uint32_t freq) |
Set I2C frequency. More... | |
void | i2c_send_data (uint32_t i2c, uint8_t data) |
Write Data to TXD register to be sent. More... | |
uint8_t | i2c_get_data (uint32_t i2c) |
Read Data from RXD register. More... | |
void | i2c_select_pins (uint32_t i2c, uint32_t scl_pin, uint32_t sda_pin) |
Select GPIO pins to be used by this peripheral. More... | |
void | i2c_set_address (uint32_t i2c, uint8_t addr) |
Set 7bit I2C address of the device you wish to communicate with. More... | |
void | i2c_resume (uint32_t i2c) |
Resume I2C transaction. More... | |
void | i2c_set_shorts (uint32_t i2c, uint32_t shorts) |
Configure event -> task shortcuts. More... | |
void | i2c_set_tx_buffer (uint32_t i2c, const uint8_t *buffer, uint8_t len) |
Configure I2C transmit buffer properties. More... | |
void | i2c_set_rx_buffer (uint32_t i2c, uint8_t *buffer, uint8_t len) |
Configure I2C receive buffer properties. More... | |
Access functions for the I2C Controller
LGPL License Terms libopencm3 License
void i2c_disable | ( | uint32_t | i2c | ) |
Disable I2C peripheral.
[in] | i2c | i2c peripheral base, see I2C instances |
Definition at line 52 of file i2c_common.c.
References I2C_ENABLE.
void i2c_enable | ( | uint32_t | i2c, |
uint32_t | mode | ||
) |
Enable I2C peripheral.
[in] | i2c | i2c peripheral base, see I2C instances |
[in] | mode | i2c I2C peripheral mode |
Definition at line 43 of file i2c_common.c.
References I2C_ENABLE.
uint8_t i2c_get_data | ( | uint32_t | i2c | ) |
Read Data from RXD register.
Reads one byte from reception buffer. This API is only available if I2C_MODE_LEGACY is activated.
[in] | i2c | i2c peripheral base, see I2C instances |
Definition at line 140 of file i2c_common.c.
References I2C_RXD.
void i2c_resume | ( | uint32_t | i2c | ) |
Resume I2C transaction.
This function is unusual, but required to implement i2c exchange with this peripheral.
[in] | i2c | i2c peripheral base, see I2C instances |
Definition at line 190 of file i2c_common.c.
References I2C_TASK_RESUME, and PERIPH_TRIGGER_TASK.
void i2c_select_pins | ( | uint32_t | i2c, |
uint32_t | scl_pin, | ||
uint32_t | sda_pin | ||
) |
Select GPIO pins to be used by this peripheral.
Configures GPIO pins assigned to SCL and SDA signals. These pins are only occupied by I2C peripheral whenever it is enabled using i2c_enable. It is possible to ignore any given signal and not map it to pin by using special value of GPIO_UNCONNECTED instead of GPIO Pin Identifiers values.
This needs to be configured when no transaction is in progress.
[in] | i2c | i2c peripheral base, see I2C instances |
[in] | scl_pin | GPIO pin used for SCL signal |
[in] | sda_pin | GPIO pin used for SDA signal |
Definition at line 158 of file i2c_common.c.
References __GPIO2PIN, GPIO_UNCONNECTED, I2C_PSELSCL, and I2C_PSELSDA.
void i2c_send_data | ( | uint32_t | i2c, |
uint8_t | data | ||
) |
Write Data to TXD register to be sent.
Writes one byte into transmission buffer. This API is only available if I2C_MODE_LEGACY is activated.
[in] | i2c | i2c peripheral base, see I2C instances |
[in] | data | byte to send next. |
Definition at line 127 of file i2c_common.c.
References I2C_TXD.
void i2c_send_stop | ( | uint32_t | i2c | ) |
Signal stop on I2C line.
[in] | i2c | i2c peripheral base, see I2C instances. |
Definition at line 82 of file i2c_common.c.
References I2C_TASK_STOP.
void i2c_set_address | ( | uint32_t | i2c, |
uint8_t | addr | ||
) |
Set 7bit I2C address of the device you wish to communicate with.
[in] | i2c | i2c peripheral base, see I2C instances |
[in] | addr | device address (7bit). |
Definition at line 178 of file i2c_common.c.
References I2C_ADDRESS.
void i2c_set_fast_mode | ( | uint32_t | i2c | ) |
Select Fast (400kHz) mode.
[in] | i2c | i2c peripheral base, see I2C instances. |
Definition at line 91 of file i2c_common.c.
References I2C_FREQUENCY, and I2C_FREQUENCY_400K.
void i2c_set_frequency | ( | uint32_t | i2c, |
uint32_t | freq | ||
) |
Set I2C frequency.
In addition to Standard (100kHz) and Fast (400kHz) modes this peripheral also supports 250kHz mode.
[in] | i2c | i2c peripheral base, see I2C instances |
[in] | freq | frequency constant. See I2C frequency constants for details and note that this is not actually a frequency in Hz or kHz. |
Definition at line 114 of file i2c_common.c.
References I2C_FREQUENCY.
void i2c_set_rx_buffer | ( | uint32_t | i2c, |
uint8_t * | buffer, | ||
uint8_t | len | ||
) |
Configure I2C receive buffer properties.
Configures receive buffer for EasyDMA transaction. This API is only available if I2C_MODE_MASTER mode is activated.
Configures linear RX buffer for EasyDMA transmission.
[in] | i2c | i2c peripheral base, see I2C instances |
[in] | buffer | address of buffer start |
[in] | len | length of the buffer |
Definition at line 54 of file i2c.c.
References I2C_RXDLIST, I2C_RXDMAXCNT, and I2C_RXDPTR.
void i2c_set_shorts | ( | uint32_t | i2c, |
uint32_t | shorts | ||
) |
Configure event -> task shortcuts.
Sets new shortcut configuration bitmask for I2C peripheral.
[in] | i2c | i2c peripheral base, see I2C instances |
[in] | shorts | I2C event -> task shortcuts activated |
Definition at line 202 of file i2c_common.c.
References I2C_SHORTS.
void i2c_set_standard_mode | ( | uint32_t | i2c | ) |
Select Standard (100kHz) mode.
[in] | i2c | i2c peripheral base, see I2C instances. |
Definition at line 100 of file i2c_common.c.
References I2C_FREQUENCY, and I2C_FREQUENCY_100K.
void i2c_set_tx_buffer | ( | uint32_t | i2c, |
const uint8_t * | buffer, | ||
uint8_t | len | ||
) |
Configure I2C transmit buffer properties.
Configures transmit buffer for EasyDMA transaction. This API is only available if I2C_MODE_MASTER mode is activated.
Configures linear TX buffer for EasyDMA transmission.
[in] | i2c | i2c peripheral base, see I2C instances |
[in] | buffer | address of buffer start |
[in] | len | length of data in the buffer |
Definition at line 37 of file i2c.c.
References I2C_TXDLIST, I2C_TXDMAXCNT, and I2C_TXDPTR.
void i2c_start_rx | ( | uint32_t | i2c | ) |
Start I2C reception.
[in] | i2c | i2c peripheral base, see I2C instances. |
Definition at line 73 of file i2c_common.c.
References I2C_TASK_STARTRX.
void i2c_start_tx | ( | uint32_t | i2c | ) |
Start I2C transmission.
Starts STARTTX task, which generates start condition on I2C bus and transmits address previously configured by i2c_set_address.
[in] | i2c | i2c peripheral base, see I2C instances. |
Definition at line 64 of file i2c_common.c.
References I2C_TASK_STARTTX.