Defines for ALT functions of pins.
Posted: Mon Feb 23, 2015 6:15 pm
I made a stupid mistake this weekend:
I copied:from the '407-mems demo to my project on the '072 because I wanted PB13 to be SCK for SPI2, just like on the '407 discovery board. The problem is that the "magic number" 5 in there does not hold for the '072.
So, I would like to write:
to indicate that I want the SPI2 AF. This should be defined to "5" for STM32F4, and to "0" for STM32F0.
Possibly we'd need the define to read "AF_GPIOB_SPI2" if the define needs to be different for the higher ports. Hmm. The defines are (on STM32F0) specific for the PIN. Then maybe I'd prefer to write something like make_PB13_SPI2_SCK().
Any other suggestions to make it possible to catch errors like this at compile-time instead of after a deep debugging session?
I copied:
Code: Select all
palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(5) |
PAL_STM32_OSPEED_HIGHEST); /* SCK. */
So, I would like to write:
Code: Select all
palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(AF_SPI2));
Possibly we'd need the define to read "AF_GPIOB_SPI2" if the define needs to be different for the higher ports. Hmm. The defines are (on STM32F0) specific for the PIN. Then maybe I'd prefer to write something like make_PB13_SPI2_SCK().
Any other suggestions to make it possible to catch errors like this at compile-time instead of after a deep debugging session?