|
@@ -20,6 +20,12 @@ static void set_dac(uint8_t slot, uint16_t value) {
|
|
|
static void set_pwm(uint8_t slot, uint16_t value) {
|
|
static void set_pwm(uint8_t slot, uint16_t value) {
|
|
|
battery_slots[slot].pwm_value = value;
|
|
battery_slots[slot].pwm_value = value;
|
|
|
DL_TimerG_setCaptureCompareValue(battery_slots[slot].timer, value, DL_TIMER_CC_1_INDEX);
|
|
DL_TimerG_setCaptureCompareValue(battery_slots[slot].timer, value, DL_TIMER_CC_1_INDEX);
|
|
|
|
|
+ if (value > 0 && !DL_TimerG_isRunning(battery_slots[slot].timer)) {
|
|
|
|
|
+ DL_TimerG_startCounter(battery_slots[slot].timer);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (value == 0 && DL_TimerG_isRunning(battery_slots[slot].timer)) {
|
|
|
|
|
+ DL_TimerG_stopCounter(battery_slots[slot].timer);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
static void batteryslots_disable(uint8_t slot) {
|
|
static void batteryslots_disable(uint8_t slot) {
|
|
|
if (battery_slots[slot].dac_value != 0) {
|
|
if (battery_slots[slot].dac_value != 0) {
|
|
@@ -56,7 +62,6 @@ static void batteryslots_init() {
|
|
|
battery_slots[i].measurement.temperature = 0;
|
|
battery_slots[i].measurement.temperature = 0;
|
|
|
battery_slots[i].set_current = 0;
|
|
battery_slots[i].set_current = 0;
|
|
|
|
|
|
|
|
- DL_TimerG_startCounter(battery_slots[i].timer);
|
|
|
|
|
set_pwm(i, 0);
|
|
set_pwm(i, 0);
|
|
|
set_dac(i, 0);
|
|
set_dac(i, 0);
|
|
|
delay_cycles(PWM_INITIALIZATION_DELAY);
|
|
delay_cycles(PWM_INITIALIZATION_DELAY);
|