Skip to content

Commit

Permalink
fix ch32v30x board_flash_write()
Browse files Browse the repository at this point in the history
  • Loading branch information
YCF committed Jul 23, 2024
1 parent 70ebfdc commit 316e21a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ports/WCH/ch32v30x/board_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,15 @@ __attribute__((weak)) void board_flash_flush(void) {}

__attribute__((weak)) void board_flash_write(uint32_t addr, void const *data, uint32_t len) {
uint32_t flash_addr = FLASH_BASE_ADDR + addr;
FLASH_Unlock();
flash_write(flash_addr, data, len);
FLASH_Lock();
if (len == 256) {
FLASH_Unlock_Fast();
FLASH_ProgramPage_Fast(flash_addr, data);
FLASH_Lock_Fast();
} else {
FLASH_Unlock();
flash_write(flash_addr, data, len);
FLASH_Lock();
}
}

__attribute__((weak)) void board_flash_erase_app(void) {}

0 comments on commit 316e21a

Please sign in to comment.