New ML support - multiple languages in internal flash (MK25/MK2)

This commit is contained in:
Robert Pelnar 2018-06-23 01:31:38 +02:00
parent 7f9c9c153a
commit febca066f2
3 changed files with 10 additions and 10 deletions

View File

@ -29,7 +29,7 @@
//LANG - Multi-language support
//#define LANG_MODE 0 // primary language only
#define LANG_MODE 1 // sec. language support
#define LANG_SIZE_RESERVED 0x2400 // reserved space for secondary language (~10kb)
#define LANG_SIZE_RESERVED 0x2400 // reserved space for secondary language (~12kb)
//#define LANG_SIZE_RESERVED 0x1ef8 // reserved space for secondary language (~10kb)

View File

@ -153,7 +153,6 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off
if (--lang == 0) return 1;
addr += header->size; //calc address of next table
}
return 0;
#else //W25X20CL
if (lang == LANG_ID_SEC)
{
@ -163,6 +162,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
}
#endif //W25X20CL
return 0;
}
uint16_t lang_get_code(uint8_t lang)
@ -187,11 +187,13 @@ uint16_t lang_get_code(uint8_t lang)
addr += header.size; //calc address of next table
}
#else //W25X20CL
if (lang == LANG_ID_SEC)
uint16_t table = _SEC_LANG_TABLE;
uint8_t count = 1; //count = 1 (primary)
while (pgm_read_dword((uint32_t*)table) == LANG_MAGIC) //magic valid
{
uint16_t ui = _SEC_LANG_TABLE; //table pointer
if (pgm_read_dword(((uint32_t*)(ui + 0))) == LANG_MAGIC) //magic num is OK
return pgm_read_word(((uint16_t*)(ui + 10))); //read language code
if (count == lang) return pgm_read_word(((uint16_t*)(table + 10))); //read language code
table += pgm_read_word((uint16_t*)(table + 4));
count++;
}
#endif //W25X20CL
return LANG_CODE_XX;

View File

@ -2,8 +2,6 @@
#ifndef LANGUAGE_H
#define LANGUAGE_H
//#define W25X20CL
#include "config.h"
#include <inttypes.h>