File tree Expand file tree Collapse file tree 3 files changed +10
-13
lines changed
Expand file tree Collapse file tree 3 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -269,10 +269,15 @@ void SysTick_Handler(void) {
269269 // work properly.
270270 SysTick -> CTRL ;
271271
272- // Right now we just have the DMA controllers to process during this
273- // interrupt and we use a custom dispatch handler . If this needs to
272+ // Right now we have the storage and DMA controllers to process during
273+ // this interrupt and we use custom dispatch handlers . If this needs to
274274 // be generalised in the future then a dispatch table can be used as
275275 // follows: ((void(*)(void))(systick_dispatch[uwTick & 0xf]))();
276+
277+ if (STORAGE_IDLE_TICK (uwTick )) {
278+ NVIC -> STIR = FLASH_IRQn ;
279+ }
280+
276281 if (DMA_IDLE_ENABLED () && DMA_IDLE_TICK (uwTick )) {
277282 dma_idle_handler (uwTick );
278283 }
Original file line number Diff line number Diff line change 2626
2727#define FLASH_BLOCK_SIZE (512)
2828
29+ #define STORAGE_SYSTICK_MASK (0x1ff) // 512ms
30+ #define STORAGE_IDLE_TICK (tick ) (((tick) & STORAGE_SYSTICK_MASK) == 0)
31+
2932void storage_init (void );
3033uint32_t storage_get_block_size (void );
3134uint32_t storage_get_block_count (void );
Original file line number Diff line number Diff line change @@ -148,9 +148,6 @@ TIM_HandleTypeDef TIM3_Handle;
148148TIM_HandleTypeDef TIM5_Handle ;
149149TIM_HandleTypeDef TIM6_Handle ;
150150
151- // Used to divide down TIM3 and periodically call the flash storage IRQ
152- STATIC uint32_t tim3_counter = 0 ;
153-
154151#define PYB_TIMER_OBJ_ALL_NUM MP_ARRAY_SIZE(MP_STATE_PORT(pyb_timer_obj_all))
155152
156153STATIC 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);
159156STATIC mp_obj_t pyb_timer_channel_callback (mp_obj_t self_in , mp_obj_t callback );
160157
161158void timer_init0 (void ) {
162- tim3_counter = 0 ;
163159 for (uint i = 0 ; i < PYB_TIMER_OBJ_ALL_NUM ; i ++ ) {
164160 MP_STATE_PORT (pyb_timer_obj_all )[i ] = NULL ;
165161 }
@@ -256,13 +252,6 @@ TIM_HandleTypeDef *timer_tim6_init(uint freq) {
256252void HAL_TIM_PeriodElapsedCallback (TIM_HandleTypeDef * htim ) {
257253 if (htim == & TIM3_Handle ) {
258254 USBD_CDC_HAL_TIM_PeriodElapsedCallback ();
259-
260- // Periodically raise a flash IRQ for the flash storage controller
261- if (tim3_counter ++ >= 500 / USBD_CDC_POLLING_INTERVAL ) {
262- tim3_counter = 0 ;
263- NVIC -> STIR = FLASH_IRQn ;
264- }
265-
266255 } else if (htim == & TIM5_Handle ) {
267256 servo_timer_irq_callback ();
268257 }
You can’t perform that action at this time.
0 commit comments