import cbaos v0.1
[cbaos.git] / test / blinky.c
blobf3367577ae2157570ba4a3d3432d65e138f99b98
1 /* Author: Domen Puncer <domen@cba.si>. License: WTFPL, see file LICENSE */
2 #include <stdio.h>
4 #include <sched.h>
5 #include <lock.h>
6 #include <compiler.h>
8 #include <gpio.h>
10 #ifdef BOARD_LPCXPRESSO
11 #include <mach/lpc13xx_gpio.h>
12 #define GPIO_LED GPIO_0_7
13 #else
14 #define GPIO_LED 0
15 #endif
17 static void blinky_func(u32 arg)
19 int i= 0;
20 gpio_init(GPIO_LED, GPIO_OUTPUT, 0);
22 while (1) {
23 printf("%s, loop %i\n", __func__, i);
24 gpio_set(GPIO_LED, i%2);
25 msleep(500);
26 i++;
31 #ifdef ARCH_UNIX
32 #define STACK 2048
33 #else
34 #define STACK 128
35 #endif
36 static u32 blinky_stack[STACK];
37 static struct task blinky_task;
39 void blinky()
41 blinky_task = (struct task) {
42 .name = "blinky",
43 .stack = blinky_stack,
44 .stack_len = ALEN(blinky_stack),
47 sched_init();
49 task_new(&blinky_task, blinky_func, 0, 0);
51 sched_start();