aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/nil/NIL-STM32F051-DISCOVERY/nilconf.h6
-rw-r--r--demos/nil/NIL-STM32F373-STM32373C_EVAL/nilconf.h6
-rw-r--r--demos/nil/NIL-STM32L152-DISCOVERY/nilconf.h8
-rw-r--r--os/hal/ports/STM32/TIMv1/st_lld.c12
-rw-r--r--os/nil/osal/osal.h24
-rw-r--r--os/rt/osal/osal.h21
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
@@ -52,6 +52,12 @@
/*===========================================================================*/
/**
+ * @brief System time counter resolution.
+ * @note Allowed values are 16 or 32 bits.
+ */
+#define NIL_CFG_ST_RESOLUTION 32
+
+/**
* @brief System tick frequency.
*/
#define NIL_CFG_ST_FREQUENCY 50000
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
@@ -52,6 +52,12 @@
/*===========================================================================*/
/**
+ * @brief System time counter resolution.
+ * @note Allowed values are 16 or 32 bits.
+ */
+#define NIL_CFG_ST_RESOLUTION 32
+
+/**
* @brief System tick frequency.
*/
#define NIL_CFG_ST_FREQUENCY 50000
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
@@ -52,6 +52,12 @@
/*===========================================================================*/
/**
+ * @brief System time counter resolution.
+ * @note Allowed values are 16 or 32 bits.
+ */
+#define NIL_CFG_ST_RESOLUTION 16
+
+/**
* @brief System tick frequency.
*/
#define NIL_CFG_ST_FREQUENCY 1000
@@ -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
@@ -86,6 +86,20 @@
/** @} */
/**
+ * @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.
*/
#if (NIL_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
@@ -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. */