tec: add pwm default setup

master
Astro 2019-10-03 01:33:21 +02:00
parent 4ac0f7b171
commit c8d31c7b0d
2 changed files with 9 additions and 2 deletions

View File

@ -127,8 +127,8 @@ fn main() -> ! {
writeln!(stdout, "tecpak boot").unwrap();
board::init();
writeln!(stdout, "board initialized").unwrap();
let mut tec0 = Tec::tec0();
let mut tec1 = Tec::tec1();
let mut tec0 = Tec::tec0().setup(PWM_PID_WIDTH);
let mut tec1 = Tec::tec1().setup(PWM_PID_WIDTH);
println!(r#"
_ _

View File

@ -60,6 +60,13 @@ impl Tec<pwm::T4CCP0, pwm::T4CCP1, pwm::T5CCP0, pwm::T5CCP1> {
impl<MaxIPos: PwmChannel, MaxINeg: PwmChannel, ISet: PwmChannel, MaxV: PwmChannel> Tec<MaxIPos, MaxINeg, ISet, MaxV> {
pub fn setup(mut self, max: u16) -> Self {
self.max_i_pos.set(max, max);
self.max_i_neg.set(max, max);
self.max_v.set(max, max);
self
}
pub fn get(&mut self, pin: TecPin) -> (u16, u16) {
match pin {
TecPin::MaxIPos =>