Data Structures | |
struct | KI2CConf |
struct | KI2C |
Macros | |
#define | K_NUM_I2CS YOTTA_CFG_HARDWARE_I2CCOUNT |
KubOS-HAL I2C Interface. More... | |
#define | DEFAULT_I2C YOTTA_CFG_HARDWARE_DEFAULTS_I2C |
Enumerations | |
enum | KI2CNum { K_I2C1 = 0, K_I2C2 = 1 } |
enum | I2CAddressingMode { K_ADDRESSINGMODE_7BIT = 0, K_ADDRESSINGMODE_10BIT } |
enum | I2CRole { K_MASTER = 0, K_SLAVE } |
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 } |
Functions | |
void | k_i2c_init (KI2CNum i2c, KI2CConf *conf) |
void | k_i2c_terminate (KI2CNum i2c) |
KI2CConf | k_i2c_conf_defaults (void) |
void | k_i2c_default_init () |
void | k_i2c_default_dev_init (KI2CNum i2c) |
KI2CStatus | k_i2c_write (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
KI2CStatus | k_i2c_read (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
KI2C * | kprv_i2c_get (KI2CNum i2c) |
void | kprv_i2c_dev_init (KI2CNum i2c) |
void | kprv_i2c_dev_terminate (KI2CNum i2c) |
KI2CStatus | kprv_i2c_master_write (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
KI2CStatus | kprv_i2c_master_read (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
KI2CStatus | kprv_i2c_slave_write (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
KI2CStatus | kprv_i2c_slave_read (KI2CNum i2c, uint16_t addr, uint8_t *ptr, int len) |
Macro Definition Documentation
#define DEFAULT_I2C YOTTA_CFG_HARDWARE_DEFAULTS_I2C |
#define K_NUM_I2CS YOTTA_CFG_HARDWARE_I2CCOUNT |
KubOS-HAL I2C Interface.
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
void 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
void 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
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