瀏覽代碼

Merge remote-tracking branch 'origin/master' into develop

QMK Bot 3 年之前
父節點
當前提交
83bd56e68c
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      tmk_core/common/chibios/flash_stm32.c

+ 5 - 3
tmk_core/common/chibios/flash_stm32.c

@@ -161,9 +161,11 @@ FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data) {
  * @retval None
  */
 void FLASH_Unlock(void) {
-    /* Authorize the FPEC Access */
-    FLASH->KEYR = FLASH_KEY1;
-    FLASH->KEYR = FLASH_KEY2;
+    if (FLASH->CR & FLASH_CR_LOCK) {
+        /* Authorize the FPEC Access */
+        FLASH->KEYR = FLASH_KEY1;
+        FLASH->KEYR = FLASH_KEY2;
+    }
 }
 
 /**