|
SmartSnippets DA1459x SDK
|
Inter Integrated Circuit adapter. More...
Files | |
| file | ad_i2c.h |
| I2C device access API. | |
Data Structures | |
| struct | ad_i2c_io_conf_t |
| I2C I/O configuration. More... | |
| struct | ad_i2c_driver_conf_t |
| I2C driver configuration. More... | |
| struct | ad_i2c_controller_conf_t |
| I2C controller configuration. More... | |
Macros | |
| #define | CONFIG_I2C_USE_ASYNC_TRANSACTIONS (1) |
| Controls whether I2C asynchronous transaction API will be used. More... | |
| #define | CONFIG_I2C_USE_SYNC_TRANSACTIONS (1) |
| Controls whether I2C synchronous transaction API will be used. More... | |
Typedefs | |
| typedef void * | ad_i2c_handle_t |
| I2C Handle returned by ad_i2c_open() | |
| typedef void(* | ad_i2c_user_cb) (void *user_data, HW_I2C_ABORT_SOURCE error) |
| Asynchronous callback function. More... | |
Enumerations | |
| enum | AD_I2C_ERROR |
| I2C adapter error codes. More... | |
Functions | |
| void | ad_i2c_init (void) |
| Initialize adapter. More... | |
| ad_i2c_handle_t | ad_i2c_open (const ad_i2c_controller_conf_t *conf) |
| Open I2C controller. More... | |
| int | ad_i2c_reconfig (ad_i2c_handle_t p, const ad_i2c_driver_conf_t *conf) |
| Reconfigure I2C controller. More... | |
| int | ad_i2c_close (ad_i2c_handle_t p, bool force) |
| Close I2C controller. More... | |
| int | ad_i2c_io_config (HW_I2C_ID id, const ad_i2c_io_conf_t *io, AD_IO_CONF_STATE state) |
| Initialize controller pins to on / off io configuration. More... | |
| int | ad_i2c_write (ad_i2c_handle_t p, const uint8_t *wbuf, size_t wlen, uint8_t condition_flags) |
| Perform a blocking write transaction. More... | |
| int | ad_i2c_write_with_to (ad_i2c_handle_t p, const uint8_t *wbuf, size_t wlen, uint8_t condition_flags, OS_TICK_TIME timeout) |
| Perform a blocking write transaction with time out. More... | |
| int | ad_i2c_read (ad_i2c_handle_t p, uint8_t *rbuf, size_t rlen, uint8_t condition_flags) |
| Perform a blocking read transaction. More... | |
| int | ad_i2c_read_with_to (ad_i2c_handle_t p, uint8_t *rbuf, size_t rlen, uint8_t condition_flags, OS_TICK_TIME timeout) |
| Perform a blocking read transaction with time out. More... | |
| int | ad_i2c_write_read (ad_i2c_handle_t p, const uint8_t *wbuf, size_t wlen, uint8_t *rbuf, size_t rlen, uint8_t condition_flags) |
| Perform synchronous write/read transaction. More... | |
| int | ad_i2c_write_read_with_to (ad_i2c_handle_t p, const uint8_t *wbuf, size_t wlen, uint8_t *rbuf, size_t rlen, uint8_t condition_flags, OS_TICK_TIME timeout) |
| Perform synchronous write/read transaction with time out. More... | |
| void | ad_i2c_wait_while_master_busy (ad_i2c_handle_t p) |
| Wait while I2C master device is busy. More... | |
| int | ad_i2c_write_async (ad_i2c_handle_t p, const uint8_t *wbuf, size_t wlen, ad_i2c_user_cb cb, void *user_data, uint8_t condition_flags) |
| Perform a non blocking write transaction. More... | |
| int | ad_i2c_read_async (ad_i2c_handle_t p, uint8_t *rbuf, size_t rlen, ad_i2c_user_cb cb, void *user_data, uint8_t condition_flags) |
| Perform a non blocking read transaction. More... | |
| int | ad_i2c_write_read_async (ad_i2c_handle_t p, const uint8_t *wbuf, size_t wlen, uint8_t *rbuf, size_t rlen, ad_i2c_user_cb cb, void *user_data, uint8_t condition_flags) |
| Perform write and asynchronous read I2C transaction. More... | |
Inter Integrated Circuit adapter.
| #define CONFIG_I2C_USE_ASYNC_TRANSACTIONS (1) |
Controls whether I2C asynchronous transaction API will be used.
I2C asynchronous transaction API (see "ad_i2c_xx_async" API) maintains state in RAM for every I2C bus declared. If the API is not to be used, setting this macro to 0 will save RAM.
| #define CONFIG_I2C_USE_SYNC_TRANSACTIONS (1) |
Controls whether I2C synchronous transaction API will be used.
I2C synchronous transaction API (see "ad_i2c_write_read", "ad_i2c_write", "ad_i2c_read" functions) maintains state in retention RAM for every I2C bus declared. If the API is not to be used, setting this macro to 0 will save retention RAM.
| typedef void(* ad_i2c_user_cb) (void *user_data, HW_I2C_ABORT_SOURCE error) |
Asynchronous callback function.
| enum AD_I2C_ERROR |
I2C adapter error codes.
| int ad_i2c_close | ( | ad_i2c_handle_t | p, |
| bool | force | ||
| ) |
Close I2C controller.
This function:
| [in] | p | handle returned from ad_i2c_open() |
| [in] | force | force close even if controller is occupied |
| void ad_i2c_init | ( | void | ) |
Initialize adapter.
| int ad_i2c_io_config | ( | HW_I2C_ID | id, |
| const ad_i2c_io_conf_t * | io, | ||
| AD_IO_CONF_STATE | state | ||
| ) |
Initialize controller pins to on / off io configuration.
This function should be called for setting pins to the correct level before external devices are powered up (e.g on system init). It does not need to be called before every ad_i2c_open() call.
| [in] | id | controller instance |
| [in] | io | controller io configuration |
| [in] | state | on/off io configuration |
| ad_i2c_handle_t ad_i2c_open | ( | const ad_i2c_controller_conf_t * | conf | ) |
Open I2C controller.
This function:
| [in] | conf | controller configuration |
| int ad_i2c_read | ( | ad_i2c_handle_t | p, |
| uint8_t * | rbuf, | ||
| size_t | rlen, | ||
| uint8_t | condition_flags | ||
| ) |
Perform a blocking read transaction.
This function performs a synchronous read only transaction
| [in] | p | handle returned from ad_i2c_open() |
| [out] | rbuf | buffer for incoming data |
| [in] | rlen | number of bytes to read |
| [in] | condition_flags | Possible values for flags are: HW_I2C_F_NONE HW_I2C_F_ADD_STOP HW_I2C_F_ADD_RESTART |
| int ad_i2c_read_async | ( | ad_i2c_handle_t | p, |
| uint8_t * | rbuf, | ||
| size_t | rlen, | ||
| ad_i2c_user_cb | cb, | ||
| void * | user_data, | ||
| uint8_t | condition_flags | ||
| ) |
Perform a non blocking read transaction.
This function performs an asynchronous read only transaction Caller task should retry until function returns no error Callback will be called when transaction is completed
| [in] | p | handle returned from ad_i2c_open() |
| [out] | rbuf | buffer for incoming data |
| [in] | rlen | number of bytes to read |
| [in] | cb | callback to call after transaction is over (from ISR context) |
| [in] | user_data | user data passed to cb callback |
| [in] | condition_flags | Possible values for flags are: HW_I2C_F_NONE HW_I2C_F_ADD_STOP HW_I2C_F_ADD_RESTART |
| int ad_i2c_read_with_to | ( | ad_i2c_handle_t | p, |
| uint8_t * | rbuf, | ||
| size_t | rlen, | ||
| uint8_t | condition_flags, | ||
| OS_TICK_TIME | timeout | ||
| ) |
Perform a blocking read transaction with time out.
This function performs a synchronous read only transaction
| [in] | p | handle returned from ad_i2c_open() |
| [out] | rbuf | buffer for incoming data |
| [in] | rlen | number of bytes to read |
| [in] | condition_flags | Possible values for flags are: HW_I2C_F_NONE HW_I2C_F_ADD_STOP HW_I2C_F_ADD_RESTART |
| [in] | timeout | time in OS ticks that is expected for read to complete. If time out occurs AD_I2C_ERROR_TRANSFER_TIMEOUT error is returned. :: OS_EVENT_FOREVER :: 0 |
| int ad_i2c_reconfig | ( | ad_i2c_handle_t | p, |
| const ad_i2c_driver_conf_t * | conf | ||
| ) |
Reconfigure I2C controller.
This function will apply a new I2C driver configuration.
| [in] | p | handle returned from ad_i2c_open() |
| [in] | conf | pointer to driver configuration |
| void ad_i2c_wait_while_master_busy | ( | ad_i2c_handle_t | p | ) |
Wait while I2C master device is busy.
| [in] | p | pointer returned from ad_i2c_open() |
| int ad_i2c_write | ( | ad_i2c_handle_t | p, |
| const uint8_t * | wbuf, | ||
| size_t | wlen, | ||
| uint8_t | condition_flags | ||
| ) |
Perform a blocking write transaction.
This function performs a synchronous write only transaction
| [in] | p | handle returned from ad_i2c_open() |
| [in] | wbuf | buffer containing the data to be sent to the device |
| [in] | wlen | size of data to be sent to the device |
| [in] | condition_flags | Possible values for flags are: HW_I2C_F_NONE HW_I2C_F_ADD_STOP HW_I2C_F_ADD_RESTART |
| int ad_i2c_write_async | ( | ad_i2c_handle_t | p, |
| const uint8_t * | wbuf, | ||
| size_t | wlen, | ||
| ad_i2c_user_cb | cb, | ||
| void * | user_data, | ||
| uint8_t | condition_flags | ||
| ) |
Perform a non blocking write transaction.
This function performs an asynchronous write only transaction Caller task should retry until function returns no error Callback will be called when transaction is completed
| [in] | p | handle returned from ad_i2c_open() |
| [in] | wbuf | buffer containing the data to be sent to the device |
| [in] | wlen | size of data to be sent to the device |
| [in] | cb | callback to call after transaction is over (from ISR context) |
| [in] | user_data | user data passed to cb callback |
| [in] | condition_flags | Possible values for flags are: HW_I2C_F_NONE HW_I2C_F_ADD_STOP HW_I2C_F_ADD_RESTART |
| int ad_i2c_write_read | ( | ad_i2c_handle_t | p, |
| const uint8_t * | wbuf, | ||
| size_t | wlen, | ||
| uint8_t * | rbuf, | ||
| size_t | rlen, | ||
| uint8_t | condition_flags | ||
| ) |
Perform synchronous write/read transaction.
This function performs a synchronous write and read transaction on I2C bus.
| [in] | p | handle returned from ad_i2c_open() |
| [in] | wbuf | buffer containing the data to be sent to the device |
| [in] | wlen | size of data to be sent to the device |
| [out] | rbuf | buffer to store the data read from the device |
| [in] | rlen | size of buffer pointed by rbuf |
| [in] | condition_flags | Possible values for flags are: HW_I2C_F_NONE HW_I2C_F_ADD_STOP HW_I2C_F_ADD_RESTART |
| int ad_i2c_write_read_async | ( | ad_i2c_handle_t | p, |
| const uint8_t * | wbuf, | ||
| size_t | wlen, | ||
| uint8_t * | rbuf, | ||
| size_t | rlen, | ||
| ad_i2c_user_cb | cb, | ||
| void * | user_data, | ||
| uint8_t | condition_flags | ||
| ) |
Perform write and asynchronous read I2C transaction.
This function performs asynchronous write and read transaction.
| [in] | p | handle returned from ad_i2c_open() |
| [in] | wbuf | data to send |
| [in] | wlen | number of bytes to write |
| [out] | rbuf | buffer to store the data read from the device |
| [in] | rlen | size of buffer pointed by rbuf |
| [in] | cb | callback to call after transaction is over (from ISR context) |
| [in] | user_data | user data to pass to cb |
| [in] | condition_flags | Possible values for flags are: HW_I2C_F_NONE HW_I2C_F_ADD_STOP HW_I2C_F_ADD_RESTART |
| int ad_i2c_write_read_with_to | ( | ad_i2c_handle_t | p, |
| const uint8_t * | wbuf, | ||
| size_t | wlen, | ||
| uint8_t * | rbuf, | ||
| size_t | rlen, | ||
| uint8_t | condition_flags, | ||
| OS_TICK_TIME | timeout | ||
| ) |
Perform synchronous write/read transaction with time out.
This function performs a synchronous write and read transaction on I2C bus.
| [in] | p | handle returned from ad_i2c_open() |
| [in] | wbuf | buffer containing the data to be sent to the device |
| [in] | wlen | size of data to be sent to the device |
| [out] | rbuf | buffer to store the data read from the device |
| [in] | rlen | size of buffer pointed by rbuf |
| [in] | condition_flags | Possible values for flags are: HW_I2C_F_NONE HW_I2C_F_ADD_STOP HW_I2C_F_ADD_RESTART |
| [in] | timeout | time in OS ticks that is expected for transaction to complete. If time out occurs AD_I2C_ERROR_TRANSFER_TIMEOUT error is returned. :: OS_EVENT_FOREVER :: 0 |
| int ad_i2c_write_with_to | ( | ad_i2c_handle_t | p, |
| const uint8_t * | wbuf, | ||
| size_t | wlen, | ||
| uint8_t | condition_flags, | ||
| OS_TICK_TIME | timeout | ||
| ) |
Perform a blocking write transaction with time out.
This function performs a synchronous write only transaction
| [in] | p | handle returned from ad_i2c_open() |
| [in] | wbuf | buffer containing the data to be sent to the device |
| [in] | wlen | size of data to be sent to the device |
| [in] | condition_flags | Possible values for flags are: HW_I2C_F_NONE HW_I2C_F_ADD_STOP HW_I2C_F_ADD_RESTART |
| [in] | timeout | time in OS ticks that is expected for write to complete. If time out occurs AD_I2C_ERROR_TRANSFER_TIMEOUT error is returned. :: OS_EVENT_FOREVER :: 0 |
1.8.16