瀏覽代碼

update:sfdp参数长度做下兼容处理,不必占用那么大空间

Dozingfiretruck 5 月之前
父節點
當前提交
13de1d0319
共有 2 個文件被更改,包括 7 次插入5 次删除
  1. 4 2
      components/little_flash/inc/little_flash_define.h
  2. 3 3
      components/little_flash/src/little_flash.c

+ 4 - 2
components/little_flash/inc/little_flash_define.h

@@ -25,6 +25,10 @@ typedef struct little_flash little_flash_t;
 #define LF_INFO(...)  LF_PRINTF(__VA_ARGS__)
 #endif
 
+#ifndef LF_WARNING
+#define LF_WARNING(...)  LF_PRINTF(__VA_ARGS__)
+#endif
+
 #ifndef LF_ERROR
 #define LF_ERROR(...)  LF_PRINTF(__VA_ARGS__)
 #endif
@@ -216,8 +220,6 @@ typedef struct {
     uint32_t pt22;
     uint32_t pt23;
     // ...
-    uint32_t reserved[8];
-    // ...
 }little_flash_sfdp_pt_t;
 
 typedef struct {

+ 3 - 3
components/little_flash/src/little_flash.c

@@ -196,9 +196,9 @@ lf_err_t little_flash_sfdp_probe(little_flash_t *lf){
     }
     LF_DEBUG("Parameter Header is OK. The Parameter ID is 0x%04X, Revision is V%d.%d, Length is %d,Parameter Table Pointer is 0x%06lX.",
             sfdp.parameter_id, recv_data[1],recv_data[2],sfdp.parameter_length, sfdp.parameter_pointer);
-    if (sfdp.parameter_length * 4>sizeof(little_flash_sfdp_pt_t)){
-        LF_ERROR("Table Revision %d.%d is not supported", sfdp.parameter_major_rev, sfdp.parameter_minor_rev);
-        return LF_ERR_SFDP_PARAMETER;
+    if (sfdp.parameter_length * 4 > sizeof(little_flash_sfdp_pt_t)){
+        LF_WARNING("Table Revision %d.%d parameter_length is too long", sfdp.parameter_major_rev, sfdp.parameter_minor_rev);
+        sfdp.parameter_length = sizeof(little_flash_sfdp_pt_t) / 4;
     }
     uint8_t parameter_table[sfdp.parameter_length * 4];
     little_flash_sfdp_read(lf, sfdp.parameter_pointer, parameter_table, sfdp.parameter_length);