RV32 SoC DS UG
High-Perf RV32 SoC DS UG
RV64 SoC DS UG API and Examples
Embedded IDE UG
Loading...
Searching...
No Matches
Temperature Sensor Driver

Overview

Temperature Sensor driver.

This module provides Generic functions to configure and control Temperature Sensor input/output and interrupt behavior.

Usage & Initialization.

This is an example show how to instantiate Temperature Sensor Driver with temp_sensor_instance_t.

This implementation depends on I2C Driver.

#define I2C_CTRL_HZ SYSTEM_CLINT_HZ
#define I2C_CTRL (i2c_hwreg_t *)SYSTEM_I2C_0_IO_CTRL
#define I2C_FREQ 100000
#define ACTIVE_TEMP_SENSOR_TYPE SENSOR_TYPE_EMC1413
temp_sensor_instance_t TEMP_SENSOR = {
.inst = &(i2c_instance_t){
.hwreg = I2C_CTRL,
.slaveAddress = TEMP_SENSOR_CTRL,
.samplingClockDivider = 3,
.timeout = I2C_CTRL_HZ/1000,
.tsuDat = I2C_CTRL_HZ/(I2C_FREQ*5),
.tLow = I2C_CTRL_HZ/(I2C_FREQ*2),
.tHigh = I2C_CTRL_HZ/(I2C_FREQ*2),
.tBuf = I2C_CTRL_HZ/(I2C_FREQ),
},
};
TEMP_SENSOR.drv->applyConfig(&TEMP_SENSOR);
TEMP_SENSOR.drv->enableErrorInterrupt(&TEMP_SENSOR);
TEMP_SENSOR.drv->getTemp(&TEMP_SENSOR);
printf("Current Temperature: %.2f°C\n", TEMP_SENSOR.temp_value.channels[0].current_temp);
#define TEMP_SENSOR_CTRL
I2C Address for the currently selected RTC (PCF8523).
#define TEMP_SENSOR_DRIVER
struct temp_sensor_instance temp_sensor_instance_t
Forward declaration of Temperature Sensor instance.
I2C instance. Holds the software registers and hardware pointer.
Definition i2c.h:290
temp_sensor_status_t(* applyConfig)(temp_sensor_instance_t *temp)
temp_sensor_status_t(* enableErrorInterrupt)(temp_sensor_instance_t *temp)
temp_sensor_status_t(* getTemp)(temp_sensor_instance_t *temp)
float current_temp
Current Temperature *‍/.
temp_sensor_channelData_t channels[3]
const temp_sensor_api_t * drv
Pointer to Temperature Sensor API structure *‍/.
temp_sensor_data_t temp_value
Temperature Sensor data *‍/.
Temperature Sensor driver API definitions.
See also
Supported Devices - Learn about the supported Temperature Sensor list.
Example Temperature Sensor Demo - Learn how to use the driver for Temperature Sensor operations

Topics

 API Functions
 Common Function definitions for Temperature Sensor driver.
 Data Structures
 Structs used by the driver.
 Data Types
 Enums used by the driver.
 Driver Configuration
 Automatic hardware selection logic.
 Supported Devices
 Supported Temperature Sensor devices.