|
@@ -8,14 +8,14 @@
|
|
|
|
|
|
|
|
|
out_t outputs[DO_NUMBER] = {
|
|
|
- {GPIOC, GPIO_PINS_12, 0, 0, 0}, // -
|
|
|
- {GPIOD, GPIO_PINS_2, 0, 0, 0}, // -
|
|
|
- {GPIOE, GPIO_PINS_6, 0, 0, 0}, // TMR9_CH2 (remap)
|
|
|
- {GPIOC, GPIO_PINS_1, 0, 0, 0}, // -
|
|
|
- {GPIOC, GPIO_PINS_11, 0, 0, 0}, // -
|
|
|
- {GPIOD, GPIO_PINS_3, 0, 0, 0}, // -
|
|
|
- {GPIOE, GPIO_PINS_5, 0, 0, 0}, // TMR9_CH1 (remap)
|
|
|
- {GPIOC, GPIO_PINS_2, 0, 0, 0} // -
|
|
|
+ {GPIOC, GPIO_PINS_12, 0, 0, 0, false}, // -
|
|
|
+ {GPIOD, GPIO_PINS_2, 0, 0, 0, false}, // -
|
|
|
+ {GPIOE, GPIO_PINS_6, 0, 0, 0, false}, // TMR9_CH2 (remap)
|
|
|
+ {GPIOC, GPIO_PINS_1, 0, 0, 0, false}, // -
|
|
|
+ {GPIOC, GPIO_PINS_11, 0, 0, 0, false}, // -
|
|
|
+ {GPIOD, GPIO_PINS_3, 0, 0, 0, false}, // -
|
|
|
+ {GPIOE, GPIO_PINS_5, 0, 0, 0, false}, // TMR9_CH1 (remap)
|
|
|
+ {GPIOC, GPIO_PINS_2, 0, 0, 0, false} // -
|
|
|
};
|
|
|
|
|
|
|
|
@@ -90,6 +90,8 @@ void do_update(out_t *out, uint8_t index)
|
|
|
// Режим обычного выхода
|
|
|
else
|
|
|
{
|
|
|
+ out->mode = 0;
|
|
|
+
|
|
|
// Безопасный режим включен
|
|
|
if (get_save_mode()) {
|
|
|
do_set_out(out, settings.do_save_bits & (1 << index));
|
|
@@ -111,7 +113,7 @@ void do_set_mode(void)
|
|
|
{
|
|
|
if ((settings.do_mode_bits & (1 << i)) != (output_mode_bit & (1 << i)))
|
|
|
{
|
|
|
- settings.do_mode_bits |= (1 << i);
|
|
|
+ settings.do_mode_bits ^= (1 << i);
|
|
|
do_update(&outputs[i], i);
|
|
|
}
|
|
|
}
|
|
@@ -124,7 +126,11 @@ void do_set_mode(void)
|
|
|
void do_set_pwm(uint16_t pwm, uint8_t index)
|
|
|
{
|
|
|
//outputs[index].pwm_duty_cnt = (uint16_t)(outputs[index].pwm_period_cnt*pwm/100.0);
|
|
|
- outputs[index].pwm_duty_cnt = (uint16_t)(PWM_PERIOD_TEST*pwm/100.0);
|
|
|
+ //outputs[index].pwm_duty_cnt = (uint16_t)(PWM_PERIOD_TEST*pwm/100.0);
|
|
|
+
|
|
|
+ outputs[index].pwm_flag = false;
|
|
|
+ outputs[index].pwm_period_cnt = 0;
|
|
|
+ outputs[index].pwm_duty_cnt = 0;
|
|
|
outputs[index].mode = 1;
|
|
|
|
|
|
}
|
|
@@ -132,10 +138,14 @@ void do_set_pwm(uint16_t pwm, uint8_t index)
|
|
|
//
|
|
|
void do_set_out(out_t *out, uint8_t val)
|
|
|
{
|
|
|
- if (val)
|
|
|
+ if (val) {
|
|
|
+ gpio_bits_set(GPIOB, GPIO_PINS_15);
|
|
|
gpio_bits_set(out->port, out->pin);
|
|
|
- else
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ gpio_bits_reset(GPIOB, GPIO_PINS_15);
|
|
|
gpio_bits_reset(out->port, out->pin);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//
|
|
@@ -216,23 +226,24 @@ inline void pwm_proc(void)
|
|
|
{
|
|
|
if (outputs[i].mode) // режим PWM
|
|
|
{
|
|
|
- outputs[i].pwm_period_cnt++;
|
|
|
- outputs[i].pwm_duty_cnt++;
|
|
|
-
|
|
|
- if (outputs[i].pwm_period_cnt == PWM_PERIOD_TEST)
|
|
|
- {
|
|
|
+ if (outputs[i].pwm_period_cnt == PWM_PERIOD_TEST) {
|
|
|
outputs[i].pwm_period_cnt = 0;
|
|
|
+ }
|
|
|
+ if (outputs[i].pwm_period_cnt == 0) {
|
|
|
+ outputs[i].pwm_flag = false;
|
|
|
gpio_bits_set(GPIOB, GPIO_PINS_15);
|
|
|
}
|
|
|
- else if (outputs[i].pwm_duty_cnt == PWM_DUTY_TEST)
|
|
|
- {
|
|
|
+ if (outputs[i].pwm_duty_cnt == PWM_DUTY_TEST) {
|
|
|
outputs[i].pwm_duty_cnt = 0;
|
|
|
gpio_bits_reset(GPIOB, GPIO_PINS_15);
|
|
|
+ outputs[i].pwm_flag = true;
|
|
|
+ }
|
|
|
+ outputs[i].pwm_period_cnt++;
|
|
|
+ if (outputs[i].pwm_flag == false) {
|
|
|
+ outputs[i].pwm_duty_cnt++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//
|