Browse Source

Introduce "xflash_layout" to organize XFLASH's content

Update the language code to use the new LANG_OFFSET definition
and remove hard-coded flash sizes.
Yuri D'Elia 2 years ago
parent
commit
5ae8bad0ba
3 changed files with 14 additions and 4 deletions
  1. 2 1
      Firmware/Dcodes.cpp
  2. 4 3
      Firmware/language.c
  3. 8 0
      Firmware/xflash_layout.h

+ 2 - 1
Firmware/Dcodes.cpp

@@ -26,6 +26,7 @@ void print_hex_byte(uint8_t val)
 // debug range address type (fits all SRAM/PROGMEM/XFLASH memory ranges)
 #if defined(DEBUG_DCODE6) || defined(DEBUG_DCODES)
 #include "xflash.h"
+#include "xflash_layout.h"
 
 #define DADDR_SIZE 32
 typedef uint32_t daddr_t; // XFLASH requires 24 bits
@@ -427,7 +428,7 @@ void dcode_5()
     */
 void dcode_6()
 {
-    dcode_core(0x0, 0x40000, dcode_mem_t::xflash, 6, _N("XFLASH"));
+    dcode_core(0x0, XFLASH_SIZE, dcode_mem_t::xflash, 6, _N("XFLASH"));
 }
 #endif
 

+ 4 - 3
Firmware/language.c

@@ -9,6 +9,7 @@
 
 #ifdef XFLASH
 #include "xflash.h"
+#include "xflash_layout.h"
 #endif //XFLASH
 
 // Currently active language selection.
@@ -110,7 +111,7 @@ uint8_t lang_get_count()
 #ifdef XFLASH
 	XFLASH_SPI_ENTER();
 	uint8_t count = 2; //count = 1+n (primary + secondary + all in xflash)
-	uint32_t addr = 0x00000; //start of xflash
+	uint32_t addr = LANG_OFFSET;
 	lang_table_header_t header; //table header structure
 	while (1)
 	{
@@ -143,7 +144,7 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off
 		return (header->magic == LANG_MAGIC)?1:0; //return 1 if magic valid
 	}
 	XFLASH_SPI_ENTER();
-	uint32_t addr = 0x00000; //start of xflash
+	uint32_t addr = LANG_OFFSET;
 	lang--;
 	while (1)
 	{
@@ -176,7 +177,7 @@ uint16_t lang_get_code(uint8_t lang)
 		return pgm_read_word(((uint32_t*)(ui + 10))); //return lang code from progmem
 	}
 	XFLASH_SPI_ENTER();
-	uint32_t addr = 0x00000; //start of xflash
+	uint32_t addr = LANG_OFFSET;
 	lang_table_header_t header; //table header structure
 	lang--;
 	while (1)

+ 8 - 0
Firmware/xflash_layout.h

@@ -0,0 +1,8 @@
+// XFLASH memory layout
+#pragma once
+#include <stdint.h>
+#include "config.h"
+
+#define XFLASH_SIZE 0x40000ul // size of XFLASH
+#define LANG_OFFSET 0x0       // offset for language data
+#define LANG_SIZE   XFLASH_SIZE