From: lottaviano Date: Tue, 17 May 2011 09:49:49 +0000 (+0000) Subject: Kernel project main.c file implemented. Necessary libraries modified in cfg folder. X-Git-Tag: 2.7.0~63 X-Git-Url: https://codewiz.org/gitweb?p=bertos.git;a=commitdiff_plain;h=b07b6aae50a356a3d1bb9043876b8b30b9c9c521 Kernel project main.c file implemented. Necessary libraries modified in cfg folder. Signed-off-by: Andrea Scalise Signed-off-by: Matteo Silvestri git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4903 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_monitor.h b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_monitor.h index 78f222bf..d0e24da4 100644 --- a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_monitor.h +++ b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_monitor.h @@ -42,6 +42,6 @@ * Process monitor. * $WIZ$ type = "autoenabled" */ -#define CONFIG_KERN_MONITOR 0 +#define CONFIG_KERN_MONITOR 1 #endif /* CFG_MONITOR_H */ diff --git a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_proc.h b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_proc.h index 3c9439fb..e779ebe4 100644 --- a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_proc.h +++ b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_proc.h @@ -43,7 +43,7 @@ * * $WIZ$ type = "autoenabled" */ -#define CONFIG_KERN 0 +#define CONFIG_KERN 1 /** * Kernel interrupt supervisor. WARNING: Experimental, still incomplete! @@ -72,21 +72,21 @@ * Priority-based scheduling policy. * $WIZ$ type = "boolean" */ -#define CONFIG_KERN_PRI 0 +#define CONFIG_KERN_PRI 1 /** * Dynamic memory allocation for processes. * $WIZ$ type = "boolean" * $WIZ$ conditional_deps = "heap" */ -#define CONFIG_KERN_HEAP 0 +#define CONFIG_KERN_HEAP 1 /** * Size of the dynamic memory pool used by processes. * $WIZ$ type = "int" * $WIZ$ min = 0 */ -#define CONFIG_KERN_HEAP_SIZE 2048L +#define CONFIG_KERN_HEAP_SIZE 1024L /** * Module logging level. diff --git a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_sem.h b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_sem.h index 51811da4..905f0455 100644 --- a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_sem.h +++ b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_sem.h @@ -42,6 +42,6 @@ * Re-entrant mutual exclusion primitives. * $WIZ$ type = "autoenabled" */ -#define CONFIG_KERN_SEMAPHORES 0 +#define CONFIG_KERN_SEMAPHORES 1 #endif /* CFG_SEM_H */ diff --git a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_ser.h b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_ser.h index 91a10e0b..03e7b49d 100644 --- a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_ser.h +++ b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_ser.h @@ -214,7 +214,7 @@ * $WIZ$ type = "int" * $WIZ$ min = 0 */ -#define CONFIG_SER_DEFBAUDRATE 0UL +#define CONFIG_SER_DEFBAUDRATE 115200UL /// Enable strobe pin for debugging serial interrupt. $WIZ$ type = "boolean" #define CONFIG_SER_STROBE 0 diff --git a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_signal.h b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_signal.h index e48d86a6..ce5324ec 100644 --- a/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_signal.h +++ b/boards/stm32VLDiscovery/templates/kernel/cfg/cfg_signal.h @@ -42,6 +42,6 @@ * Inter-process signals. * $WIZ$ type = "autoenabled" */ -#define CONFIG_KERN_SIGNALS 0 +#define CONFIG_KERN_SIGNALS 1 #endif /* CFG_SIGNAL_H */ 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; } -