rp2xxx: Remove SchmittTrigger, use Enabled#635
rp2xxx: Remove SchmittTrigger, use Enabled#635tact1m4n3 merged 7 commits intoZigEmbeddedGroup:mainfrom
Conversation
Grazfather
left a comment
There was a problem hiding this comment.
Looks good. I noticed set_input_enabled uses a bool. We might want to use this enum there for consistency.
|
Isn't it looking a bit weird in terms of code readability? I mean pub inline fn set_input_enabled(pin: Pin, enabled: SchmittTrigger) void {
const pads_reg = pin.get_pads_reg();
pads_reg.modify(.{ .IE = @intFromEnum(enabled) });
} |
|
Maybe we should have kept the |
|
Yes that is what I was suggesting. |
|
I'd say to keep Enabled for set_schmitt_trigger for now and leave the others as they are. |
|
So what's the final verdict? |
|
Imo no |
…ymore - Removed all Enabled enum usage in schmitt trigger and turned them to be bool only - Only GPIO confing uses now the Enabled enum for user-friendly readability
tact1m4n3
left a comment
There was a problem hiding this comment.
A few minor changes and we're good to go
- Remove switch and use logical eval
All done I guess. |
|
Nice! Thank you! |
Code:
Causing:
install └─ install generated to light-mcu.uf2 └─ run elf2uf2 (light-mcu.uf2) └─ zig build-exe light-mcu ReleaseSmall thumb-freestanding-eabi 1 errors /home/guney/.cache/zig/p/mz_port_raspberrypi_rp2xxx-0.0.0-wCvtidmzDQDWXpsuqBY_8dkz96PsJ_rrMKX04haxvjRt/src/hal/pins.zig:944:60: error: expected type 'hal.gpio.Enabled', found 'hal.gpio.SchmittTrigger' gpio.num(gpio_num).set_schmitt_trigger(enabled);When I dig into the code base. I realized that gpio config uses
SchmittTriggerbutset_schmitt_triggerinpins.zigusesEnabledso if you passSchmittTriggerenum the pins.zig fails, if you passEnabledthengpio.zigfails.I honestly couldn't see if there was a purpose of having them twice(ish), but looks like causing trouble if I'm not really doing something completely stupid.