mirror of
https://github.com/eddyem/stm32samples.git
synced 2026-08-13 11:39:31 +03:00
add flash storage
This commit is contained in:
@@ -81,7 +81,7 @@ static int binarySearch(int r, const uint8_t *start, int stor_size){
|
||||
*/
|
||||
void flashstorage_init(){
|
||||
if(FLASH_SIZE > 0 && FLASH_SIZE < 20000){
|
||||
uint32_t flsz = FLASH_SIZE * blocksize; // size in bytes
|
||||
uint32_t flsz = FLASH_SIZE * 1024; // size in bytes
|
||||
flsz -= (uint32_t)(&__varsstart) - FLASH_BASE;
|
||||
maxCnum = flsz / sizeof(user_conf);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ static int erase_flash(const void *start, const void *end){
|
||||
if(!start) return 1;
|
||||
uint32_t startb = (((uint32_t)start - FLASH_BASE) + blocksize - 1) / blocksize, endb;
|
||||
if(!end){ // erase all remaining
|
||||
endb = FLASH_SIZE / blocksize;
|
||||
endb = FLASH_SIZE * 1024 / blocksize;
|
||||
}else{ // erase a part
|
||||
endb = (((uint32_t)end - FLASH_BASE) + blocksize - 1) / blocksize;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user