Sapphire SoC DS Sapphire SoC UG Sapphire HP SoC DS Sapphire HP SoC UG RISC-V Embedded IDE UG Board Support Package
Loading...
Searching...
No Matches
temp_sensor.h
Go to the documentation of this file.
1
2// Copyright (C) 2013-2026 Efinix Inc. All rights reserved.
3// Full license header bsp/efinix/EfxSapphireSocRV64/include/LICENSE.MD
5
6#ifndef TEMP_SENSOR_H_
7#define TEMP_SENSOR_H_
8
19
20#include "i2c/i2c.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
37
38/* ========================================================================== */
39/* SUB-GROUP : Data Types */
40/* ========================================================================== */
41
48
54
55
67 // End of TEMP_SENSOR_ENUM group
70
71/* ========================================================================== */
72/* SUB-GROUP : DATA STRUCTS */
73/* ========================================================================== */
111
116 typedef struct {
119 float low_limit;
121
126 typedef struct {
127 temp_sensor_channelData_t channels[3]; // Supports up to 3 diodes
129
147
162 // End of TEMP_SENSOR_Types group
164
165
166/* ========================================================================== */
167/* SUB-GROUP: FUNCTIONS */
168/* ========================================================================== */
169
190 u8 temp_writeTempReg(temp_sensor_instance_t *temp, const u8 reg, const u8 data);
199 u8 encode_temp_limit(float val, u8 is_extended, u8 *out_hb, u8 *out_lb);
207 float calculate_temp_celsius(u8 hb, u8 lb, u8 is_extended); // End of TEMP_SENSOR_Funcs group
209
210
211
212/* ========================================================================== */
213/* SUB-GROUP: TEMP SENSOR CONFIGURATION */
214/* ========================================================================== */
215
218
219#ifdef __cplusplus
220
221}
222#endif //End of TEMP_SENSOR group
224
225#endif /* TEMP_SENSOR_H_ */
temp_sensor_status_t
Temperature Sensor Status List.
Definition temp_sensor.h:59
@ TEMP_SENSOR_USER_ERR
User provide wrong input *‍/.
Definition temp_sensor.h:62
@ TEMP_SENSOR_SKIP
Skip the function *‍/.
Definition temp_sensor.h:63
@ TEMP_SENSOR_HIGH_ALERT
High Temperature Alert *‍/.
Definition temp_sensor.h:64
@ TEMP_SENSOR_OK
Successful Operation *‍/.
Definition temp_sensor.h:60
@ TEMP_SENSOR_LOW_ALERT
Low Temperature Alert *‍/.
Definition temp_sensor.h:65
@ TEMP_SENSOR_ERR
Failed to retrieve/write value *‍/.
Definition temp_sensor.h:61
u8 temp_writeTempReg(temp_sensor_instance_t *temp, const u8 reg, const u8 data)
Write a value to a register in the Temperature Sensor.
Definition temp_sensor.c:32
u8 temp_readTempReg(temp_sensor_instance_t *temp, const u8 reg)
Read a register from the Temperature Sensor.
Definition temp_sensor.c:22
u8 encode_temp_limit(float val, u8 is_extended, u8 *out_hb, u8 *out_lb)
Encode temperature limit into high and low byte format.
Definition temp_sensor.c:55
float calculate_temp_celsius(u8 hb, u8 lb, u8 is_extended)
Calculate temperature in Celsius from high and low byte format.
Definition temp_sensor.c:42
struct temp_sensor_instance temp_sensor_instance_t
Forward declaration of Temperature Sensor instance.
I2C driver API definitions.
I2C instance. Holds the software registers and hardware pointer.
Definition i2c.h:259
Temperature Sensor API structure.
temp_sensor_status_t(* checkTempAlert)(temp_sensor_instance_t *temp)
u8(* checkTempRange)(temp_sensor_instance_t *temp)
temp_sensor_status_t(* getTemp)(temp_sensor_instance_t *temp)
temp_sensor_status_t(* setTempRange)(temp_sensor_instance_t *temp, u8 enable_extended)
temp_sensor_status_t(* getTempLimit)(temp_sensor_instance_t *temp)
temp_sensor_status_t(* setTempLimit)(temp_sensor_instance_t *temp)
Hold temperature data for a single channel/diode.
float high_limit
High Temperature Limit *‍/.
float current_temp
Current Temperature *‍/.
float low_limit
Low Temperature Limit *‍/.
Temperature Sensor data structure.
temp_sensor_channelData_t channels[3]
Temperature Sensor instance structure.
const temp_sensor_api_t * drv
Pointer to Temperature Sensor API structure *‍/.
temp_sensor_data_t temp_value
Temperature Sensor data *‍/.
i2c_instance_t * inst
Pointer to I2C instance *‍/.
Temperature Sensor Configuration and Driver Selection.
uint8_t u8
Definition type.h:26