9 years, 5 months ago.

How do I modify the mbed target-specific library code (to remap some pins)?

Hi all,

I'm trying to remap certain PinNames to different pins on the nRF51822-mkit platform. I've converted the mbed imported library in the online IDE, which gave me a lot of header files for all targets. I found the "PinNames.h" file for the nordic platform, and modified it to remap the pins (specifically, SPI1 is remapped from pins 12-15 (default) to pin 1-4 (on my hardware).

It compiles fine, but doesn't run on the hardware. I get two blinking LEDs indicating a failure.

It seems the header files aren't being included in the compilation. I also cannot find any .c/.cpp implementation files in the mbed library.

Does anyone know how to remap the pins? Any pointers would be much appreciated. Thanks.

2 Answers

9 years, 5 months ago.

If you want to change the source files you should look at the mbed-src library: http://developer.mbed.org/users/mbed_official/code/mbed-src/. Pinout file is in Targets/Hal/Target_Nordic/Target_nrf/[board]

Accepted Answer

I may be wrong here but I think he has done that Erik, I don't think he can remap peripherals to 'illegal' physical pins. But I don't have the peripheral pin out configuration tables.

posted by Paul Staron 17 Nov 2014

Wonderful. Thanks Erik, this is exactly what I was looking for. I imported mbed-src in place of mbed in my project and am able to recompile with my modified sources.

Now to see if just changing PinNames.h solves my problem..!

EDIT: can verify just changing the mapping in PinNames.h file seems to be working. No blinking LEDs anymore and my hardware is up and running.

posted by Prashant Vaibhav 17 Nov 2014

@Paul: no actually I had not imported the "mbed-src" library, but had just used the right-click>convert to library option on the pre-included "mbed" library.

posted by Prashant Vaibhav 17 Nov 2014
9 years, 5 months ago.

I do not have this platform, however Nordic should have a peripheral pin out alternative chart similar to other platforms on Mbed. Generally not all peripheral functions are accessible on every pin combination. Perhaps there are no alternatives available at all for this platform so you may have to change your hardware connections to suit the default pins specified. Best bet is to contact Nordic for confirmation.

Thanks for the response. I do have the pinout, but the problem is that on my hardware the SPI pins are routed to different pins than what the mbed pinout says. I've contacted the mbed developers and they've told me that the SPI implementation made the assumption that only those pins can be used. In reality Nordic chip can be configured to use any pin combination. Mbed developers confirmed that the spi implementation will need to be rewritten to support that.

In the meantime I'm trying to do this myself as I'm running out of time on this project. Perhaps I will try using the nordic native SDK within mbed.

posted by Prashant Vaibhav 17 Nov 2014