**** WARNING **** This change may break your code!!!
Change flash_erase_sector (f2/f4) to take numerical sector argument. As opposed to using one of the defines in the header, this is more convenient when programatically deciding which sectors to erase.
This commit is contained in:
parent
b039504494
commit
410be2a39a
@ -138,7 +138,7 @@ void flash_clear_status_flags(void);
|
||||
void flash_unlock_option_bytes(void);
|
||||
void flash_lock_option_bytes(void);
|
||||
void flash_erase_all_sectors(u32 program_size);
|
||||
void flash_erase_sector(u32 sector, u32 program_size);
|
||||
void flash_erase_sector(u8 sector, u32 program_size);
|
||||
void flash_program_double_word(u32 address, u64 data);
|
||||
void flash_program_word(u32 address, u32 data);
|
||||
void flash_program_half_word(u32 address, u16 data);
|
||||
|
@ -218,19 +218,19 @@ void flash_program_byte(u32 address, u8 data)
|
||||
FLASH_CR &= ~FLASH_CR_PG; /* Disable the PG bit. */
|
||||
}
|
||||
|
||||
void flash_erase_sector(u32 sector, u32 program_size)
|
||||
void flash_erase_sector(u8 sector, u32 program_size)
|
||||
{
|
||||
flash_wait_for_last_operation();
|
||||
flash_set_program_size(program_size);
|
||||
|
||||
FLASH_CR &= ~(((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)) << 3);
|
||||
FLASH_CR |= sector;
|
||||
FLASH_CR &= ~(0xF << 3);
|
||||
FLASH_CR |= (sector << 3) & 0x78;
|
||||
FLASH_CR |= FLASH_CR_SER;
|
||||
FLASH_CR |= FLASH_CR_STRT;
|
||||
|
||||
flash_wait_for_last_operation();
|
||||
FLASH_CR &= ~FLASH_CR_SER;
|
||||
FLASH_CR &= ~(((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3)) << 3);
|
||||
FLASH_CR &= ~(0xF << 3);
|
||||
}
|
||||
|
||||
void flash_erase_all_sectors(u32 program_size)
|
||||
|
Loading…
x
Reference in New Issue
Block a user