git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6298 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2013-09-12 17:45:10 +00:00
parent 8261c67442
commit a86b48c578
6 changed files with 56 additions and 21 deletions

View File

@ -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. * @brief System tick frequency.
*/ */

View File

@ -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. * @brief System tick frequency.
*/ */

View File

@ -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. * @brief System tick frequency.
*/ */
@ -64,7 +70,7 @@
* The value one is not valid, timeouts are rounded up to * The value one is not valid, timeouts are rounded up to
* this value. * this value.
*/ */
#define NIL_CFG_ST_TIMEDELTA 0 #define NIL_CFG_ST_TIMEDELTA 2
/** @} */ /** @} */

View File

@ -83,11 +83,11 @@
#error "STM32_ST_USE_TIMER specifies an unsupported timer" #error "STM32_ST_USE_TIMER specifies an unsupported timer"
#endif #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" #error "the selected ST frequency is not obtainable because integer rounding"
#endif #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" #error "the selected ST frequency is not obtainable because TIM timer prescaler limits"
#endif #endif
@ -95,11 +95,11 @@
#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC #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" #error "the selected ST frequency is not obtainable because integer rounding"
#endif #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" #error "the selected ST frequency is not obtainable because SysTick timer counter limits"
#endif #endif
@ -183,7 +183,7 @@ void st_lld_init(void) {
ST_ENABLE_CLOCK(); ST_ENABLE_CLOCK();
/* Initializing the counter in free running mode.*/ /* 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->ARR = ST_ARR_INIT;
STM32_ST_TIM->CCMR1 = 0; STM32_ST_TIM->CCMR1 = 0;
STM32_ST_TIM->CCR[0] = 0; STM32_ST_TIM->CCR[0] = 0;
@ -199,7 +199,7 @@ void st_lld_init(void) {
#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC
/* Periodic systick mode, the Cortex-Mx internal systick timer is used /* Periodic systick mode, the Cortex-Mx internal systick timer is used
in this mode.*/ in this mode.*/
SysTick->LOAD = (STM32_HCLK / OSAL_SYSTICK_FREQUENCY) - 1; SysTick->LOAD = (STM32_HCLK / OSAL_ST_FREQUENCY) - 1;
SysTick->VAL = 0; SysTick->VAL = 0;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_ENABLE_Msk | SysTick_CTRL_ENABLE_Msk |

View File

@ -85,6 +85,20 @@
#define OSAL_ST_MODE_FREERUNNING 2 #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. * @brief Systick mode required by the underlying OS.
*/ */
@ -93,11 +107,7 @@
#else #else
#define OSAL_ST_MODE OSAL_ST_MODE_FREERUNNING #define OSAL_ST_MODE OSAL_ST_MODE_FREERUNNING
#endif #endif
/** @} */
/**
* @brief Required systick frequency or resolution.
*/
#define OSAL_SYSTICK_FREQUENCY NIL_CFG_ST_FREQUENCY
/*===========================================================================*/ /*===========================================================================*/
/* Module pre-compile time settings. */ /* Module pre-compile time settings. */
@ -117,6 +127,10 @@
#error "invalid OSAL_ST_MODE setting in osal.h" #error "invalid OSAL_ST_MODE setting in osal.h"
#endif #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. */ /* Module data structures and types. */
/*===========================================================================*/ /*===========================================================================*/

View File

@ -71,8 +71,8 @@
* @name Special time constants * @name Special time constants
* @{ * @{
*/ */
#define TIME_IMMEDIATE ((systime_t)0) #define TIME_IMMEDIATE ((systime_t)0)
#define TIME_INFINITE ((systime_t)-1) #define TIME_INFINITE ((systime_t)-1)
/** @} */ /** @} */
#endif #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 #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. * @brief Systick mode required by the underlying OS.
@ -100,11 +107,7 @@
#else #else
#define OSAL_ST_MODE OSAL_ST_MODE_FREERUNNING #define OSAL_ST_MODE OSAL_ST_MODE_FREERUNNING
#endif #endif
/** @} */
/**
* @brief Required systick frequency or resolution.
*/
#define OSAL_SYSTICK_FREQUENCY CH_CFG_ST_FREQUENCY
/*===========================================================================*/ /*===========================================================================*/
/* Module pre-compile time settings. */ /* Module pre-compile time settings. */