stmhal: ADC class only uses ADC1 hardware
This issue appears not to be very minor for the pyboard or any board using 64- or 100-pin versions of the STM32F405, so it could be low-priority or 'won't fix'. However, I encountered this running MicroPython on an Olimex STM32-E407 dev board, which uses a 144-pin STM32F407. On this board, much of the GPIO from ports A, B, and C are connected to / utilized by on-board peripherals (like an Ethernet PHY). Most of the ADC input pins that are broken out to headers are on Port F, but those ADC pins are only connected internally to ADC3, so not accessible via the current ADC class:
>>> pf6 = pyb.ADC('PF6')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: pin F6 does not have ADC capabilities
>>>
Since I am already customizing the firmware a bit to get it running on the Olimex board, I think that I can solve my immediate problem by hacking a few lines in adc.c to use ADC3 instead of ADC1. I don't have a more generic solution yet, so I just wanted to raise the issue before I forgot about it.
The biggest potential benefit that I could see in enabling the ADC2 and ADC3 hardware for lower pin-count chips would be to enable high-speed interleaved ADC reads on those pins connected to all three instances, but it would take some serious recoding to allow this, for an application that may see relatively little use.
[STM32H743] ADC fail
Using the latest version of the main branch and run the script.
>>> import pyb
>>> adc = pyb.ADC(pyb.Pin.board.PA4)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: pin A4 does not have ADC capabilities
https://github.com/micropython/micropython/blob/9ac9aa989c89a1d6310160dd408820d1164d4dd7/ports/stm32/adc.c#L396-L399
Because H7 uses ADC3
https://github.com/micropython/micropython/blob/9ac9aa989c89a1d6310160dd408820d1164d4dd7/ports/stm32/adc.c#L53-L58