📄 bsp_temperature.c
字号:
#include <includes.h>
/*********************************************************************************************************
* Temperature_Reading()
*
* Description : Function reading the Temperature value from the SA56004
*
* Argument(s) : Temperature (integer + decimal) , Temp Sensor type : INTERNAL or EXTERNAL
*
* Return(s) : none.
*********************************************************************************************************/
void Temperature_Reading(CPU_INT08S *integer,CPU_INT08U *decimal, CPU_INT08S Temp_Type)
{
CPU_INT08U reg;
CPU_INT08U data;
if (Temp_Type == INTERNAL)
{
reg = 0x00;
data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*integer = data;
reg = 0x22;
data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*decimal = (data>>5) & 0x07;
}
if (Temp_Type == EXTERNAL)
{
reg = 0x01;
data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*integer = data;
reg = 0x10;
data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*decimal = (data>>5) & 0x07;
}
}
/*********************************************************************************************************
* Temp_Sensor_Write()
*
* Description : Function writing to a specific register of the SA56004
*
* Argument(s) : Address of the register to be accessed and data to write to that register
*
* Return(s) : none.
*********************************************************************************************************/
void Temp_Sensor_Write(CPU_INT08U Reg_Ptr, CPU_INT08U Data_Write)
{
CPU_INT08U I2C_Data_Write_Buffer[2];
I2C_Data_Write_Buffer[0] = Reg_Ptr;
I2C_Data_Write_Buffer[1] = Data_Write;
I2C_Write(SA56004_ADDRESS,I2C_Data_Write_Buffer, 2); // Write to SA56004
}
/*********************************************************************************************************
* SetTempHighLimitLocal()
*
* Description : Set Local Temperature High Limit
*
* Argument(s) : Local Temperature High Limit Value.
*
* Return(s) : none.
*********************************************************************************************************/
void SetTempHighLimitLocal (CPU_INT08S HighLimitLocalInteger)
{
Temp_Sensor_Write(0x0B, HighLimitLocalInteger);
}
/*********************************************************************************************************
* SetTempLowLimitLocal()
*
* Description : Set Local Temperature Low Limit
*
* Argument(s) : Local Temperature Low Limit Value.
*
* Return(s) : none.
*********************************************************************************************************/
void SetTempLowLimitLocal (CPU_INT08S LowLimitLocalInteger)
{
Temp_Sensor_Write(0x0C, LowLimitLocalInteger);
}
/*********************************************************************************************************
* GetTempHighLimitLocal()
*
* Description : Read Local Temperature High Limit
*
* Argument(s) : Pointer to the Local Temperature High Limit Value.
*
* Return(s) : none.
*********************************************************************************************************/
void GetTempHighLimitLocal(CPU_INT08S *integer)
{
CPU_INT08U reg = 0x05;
CPU_INT08U data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*integer = data;
}
/*********************************************************************************************************
* GetTempLowLimitLocal()
*
* Description : Read Local Temperature Low Limit
*
* Argument(s) : Pointer to the Local Temperature Low Limit Value.
*
* Return(s) : none.
*********************************************************************************************************/
void GetTempLowLimitLocal(CPU_INT08S *integer)
{
CPU_INT08U reg = 0x06;
CPU_INT08U data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*integer = data;
}
/*********************************************************************************************************
* SetTempHighLimitRemote()
*
* Description : Set Remote Temperature High Limit
*
* Argument(s) : Remote Temperature High Limit Value.
*
* Return(s) : none.
*********************************************************************************************************/
void SetTempHighLimitRemote (CPU_INT08S HighLimitRemoteInteger, CPU_INT08S HighLimitRemoteDecimal)
{
Temp_Sensor_Write(0x0D, HighLimitRemoteInteger);
Temp_Sensor_Write(0x13, HighLimitRemoteDecimal);
}
/*********************************************************************************************************
* SetTempLowLimitRemote()
*
* Description : Set Remote Temperature Low Limit
*
* Argument(s) : Remote Temperature Low Limit Value.
*
* Return(s) : none.
*********************************************************************************************************/
void SetTempLowLimitRemote (CPU_INT08S LowLimitRemoteInteger, CPU_INT08S LowLimitRemoteDecimal)
{
Temp_Sensor_Write(0x0E, LowLimitRemoteInteger);
Temp_Sensor_Write(0x14, LowLimitRemoteDecimal);
}
/*********************************************************************************************************
* GetTempHighLimitRemote()
*
* Description : Read Remote Temperature High Limit
*
* Argument(s) : Pointer to Remote Temperature High Limit Value.
*
* Return(s) : none.
*********************************************************************************************************/
void GetTempHighLimitRemote (CPU_INT08S *integer,CPU_INT08U *decimal)
{
CPU_INT08U reg;
CPU_INT08U data;
reg = 0x07;
data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*integer = data;
reg = 0x13;
data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*decimal = (data>>5) & 0x07;
}
/*********************************************************************************************************
* GetTempLowLimitRemote()
*
* Description : Read Remote Temperature Low Limit
*
* Argument(s) : Pointer to Remote Temperature Low Limit Value.
*
* Return(s) : none.
*********************************************************************************************************/
void GetTempLowLimitRemote (CPU_INT08S *integer,CPU_INT08U *decimal)
{
CPU_INT08U reg;
CPU_INT08U data;
reg = 0x08;
data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*integer = data;
reg = 0x14;
data = 0xFF;
I2C_ReadReg(SA56004_ADDRESS, &data, 1, reg);
*decimal = (data>>5) & 0x07;
}
/*********************************************************************************************************
* SetCriticalTempRemote()
*
* Description : Set Remote Temperature Critical Limit
*
* Argument(s) : Remote Temperature Critical Limit value.
*
* Return(s) : none.
*********************************************************************************************************/
void SetCriticalTempRemote (CPU_INT08S CriticalTempRemoteInteger)
{
Temp_Sensor_Write(0x19, CriticalTempRemoteInteger);
}
/*********************************************************************************************************
* SetCriticalTempLocal()
*
* Description : Set Local Temperature Critical Limit
*
* Argument(s) : Local Temperature Critical Limit Value.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -