Skip to content

Commit

Permalink
update:little flash支持多设备
Browse files Browse the repository at this point in the history
  • Loading branch information
Dozingfiretruck committed May 11, 2024
1 parent f81f850 commit 37ed0b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 9 additions & 6 deletions components/little_flash/luat_lib_little_flash.c
Expand Up @@ -15,8 +15,6 @@
#include "luat_log.h"
#include "little_flash.h"

static little_flash_t lf_flash = {0};

/*
初始化 little_flash
@api lf.init(spi_device)
Expand All @@ -28,14 +26,19 @@ local spi_device = spi.deviceSetup(0,17,0,0,8,2000000,spi.MSB,1,0)
log.info("lf.init",lf.init(spi_device))
*/
static int luat_little_flash_init(lua_State *L){
static luat_spi_device_t* little_flash_spi_device = NULL;
luat_spi_device_t* little_flash_spi_device = NULL;
little_flash_t* lf_flash = NULL;
if (lua_type(L, 1) == LUA_TUSERDATA){
little_flash_spi_device = (luat_spi_device_t*)lua_touserdata(L, 1);
lf_flash.spi.user_data = little_flash_spi_device;
lf_flash = luat_heap_malloc(sizeof(little_flash_t));
lf_flash->spi.user_data = little_flash_spi_device;
}else{
LLOGW("little_flash init spi_device is nil");
return 0;
}
little_flash_init();
int re = little_flash_device_init(&lf_flash);
lua_pushlightuserdata(L, &lf_flash);
int re = little_flash_device_init(lf_flash);
lua_pushlightuserdata(L, lf_flash);
return 1;
}

Expand Down
2 changes: 0 additions & 2 deletions components/little_flash/src/little_flash.c
Expand Up @@ -141,8 +141,6 @@ lf_err_t little_flash_deinit(void){
return LF_ERR_OK;
}

// lf_err_t little_flash_get_info(const little_flash_t *lf, uint32_t *total_size, uint32_t *block_size, uint32_t *page_size, uint32_t *sector_size);

static lf_err_t little_flash_cheak_erase(const little_flash_t *lf){
lf_err_t result = LF_ERR_OK;
uint8_t status;
Expand Down

0 comments on commit 37ed0b7

Please sign in to comment.