aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-07-23 13:51:02 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2013-07-23 13:51:02 +0000
commitfa64f08fc1ad45d0984828695697f6abde7e8ffd (patch)
tree6d7c116760540a13a3e87c2b512dff4618de196f /os
parent30895b26766443c620dfe5a5aabc90fc8c53c7f8 (diff)
downloadChibiOS-fa64f08fc1ad45d0984828695697f6abde7e8ffd.tar.gz
ChibiOS-fa64f08fc1ad45d0984828695697f6abde7e8ffd.tar.bz2
ChibiOS-fa64f08fc1ad45d0984828695697f6abde7e8ffd.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6024 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/platforms/STM32F30x/hal_lld.c6
-rw-r--r--os/kernel/include/chvt.h15
-rw-r--r--os/ports/GCC/ARMCMx/STM32F3xx/chtimer.c2
-rw-r--r--os/ports/GCC/ARMCMx/chcore_v7m.c2
4 files changed, 20 insertions, 5 deletions
diff --git a/os/hal/platforms/STM32F30x/hal_lld.c b/os/hal/platforms/STM32F30x/hal_lld.c
index 64b691ade..fcfbd4d10 100644
--- a/os/hal/platforms/STM32F30x/hal_lld.c
+++ b/os/hal/platforms/STM32F30x/hal_lld.c
@@ -103,12 +103,18 @@ void hal_lld_init(void) {
rccResetAPB1(0xFFFFFFFF);
rccResetAPB2(0xFFFFFFFF);
+#if CH_CFG_TIMEDELTA == 0
/* SysTick initialization using the system clock.*/
SysTick->LOAD = STM32_HCLK / CH_CFG_FREQUENCY - 1;
SysTick->VAL = 0;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_ENABLE_Msk |
SysTick_CTRL_TICKINT_Msk;
+#else
+ rccEnableAPB1(RCC_APB1ENR_TIM2EN, TRUE);
+ nvicEnableVector(28, CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SYSTICK));
+ TIM2->PSC = STM32_TIMCLK2 / CH_CFG_FREQUENCY - 1;
+#endif
/* DWT cycle counter enable.*/
SCS_DEMCR |= SCS_DEMCR_TRCENA;
diff --git a/os/kernel/include/chvt.h b/os/kernel/include/chvt.h
index 2c4b489d5..d1659d286 100644
--- a/os/kernel/include/chvt.h
+++ b/os/kernel/include/chvt.h
@@ -41,6 +41,14 @@
/* Derived constants and error checks. */
/*===========================================================================*/
+#if CH_CFG_FREQUENCY <= 0
+#error "invalid CH_CFG_FREQUENCY specified"
+#endif
+
+#if (CH_CFG_TIMEDELTA < 0) || (CH_CFG_TIMEDELTA == 1)
+#error "invalid NIL_CFG_TIMEDELTA specified"
+#endif
+
/*===========================================================================*/
/* Module data structures and types. */
/*===========================================================================*/
@@ -387,6 +395,8 @@ static inline void chVTDoTickI(void) {
systime_t delta = now - vtlist.vt_lasttime;
while ((vtp = vtlist.vt_next)->vt_delta <= delta) {
+ delta -= vtp->vt_delta;
+ vtlist.vt_lasttime += vtp->vt_delta;
vtfunc_t fn = vtp->vt_func;
vtp->vt_func = (vtfunc_t)NULL;
vtp->vt_next->vt_prev = (void *)&vtlist;
@@ -401,10 +411,7 @@ static inline void chVTDoTickI(void) {
port_timer_stop_alarm();
}
else {
- /* The delta is subtracted to the next list element, the current time
- becomes the new delta list base time.*/
- vtp->vt_delta -= delta;
- vtlist.vt_lasttime = now;
+ /* Updating the alarm to the next deadline.*/
port_timer_set_alarm(now + vtp->vt_delta);
}
#endif /* CH_CFG_TIMEDELTA > 0 */
diff --git a/os/ports/GCC/ARMCMx/STM32F3xx/chtimer.c b/os/ports/GCC/ARMCMx/STM32F3xx/chtimer.c
index 5cb8d8c75..78d2aaf06 100644
--- a/os/ports/GCC/ARMCMx/STM32F3xx/chtimer.c
+++ b/os/ports/GCC/ARMCMx/STM32F3xx/chtimer.c
@@ -53,7 +53,7 @@
*
* @isr
*/
-CH_IRQ_HANDLER(Vector7C) {
+CH_IRQ_HANDLER(VectorB0) {
CH_IRQ_PROLOGUE();
diff --git a/os/ports/GCC/ARMCMx/chcore_v7m.c b/os/ports/GCC/ARMCMx/chcore_v7m.c
index dfe2e2d5a..23554935a 100644
--- a/os/ports/GCC/ARMCMx/chcore_v7m.c
+++ b/os/ports/GCC/ARMCMx/chcore_v7m.c
@@ -124,6 +124,8 @@ void _port_init(void) {
#if CH_CFG_TIMEDELTA == 0
nvicSetSystemHandlerPriority(HANDLER_SYSTICK,
CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SYSTICK));
+#else
+ port_timer_init();
#endif
}