1 #include "pregulator.h"
2 #include "../bbb_pin.h"
4 #define PREGULATOR_PWM ECAP0
5 #define PREGULATOR_PERIOD 500000
9 * Initiliase the pressure regulator
11 bool Pregulator_Init(const char * name, int id)
13 return PWM_Export(PREGULATOR_PWM) && PWM_Set(PREGULATOR_PWM, false, PREGULATOR_PERIOD, 0);
16 bool Pregulator_Cleanup(int id)
18 if (!PWM_Set(PREGULATOR_PWM, false, PREGULATOR_PERIOD, 0))
20 PWM_Unexport(PREGULATOR_PWM);
24 bool Pregulator_Set(int id, double value)
26 return PWM_Set(PREGULATOR_PWM, false, PREGULATOR_PERIOD, value*(PREGULATOR_PERIOD));
29 bool Pregulator_Sanity(int id, double value)
31 return (value >= 0.0 && value <= 1.0);