From 156a195bf72bd366f91e03c170ad4b344797778a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 2 Sep 2013 13:56:36 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6249 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/nil/NIL-STM32F051-DISCOVERY/.cproject | 212 ++++++++++++++++++++ demos/nil/NIL-STM32F051-DISCOVERY/.project | 90 +++++++++ demos/nil/NIL-STM32F051-DISCOVERY/Makefile | 209 +++++++++++++++++++ demos/nil/NIL-STM32F051-DISCOVERY/main.c | 81 ++++++++ demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h | 99 +++++++++ os/nil/nil.mk | 6 +- 6 files changed, 694 insertions(+), 3 deletions(-) create mode 100644 demos/nil/NIL-STM32F051-DISCOVERY/.cproject create mode 100644 demos/nil/NIL-STM32F051-DISCOVERY/.project create mode 100644 demos/nil/NIL-STM32F051-DISCOVERY/Makefile create mode 100644 demos/nil/NIL-STM32F051-DISCOVERY/main.c create mode 100644 demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h diff --git a/demos/nil/NIL-STM32F051-DISCOVERY/.cproject b/demos/nil/NIL-STM32F051-DISCOVERY/.cproject new file mode 100644 index 000000000..03d7ff75e --- /dev/null +++ b/demos/nil/NIL-STM32F051-DISCOVERY/.cproject @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/nil/NIL-STM32F051-DISCOVERY/.project b/demos/nil/NIL-STM32F051-DISCOVERY/.project new file mode 100644 index 000000000..041565660 --- /dev/null +++ b/demos/nil/NIL-STM32F051-DISCOVERY/.project @@ -0,0 +1,90 @@ + + + NIL-STM32F051-DISCOVERY + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + mingw32-make + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + false + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + board + 2 + CHIBIOS/os/hal/boards/ST_STM32F0_DISCOVERY + + + os + 2 + CHIBIOS/os + + + diff --git a/demos/nil/NIL-STM32F051-DISCOVERY/Makefile b/demos/nil/NIL-STM32F051-DISCOVERY/Makefile new file mode 100644 index 000000000..47e3d2f8c --- /dev/null +++ b/demos/nil/NIL-STM32F051-DISCOVERY/Makefile @@ -0,0 +1,209 @@ +############################################################################## +# Build global options +# NOTE: Can be overridden externally. +# + +# Compiler options here. +ifeq ($(USE_OPT),) + USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 +endif + +# C specific options here (added to USE_OPT). +ifeq ($(USE_COPT),) + USE_COPT = +endif + +# C++ specific options here (added to USE_OPT). +ifeq ($(USE_CPPOPT),) + USE_CPPOPT = -fno-rtti +endif + +# Enable this if you want the linker to remove unused code and data +ifeq ($(USE_LINK_GC),) + USE_LINK_GC = yes +endif + +# If enabled, this option allows to compile the application in THUMB mode. +ifeq ($(USE_THUMB),) + USE_THUMB = yes +endif + +# Enable this if you want to see the full log while compiling. +ifeq ($(USE_VERBOSE_COMPILE),) + USE_VERBOSE_COMPILE = no +endif + +# +# Build global options +############################################################################## + +############################################################################## +# Architecture or project specific options +# + +# Enable this if you really want to use the STM FWLib. +ifeq ($(USE_FWLIB),) + USE_FWLIB = no +endif + +# +# Architecture or project specific options +############################################################################## + +############################################################################## +# Project, sources and paths +# + +# Define project name here +PROJECT = ch + +# Imported source files and paths +CHIBIOS = ../../.. +#include $(CHIBIOS)/os/hal/hal.mk +#include $(CHIBIOS)/os/hal/boards/ST_STM32F0_DISCOVERY/board.mk +#include $(CHIBIOS)/os/hal/ports/STM32F0xx/platform.mk +include $(CHIBIOS)/os/nil/nil.mk +#include $(CHIBIOS)/os/rt/osal/osal.mk +include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_stm32f0xx.mk +#include $(CHIBIOS)/test/test.mk + +# Define linker script file here +LDSCRIPT= $(PORTLD)/STM32F051x8.ld + +# C sources that can be compiled in ARM or THUMB mode depending on the global +# setting. +CSRC = $(PORTSRC) \ + $(KERNSRC) \ + $(TESTSRC) \ + $(HALSRC) \ + $(OSALSRC) \ + $(PLATFORMSRC) \ + $(BOARDSRC) \ + main.c + +# C++ sources that can be compiled in ARM or THUMB mode depending on the global +# setting. +CPPSRC = + +# C sources to be compiled in ARM mode regardless of the global setting. +# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler +# option that results in lower performance and larger code size. +ACSRC = + +# C++ sources to be compiled in ARM mode regardless of the global setting. +# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler +# option that results in lower performance and larger code size. +ACPPSRC = + +# C sources to be compiled in THUMB mode regardless of the global setting. +# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler +# option that results in lower performance and larger code size. +TCSRC = + +# C sources to be compiled in THUMB mode regardless of the global setting. +# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler +# option that results in lower performance and larger code size. +TCPPSRC = + +# List ASM source files here +ASMSRC = $(PORTASM) + +INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ + $(HALINC) $(OSALINC) $(PLATFORMINC) $(BOARDINC) \ + $(CHIBIOS)/os/various + +# +# Project, sources and paths +############################################################################## + +############################################################################## +# Compiler settings +# + +MCU = cortex-m0 + +#TRGT = arm-elf- +TRGT = arm-none-eabi- +CC = $(TRGT)gcc +CPPC = $(TRGT)g++ +# Enable loading with g++ only if you need C++ runtime support. +# NOTE: You can use C++ even without C++ support if you are careful. C++ +# runtime support makes code size explode. +LD = $(TRGT)gcc +#LD = $(TRGT)g++ +CP = $(TRGT)objcopy +AS = $(TRGT)gcc -x assembler-with-cpp +OD = $(TRGT)objdump +HEX = $(CP) -O ihex +BIN = $(CP) -O binary + +# ARM-specific options here +AOPT = + +# THUMB-specific options here +TOPT = -mthumb -DTHUMB + +# Define C warning options here +CWARN = -Wall -Wextra -Wstrict-prototypes + +# Define C++ warning options here +CPPWARN = -Wall -Wextra + +# +# Compiler settings +############################################################################## + +############################################################################## +# Start of default section +# + +# List all default C defines here, like -D_DEBUG=1 +DDEFS = + +# List all default ASM defines here, like -D_DEBUG=1 +DADEFS = + +# List all default directories to look for include files here +DINCDIR = + +# List the default directory to look for the libraries here +DLIBDIR = + +# List all default libraries here +DLIBS = + +# +# End of default section +############################################################################## + +############################################################################## +# Start of user section +# + +# List all user C define here, like -D_DEBUG=1 +UDEFS = + +# Define ASM defines here +UADEFS = + +# List all user directories here +UINCDIR = + +# List the user directory to look for the libraries here +ULIBDIR = + +# List all user libraries here +ULIBS = + +# +# End of user defines +############################################################################## + +ifeq ($(USE_FWLIB),yes) + include $(CHIBIOS)/ext/stm32lib/stm32lib.mk + CSRC += $(STM32SRC) + INCDIR += $(STM32INC) + USE_OPT += -DUSE_STDPERIPH_DRIVER +endif + +include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/rules.mk diff --git a/demos/nil/NIL-STM32F051-DISCOVERY/main.c b/demos/nil/NIL-STM32F051-DISCOVERY/main.c new file mode 100644 index 000000000..5fcf9da8c --- /dev/null +++ b/demos/nil/NIL-STM32F051-DISCOVERY/main.c @@ -0,0 +1,81 @@ +/* + Nil RTOS - Copyright (C) 2012 Giovanni Di Sirio. + + This file is part of Nil RTOS. + + Nil RTOS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Nil RTOS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "nil.h" +#include "hwinit.h" + +/* + * Thread 1. + */ +NIL_WORKING_AREA(waThread1, 128); +NIL_THREAD(Thread1, arg) { + + (void)arg; + + while (true) { + gpioSetPad(GPIOC, GPIOC_LED4); + nilThdSleepMilliseconds(500); + gpioClearPad(GPIOC, GPIOC_LED4); + nilThdSleepMilliseconds(500); + } +} + +/* + * Thread 2. + */ +NIL_WORKING_AREA(waThread2, 128); +NIL_THREAD(Thread2, arg) { + + (void)arg; + + while (true) { + gpioSetPad(GPIOC, GPIOC_LED3); + nilThdSleepMilliseconds(250); + gpioClearPad(GPIOC, GPIOC_LED3); + nilThdSleepMilliseconds(250); + } +} + +/* + * Threads static table, one entry per thread. The number of entries must + * match NIL_CFG_NUM_THREADS. + */ +NIL_THREADS_TABLE_BEGIN() + NIL_THREADS_TABLE_ENTRY("thread1", Thread1, NULL, waThread1, sizeof(waThread1)) + NIL_THREADS_TABLE_ENTRY("thread2", Thread2, NULL, waThread2, sizeof(waThread2)) +NIL_THREADS_TABLE_END() + +/* + * Application entry point. + */ +int main(void) { + + /* + * System initializations: + * - HW specific initialization. + * - Nil RTOS initialization. + */ + hwInit(); + nilSysInit(); + + /* This is now the idle thread loop, you may perform here a low priority + task but you must never try to sleep or wait in this loop.*/ + while (true) { + } +} diff --git a/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h b/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h new file mode 100644 index 000000000..d6d73fad8 --- /dev/null +++ b/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h @@ -0,0 +1,99 @@ +/* + Nil RTOS - Copyright (C) 2012 Giovanni Di Sirio. + + This file is part of Nil RTOS. + + Nil RTOS is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Nil RTOS is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file nilconf.h + * @brief Configuration file template. + * @details A copy of this file must be placed in each project directory, it + * contains the application specific kernel settings. + * + * @addtogroup config + * @details Kernel related settings and hooks. + * @{ + */ + +#ifndef _NILCONF_H_ +#define _NILCONF_H_ + +/** + * @brief Number of user threads in the application. + * @note This number is not inclusive of the idle thread which is + * Implicitly handled. + */ +#define NIL_CFG_NUM_THREADS 2 + +/** + * @brief System tick frequency. + */ +#define NIL_CFG_FREQUENCY 50000 + +/** + * @brief Time delta constant for the tick-less mode. + * @note If this value is zero then the system uses the classic + * periodic tick. This value represents the minimum number + * of ticks that is safe to specify in a timeout directive. + * The value one is not valid, timeouts are rounded up to + * this value. + */ +#define NIL_CFG_TIMEDELTA 2 + +/** + * @brief System assertions. + */ +#define NIL_CFG_ENABLE_ASSERTS FALSE + +/** + * @brief Threads descriptor structure extension. + * @details User fields added to the end of the @p thread_t structure. + */ +#define NIL_CFG_THREAD_EXT_FIELDS \ + /* Add threads custom fields here.*/ + +/** + * @brief Threads initialization hook. + */ +#define NIL_CFG_THREAD_EXT_INIT_HOOK(tr) { \ + /* Add custom threads initialization code here.*/ \ +} + +/** + * @brief Idle thread enter hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to activate a power saving mode. + */ +#define NIL_CFG_IDLE_ENTER_HOOK() { \ +} + +/** + * @brief Idle thread leave hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to deactivate a power saving mode. + */ +#define NIL_CFG_IDLE_LEAVE_HOOK() { \ +} + +/*===========================================================================*/ +/* Port-specific settings (override port settings defaulted in nilcore.h). */ +/*===========================================================================*/ + +#endif /* _NILCONF_H_ */ + +/** @} */ diff --git a/os/nil/nil.mk b/os/nil/nil.mk index 9e46f1c02..51f0e8083 100644 --- a/os/nil/nil.mk +++ b/os/nil/nil.mk @@ -1,5 +1,5 @@ -# List of all the Nil RTOS kernel files. -KERNSRC = ${NILRTOS}/os/kernel/nil.c +# List of all the ChibiOS/NIL kernel files. +KERNSRC = ${CHIBIOS}/os/nil/src/nil.c # Required include directories -KERNINC = ${NILRTOS}/os/kernel +KERNINC = ${CHIBIOS}/os/nil/include