Thank you so much Chris and Will for your notes. Let me specify my case. There are actually 2 different scenarios that I need to address.
BACKGROUND: I have developed (or should I say Will has and I have subsequently hacked it) an app that runs on 2 NRF52-based BSPs, namely NRF52DK and RBN2 and that exhibits same behaviour on both. ISSUE ǸUMBER 1 Both boards has one LED on the board and both BSPs define LED_BLINK_PIN. But the issue is the following code would turn on the led on NRF52DK and will turn it off on RBN2 ! g_led_pin = LED_BLINK_PIN; hal_gpio_init_out(g_led_pin, 0); ISSUE NUMBER 2 For practical wiring reasons I want to enable different GPIO input PINS on the 2 BSPs Looking forward to your comments. Ciao Ugo On Wed, Jun 14, 2017, at 07:12 PM, Christopher Collins wrote: > On Wed, Jun 14, 2017 at 04:22:52PM +0200, Ugo Mastracchio wrote: > > Hello everyone, may I throw an absolute beginner's question ? > > > > How do I conditionally compile based on the BSP the target is > > associated with ?I want to use different GPIO pins depending on the > > board.... > > > > Is there a system configuration setting valued with the BSP name ? > > After writing my previous response, I am thinking I may have > misunderstood the question. Generally, the PIN mappings are defined in > the BSP package itself, so there should be no need to remap pins based > on the BSP being used. Are you perhaps trying to use the same BSP > package for two slightly different boards? > > If this is what you want to do, you may want to take a look at how the > arduino_zero BSP handles this. The 1) arduino zero and 2) arduino zero > pro hardware is very similar. I believe the only difference are a few > GPIO mappings. Rather than create a separate BSP for each board, the > arduino BSP package code uses conditional compilation. > > Within the arduino repo > (https://github.com/runtimeco/mynewt_arduino_zero), the arduino_zero BSP > defines these settings: > > BSP_ARDUINO_ZERO: > description: 'TBD' > value: 0 > restrictions: > - "!BSP_ARDUINO_ZERO_PRO" > > BSP_ARDUINO_ZERO_PRO: > description: 'TBD' > value: 0 > restrictions: > - "!BSP_ARDUINO_ZERO" > > Then, in hw/bsp/arduino_zero/include/bsp/bsp.h, pins are mapped as > follows: > > #if MYNEWT_VAL(BSP_ARDUINO_ZERO_PRO) > ARDUINO_ZERO_D2 = (8), > ARDUINO_ZERO_D4 = (14), > #endif > > #if MYNEWT_VAL(BSP_ARDUINO_ZERO) > ARDUINO_ZERO_D2 = (14), > ARDUINO_ZERO_D4 = (8), > #endif > > It is up to the target package to define one (and only one) of > BSP_ARDUINO_ZERO_PRO or BSP_ARDUINO_ZERO. > > This approach is nice because it eliminates the need for a lot of > duplicate code in a second BSP package. One hassle involved is the > necessity to define the appropriate syscfg setting in the target > package. > > Chris -- Ugo Mastracchio, mastr...@fastmail.co.uk Telefono: +39 03631806106[https://www.fastmail.fm/mail/Inbox/090d6d955e843818-f9048467u8138?u=53b641b7#] Cellulare: +39 3484116043[https://www.fastmail.fm/mail/Inbox/090d6d955e843818-f9048467u8138?u=53b641b7#]