From 49d04be3405fafec5532fc93c1fe8575ec99b339 Mon Sep 17 00:00:00 2001 From: wu58430 Date: Sat, 13 Jan 2024 22:26:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=A4=E4=B8=AAAT24C1024?= =?UTF-8?q?=E5=A0=86=E5=8F=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/workspace.xml | 32 ++++++++++++++------------------ Makefile | 6 +++++- driver/eeprom.c | 23 ++++++++++++++++++----- main.c | 38 ++++++++++++++++++++++++++++++-------- 4 files changed, 67 insertions(+), 32 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 13f3903..57bf3f1 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -20,15 +20,11 @@ - + - - - - - + + - @@ -673,7 +669,6 @@ - @@ -698,7 +693,8 @@ - diff --git a/Makefile b/Makefile index d58b8c2..f450b1f 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ ENABLE_MDC1200_SIDE_BEEP ?= 0 ENABLE_MDC1200_CONTACT ?= 1 ENABLE_UART_RW_BK_REGS ?= 0 ENABLE_AUDIO_BAR_DEFAULT ?= 0 -ENABLE_EEPROM_4M ?= 1 +ENABLE_EEPROM_TYPE = 2 #0:1*1Mib 1:2*2Mib 2:2*1Mib ENABLE_CHINESE_FULL = 4 ENABLE_DOCK ?= 1 ENABLE_CUSTOM_SIDEFUNCTIONS ?= 1 @@ -83,6 +83,7 @@ ifeq ($(ENABLE_CHINESE_FULL),4) endif ifeq ($(ENABLE_CHINESE_FULL),0) + ENABLE_EEPROM_TYPE=0 $(info Normal) endif @@ -289,6 +290,9 @@ CFLAGS += -Wextra #CFLAGS += -Wpedantic # 设置PACKED_FILE_SUFFIX,根据ENABLE_CHINESE_FULL的值设置不同的后缀 + +CFLAGS += -DENABLE_EEPROM_TYPE=$(ENABLE_EEPROM_TYPE) + CFLAGS += -DENABLE_CHINESE_FULL=$(ENABLE_CHINESE_FULL) CFLAGS += -DPACKED_FILE_SUFFIX=\"$(PACKED_FILE_SUFFIX)\" CFLAGS += -DPRINTF_INCLUDE_CONFIG_H diff --git a/driver/eeprom.c b/driver/eeprom.c index 3b16c82..2b68967 100644 --- a/driver/eeprom.c +++ b/driver/eeprom.c @@ -28,12 +28,17 @@ void EEPROM_ReadBuffer(uint32_t Address, void *pBuffer, uint8_t Size) { I2C_Start(); uint8_t IIC_ADD = 0xA0 | ((Address / 0x10000) << 1); -#ifdef ENABLE_EEPROM_4M +#if ENABLE_EEPROM_TYPE==1 + if (Address >= 0x40000) + {IIC_ADD = 0xA8 | (((Address - 0x40000) / 0x10000) << 1); +Address-=0x40000; + + } +#elif ENABLE_EEPROM_4M==2 if (Address >= 0x20000) {IIC_ADD = 0xA8 | (((Address - 0x20000) / 0x10000) << 1); Address-=0x20000; - } #endif I2C_Write(IIC_ADD); @@ -54,17 +59,25 @@ void EEPROM_WriteBuffer(uint32_t Address, const void *pBuffer, uint8_t WRITE_SIZ if (pBuffer == NULL) return; uint8_t buffer[128]; + uint32_t offset=0; EEPROM_ReadBuffer(Address, buffer, WRITE_SIZE); if (memcmp(pBuffer, buffer, WRITE_SIZE) != 0) { uint8_t IIC_ADD=0xA0 | ((Address / 0x10000) << 1); I2C_Start(); -#ifdef ENABLE_EEPROM_4M +#if ENABLE_EEPROM_TYPE==1 + if(Address>=0x40000) + IIC_ADD = 0xA8 | (((Address - 0x40000) / 0x10000) << 1); + offset=0x40000; +#elif ENABLE_EEPROM_TYPE==2 if(Address>=0x20000) IIC_ADD = 0xA8 | (((Address - 0x20000) / 0x10000) << 1); + offset=0x20000; + #endif I2C_Write(IIC_ADD); - I2C_Write(((Address>=0x20000?Address:Address-0x20000) >> 8) & 0xFF); - I2C_Write(((Address>=0x20000?Address:Address-0x20000) >> 0) & 0xFF); + + I2C_Write(((Address>=offset?Address:Address-offset) >> 8) & 0xFF); + I2C_Write(((Address>=offset?Address:Address-offset) >> 0) & 0xFF); I2C_WriteBuffer(pBuffer, WRITE_SIZE); I2C_Stop(); } diff --git a/main.c b/main.c index 316c8f8..b072c01 100644 --- a/main.c +++ b/main.c @@ -339,29 +339,51 @@ void Main(void) { // // //} - - UI_DisplayWelcome(); - +// memset(gStatusLine, 0, sizeof(gStatusLine)); +// UI_DisplayClear(); // while(1) // { // char A[128]; char B[128]; // // memset(A,'A',sizeof (A));//0x20000 128K 0X40000 256K -// EEPROM_WriteBuffer(0x50000, A, 128); -// EEPROM_ReadBuffer(0x50000, B, 128) ; +// uint32_t ADD; +// +//#if ENABLE_EEPROM_TYPE==1 +// ADD=0x50000; +//#elif ENABLE_EEPROM_TYPE==2 +// ADD=0x30000; +//#endif +// EEPROM_WriteBuffer(ADD, A, 128); +// EEPROM_ReadBuffer(ADD, B, 128) ; // if (memcmp(A,B,128)==0) // { -// UI_PrintStringSmall("Double 2Mb Eeprom\nInstall OK!", 0, 127, 2); +//#if ENABLE_EEPROM_TYPE==1 +// UI_PrintStringSmall("Double 2Mb Eeprom", 0, 127, 2); +// UI_PrintStringSmall("Install OK!", 0, 127, 3); +// +//#elif ENABLE_EEPROM_TYPE==2 +// UI_PrintStringSmall("Double 1Mb Eeprom", 0, 127, 2); +// UI_PrintStringSmall("Install OK!", 0, 127, 3); +//#endif // ST7565_BlitStatusLine(); // blank status line // ST7565_BlitFullScreen(); // } else // { -// UI_PrintStringSmall("Double 2Mb Eeprom\nInstall Failed!", 0, 127, 2); +//#if ENABLE_EEPROM_TYPE==1 +// UI_PrintStringSmall("Double 2Mb Eeprom", 0, 127, 2); +// UI_PrintStringSmall("Install Failed!", 0, 127, 3); +// +//#elif ENABLE_EEPROM_TYPE==2 +// UI_PrintStringSmall("Double 1Mb Eeprom", 0, 127, 2); +// UI_PrintStringSmall("Install Failed!", 0, 127, 3); +//#endif // ST7565_BlitStatusLine(); // blank status line // ST7565_BlitFullScreen(); // } // -// } +// } + UI_DisplayWelcome(); + boot_counter_10ms = 250;