FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
iot_i2c.h File Reference

File for the APIs of I2C called by application layer. More...

#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Data Structures

struct  IotI2CConfig_t
 I2C bus configuration. More...
 

Macros

#define IOT_I2C_STANDARD_MODE_BPS   ( 100000 )
 
#define IOT_I2C_FAST_MODE_BPS   ( 400000 )
 
#define IOT_I2C_FAST_MODE_PLUS_BPS   ( 1000000 )
 
#define IOT_I2C_HIGH_SPEED_BPS   ( 3400000 )
 
#define IOT_I2C_SUCCESS   ( 0 )
 
#define IOT_I2C_INVALID_VALUE   ( 1 )
 
#define IOT_I2C_BUSY   ( 2 )
 
#define IOT_I2C_WRITE_FAILED   ( 3 )
 
#define IOT_I2C_READ_FAILED   ( 4 )
 
#define IOT_I2C_NACK   ( 5 )
 
#define IOT_I2C_BUS_TIMEOUT   ( 6 )
 
#define IOT_I2C_NOTHING_TO_CANCEL   ( 7 )
 
#define IOT_I2C_FUNCTION_NOT_SUPPORTED   ( 8 )
 
#define IOT_I2C_SLAVE_ADDRESS_NOT_SET   ( 9 )
 

Typedefs

typedef struct IotI2CDescriptor * IotI2CHandle_t
 IotI2CHandle_t is the handle type returned by calling iot_i2c_open(). This is initialized in open and returned to caller. The caller must pass this pointer to the rest of APIs.
 
typedef void(* IotI2CCallback_t) (IotI2COperationStatus_t xOpStatus, void *pvUserContext)
 The callback function for completion of I2C operation. More...
 

Enumerations

enum  IotI2CBusStatus_t { eI2CBusIdle = 0, eI2cBusBusy = IOT_I2C_BUSY }
 I2C Bus status. More...
 
enum  IotI2COperationStatus_t { eI2CCompleted = IOT_I2C_SUCCESS, eI2CDriverFailed, eI2CNackFromSlave = IOT_I2C_NACK, eI2CMasterTimeout = IOT_I2C_BUS_TIMEOUT }
 I2C operation status. More...
 
enum  IotI2CIoctlRequest_t {
  eI2CSendNoStopFlag, eI2CSetSlaveAddr, eI2CSetMasterConfig, eI2CGetMasterConfig,
  eI2CGetBusState, eI2CBusReset, eI2CGetTxNoOfbytes, eI2CGetRxNoOfbytes
}
 Ioctl request types. More...
 

Functions

IotI2CHandle_t iot_i2c_open (int32_t lI2CInstance)
 Initiates and reserves an I2C instance as master. More...
 
void iot_i2c_set_callback (IotI2CHandle_t const pxI2CPeripheral, IotI2CCallback_t xCallback, void *pvUserContext)
 Sets the application callback to be called on completion of an operation. More...
 
int32_t iot_i2c_read_sync (IotI2CHandle_t const pxI2CPeripheral, uint8_t *const pucBuffer, size_t xBytes)
 Starts the I2C master read operation in synchronous mode. More...
 
int32_t iot_i2c_write_sync (IotI2CHandle_t const pxI2CPeripheral, uint8_t *const pucBuffer, size_t xBytes)
 Starts the I2C master write operation in synchronous mode. More...
 
int32_t iot_i2c_read_async (IotI2CHandle_t const pxI2CPeripheral, uint8_t *const pucBuffer, size_t xBytes)
 Starts the I2C master read operation in asynchronous mode. More...
 
int32_t iot_i2c_write_async (IotI2CHandle_t const pxI2CPeripheral, uint8_t *const pucBuffer, size_t xBytes)
 Starts the I2C master write operation in asynchronous mode. More...
 
int32_t iot_i2c_ioctl (IotI2CHandle_t const pxI2CPeripheral, IotI2CIoctlRequest_t xI2CRequest, void *const pvBuffer)
 Configures the I2C master with user configuration. More...
 
int32_t iot_i2c_close (IotI2CHandle_t const pxI2CPeripheral)
 Stops the ongoing operation and de-initializes the I2C peripheral. More...
 
int32_t iot_i2c_cancel (IotI2CHandle_t const pxI2CPeripheral)
 This function is used to cancel the current operation in progress, if possible. More...
 

Detailed Description

File for the APIs of I2C called by application layer.