ataradov / mcu-starter-projects

Simple starter projects for bare-metal MCU development
309 stars 41 forks source link

[REQUEST] Allow the bootsel button to be used as well as GPIO 18 for the rp2040 example #9

Closed shreeve closed 10 months ago

shreeve commented 10 months ago

For the rp2040 example, the toggle occurs when a "button" on GPIO 18 is pulled low, shown here:

I'd like to see if the bootsel button can be used in addition to this. But, the bootsel button is a little bit special. It requires some logic in order to read it's current state. Here's what the the pico-examples shows is needed:

My request is if you could implement the get_bootsel_button function using your extremely lightweight mcu-starter-projects/rp2040 code. I don't really see any examples of people using this "built in" bootsel button, likely because it requires this extra bit of work to check it's value. Without having access to the Pico-SDK, how would you implement this function so that both GPIO 18 and/or the bootsel button could be used for this example?

ataradov commented 10 months ago

The goal of this repo is to provide the same basic example for different MCUs. This is not a generic library, I don't want to support all possible features. Also, startup code relocates everything into SRAM, so flash can be disabled permanently and then you don't need to save/restore registers. So, reading the button is reduced to reading one register.

shreeve commented 10 months ago

Excellent, thank you!