rp-rs / rp2040-pac

A Rust PAC for the RP2040 Microcontroller
145 stars 28 forks source link

GPIO GPIO_CTRL registers field funcsel all have the same options #22

Closed hmvp closed 2 years ago

hmvp commented 3 years ago

According to 2.19.2 from the datasheet each pin has its own set of functions. This crate generates set functions for each function but each pin seems to have the same set of set functions (which seem to match gpio pin 0)

I expect to be able to do something like:

    p.IO_BANK0.gpio[16].gpio_ctrl.modify(|_,w|w.funcsel().spi0_rx());
    p.IO_BANK0.gpio[17].gpio_ctrl.modify(|_,w|w.funcsel().spi0_csn());
    p.IO_BANK0.gpio[18].gpio_ctrl.modify(|_,w|w.funcsel().spi0_sck());
    p.IO_BANK0.gpio[19].gpio_ctrl.modify(|_,w|w.funcsel().spi0_tx());

but all pins only have spi0_rx() for spi0 functions (which is wrong)

anall commented 3 years ago

This is just an artifact of clustering them. These should probably just be renamed to spi to remove specific meaning (while the specific pin is still restricted to spi0_rx or whatever)

hmvp commented 3 years ago

Ah yes the underlying bits will stay the same indeed.. Its a bit unfortunate that you lose the information about which spi is on that pin or if its an RX or TX pin, but I guess I need to add that myself with a comment...

Maybe it could be added to the doc string for that function so you see what is what without needing the datasheet..