summaryrefslogtreecommitdiff
path: root/stmhal/timer.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-11-24 16:18:07 +0000
committerDamien George <damien.p.george@gmail.com>2015-11-24 16:18:07 +0000
commite99e6c883d70eda894aba124c8ee0495dc90c350 (patch)
tree3899eb1ef11b86fa1316999eaaedc8f1a2798104 /stmhal/timer.c
parent3cfb02f1663fbf3a6d7ae367974d0984d3424806 (diff)
stmhal: Move flash storage idle tick handler from TIM3 to SysTick.
Using SysTick to do the counting and dispatch of the flash storage idle handler is more efficient than requiring a dedicated hardware timer. No new counter is needed, just the existing uwTick variable. The processing is not actually done in the SysTick IRQ, it is deferred to the flash IRQ (which runs at lower priority).
Diffstat (limited to 'stmhal/timer.c')
-rw-r--r--stmhal/timer.c11
1 files changed, 0 insertions, 11 deletions
diff --git a/stmhal/timer.c b/stmhal/timer.c
index 39643385b..cf93a01d7 100644
--- a/stmhal/timer.c
+++ b/stmhal/timer.c
@@ -148,9 +148,6 @@ TIM_HandleTypeDef TIM3_Handle;
TIM_HandleTypeDef TIM5_Handle;
TIM_HandleTypeDef TIM6_Handle;
-// Used to divide down TIM3 and periodically call the flash storage IRQ
-STATIC uint32_t tim3_counter = 0;
-
#define PYB_TIMER_OBJ_ALL_NUM MP_ARRAY_SIZE(MP_STATE_PORT(pyb_timer_obj_all))
STATIC uint32_t timer_get_source_freq(uint32_t tim_id);
@@ -159,7 +156,6 @@ STATIC mp_obj_t pyb_timer_callback(mp_obj_t self_in, mp_obj_t callback);
STATIC mp_obj_t pyb_timer_channel_callback(mp_obj_t self_in, mp_obj_t callback);
void timer_init0(void) {
- tim3_counter = 0;
for (uint i = 0; i < PYB_TIMER_OBJ_ALL_NUM; i++) {
MP_STATE_PORT(pyb_timer_obj_all)[i] = NULL;
}
@@ -256,13 +252,6 @@ TIM_HandleTypeDef *timer_tim6_init(uint freq) {
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
if (htim == &TIM3_Handle) {
USBD_CDC_HAL_TIM_PeriodElapsedCallback();
-
- // Periodically raise a flash IRQ for the flash storage controller
- if (tim3_counter++ >= 500 / USBD_CDC_POLLING_INTERVAL) {
- tim3_counter = 0;
- NVIC->STIR = FLASH_IRQn;
- }
-
} else if (htim == &TIM5_Handle) {
servo_timer_irq_callback();
}