I find in the following example code that if I start my application from a powered-off to a powered-on condition and main() executes the code as shown, everything works fine...ONCE. If I were to reset the device, and start executing in main() again (without a power cycle) that the sd_mbr_command() function will essentially lock up. I have no idea what it's doing, I just never get execution back after making the call.
I also find that if I comment out the sm_mbr_command() call, I can now reset and run as many times as I like, and everything works just fine.
I also find that if I leave the sm_mbr_command() call commented out, and power-cycle the device (remove power, reattach power) that the sd_softdevice_is_enabled() call will fail and execution will end up at address 0xFFFFFFFE or some such nonsense.
What am I missing here? Is there a way to tell if the SD_MBR_COMMAND_INIT_SD needs to be called via the sd_mbr_command() function? I can't just call it every time, nor can I assume that it has been called prior to my main(). Is there a flag that gets set? A register I can read? Some other function call?
unsigned char e;
sd_mbr_command_t com = {SD_MBR_COMMAND_INIT_SD, };
Result = sd_mbr_command(&com);
Result = sd_softdevice_is_enabled(&e);