66#define FLASH_END_ADDR 0x01000000U // 16*1024*1024
77
88#define FLASH_PROGRAM_MIN_SIZE 256 // 256 bytes
9- //每次对falsh写入时 底层可以写入的最大字节数为 FALSH_PAGE_SIZE
10- #define FALSH_PAGE_SIZE FLASH_PROGRAM_MIN_SIZE // 256 bytes
9+ //每次对falsh写入时 底层可以写入的最大字节数为 FLASH_PAGE_SIZE
10+ #define FLASH_PAGE_SIZE FLASH_PROGRAM_MIN_SIZE // 256 bytes
1111
1212/**
1313 * @brief 需要实现以下函数
@@ -71,12 +71,12 @@ static uint32_t judge_whether_erase( uint8_t* sector_buf, uint16_t len )
7171static int write_sector ( long offset , const uint8_t * buf , size_t size )
7272{
7373 uint32_t addr = FLASH_START_ADDR + offset ;
74- uint32_t addr_up = FAL_ALIGN_UP ( addr , FALSH_PAGE_SIZE );
75- uint32_t addr_down = FAL_ALIGN_DOWN ( addr , FALSH_PAGE_SIZE );
74+ uint32_t addr_up = FAL_ALIGN_UP ( addr , FLASH_PAGE_SIZE );
75+ uint32_t addr_down = FAL_ALIGN_DOWN ( addr , FLASH_PAGE_SIZE );
7676
7777 uint32_t addr_end = addr + size ;
78- uint32_t addr_end_up = FAL_ALIGN_UP ( addr_end , FALSH_PAGE_SIZE );
79- uint32_t addr_end_down = FAL_ALIGN_DOWN ( addr_end , FALSH_PAGE_SIZE );
78+ uint32_t addr_end_up = FAL_ALIGN_UP ( addr_end , FLASH_PAGE_SIZE );
79+ uint32_t addr_end_down = FAL_ALIGN_DOWN ( addr_end , FLASH_PAGE_SIZE );
8080
8181 uint32_t cur_addr = addr_down ;
8282 uint32_t max_write_len = 0 ;
@@ -89,17 +89,17 @@ static int write_sector( long offset, const uint8_t* buf, size_t size )
8989 buf += write_len ;
9090 }
9191 else if ( cur_addr == addr_end_down ) {
92- max_write_len = FALSH_PAGE_SIZE ;
92+ max_write_len = FLASH_PAGE_SIZE ;
9393 write_len = addr_end - cur_addr ;
9494 write_len = write_len >= max_write_len ? max_write_len : write_len ;
9595 norflash_write_page ( buf , cur_addr , write_len );
9696 }
9797 else {
98- norflash_write_page ( buf , cur_addr , FALSH_PAGE_SIZE );
99- buf += FALSH_PAGE_SIZE ;
98+ norflash_write_page ( buf , cur_addr , FLASH_PAGE_SIZE );
99+ buf += FLASH_PAGE_SIZE ;
100100 }
101101
102- cur_addr += FALSH_PAGE_SIZE ;
102+ cur_addr += FLASH_PAGE_SIZE ;
103103 }
104104 return size ;
105105}
0 commit comments