Data Structures | |
struct | KI2CConf |
i2c configuration structure More... | |
struct | KI2C |
i2c bus data structure More... | |
Enumerations | |
enum | KI2CNum { K_I2C_NO_BUS = 0, K_I2C1, K_I2C2, K_I2C3 } |
Available i2c buses. More... | |
enum | I2CAddressingMode { K_ADDRESSINGMODE_7BIT = 0, K_ADDRESSINGMODE_10BIT } |
Expected addressing mode of i2c bus. More... | |
enum | I2CRole { K_MASTER = 0, K_SLAVE } |
Expected role of i2c bus. More... | |
enum | KI2CStatus { I2C_OK = 0, I2C_ERROR, I2C_ERROR_AF, I2C_ERROR_ADDR_TIMEOUT, I2C_ERROR_TIMEOUT, I2C_ERROR_NACK, I2C_ERROR_TXE_TIMEOUT, I2C_ERROR_BTF_TIMEOUT, I2C_ERROR_NULL_HANDLE, I2C_ERROR_CONFIG } |
i2c function status More... | |
Functions | |
void | k_i2c_init (KI2CNum i2c, KI2CConf *conf) |
Setup and enable i2c bus. More... | |
void | k_i2c_terminate (KI2CNum i2c) |
Terminate i2c bus. More... | |
KI2CConf | k_i2c_conf_defaults (void) |
Generate KI2CConf with default I2C values. More... | |
void | k_i2c_default_init () |
Init DEFAULT_I2C bus with default config values. More... | |
void | k_i2c_default_dev_init (KI2CNum i2c) |
Initialize i2c device with default config values. More... | |
KI2CStatus | k_i2c_write (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
Transmit data over i2c bus to specified address. More... | |
KI2CStatus | k_i2c_read (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
Read data over i2c bus from specified address. More... | |
KI2C * | kprv_i2c_get (KI2CNum i2c) |
Fetches i2c bus data structure. More... | |
KI2CStatus | kprv_i2c_dev_init (KI2CNum i2c) |
Low level hal device initialization This is implemented by the device specific hal. More... | |
KI2CStatus | kprv_i2c_dev_terminate (KI2CNum i2c) |
Low level hal i2c termination This is implemented by the device specific hal. More... | |
KI2CStatus | kprv_i2c_master_write (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
Low level hal i2c write (as master) This is implemented by the device specific hal. More... | |
KI2CStatus | kprv_i2c_master_read (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
Low level hal i2c read (as master) This is implemented by the device specific hal. More... | |
KI2CStatus | kprv_i2c_slave_write (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
Low level hal i2c write (as slave) This is implemented by the device specific hal. More... | |
KI2CStatus | kprv_i2c_slave_read (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
Low level hal i2c read (as slave) This is implemented by the device specific hal. More... | |
Enumeration Type Documentation
enum I2CAddressingMode |
enum I2CRole |
enum KI2CNum |
enum KI2CStatus |
Function Documentation
void k_i2c_default_dev_init | ( | KI2CNum | i2c | ) |
Initialize i2c device with default config values.
- Parameters
-
i2c I2C bus num to initialize
void k_i2c_default_init | ( | ) |
Init DEFAULT_I2C bus with default config values.
Setup and enable i2c bus.
- Parameters
-
i2c i2c bus to initialize conf config values to initialize with
KI2CStatus k_i2c_read | ( | KI2CNum | i2c, |
uint16_t | addr, | ||
uint8_t * | ptr, | ||
int | len | ||
) |
Read data over i2c bus from specified address.
In order to ensure safe i2c sharing, this function is semaphore locked. There is one semaphore per bus. This function will block indefinitely while waiting for the semaphore.
- Parameters
-
i2c i2c bus to read from addr address of target i2c device ptr pointer to data buffer len length of data to read
- Returns
- int I2C_OK on success, I2C_ERROR on error
void k_i2c_terminate | ( | KI2CNum | i2c | ) |
Terminate i2c bus.
- Parameters
-
i2c i2c bus to terminate
KI2CStatus k_i2c_write | ( | KI2CNum | i2c, |
uint16_t | addr, | ||
uint8_t * | ptr, | ||
int | len | ||
) |
Transmit data over i2c bus to specified address.
In order to ensure safe i2c sharing, this function is semaphore locked. There is one semaphore per bus. This function will block indefinitely while waiting for the semaphore.
- Parameters
-
i2c i2c bus to transmit over addr address of target i2c device ptr pointer to data buffer len length of data in buffer
- Returns
- int I2C_OK on success, I2C_ERROR on error
KI2CStatus kprv_i2c_dev_init | ( | KI2CNum | i2c | ) |
Low level hal device initialization This is implemented by the device specific hal.
- Parameters
-
i2c i2c bus to initialize
- Returns
- KI2CStatus I2C_OK if success, otherwise specific error
KI2CStatus kprv_i2c_dev_terminate | ( | KI2CNum | i2c | ) |
Low level hal i2c termination This is implemented by the device specific hal.
- Parameters
-
i2c i2c bus to terminate
- Returns
- KI2CStatus I2C_OK if success, otherwise specific error
Fetches i2c bus data structure.
- Parameters
-
i2c number of i2c bus to fetch
- Returns
- KI2C* pointer to data structure
KI2CStatus kprv_i2c_master_read | ( | KI2CNum | i2c, |
uint16_t | addr, | ||
uint8_t * | ptr, | ||
int | len | ||
) |
Low level hal i2c read (as master) This is implemented by the device specific hal.
- Parameters
-
i2c i2c bus to read from addr i2c addr to read from ptr data buffer len length of data expected to read
- Returns
- KI2CStatus I2C_OK on success, I2C_ERROR on error
KI2CStatus kprv_i2c_master_write | ( | KI2CNum | i2c, |
uint16_t | addr, | ||
uint8_t * | ptr, | ||
int | len | ||
) |
Low level hal i2c write (as master) This is implemented by the device specific hal.
- Parameters
-
i2c i2c bus to write from addr i2c addr to write to ptr data buffer len length of data in buffer
- Returns
- KI2CStatus I2C_OK on success, I2C_ERROR on error
KI2CStatus kprv_i2c_slave_read | ( | KI2CNum | i2c, |
uint16_t | addr, | ||
uint8_t * | ptr, | ||
int | len | ||
) |
Low level hal i2c read (as slave) This is implemented by the device specific hal.
- Warning
- Not implemented as of v0.0.4
- Parameters
-
i2c i2c bus to read from addr i2c addr to read from ptr data buffer len length of data expected to read
- Returns
- KI2CStatus I2C_OK on success, I2C_ERROR on error
KI2CStatus kprv_i2c_slave_write | ( | KI2CNum | i2c, |
uint16_t | addr, | ||
uint8_t * | ptr, | ||
int | len | ||
) |
Low level hal i2c write (as slave) This is implemented by the device specific hal.
- Warning
- Not implemented as of v0.0.4
- Parameters
-
i2c i2c bus to write from addr i2c addr to write to ptr data buffer len length of data in buffer
- Returns
- KI2CStatus I2C_OK on success, I2C_ERROR on error