Added GPIO IRQ interface, refactoring

- Adds the IRQ interface to configure interrupts on output and input pins
- Moved the `FilterClkSel` struct to the `clock` module, reexporting in `gpio`
- Added function to set clock divisor registers
- Clearing output state at initialization of Output pins
- Added utility function to set up millisecond timer
This commit is contained in:
2021-11-13 14:43:21 +01:00
parent 1c31e9177d
commit af5a831579
9 changed files with 314 additions and 105 deletions

View File

@ -12,7 +12,7 @@ use va108xx_hal::{
pac::{self, interrupt},
prelude::*,
time::Hertz,
timer::{CountDownTimer, Event},
timer::{set_up_ms_timer, CountDownTimer, Event},
};
#[allow(dead_code)]
@ -65,23 +65,21 @@ fn main() -> ! {
}
}
LibType::Hal => {
let mut ms_timer =
CountDownTimer::tim0(&mut dp.SYSCONFIG, get_sys_clock().unwrap(), dp.TIM0);
let mut second_timer =
CountDownTimer::tim1(&mut dp.SYSCONFIG, get_sys_clock().unwrap(), dp.TIM1);
ms_timer.listen(
Event::TimeOut,
set_up_ms_timer(
&mut dp.SYSCONFIG,
&mut dp.IRQSEL,
50.mhz().into(),
dp.TIM0,
interrupt::OC0,
);
let mut second_timer =
CountDownTimer::tim1(&mut dp.SYSCONFIG, get_sys_clock().unwrap(), dp.TIM1);
second_timer.listen(
Event::TimeOut,
&mut dp.SYSCONFIG,
&mut dp.IRQSEL,
interrupt::OC1,
);
ms_timer.start(1000.hz());
second_timer.start(1.hz());
unmask_irqs();
}