Bar Logo Dual Active Bridge Development Board (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
dev_fan.c
Go to the documentation of this file.
1
2
3
10#include "dev_fan.h"
11#include "dev_temp.h"
12#include "config/macros.h"
13
14
23
29
31
32//Private Function Call Prototypes
33static uint16_t Convert_From_Percentage (uint8_t percentage);
34static uint8_t Convert_From_Raw(uint16_t raw);
35static void Override_Speed(void);
36static void Calculate_Speed(void);
37static void Update_Speed(void);
38
39
40
62
63
77{
78 static uint8_t currentTickCount;
79
80 if (devFanData.OverrideFlag == 1)
81 {
85 Update_Speed();
86 }
87 else if (++currentTickCount >= devFanData.Tick)
88 {
91 currentTickCount = 0;
92 }
93}
94
95
111{
112 static uint8_t fanSpeedPercent = 0;
113 uint16_t TCelsiusNTC = Dev_Temp_Get_Temperature_Celcius();//
114
115 if(TCelsiusNTC > H_TEMPERATURE_THRESHOLD){
116 fanSpeedPercent += 2;
117 // Fan speed maximum clamping value
118 if(fanSpeedPercent >= MAX_SPEED_PERCENT){
119 fanSpeedPercent = MAX_SPEED_PERCENT;
120 }
121 else{}
122 }
123 else if(TCelsiusNTC < L_TEMPERATURE_THRESHOLD){
124 fanSpeedPercent -= 2;
125 // Fan speed minimum clamping value
126 if(fanSpeedPercent <= 10){
127 fanSpeedPercent = 10;//hw request to have a minimum load on auxiliary supply
128 }
129 else{}
130 }
131 else{}
132
133 Dev_Fan_Set_Speed(fanSpeedPercent);
134}
135
136
146{
149}
150
151
159void Dev_Fan_Set_Speed(uint8_t target_speed_percent)
160{
161 if (target_speed_percent <= MAX_SPEED_PERCENT)
162 {
163 devFanData.TargetSpeedPercent = target_speed_percent;
164 }
165}
166
167
175static uint16_t Convert_From_Percentage(uint8_t percentage_value)
176{
177 return (percentage_value * MULTIPLIER) ;
178}
179
180
192
193
222
223
242
243
251static uint8_t Convert_From_Raw(uint16_t raw)
252{
253 return ( raw * 0.02 ); //TODO: recalculate math
254}
255
256
static uint8_t Convert_From_Raw(uint16_t raw)
Definition dev_fan.c:251
enum FAN_SETTINGS_e FAN_SETTINGS_t
Definition dev_fan.c:28
static FAN_SETTINGS_t changeSpeed
Definition dev_fan.c:30
FAN_DATA_t * devFanDataPtr
Definition dev_fan.c:22
FAN_SETTINGS_e
Definition dev_fan.c:24
@ NO_CHANGE
Definition dev_fan.c:25
@ CHANGE_SPEED
Definition dev_fan.c:26
fan device driver
#define MIN_TICK
fastest possible tick. needed for override flag.
Definition dev_fan.h:41
#define STEP_SIZE
in percent. needed for overide flag.
Definition dev_fan.h:42
#define MAX_SPEED_PERCENT
macros defining the speed limits
Definition dev_fan.h:39
#define INIT_SPEED_PERCENT
intial start fan value
Definition dev_fan.h:40
#define MULTIPLIER
These have to be renamed to make the fan device driver abstract.
Definition dev_fan.h:30
Contains temperature initialization and execution functions.
#define L_TEMPERATURE_THRESHOLD
Definition macros.h:159
#define H_TEMPERATURE_THRESHOLD
Definition macros.h:160
static void Override_Speed(void)
Override the fan speed with maximum speed.
Definition dev_fan.c:187
void Dev_Fan_Task_100ms(void)
this function needs to be called every 100ms it contains the code to update the status of the fan
Definition dev_fan.c:76
static uint16_t Convert_From_Percentage(uint8_t percentage)
Converts the percentage value to number of ticks.
Definition dev_fan.c:175
FAN_DATA_t devFanData
Data Object of fan.
Definition dev_fan.c:21
void Dev_Fan_Set_Speed(uint8_t target_speed_percent)
Sets the fan speed.
Definition dev_fan.c:159
static void Calculate_Speed(void)
Calculates the fan speed.
Definition dev_fan.c:200
void Dev_Fan_Set_Override(void)
Sets the fan override bit and the fan speed.
Definition dev_fan.c:145
void Dev_Fan_Initialize(void)
This function initializes the fan object.
Definition dev_fan.c:49
static void Update_Speed(void)
Update the fan speed.
Definition dev_fan.c:230
void Dev_Fan_Task_1s(void)
This function needs to be called every 1s to keep the temperature of the board at a certain temperatu...
Definition dev_fan.c:110
int8_t Dev_Temp_Get_Temperature_Celcius(void)
This converts the raw values to temperature celcius as per device lookup table.
Definition dev_temp.c:87
#define FAN_PWM_DutyCycleSet
This macro defines the Custom Name for SCCP3_PWM_DutyCycleSet API.
Definition sccp3.h:90
A custom data type for fan.
Definition dev_fan.h:50
uint16_t MaxSpeedRaw
based on period value (CCXPRL).
Definition dev_fan.h:58
uint16_t Tick
set the execution rate in multiples of 100ms
Definition dev_fan.h:54
uint8_t OverrideFlag
override flag. sets tick value to 1, step_size to 20 and target to 100%
Definition dev_fan.h:59
uint16_t StepSizePercent
set the increment rate per tick in percentage
Definition dev_fan.h:55
uint16_t CurrentSpeedRaw
current value raw.
Definition dev_fan.h:57
uint16_t TargetSpeedRaw
targetted value raw.
Definition dev_fan.h:56
uint8_t TargetSpeedPercent
targetted Speed in percentage
Definition dev_fan.h:52
uint16_t MaxSpeedPercent
based on period value (CCXPRL). Use this to limit the fan max speed
Definition dev_fan.h:53
uint8_t CurrentSpeedPercent
Current Speed in percentage.
Definition dev_fan.h:51