-
Notifications
You must be signed in to change notification settings - Fork 276
Added support for pins_with_function!() and pin_with_name!() #963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
pub static PICOTOOL_ENTRIES: [rp_binary_info::EntryAddr; 7] = [
rp_binary_info::pins_with_function!(
PICO_DEFAULT_I2C_SDA_PIN,
PICO_DEFAULT_I2C_SCL_PIN,
GPIO_FUNC_I2C),
rp_binary_info::pin_with_name!(
25, // pin 25 is the LED
c"The LED"
),
];
I found constants in these places:
pico-sdk/src/boards/include/boards/pico2_w.h
pico-sdk/src/common/pico_binary_info/include/pico/binary_info/structure.h
pico-sdk/src/rp2350/hardware_structs/include/hardware/structs/io_bank0.h
|
Can you reformat and squash? |
| data_type: DataType::PinsWithFunction, | ||
| tag: TAG_RASPBERRY_PI, | ||
| }, | ||
| pin_encoding: BI_PINS_ENCODING_MULTI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth noting that this is a value with multiple fields, and raspberry pi seem to indicate that there are no more pins by setting two consecutive fields to the same value.
You could also consider using bitbybit::bitfield to describe this 32-bit value, and avoid needing to do a bunch of shifts using magic numbers. I have examples you can refer to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could then change this to take a slice of pins, rather than only two pins.
| /// GPIO pins, with their function | ||
| PinsWithFunction = 8, | ||
| /// GPIO pins, with their name | ||
| /// GPIO pins, with their name pico-sdk: BINARY_INFO_TYPE_PINS_WITH_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// GPIO pins, with their name pico-sdk: BINARY_INFO_TYPE_PINS_WITH_NAME | |
| /// GPIO pins, with their name | |
| /// | |
| /// The Pico SDK calls this `BINARY_INFO_TYPE_PINS_WITH_NAME` |
I submitted this to be used as a reference to save someone some time for when they decide to do a full implementation.
pub static PICOTOOL_ENTRIES: [rp_binary_info::EntryAddr; 2] = [
rp_binary_info::pins_with_function!(
PICO_DEFAULT_I2C_SDA_PIN,
PICO_DEFAULT_I2C_SCL_PIN,
GPIO_FUNC_I2C),
];
$ picotool info -a ./m.bin
Fixed Pin Information
4: I2C0 SDA
5: I2C0 SCL
25: The LED
I found constants in these places:
pico-sdk/src/boards/include/boards/pico2_w.h
pico-sdk/src/common/pico_binary_info/include/pico/binary_info/structure.h pico-sdk/src/rp2350/hardware_structs/include/hardware/structs/io_bank0.h