-
Notifications
You must be signed in to change notification settings - Fork 2.1k
stm32_common/flashpage: cleanup #11715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1087589
eb78d35
5e709ed
46b9013
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,6 @@ | |
| #define CNTRL_REG (FLASH->PECR) | ||
| #define CNTRL_REG_LOCK (FLASH_PECR_PELOCK) | ||
| #define FLASH_CR_PER (FLASH_PECR_ERASE | FLASH_PECR_PROG) | ||
| #define FLASH_CR_PG (FLASH_PECR_FPRG | FLASH_PECR_PROG) | ||
| #define FLASHPAGE_DIV (4U) /* write 4 bytes in one go */ | ||
| #else | ||
| #if defined(CPU_FAM_STM32L4) | ||
|
|
@@ -77,7 +76,8 @@ static void _erase_page(void *page_addr) | |
| uint32_t *dst = page_addr; | ||
| #else | ||
| uint16_t *dst = page_addr; | ||
|
|
||
| #endif | ||
| #if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) | ||
| uint32_t hsi_state = (RCC->CR & RCC_CR_HSION); | ||
| /* the internal RC oscillator (HSI) must be enabled */ | ||
| stmclk_enable_hsi(); | ||
|
|
@@ -98,7 +98,6 @@ static void _erase_page(void *page_addr) | |
| *dst = (uint32_t)0; | ||
| #elif defined(CPU_FAM_STM32L4) | ||
| DEBUG("[flashpage] erase: setting the page address\n"); | ||
| CNTRL_REG |= FLASH_CR_PER; | ||
| uint8_t pn; | ||
| #if FLASHPAGE_NUMOF <= 256 | ||
| pn = (uint8_t)flashpage_page(dst); | ||
|
|
@@ -131,8 +130,7 @@ static void _erase_page(void *page_addr) | |
| /* lock the flash module again */ | ||
| _lock(); | ||
|
|
||
| #if !(defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1) || \ | ||
| defined(CPU_FAM_STM32L4)) | ||
| #if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) | ||
| /* restore the HSI state */ | ||
| if (!hsi_state) { | ||
| stmclk_disable_hsi(); | ||
|
|
@@ -163,7 +161,9 @@ void flashpage_write_raw(void *target_addr, const void *data, size_t len) | |
| #else | ||
| uint16_t *dst = (uint16_t *)target_addr; | ||
| 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); | ||
| /* the internal RC oscillator (HSI) must be enabled */ | ||
| stmclk_enable_hsi(); | ||
|
|
@@ -173,7 +173,8 @@ void flashpage_write_raw(void *target_addr, const void *data, size_t len) | |
| _unlock_flash(); | ||
|
|
||
| DEBUG("[flashpage_raw] write: now writing the data\n"); | ||
| #if !(defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)) | ||
| #if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) || \ | ||
| defined(CPU_FAM_STM32L4) | ||
| /* set PG bit and program page to flash */ | ||
| CNTRL_REG |= FLASH_CR_PG; | ||
| #endif | ||
|
|
@@ -185,14 +186,16 @@ void flashpage_write_raw(void *target_addr, const void *data, size_t len) | |
| } | ||
|
|
||
| /* clear program bit again */ | ||
| #if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) || \ | ||
| defined(CPU_FAM_STM32L4) | ||
| CNTRL_REG &= ~(FLASH_CR_PG); | ||
| #endif | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The DEBUG message above is now only displayed with F0/F1/L4 but not for L0/L1. It should be put after.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right about the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, let's keep the changes in the same commit then. You still have to fix the commit message: it's full of typos :)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The DEBUG line must still move out of the define (preferably after).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. damn, I was concentrating on the typos sorry
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I think now it should be ok .. sorry for missing this. |
||
| DEBUG("[flashpage_raw] write: done writing data\n"); | ||
|
|
||
| /* lock the flash module again */ | ||
| _lock(); | ||
|
|
||
| #if !(defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1) || \ | ||
| defined(CPU_FAM_STM32L4)) | ||
| #if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) | ||
| /* restore the HSI state */ | ||
| if (!hsi_state) { | ||
| stmclk_disable_hsi(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change should be in it's own commit and not in b72a6ed where it's unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? Only
STM32F0 STM32F1need to initialize HSI clock (at least for the implemented boards). My goal was to separate it from the default case which only said/* Default is to support half-word sizes */, But I guess you are right, the commit message is not explicit enough. Would you be Ok with just re-wording?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this changes the initial behaviour as you say, so it needs to be in its own commit.