Skip to content

Commit

Permalink
add:lf去掉ms函数
Browse files Browse the repository at this point in the history
  • Loading branch information
Dozingfiretruck committed May 15, 2024
1 parent 58979d4 commit 06541d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
4 changes: 1 addition & 3 deletions components/little_flash/inc/little_flash_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ struct little_flash{
/* unlock */
void (*unlock)(little_flash_t *lf);
/* wait 10us */
void (*wait_10us)(void);
/* wait ms */
void (*wait_ms)(uint32_t ms);
void (*wait_10us)(uint32_t count);
#ifdef LF_USE_HEAP
/* malloc */
void* (*malloc)(size_t size);
Expand Down
9 changes: 2 additions & 7 deletions components/little_flash/port/little_flash_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ static lf_err_t little_flash_spi_transfer(const little_flash_t *lf,uint8_t *tx_b
return result;
}

static void little_flash_wait_10us(void){
uint32_t delay = 12;
static void little_flash_wait_10us(uint32_t count){
uint32_t delay = 12*count;
while(delay--);
}

static void little_flash_wait_ms(uint32_t ms){
luat_rtos_task_sleep(ms);
}

#ifdef LF_USE_HEAP
static void* little_flash_malloc(size_t size){
return luat_heap_opt_malloc(LUAT_HEAP_SRAM,size);
Expand All @@ -46,7 +42,6 @@ static void little_flash_free(void* ptr){
lf_err_t little_flash_port_init(little_flash_t *lf){
lf->spi.transfer = little_flash_spi_transfer;
lf->wait_10us = little_flash_wait_10us;
lf->wait_ms = little_flash_wait_ms;
#ifdef LF_USE_HEAP
lf->malloc = little_flash_malloc;
lf->free = little_flash_free;
Expand Down
11 changes: 5 additions & 6 deletions components/little_flash/src/little_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static lf_err_t little_flash_wait_busy(const little_flash_t *lf) {
LF_ERROR("Error: Wait busy timeout.");
return LF_ERR_TIMEOUT;
}else{
lf->wait_10us();
lf->wait_10us(1);
}
}
return result;
Expand All @@ -73,7 +73,7 @@ static lf_err_t little_flash_reset(little_flash_t *lf){
result |= lf->spi.transfer(lf,(uint8_t[]){LF_CMD_NANDFLASH_RESET}, 1,LF_NULL,0);
}

lf->wait_ms(1);
lf->wait_10us(100);
result |= little_flash_wait_busy(lf);
if (result) return result;
if(lf->chip_info.type==LF_DRIVER_NOR_FLASH){
Expand Down Expand Up @@ -250,7 +250,6 @@ lf_err_t little_flash_device_init(little_flash_t *lf){
uint16_t device_id = 0;
little_flash_port_init(lf);
LF_ASSERT(lf->wait_10us);
LF_ASSERT(lf->wait_ms);
LF_ASSERT(lf->spi.transfer);
#ifdef LF_USE_HEAP
LF_ASSERT(lf->malloc);
Expand Down Expand Up @@ -352,7 +351,7 @@ lf_err_t little_flash_chip_erase(const little_flash_t *lf){
if(result) goto error;
if(lf->chip_info.type==LF_DRIVER_NOR_FLASH){
result |= lf->spi.transfer(lf,(uint8_t[]){LF_CMD_ERASE_CHIP}, 1,LF_NULL,0);
lf->wait_ms(40000);
lf->wait_10us(4000000);
result |= little_flash_cheak_erase(lf);
}else{
cmd_data[0] = lf->chip_info.erase_cmd;
Expand All @@ -363,7 +362,7 @@ lf_err_t little_flash_chip_erase(const little_flash_t *lf){
cmd_data[3] = page_addr;
result |= lf->spi.transfer(lf,cmd_data, 4,LF_NULL,0);
if(result) goto error;
lf->wait_ms(2);
lf->wait_10us(200);
result |= little_flash_cheak_erase(lf);
if(result) goto error;
addr += lf->chip_info.erase_size;
Expand Down Expand Up @@ -410,7 +409,7 @@ lf_err_t little_flash_erase(const little_flash_t *lf, uint32_t addr, uint32_t le
cmd_data[3] = page_addr;
result |= lf->spi.transfer(lf,cmd_data, 4,LF_NULL,0);
if(result) goto error;
lf->wait_ms(2);
lf->wait_10us(200);
result |= little_flash_cheak_erase(lf);
if(result) goto error;
addr += lf->chip_info.erase_size;
Expand Down

0 comments on commit 06541d0

Please sign in to comment.