Temperature Sensor HAL Interface Documentation#
Hardware introduction#
K230 integrates a temperature sensor (Temperature Sensor) for monitoring the internal temperature of the chip. It supports two working modes: single sampling and continuous sampling, and the temperature calibration can be adjusted through the trim value.
Macro definition instructions#
working mode#
RT_DEVICE_TS_CTRL_MODE_SINGLE: Single sampling modeRT_DEVICE_TS_CTRL_MODE_CONTINUUOS: continuous sampling mode
Trim value range#
RT_DEVICE_TS_CTRL_MAX_TRIM: Maximum trim value (15)
Function interface description#
int drv_tsensor_read_temperature(double *temp);#
Function: Read the current temperature value.
parameter:
temp: Pointer used to store temperature value (unit: degrees Celsius)
Return Value:
0: Success-1: failed
int drv_tsensor_set_mode(uint8_t mode);#
Function: Set the temperature sensor working mode.
parameter:
mode: working modeRT_DEVICE_TS_CTRL_MODE_SINGLE: Single sampling modeRT_DEVICE_TS_CTRL_MODE_CONTINUUOS: continuous sampling mode
Return Value:
0: Success-1: failed (invalid mode)
int drv_tsensor_get_mode(uint8_t *mode);#
Function: Get the current working mode.
parameter:
mode: Pointer used to store working mode
Return Value:
0: Success-1: failed
int drv_tsensor_set_trim(uint8_t trim);#
Function: Set the temperature sensor trim value for temperature calibration.
parameter:
trim: trim value, range[0, 15]
Return Value:
0: Success-1: failed
int drv_tsensor_get_trim(uint8_t *trim);#
Function: Get the current trim value.
parameter:
trim: Pointer used to store trim value
Return Value:
0: Success-1: failed
Usage example#
Please refer to src/rtsmart/examples/peripheral/tsensor/test_tsensor.c
