In the Temperature Sensor (TSENS) asynchronous driver, a callback function can be registered in the driver by the application and triggered when temperature measurement complete or window monitor condition happens to let the application know the result.
Initialize and deinitialize the driver and associated hardware
Enable or disable the TSENS hardware
Temperature Measurement (Celsius)
Hook callback functions on temperature measurement complete or window monitor condition
The main TSENS parameters can be configured in START. Many of these parameters are used by the temp_async_init function when initializing the driver and underlying hardware.
The driver supports temperature measurement, and window monitor. The window monitor can be used to monitor temperature and compare to predefined threshold. The threshold include two values, lower and upper temperature value. The threshold value should be setup by application before starting window monitor. There are several monitor modes that can be selected in the driver configuration. Typical one includes inside, outside, beyond upper threshold or below the lower threshold. For different MCU/MPU device, the supported monitor modes maybe different, please refer to driver's configuration. A callback function can be registered to window monitor, once the monitor condition happens, the callback function is invoked to notify the application.
The temperature unit used in this driver is Celsius.
The following shows a simple example of using the TSENS driver to get device temperature. The TSENS must have been initialized by temp_async_init.
The example registers a callback function for temperature data complete and will be invoked when temperature measurement is done.
static int32_t temp;
static int32_t result;
static void read_cb_TEMPERATURE_SENSOR_0(const struct temp_async_descriptor *const descr, int32_t state)
{
result = state;
}
/**
* Example of using TEMPERATURE_SENSOR_0 to generate waveform.
*/
void TEMPERATURE_SENSOR_0_example(void)
{
result = -1;
temp_async_enable(&TEMPERATURE_SENSOR_0);
temp_async_register_callback(&TEMPERATURE_SENSOR_0, TEMP_ASYNC_READY_CB, read_cb_TEMPERATURE_SENSOR_0);
temp_async_read(&TEMPERATURE_SENSOR_0, &temp);
while (result != ERR_NONE)
;
}
The Temperature Sensor peripheral and its related I/O lines and clocks
The NVIC must be configured so that AC interrupt requests are periodically serviced