Преглед изворни кода

change: 调整sfud适配的flash_table变量为sfud_flash_tables

Wendal Chen пре 2 година
родитељ
комит
c683b53eb3
2 измењених фајлова са 12 додато и 12 уклоњено
  1. 5 5
      components/sfud/luat_lib_sfud.c
  2. 7 7
      components/sfud/sfud.c

+ 5 - 5
components/sfud/luat_lib_sfud.c

@@ -15,7 +15,7 @@
 #include "luat_log.h"
 #include "sfud.h"
 
-extern sfud_flash flash_table[];
+extern sfud_flash sfud_flash_tables[];
 /*
 初始化sfud
 @api  sfud.init(spi_id, spi_cs, spi_bandrate)/sfud.init(spi_device)
@@ -34,7 +34,7 @@ static int luat_sfud_init(lua_State *L){
     static luat_spi_t sfud_spi_flash;
     static luat_spi_device_t* sfud_spi_device_flash = NULL;
     if (lua_type(L, 1) == LUA_TNUMBER){
-        flash_table[0].luat_sfud.luat_spi = LUAT_TYPE_SPI;
+        sfud_flash_tables[0].luat_sfud.luat_spi = LUAT_TYPE_SPI;
         sfud_spi_flash.id = luaL_checkinteger(L, 1);
         sfud_spi_flash.cs = luaL_checkinteger(L, 2);
         sfud_spi_flash.bandrate = luaL_checkinteger(L, 3);
@@ -45,11 +45,11 @@ static int luat_sfud_init(lua_State *L){
         sfud_spi_flash.master = 1; // master=1,slave=0
         sfud_spi_flash.mode = 0; // FULL=1, half=0
         luat_spi_setup(&sfud_spi_flash);
-        flash_table[0].luat_sfud.user_data = &sfud_spi_flash;
+        sfud_flash_tables[0].luat_sfud.user_data = &sfud_spi_flash;
     }else if (lua_type(L, 1) == LUA_TUSERDATA){
-        flash_table[0].luat_sfud.luat_spi = LUAT_TYPE_SPI_DEVICE;
+        sfud_flash_tables[0].luat_sfud.luat_spi = LUAT_TYPE_SPI_DEVICE;
         sfud_spi_device_flash = (luat_spi_device_t*)lua_touserdata(L, 1);
-        flash_table[0].luat_sfud.user_data = sfud_spi_device_flash;
+        sfud_flash_tables[0].luat_sfud.user_data = sfud_spi_device_flash;
     }
     
     int re = sfud_init();

+ 7 - 7
components/sfud/sfud.c

@@ -37,7 +37,7 @@
 #endif
 
 /* user configured flash device information table */
-sfud_flash flash_table[] = SFUD_FLASH_DEVICE_TABLE;
+sfud_flash sfud_flash_tables[] = SFUD_FLASH_DEVICE_TABLE;
 /* supported manufacturer information table */
 static const sfud_mf mf_table[] = SFUD_MF_TABLE;
 
@@ -116,10 +116,10 @@ sfud_err sfud_init(void) {
     SFUD_DEBUG("Start initialize Serial Flash Universal Driver(SFUD) V%s.", SFUD_SW_VERSION);
     SFUD_DEBUG("You can get the latest version on https://github.com/armink/SFUD .");
     /* initialize all flash device in flash device table */
-    for (i = 0; i < sizeof(flash_table) / sizeof(sfud_flash); i++) {
+    for (i = 0; i < sizeof(sfud_flash_tables) / sizeof(sfud_flash); i++) {
         /* initialize flash device index of flash device information table */
-        flash_table[i].index = i;
-        cur_flash_result = sfud_device_init(&flash_table[i]);
+        sfud_flash_tables[i].index = i;
+        cur_flash_result = sfud_device_init(&sfud_flash_tables[i]);
 
         if (cur_flash_result != SFUD_SUCCESS) {
             all_flash_result = cur_flash_result;
@@ -138,7 +138,7 @@ sfud_err sfud_init(void) {
  */
 sfud_flash *sfud_get_device(size_t index) {
     if (index < sfud_get_device_num()) {
-        return &flash_table[index];
+        return &sfud_flash_tables[index];
     } else {
         return NULL;
     }
@@ -150,7 +150,7 @@ sfud_flash *sfud_get_device(size_t index) {
  * @return flash device total number
  */
 size_t sfud_get_device_num(void) {
-    return sizeof(flash_table) / sizeof(sfud_flash);
+    return sizeof(sfud_flash_tables) / sizeof(sfud_flash);
 }
 
 /**
@@ -159,7 +159,7 @@ size_t sfud_get_device_num(void) {
  * @return flash device table pointer
  */
 const sfud_flash *sfud_get_device_table(void) {
-    return flash_table;
+    return sfud_flash_tables;
 }
 
 #ifdef SFUD_USING_QSPI