From a86b48c578db236dddea8f141db7607741d48e57 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 12 Sep 2013 17:45:10 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6298 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h | 6 +++++ .../NIL-STM32F373-STM32373C_EVAL/nilconf.h | 6 +++++ demos/nil/NIL-STM32L152-DISCOVERY/nilconf.h | 8 ++++++- os/hal/ports/STM32/TIMv1/st_lld.c | 12 +++++----- os/nil/osal/osal.h | 24 +++++++++++++++---- os/rt/osal/osal.h | 21 +++++++++------- 6 files changed, 56 insertions(+), 21 deletions(-) diff --git a/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h b/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h index 220ce8b37..54fb32ca4 100644 --- a/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h +++ b/demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h @@ -51,6 +51,12 @@ */ /*===========================================================================*/ +/** + * @brief System time counter resolution. + * @note Allowed values are 16 or 32 bits. + */ +#define NIL_CFG_ST_RESOLUTION 32 + /** * @brief System tick frequency. */ diff --git a/demos/nil/NIL-STM32F373-STM32373C_EVAL/nilconf.h b/demos/nil/NIL-STM32F373-STM32373C_EVAL/nilconf.h index 220ce8b37..54fb32ca4 100644 --- a/demos/nil/NIL-STM32F373-STM32373C_EVAL/nilconf.h +++ b/demos/nil/NIL-STM32F373-STM32373C_EVAL/nilconf.h @@ -51,6 +51,12 @@ */ /*===========================================================================*/ +/** + * @brief System time counter resolution. + * @note Allowed values are 16 or 32 bits. + */ +#define NIL_CFG_ST_RESOLUTION 32 + /** * @brief System tick frequency. */ diff --git a/demos/nil/NIL-STM32L152-DISCOVERY/nilconf.h b/demos/nil/NIL-STM32L152-DISCOVERY/nilconf.h index c43879adb..eeec0899f 100644 --- a/demos/nil/NIL-STM32L152-DISCOVERY/nilconf.h +++ b/demos/nil/NIL-STM32L152-DISCOVERY/nilconf.h @@ -51,6 +51,12 @@ */ /*===========================================================================*/ +/** + * @brief System time counter resolution. + * @note Allowed values are 16 or 32 bits. + */ +#define NIL_CFG_ST_RESOLUTION 16 + /** * @brief System tick frequency. */ @@ -64,7 +70,7 @@ * The value one is not valid, timeouts are rounded up to * this value. */ -#define NIL_CFG_ST_TIMEDELTA 0 +#define NIL_CFG_ST_TIMEDELTA 2 /** @} */ diff --git a/os/hal/ports/STM32/TIMv1/st_lld.c b/os/hal/ports/STM32/TIMv1/st_lld.c index 507cad948..090b7a4fe 100644 --- a/os/hal/ports/STM32/TIMv1/st_lld.c +++ b/os/hal/ports/STM32/TIMv1/st_lld.c @@ -83,11 +83,11 @@ #error "STM32_ST_USE_TIMER specifies an unsupported timer" #endif -#if ST_CLOCK_SRC % OSAL_SYSTICK_FREQUENCY != 0 +#if ST_CLOCK_SRC % OSAL_ST_FREQUENCY != 0 #error "the selected ST frequency is not obtainable because integer rounding" #endif -#if (ST_CLOCK_SRC / OSAL_SYSTICK_FREQUENCY) - 1 > 0xFFFF +#if (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1 > 0xFFFF #error "the selected ST frequency is not obtainable because TIM timer prescaler limits" #endif @@ -95,11 +95,11 @@ #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC -#if STM32_HCLK % OSAL_SYSTICK_FREQUENCY != 0 +#if STM32_HCLK % OSAL_ST_FREQUENCY != 0 #error "the selected ST frequency is not obtainable because integer rounding" #endif -#if (STM32_HCLK / OSAL_SYSTICK_FREQUENCY) - 1 > 0xFFFFFF +#if (STM32_HCLK / OSAL_ST_FREQUENCY) - 1 > 0xFFFFFF #error "the selected ST frequency is not obtainable because SysTick timer counter limits" #endif @@ -183,7 +183,7 @@ void st_lld_init(void) { ST_ENABLE_CLOCK(); /* Initializing the counter in free running mode.*/ - STM32_ST_TIM->PSC = (ST_CLOCK_SRC / OSAL_SYSTICK_FREQUENCY) - 1; + STM32_ST_TIM->PSC = (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1; STM32_ST_TIM->ARR = ST_ARR_INIT; STM32_ST_TIM->CCMR1 = 0; STM32_ST_TIM->CCR[0] = 0; @@ -199,7 +199,7 @@ void st_lld_init(void) { #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC /* Periodic systick mode, the Cortex-Mx internal systick timer is used in this mode.*/ - SysTick->LOAD = (STM32_HCLK / OSAL_SYSTICK_FREQUENCY) - 1; + SysTick->LOAD = (STM32_HCLK / OSAL_ST_FREQUENCY) - 1; SysTick->VAL = 0; SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk | diff --git a/os/nil/osal/osal.h b/os/nil/osal/osal.h index 71d47894f..93483e6f0 100644 --- a/os/nil/osal/osal.h +++ b/os/nil/osal/osal.h @@ -85,6 +85,20 @@ #define OSAL_ST_MODE_FREERUNNING 2 /** @} */ +/** + * @name Systick parameters. + * @{ + */ +/** + * @brief Size in bits of the @p systick_t type. + */ +#define OSAL_ST_RESOLUTION NIL_CFG_ST_RESOLUTION + +/** + * @brief Required systick frequency or resolution. + */ +#define OSAL_ST_FREQUENCY NIL_CFG_ST_FREQUENCY + /** * @brief Systick mode required by the underlying OS. */ @@ -93,11 +107,7 @@ #else #define OSAL_ST_MODE OSAL_ST_MODE_FREERUNNING #endif - -/** - * @brief Required systick frequency or resolution. - */ -#define OSAL_SYSTICK_FREQUENCY NIL_CFG_ST_FREQUENCY +/** @} */ /*===========================================================================*/ /* Module pre-compile time settings. */ @@ -117,6 +127,10 @@ #error "invalid OSAL_ST_MODE setting in osal.h" #endif +#if (OSAL_ST_RESOLUTION != 16) && (OSAL_ST_RESOLUTION != 32) +#error "invalid OSAL_ST_RESOLUTION, must be 16 or 32" +#endif + /*===========================================================================*/ /* Module data structures and types. */ /*===========================================================================*/ diff --git a/os/rt/osal/osal.h b/os/rt/osal/osal.h index edaa34547..c9cb9b1ec 100644 --- a/os/rt/osal/osal.h +++ b/os/rt/osal/osal.h @@ -71,8 +71,8 @@ * @name Special time constants * @{ */ -#define TIME_IMMEDIATE ((systime_t)0) -#define TIME_INFINITE ((systime_t)-1) +#define TIME_IMMEDIATE ((systime_t)0) +#define TIME_INFINITE ((systime_t)-1) /** @} */ #endif @@ -86,11 +86,18 @@ /** @} */ /** - * @name Systick resolution. + * @name Systick parameters. * @{ */ +/** + * @brief Size in bits of the @p systick_t type. + */ #define OSAL_ST_RESOLUTION CH_CFG_ST_RESOLUTION -/** @} */ + +/** + * @brief Required systick frequency or resolution. + */ +#define OSAL_ST_FREQUENCY CH_CFG_ST_FREQUENCY /** * @brief Systick mode required by the underlying OS. @@ -100,11 +107,7 @@ #else #define OSAL_ST_MODE OSAL_ST_MODE_FREERUNNING #endif - -/** - * @brief Required systick frequency or resolution. - */ -#define OSAL_SYSTICK_FREQUENCY CH_CFG_ST_FREQUENCY +/** @} */ /*===========================================================================*/ /* Module pre-compile time settings. */