git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6024 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
30895b2676
commit
fa64f08fc1
|
@ -414,12 +414,12 @@
|
||||||
* @details If enabled then a field is added to the @p thread_t structure that
|
* @details If enabled then a field is added to the @p thread_t structure that
|
||||||
* counts the system ticks occurred while executing the thread.
|
* counts the system ticks occurred while executing the thread.
|
||||||
*
|
*
|
||||||
* @note The default is @p TRUE.
|
* @note The default is @p FALSE.
|
||||||
* @note This debug option is defaulted to TRUE because it is required by
|
* @note This debug option is not currently compatible with the
|
||||||
* some test cases into the test suite.
|
* tickless mode.
|
||||||
*/
|
*/
|
||||||
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
|
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
|
||||||
#define CH_DBG_THREADS_PROFILING TRUE
|
#define CH_DBG_THREADS_PROFILING FALSE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
/*
|
/*
|
||||||
* This is a periodic thread that does absolutely nothing except flashing LEDs.
|
* This is a periodic thread that does absolutely nothing except flashing LEDs.
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +54,33 @@ static msg_t Thread1(void *arg) {
|
||||||
palClearPad(GPIOE, GPIOE_LED4_BLUE);
|
palClearPad(GPIOE, GPIOE_LED4_BLUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static WORKING_AREA(waThread1, 128);
|
||||||
|
static msg_t Thread1(void *arg) {
|
||||||
|
|
||||||
|
(void)arg;
|
||||||
|
chRegSetThreadName("blinker1");
|
||||||
|
while (TRUE) {
|
||||||
|
palSetPad(GPIOE, GPIOE_LED3_RED);
|
||||||
|
chThdSleepMilliseconds(250);
|
||||||
|
palClearPad(GPIOE, GPIOE_LED3_RED);
|
||||||
|
chThdSleepMilliseconds(250);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static WORKING_AREA(waThread2, 128);
|
||||||
|
static msg_t Thread2(void *arg) {
|
||||||
|
|
||||||
|
(void)arg;
|
||||||
|
chRegSetThreadName("blinker2");
|
||||||
|
while (TRUE) {
|
||||||
|
palSetPad(GPIOE, GPIOE_LED4_BLUE);
|
||||||
|
chThdSleepMilliseconds(500);
|
||||||
|
palClearPad(GPIOE, GPIOE_LED4_BLUE);
|
||||||
|
chThdSleepMilliseconds(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Application entry point.
|
* Application entry point.
|
||||||
|
@ -80,7 +108,8 @@ int main(void) {
|
||||||
/*
|
/*
|
||||||
* Creates the example thread.
|
* Creates the example thread.
|
||||||
*/
|
*/
|
||||||
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
|
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO+1, Thread1, NULL);
|
||||||
|
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO+2, Thread2, NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Normal main() thread activity, in this demo it does nothing except
|
* Normal main() thread activity, in this demo it does nothing except
|
||||||
|
|
|
@ -103,12 +103,18 @@ void hal_lld_init(void) {
|
||||||
rccResetAPB1(0xFFFFFFFF);
|
rccResetAPB1(0xFFFFFFFF);
|
||||||
rccResetAPB2(0xFFFFFFFF);
|
rccResetAPB2(0xFFFFFFFF);
|
||||||
|
|
||||||
|
#if CH_CFG_TIMEDELTA == 0
|
||||||
/* SysTick initialization using the system clock.*/
|
/* SysTick initialization using the system clock.*/
|
||||||
SysTick->LOAD = STM32_HCLK / CH_CFG_FREQUENCY - 1;
|
SysTick->LOAD = STM32_HCLK / CH_CFG_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 |
|
||||||
SysTick_CTRL_TICKINT_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.*/
|
/* DWT cycle counter enable.*/
|
||||||
SCS_DEMCR |= SCS_DEMCR_TRCENA;
|
SCS_DEMCR |= SCS_DEMCR_TRCENA;
|
||||||
|
|
|
@ -41,6 +41,14 @@
|
||||||
/* Derived constants and error checks. */
|
/* 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. */
|
/* Module data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -387,6 +395,8 @@ static inline void chVTDoTickI(void) {
|
||||||
systime_t delta = now - vtlist.vt_lasttime;
|
systime_t delta = now - vtlist.vt_lasttime;
|
||||||
|
|
||||||
while ((vtp = vtlist.vt_next)->vt_delta <= delta) {
|
while ((vtp = vtlist.vt_next)->vt_delta <= delta) {
|
||||||
|
delta -= vtp->vt_delta;
|
||||||
|
vtlist.vt_lasttime += vtp->vt_delta;
|
||||||
vtfunc_t fn = vtp->vt_func;
|
vtfunc_t fn = vtp->vt_func;
|
||||||
vtp->vt_func = (vtfunc_t)NULL;
|
vtp->vt_func = (vtfunc_t)NULL;
|
||||||
vtp->vt_next->vt_prev = (void *)&vtlist;
|
vtp->vt_next->vt_prev = (void *)&vtlist;
|
||||||
|
@ -401,10 +411,7 @@ static inline void chVTDoTickI(void) {
|
||||||
port_timer_stop_alarm();
|
port_timer_stop_alarm();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* The delta is subtracted to the next list element, the current time
|
/* Updating the alarm to the next deadline.*/
|
||||||
becomes the new delta list base time.*/
|
|
||||||
vtp->vt_delta -= delta;
|
|
||||||
vtlist.vt_lasttime = now;
|
|
||||||
port_timer_set_alarm(now + vtp->vt_delta);
|
port_timer_set_alarm(now + vtp->vt_delta);
|
||||||
}
|
}
|
||||||
#endif /* CH_CFG_TIMEDELTA > 0 */
|
#endif /* CH_CFG_TIMEDELTA > 0 */
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
*
|
*
|
||||||
* @isr
|
* @isr
|
||||||
*/
|
*/
|
||||||
CH_IRQ_HANDLER(Vector7C) {
|
CH_IRQ_HANDLER(VectorB0) {
|
||||||
|
|
||||||
CH_IRQ_PROLOGUE();
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,8 @@ void _port_init(void) {
|
||||||
#if CH_CFG_TIMEDELTA == 0
|
#if CH_CFG_TIMEDELTA == 0
|
||||||
nvicSetSystemHandlerPriority(HANDLER_SYSTICK,
|
nvicSetSystemHandlerPriority(HANDLER_SYSTICK,
|
||||||
CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SYSTICK));
|
CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SYSTICK));
|
||||||
|
#else
|
||||||
|
port_timer_init();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue