Ambiq Apollo3: Make SFE_ARTEMIS use arduino uno form factor, fix GPIO IRQ API #473
+612
−332
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of changes
I'm starting to test Ambiq Apollo3 on the CI test shield. In order to do this, I first had to add arduino uno form factor support for the SFE_ARTEMIS board. This board does use the physical arduino uno form factor, but was not configured as such in Mbed, meaning the test shield project wouldn't compile. I updated PinNames.h to fix this.
With that sorted out, I investigated some failures I was seeing in the InterruptIn test. Turns out that there were two bugs in this target's implementation:
InterruptIn::_irq_handler()
withIRQ_RISE | IRQ_FALL
as the event argument, which is not valid and led to no callback getting executed.To fix the first issue, I set up a workaround where the pin is kept in interrupts-enabled-but-masked mode when no interrupt is configured, so that it can be read. To fix the second issue, I updated the HAL to read the pin state in the ISR and then send the rise or fall event accordingly. This is a little bit janky, but should work OK in most cases, and it's how STM32 HAL currently works.
I also realized that there was a big issue with how this family of boards writes its PinNames.h files: it only contains "Dx" and "Ax" names, which match up with the labeling on the board, but do not map consistently to MCU pins. This makes it a pain to write pinmaps for this target, because you constantly have to cast integers into PinNames if you want to reference the MCU pin numbering.
I updated all of the PinNames.h files to use "IO_xx" to mean pin XX of the MCU, and then map the hardware names to those IO_xx values instead of just integers. This should not be a significant compatibility change (apart from names getting standardized like SW1 -> BUTTON1), but does make code for this MCU a lot clearer.
Impact of changes
Migration actions required
Documentation
None
Pull request type
Test results
InterruptIn test shield test now passes (except some weird analog propagation time related stuff that I still need to debug).