Small improvements of using FLASH memory in STM32F1XX

This commit is contained in:
millerd 2013-04-22 17:37:47 +02:00 committed by Piotr Esden-Tempski
parent b2df978eae
commit 6313af8869
3 changed files with 8 additions and 2 deletions

View File

@ -103,6 +103,7 @@ void flash_clear_eop_flag(void);
void flash_clear_wrprterr_flag(void);
void flash_clear_bsy_flag(void);
void flash_clear_status_flags(void);
u32 flash_get_status_flags(void);
void flash_unlock_option_bytes(void);
void flash_erase_all_pages(void);
void flash_erase_page(u32 page_address);

View File

@ -25,6 +25,7 @@
/* --- STM32 specific peripheral definitions ------------------------------- */
/* Memory map for all busses */
#define FLASH_BASE ((u32)0x08000000)
#define PERIPH_BASE ((u32)0x40000000)
#define INFO_BASE ((u32)0x1ffff000)
#define PERIPH_BASE_APB1 (PERIPH_BASE + 0x00000)

View File

@ -93,6 +93,11 @@ void flash_clear_status_flags(void)
flash_clear_bsy_flag();
}
u32 flash_get_status_flags(void)
{
return (FLASH_SR &= (FLASH_SR_PGERR | FLASH_SR_EOP | FLASH_SR_WRPRTERR | FLASH_SR_BSY));
}
void flash_unlock_option_bytes(void)
{
/* F1 uses same keys for flash and option */
@ -102,8 +107,7 @@ void flash_unlock_option_bytes(void)
void flash_wait_for_last_operation(void)
{
while ((FLASH_SR & FLASH_SR_BSY) == FLASH_SR_BSY)
;
while ((FLASH_SR & FLASH_SR_BSY) == FLASH_SR_BSY);
}
void flash_program_word(u32 address, u32 data)