FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
TempSensor Abstraction APIs.

Macros

#define IOT_TSENSOR_SUCCESS   ( 0 )
 Return values used by tsensor driver. More...
 
#define IOT_TSENSOR_INVALID_VALUE   ( 1 )
 
#define IOT_TSENSOR_DISABLED   ( 2 )
 
#define IOT_TSENSOR_CLOSED   ( 3 )
 
#define IOT_TSENSOR_GET_TEMP_FAILED   ( 4 )
 
#define IOT_TSENSOR_SET_FAILED   ( 5 )
 
#define IOT_TSENSOR_NOT_SUPPORTED   ( 6 )
 

Typedefs

typedef struct IotTsensorDescriptor_t * IotTsensorHandle_t
 IotTsensorHandle_t type is the tsensor handle returned by calling iot_tsensor_open() this is initialized in open and returned to caller. Caller must pass this pointer to the rest of the APIs.
 
typedef void(* IotTsensorCallback_t) (IotTsensorStatus_t xStatus, void *pvUserContext)
 The callback function for completion of Tsensor operation. More...
 

Enumerations

enum  IotTsensorStatus_t { eTsensorMinThresholdReached, eTsensorMaxThresholdReached }
 tsensor threshold reached status More...
 
enum  IotTsensorIoctlRequest_t {
  eTsensorSetMinThreshold, eTsensorSetMaxThreshold, eTsensorGetMinThreshold, eTsensorGetMaxThreshold,
  eTsensorPerformCalibration
}
 Ioctl request types. More...
 

Functions

IotTsensorHandle_t iot_tsensor_open (int32_t lTsensorInstance)
 iot_tsensor_open is used to initialize the temperature sensor. It sets up the clocks and power etc, if the sensor is internal and sets up the communication channel if the sensor is external. More...
 
void iot_tsensor_set_callback (IotTsensorHandle_t const xTsensorHandle, IotTsensorCallback_t xCallback, void *pvUserContext)
 Set the callback to be called when a threshold is reached on the sensor. The caller must set the threshold level using IOCTL before the callback can be called. More...
 
int32_t iot_tsensor_enable (IotTsensorHandle_t const xTsensorHandle)
 iot_tsensor_enable is used to enable the temperature sensor to start reading the temperature and trigger thresholds (if any were set and supported) More...
 
int32_t iot_tsensor_disable (IotTsensorHandle_t const xTsensorHandle)
 iot_tsensor_disable is used to disable the temperature sensor which stops monitoring the temperature. More...
 
int32_t iot_tsensor_get_temp (IotTsensorHandle_t const xTsensorHandle, int32_t *plTemp)
 iot_tsensor_get_temp is used to get the current temperature read from the sensor. More...
 
int32_t iot_tsensor_ioctl (IotTsensorHandle_t const xTsensorHandle, IotTsensorIoctlRequest_t xRequest, void *const pvBuffer)
 iot_tsensor_ioctl is used to set tsensor configuration and tsensor properties like minimum threshold, maximum threshold value, etc. Supported IOCTL requests are defined in aws_hal_Tsensor_Ioctl_Request_t More...
 
int32_t iot_tsensor_close (IotTsensorHandle_t const xTsensorHandle)
 iot_tsensor_close is used to de-initialize Tsensor. More...
 

Detailed Description

Macro Definition Documentation

◆ IOT_TSENSOR_SUCCESS

#define IOT_TSENSOR_SUCCESS   ( 0 )

Return values used by tsensor driver.

TempSensor operation completed successfully.

◆ IOT_TSENSOR_INVALID_VALUE

#define IOT_TSENSOR_INVALID_VALUE   ( 1 )

At least one parameter is invalid.

◆ IOT_TSENSOR_DISABLED

#define IOT_TSENSOR_DISABLED   ( 2 )

TempSensor is disabled.

◆ IOT_TSENSOR_CLOSED

#define IOT_TSENSOR_CLOSED   ( 3 )

TempSensor instance is not open.

◆ IOT_TSENSOR_GET_TEMP_FAILED

#define IOT_TSENSOR_GET_TEMP_FAILED   ( 4 )

TempSensor failed to get the temperature.

◆ IOT_TSENSOR_SET_FAILED

#define IOT_TSENSOR_SET_FAILED   ( 5 )

TempSensor set threshold operation failed.

◆ IOT_TSENSOR_NOT_SUPPORTED

#define IOT_TSENSOR_NOT_SUPPORTED   ( 6 )

TempSensor operation not supported.

Typedef Documentation

◆ IotTsensorCallback_t

typedef void( * IotTsensorCallback_t) (IotTsensorStatus_t xStatus, void *pvUserContext)

The callback function for completion of Tsensor operation.

Parameters
[in]xStatustsensor threshold reached status
[in]pvUserContextuser provid context

Enumeration Type Documentation

◆ IotTsensorStatus_t

tsensor threshold reached status

Enumerator
eTsensorMinThresholdReached 

min temperature threshold reached status

eTsensorMaxThresholdReached 

max temperature threshold reached status

◆ IotTsensorIoctlRequest_t

Ioctl request types.

Enumerator
eTsensorSetMinThreshold 

Set min temperature threshold using IotI2CIoctlConfig_t. Takes int32_t value in degrees celcius.

eTsensorSetMaxThreshold 

Set max temperature threshold using IotI2CIoctlConfig_t . Takes int32_t value in degrees celcius.

eTsensorGetMinThreshold 

