ch32f1: Fixed the return type for ch32f1_flash_lock

This commit is contained in:
dragonmux 2022-07-30 10:02:41 +01:00 committed by Piotr Esden-Tempski
parent f548473f28
commit 7e7bc3789c
1 changed files with 5 additions and 5 deletions

View File

@ -146,17 +146,17 @@ static bool ch32f1_flash_unlock(target *t)
return false;
}
static int ch32f1_flash_lock(target *t)
static bool ch32f1_flash_lock(target *t)
{
DEBUG_INFO("CH32: flash lock \n");
SET_CR(FLASH_CR_LOCK);
uint32_t cr = target_mem_read32(t, FLASH_CR);
const uint32_t cr = target_mem_read32(t, FLASH_CR);
// FLASH_CR_FLOCK_CH32 bit does not exists on *regular* clones and defaults to '0' (see PM0075 for STM32F1xx)
if ((cr & FLASH_CR_FLOCK_CH32) == 0) {
if (!(cr & FLASH_CR_FLOCK_CH32)) {
DEBUG_WARN("Fast lock failed, cr: 0x%08" PRIx32 "\n", cr);
return -1;
return true;
}
return 0;
return false;
}
/**