Yuqiang Wang e1498cabc9 SDK build (#47) 5 месяцев назад
..
.settings 4795f3d206 更新fsp为2.2.0 6 месяцев назад
board 4795f3d206 更新fsp为2.2.0 6 месяцев назад
figures 539cd344e1 增加示例的FSP配置描述 1 год назад
packages 4795f3d206 更新fsp为2.2.0 6 месяцев назад
rzn 0e9a0dfdbd fix iar link source 6 месяцев назад
rzn_cfg 0e9a0dfdbd fix iar link source 6 месяцев назад
rzn_gen 0e9a0dfdbd fix iar link source 6 месяцев назад
script 4795f3d206 更新fsp为2.2.0 6 месяцев назад
src e9ee0a7ce5 add filesystem project and public v1.2.1 8 месяцев назад
.api_xml ec58fed6ce fix i2c project ci problem 1 год назад
.config 4795f3d206 更新fsp为2.2.0 6 месяцев назад
.cproject 4795f3d206 更新fsp为2.2.0 6 месяцев назад
.gitignore 43669c1c97 Fixed some known issues 1 год назад
.project ec58fed6ce fix i2c project ci problem 1 год назад
.secure_azone ec58fed6ce fix i2c project ci problem 1 год назад
.secure_rzone 4795f3d206 更新fsp为2.2.0 6 месяцев назад
.secure_xml 4795f3d206 更新fsp为2.2.0 6 месяцев назад
Kconfig 4795f3d206 更新fsp为2.2.0 6 месяцев назад
README.md e1498cabc9 SDK build (#47) 5 месяцев назад
README_zh.md e1498cabc9 SDK build (#47) 5 месяцев назад
SConscript 0e9a0dfdbd fix iar link source 6 месяцев назад
SConstruct ec58fed6ce fix i2c project ci problem 1 год назад
buildinfo.ipcf 0e9a0dfdbd fix iar link source 6 месяцев назад
buildinfo.json 4795f3d206 更新fsp为2.2.0 6 месяцев назад
configuration.xml 4795f3d206 更新fsp为2.2.0 6 месяцев назад
envsetup.sh ec58fed6ce fix i2c project ci problem 1 год назад
mklinks.bat ec58fed6ce fix i2c project ci problem 1 год назад
mklinks.sh ec58fed6ce fix i2c project ci problem 1 год назад
ozone_scons.jdebug 384e7a31df 修复scons固件无法运行的问题,添加ozone调试脚本 1 год назад
project.ewd 0e9a0dfdbd fix iar link source 6 месяцев назад
project.ewp 0e9a0dfdbd fix iar link source 6 месяцев назад
project.ewt 0e9a0dfdbd fix iar link source 6 месяцев назад
project.eww ec58fed6ce fix i2c project ci problem 1 год назад
rtconfig.h 4795f3d206 更新fsp为2.2.0 6 месяцев назад
rtconfig.py 384e7a31df 修复scons固件无法运行的问题,添加ozone调试脚本 1 год назад
rzn_cfg.txt 4795f3d206 更新fsp为2.2.0 6 месяцев назад
template.ewd 0e9a0dfdbd fix iar link source 6 месяцев назад
template.ewp 0e9a0dfdbd fix iar link source 6 месяцев назад
template.eww ec58fed6ce fix i2c project ci problem 1 год назад

README.md

IIC EEPROM Driver Usage Instructions

English | 中文

Introduction

This example demonstrates how to use the RT-Thread I2C framework on the EtherKit to perform read and write operations on the onboard EEPROM.

Hardware Description

The EEPROM used on the EtherKit is an AT24C16, which is connected to the I2C0 of the R9A07G084M08GBG chip.

image-20241126101055884

FSP Configuration Instructions

Create a new stack and select r_iic_master. Then, configure the I2C0 settings as shown below:

image-20241126101119612image-20241204164236877

image-20241204164246566

RT-Thread Settings Configuration

Enable the RT-Thread I2C driver framework and the AT24C16 driver software package in the configuration.

image-20241126101213305

image-20241126101223969

Example Project Description

The example uses the AT24C16 driver package to perform read and write operations at EEPROM addresses 0x00 and 0x20.

#ifdef PKG_USING_AT24CXX
#include "at24cxx.h"
#define EEPROM_I2C_NAME "i2c0"
static at24cxx_device_t at24c02_dev;
static void eeprom_test(void)
{
    char str1[] = "test string-hello rtthread\n";
    char str2[] = "test string-rzt2m eeprom testcase\n";
    uint8_t read_buffer1[50];
    uint8_t read_buffer2[50];
    at24c02_dev = at24cxx_init(EEPROM_I2C_NAME, 0x0);
    if (at24c02_dev == RT_NULL)
    {
        rt_kprintf("eeprom init failed\n");
        return;
    }
    rt_memset(read_buffer1, 0x0, sizeof(read_buffer1));
    rt_memset(read_buffer2, 0x0, sizeof(read_buffer2));
    at24cxx_write(at24c02_dev, 0x0, (uint8_t *)str1, (sizeof(str1) - 1));
    rt_kprintf("write eeprom data to 0x0: %s\n", str1);
    rt_thread_mdelay(1000);
    at24cxx_read(at24c02_dev, 0x0, read_buffer1, (sizeof(str1) - 1));
    rt_kprintf("read eeprom data from 0x0: %s\n", read_buffer1);
    at24cxx_write(at24c02_dev, 0x20, (uint8_t *)str2, (sizeof(str2) - 1));
    rt_kprintf("write eeprom data to 0x20: %s\n", str2);
    rt_thread_mdelay(1000);
    at24cxx_read(at24c02_dev, 0x20, read_buffer2, (sizeof(str2) - 1));
    rt_kprintf("read eeprom data from 0x20: %s\n", read_buffer2);
    if (rt_strcmp((const char *)str1, (const char *)read_buffer1) != 0 && rt_strcmp((const char *)str2, (const char *)read_buffer2) != 0)
        rt_kprintf("eeprom test fail\n");
    else
        rt_kprintf("eeprom test success\n");
    at24cxx_deinit(at24c02_dev);
}
MSH_CMD_EXPORT(eeprom_test, eeprom test sample);
#endif

Compilation & Download

  • RT-Thread Studio: In RT-Thread Studio’s package manager, download the EtherKit resource package, create a new project, and compile it.
  • IAR: First, double-click mklinks.bat to create symbolic links between RT-Thread and the libraries folder. Then, use the Env tool to generate the IAR project. Finally, double-click project.eww to open the IAR project and compile it.

After compilation, connect the development board’s JLink interface to the PC and download the firmware to the development board.

Run Effect

To test the EEPROM, enter the eeprom_test command in the serial terminal:

image-20241126101319522