Get min temperature threshold using IotI2CIoctlConfig_t. Returns int32_t value in degrees celcius.

eTsensorGetMaxThreshold 

Get max temperature threshold using IotI2CIoctlConfig_t. Returns int32_t value in degrees celcius.

eTsensorPerformCalibration 

Perform calibration of the sensor

Function Documentation

◆ iot_tsensor_open()

IotTsensorHandle_t iot_tsensor_open ( int32_t  lTsensorInstance)

iot_tsensor_open is used to initialize the temperature sensor. It sets up the clocks and power etc, if the sensor is internal and sets up the communication channel if the sensor is external.

Parameters
[in]lTsensorInstanceThe instance of the tsensor to initialize. The instance number is platform specific. i,e if you have more than one temperature ensors, then 2 instances point to 2 different sensors.
Returns
  • Handle to tsensor interface on success.
  • NULL if
    • lTesnsorInstance is invalid.
    • instance is already open.

◆ iot_tsensor_set_callback()

void iot_tsensor_set_callback ( IotTsensorHandle_t const  xTsensorHandle,
IotTsensorCallback_t  xCallback,
void *  pvUserContext 
)

Set the callback to be called when a threshold is reached on the sensor. The caller must set the threshold level using IOCTL before the callback can be called.

Note
Single callback is used per instance for both min and max threshold points being reached.
Newly set callback overrides the one previously set
Warning
If input handle or if callback function is NULL, this function silently takes no action.
If threshold detection is not supported by the hardware, then the callback function will not work.
Parameters
[in]xTsensorHandleHandle to tsensor driver returned in open() call
[in]xCallbackThe callback function to be called on completion of transaction.
[in]pvUserContextuser provid context

◆ iot_tsensor_enable()

int32_t iot_tsensor_enable ( IotTsensorHandle_t const  xTsensorHandle)

iot_tsensor_enable is used to enable the temperature sensor to start reading the temperature and trigger thresholds (if any were set and supported)

Parameters
[in]xTsensorHandleHandle to tsensor driver returned in iot_tsensor_open
Returns
  • IOT_TSENSOR_SUCCESS on success
  • IOT_TSENSOR_INVALID_VALUE if xTsensorHandle is NULL.

◆ iot_tsensor_disable()

int32_t iot_tsensor_disable ( IotTsensorHandle_t const  xTsensorHandle)

iot_tsensor_disable is used to disable the temperature sensor which stops monitoring the temperature.

Parameters
[in]xTsensorHandleHandle to tsensor driver returned in iot_tsensor_open
Returns
  • IOT_TSENSOR_SUCCESS on success
  • IOT_TSENSOR_INVALID_VALUE if xTsensorHandle is NULL.

◆ iot_tsensor_get_temp()

int32_t iot_tsensor_get_temp ( IotTsensorHandle_t const  xTsensorHandle,
int32_t *  plTemp 
)

iot_tsensor_get_temp is used to get the current temperature read from the sensor.

Parameters
[in]xTsensorHandlehandle to tsensor driver returned in iot_tsensor_open
[out]plTemptemperature read from the sensor.
Returns
  • IOT_TSENSOR_SUCCESS on success
  • IOT_TSENSOR_INVALID_VALUE if
    • xTsensorHandle is NULL
    • lTemp is NULL
  • IOT_TSENSOR_DISABLED if tsensor instance has been disabled with call to iot_tsensor_disable().
  • IOT_TSENSOR_GET_TEMP_FAILED if error occured reading the temperature.

◆ iot_tsensor_ioctl()

int32_t iot_tsensor_ioctl ( IotTsensorHandle_t const  xTsensorHandle,
IotTsensorIoctlRequest_t  xRequest,
void *const  pvBuffer 
)

iot_tsensor_ioctl is used to set tsensor configuration and tsensor properties like minimum threshold, maximum threshold value, etc. Supported IOCTL requests are defined in aws_hal_Tsensor_Ioctl_Request_t

Parameters
[in]xTsensorHandlehandle to tsensor driver returned in iot_tsensor_open
[in]xRequestconfiguration request.
[in,out]pvBufferbuffer holding tsensor set and get values.
Returns
  • IOT_TSENSOR_SUCCESS on success
  • IOT_TSENSOR_INVALID_VALUE
    • xTsensorHandle is NULL
    • xRequest is invalid
    • pvBuffer is NULL (excluding eTsensorPerformCalibration)
  • IOT_TSENSOR_CLOSED if instance not in open state.
  • IOT_TSENSOR_DISABLED if tsensor instance has been disabled with call to iot_tsensor_disable().
  • IOT_TSENSOR_GET_TEMP_FAILED if error occured reading the temperature.
  • IOT_TSENSOR_SET_FAILED if set threshold operation failed.
  • IOT_TSENSOR_NOT_SUPPORTED valid if xRequest feature not supported.
Note
: If eTsensorSetMinThreshold or eTsensorSetMaxThreshold ioctl is supported, then the corresponding eTsensorGetMinThreshold and eTsensorGetMaxThreshold must also be supported.

◆ iot_tsensor_close()

int32_t iot_tsensor_close ( IotTsensorHandle_t const  xTsensorHandle)

iot_tsensor_close is used to de-initialize Tsensor.

Parameters
[in]xTsensorHandlehandle to tsensor driver returned in iot_tsensor_open
Returns
  • IOT_TSENSOR_SUCCESS on success
  • IOT_TSENSOR_INVALID_VALUE if
    • xTensorHandle is NULL
    • not in open state (already closed)