diff --git a/src/main.c b/src/main.c index a3d3e93..407e4f5 100644 --- a/src/main.c +++ b/src/main.c @@ -126,25 +126,33 @@ int main() { + // seconds TCCR2 = 0b00000101; ASSR |= (1 << AS2); TIMSK |= (1 << TOIE2) | (1 << TICIE1); + // signal measurment TCCR1A = 0; TCCR1B = (1 << CS12) | (1 << CS10); DDRD &= ~(1 << PD2); DDRD &= ~(1 << PD3); PORTD |= (1 << PD2) | (1 << PD3); + MCUCR |= (1 << ISC11) | (1 << ISC10) | (1 << ISC01); + GICR |= (1 << INT0) | (1 << INT1); + // esd prot DDRD |= (1 << PD5) | (1 << PD6); + // valid led DDRB |= (1 << PB0); TCCR0 = (1 << CS02) | (1 << CS00); TIMSK |= (1 << TOIE0); - MCUCR |= (1 << ISC11) | (1 << ISC10) | (1 << ISC01); - GICR |= (1 << INT0) | (1 << INT1); + // position switches + DDRB &= ~(1 << PB1); + DDRB &= ~(1 << PB2); + PORTB |= (1 << PB1) | (1 << PB2); sei(); @@ -487,6 +495,13 @@ int main() { } + static uint8_t oldPositionSwitch = 255; + uint8_t positionSwitch = PINB & ((1 << PB1) | (1 << PB2)); + if (oldPositionSwitch != positionSwitch) { + oldPositionSwitch = positionSwitch; + printf("POS: %02d\n", positionSwitch); + } + if (tack != 0) { tack = 0; switch (valid) {