|  | Dual Active Bridge Development Board (Part-No. ) |
Content |  |  |  |  |  |

Loading...
Searching...
No Matches
pwrctrl_common.c
Go to the documentation of this file.
1
9#include <xc.h>
10#include <stdint.h> // include standard integer data types
11#include <stdbool.h> // include standard boolean data types
12#include <stddef.h>
13
14#include "pwrctrl.h"
15
16
25uint16_t PwrCtrl_UpdateAverage(AVERAGING_t* data, uint16_t sample)
26{
27 data->Accumulator += sample;
28 if(++data->Counter >= data->AveragingCount){
29 data->AverageValue = (uint16_t)(__builtin_divud(data->Accumulator, data->Counter));
30 data->Accumulator = 0;
31 data->Counter = 0;
32 }
33 return(data->AverageValue);
34}
35
36
46 bool PwrCtrl_RampReference(START_UP_RAMP_t* rampUp)
47{
48 rampUp->RampComplete = false;
49
50 if (++rampUp->Counter > rampUp->Delay)
51 {
52 rampUp->Counter = 0;
53
54 if(*rampUp->ptrReference == *rampUp->ptrReferenceTarget)
55 {
56 rampUp->RampComplete = true;
57 }
58 else if ((*rampUp->ptrReference + rampUp->StepSize) < *rampUp->ptrReferenceTarget)
59 {
60 *rampUp->ptrReference += rampUp->StepSize;
61 }
62 else if ((*rampUp->ptrReference - rampUp->StepSize) > *rampUp->ptrReferenceTarget)
63 {
64 *rampUp->ptrReference -= rampUp->StepSize;
65 }
66 else
67 {
68 *rampUp->ptrReference = *rampUp->ptrReferenceTarget;
69 rampUp->RampComplete = true;
70 }
71 }
72
73 return (rampUp->RampComplete);
74}
75
PwrCtrl_RampReference
bool PwrCtrl_RampReference(START_UP_RAMP_t *rampUp)
Softly increment / decrement to the set reference target.
Definition pwrctrl_common.c:46
PwrCtrl_UpdateAverage
uint16_t PwrCtrl_UpdateAverage(AVERAGING_t *data, uint16_t sample)
Average the raw data over number of samples.
Definition pwrctrl_common.c:25
AVERAGING_s
Definition pwrctrl_common.h:18
AVERAGING_s::Accumulator
uint32_t Accumulator
Definition pwrctrl_common.h:19
AVERAGING_s::AveragingCount
uint16_t AveragingCount
Definition pwrctrl_common.h:21
AVERAGING_s::AverageValue
uint16_t AverageValue
Definition pwrctrl_common.h:22
AVERAGING_s::Counter
uint16_t Counter
Definition pwrctrl_common.h:20
START_UP_RAMP_s
Stores data related to the ramping up/down of the reference.
Definition pwrctrl_typedef.h:99
START_UP_RAMP_s::RampComplete
bool RampComplete
indicates when ramp-up is complete
Definition pwrctrl_typedef.h:105
START_UP_RAMP_s::Delay
uint16_t Delay
Soft-Start Period (POD, RAMP PERIOD, PGD, etc.)
Definition pwrctrl_typedef.h:101
START_UP_RAMP_s::ptrReferenceTarget
uint16_t * ptrReferenceTarget
pointer to the ramp-up reference target
Definition pwrctrl_typedef.h:104
START_UP_RAMP_s::ptrReference
uint16_t * ptrReference
pointer the reference variable
Definition pwrctrl_typedef.h:103
START_UP_RAMP_s::Counter
uint16_t Counter
Soft-Start Execution Counter. This setting is set/cleared by the device driver and is 'read only'.
Definition pwrctrl_typedef.h:100
START_UP_RAMP_s::StepSize
uint16_t StepSize
Size/value of one reference increment/decrement or this period.
Definition pwrctrl_typedef.h:102