The function interrupts_disable() is defined in components/libraries/bootloader_dfu/dfu_app_handler.c and examples/dfu/experimental_ant_bootloader/bootloader.c like so:
/**@brief Function for disabling all interrupts before jumping from bootloader to application.
*/
static void interrupts_disable(void)
{
uint32_t interrupt_setting_mask;
uint32_t irq;
// Fetch the current interrupt settings.
interrupt_setting_mask = NVIC->ISER[0];
// Loop from interrupt 0 for disabling of all interrupts.
for (irq = 0; irq < MAX_NUMBER_INTERRUPTS; irq++)
{
if (interrupt_setting_mask & (IRQ_ENABLED << irq))
{
// The interrupt was enabled, hence disable it.
NVIC_DisableIRQ((IRQn_Type)irq);
}
}
}
Is there a reason that it is defined this way? It is convoluted and buggy for nRF52 (I2S_IRQn isn't cleared, for example). Instead of the simpler:
static void interrupts_disable(void)
{
NVIC->ICER[0] = 0xffffffff;
#ifdef NRF52
NVIC->ICER[1] = 0xffffffff;
#endif
}
I am looking for ways to save space in the bootloader.
edit: fixed bug from comments