213e96117f2c6c3294002cacc539b1781f126419
[bertos.git] / examples / lpc2378 / main.c
1 // Emtpy main.c file generated by the wizard
2 #include <cpu/irq.h>
3 #include <cfg/debug.h>
4 #include <drv/timer.h>
5 #include <io/lpc23xx.h>
6
7 #define STATUS_LED (1<<19)
8 #define LED_ON()  do { IOCLR1 =  STATUS_LED; } while (0)
9 #define LED_OFF() do { IOSET1 =  STATUS_LED; } while (0)
10
11 static void init(void)
12 {
13         IRQ_ENABLE;
14         kdbg_init();
15         timer_init();
16         proc_init();
17         timer_delay(3000);
18         kprintf("NXP LPC2378 BeRTOS port test\n");
19         timer_delay(3000);
20         /* Turn off boot led */
21         IODIR0 = (1<<21);       
22         IOCLR0 = (1<<21);       
23         /* Init status led */
24         IODIR1 |= STATUS_LED;
25         LED_OFF();
26 }
27
28 static void NORETURN bertos_up(void)
29 {
30         char spinner[] = {'/', '-', '\\', '|'};
31         int i = 0;
32         while (1)
33         {
34                 i++;
35                 proc_forbid();
36                 kprintf("BeRTOS is up & running: %c\r",
37                         spinner[i % countof(spinner)]);
38                 proc_permit();
39                 timer_delay(100);
40         }
41 }
42
43 static void NORETURN status(void)
44 {
45         while (1)
46         {
47                 LED_ON();
48                 timer_delay(250);
49                 
50                 LED_OFF();
51                 timer_delay(250);
52         }
53 }
54
55 int main(void)
56 {
57
58         init();
59         proc_testRun();
60         proc_new(bertos_up, NULL, KERN_MINSTACKSIZE * 3, NULL);
61         proc_new(status, NULL, 0, NULL);
62         while (1)
63         {
64         }
65
66         return 0;
67 }
68