You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...Then they use examples/documentation to create a blinker:
use esp_hal::gpio::{GpioPin,Output,PushPull};#[initializer(init)]#[derive(esp_hal::ListBuild)]structBlinker{blink_pin:GpioPin<Output<PushPull>,8>}implBlinker{// Specified as the initializer by `#[initializer(init)]`fninit(&mutself){self.blink_pin.set_low().unwrap()}fnblink_loop(self,mutdelay:Delay) -> ! {loop{self.blink_pin.toggle().unwrap();
delay.delay_ms(500u32);}unreachable!();}}
Current efforts are going well. At time of writing, we are close to this example being correct:
// mod/use's here#[entry]fnmain() -> ! {let resources = Resources::default_init();letmut delay = unimplemented!("TBD");// `list_build` is generated by the list-build derive. it auto-magically takes ownership of the pins, initializes them, and returns the peripheral and updated list of available resources, all ready to go.let(mut wheel, _resources) = peripherals::WheelEncoder::list_build(resources);loop{let scroll = wheel.read_encoder();// do something with scroll, then delay}}
...the WheelEncoderPins below would be specified more like so:
use embedded_hal::digital::v2::{InputPin,OutputPin};// Pin resource-and-init declaration#[init_with(init)]#[derive(ListBuild)]structWheelEncoderPins<I:InputPin,O:OutputPin>{#[using(GpioPin<Unknown,35>)]pin_a:I#[using(GpioPin<Unknown,36>)]pin_b:I#[using(GpioPin<Unknown,0>)]_pin_gnd:O}
the init would degrade() so that I's and O's are AnyPin
there could be a struct that contains the pins-struct
Follow-on from #745
A reference point for these R&D efforts is two-fold:
A key factor, is to make sure that
#1
can be a staging ground for#2
.A near-first-time maker with zero code experience. Arduino-like simplicity
First, they have a
cargo-generate
ed main:...Then they use examples/documentation to create a blinker:
...and add these lines to main:
Single-place specification of pin-usage. Scalable, maintainable, rapid-development
The goal in this context, is to make specifications of pins easy to extend and maintain:
...and then
pinout.json
that's in the project-root might look something like this:Current state.
Current efforts are going well. At time of writing, we are close to this example being correct:
...and in a peripheral module:
(One refinement idea:)
...the
WheelEncoderPins
below would be specified more like so:degrade()
so that I's and O's are AnyPinNext steps
Make this kind of API easy to implement
List-of-pin fields:
Pin-out specification file
As described in an earlier drop-down
The text was updated successfully, but these errors were encountered: