Skip to content

Commit

Permalink
Add code to set the reset pin in the UICR if it's unprogrammed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-Paul committed Mar 22, 2019
1 parent 8a8170f commit 5664404
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion software/firmware/badge_840/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ int main(void)
* Enable memory management, usage and bus fault exceptions, so that
* we don't always end up diverting through the hard fault handler.
* Note: the memory management fault only applies if the MPU is
* enabled, which it currently is not.
* enabled, which it currently is (for stack guard pages).
*/

SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk |
Expand Down Expand Up @@ -363,6 +363,27 @@ int main(void)
printf (PORT_INFO "\r\n");
chThdSleep(2);

/* Check if the reset pin has been set, and update the UICR if not */

if (NRF_UICR->PSELRESET[0] != IOPORT1_RESET) {
printf ("Reset pin not configured, programming... ");
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Een;
NRF_NVMC->ERASEUICR = 1;
while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
;
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;

NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen;

NRF_UICR->PSELRESET[0] = IOPORT1_RESET;
NRF_UICR->PSELRESET[1] = IOPORT1_RESET;

while (NRF_NVMC->READY == NVMC_READY_READY_Busy)
;
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren;
printf ("Done.\r\n");
}

printf("Priority levels %d\r\n", CORTEX_PRIORITY_LEVELS);

/* Set up I/O pins */
Expand Down

0 comments on commit 5664404

Please sign in to comment.