From 6c18028a35db35c45c8c342d43abd74b13ef1605 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 4 Nov 2017 19:23:04 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10946 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/SPC5/NIL-SPC560D-EVB/chconf.h | 2 +- demos/STM32/NIL-STM32F051-DISCOVERY/chconf.h | 2 +- demos/STM32/NIL-STM32F100-DISCOVERY/chconf.h | 2 +- demos/STM32/NIL-STM32F303-DISCOVERY/chconf.h | 2 +- .../NIL-STM32F373-STM32373C_EVAL/chconf.h | 2 +- demos/STM32/NIL-STM32F746G-DISCOVERY/chconf.h | 2 +- demos/STM32/NIL-STM32L011K4-NUCLEO32/Makefile | 4 +- demos/STM32/NIL-STM32L011K4-NUCLEO32/chconf.h | 2 +- demos/STM32/NIL-STM32L152-DISCOVERY/Makefile | 4 +- demos/STM32/NIL-STM32L152-DISCOVERY/chconf.h | 2 +- ...-DISCOVERY (OpenOCD, Flash and Run).launch | 104 +++++++++--------- demos/various/NIL-ARMCM0-GENERIC/Makefile | 4 +- demos/various/NIL-ARMCM0-GENERIC/chconf.h | 4 +- demos/various/NIL-ARMCM4-GENERIC/Makefile | 4 +- demos/various/NIL-ARMCM4-GENERIC/chconf.h | 4 +- os/common/abstractions/cmsis_os/cmsis_os.c | 24 ++-- os/common/oslib/src/chfactory.c | 4 +- os/nil/include/ch.h | 62 ++++++++++- os/nil/nil.mk | 12 +- os/rt/rt.mk | 3 +- test/nil/testbuild/chconf.h | 4 +- 21 files changed, 159 insertions(+), 94 deletions(-) diff --git a/demos/SPC5/NIL-SPC560D-EVB/chconf.h b/demos/SPC5/NIL-SPC560D-EVB/chconf.h index 1165a0d88..87f60a583 100644 --- a/demos/SPC5/NIL-SPC560D-EVB/chconf.h +++ b/demos/SPC5/NIL-SPC560D-EVB/chconf.h @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/demos/STM32/NIL-STM32F051-DISCOVERY/chconf.h b/demos/STM32/NIL-STM32F051-DISCOVERY/chconf.h index 912b3a9cf..e2c5ad90d 100644 --- a/demos/STM32/NIL-STM32F051-DISCOVERY/chconf.h +++ b/demos/STM32/NIL-STM32F051-DISCOVERY/chconf.h @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/demos/STM32/NIL-STM32F100-DISCOVERY/chconf.h b/demos/STM32/NIL-STM32F100-DISCOVERY/chconf.h index 260145e60..e584d60b8 100644 --- a/demos/STM32/NIL-STM32F100-DISCOVERY/chconf.h +++ b/demos/STM32/NIL-STM32F100-DISCOVERY/chconf.h @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/demos/STM32/NIL-STM32F303-DISCOVERY/chconf.h b/demos/STM32/NIL-STM32F303-DISCOVERY/chconf.h index fcd948e50..648003a72 100644 --- a/demos/STM32/NIL-STM32F303-DISCOVERY/chconf.h +++ b/demos/STM32/NIL-STM32F303-DISCOVERY/chconf.h @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/demos/STM32/NIL-STM32F373-STM32373C_EVAL/chconf.h b/demos/STM32/NIL-STM32F373-STM32373C_EVAL/chconf.h index c6b882185..523ce8d56 100644 --- a/demos/STM32/NIL-STM32F373-STM32373C_EVAL/chconf.h +++ b/demos/STM32/NIL-STM32F373-STM32373C_EVAL/chconf.h @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/demos/STM32/NIL-STM32F746G-DISCOVERY/chconf.h b/demos/STM32/NIL-STM32F746G-DISCOVERY/chconf.h index 270957fb5..be691148c 100644 --- a/demos/STM32/NIL-STM32F746G-DISCOVERY/chconf.h +++ b/demos/STM32/NIL-STM32F746G-DISCOVERY/chconf.h @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/demos/STM32/NIL-STM32L011K4-NUCLEO32/Makefile b/demos/STM32/NIL-STM32L011K4-NUCLEO32/Makefile index e5b60457f..0421f0446 100644 --- a/demos/STM32/NIL-STM32L011K4-NUCLEO32/Makefile +++ b/demos/STM32/NIL-STM32L011K4-NUCLEO32/Makefile @@ -99,8 +99,8 @@ include $(CHIBIOS)/os/nil/nil.mk include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk # Other files (optional). #include $(CHIBIOS)/test/lib/test.mk -include $(CHIBIOS)/test/nil/nil_test.mk -include $(CHIBIOS)/test/oslib/oslib_test.mk +#include $(CHIBIOS)/test/nil/nil_test.mk +#include $(CHIBIOS)/test/oslib/oslib_test.mk # Define linker script file here LDSCRIPT= $(STARTUPLD)/STM32L011x4.ld diff --git a/demos/STM32/NIL-STM32L011K4-NUCLEO32/chconf.h b/demos/STM32/NIL-STM32L011K4-NUCLEO32/chconf.h index 0d4c319d8..9c5c1c810 100644 --- a/demos/STM32/NIL-STM32L011K4-NUCLEO32/chconf.h +++ b/demos/STM32/NIL-STM32L011K4-NUCLEO32/chconf.h @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/demos/STM32/NIL-STM32L152-DISCOVERY/Makefile b/demos/STM32/NIL-STM32L152-DISCOVERY/Makefile index de5aaaebe..3f4968935 100644 --- a/demos/STM32/NIL-STM32L152-DISCOVERY/Makefile +++ b/demos/STM32/NIL-STM32L152-DISCOVERY/Makefile @@ -99,8 +99,8 @@ include $(CHIBIOS)/os/nil/nil.mk include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk # Other files (optional). #include $(CHIBIOS)/test/lib/test.mk -include $(CHIBIOS)/test/nil/nil_test.mk -include $(CHIBIOS)/test/oslib/oslib_test.mk +#include $(CHIBIOS)/test/nil/nil_test.mk +#include $(CHIBIOS)/test/oslib/oslib_test.mk # Define linker script file here LDSCRIPT= $(STARTUPLD)/STM32L152xB.ld diff --git a/demos/STM32/NIL-STM32L152-DISCOVERY/chconf.h b/demos/STM32/NIL-STM32L152-DISCOVERY/chconf.h index 260145e60..e584d60b8 100644 --- a/demos/STM32/NIL-STM32L152-DISCOVERY/chconf.h +++ b/demos/STM32/NIL-STM32L152-DISCOVERY/chconf.h @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/demos/STM32/RT-STM32F746G-DISCOVERY/debug/RT-STM32F746G-DISCOVERY (OpenOCD, Flash and Run).launch b/demos/STM32/RT-STM32F746G-DISCOVERY/debug/RT-STM32F746G-DISCOVERY (OpenOCD, Flash and Run).launch index 92f436493..620c606b2 100644 --- a/demos/STM32/RT-STM32F746G-DISCOVERY/debug/RT-STM32F746G-DISCOVERY (OpenOCD, Flash and Run).launch +++ b/demos/STM32/RT-STM32F746G-DISCOVERY/debug/RT-STM32F746G-DISCOVERY (OpenOCD, Flash and Run).launch @@ -1,52 +1,52 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/various/NIL-ARMCM0-GENERIC/Makefile b/demos/various/NIL-ARMCM0-GENERIC/Makefile index 5a7fe2e0d..32aba1db1 100644 --- a/demos/various/NIL-ARMCM0-GENERIC/Makefile +++ b/demos/various/NIL-ARMCM0-GENERIC/Makefile @@ -99,8 +99,8 @@ include $(CHIBIOS)/os/nil/nil.mk include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v6m.mk # Other files (optional). #include $(CHIBIOS)/test/lib/test.mk -include $(CHIBIOS)/test/nil/nil_test.mk -include $(CHIBIOS)/test/oslib/oslib_test.mk +#include $(CHIBIOS)/test/nil/nil_test.mk +#include $(CHIBIOS)/test/oslib/oslib_test.mk # Define linker script file here LDSCRIPT= $(STARTUPLD)/STM32F051x8.ld diff --git a/demos/various/NIL-ARMCM0-GENERIC/chconf.h b/demos/various/NIL-ARMCM0-GENERIC/chconf.h index 2e965b2b8..af7e94494 100644 --- a/demos/various/NIL-ARMCM0-GENERIC/chconf.h +++ b/demos/various/NIL-ARMCM0-GENERIC/chconf.h @@ -20,7 +20,7 @@ * @details A copy of this file must be placed in each project directory, it * contains the application specific kernel settings. * - * @addtogroup config + * @addtogroup NIL_CONFIG * @details Kernel related settings and hooks. * @{ */ @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/demos/various/NIL-ARMCM4-GENERIC/Makefile b/demos/various/NIL-ARMCM4-GENERIC/Makefile index 52873cd39..21414c527 100644 --- a/demos/various/NIL-ARMCM4-GENERIC/Makefile +++ b/demos/various/NIL-ARMCM4-GENERIC/Makefile @@ -99,8 +99,8 @@ include $(CHIBIOS)/os/nil/nil.mk include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk # Other files (optional). #include $(CHIBIOS)/test/lib/test.mk -include $(CHIBIOS)/test/nil/nil_test.mk -include $(CHIBIOS)/test/oslib/oslib_test.mk +#include $(CHIBIOS)/test/nil/nil_test.mk +#include $(CHIBIOS)/test/oslib/oslib_test.mk # Define linker script file here LDSCRIPT= $(STARTUPLD)/STM32F407xG.ld diff --git a/demos/various/NIL-ARMCM4-GENERIC/chconf.h b/demos/various/NIL-ARMCM4-GENERIC/chconf.h index 2e965b2b8..af7e94494 100644 --- a/demos/various/NIL-ARMCM4-GENERIC/chconf.h +++ b/demos/various/NIL-ARMCM4-GENERIC/chconf.h @@ -20,7 +20,7 @@ * @details A copy of this file must be placed in each project directory, it * contains the application specific kernel settings. * - * @addtogroup config + * @addtogroup NIL_CONFIG * @details Kernel related settings and hooks. * @{ */ @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /** diff --git a/os/common/abstractions/cmsis_os/cmsis_os.c b/os/common/abstractions/cmsis_os/cmsis_os.c index a871b761f..a01ebc0e0 100644 --- a/os/common/abstractions/cmsis_os/cmsis_os.c +++ b/os/common/abstractions/cmsis_os/cmsis_os.c @@ -68,7 +68,7 @@ static void timer_cb(void const *arg) { timer_id->ptimer(timer_id->argument); if (timer_id->type == osTimerPeriodic) { chSysLockFromISR(); - chVTDoSetI(&timer_id->vt, MS2ST(timer_id->millisec), + chVTDoSetI(&timer_id->vt, TIME_MS2I(timer_id->millisec), (vtfunc_t)timer_cb, timer_id); chSysUnlockFromISR(); } @@ -226,7 +226,7 @@ osStatus osTimerStart(osTimerId timer_id, uint32_t millisec) { return osErrorValue; timer_id->millisec = millisec; - chVTSet(&timer_id->vt, MS2ST(millisec), (vtfunc_t)timer_cb, timer_id); + chVTSet(&timer_id->vt, TIME_MS2I(millisec), (vtfunc_t)timer_cb, timer_id); return osOK; } @@ -287,8 +287,8 @@ int32_t osSignalClear(osThreadId thread_id, int32_t signals) { */ osEvent osSignalWait(int32_t signals, uint32_t millisec) { osEvent event; - systime_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? - TIME_INFINITE : MS2ST(millisec); + sysinterval_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? + TIME_INFINITE : TIME_MS2I(millisec); if (signals == 0) event.value.signals = (uint32_t)chEvtWaitAnyTimeout(ALL_EVENTS, timeout); @@ -324,8 +324,8 @@ osSemaphoreId osSemaphoreCreate(const osSemaphoreDef_t *semaphore_def, * @brief Wait on a semaphore. */ int32_t osSemaphoreWait(osSemaphoreId semaphore_id, uint32_t millisec) { - systime_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? - TIME_INFINITE : MS2ST(millisec); + sysinterval_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? + TIME_INFINITE : TIME_MS2I(millisec); msg_t msg = chSemWaitTimeout((semaphore_t *)semaphore_id, timeout); switch (msg) { @@ -380,8 +380,8 @@ osMutexId osMutexCreate(const osMutexDef_t *mutex_def) { * @brief Wait on a mutex. */ osStatus osMutexWait(osMutexId mutex_id, uint32_t millisec) { - systime_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? - TIME_INFINITE : MS2ST(millisec); + sysinterval_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? + TIME_INFINITE : TIME_MS2I(millisec); msg_t msg = chBSemWaitTimeout((binary_semaphore_t *)mutex_id, timeout); switch (msg) { @@ -495,8 +495,8 @@ osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec) { msg_t msg; - systime_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? - TIME_INFINITE : MS2ST(millisec); + sysinterval_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? + TIME_INFINITE : TIME_MS2I(millisec); if (port_is_isr_context()) { @@ -522,8 +522,8 @@ osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec) { msg_t msg; osEvent event; - systime_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? - TIME_INFINITE : MS2ST(millisec); + sysinterval_t timeout = ((millisec == 0) || (millisec == osWaitForever)) ? + TIME_INFINITE : TIME_MS2I(millisec); event.def.message_id = queue_id; diff --git a/os/common/oslib/src/chfactory.c b/os/common/oslib/src/chfactory.c index 74e80e528..6e187c929 100644 --- a/os/common/oslib/src/chfactory.c +++ b/os/common/oslib/src/chfactory.c @@ -56,8 +56,8 @@ #define F_LOCK() chMtxLock(&ch_factory.mtx) #define F_UNLOCK() chMtxUnlock(&ch_factory.mtx) #else -#define F_LOCK() (void) chSemWait(ch_factory.sem) -#define F_UNLOCK() chSemSignal(ch_factory.sem) +#define F_LOCK() (void) chSemWait(&ch_factory.sem) +#define F_UNLOCK() chSemSignal(&ch_factory.sem) #endif /*===========================================================================*/ diff --git a/os/nil/include/ch.h b/os/nil/include/ch.h index f413585af..b55133b9c 100644 --- a/os/nil/include/ch.h +++ b/os/nil/include/ch.h @@ -263,6 +263,60 @@ #if !defined(CH_CFG_USE_MEMPOOLS) || defined(__DOXYGEN__) #define CH_CFG_USE_MEMPOOLS TRUE #endif +/** + * @brief Objects Factory APIs. + * @details If enabled then the objects factory APIs are included in the + * kernel. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_CFG_USE_FACTORY) || defined(__DOXYGEN__) +#define CH_CFG_USE_FACTORY TRUE +#endif + +/** + * @brief Maximum length for object names. + * @details If the specified length is zero then the name is stored by + * pointer but this could have unintended side effects. + */ +#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH) || defined(__DOXYGEN__) +#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 +#endif + +/** + * @brief Enables the registry of generic objects. + */ +#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) || defined(__DOXYGEN__) +#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE +#endif + +/** + * @brief Enables factory for generic buffers. + */ +#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) || defined(__DOXYGEN__) +#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE +#endif + +/** + * @brief Enables factory for semaphores. + */ +#if !defined(CH_CFG_FACTORY_SEMAPHORES) || defined(__DOXYGEN__) +#define CH_CFG_FACTORY_SEMAPHORES TRUE +#endif + +/** + * @brief Enables factory for mailboxes. + */ +#if !defined(CH_CFG_FACTORY_MAILBOXES) || defined(__DOXYGEN__) +#define CH_CFG_FACTORY_MAILBOXES TRUE +#endif + +/** + * @brief Enables factory for objects FIFOs. + */ +#if !defined(CH_CFG_FACTORY_OBJ_FIFOS) || defined(__DOXYGEN__) +#define CH_CFG_FACTORY_OBJ_FIFOS TRUE +#endif /*-* * @brief Debug option, kernel statistics. @@ -414,6 +468,10 @@ #error "missing or wrong configuration file" #endif +#if !defined(_CHIBIOS_NIL_CONF_VER_3_0_) +#error "obsolete or unknown configuration file" +#endif + #if CH_CFG_NUM_THREADS < 1 #error "at least one thread must be defined" #endif @@ -1501,8 +1559,10 @@ extern "C" { /* Optional subsystems.*/ #include "chmboxes.h" #include "chmemcore.h" -#include "chmempools.h" #include "chheap.h" +#include "chmempools.h" +#include "chfifo.h" +#include "chfactory.h" #endif /* CH_H */ diff --git a/os/nil/nil.mk b/os/nil/nil.mk index f0717ba68..800b702c8 100644 --- a/os/nil/nil.mk +++ b/os/nil/nil.mk @@ -15,12 +15,16 @@ endif ifneq ($(findstring CH_CFG_USE_MEMPOOLS TRUE,$(CHCONF)),) KERNSRC += $(CHIBIOS)/os/common/oslib/src/chmempools.c endif +ifneq ($(findstring CH_CFG_USE_FACTORY TRUE,$(CHCONF)),) +KERNSRC += $(CHIBIOS)/os/common/oslib/src/chfactory.c +endif else KERNSRC := ${CHIBIOS}/os/nil/src/ch.c \ - ${CHIBIOS}/os/common/oslib/src/chmboxes.c \ - ${CHIBIOS}/os/common/oslib/src/chmemcore.c \ - ${CHIBIOS}/os/common/oslib/src/chmempools.c \ - ${CHIBIOS}/os/common/oslib/src/chheap.c + $(CHIBIOS)/os/common/oslib/src/chmboxes.c \ + $(CHIBIOS)/os/common/oslib/src/chmemcore.c \ + $(CHIBIOS)/os/common/oslib/src/chheap.c \ + $(CHIBIOS)/os/common/oslib/src/chmempools.c \ + $(CHIBIOS)/os/common/oslib/src/chfactory.c endif # Required include directories diff --git a/os/rt/rt.mk b/os/rt/rt.mk index 85607b4c4..039963891 100644 --- a/os/rt/rt.mk +++ b/os/rt/rt.mk @@ -76,7 +76,8 @@ KERNSRC := $(CHIBIOS)/os/rt/src/chsys.c \ $(CHIBIOS)/os/common/oslib/src/chmboxes.c \ $(CHIBIOS)/os/common/oslib/src/chmemcore.c \ $(CHIBIOS)/os/common/oslib/src/chheap.c \ - $(CHIBIOS)/os/common/oslib/src/chmempools.c + $(CHIBIOS)/os/common/oslib/src/chmempools.c \ + $(CHIBIOS)/os/common/oslib/src/chfactory.c endif # Required include directories diff --git a/test/nil/testbuild/chconf.h b/test/nil/testbuild/chconf.h index 008b99eef..1eb550a45 100644 --- a/test/nil/testbuild/chconf.h +++ b/test/nil/testbuild/chconf.h @@ -20,7 +20,7 @@ * @details A copy of this file must be placed in each project directory, it * contains the application specific kernel settings. * - * @addtogroup config + * @addtogroup NIL_CONFIG * @details Kernel related settings and hooks. * @{ */ @@ -29,7 +29,7 @@ #define CHCONF_H #define _CHIBIOS_NIL_CONF_ -#define _CHIBIOS_NIL_CONF_VER_5_0_ +#define _CHIBIOS_NIL_CONF_VER_3_0_ /*===========================================================================*/ /**