# HG changeset patch # User Malte Bayer # Date 1322907036 -3600 # Node ID a8f082503782cb05cda13c98c0dcc9e4846dbd00 # Parent 10c78c097d1841499b25251241e998109da11a49 carrerashark minor changes diff -r 10c78c097d18 -r a8f082503782 carrerashark/README --- a/carrerashark/README Thu Dec 01 15:31:19 2011 +0100 +++ b/carrerashark/README Sat Dec 03 11:10:36 2011 +0100 @@ -5,7 +5,7 @@ PD2 = Controller Input |>o = Inv Schmitt Trigger for signal buffering (74hc14) - [RAIL+] ------[33kohm]------+-----|>o--|>0----[PD2] + [RAIL+] ------[33kohm]------+-----|>o--|>o----[PD2] | --[10kohm]--- | diff -r 10c78c097d18 -r a8f082503782 carrerashark/main.c --- a/carrerashark/main.c Thu Dec 01 15:31:19 2011 +0100 +++ b/carrerashark/main.c Sat Dec 03 11:10:36 2011 +0100 @@ -57,16 +57,27 @@ volatile uint8_t bitbuf_len = 0; volatile uint16_t bitbuf = 0; +volatile uint16_t sysclock = 0; +ISR ( TIMER0_OVF_vect ) { + PORTD ^= _BV(PD6); + if (sysclock != 0xffff) sysclock++; +} + ISR ( INT0_vect ) { PORTD ^= _BV(PD3); + if (sysclock<10) { + // this is the answer slot start bit?? + PORTD ^= _BV(PD7); + } else { GICR &= ~_BV(INT0) ; // Disable INT0 - // Startsignal erkannt, ab hier den Timer2 starten, - // der liest dann alle 50µs den Zustand ein und schreibt das - // empfangene Bit in den Puffer - bitbuf = 0; // init - bitbuf_len = 0b10000000; // init 1 pulse received - TCNT2 = 0; - TIMSK |= _BV(OCIE2); //enable timer2 interrupt + // Startsignal erkannt, ab hier den Timer2 starten, + // der liest dann alle 50µs den Zustand ein und schreibt das + // empfangene Bit in den Puffer + bitbuf = 0; // init + bitbuf_len = 0b10000000; // init 1 pulse received + TCNT2 = 0; + TIMSK |= _BV(OCIE2); //enable timer2 interrupt + } } @@ -87,8 +98,10 @@ data_len = (bitbuf_len & 0b00111111); if (data_len == 13) PORTD ^= _BV(6); // debug sync output on program packets TIMSK &= ~_BV(OCIE2); //disable timer2 interrupt - GICR |= _BV(INT0) ; // Enable INT0 + GICR |= _BV(INT0); // Enable INT0 + GIFR &= ~_BV(INTF0); // clear int0 irq flag data = bitbuf; // output data + sysclock = 0; // reset system clock counter } else { bitbuf_len++; // increment bit counter bitbuf = bitbuf << 1; // shift bits @@ -119,13 +132,20 @@ OCR2 = TIMER2_50US; TIMSK |= 1<