X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=boards%2Fstm32VLDiscovery%2Ftemplates%2Fkernel%2Fmain.c;h=2ccb10b1d5447d20a957ed600d40039882e260b3;hb=b07b6aae50a356a3d1bb9043876b8b30b9c9c521;hp=c21b9a0ffab1db3aef91441d75493861763d002f;hpb=150b803365687c36d4ff94c65b089a4e91425a65;p=bertos.git diff --git a/boards/stm32VLDiscovery/templates/kernel/main.c b/boards/stm32VLDiscovery/templates/kernel/main.c index c21b9a0f..2ccb10b1 100644 --- a/boards/stm32VLDiscovery/templates/kernel/main.c +++ b/boards/stm32VLDiscovery/templates/kernel/main.c @@ -1,7 +1,42 @@ -/* \brief Empty project. +/** + * \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" @@ -12,6 +47,9 @@ #include +#include +#include + static void init(void) { /* Enable all the interrupts */ @@ -23,18 +61,44 @@ static void init(void) timer_init(); /* 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) { - // your code goes here + monitor_report(); + timer_delay(1000); } - - return 0; } -