diff options
author | Damien George <damien.p.george@gmail.com> | 2015-12-04 14:07:15 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-12-04 14:07:15 +0000 |
commit | 66b96822fb33863fde5ce13a6bdeb99a404575dc (patch) | |
tree | 3bd14e12de97527afd9f362bdd9aaef0a1f2ec2c /stmhal/stm32_it.c | |
parent | 9aaf888b420101fd01c9455f20fda7a09ce8d93d (diff) |
stmhal: Add option to free up TIM3 from USB VCP polling.
This is a hack to free up TIM3 so that it can be used by the user.
Instead we use the PVD irq to call the USB VCP polling function, and
trigger it from SysTick (so SysTick itself does not do any processing).
The feature is enabled for pyboard lite only, since it lacks timers.
Diffstat (limited to 'stmhal/stm32_it.c')
-rw-r--r-- | stmhal/stm32_it.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/stmhal/stm32_it.c b/stmhal/stm32_it.c index 5f96c6083..371d20dd7 100644 --- a/stmhal/stm32_it.c +++ b/stmhal/stm32_it.c @@ -277,6 +277,12 @@ void SysTick_Handler(void) { // be generalised in the future then a dispatch table can be used as // follows: ((void(*)(void))(systick_dispatch[uwTick & 0xf]))(); + #if defined(MICROPY_HW_USE_ALT_IRQ_FOR_CDC) + if (((uwTick) & 7) == 4) { // every 8ms + NVIC->STIR = PVD_IRQn; + } + #endif + if (STORAGE_IDLE_TICK(uwTick)) { NVIC->STIR = FLASH_IRQn; } @@ -425,6 +431,10 @@ void EXTI15_10_IRQHandler(void) { } void PVD_IRQHandler(void) { + #if defined(MICROPY_HW_USE_ALT_IRQ_FOR_CDC) + extern void USBD_CDC_HAL_TIM_PeriodElapsedCallback(void); + USBD_CDC_HAL_TIM_PeriodElapsedCallback(); + #endif Handle_EXTI_Irq(EXTI_PVD_OUTPUT); } @@ -465,7 +475,11 @@ void TIM2_IRQHandler(void) { } void TIM3_IRQHandler(void) { + #if defined(MICROPY_HW_USE_ALT_IRQ_FOR_CDC) + timer_irq_handler(3); + #else HAL_TIM_IRQHandler(&TIM3_Handle); + #endif } void TIM4_IRQHandler(void) { |