1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 22:43:50 +01:00

cpu/stm32_common/periph: don't lock if flash is already locked

This commit is contained in:
Alexandre Abadie 2018-05-27 15:11:59 +02:00
parent cb089a2f74
commit c73ec5c00f

View File

@ -38,8 +38,8 @@
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;
}
@ -47,6 +47,8 @@ void _unlock(void)
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;
}
}