Open tib888 opened 6 years ago
@japaric Since all reactive/rtfm examples become outdated. It would be nice to get some information how to deal with the IRQs and their setup in the future? The RTFM will be improved or we should expect something new?
I have the same issue. For now, I do
fn one_khz(_t: &mut rtfm::Threshold, mut r: TIM3::Resources) {
unsafe { (*hal::stm32f103xx::TIM3::ptr()).sr.modify(|_, w| w.uif().clear_bit()); };
r.ALARM.poll();
}
To make this timer2 based blinky example work, I had to add clear_interrupt_pending to the timer implementation macro.
' /// use this in the interrupt handler pub fn clear_interruptpending(&mut self) { self.tim.sr.modify(|, w| w.uif().clear_bit()); } ' But this is just the very minimum. Looking at the C examples, they test several flags to decide the event tipe raised the interrupt and call the appropriate callback, which has a default weak implementation. 'if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) { TIM_ClearITPendingBit(TIM2, TIM_IT_Update); Timer_update_cb(...); }'
TIM_IT_Update: TIM1 update Interrupt source TIM_IT_CC1: TIM Capture Compare 1 Interrupt source TIM_IT_CC2: TIM Capture Compare 2 Interrupt source TIM_IT_CC3: TIM Capture Compare 3 Interrupt source TIM_IT_CC4: TIM Capture Compare 4 Interrupt source TIM_IT_COM: TIM Commutation Interrupt source TIM_IT_Trigger: TIM Trigger Interrupt source TIM_IT_Break: TIM Break Interrupt source