carrerashark/main.c

Tue, 22 Nov 2011 21:36:35 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Tue, 22 Nov 2011 21:36:35 +0100
changeset 13
0bb6f12124fd
parent 12
a399f9d5e672
child 28
d4235895fdbc
permissions
-rw-r--r--

added android trackscanner project

12
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
1 #include <avr/interrupt.h>
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
2 #include <avr/io.h>
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
3 #include <avr/wdt.h>
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
4 #include <avr/eeprom.h>
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
5 #include <stdlib.h>
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
6 #include <stdint.h>
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
7 #include <avr/pgmspace.h>
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
8
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
9 #include "main.h"
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
10
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
11 #include "driver/rs232.h"
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
12 #include "util/delay.h"
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
13
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
14
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
15 static char buffer[RS232_BUFSIZE+1];
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
16 static uint8_t buffer_len;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
17
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
18
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
19
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
20
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
21 // USART0 RX interrupt
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
22 ISR ( USART_RXC_vect ) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
23 char c = UDR;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
24
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
25 // check for buffer overflow
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
26 if (buffer_len==sizeof(buffer)) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
27 buffer_len=0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
28 if (c == 27) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
29 // escape sequence, store to empty buffer
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
30 buffer[buffer_len++] = c;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
31 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
32 } else {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
33 // collect characters until end of line
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
34 if (c == 27) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
35 // escape sequence, clear buffer
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
36 buffer_len = 0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
37 buffer[buffer_len++] = c;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
38 } else if ( (c==0xff) && (buffer_len > 3) ) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
39 buffer[buffer_len]=0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
40
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
41 // packet end received, parse the received packet
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
42
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
43 // wait for the next packet
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
44 buffer_len=0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
45 } else {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
46 buffer[buffer_len++]=c;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
47 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
48 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
49 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
50
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
51
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
52 #define PULSE_PORT PORTD
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
53 #define PULSE_BIT PD2
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
54
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
55 volatile uint16_t data = 0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
56 volatile uint8_t data_len = 0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
57 volatile uint8_t bitbuf_len = 0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
58 volatile uint16_t bitbuf = 0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
59
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
60 ISR ( INT0_vect ) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
61 writeBit(PORTD, 5, 1);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
62 GICR &= ~_BV(INT0) ; // Disable INT0
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
63 // Startsignal erkannt, ab hier den Timer2 starten,
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
64 // der liest dann alle 50µs den Zustand ein und schreibt das
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
65 // empfangene Bit in den Puffer
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
66 bitbuf = 0; // init
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
67 bitbuf_len = 0b10000000; // init 1 pulse received
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
68 TCNT2 = 0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
69 TIMSK |= _BV(OCIE2); //enable timer2 interrupt
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
70 writeBit(PORTD, 5, 0);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
71 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
72
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
73
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
74 ISR ( TIMER2_COMP_vect ) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
75 writeBit(PORTD, 4, 0);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
76
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
77 uint8_t clock;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
78 uint8_t state;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
79 uint8_t state2;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
80 if ((bitbuf_len & 0b10000000) == 0) clock = 0; else clock = 0xff;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
81 if ((bitbuf_len & 0b01000000) == 0) state = 0; else state = 0xff;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
82 if ((PIN(PULSE_PORT) & _BV(PULSE_BIT)) == 0) state2 = 0; else state2 = 0xff;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
83
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
84 if (clock) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
85 // second pulse of bit
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
86 bitbuf_len &= ~_BV(7); // switch clock to low
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
87 if ((state==state2) & state2) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
88 // two cycles high: packet end received
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
89 data_len = (bitbuf_len & 0b00111111);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
90 if (data_len == 13) PORTD ^= _BV(6); // debug sync output on program packets
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
91 TIMSK &= ~_BV(OCIE2); //disable timer2 interrupt
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
92 GICR |= _BV(INT0) ; // Enable INT0
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
93 data = bitbuf; // output data
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
94 } else {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
95 bitbuf_len++; // increment bit counter
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
96 bitbuf = bitbuf << 1; // shift bits
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
97 if (state2 == 0) bitbuf |= 1; // receive logic one
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
98 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
99 } else {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
100 // first pulse of bit
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
101 bitbuf_len |= _BV(7); // switch clock to high
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
102 if (state2) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
103 bitbuf_len |= _BV(6); // store new state
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
104 } else {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
105 bitbuf_len &= ~_BV(6); // store new state
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
106 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
107 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
108
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
109
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
110 writeBit(PORTD, 4, 1);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
111 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
112
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
113
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
114
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
115 int main(void)
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
116 {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
117 uint8_t i;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
118 unsigned char s[30];
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
119
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
120 // setup data bit timer
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
121 TCCR2 = (1<<CS21) | (1<<WGM21); //divide by 8, set compare match
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
122 OCR2 = TIMER2_50US;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
123 TIMSK |= 1<<OCIE2; //enable timer2 interrupt
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
124
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
125 MCUCR = _BV(ISC00); // falling edge
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
126 GICR = _BV(INT0) ; // Enable INT0
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
127
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
128 writeBit(DDRD, 4, 1);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
129 writeBit(DDRD, 5, 1);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
130 writeBit(DDRD, 6, 1);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
131
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
132
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
133 RS232_init(); // initialize RS232 interface
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
134 RS232_puts_p(PSTR("CarreraShark 1.0 - INIT OK\n"));
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
135 //RS232_puts_p(PSTR("Receiving one complete cycle:\n"));
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
136
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
137 sei();
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
138 i = 0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
139 while (1) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
140 // main loop
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
141
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
142 if (data != 0) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
143 if (data_len > 5) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
144 if (data_len == 13) { // sync to first packet
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
145 i = 1;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
146 RS232_puts("\n");
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
147 } else if (i!=0) i++;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
148 if (i>0) {
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
149 itoa( data, s, 16);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
150 data = 0;
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
151 RS232_puts("0x");
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
152 RS232_puts( s );
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
153 RS232_putc(' ');
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
154 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
155 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
156 //if (i==10) for (;;);
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
157 }
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
158 } // main loop end
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
159 };
a399f9d5e672 added carrerashark project-part to separate subdirectory
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
160

mercurial