6 years ago.

How to have custom PeripheralPins.c on MBED 5

I am using NUCLEO_F446RE platform and needed to do some changes in PeripheralPins.c - mapping of which PWM timer is mapped to which PIN (the alternatives was already there, just commented out, so i uncommented the ones i needed and commented out conflicting ones)

Is there some way to achieve this without changing mbed-os source files? Like inherited platform with only this file changed or something?

Is there some best practice for this?

Thank you

2 Answers

6 years ago.

Hi Pavel, I added some time ago a weak linker property to the PeripheralPins.c tables which has been now adapted to all STM32 targets. You can simply define your own custom PeripheralPins.c tables and the linker will use yours because the default tables are weak linked.

Please note that you cannot add more SPI, I2C etc. devices because this is somehow static in some of the STM code, however using the additional pins will work.

Regards Helmut

Accepted Answer

Perfect - this is what i was looking for - i don't need to add, i just need to move some PWM pins to different timers (need more PWM pins to sit on non colliding timer channels)

posted by Pavel Sorejs 31 Mar 2018
6 years ago.

Hi Pavel,

You can alter the PeripheralPins.c file just for the NUCLEO_F466RE platform: https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F446xE/TARGET_NUCLEO_F446RE/PeripheralPins.c

That would be the easiest way to achieve a custom pin mapping. However, you can also try creating your own custom target for Mbed OS using your own custom code, you can follow ST's instructions for this here: https://os.mbed.com/teams/ST/wiki/steps-to-create-a-new-STM32-platform

- Jenny, team Mbed