CuVoodoo STM32F1 firmware template
|
library to communicate using I2C as master (API) More...
Go to the source code of this file.
Enumerations | |
enum | i2c_master_rc { I2C_MASTER_RC_NONE = 0, I2C_MASTER_RC_START_STOP_IN_PROGESS, I2C_MASTER_RC_NOT_MASTER, I2C_MASTER_RC_NOT_TRANSMIT, I2C_MASTER_RC_NOT_RECEIVE, I2C_MASTER_RC_NOT_READY, I2C_MASTER_RC_NAK } |
I2C return codes. More... | |
Functions | |
void | i2c_master_setup (uint32_t i2c, uint16_t frequency) |
setup I2C peripheral More... | |
void | i2c_master_release (uint32_t i2c) |
release I2C peripheral More... | |
void | i2c_master_reset (uint32_t i2c) |
reset I2C peripheral, fixing any locked state More... | |
bool | i2c_master_check_signals (uint32_t i2c) |
check if SDA and SCL signals are high More... | |
enum i2c_master_rc | i2c_master_start (uint32_t i2c) |
send start condition More... | |
enum i2c_master_rc | i2c_master_select_slave (uint32_t i2c, uint16_t slave, bool address_10bit, bool write) |
select I2C slave device More... | |
enum i2c_master_rc | i2c_master_read (uint32_t i2c, uint8_t *data, size_t data_size) |
read data over I2C More... | |
enum i2c_master_rc | i2c_master_write (uint32_t i2c, const uint8_t *data, size_t data_size) |
write data over I2C More... | |
enum i2c_master_rc | i2c_master_stop (uint32_t i2c) |
sent stop condition More... | |
enum i2c_master_rc | i2c_master_slave_read (uint32_t i2c, uint16_t slave, bool address_10bit, uint8_t *data, size_t data_size) |
read data from slave device More... | |
enum i2c_master_rc | i2c_master_slave_write (uint32_t i2c, uint16_t slave, bool address_10bit, const uint8_t *data, size_t data_size) |
write data to slave device More... | |
enum i2c_master_rc | i2c_master_address_read (uint32_t i2c, uint16_t slave, bool address_10bit, const uint8_t *address, size_t address_size, uint8_t *data, size_t data_size) |
read data at specific address from an I2C memory slave More... | |
enum i2c_master_rc | i2c_master_address_write (uint32_t i2c, uint16_t slave, bool address_10bit, const uint8_t *address, size_t address_size, const uint8_t *data, size_t data_size) |
write data at specific address on an I2C memory slave More... | |
library to communicate using I2C as master (API)
Definition in file i2c_master.h.
enum i2c_master_rc |
I2C return codes.
Definition at line 24 of file i2c_master.h.
enum i2c_master_rc i2c_master_address_read | ( | uint32_t | i2c, |
uint16_t | slave, | ||
bool | address_10bit, | ||
const uint8_t * | address, | ||
size_t | address_size, | ||
uint8_t * | data, | ||
size_t | data_size | ||
) |
read data at specific address from an I2C memory slave
[in] | i2c | I2C base address |
[in] | slave | I2C address of slave device to select |
[in] | address_10bit | if the I2C slave address is 10 bits wide |
[in] | address | memory address of slave to read from |
[in] | address_size | address size in bytes |
[out] | data | array to store bytes read |
[in] | data_size | number of bytes to read |
Definition at line 506 of file i2c_master.c.
enum i2c_master_rc i2c_master_address_write | ( | uint32_t | i2c, |
uint16_t | slave, | ||
bool | address_10bit, | ||
const uint8_t * | address, | ||
size_t | address_size, | ||
const uint8_t * | data, | ||
size_t | data_size | ||
) |
write data at specific address on an I2C memory slave
[in] | i2c | I2C base address |
[in] | slave | I2C address of slave device to select |
[in] | address_10bit | if the I2C slave address is 10 bits wide |
[in] | address | memory address of slave to write to |
[in] | address_size | address size in bytes |
[in] | data | array of byte to write to slave |
[in] | data_size | number of bytes to write |
Definition at line 552 of file i2c_master.c.
bool i2c_master_check_signals | ( | uint32_t | i2c | ) |
check if SDA and SCL signals are high
[in] | i2c | I2C base address |
Definition at line 225 of file i2c_master.c.
enum i2c_master_rc i2c_master_read | ( | uint32_t | i2c, |
uint8_t * | data, | ||
size_t | data_size | ||
) |
read data over I2C
[in] | i2c | I2C base address |
[out] | data | array to store bytes read |
[in] | data_size | number of bytes to read |
Definition at line 356 of file i2c_master.c.
void i2c_master_release | ( | uint32_t | i2c | ) |
release I2C peripheral
[in] | i2c | I2C base address |
Definition at line 211 of file i2c_master.c.
void i2c_master_reset | ( | uint32_t | i2c | ) |
reset I2C peripheral, fixing any locked state
[in] | i2c | I2C base address |
Definition at line 235 of file i2c_master.c.
enum i2c_master_rc i2c_master_select_slave | ( | uint32_t | i2c, |
uint16_t | slave, | ||
bool | address_10bit, | ||
bool | write | ||
) |
select I2C slave device
[in] | i2c | I2C base address |
[in] | slave | I2C address of slave device to select |
[in] | address_10bit | if the I2C slave address is 10 bits wide |
[in] | write | this transaction will be followed by a read (false) or write (true) operation |
Definition at line 287 of file i2c_master.c.
void i2c_master_setup | ( | uint32_t | i2c, |
uint16_t | frequency | ||
) |
setup I2C peripheral
[in] | i2c | I2C base address |
[in] | frequency | frequency to use in kHz (1-400) |
Definition at line 173 of file i2c_master.c.
enum i2c_master_rc i2c_master_slave_read | ( | uint32_t | i2c, |
uint16_t | slave, | ||
bool | address_10bit, | ||
uint8_t * | data, | ||
size_t | data_size | ||
) |
read data from slave device
[in] | i2c | I2C base address |
[in] | slave | I2C address of slave device to select |
[in] | address_10bit | if the I2C slave address is 10 bits wide |
[out] | data | array to store bytes read |
[in] | data_size | number of bytes to read |
Definition at line 448 of file i2c_master.c.
enum i2c_master_rc i2c_master_slave_write | ( | uint32_t | i2c, |
uint16_t | slave, | ||
bool | address_10bit, | ||
const uint8_t * | data, | ||
size_t | data_size | ||
) |
write data to slave device
[in] | i2c | I2C base address |
[in] | slave | I2C address of slave device to select |
[in] | address_10bit | if the I2C slave address is 10 bits wide |
[in] | data | array of byte to write to slave |
[in] | data_size | number of bytes to write |
Definition at line 477 of file i2c_master.c.
enum i2c_master_rc i2c_master_start | ( | uint32_t | i2c | ) |
send start condition
[in] | i2c | I2C base address |
Definition at line 265 of file i2c_master.c.
enum i2c_master_rc i2c_master_stop | ( | uint32_t | i2c | ) |
sent stop condition
[in] | i2c | I2C base address |
Definition at line 425 of file i2c_master.c.
enum i2c_master_rc i2c_master_write | ( | uint32_t | i2c, |
const uint8_t * | data, | ||
size_t | data_size | ||
) |
write data over I2C
[in] | i2c | I2C base address |
[in] | data | array of byte to write to slave |
[in] | data_size | number of bytes to write |
Definition at line 391 of file i2c_master.c.