This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

bootloader code & input interrupt

hello everybody,

I'm working in a project using the automated generic bootloader example, I want to do some edits so as I can have an input interrupt at any time, I mean for example: when pin 3 is raised to logic one then I can turn on a led ,that's it, I don't know how to edit the code to do the added tasks.

Note that these edits has no dependency on connection or advertising, I mean while advertising I can check the input & then do the function upon the check, while connection, it doesn't matter & for me to check the input signal at all.

can I do that??

here is the main function:

/**@brief Function for bootloader main entry.
   */
  int main(void)
  {
      uint32_t err_code;
       bool     dfu_start = false;
       bool     app_reset = (NRF_POWER->GPREGRET == BOOTLOADER_DFU_START);
if (app_reset)
{
    NRF_POWER->GPREGRET = 0;
}

	//leds_init();
// This check ensures that the defined fields in the bootloader corresponds with actual
// setting in the nRF51 chip.
APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
APP_ERROR_CHECK_BOOL(NRF_FICR->CODEPAGESIZE == CODE_PAGE_SIZE);

// Initialize.
timers_init();
//  buttons_init();

(void)bootloader_init();

if (bootloader_dfu_sd_in_progress())
{
    nrf_gpio_pin_clear(8);
			nrf_gpio_pin_clear(19);
			nrf_gpio_pin_clear(25);
    nrf_gpio_pin_clear(29);
    err_code = bootloader_dfu_sd_update_continue();
    APP_ERROR_CHECK(err_code);

    ble_stack_init(!app_reset);
    scheduler_init();

    err_code = bootloader_dfu_sd_update_finalize();
    APP_ERROR_CHECK(err_code);

			nrf_gpio_pin_set(8);
			nrf_gpio_pin_set(19);
			nrf_gpio_pin_set(25);
			nrf_gpio_pin_set(29);
  //nrf_gpio_pin_set(UPDATE_IN_PROGRESS_LED);

}
else
{
    // If stack is present then continue initialization of bootloader.
    ble_stack_init(!app_reset);
    scheduler_init();
}

dfu_start  = app_reset;
//  dfu_start |= ((nrf_gpio_pin_read(BOOTLOADER_BUTTON) == 0) ? true: false);

if (dfu_start || (!bootloader_app_is_valid(DFU_BANK_0_REGION_START)))
{
    nrf_gpio_pin_clear(8);
			nrf_gpio_pin_clear(19);
			nrf_gpio_pin_clear(25);
    nrf_gpio_pin_clear(29);


		
		
    // Initiate an update of the firmware.
    err_code = bootloader_dfu_start();
    APP_ERROR_CHECK(err_code);

			nrf_gpio_pin_set(8);
			nrf_gpio_pin_set(19);
			nrf_gpio_pin_set(25);
			nrf_gpio_pin_set(29);

}

if (bootloader_app_is_valid(DFU_BANK_0_REGION_START) && !bootloader_dfu_sd_in_progress())
{
    // Select a bank region to use as application region.
    // @note: Only applications running from DFU_BANK_0_REGION_START is supported.
    bootloader_app_start(DFU_BANK_0_REGION_START);
}
NVIC_SystemReset();
}

note that advertising functions , gap params are defined in dfu_ble_transport.c

Parents Reply Children
No Data
Related