X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=boards%2Fat91sam7s-ek%2Ftemplates%2Fat91sam7s-ek_kernel%2Fmain.c;fp=boards%2Fat91sam7s-ek%2Ftemplates%2Fat91sam7s-ek_kernel%2Fmain.c;h=28035dddb0646ab0177203360095120999f28ec3;hb=8f7814c52313b79a67ddbfef7a068af343ea6541;hp=0000000000000000000000000000000000000000;hpb=e04285605a166a50fada6dcc601ee2ad2fedb32f;p=bertos.git diff --git a/boards/at91sam7s-ek/templates/at91sam7s-ek_kernel/main.c b/boards/at91sam7s-ek/templates/at91sam7s-ek_kernel/main.c new file mode 100644 index 00000000..28035ddd --- /dev/null +++ b/boards/at91sam7s-ek/templates/at91sam7s-ek_kernel/main.c @@ -0,0 +1,115 @@ +/** + * \file + * + * + * \author Andrea Righi + * + * \brief Kernel project. + * + * This is a minimalist kernel project: it just initializes the hardware and + * creates an independent process to blink an LED, while the main loop + * continues to monitor the stack utilization of all the processes. + */ + +#include "hw/hw_led.h" + +#include + +#include + +#include +#include + +#include +#include + +static Serial out; + +static void init(void) +{ + /* Enable all the interrupts */ + IRQ_ENABLE; + + /* Initialize debugging module (allow kprintf(), etc.) */ + kdbg_init(); + /* Initialize system timer */ + timer_init(); + /* Initialize UART0 */ + ser_init(&out, SER_UART0); + /* Configure UART0 to work at 115.200 bps */ + ser_setbaudrate(&out, 115200); + /* Initialize LED driver */ + LED_INIT(); + + /* + * Kernel initialization: processes (allow to create and dispatch + * processes using proc_new()). + */ + proc_init(); +} + +static void NORETURN led_process(void) +{ + int i; + + /* Periodically blink the led (toggle each 100 ms) */ + for (i = 0; ; i = !i) + { + if (i) + { + LED_ON(); + } + else + { + LED_OFF(); + } + timer_delay(100); + } +} + +int main(void) +{ + /* Hardware initialization */ + init(); + + /* Create a new child process */ + proc_new(led_process, NULL, KERN_MINSTACKSIZE * 2, NULL); + + /* + * The main process is kept to periodically report the stack + * utilization of all the processes (1 probe per second). + */ + while (1) + { + monitor_report(); + timer_delay(1000); + } +}