Closed jamwaffles closed 3 years ago
This was tested on an L053 Nucleo with a lil hand encoder module from Aliexpress.
I just realised it's not possible to enable interrupts with this API. Converting to draft until that's fixed...
The API looks like this now:
let mut encoder = LpTimer::init_encoder(
LPTIM,
&mut pwr,
&mut rcc,
// Use low speed internal oscillator
lptim::ClockSrc::Lsi,
(gpiob.pb5, gpiob.pb7),
);
encoder.enable_interrupts(lptim::Interrupts {
enc_dir_up: true,
..lptim::Interrupts::default()
});
// Set ARR to 4096
encoder.enable(4096);
I don't think it's very ergonomic, but at least it works... it also reuses as much of the existing API as possible.
Very open to suggestions on how to make this nicer to use!
Review comments addressed - I added a more descriptive comment for arr
, although I left it vague as I'm unsure what it wraps around to. The value in CMP
maybe?
I also added a disable
method as suggested.
Thanks! One less patch to keep in my fork :P
As per the title, adds support for turning on encoder mode for LPTIM. e.g.