|
| wiced_result_t | wiced_i2c_deinit (const wiced_i2c_device_t *device) |
| |
| wiced_result_t | wiced_i2c_init (const wiced_i2c_device_t *device) |
| |
| wiced_result_t | wiced_i2c_init_combined_message (wiced_i2c_message_t *message, const void *tx_buffer, void *rx_buffer, uint16_t tx_buffer_length, uint16_t rx_buffer_length, uint16_t retries, wiced_bool_t disable_dma) |
| |
| wiced_result_t | wiced_i2c_init_rx_message (wiced_i2c_message_t *message, void *rx_buffer, uint16_t rx_buffer_length, uint16_t retries, wiced_bool_t disable_dma) |
| |
| wiced_result_t | wiced_i2c_init_tx_message (wiced_i2c_message_t *message, const void *tx_buffer, uint16_t tx_buffer_length, uint16_t retries, wiced_bool_t disable_dma) |
| |
| wiced_bool_t | wiced_i2c_probe_device (const wiced_i2c_device_t *device, int retries) |
| |
| wiced_result_t | wiced_i2c_read (const wiced_i2c_device_t *device, uint16_t flags, void *buffer, uint16_t buffer_length) |
| |
| wiced_result_t | wiced_i2c_transfer (const wiced_i2c_device_t *device, wiced_i2c_message_t *message, uint16_t number_of_messages) |
| |
| wiced_result_t | wiced_i2c_write (const wiced_i2c_device_t *device, uint16_t flags, const void *buffer, uint16_t buffer_length) |
| |
Inter-IC bus (I2C) Functions
For I2C device configuration and specification parameters <WICED_SDK>/platforms/<platform_name>/platform.c and <WICED_SDK>/platforms/<platform_name>/platform.h
Example Usage flow, check for return values in implementation
wiced_i2c_init(&wiced_i2c_device);
wiced_i2c_probe_device(&wiced_i2c_device, NUM_TRIES);
// OPTION 1 :
// wiced_i2c_message_t i2c_message[NUM_MSG];
// specify i2c buffer, length. number of tries, and flags in the i2c_message
// refer to <WICED_SDK>/WICED/platform/include/platform_peripheral.h
wiced_i2c_init_tx_message(i2c_message, data, data_size, number_of_tries, flags);
wiced_i2c_init_rx_message(i2c_message, data, data_size, number_of_tries, flags);
wiced_i2c_transfer(&wiced_i2c_device, i2c_message, number_of_messages);
// OPTION 2
// Gives more control on specifying I2C START/STOP/Repeated START Flags
wiced_i2c_read (&wiced_i2c_device, flags, read_buffer, read_buffer_size);
wiced_i2c_write(&wiced_i2c_device, flags, write_buffer, write_buffer_size);
wiced_i2c_deinit(&wiced_i2c_device);
◆ wiced_i2c_deinit()
De-initializes an I2C device
- Parameters
-
| [in] | device | : The device for which the i2c port should be deinitialized |
- Returns
- WICED_SUCCESS : on success.
-
WICED_ERROR : if an error occurred during deinitialization
◆ wiced_i2c_init()
Initializes an I2C interface
Prepares an I2C hardware interface for communication as a master
- Parameters
-
| [in] | device | : The device for which the i2c port should be initialized |
- Returns
- WICED_SUCCESS : on success.
-
WICED_ERROR : if an error occurred during initialization
◆ wiced_i2c_init_combined_message()
Initialize the wiced_i2c_message_t structure for i2c combined transaction
- Parameters
-
| [out] | message | : Pointer to a message structure, this should be a valid pointer |
| [in] | tx_buffer | : Pointer to a tx buffer that is already allocated |
| [in] | rx_buffer | : Pointer to an rx buffer that is already allocated |
| [in] | tx_buffer_length | : Number of bytes to transmit |
| [in] | rx_buffer_length | : Number of bytes to receive |
| [in] | retries | : The number of times to attempt receive a message in case device doesnt respond |
| [in] | disable_dma | : If true, disables the dma for current rx transaction. You may find it useful to switch off dma for short rx messages. If you set this flag to 0, then you should make sure that the device flags was configured with I2C_DEVICE_USE_DMA. If the device doesn't support DMA, the message will be received not using DMA. |
- Returns
- WICED_SUCCESS : message structure was initialized properly.
-
WICED_BADARG : one of the arguments is given incorrectly
◆ wiced_i2c_init_rx_message()
Initialize the wiced_i2c_message_t structure for i2c rx transaction
- Parameters
-
| [out] | message | : Pointer to a message structure, this should be a valid pointer |
| [in] | rx_buffer | : Pointer to an rx buffer that is already allocated |
| [in] | rx_buffer_length | : Number of bytes to receive |
| [in] | retries | : The number of times to attempt receive a message in case device doesnt respond |
| [in] | disable_dma | : If true, disables the dma for current rx transaction. You may find it useful to switch off dma for short rx messages. If you set this flag to 0, then you should make sure that the device flags was configured with I2C_DEVICE_USE_DMA. If the device doesn't support DMA, the message will be received not using DMA. |
- Returns
- WICED_SUCCESS : message structure was initialized properly.
-
WICED_BADARG : one of the arguments is given incorrectly
◆ wiced_i2c_init_tx_message()
Initialize the wiced_i2c_message_t structure for i2c tx transaction
- Parameters
-
| [out] | message | : Pointer to a message structure, this should be a valid pointer |
| [in] | tx_buffer | : Pointer to a tx buffer that is already allocated |
| [in] | tx_buffer_length | : Number of bytes to transmit |
| [in] | retries | : The number of times to attempt send a message in case it can't not be sent |
| [in] | disable_dma | : If true, disables the dma for current tx transaction. You may find it useful to switch off dma for short tx messages. If you set this flag to 0, then you should make sure that the device flags was configured with I2C_DEVICE_USE_DMA. If the device doesn't support DMA, the message will be transmitted with no DMA. |
- Returns
- WICED_SUCCESS : message structure was initialized properly.
-
WICED_BADARG : one of the arguments is given incorrectly
◆ wiced_i2c_probe_device()
Checks whether the device is available on a bus or not
- Parameters
-
| [in] | device | : The i2c device to be probed |
| [in] | retries | : The number of times to attempt to probe the device |
- Returns
- WICED_TRUE : device is found.
-
WICED_FALSE: device is not found
◆ wiced_i2c_read()
Read data over an I2C interface
- Parameters
-
| [in] | device | : The i2c device to communicate with |
| [in] | flags | : Bitwise flags to control i2c data transfers (WICED_I2C_XXX_FLAG) |
| [out] | buffer | : Pointer to a buffer to hold received data |
| [in] | buffer_length | : Length in bytes of the buffer |
- Returns
- WICED_SUCCESS : on success
-
WICED_ERROR : if an error occurred during message transfer
◆ wiced_i2c_transfer()
Transmits and/or receives data over an I2C interface
- Parameters
-
| [in] | device | : The i2c device to communicate with |
| [in] | message | : A pointer to a message (or an array of messages) to be transmitted/received |
| [in] | number_of_messages | : The number of messages to transfer. [1 .. N] messages |
- Returns
- WICED_SUCCESS : on success.
-
WICED_ERROR : if an error occurred during message transfer
◆ wiced_i2c_write()
Write data over an I2C interface
- Parameters
-
| [in] | device | : The i2c device to communicate with |
| [in] | flags | : Bitwise flags to control i2c data transfers (WICED_I2C_XXX_FLAG) |
| [in] | buffer | : Pointer to a buffer with data to write |
| [in] | buffer_length | : Length in bytes of the buffer |
- Returns
- WICED_SUCCESS : on success
-
WICED_ERROR : if an error occurred during message transfer