Skip to content

Commit f33be23

Browse files
committed
use storage for testing
1 parent 214f65f commit f33be23

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

bsp/gd32/arm/gd32e230-lckfb/.config

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,10 @@ CONFIG_PKG_GD32_ARM_SERIES_DRIVER_VER="latest"
10021002
# CONFIG_PKG_USING_MULTI_INFRARED is not set
10031003
# CONFIG_PKG_USING_AGILE_BUTTON is not set
10041004
# CONFIG_PKG_USING_AGILE_LED is not set
1005-
# CONFIG_PKG_USING_AT24CXX is not set
1005+
CONFIG_PKG_USING_AT24CXX=y
1006+
CONFIG_PKG_AT24CXX_PATH="/packages/peripherals/at24cxx"
1007+
CONFIG_PKG_USING_AT24CXX_LATEST_VERSION=y
1008+
CONFIG_PKG_AT24CXX_VER="latest"
10061009
# CONFIG_PKG_USING_MOTIONDRIVER2RTT is not set
10071010
# CONFIG_PKG_USING_PCA9685 is not set
10081011
# CONFIG_PKG_USING_ILI9341 is not set

bsp/gd32/arm/gd32e230-lckfb/applications/main.c

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,47 @@
1111
#include <rtthread.h>
1212
#include <rtdevice.h>
1313
#include <board.h>
14+
#include "at24cxx.h"
1415

15-
#include "ssd1306.h"
16-
void ssd1306_TestCircle()
17-
{
18-
uint32_t delta;
1916

20-
for(delta = 0; delta < 5; delta ++)
21-
{
22-
ssd1306_DrawCircle(20* delta+30, 30, 10, White);
23-
}
24-
ssd1306_UpdateScreen();
25-
return;
26-
}
17+
#define POWER_PIN GET_PIN(B, 11)
18+
#define EEPROM_TEST_ADDR 10 // 要写入数据的EEPROM起始地址
2719

2820

2921
int main(void)
3022
{
31-
ssd1306_Init();
23+
rt_pin_mode(POWER_PIN, PIN_MODE_OUTPUT);
24+
25+
// Step 1: 启动时先拉低(确保断电)
26+
rt_pin_write(POWER_PIN, PIN_LOW);
27+
rt_thread_mdelay(100); // 稳定断电
28+
29+
// Step 2: 延时 1 秒
30+
rt_kprintf("AT24C64: Power off, waiting 1s...\n");
31+
rt_thread_mdelay(1000);
32+
33+
// Step 3: 上电
34+
rt_pin_write(POWER_PIN, PIN_HIGH);
35+
rt_kprintf("AT24C64: Power ON, wait for stable...\n");
36+
37+
// 建议再延时几 ms 等待芯片稳定
38+
rt_thread_mdelay(10);
3239

33-
ssd1306_TestCircle();
40+
at24cxx_device_t dev;
41+
42+
// 等待 I2C 总线就绪(可选:加点延时或检测设备)
43+
rt_thread_mdelay(10);
44+
45+
dev = at24cxx_init("i2c0", 0);
46+
47+
if (dev != RT_NULL)
48+
{
49+
rt_kprintf("AT24C64: Device initialized successfully.\n");
50+
51+
rt_err_t t = at24cxx_check(dev);
52+
53+
rt_kprintf("AT24C64: Check result: %s\n", (t == RT_EOK) ? "OK" : "Failed");
54+
}
3455

3556
return 0;
3657
}

bsp/gd32/arm/gd32e230-lckfb/rtconfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@
328328
/* touch drivers */
329329

330330
/* end of touch drivers */
331+
#define PKG_USING_AT24CXX
332+
#define PKG_USING_AT24CXX_LATEST_VERSION
331333
#define PKG_USING_SSD1306
332334
#define PKG_USING_SSD1306_DEBUG
333335
#define PKG_USING_SSD1306_I2C_ADDRESS 0x3C

0 commit comments

Comments
 (0)