|
@@ -33,6 +33,7 @@
|
|
|
#include "Int_mpu.h"
|
|
#include "Int_mpu.h"
|
|
|
#include "Int_lcd.h"
|
|
#include "Int_lcd.h"
|
|
|
#include "Int_flash.h"
|
|
#include "Int_flash.h"
|
|
|
|
|
+#include "Int_eeprom.h"
|
|
|
/* USER CODE END Includes */
|
|
/* USER CODE END Includes */
|
|
|
|
|
|
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
/* Private typedef -----------------------------------------------------------*/
|
|
@@ -61,6 +62,7 @@ void SystemClock_Config(void);
|
|
|
static void MPU_Config(void);
|
|
static void MPU_Config(void);
|
|
|
/* USER CODE BEGIN PFP */
|
|
/* USER CODE BEGIN PFP */
|
|
|
void Int_flash_test(void);
|
|
void Int_flash_test(void);
|
|
|
|
|
+void Int_eeprom_test(void);
|
|
|
/* USER CODE END PFP */
|
|
/* USER CODE END PFP */
|
|
|
|
|
|
|
|
/* Private user code ---------------------------------------------------------*/
|
|
/* Private user code ---------------------------------------------------------*/
|
|
@@ -222,6 +224,101 @@ void Int_flash_test(void)
|
|
|
|
|
|
|
|
printf("======== QSPI FLASH TEST DONE ========\r\n\r\n");
|
|
printf("======== QSPI FLASH TEST DONE ========\r\n\r\n");
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+void Int_eeprom_test(void)
|
|
|
|
|
+{
|
|
|
|
|
+ uint8_t wbuf[64];
|
|
|
|
|
+ uint8_t rbuf[64];
|
|
|
|
|
+ uint16_t i;
|
|
|
|
|
+ uint8_t pass;
|
|
|
|
|
+
|
|
|
|
|
+ printf("\r\n======== EEPROM TEST (BL24C16F) ========\r\n");
|
|
|
|
|
+
|
|
|
|
|
+ /* 1. 初始化并检测芯片应答 */
|
|
|
|
|
+ if (Int_eeprom_init() != 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ printf("[FAIL] Int_eeprom_init\r\n");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ printf("EEPROM present (I2C2 @ 0x%02X)\r\n", INT_EEPROM_ADDR);
|
|
|
|
|
+
|
|
|
|
|
+ /* 2. 单字节写入+回读:地址 0x000 */
|
|
|
|
|
+ wbuf[0] = 0xAA;
|
|
|
|
|
+ Int_eeprom_write(wbuf, 0x000, 1);
|
|
|
|
|
+ Int_eeprom_read(rbuf, 0x000, 1);
|
|
|
|
|
+ printf("Byte write/read (addr 0x000): %s\r\n",
|
|
|
|
|
+ (rbuf[0] == 0xAA) ? "PASS" : "FAIL");
|
|
|
|
|
+
|
|
|
|
|
+ /* 3. 页写入+回读:地址 0x010(页对齐,16 字节) */
|
|
|
|
|
+ for (i = 0; i < 16; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ wbuf[i] = (uint8_t)i;
|
|
|
|
|
+ }
|
|
|
|
|
+ Int_eeprom_write(wbuf, 0x010, 16);
|
|
|
|
|
+ Int_eeprom_read(rbuf, 0x010, 16);
|
|
|
|
|
+ pass = 1;
|
|
|
|
|
+ for (i = 0; i < 16; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (rbuf[i] != wbuf[i])
|
|
|
|
|
+ {
|
|
|
|
|
+ pass = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ printf("Page write/read (page1): %s\r\n", pass ? "PASS" : "FAIL");
|
|
|
|
|
+
|
|
|
|
|
+ /* 4. 跨页写入+回读:地址 0x00C 写 32 字节(跨页 0/1/2) */
|
|
|
|
|
+ for (i = 0; i < 32; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ wbuf[i] = (uint8_t)(0x50 + i);
|
|
|
|
|
+ }
|
|
|
|
|
+ Int_eeprom_write(wbuf, 0x00C, 32);
|
|
|
|
|
+ Int_eeprom_read(rbuf, 0x00C, 32);
|
|
|
|
|
+ pass = 1;
|
|
|
|
|
+ for (i = 0; i < 32; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (rbuf[i] != wbuf[i])
|
|
|
|
|
+ {
|
|
|
|
|
+ pass = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ printf("Cross-page write/read: %s\r\n", pass ? "PASS" : "FAIL");
|
|
|
|
|
+
|
|
|
|
|
+ /* 5. 全片擦除后回读验证全 0xFF */
|
|
|
|
|
+ Int_eeprom_erase_chip();
|
|
|
|
|
+ Int_eeprom_read(rbuf, 0x000, 16);
|
|
|
|
|
+ pass = 1;
|
|
|
|
|
+ for (i = 0; i < 16; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (rbuf[i] != 0xFF)
|
|
|
|
|
+ {
|
|
|
|
|
+ pass = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ printf("Chip erase verify: %s\r\n", pass ? "PASS" : "FAIL");
|
|
|
|
|
+
|
|
|
|
|
+ /* 6. 最后一页边界:地址 0x7F0 写 16 字节 */
|
|
|
|
|
+ for (i = 0; i < 16; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ wbuf[i] = (uint8_t)(0xC0 + i);
|
|
|
|
|
+ }
|
|
|
|
|
+ Int_eeprom_write(wbuf, 0x7F0, 16);
|
|
|
|
|
+ Int_eeprom_read(rbuf, 0x7F0, 16);
|
|
|
|
|
+ pass = 1;
|
|
|
|
|
+ for (i = 0; i < 16; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (rbuf[i] != wbuf[i])
|
|
|
|
|
+ {
|
|
|
|
|
+ pass = 0;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ printf("Last page write/read (addr 0x7F0): %s\r\n", pass ? "PASS" : "FAIL");
|
|
|
|
|
+
|
|
|
|
|
+ printf("======== EEPROM TEST DONE ========\r\n\r\n");
|
|
|
|
|
+}
|
|
|
/* USER CODE END 0 */
|
|
/* USER CODE END 0 */
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -273,9 +370,10 @@ int main(void)
|
|
|
printf("hello h743\r\n");
|
|
printf("hello h743\r\n");
|
|
|
Int_sdram_init();
|
|
Int_sdram_init();
|
|
|
Int_sdram_test();
|
|
Int_sdram_test();
|
|
|
- Int_flash_test();
|
|
|
|
|
|
|
+ // Int_flash_test();
|
|
|
|
|
+ Int_eeprom_test();
|
|
|
Int_lcd_init();
|
|
Int_lcd_init();
|
|
|
- Int_lcd_clear(LCD_COLOR_RED);
|
|
|
|
|
|
|
+ Int_lcd_clear(LCD_COLOR_WHITE);
|
|
|
printf("System Init OK\r\n");
|
|
printf("System Init OK\r\n");
|
|
|
/* USER CODE END 2 */
|
|
/* USER CODE END 2 */
|
|
|
|
|
|
|
@@ -286,11 +384,7 @@ int main(void)
|
|
|
/* USER CODE END WHILE */
|
|
/* USER CODE END WHILE */
|
|
|
|
|
|
|
|
/* USER CODE BEGIN 3 */
|
|
/* USER CODE BEGIN 3 */
|
|
|
- Int_lcd_clear(LCD_COLOR_RED);
|
|
|
|
|
- HAL_Delay(1000);
|
|
|
|
|
- Int_lcd_clear(LCD_COLOR_GREEN);
|
|
|
|
|
- HAL_Delay(1000);
|
|
|
|
|
- Int_lcd_clear(LCD_COLOR_BLUE);
|
|
|
|
|
|
|
+ Int_lcd_clear(LCD_COLOR_WHITE);
|
|
|
HAL_Delay(1000);
|
|
HAL_Delay(1000);
|
|
|
}
|
|
}
|
|
|
/* USER CODE END 3 */
|
|
/* USER CODE END 3 */
|