This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GPIO checking in start-up code, before booting S110 soft device?

Hey guys,

I’m working on an nRF51822 design where I’d like to check the value of a GPIO at Power-ON, then either shutdown, OR start the BLE stack and do BLE stuff. I really don’t want to have to do a full boot-up, initialization and loading of the S110 each time we check the GPIO.

I think it can be done in the start-up code, before loading the soft device? Using gcc. Where exactly would I need to put this code? I’m looking at gcc_startup_nrf51.s, but what happens between that start-up code and main.c?

From an earlier post, I understand we jump to the soft device, before main(), but from where does that jump happen and can we make changes there to do this GPIO checking as I describe?

Many Thanks! Brian

  • No it can't be done in startup code before the softdevice. All that code, gcc_startup_nrf51.s, main, start .. all is executed after the softdevice startup code runs. The sequence is actually, bootloader, softdevice then you.

    However the bootloader startup (if there isn't a bootloader) and the softdevice startup don't really do very much at all, softdevice writes a couple of bytes of memory and then bounces to your startup code, it's not until you actually call the softdevice init function in your code that it really does any work, so you're not really saving much anyway.

    if you want the earliest possible hook then a bootloader would be the first code which gets called, write a custom one of those which checks your GPIO and shuts down, or has the usual exit to run through the softdevice init code and then on to your app. Or don't worry about it, it's of the order of a few hundred instructions before you get to your code in the normal case.

Related