This commit is contained in:
wolfgang
2013-01-22 07:58:08 +01:00
parent 48293f5b4c
commit 02f25d0783

View File

@ -12,6 +12,8 @@
#define ZERO_WIDTH_MIN 70 #define ZERO_WIDTH_MIN 70
#define ZERO_WIDTH_MAX 150 #define ZERO_WIDTH_MAX 150
#define SUB_DIV_VAL 30
typedef struct receivedData_s { typedef struct receivedData_s {
uint8_t minuteDigit0; uint8_t minuteDigit0;
@ -55,7 +57,7 @@ volatile uint8_t tick;
volatile uint16_t captValue = 0; volatile uint16_t captValue = 0;
volatile uint16_t gapValue = 0; volatile uint16_t gapValue = 0;
volatile uint8_t valid = 0; volatile uint8_t valid = 0;
volatile uint8_t tack = 0;
ISR(TIMER2_OVF_vect) { ISR(TIMER2_OVF_vect) {
clock.second++; clock.second++;
@ -101,6 +103,14 @@ ISR(INT1_vect) {
tick = 1; tick = 1;
} }
ISR(TIMER0_OVF_vect) {
static uint16_t subDiv = 0;
subDiv++;
if (subDiv >= SUB_DIV_VAL) {
subDiv = 0;
tack = 1;
}
}
int main() { int main() {
uartdrvInit(); uartdrvInit();
@ -123,10 +133,16 @@ int main() {
TCCR1A = 0; TCCR1A = 0;
TCCR1B = (1 << CS12) | (1 << CS10); TCCR1B = (1 << CS12) | (1 << CS10);
PIND &= ~(1 << PD2); DDRD &= ~(1 << PD2);
PIND &= ~(1 << PD3); DDRD &= ~(1 << PD3);
PORTD |= (1 << PD2) | (1 << PD3); PORTD |= (1 << PD2) | (1 << PD3);
DDRD |= (1 << PD5) | (1 << PD6);
DDRB |= (1 << PB0);
TCCR0 = (1 << CS02) | (1 << CS00);
TIMSK |= (1 << TOIE0);
MCUCR |= (1 << ISC11) | (1 << ISC10) | (1 << ISC01); MCUCR |= (1 << ISC11) | (1 << ISC10) | (1 << ISC01);
GICR |= (1 << INT0) | (1 << INT1); GICR |= (1 << INT0) | (1 << INT1);
@ -139,6 +155,7 @@ int main() {
uint8_t bit = 0; uint8_t bit = 0;
uint8_t state = 0; uint8_t state = 0;
uint16_t validCnt = 0; uint16_t validCnt = 0;
uint8_t ledToggle = 0;
while (1) { while (1) {
@ -466,6 +483,30 @@ int main() {
valid, state, bit, pulse, gap, validCnt); valid, state, bit, pulse, gap, validCnt);
} }
} }
if (tack != 0) {
tack = 0;
switch (valid) {
case 0:
PORTB &= ~(1 << PB0);
break;
case 1:
if (ledToggle != 0) {
ledToggle = 0;
PORTB &= ~(1 << PB0);
} else {
ledToggle = 1;
PORTB |= (1 << PB0);
}
break;
case 2:
PORTB |= (1 << PB0);
break;
} }
} }
}
}