shark: fixed uart bug

Thu, 01 Dec 2011 14:41:19 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Thu, 01 Dec 2011 14:41:19 +0100
changeset 29
ba4f69250592
parent 28
d4235895fdbc
child 30
10c78c097d18

shark: fixed uart bug

carrerashark/Makefile file | annotate | diff | comparison | revisions
carrerashark/main.c file | annotate | diff | comparison | revisions
--- a/carrerashark/Makefile	Thu Dec 01 14:17:21 2011 +0100
+++ b/carrerashark/Makefile	Thu Dec 01 14:41:19 2011 +0100
@@ -9,7 +9,7 @@
 
 F_CPU = 8000000
 
-BAUD=38400
+BAUD=115200
 ISP_BAUD = 115200
 
 #SRC = main.c seriald.c driver/ADC.c driver/clock.c driver/timer.c
--- a/carrerashark/main.c	Thu Dec 01 14:17:21 2011 +0100
+++ b/carrerashark/main.c	Thu Dec 01 14:41:19 2011 +0100
@@ -110,7 +110,9 @@
 int main(void)
 {
     uint8_t i;
-    unsigned char s[30];
+    unsigned char s[10];
+    uint16_t tmp;
+    uint16_t cycle[11];
 
     // setup data bit timer
     TCCR2 = (1<<CS21) | (1<<WGM21); //divide by 8, set compare match
@@ -136,18 +138,24 @@
 
         if (data != 0) {
             if (data_len > 5) {
+                tmp = data;
+                data = 0;
                 if (data_len == 13) { // sync to first packet
-                    i = 1;
-                    RS232_puts("\n");
                     PORTD ^= _BV(PD5);
-                } else if (i!=0) i++;
-                if (i>0) {
-                    itoa( data, s, 16);
-                    data = 0;
-                    RS232_puts("0x");
-                    RS232_puts( s );
-                    RS232_putc(' ');
+                    for (i=0; i<10;i++ ) {
+                        // output previous cycle data
+                        itoa( cycle[i], s, 16);
+                        RS232_putc('0');
+                        RS232_putc('x');
+                        RS232_puts( s );
+                        RS232_putc(' ');
+                    }
+                    RS232_putc('\n');
+                    i = 0;
+                    PORTD ^= _BV(PD5);
                 }
+                cycle[i] = tmp;
+                i++;
             }
             //if (i==10) for (;;);
         }

mercurial