Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cpu/stm32_common/periph: don't lock if flash is already locked
  • Loading branch information
aabadie committed May 30, 2018
1 parent cb089a2 commit c73ec5c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cpu/stm32_common/periph/flash_common.c
Expand Up @@ -38,15 +38,17 @@

void _unlock(void)
{
DEBUG("[flash-common] unlocking the flash module\n");
if (CNTRL_REG & CNTRL_REG_LOCK) {
DEBUG("[flash-common] unlocking the flash module\n");
KEY_REG = FLASH_KEY1;
KEY_REG = FLASH_KEY2;
}
}

void _lock(void)
{
DEBUG("[flash-common] locking the flash module\n");
CNTRL_REG |= CNTRL_REG_LOCK;
if (!(CNTRL_REG & CNTRL_REG_LOCK)) {
DEBUG("[flash-common] locking the flash module\n");
CNTRL_REG |= CNTRL_REG_LOCK;
}
}

0 comments on commit c73ec5c

Please sign in to comment.