stm32_common/flashpage: use HSI only for stm32f0/1
- Before, HSI was enabled as the default case when it is only used for stm32f0 and stm32f1. It is now implemented explicitly for those platforms, and only those.
This commit is contained in:
parent
d5bdb5d9ea
commit
10875890e0
@ -77,7 +77,8 @@ static void _erase_page(void *page_addr)
|
|||||||
uint32_t *dst = page_addr;
|
uint32_t *dst = page_addr;
|
||||||
#else
|
#else
|
||||||
uint16_t *dst = page_addr;
|
uint16_t *dst = page_addr;
|
||||||
|
#endif
|
||||||
|
#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1)
|
||||||
uint32_t hsi_state = (RCC->CR & RCC_CR_HSION);
|
uint32_t hsi_state = (RCC->CR & RCC_CR_HSION);
|
||||||
/* the internal RC oscillator (HSI) must be enabled */
|
/* the internal RC oscillator (HSI) must be enabled */
|
||||||
stmclk_enable_hsi();
|
stmclk_enable_hsi();
|
||||||
@ -131,8 +132,7 @@ static void _erase_page(void *page_addr)
|
|||||||
/* lock the flash module again */
|
/* lock the flash module again */
|
||||||
_lock();
|
_lock();
|
||||||
|
|
||||||
#if !(defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1) || \
|
#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1)
|
||||||
defined(CPU_FAM_STM32L4))
|
|
||||||
/* restore the HSI state */
|
/* restore the HSI state */
|
||||||
if (!hsi_state) {
|
if (!hsi_state) {
|
||||||
stmclk_disable_hsi();
|
stmclk_disable_hsi();
|
||||||
@ -163,7 +163,9 @@ void flashpage_write_raw(void *target_addr, const void *data, size_t len)
|
|||||||
#else
|
#else
|
||||||
uint16_t *dst = (uint16_t *)target_addr;
|
uint16_t *dst = (uint16_t *)target_addr;
|
||||||
const uint16_t *data_addr = data;
|
const uint16_t *data_addr = data;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1)
|
||||||
uint32_t hsi_state = (RCC->CR & RCC_CR_HSION);
|
uint32_t hsi_state = (RCC->CR & RCC_CR_HSION);
|
||||||
/* the internal RC oscillator (HSI) must be enabled */
|
/* the internal RC oscillator (HSI) must be enabled */
|
||||||
stmclk_enable_hsi();
|
stmclk_enable_hsi();
|
||||||
@ -191,8 +193,7 @@ void flashpage_write_raw(void *target_addr, const void *data, size_t len)
|
|||||||
/* lock the flash module again */
|
/* lock the flash module again */
|
||||||
_lock();
|
_lock();
|
||||||
|
|
||||||
#if !(defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1) || \
|
#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1)
|
||||||
defined(CPU_FAM_STM32L4))
|
|
||||||
/* restore the HSI state */
|
/* restore the HSI state */
|
||||||
if (!hsi_state) {
|
if (!hsi_state) {
|
||||||
stmclk_disable_hsi();
|
stmclk_disable_hsi();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user