Add comments and explicit test for proc_testRun.
[bertos.git] / examples / at91sam7s / at91sam7s.c
index 89aedcb52324f120a87c11e83b54d2acc33c1672..d47264bc83d4ac8be45ec89b15036b641299f942 100644 (file)
 
 Timer leds_timer;
 Serial ser_fd;
+int roll = 0;
 
 static void leds_toggle(void)
 {
        uint8_t a = (~PIOA_ODSR & 0x0f);
 
-       if (a)
+       if (roll == 1)
        {
+               if(a == 4)
+                       roll = 2;
+
                PIOA_SODR = a;
                PIOA_CODR = a << 1;
+
+       }
+       else if (roll == 2)
+       {
+               if(a == 2)
+                       roll = 1;
+
+               PIOA_SODR = a;
+               PIOA_CODR = a >> 1;
        }
        else
        {
                PIOA_SODR  =  0x0f;
                /* turn first led on */
                PIOA_CODR  = 0x00000001;
+               roll = 1;
        }
 
        /* Wait for interval time */
@@ -72,14 +86,15 @@ static void leds_toggle(void)
        timer_add(&leds_timer);
 }
 
-
 int main(void)
 {
        char msg[]="BeRTOS, be fast be beatiful be realtime";
+
+
        kdbg_init();
        timer_init();
-
        proc_init();
+
        ASSERT(!IRQ_ENABLED());
 
        /* Open the main communication port */
@@ -105,11 +120,21 @@ int main(void)
        /* turn first led on */
        PIOA_CODR  = 0x00000001;
 
+       /*
+        * Register timer and arm timer interupt.
+        */
        timer_setSoftint(&leds_timer, (Hook)leds_toggle, 0);
        timer_setDelay(&leds_timer, ms_to_ticks(100));
        timer_add(&leds_timer);
 
-       ASSERT(proc_testRun() == 0);
+       /*
+        * Run process test.
+        */
+       if(!proc_testRun())
+               kfile_printf(&ser_fd.fd, "ProcTest..ok!\n");
+       else
+               kfile_printf(&ser_fd.fd, "ProcTest..FAIL!\n");
+
        // Main loop
        for(;;)
        {