Write little test for serial.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 26 Oct 2007 15:50:31 +0000 (15:50 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 26 Oct 2007 15:50:31 +0000 (15:50 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@946 38d2e660-2303-0410-9eaa-f027e97ec537

app/at91sam7s/at91sam7s.c

index 57fdd8fde89a04268585ead10237cf8f5d31df43..371c7dc63f57fe8166885d716a9275d752485679 100644 (file)
 #include <cfg/macros.h>
 #include <io/arm.h>
 
-static int iort = 23;
-static int iort1 = 232;
-static int iort2 = 233;
-
 Timer leds_timer;
 
 static void leds_toggle(void)
@@ -79,7 +75,7 @@ int main(void)
        sysirq_init();
        timer_init();
 
-       proc_init();
+//  proc_init();
        ASSERT(!IRQ_ENABLED());
 
 
@@ -89,38 +85,58 @@ int main(void)
        ser_setbaudrate(host_port, 115200);
        ser_setparity(host_port, SER_PARITY_NONE);
 
+       /* Open the main communication port */
+       Serial *host_port1 = ser_open(1);
+       ser_setbaudrate(host_port1, 115200);
+       ser_setparity(host_port1, SER_PARITY_NONE);
+
        IRQ_ENABLE;
        ASSERT(IRQ_ENABLED());
 
        /* Disable all pullups */
        PIOA_PUDR = 0xffffffff;
        /* Set PA0..3 connected to PIOA */
-       PIOA_PER  = 0x0000000f;
+       PIOA_PER  = 0x0000001f;
        /* Set PA0..3 as output */
-       PIOA_OER  = 0x0000000f;
+       PIOA_OER  = 0x0000001f;
        /* Disable multidrive on all pins */
-       PIOA_MDDR = 0x0000000f;
+       PIOA_MDDR = 0x0000001f;
 
        /* Set PA0..3 to 1 to turn off leds */
        PIOA_SODR  = 0x0000000f;
        /* turn first led on */
        PIOA_CODR  = 0x00000001;
 
-       timer_set_event_softint(&leds_timer, (Hook)leds_toggle, 0);
-       timer_setDelay(&leds_timer, ms_to_ticks(100));
-       timer_add(&leds_timer);
 
+//     timer_set_event_softint(&leds_timer, (Hook)leds_toggle, 0);
+//     timer_setDelay(&leds_timer, ms_to_ticks(100));
+//     timer_add(&leds_timer);
+
+       int a=0;
        // Main loop
        for(;;)
        {
-               ser_printf(host_port," %s", "a");
-               kprintf("W la figa!\n");
-               proc_test();
-               iort+= 1;
-               iort1+= 1;
-               iort2+= 1;
+//             proc_test();
+
+               a = ser_getchar(host_port1);
+
+               if(a == 49)
+                       PIOA_CODR  = 0x0000000F;
+               if(a == 50)
+               {
+                       PIOA_SODR  = 0x0000000A;
+                       ser_printf(host_port, "%c", a);
+               }
+
+               if(a == 51)
+                       PIOA_CODR  = 0x0000000F;
+               if(a == 52)
+               {
+                       PIOA_SODR  = 0x00000005;
+                       ser_printf(host_port1, "%c", a);
+               }
+
        }
 
        return 0;
 }
-