diff --git a/include/libopencm3/stm32/common/flash_common_f234.h b/include/libopencm3/stm32/common/flash_common_f234.h index a012cf6e..19247c4e 100644 --- a/include/libopencm3/stm32/common/flash_common_f234.h +++ b/include/libopencm3/stm32/common/flash_common_f234.h @@ -50,6 +50,7 @@ /* --- FLASH_ACR values ---------------------------------------------------- */ +#define FLASH_ACR_LATENCY_MASK 0x07 #define FLASH_ACR_LATENCY_0WS 0x00 #define FLASH_ACR_LATENCY_1WS 0x01 #define FLASH_ACR_LATENCY_2WS 0x02 diff --git a/lib/stm32/common/flash_common_f234.c b/lib/stm32/common/flash_common_f234.c index 33ca226b..1977fbbe 100644 --- a/lib/stm32/common/flash_common_f234.c +++ b/lib/stm32/common/flash_common_f234.c @@ -41,7 +41,7 @@ void flash_set_ws(uint32_t ws) uint32_t reg32; reg32 = FLASH_ACR; - reg32 &= ~((1 << 0) | (1 << 1) | (1 << 2)); + reg32 &= ~(FLASH_ACR_LATENCY_MASK); reg32 |= ws; FLASH_ACR = reg32; }