This commit is contained in:
2025-09-10 19:34:18 +03:00
parent cf222035b3
commit a2e5b3389c
2 changed files with 9 additions and 11 deletions

View File

@@ -5,7 +5,7 @@
#include "avr_port.h" #include "avr_port.h"
#include "stdbool.h" #include "stdbool.h"
#include "avr/interrupt.h" #include "avr/interrupt.h"
// #include "avr/pgmspace.h" #include "util/delay.h"
#define ZH_AVR_AC_DIMMER_INIT_CONFIG_DEFAULT() \ #define ZH_AVR_AC_DIMMER_INIT_CONFIG_DEFAULT() \
{ \ { \

View File

@@ -83,17 +83,16 @@ void zh_avr_ac_dimmer_isr_handler(void)
{ {
case AVR_PORTB: case AVR_PORTB:
PORTB |= (1 << _init_config.triac_gpio); PORTB |= (1 << _init_config.triac_gpio);
asm("nop"); _delay_us(5);
PORTB &= ~(1 << _init_config.triac_gpio); PORTB &= ~(1 << _init_config.triac_gpio);
break; break;
case AVR_PORTC: case AVR_PORTC:
PORTC |= (1 << _init_config.triac_gpio); PORTC |= (1 << _init_config.triac_gpio);
asm("nop"); _delay_us(5);
PORTC &= ~(1 << _init_config.triac_gpio); PORTC &= ~(1 << _init_config.triac_gpio);
break;
case AVR_PORTD: case AVR_PORTD:
PORTD |= (1 << _init_config.triac_gpio); PORTD |= (1 << _init_config.triac_gpio);
asm("nop"); _delay_us(5);
PORTD &= ~(1 << _init_config.triac_gpio); PORTD &= ~(1 << _init_config.triac_gpio);
break; break;
default: default:
@@ -240,23 +239,22 @@ ISR(TIMER0_COMPA_vect)
if (_dimmer_count == (100 - _dimmer_value)) if (_dimmer_count == (100 - _dimmer_value))
{ {
_dimmer_count = 0; _dimmer_count = 0;
TCCR0B &= ~_prescaler; TCCR0B = 0;
TIMSK0 &= ~(1 << OCIE0A); TIMSK0 = 0;
switch (_init_config.triac_port) switch (_init_config.triac_port)
{ {
case AVR_PORTB: case AVR_PORTB:
PORTB |= (1 << _init_config.triac_gpio); PORTB |= (1 << _init_config.triac_gpio);
asm("nop"); _delay_us(5);
PORTB &= ~(1 << _init_config.triac_gpio); PORTB &= ~(1 << _init_config.triac_gpio);
break; break;
case AVR_PORTC: case AVR_PORTC:
PORTC |= (1 << _init_config.triac_gpio); PORTC |= (1 << _init_config.triac_gpio);
asm("nop"); _delay_us(5);
PORTC &= ~(1 << _init_config.triac_gpio); PORTC &= ~(1 << _init_config.triac_gpio);
break;
case AVR_PORTD: case AVR_PORTD:
PORTD |= (1 << _init_config.triac_gpio); PORTD |= (1 << _init_config.triac_gpio);
asm("nop"); _delay_us(5);
PORTD &= ~(1 << _init_config.triac_gpio); PORTD &= ~(1 << _init_config.triac_gpio);
break; break;
default: default: