diff --git a/.vscode/settings.json b/.vscode/settings.json
index fc03d11324a93d8263281f0e5bcc435bc5e60758..7bb271f62986006692f16b7c868c77b9b6ba9cc5 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -177,6 +177,11 @@
"sdmmc_cmd.h": "c",
"f_sdmmc_hw.h": "c",
"sdio_app.h": "c",
- "f_sdio_hw.h": "c"
+ "f_sdio_hw.h": "c",
+ "fi2c.h": "c",
+ "i2c_eeprom_example.h": "c",
+ "fi2c_hw.h": "c",
+ "fi2c_eeprom_example.h": "c",
+ "fi2c_slave_example.h": "c"
}
}
\ No newline at end of file
diff --git a/README.md b/README.md
index 7d0e6327dd4b6310ee93a8190556665a43389ad0..f19a714a25b8b8333225a00a62405f60831de919 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Phytium-Standalone-SDK
-**v0.1.7** [ReleaseNote](./doc/ChangeLog.md)
+**v0.1.8** [ReleaseNote](./doc/ChangeLog.md)
---
@@ -18,7 +18,7 @@
本项目的整体设计如下所示,自下而上可以分为平台层、组件层、框架层和应用层。
-
+
- 平台层(Platform)在整个软件框架中位于最底层,提供了基本数据结构类型定义、驱动参数标定、硬件平台耦合的寄存器自检、板级启动、CPU 内存虚拟等功能
@@ -88,9 +88,10 @@

-- 参考[Windows10 快速入门](./doc/install_windows.md), [Linux x86_64 快速入门](./doc/install_linux_x86_64.md)或[Linux arm aarch64 快速入门](./doc/install_linux_aarch64.md)搭建Phytium Standalone SDK的软件环境
+- 参考[Windows10 快速入门](./doc/reference/usr/install_windows.md), [Linux x86_64 快速入门](./doc/reference/usr/install_linux_x86_64.md)或[Linux arm aarch64 快速入门](./doc/reference/usr/install_linux_aarch64.md)搭建Phytium Standalone SDK的软件环境
+
+- 参考[使用说明](./doc/reference/usr/usage.md), 新建Phytium Standalone SDK的应用工程,与开发板建立连接
-- 参考[使用说明](./doc/usage.md), 新建Phytium Standalone SDK的应用工程,与开发板建立连接
---
@@ -138,7 +139,7 @@ D2000 是一款面向桌面应用的高性能通用 8 核处理器。每 2 个
| 10/100/1000MB-ETHERNET | FT2000/4
D2000 | E2000 | eth/f_gmac |
| CAN | FT2000/4 | E2000 | can/ft_can |
| GPIO | FT2000/4
E2000
D2000 | | gpio/f_gpio |
-| I2C | FT2000/4
D2000 | E2000 | i2c/dw_i2c |
+| I2C | FT2000/4
D2000 | E2000 | i2c/fi2c |
| IOMUX | FT2000/4
D2000 | | iomux/f_iomux |
| QSPI (Nor Flash) | FT2000/4
D2000 | E2000 | qspi/nor_qspi |
| SPI | FT2000/4
D2000 | E2000 | spi/f_spi |
@@ -161,7 +162,7 @@ D2000 是一款面向桌面应用的高性能通用 8 核处理器。每 2 个
## 4. API指南
-
+### 4.1 [I2C](./doc/reference/driver/i2c.md)
---
diff --git a/arch/armv8/aarch64/gcc/start.S b/arch/armv8/aarch64/gcc/start.S
index 63dae066bed0c5809963ac8cac9165f55d3dff7e..51106b5654456bc8b1ea7f527617ae61ff0c784f 100644
--- a/arch/armv8/aarch64/gcc/start.S
+++ b/arch/armv8/aarch64/gcc/start.S
@@ -88,7 +88,7 @@ data_loop:
sub w2, w2, #1
cbnz w2, 1b
-#ifdef CONFIG_USE_LIBC
+#ifdef CONFIG_USE_G_LIBC
// Set up _fini and fini_array to be called at exit
ldr x0, =__libc_fini_array
bl atexit
@@ -123,7 +123,7 @@ isb
#endif
-#ifdef CONFIG_USE_LIBC
+#ifdef CONFIG_USE_G_LIBC
// Set up the standard file handles
#endif
2:
diff --git a/baremetal/example/Makefile b/baremetal/example/Makefile
deleted file mode 100644
index 044a4b8dc324151c75a8b2eb012eda7a27bb0d10..0000000000000000000000000000000000000000
--- a/baremetal/example/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# Compiling all examples
-TOPTARGETS := all clean
-
-#SUBDIRS := $(wildcard */.)
-SUBDIRS := can_test \
- gdma_test \
- gmac_test \
- i2c_eeprom \
- letter_shell_test \
- lwip_test \
- pcie_test \
- qspi_nor_flash \
- spi_test
-
-
-$(TOPTARGETS): $(SUBDIRS)
- @for i in $(SUBDIRS); do \
- echo -e "\033[44;37;1m +++ Compiling $$i...\033[0m"; \
- $(MAKE) -C $$i $(MAKECMDGOALS) > /dev/null || exit $$?; \
- echo -e "\033[44;37;1m +++ Compiled OK $$i...\033[0m"; \
- done
-
-.PHONY: $(TOPTARGETS) $(SUBDIRS)
\ No newline at end of file
diff --git a/baremetal/example/template-mingw64/Kconfig b/baremetal/example/fi2c_eeprom/Kconfig
similarity index 100%
rename from baremetal/example/template-mingw64/Kconfig
rename to baremetal/example/fi2c_eeprom/Kconfig
diff --git a/baremetal/example/fi2c_eeprom/README.md b/baremetal/example/fi2c_eeprom/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..f0d5eb1ee7f49efaf45c0fb61d7a95ae47b71062
--- /dev/null
+++ b/baremetal/example/fi2c_eeprom/README.md
@@ -0,0 +1,113 @@
+
+# I2C EEPROM 读写测试
+
+## 1. 例程介绍
+
+>介绍例程的用途,使用场景,相关基本概念,描述用户可以使用例程完成哪些工作
+
+本例程实现了I2C主机读写板载EEPROM,主机侧是FT2000/4或D2000的I2C0,从机为一枚EEPROM,地址为0x57, 主机负责检测EEPROM,建立连接,发起读写请求,完成数据交互。
+
+## 2. 如何使用例程
+
+>描述开发平台准备,使用例程配置,构建和下载镜像的过程
+
+- 本example在FT2000/4上测试通过
+- 本example在D2000上测试通过
+您可以参考以下方法配置本例程所需要的硬件和软件环境,
+
+### 2.1 硬件配置方法
+
+#### 2.1.2 硬件需求
+本example需要一下硬件
+- D2000|FT2000/4 开发板, I2C0板载连接EEPROM在0x57位置
+
+
+
+- 不需要额外的管脚连线
+- 调试时可以用逻辑分析仪连接I2C0 的 SCL和SDA引脚,检测I2C信号
+
+
+>哪些硬件平台是支持的,需要哪些外设,例程与开发板哪些IO口相关等(建议附录开发板照片,展示哪些IO口被引出)
+
+### 2.2 SDK配置方法
+
+>依赖哪些驱动、库和第三方组件,如何完成配置(列出需要使能的关键配置项)
+
+- 使能I2C `CONFIG_USE_I2C`, 然后选择FI2C驱动 `CONFIG_USE_FI2C`
+
+
+
+- 使能IOMUX `CONFIG_USE_IOMUX`, 然后选择FIOMUX驱动 `CONFIG_ENABLE_FIOMUX`
+
+- 使能Letter Shell `CONFIG_USE_LETTER_SHELL`
+
+
+
+### 2.3 构建和下载
+
+>描述构建、烧录下载镜像的过程,列出相关的命令
+
+- 切换到目标平台,`make config_ft2004_aarch32`
+
+- 按照2.2 选择配置,`make menuconfig`
+
+- 完成编译构建,将编译出来的镜像复制到Tftp目录下,`make`
+
+- 在FT2000/4侧的u-boot命令行输入以下命令,下载镜像
+```
+setenv ipaddr 192.168.4.20
+setenv serverip 192.168.4.50
+setenv gatewayip 192.168.4.1
+tftpboot 0x90100000 baremetal.elf
+bootelf -p 0x90100000
+```
+
+### 2.4 输出与实验现象
+
+>描述输入输出情况,列出存在哪些输出,对应的输出是什么(建议附录相关现象图片)
+
+- 开发板加载镜像启动后,可以通过Letter Shell进行下列实验,
+
+### 检测eeprom
+
+- 从0x57位置检测到eeprom
+
+
+
+- 向eeprom写入一段数据,
+
+
+
+- 读取eeprom中刚刚写入的数据,
+
+
+
+## 3. 如何解决问题
+
+>主要记录使用例程中可能会遇到的问题,给出相应的解决方案
+
+Q: 读写eeprom时显示超时
+A:确认开发板是否在0x57位置存在EEPROM,可以通过`i2cdetect`等第三方工具进行检测,确认I2C从设备是否存在,从设备地址是多少,具体方法参考fi2c_slave例程
+
+Q:I2C引脚没有引出
+A:部分开发板的I2C可能复用做其它功能,不支持以上测试
+
+## 4. 修改历史记录
+
+>记录例程的重大修改记录,标明修改发生的版本号
+
+- 2021-10-28 :v0.1.8 添加example
+
+
diff --git a/baremetal/example/fi2c_eeprom/cmd_fi2c_eeprom.c b/baremetal/example/fi2c_eeprom/cmd_fi2c_eeprom.c
new file mode 100644
index 0000000000000000000000000000000000000000..b71ac7b4a352bff939a6f2bac4342d8fc19192e5
--- /dev/null
+++ b/baremetal/example/fi2c_eeprom/cmd_fi2c_eeprom.c
@@ -0,0 +1,99 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-22 14:32:44
+ * @LastEditTime: 2021-10-29 15:12:48
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+#include
+#include
+#include "strto.h"
+#include "parameters.h"
+#include "ft_types.h"
+#include "ft_debug.h"
+#include "../src/shell.h"
+#include "fi2c_eeprom_example.h"
+
+#define IO_BUF_LEN 64
+static u8 write_buf[IO_BUF_LEN] __attribute__((aligned(4)));
+static u8 read_buf[IO_BUF_LEN] __attribute__((aligned(4)));
+
+static void I2cEepromCmdUsage(void)
+{
+ printf("usage:\r\n");
+ printf(" fi2ceeprom probe\r\n");
+ printf(" -- init i2c ctrl\r\n");
+ printf(" fi2ceeprom write [offset] [string]\r\n");
+ printf(" -- init i2c ctrl\r\n");
+ printf(" fi2ceeprom read [offset] [len] \r\n");
+ printf(" -- init i2c ctrl\r\n");
+ printf(" fi2ceeprom info\r\n");
+ printf(" -- print i2c driver info\r\n");
+}
+
+static int I2cEepromCmdEntry(int argc, char *argv[])
+{
+ int ret = 0;
+ const char *input;
+ u8 input_len;
+ u8 offset;
+
+ if (argc < 2)
+ {
+ I2cEepromCmdUsage();
+ return -1;
+ }
+
+ if(!strcmp(argv[1], "probe"))
+ {
+ ret = FI2cEepromInit(I2C_INSTANCE_0);
+ }
+ else if(!strcmp(argv[1], "write"))
+ {
+ if (argc < 4)
+ {
+ I2cEepromCmdUsage();
+ return -1;
+ }
+
+ offset = (u8)simple_strtoul(argv[2], NULL, 16);
+ input = argv[3];
+ input_len = strlen(input);
+ strncpy(write_buf, input, input_len);
+ printf("write 0x%x len %d\r\n", offset, input_len);
+ ret = FI2cEepromWrite(write_buf, input_len, offset);
+ }
+ else if(!strcmp(argv[1], "read"))
+ {
+ if (argc < 4)
+ {
+ I2cEepromCmdUsage();
+ return -1;
+ }
+
+ offset = (u8)simple_strtoul(argv[2], NULL, 16);
+ input_len = (u8)simple_strtoul(argv[3], NULL, 16);
+ printf("read 0x%x len %d\r\n", offset, input_len);
+ ret = FI2cEepromRead(read_buf, input_len, offset);
+ if (0 == ret)
+ FtDumpHexByte(read_buf, input_len);
+ }
+ else if(!strcmp(argv[1], "info"))
+ {
+ ret = FI2cEepromDriverInfo();
+ }
+
+ if (0 != ret)
+ {
+ printf("failed: 0x%x\r\n", ret);
+ }
+
+ return ret;
+}
+SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), fi2ceeprom, I2cEepromCmdEntry, test fi2c driver);
\ No newline at end of file
diff --git a/baremetal/example/fi2c_eeprom/configs/d2000_aarch32_eg_configs b/baremetal/example/fi2c_eeprom/configs/d2000_aarch32_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..a39ed990b670eade5251c7a3d05178730ee0b453
--- /dev/null
+++ b/baremetal/example/fi2c_eeprom/configs/d2000_aarch32_eg_configs
@@ -0,0 +1,122 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a32"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+CONFIG_TARGET_ARMV8_AARCH32=y
+# CONFIG_TARGET_ARMV8_AARCH64 is not set
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+CONFIG_USE_AARCH64_L1_TO_AARCH32=y
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+# CONFIG_TARGET_E2000 is not set
+CONFIG_TARGET_D2000=y
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+CONFIG_AARCH32_RAM_LD=y
+# CONFIG_AARCH64_RAM_LD is not set
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_SIZE=0x1000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/fi2c_eeprom/configs/d2000_aarch64_eg_configs b/baremetal/example/fi2c_eeprom/configs/d2000_aarch64_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..6b1268d24f0a3144d6018fc3e5a34fc950ac33ef
--- /dev/null
+++ b/baremetal/example/fi2c_eeprom/configs/d2000_aarch64_eg_configs
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a64"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+# CONFIG_TARGET_E2000 is not set
+CONFIG_TARGET_D2000=y
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/fi2c_eeprom/configs/ft2004_aarch32_eg_configs b/baremetal/example/fi2c_eeprom/configs/ft2004_aarch32_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..79eb7074fd33d37eaa369ef82e0a5401f64e782e
--- /dev/null
+++ b/baremetal/example/fi2c_eeprom/configs/ft2004_aarch32_eg_configs
@@ -0,0 +1,122 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="ft2004_baremetal_a32"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+CONFIG_TARGET_ARMV8_AARCH32=y
+# CONFIG_TARGET_ARMV8_AARCH64 is not set
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+CONFIG_USE_AARCH64_L1_TO_AARCH32=y
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+CONFIG_TARGET_F2000_4=y
+# CONFIG_TARGET_E2000 is not set
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+CONFIG_AARCH32_RAM_LD=y
+# CONFIG_AARCH64_RAM_LD is not set
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_SIZE=0x1000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/fi2c_eeprom/configs/ft2004_aarch64_eg_configs b/baremetal/example/fi2c_eeprom/configs/ft2004_aarch64_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..f5567afd0846e378ba9994576a298025af4d65e2
--- /dev/null
+++ b/baremetal/example/fi2c_eeprom/configs/ft2004_aarch64_eg_configs
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="ft2004_baremetal_a64"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+CONFIG_TARGET_F2000_4=y
+# CONFIG_TARGET_E2000 is not set
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/fi2c_eeprom/fi2c_eeprom_example.c b/baremetal/example/fi2c_eeprom/fi2c_eeprom_example.c
new file mode 100644
index 0000000000000000000000000000000000000000..45aa32db975ded1f94b76d159daf359a19a77737
--- /dev/null
+++ b/baremetal/example/fi2c_eeprom/fi2c_eeprom_example.c
@@ -0,0 +1,292 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-22 10:31:26
+ * @LastEditTime: 2021-10-28 10:56:09
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+#include
+#include
+#include "parameters.h"
+#include "kernel.h"
+#include "ft_types.h"
+#include "ft_debug.h"
+#include "fsleep.h"
+#include "fi2c_eeprom_example.h"
+#include "fi2c.h"
+#include "f_iomux.h"
+
+static FI2c device;
+#define IO_BUF_LEN 64
+static u8 write_buf[IO_BUF_LEN] __attribute__((aligned(4)));
+static u8 read_buf[IO_BUF_LEN] __attribute__((aligned(4)));
+
+static FError FI2cEepromWritePoll(FI2c *instance_p, u8 inchip_addr, const u8 *buf_p, size_t buf_len)
+{
+ FError status = FI2C_SUCCESS;
+ const u32 trans_size = AT24C02_BLK_SIZE;
+ const u32 trans_times = buf_len / trans_size;
+ const u32 last_trans_len = buf_len % trans_size;
+ u32 loop;
+
+ for (loop = 0; loop < trans_times; loop++)
+ {
+ status = FI2cMasterWritePoll(instance_p,
+ inchip_addr + loop * trans_size,
+ buf_p + loop * trans_size,
+ trans_size);
+ if (FI2C_SUCCESS != status)
+ {
+ printf("failed in loop %d buf %p ret 0x%x\r\n",
+ loop,
+ buf_p + loop * trans_size,
+ status);
+ break;
+ }
+ else
+ {
+ printf("write loop %d buf %p\r\n", loop, buf_p + loop * trans_size);
+ }
+ }
+
+ if (FI2C_SUCCESS != status)
+ return status;
+
+ if (0 != last_trans_len)
+ {
+ status = FI2cMasterWritePoll(instance_p,
+ inchip_addr + trans_times * trans_size,
+ buf_p + trans_times * trans_size,
+ last_trans_len);
+
+ if (FI2C_SUCCESS != status)
+ {
+ printf("failed in last trans buf 0x%x, len %d\r\n",
+ buf_p + trans_times * trans_size,
+ last_trans_len);
+ }
+ else
+ {
+ printf("write final loop buf %p\r\n", buf_p + trans_times * trans_size);
+ }
+ }
+
+ return status;
+}
+
+static FError FI2cEepromReadPoll(FI2c *instance_p, u8 inchip_addr, u8 *buf_p, size_t buf_len)
+{
+ FError status = FI2C_SUCCESS;
+ const u32 trans_size = AT24C02_BLK_SIZE;
+ const u32 trans_times = buf_len / trans_size;
+ const u32 last_trans_len = buf_len % trans_size;
+ u32 loop;
+
+ for (loop = 0; loop < trans_times; loop++)
+ {
+ status = FI2cMasterReadPoll(instance_p,
+ inchip_addr + loop * trans_size,
+ buf_p + loop * trans_size,
+ trans_size);
+ if (FI2C_SUCCESS != status)
+ {
+ printf("failed in loop %d buf 0x%x ret 0x%x\r\n",
+ loop,
+ buf_p + loop * trans_size,
+ status);
+ return status;
+ }
+ else
+ {
+ printf("read loop %d buf %p\r\n", loop, buf_p + loop * trans_size);
+ }
+ }
+
+ if (FI2C_SUCCESS != status)
+ return status;
+
+ if (0 != last_trans_len)
+ {
+ status = FI2cMasterReadPoll(instance_p,
+ inchip_addr + trans_times * trans_size,
+ buf_p + trans_times * trans_size,
+ last_trans_len);
+
+ if (FI2C_SUCCESS != status)
+ {
+ printf("failed in last trans buf 0x%x, len %d\r\n",
+ buf_p + trans_times * trans_size,
+ last_trans_len);
+
+ return status;
+ }
+ else
+ {
+ printf("read final loop buf %p\r\n", buf_p + trans_times * trans_size);
+ }
+ }
+
+ return status;
+}
+
+static void FI2cEepromSetIoMux(u32 instance_id)
+{
+/* i2c io mux */
+#define I2C_0_SCL_MUX IOMUX_I2C_0_SCL_PAD
+#define I2C_0_SDA_MUX IOMUX_I2C_0_SDA_PAD
+#define I2C_0_SCL_FUN FUN0
+#define I2C_0_SDA_FUN FUN0
+
+#define I2C_1_SCL_MUX IOMUX_ALL_PLL_LOCK_PAD
+#define I2C_1_SDA_MUX IOMUX_ALL_PLL_LOCK_PAD
+#define I2C_1_SCL_FUN FUN2
+#define I2C_1_SDA_FUN FUN2
+
+#define I2C_2_SCL_MUX IOMUX_SWDO_SWJ_PAD
+#define I2C_2_SDA_MUX IOMUX_TDO_SWJ_PAD
+#define I2C_2_SCL_FUN FUN2
+#define I2C_2_SDA_FUN FUN2
+
+#define I2C_3_SCL_MUX IOMUX_HDT_MB_DONE_STATE_PAD
+#define I2C_3_SDA_MUX IOMUX_HDT_MB_FAIL_STATE_PAD
+#define I2C_3_SCL_FUN FUN2
+#define I2C_3_SDA_FUN FUN2
+
+ int sclpad_off, sdapad_off;
+ PadFun scl_fun, sda_fun;
+
+ switch (instance_id)
+ {
+ case I2C_INSTANCE_0:
+ sclpad_off = I2C_0_SCL_MUX;
+ sdapad_off = I2C_0_SDA_MUX;
+ scl_fun = I2C_0_SCL_FUN;
+ sda_fun = I2C_0_SDA_FUN;
+ break;
+ case I2C_INSTANCE_1:
+ sclpad_off = I2C_1_SCL_MUX;
+ sdapad_off = I2C_1_SDA_MUX;
+ scl_fun = I2C_1_SCL_FUN;
+ sda_fun = I2C_1_SDA_FUN;
+ break;
+ case I2C_INSTANCE_2:
+ sclpad_off = I2C_2_SCL_MUX;
+ sdapad_off = I2C_2_SDA_MUX;
+ scl_fun = I2C_2_SCL_FUN;
+ sda_fun = I2C_2_SDA_FUN;
+ break;
+ case I2C_INSTANCE_3:
+ sclpad_off = I2C_3_SCL_MUX;
+ sdapad_off = I2C_3_SDA_MUX;
+ scl_fun = I2C_3_SCL_FUN;
+ sda_fun = I2C_3_SDA_FUN;
+ break;
+ default:
+ FT_ASSERTVOID(0);
+ break;
+ }
+
+ FIomuxSetFun(sclpad_off, scl_fun);
+ FIomuxSetFun(sdapad_off, sda_fun);
+}
+
+int FI2cEepromInit(u32 instance_id)
+{
+ FI2cConfig input_cfg;
+ const FI2cConfig *config_p = NULL;
+ FI2c *instance_p = &device;
+ FError status = FI2C_SUCCESS;
+
+ memset(instance_p, 0, sizeof(*instance_p));
+
+ /* Lookup default configs by instance id */
+ config_p = FI2cLookupConfig(instance_id);
+ if (NULL == config_p)
+ {
+ printf("config of i2c instance %d non found\r\n", instance_id);
+ return -1;
+ }
+
+ /* Modify configuration */
+ input_cfg = *config_p;
+ input_cfg.slave_addr = AT24C02_ADDR | AT24C02_CHIP_SEL;
+ input_cfg.slave_addr_len = 1;
+ input_cfg.speed_rate = FI2C_SPEED_STANDARD_RATE;
+
+ /* Setup iomux */
+ FI2cEepromSetIoMux(instance_id);
+
+ /* Initialization */
+ status = FI2cCfgInitialize(instance_p, &input_cfg);
+ if (FI2C_SUCCESS != status)
+ {
+ printf("init i2c master failed, ret: 0x%x\r\n", status);
+ return -2;
+ }
+
+ printf("eeprom detected at 0x%x with i2c-%d\r\n", input_cfg.slave_addr, instance_id);
+ return 0;
+}
+
+int FI2cEepromWrite(const u8 *buf_p, u32 buf_len, u8 inchip_offset)
+{
+ FI2c *instance_p = &device;
+ FError status = FI2C_SUCCESS;
+
+ /*
+ * Write buf to eeprom with inchip address
+ */
+ status = FI2cEepromWritePoll(instance_p, inchip_offset, buf_p, buf_len);
+ if (FI2C_SUCCESS != status)
+ {
+ printf("write to eeprom failed, ret: 0x%x\r\n", status);
+ return -3;
+ }
+
+ return 0;
+}
+
+int FI2cEepromRead(u8 *buf_p, u32 buf_len, u8 inchip_offset)
+{
+ FI2c *instance_p = &device;
+ FError status = FI2C_SUCCESS;
+
+ /*
+ * Read eeprom to buf with inchip address
+ */
+ memset(buf_p, 0, buf_len);
+ status = FI2cEepromReadPoll(instance_p, inchip_offset, buf_p, buf_len);
+ if (FI2C_SUCCESS != status)
+ {
+ printf("read eeprom failed, ret: 0x%x\r\n", status);
+ return -4;
+ }
+
+ return 0;
+}
+
+int FI2cEepromDriverInfo()
+{
+ FError err;
+
+ printf("Error code \r\n");
+ printf(" prefix: 0x%x\r\n", FI2C_ERR_CODE_PREFIX);
+ printf(" num: %d\r\n", FI2C_NUM_OF_ERR_CODE);
+ printf(" ==========\r\n");
+ printf(" [0x%x] %s \r\n", FI2C_SUCCESS, FI2cErrorToMessage(FI2C_SUCCESS));
+ printf(" [0x%x] %s \r\n", FI2C_ERR_INVAL_PARM, FI2cErrorToMessage(FI2C_ERR_INVAL_PARM));
+ printf(" [0x%x] %s \r\n", FI2C_ERR_NOT_READY, FI2cErrorToMessage(FI2C_ERR_NOT_READY));
+ printf(" [0x%x] %s \r\n", FI2C_ERR_INVAL_PARM, FI2cErrorToMessage(FI2C_ERR_INVAL_PARM));
+ printf(" [0x%x] %s \r\n", FI2C_ERR_TIMEOUT, FI2cErrorToMessage(FI2C_ERR_TIMEOUT));
+ printf(" [0x%x] %s \r\n", FI2C_ERR_NOT_SUPPORT, FI2cErrorToMessage(FI2C_ERR_NOT_SUPPORT));
+ printf(" [0x%x] %s \r\n", FI2C_ERR_INVAL_STATE, FI2cErrorToMessage(FI2C_ERR_INVAL_STATE));
+ printf(" ==========\r\n");
+
+ return 0;
+}
\ No newline at end of file
diff --git a/baremetal/example/i2c_eeprom/eeprom.h b/baremetal/example/fi2c_eeprom/fi2c_eeprom_example.h
similarity index 40%
rename from baremetal/example/i2c_eeprom/eeprom.h
rename to baremetal/example/fi2c_eeprom/fi2c_eeprom_example.h
index 82f31b948c797bd556c68a53b9da0a571369351a..1a821e14fa575899ad02bb68870310673a185bec 100644
--- a/baremetal/example/i2c_eeprom/eeprom.h
+++ b/baremetal/example/fi2c_eeprom/fi2c_eeprom_example.h
@@ -1,39 +1,38 @@
/*
- * Copyright (c) 2021 Phytium Information Technology, Inc.
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
*
* SPDX-License-Identifier: Apache-2.0.
*
- * @Date: 2021-07-28 16:19:07
- * @LastEditTime: 2021-08-02 15:04:35
+ * @Date: 2021-10-22 10:31:36
+ * @LastEditTime: 2021-10-28 10:25:44
* @Description: This files is for
*
* @Modify History:
* Ver Who Date Changes
* ----- ------ -------- --------------------------------------
*/
-#ifndef EXAMPLE_I2C_EEPROM_H
-#define EXAMPLE_I2C_EEPROM_H
+#ifndef EXAMPLE_I2C_EEPROM_H
+#define EXAMPLE_I2C_EEPROM_H
#ifdef __cplusplus
extern "C"
{
#endif
-#include "ft_types.h"
-
#define AT24C02_ADDR 0x50 /* eeprom slave address */
#define AT24C02_CHIP_SEL 0x07 /* eeprom chip select */
-#define AT24C02_BLK_SIZE 8 /* eeprom page size,
- one cannot write more bytes to eeprom more than
- this size */
+/*
+ eeprom page size,
+ one cannot write more bytes to eeprom more than
+ this size
+*/
+#define AT24C02_BLK_SIZE 8
-u32 I2cEeMasterInit();
-u32 I2cEeMasterWrite(u32 slaveAddr, u8 offset, u8 *pBuf, u32 bufLen);
-u32 I2cEeMasterRead(u32 slaveAddr, u8 offset, u8 *pBuf, u32 bufLen);
-u32 I2cEeSlaveInit();
-u32 I2cEeSlaveReadBuf();
-void I2cEeMasterWR();
-void I2cEeMaster2Slave();
+int FI2cEepromExample(u32 instance_id);
+int FI2cEepromInit(u32 instance_id);
+int FI2cEepromWrite(const u8 *buf_p, u32 buf_len, u8 inchip_offset);
+int FI2cEepromRead(u8 *buf_p, u32 buf_len, u8 inchip_offset);
+int FI2cEepromDriverInfo();
#ifdef __cplusplus
}
diff --git a/baremetal/example/i2c_eeprom/main.c b/baremetal/example/fi2c_eeprom/main.c
similarity index 48%
rename from baremetal/example/i2c_eeprom/main.c
rename to baremetal/example/fi2c_eeprom/main.c
index f16a8967dab172b30f3dfa98dd4fcf137eefeb4e..c77be072ad1d81d5d3322caf3dd89a7f2a919cce 100644
--- a/baremetal/example/i2c_eeprom/main.c
+++ b/baremetal/example/fi2c_eeprom/main.c
@@ -4,18 +4,26 @@
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-07-09 08:08:39
- * @LastEditTime: 2021-08-03 16:50:57
- * @Description: This files is for
+ * @LastEditTime: 2021-10-28 17:11:55
+ * @Description: This files is for phytium baremetal hello world
*
* @Modify History:
* Ver Who Date Changes
* ----- ------ -------- --------------------------------------
*/
-#include "eeprom.h"
+#include
+#include
+#include "sdkconfig.h"
+#ifndef SDK_CONFIG_H__
+ #warning "Please include sdkconfig.h"
+#endif
+#ifndef CONFIG_USE_LETTER_SHELL
+ #error "Please include letter shell first!!!"
+#endif
+#include "shell_port.h"
int main()
-{
- I2cEeMasterWR();
- I2cEeMaster2Slave();
+{
+ LSUserShellLoop();
return 0;
}
\ No newline at end of file
diff --git a/baremetal/example/i2c_eeprom/makefile b/baremetal/example/fi2c_eeprom/makefile
similarity index 45%
rename from baremetal/example/i2c_eeprom/makefile
rename to baremetal/example/fi2c_eeprom/makefile
index 8753c364b1be276671b9aea6b314385f69e79a70..829b33f58178da91fdae5564a11acf0e9f7516fb 100644
--- a/baremetal/example/i2c_eeprom/makefile
+++ b/baremetal/example/fi2c_eeprom/makefile
@@ -1,6 +1,5 @@
# 指定工程项目根目录为当前(只能指定一个目录)
export PROJECT_DIR ?= .
-
# 用户添加的源文件夹和头文件夹(可以指定多个)
export USR_SRC_DIR ?= . \
./src
@@ -8,16 +7,35 @@ export USR_INC_DIR ?= . \
./inc
# 用户定义的编译目标文件上传路径
-USR_BOOT_DIR ?= /mnt/d/tftboot/
+ifeq ($(OS),Windows_NT)
+ USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp
+else
+ USR_BOOT_DIR ?= /mnt/d/phytium-dev/tftp
+endif
# 设置启动镜像名
-BOOT_IMG_NAME ?= baremetal
+BOOT_IMG_NAME ?= baremetal
-# 指定编译freertos项目使用的makefile
+# 指定编译项目使用的makefile
include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk
+# 配置例程所需的配置
+USR_CONFIGS := USE_LETTER_SHELL=y \
+ USE_IOMUX=y \
+ ENABLE_FIOMUX=y \
+ USE_I2C=y \
+ USE_FI2C=y
+
# 完成编译
boot:
- make
+ make -j
@cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf
- @cp ./$(CONFIG_TARGET_NAME).bin $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).bin
\ No newline at end of file
+ @ls $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf -l
+
+# 编译所有支持的平台
+.PHONY: build_all
+build_all:
+ make build_ft2004_aarch32
+ make build_ft2004_aarch64
+ make build_d2000_aarch32
+ make build_d2000_aarch64
\ No newline at end of file
diff --git a/baremetal/example/fi2c_eeprom/sdkconfig b/baremetal/example/fi2c_eeprom/sdkconfig
new file mode 100644
index 0000000000000000000000000000000000000000..6b1268d24f0a3144d6018fc3e5a34fc950ac33ef
--- /dev/null
+++ b/baremetal/example/fi2c_eeprom/sdkconfig
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a64"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+# CONFIG_TARGET_E2000 is not set
+CONFIG_TARGET_D2000=y
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/i2c_eeprom/sdkconfig.h b/baremetal/example/fi2c_eeprom/sdkconfig.h
similarity index 72%
rename from baremetal/example/i2c_eeprom/sdkconfig.h
rename to baremetal/example/fi2c_eeprom/sdkconfig.h
index 002e5e508b6d01fda0ca6e41ef689f0d2419b231..31b0254520f929353fa4e553352c0c26fa358027 100644
--- a/baremetal/example/i2c_eeprom/sdkconfig.h
+++ b/baremetal/example/fi2c_eeprom/sdkconfig.h
@@ -4,22 +4,19 @@
/* Project Configuration */
#define CONFIG_TARGET_NAME "d2000_baremetal_a64"
-/* CONFIG_I2C_MASTER_EEPROM is not set */
-#define CONFIG_I2C_MASTER_SLAVE
/* end of Project Configuration */
-/* Board Setting */
+/* Platform Setting */
/* Arch Configuration */
-#define CONFIG_TARGET_ARMV8_AARCH32
-/* CONFIG_TARGET_ARMV8_AARCH64 is not set */
+/* CONFIG_TARGET_ARMV8_AARCH32 is not set */
+#define CONFIG_TARGET_ARMV8_AARCH64
/* CONFIG_TARGET_ARMV7 is not set */
#define CONFIG_USE_CACHE
#define CONFIG_USE_L3CACHE
#define CONFIG_USE_MMU
/* CONFIG_USE_SYS_TICK is not set */
-#define CONFIG_USE_AARCH64_L1_TO_AARCH32
/* end of Arch Configuration */
/* Board Configuration */
@@ -35,25 +32,30 @@
/* CONFIG_USE_QSPI is not set */
#define CONFIG_USE_GIC
#define CONFIG_EBABLE_GICV3
-/* CONFIG_USE_SERIAL is not set */
+#define CONFIG_USE_SERIAL
+
+/* Usart Configuration */
+
+#define CONFIG_ENABLE_Pl011_UART
+/* end of Usart Configuration */
/* CONFIG_USE_GPIO is not set */
-/* CONFIG_USE_IOMUX is not set */
+#define CONFIG_USE_IOMUX
+#define CONFIG_ENABLE_FIOMUX
/* CONFIG_USE_ETH is not set */
/* CONFIG_USE_CAN is not set */
#define CONFIG_USE_I2C
-#define CONFIG_USE_DW_I2C
+#define CONFIG_USE_FI2C
/* CONFIG_USE_TIMER is not set */
/* CONFIG_USE_SDMMC is not set */
/* CONFIG_USE_PCIE is not set */
+/* CONFIG_USE_WDT is not set */
/* CONFIG_USE_DMA is not set */
/* CONFIG_USE_NAND is not set */
/* end of Components Configuration */
-/* end of Board Setting */
+/* end of Platform Setting */
/* Building Option */
-#define CONFIG_ENVI_UBUNTU_20_04
-
/* Cross-Compiler Setting */
#define CONFIG_COMPILER_NO_STD_STARUP
@@ -68,8 +70,8 @@
/* Linker Options */
-#define CONFIG_AARCH32_RAM_LD
-/* CONFIG_AARCH64_RAM_LD is not set */
+/* CONFIG_AARCH32_RAM_LD is not set */
+#define CONFIG_AARCH64_RAM_LD
/* CONFIG_QEMU_AARCH32_RAM_LD is not set */
/* CONFIG_USER_DEFINED_LD is not set */
#define CONFIG_LINK_SCRIPT_ROM
@@ -78,22 +80,29 @@
#define CONFIG_LINK_SCRIPT_RAM
#define CONFIG_RAM_START_UP_ADDR 0x81000000
#define CONFIG_RAM_SIZE_MB 64
-#define CONFIG_HEAP_SIZE 0x0400
-#define CONFIG_STACK_SIZE 0x1000
+#define CONFIG_HEAP_SIZE 0x04000
+#define CONFIG_STACK_TOP_ADDR 0x82000000
/* end of Linker Options */
/* end of Building Option */
/* Library Configuration */
-#define CONFIG_USE_LIBC
+#define CONFIG_USE_G_LIBC
+/* CONFIG_USE_NEW_LIBC is not set */
/* end of Library Configuration */
/* Third-Party Configuration */
/* CONFIG_USE_LWIP is not set */
-/* CONFIG_USE_LETTER_SHELL is not set */
+#define CONFIG_USE_LETTER_SHELL
+
+/* Letter Shell Configuration */
+
+#define CONFIG_LS_PL011_UART
+/* end of Letter Shell Configuration */
/* CONFIG_USE_AMP is not set */
/* CONFIG_USE_YAFFS2 is not set */
+/* CONFIG_USE_SDMMC_CMD is not set */
/* end of Third-Party Configuration */
#endif
diff --git a/baremetal/example/fi2c_slave/Kconfig b/baremetal/example/fi2c_slave/Kconfig
new file mode 100644
index 0000000000000000000000000000000000000000..16847f50fdcfff2f4cade7e1ff4cc7e31fa285d7
--- /dev/null
+++ b/baremetal/example/fi2c_slave/Kconfig
@@ -0,0 +1,11 @@
+mainmenu "Phytium Baremetal Configuration"
+
+menu "Project Configuration"
+ config TARGET_NAME
+ string "Build Target Name"
+ default "baremetal"
+ help
+ Build Target name for the demo
+endmenu
+
+source "$(STANDALONE_SDK_ROOT)/Kconfig"
diff --git a/baremetal/example/fi2c_slave/README.md b/baremetal/example/fi2c_slave/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..fd46e7dee8ddec3f13d78640d64cdebf09f54f8e
--- /dev/null
+++ b/baremetal/example/fi2c_slave/README.md
@@ -0,0 +1,142 @@
+
+# I2C Master-Slave 通信测试
+
+## 1. 例程介绍
+
+>介绍例程的用途,使用场景,相关基本概念,描述用户可以使用例程完成哪些工作
+
+本例程实现了I2C主从(Master-Slave)通信,主机侧是ESP32开发板的I2C0,负责发起I2C数据读写,从机侧是FT2000/4开发板的I2C1,负责响应I2C数据读写,从机侧实现了一个虚拟的EEPROM缓冲区,模拟主机侧写入和读取数据的过程。
+
+## 2. 如何使用例程
+
+>描述开发平台准备,使用例程配置,构建和下载镜像的过程
+
+本example在FT2000/4上测试通过,您可以参考以下方法配置本例程所需要的硬件和软件环境,
+
+### 2.1 硬件配置方法
+
+#### 2.1.2 硬件需求
+本example需要一下硬件
+- ESP32开发板,作为I2C主机
+- FT2000/4开发板, 作为I2C从机
+- USB线, 用于连接ESP32开发板,下载程序
+- 杜邦线若干,用于连接ESP32和FT2000/4
+
+#### 2.1.2 硬件连接
+
+按照如图所示的引脚,完成硬件连接ESP32和FT2000/4对应引脚的连接,
+| | SDA | SCL |
+| ------------------------- | ------ | ------ |
+| ESP32/ESP32-S2 I2C Master | I2C0 GPIO18 | I2C0 GPIO19 |
+| FT2000/4 I2C Slave | I2C1 SDA | I2C1 SCL |
+
+
+
+#### 2.2.2 ESP32 i2c_tool
+
+- I2C Tools是ESP32 IDF提供的官方例程,通过ESP32命令,提供了I2C主机协议支持,包括I2C从机发现(`i2cdetect`)、I2C主机向从机读和写(`i2cset`, `i2cget`)
+
+
+
+>哪些硬件平台是支持的,需要哪些外设,例程与开发板哪些IO口相关等(建议附录开发板照片,展示哪些IO口被引出)
+
+### 2.2 SDK配置方法
+
+>依赖哪些驱动、库和第三方组件,如何完成配置(列出需要使能的关键配置项)
+
+- 使能I2C `CONFIG_USE_I2C`, 然后选择FI2C驱动 `CONFIG_USE_FI2C`
+
+
+
+- 使能IOMUX `CONFIG_USE_IOMUX`, 然后选择FIOMUX驱动 `CONFIG_ENABLE_FIOMUX`
+
+- 使能Letter Shell `CONFIG_USE_LETTER_SHELL`
+
+
+
+### 2.3 构建和下载
+
+>描述构建、烧录下载镜像的过程,列出相关的命令
+
+- 切换到目标平台,`make config_ft2004_aarch32`
+
+- 按照2.2 选择配置,`make menuconfig`
+
+- 完成编译构建,将编译出来的镜像复制到Tftp目录下,`make`
+
+- 在FT2000/4侧的u-boot命令行输入以下命令,下载镜像
+```
+setenv ipaddr 192.168.4.20
+setenv serverip 192.168.4.50
+setenv gatewayip 192.168.4.1
+tftpboot 0x90100000 baremetal.elf
+bootelf -p 0x90100000
+```
+
+### 2.4 输出与实验现象
+
+>描述输入输出情况,列出存在哪些输出,对应的输出是什么(建议附录相关现象图片)
+
+- 开发板加载镜像启动后,可以通过ESP32的`i2c_tool`进行下列实验,
+
+#### 主机搜索发现从机
+
+- i2c从机的地址被设置为0x28
+
+
+
+#### 主机向从机写
+
+- 通过i2c_tool写入10个字节
+```
+i2cset -c 0x28 -r 0x00 0x00
+i2cset -c 0x28 -r 0x01 0x11
+i2cset -c 0x28 -r 0x02 0x22
+i2cset -c 0x28 -r 0x03 0x33
+i2cset -c 0x28 -r 0x04 0x44
+i2cset -c 0x28 -r 0x05 0x55
+i2cset -c 0x28 -r 0x06 0x66
+i2cset -c 0x28 -r 0x07 0x77
+i2cset -c 0x28 -r 0x08 0x88
+i2cset -c 0x28 -r 0x09 0x99
+```
+
+- 在从机侧观察写入的值
+
+
+
+#### 主机读从机的值
+
+- 通过i2c_tool写入10个字节
+```
+i2cget -c 0x28 -r 0x05 -l 1
+i2cget -c 0x28 -r 0x09 -l 1
+```
+
+
+## 3. 如何解决问题
+
+>主要记录使用例程中可能会遇到的问题,给出相应的解决方案
+
+Q: I2C从机发送数据时,在中断内调用打印log导致发送数据失败
+A: I2C的标准速率为400Kb/s,在中断中使用打印(假设串口波特率为115200)会阻塞I2C传输,导致I2C协议不正常
+
+## 4. 修改历史记录
+
+>记录例程的重大修改记录,标明修改发生的版本号
+
+- 2021-10-28 :v0.1.8 添加example
+
+
diff --git a/baremetal/example/fi2c_slave/cmd_fi2c_slave.c b/baremetal/example/fi2c_slave/cmd_fi2c_slave.c
new file mode 100644
index 0000000000000000000000000000000000000000..14ce94d09b393ff16b2881a338d19fcd35be4845
--- /dev/null
+++ b/baremetal/example/fi2c_slave/cmd_fi2c_slave.c
@@ -0,0 +1,55 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-26 08:37:22
+ * @LastEditTime: 2021-10-29 15:12:40
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+#include
+#include
+#include "strto.h"
+#include "parameters.h"
+#include "ft_types.h"
+#include "ft_debug.h"
+#include "../src/shell.h"
+#include "fi2c_slave_example.h"
+
+#define IO_BUF_LEN 64
+static u8 write_buf[IO_BUF_LEN] __attribute__((aligned(4)));
+static u8 read_buf[IO_BUF_LEN] __attribute__((aligned(4)));
+
+static void I2cSlaveCmdUsage(void)
+{
+ printf("usage:\r\n");
+ printf(" fi2cslave probe\r\n");
+ printf(" -- find slave device\r\n");
+}
+
+static int I2cSlaveCmdEntry(int argc, char *argv[])
+{
+ int ret = 0;
+
+ if(argc < 2)
+ {
+ I2cSlaveCmdUsage();
+ return -1;
+ }
+
+ if (!strcmp(argv[1], "probe"))
+ {
+ ret = FI2cSlaveInit(I2C_INSTANCE_3);
+ }
+ else if (!strcmp(argv[1], "dump"))
+ {
+ ret = FI2cSlaveDump();
+ }
+
+ return ret;
+}
+SHELL_EXPORT_CMD(SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN), fi2cslave, I2cSlaveCmdEntry, test fi2c driver);
\ No newline at end of file
diff --git a/baremetal/example/fi2c_slave/configs/d2000_aarch32_eg_configs b/baremetal/example/fi2c_slave/configs/d2000_aarch32_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..a39ed990b670eade5251c7a3d05178730ee0b453
--- /dev/null
+++ b/baremetal/example/fi2c_slave/configs/d2000_aarch32_eg_configs
@@ -0,0 +1,122 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a32"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+CONFIG_TARGET_ARMV8_AARCH32=y
+# CONFIG_TARGET_ARMV8_AARCH64 is not set
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+CONFIG_USE_AARCH64_L1_TO_AARCH32=y
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+# CONFIG_TARGET_E2000 is not set
+CONFIG_TARGET_D2000=y
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+CONFIG_AARCH32_RAM_LD=y
+# CONFIG_AARCH64_RAM_LD is not set
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_SIZE=0x1000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/fi2c_slave/configs/d2000_aarch64_eg_configs b/baremetal/example/fi2c_slave/configs/d2000_aarch64_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..6b1268d24f0a3144d6018fc3e5a34fc950ac33ef
--- /dev/null
+++ b/baremetal/example/fi2c_slave/configs/d2000_aarch64_eg_configs
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a64"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+# CONFIG_TARGET_E2000 is not set
+CONFIG_TARGET_D2000=y
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/fi2c_slave/configs/ft2004_aarch32_eg_configs b/baremetal/example/fi2c_slave/configs/ft2004_aarch32_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..79eb7074fd33d37eaa369ef82e0a5401f64e782e
--- /dev/null
+++ b/baremetal/example/fi2c_slave/configs/ft2004_aarch32_eg_configs
@@ -0,0 +1,122 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="ft2004_baremetal_a32"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+CONFIG_TARGET_ARMV8_AARCH32=y
+# CONFIG_TARGET_ARMV8_AARCH64 is not set
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+CONFIG_USE_AARCH64_L1_TO_AARCH32=y
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+CONFIG_TARGET_F2000_4=y
+# CONFIG_TARGET_E2000 is not set
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+CONFIG_AARCH32_RAM_LD=y
+# CONFIG_AARCH64_RAM_LD is not set
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_SIZE=0x1000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/fi2c_slave/configs/ft2004_aarch64_eg_configs b/baremetal/example/fi2c_slave/configs/ft2004_aarch64_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..f5567afd0846e378ba9994576a298025af4d65e2
--- /dev/null
+++ b/baremetal/example/fi2c_slave/configs/ft2004_aarch64_eg_configs
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="ft2004_baremetal_a64"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+CONFIG_TARGET_F2000_4=y
+# CONFIG_TARGET_E2000 is not set
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/fi2c_slave/fi2c_slave_example.c b/baremetal/example/fi2c_slave/fi2c_slave_example.c
new file mode 100644
index 0000000000000000000000000000000000000000..a49c7462718f51aa21c68fcc5acbc761c137ad15
--- /dev/null
+++ b/baremetal/example/fi2c_slave/fi2c_slave_example.c
@@ -0,0 +1,223 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-25 10:56:28
+ * @LastEditTime: 2021-10-29 15:12:25
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+#include
+#include
+#include "parameters.h"
+#include "kernel.h"
+#include "ft_types.h"
+#include "ft_debug.h"
+#include "fsleep.h"
+#include "fi2c.h"
+#include "f_iomux.h"
+#include "fi2c_slave_example.h"
+
+#define IO_BUF_LEN 64
+typedef struct
+{
+ FI2c device;
+ boolean first_write;
+ u8 buff_idx;
+ u8 buff[64];
+} FI2cSlaveData;
+
+FI2cSlaveData slave;
+
+void FI2cSlaveCb(void *instance_p, void *para, u32 evt)
+{
+ FI2cSlaveData *slave_p = &slave;
+ u8 *val = (u8 *)para;
+
+ switch (evt)
+ {
+ case FI2C_EVT_SLAVE_WRITE_RECEIVED:
+ if (slave_p->first_write)
+ {
+ slave_p->buff_idx = *val;
+ slave_p->first_write = FALSE;
+ }
+ else
+ {
+ slave_p->buff[slave_p->buff_idx++] = *val;
+ }
+
+ break;
+ case FI2C_EVT_SLAVE_READ_PROCESSED:
+ /* The previous byte made it to the bus, get next one */
+ slave_p->buff_idx++;
+ /* fallthrough */
+ case FI2C_EVT_SLAVE_READ_REQUESTED:
+ *val = slave_p->buff[slave_p->buff_idx];
+ /*
+ * Do not increment buffer_idx here, because we don't know if
+ * this byte will be actually used. Read Linux I2C slave docs
+ * for details.
+ */
+ break;
+ case FI2C_EVT_SLAVE_STOP:
+ case FI2C_EVT_SLAVE_WRITE_REQUESTED:
+ slave_p->first_write = TRUE;
+ break;
+ default:
+ break;
+ }
+
+ return;
+}
+
+void FI2cSlaveWriteReceived(void *instance_p, void *para)
+{
+ FI2cSlaveCb(instance_p, para, FI2C_EVT_SLAVE_WRITE_RECEIVED);
+}
+
+void FI2cSlaveReadProcessed(void *instance_p, void *para)
+{
+ FI2cSlaveCb(instance_p, para, FI2C_EVT_SLAVE_READ_PROCESSED);
+}
+
+void FI2cSlaveReadRequest(void *instance_p, void *para)
+{
+ FI2cSlaveCb(instance_p, para, FI2C_EVT_SLAVE_READ_REQUESTED);
+}
+
+void FI2cSlaveStop(void *instance_p, void *para)
+{
+ FI2cSlaveCb(instance_p, para, FI2C_EVT_SLAVE_STOP);
+}
+
+void FI2cSlaveWriteRequest(void *instance_p, void *para)
+{
+ FI2cSlaveCb(instance_p, para, FI2C_EVT_SLAVE_WRITE_REQUESTED);
+}
+
+static void FI2cSlaveSetIoMux(u32 instance_id)
+{
+/* i2c io mux */
+#define I2C_0_SCL_MUX IOMUX_I2C_0_SCL_PAD
+#define I2C_0_SDA_MUX IOMUX_I2C_0_SDA_PAD
+#define I2C_0_SCL_FUN FUN0
+#define I2C_0_SDA_FUN FUN0
+
+#define I2C_1_SCL_MUX IOMUX_ALL_PLL_LOCK_PAD
+#define I2C_1_SDA_MUX IOMUX_ALL_PLL_LOCK_PAD
+#define I2C_1_SCL_FUN FUN2
+#define I2C_1_SDA_FUN FUN2
+
+#define I2C_2_SCL_MUX IOMUX_SWDO_SWJ_PAD
+#define I2C_2_SDA_MUX IOMUX_TDO_SWJ_PAD
+#define I2C_2_SCL_FUN FUN2
+#define I2C_2_SDA_FUN FUN2
+
+#define I2C_3_SCL_MUX IOMUX_HDT_MB_DONE_STATE_PAD
+#define I2C_3_SDA_MUX IOMUX_HDT_MB_FAIL_STATE_PAD
+#define I2C_3_SCL_FUN FUN2
+#define I2C_3_SDA_FUN FUN2
+
+ int sclpad_off, sdapad_off;
+ PadFun scl_fun, sda_fun;
+
+ switch (instance_id)
+ {
+ case I2C_INSTANCE_0:
+ sclpad_off = I2C_0_SCL_MUX;
+ sdapad_off = I2C_0_SDA_MUX;
+ scl_fun = I2C_0_SCL_FUN;
+ sda_fun = I2C_0_SDA_FUN;
+ break;
+ case I2C_INSTANCE_1:
+ sclpad_off = I2C_1_SCL_MUX;
+ sdapad_off = I2C_1_SDA_MUX;
+ scl_fun = I2C_1_SCL_FUN;
+ sda_fun = I2C_1_SDA_FUN;
+ break;
+ case I2C_INSTANCE_2:
+ sclpad_off = I2C_2_SCL_MUX;
+ sdapad_off = I2C_2_SDA_MUX;
+ scl_fun = I2C_2_SCL_FUN;
+ sda_fun = I2C_2_SDA_FUN;
+ break;
+ case I2C_INSTANCE_3:
+ sclpad_off = I2C_3_SCL_MUX;
+ sdapad_off = I2C_3_SDA_MUX;
+ scl_fun = I2C_3_SCL_FUN;
+ sda_fun = I2C_3_SDA_FUN;
+ break;
+ default:
+ FT_ASSERTVOID(0);
+ break;
+ }
+
+ FIomuxSetFun(sclpad_off, scl_fun);
+ FIomuxSetFun(sdapad_off, sda_fun);
+}
+
+int FI2cSlaveInit(u32 instance_id)
+{
+ FI2cConfig input_cfg;
+ const FI2cConfig *config_p = NULL;
+ FI2cSlaveData *slave_p = &slave;
+ FI2c *instance_p = &slave_p->device;
+ FError status = FI2C_SUCCESS;
+
+ memset(slave_p, 0, sizeof(*slave_p));
+ slave_p->first_write = TRUE;
+
+ /* Lookup default configs by instance id */
+ config_p = FI2cLookupConfig(instance_id);
+ if (NULL == config_p)
+ {
+ printf("config of i2c instance %d non found\r\n", instance_id);
+ return -1;
+ }
+
+ /* Modify configuration */
+ input_cfg = *config_p;
+ input_cfg.work_mode = FI2C_SLAVE;
+ input_cfg.slave_addr = 0x28; /* just assign one address as id */
+ input_cfg.slave_addr_len = 1;
+ input_cfg.speed_rate = FI2C_SPEED_STANDARD_RATE;
+
+ /* Setup iomux */
+ FI2cSlaveSetIoMux(instance_id);
+
+ /* Initialization */
+ status = FI2cCfgInitialize(instance_p, &input_cfg);
+ if (FI2C_SUCCESS != status)
+ {
+ printf("init i2c slave failed, ret: 0x%x\r\n", status);
+ return -2;
+ }
+
+ status = FI2cSlaveSetupIntrrupt(instance_p);
+ if (FI2C_SUCCESS != status)
+ {
+ printf("setup i2c slave intrrupt failed, ret: 0x%x\r\n", status);
+ return -3;
+ }
+
+ FI2cSlaveRegisterIntrruptHandler(instance_p, FI2C_EVT_SLAVE_WRITE_RECEIVED, FI2cSlaveWriteReceived);
+ FI2cSlaveRegisterIntrruptHandler(instance_p, FI2C_EVT_SLAVE_READ_PROCESSED, FI2cSlaveReadProcessed);
+ FI2cSlaveRegisterIntrruptHandler(instance_p, FI2C_EVT_SLAVE_READ_REQUESTED, FI2cSlaveReadRequest);
+ FI2cSlaveRegisterIntrruptHandler(instance_p, FI2C_EVT_SLAVE_STOP, FI2cSlaveStop);
+ FI2cSlaveRegisterIntrruptHandler(instance_p, FI2C_EVT_SLAVE_WRITE_REQUESTED, FI2cSlaveWriteRequest);
+
+ return 0;
+}
+
+int FI2cSlaveDump(void)
+{
+ FI2cSlaveData *slave_p = &slave;
+
+ printf("buf size: %d, buf idx: %d\r\n", sizeof(slave_p->buff), slave_p->buff_idx);
+ FtDumpHexByte(slave_p->buff, IO_BUF_LEN);
+}
\ No newline at end of file
diff --git a/baremetal/example/fi2c_slave/fi2c_slave_example.h b/baremetal/example/fi2c_slave/fi2c_slave_example.h
new file mode 100644
index 0000000000000000000000000000000000000000..50d69dd2d2d77bc6f74671a1441767be82a95116
--- /dev/null
+++ b/baremetal/example/fi2c_slave/fi2c_slave_example.h
@@ -0,0 +1,33 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-25 10:56:36
+ * @LastEditTime: 2021-10-29 15:12:34
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+#ifndef EXAMPLE_I2C_SLAVE_H
+#define EXAMPLE_I2C_SLAVE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+int FI2cSlaveInit(u32 instance_id);
+int FI2cSlaveDump(void);
+#if 0
+int FI2cSlaveWrite(const u8 *buf_p, u32 buf_len);
+int FI2cSlaveRead(u8 *buf_p, u32 buf_len);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/baremetal/example/fi2c_slave/main.c b/baremetal/example/fi2c_slave/main.c
new file mode 100644
index 0000000000000000000000000000000000000000..95d74e5db8d8d4a2f6ce1e155bc367f054bd8e23
--- /dev/null
+++ b/baremetal/example/fi2c_slave/main.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-07-09 08:08:39
+ * @LastEditTime: 2021-10-25 15:45:58
+ * @Description: This files is for phytium baremetal hello world
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+#include
+#include
+#include "sdkconfig.h"
+#ifndef SDK_CONFIG_H__
+ #warning "Please include sdkconfig.h"
+#endif
+#ifndef CONFIG_USE_LETTER_SHELL
+ #error "Please include letter shell first!!!"
+#endif
+#include "shell_port.h"
+
+int main()
+{
+ LSUserShellLoop();
+ return 0;
+}
\ No newline at end of file
diff --git a/baremetal/example/fi2c_slave/makefile b/baremetal/example/fi2c_slave/makefile
new file mode 100644
index 0000000000000000000000000000000000000000..702b80670eb3c92587227b1b7acffdf72fc90050
--- /dev/null
+++ b/baremetal/example/fi2c_slave/makefile
@@ -0,0 +1,41 @@
+# 指定工程项目根目录为当前(只能指定一个目录)
+export PROJECT_DIR ?= .
+# 用户添加的源文件夹和头文件夹(可以指定多个)
+export USR_SRC_DIR ?= . \
+ ./src
+export USR_INC_DIR ?= . \
+ ./inc
+
+# 用户定义的编译目标文件上传路径
+ifeq ($(OS),Windows_NT)
+ USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp
+else
+ USR_BOOT_DIR ?= /mnt/d/phytium-dev/tftp
+endif
+
+# 设置启动镜像名
+BOOT_IMG_NAME ?= baremetal
+
+# 指定编译项目使用的makefile
+include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk
+
+# 配置例程中需要的配置
+USR_CONFIGS := USE_LETTER_SHELL=y \
+ USE_IOMUX=y \
+ ENABLE_FIOMUX=y \
+ USE_I2C=y \
+ USE_FI2C=y
+
+# 完成编译
+boot:
+ make -j
+ @cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf
+ @ls $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf -l
+
+# 编译所有支持的平台
+.PHONY: build_all
+build_all:
+ make build_ft2004_aarch32
+ make build_ft2004_aarch64
+ make build_d2000_aarch32
+ make build_d2000_aarch64
\ No newline at end of file
diff --git a/baremetal/example/fi2c_slave/sdkconfig b/baremetal/example/fi2c_slave/sdkconfig
new file mode 100644
index 0000000000000000000000000000000000000000..6b1268d24f0a3144d6018fc3e5a34fc950ac33ef
--- /dev/null
+++ b/baremetal/example/fi2c_slave/sdkconfig
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a64"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+# CONFIG_TARGET_E2000 is not set
+CONFIG_TARGET_D2000=y
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+CONFIG_USE_IOMUX=y
+CONFIG_ENABLE_FIOMUX=y
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+CONFIG_USE_I2C=y
+CONFIG_USE_FI2C=y
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/fi2c_slave/sdkconfig.h b/baremetal/example/fi2c_slave/sdkconfig.h
new file mode 100644
index 0000000000000000000000000000000000000000..31b0254520f929353fa4e553352c0c26fa358027
--- /dev/null
+++ b/baremetal/example/fi2c_slave/sdkconfig.h
@@ -0,0 +1,108 @@
+#ifndef SDK_CONFIG_H__
+#define SDK_CONFIG_H__
+
+/* Project Configuration */
+
+#define CONFIG_TARGET_NAME "d2000_baremetal_a64"
+/* end of Project Configuration */
+
+/* Platform Setting */
+
+/* Arch Configuration */
+
+/* CONFIG_TARGET_ARMV8_AARCH32 is not set */
+#define CONFIG_TARGET_ARMV8_AARCH64
+/* CONFIG_TARGET_ARMV7 is not set */
+#define CONFIG_USE_CACHE
+#define CONFIG_USE_L3CACHE
+#define CONFIG_USE_MMU
+/* CONFIG_USE_SYS_TICK is not set */
+/* end of Arch Configuration */
+
+/* Board Configuration */
+
+/* CONFIG_TARGET_F2000_4 is not set */
+/* CONFIG_TARGET_E2000 is not set */
+#define CONFIG_TARGET_D2000
+/* end of Board Configuration */
+
+/* Components Configuration */
+
+/* CONFIG_USE_SPI is not set */
+/* CONFIG_USE_QSPI is not set */
+#define CONFIG_USE_GIC
+#define CONFIG_EBABLE_GICV3
+#define CONFIG_USE_SERIAL
+
+/* Usart Configuration */
+
+#define CONFIG_ENABLE_Pl011_UART
+/* end of Usart Configuration */
+/* CONFIG_USE_GPIO is not set */
+#define CONFIG_USE_IOMUX
+#define CONFIG_ENABLE_FIOMUX
+/* CONFIG_USE_ETH is not set */
+/* CONFIG_USE_CAN is not set */
+#define CONFIG_USE_I2C
+#define CONFIG_USE_FI2C
+/* CONFIG_USE_TIMER is not set */
+/* CONFIG_USE_SDMMC is not set */
+/* CONFIG_USE_PCIE is not set */
+/* CONFIG_USE_WDT is not set */
+/* CONFIG_USE_DMA is not set */
+/* CONFIG_USE_NAND is not set */
+/* end of Components Configuration */
+/* end of Platform Setting */
+
+/* Building Option */
+
+/* Cross-Compiler Setting */
+
+#define CONFIG_COMPILER_NO_STD_STARUP
+/* CONFIG_USE_EXT_COMPILER is not set */
+/* end of Cross-Compiler Setting */
+/* CONFIG_LOG_VERBOS is not set */
+/* CONFIG_LOG_DEBUG is not set */
+/* CONFIG_LOG_INFO is not set */
+/* CONFIG_LOG_WARN is not set */
+#define CONFIG_LOG_ERROR
+/* CONFIG_LOG_NONE is not set */
+
+/* Linker Options */
+
+/* CONFIG_AARCH32_RAM_LD is not set */
+#define CONFIG_AARCH64_RAM_LD
+/* CONFIG_QEMU_AARCH32_RAM_LD is not set */
+/* CONFIG_USER_DEFINED_LD is not set */
+#define CONFIG_LINK_SCRIPT_ROM
+#define CONFIG_ROM_START_UP_ADDR 0x80100000
+#define CONFIG_ROM_SIZE_MB 1
+#define CONFIG_LINK_SCRIPT_RAM
+#define CONFIG_RAM_START_UP_ADDR 0x81000000
+#define CONFIG_RAM_SIZE_MB 64
+#define CONFIG_HEAP_SIZE 0x04000
+#define CONFIG_STACK_TOP_ADDR 0x82000000
+/* end of Linker Options */
+/* end of Building Option */
+
+/* Library Configuration */
+
+#define CONFIG_USE_G_LIBC
+/* CONFIG_USE_NEW_LIBC is not set */
+/* end of Library Configuration */
+
+/* Third-Party Configuration */
+
+/* CONFIG_USE_LWIP is not set */
+#define CONFIG_USE_LETTER_SHELL
+
+/* Letter Shell Configuration */
+
+#define CONFIG_LS_PL011_UART
+/* end of Letter Shell Configuration */
+/* CONFIG_USE_AMP is not set */
+/* CONFIG_USE_YAFFS2 is not set */
+/* CONFIG_USE_SDMMC_CMD is not set */
+/* end of Third-Party Configuration */
+
+#endif
diff --git a/baremetal/example/gmac_test/configs/d2000_aarch32_eg_configs b/baremetal/example/gmac_test/configs/d2000_aarch32_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..16fe55983885daaf963e89f6570680b302081ae9
--- /dev/null
+++ b/baremetal/example/gmac_test/configs/d2000_aarch32_eg_configs
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a32"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+CONFIG_TARGET_ARMV8_AARCH32=y
+# CONFIG_TARGET_ARMV8_AARCH64 is not set
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+CONFIG_USE_AARCH64_L1_TO_AARCH32=y
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+# CONFIG_TARGET_E2000 is not set
+CONFIG_TARGET_D2000=y
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+# CONFIG_USE_SERIAL is not set
+# CONFIG_USE_GPIO is not set
+# CONFIG_USE_IOMUX is not set
+CONFIG_USE_ETH=y
+
+#
+# Eth Configuration
+#
+# CONFIG_ENABLE_F_XMAC is not set
+CONFIG_ENABLE_F_GMAC=y
+
+#
+# F_GMAC Configuration
+#
+# CONFIG_F_GMAC_PHY_COMMON is not set
+CONFIG_F_GMAC_PHY_AR803X=y
+# end of F_GMAC Configuration
+# end of Eth Configuration
+
+# CONFIG_USE_CAN is not set
+# CONFIG_USE_I2C is not set
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+CONFIG_AARCH32_RAM_LD=y
+# CONFIG_AARCH64_RAM_LD is not set
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_SIZE=0x1000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+# CONFIG_USE_LETTER_SHELL is not set
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/gmac_test/configs/d2000_aarch64_eg_configs b/baremetal/example/gmac_test/configs/d2000_aarch64_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..7b363bd5c0ea42787906f3d40de03e1fd6cb2c33
--- /dev/null
+++ b/baremetal/example/gmac_test/configs/d2000_aarch64_eg_configs
@@ -0,0 +1,120 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a64"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+# CONFIG_TARGET_E2000 is not set
+CONFIG_TARGET_D2000=y
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+# CONFIG_USE_SERIAL is not set
+# CONFIG_USE_GPIO is not set
+# CONFIG_USE_IOMUX is not set
+CONFIG_USE_ETH=y
+
+#
+# Eth Configuration
+#
+# CONFIG_ENABLE_F_XMAC is not set
+CONFIG_ENABLE_F_GMAC=y
+
+#
+# F_GMAC Configuration
+#
+# CONFIG_F_GMAC_PHY_COMMON is not set
+CONFIG_F_GMAC_PHY_AR803X=y
+# end of F_GMAC Configuration
+# end of Eth Configuration
+
+# CONFIG_USE_CAN is not set
+# CONFIG_USE_I2C is not set
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+# CONFIG_USE_LETTER_SHELL is not set
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/gmac_test/configs/ft2004_aarch32_eg_configs b/baremetal/example/gmac_test/configs/ft2004_aarch32_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..fa8878841c8334e856796eb20ae9ebbc20bdfe4e
--- /dev/null
+++ b/baremetal/example/gmac_test/configs/ft2004_aarch32_eg_configs
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="ft2004_baremetal_a32"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+CONFIG_TARGET_ARMV8_AARCH32=y
+# CONFIG_TARGET_ARMV8_AARCH64 is not set
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+CONFIG_USE_AARCH64_L1_TO_AARCH32=y
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+CONFIG_TARGET_F2000_4=y
+# CONFIG_TARGET_E2000 is not set
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+# CONFIG_USE_SERIAL is not set
+# CONFIG_USE_GPIO is not set
+# CONFIG_USE_IOMUX is not set
+CONFIG_USE_ETH=y
+
+#
+# Eth Configuration
+#
+# CONFIG_ENABLE_F_XMAC is not set
+CONFIG_ENABLE_F_GMAC=y
+
+#
+# F_GMAC Configuration
+#
+# CONFIG_F_GMAC_PHY_COMMON is not set
+CONFIG_F_GMAC_PHY_AR803X=y
+# end of F_GMAC Configuration
+# end of Eth Configuration
+
+# CONFIG_USE_CAN is not set
+# CONFIG_USE_I2C is not set
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+CONFIG_AARCH32_RAM_LD=y
+# CONFIG_AARCH64_RAM_LD is not set
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_SIZE=0x1000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+# CONFIG_USE_LETTER_SHELL is not set
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/gmac_test/configs/ft2004_aarch64_eg_configs b/baremetal/example/gmac_test/configs/ft2004_aarch64_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..c867e06ecda98b6d69c7c317347ebf4b12e63226
--- /dev/null
+++ b/baremetal/example/gmac_test/configs/ft2004_aarch64_eg_configs
@@ -0,0 +1,120 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="ft2004_baremetal_a64"
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+CONFIG_TARGET_F2000_4=y
+# CONFIG_TARGET_E2000 is not set
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+# CONFIG_USE_SERIAL is not set
+# CONFIG_USE_GPIO is not set
+# CONFIG_USE_IOMUX is not set
+CONFIG_USE_ETH=y
+
+#
+# Eth Configuration
+#
+# CONFIG_ENABLE_F_XMAC is not set
+CONFIG_ENABLE_F_GMAC=y
+
+#
+# F_GMAC Configuration
+#
+# CONFIG_F_GMAC_PHY_COMMON is not set
+CONFIG_F_GMAC_PHY_AR803X=y
+# end of F_GMAC Configuration
+# end of Eth Configuration
+
+# CONFIG_USE_CAN is not set
+# CONFIG_USE_I2C is not set
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+# CONFIG_USE_LETTER_SHELL is not set
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/gmac_test/makefile b/baremetal/example/gmac_test/makefile
index 422f76681d3e69b8c9015037363941887c53145b..d6ffdf88bc26eb25f43ac8b0b7a1890d7c2f808e 100644
--- a/baremetal/example/gmac_test/makefile
+++ b/baremetal/example/gmac_test/makefile
@@ -7,7 +7,11 @@ export USR_INC_DIR ?= . \
./inc
# 用户定义的编译目标文件上传路径
-USR_BOOT_DIR ?= /mnt/d/tftboot/
+ifeq ($(OS),Windows_NT)
+ USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp
+else
+ USR_BOOT_DIR ?= /mnt/d/phytium-dev/tftp
+endif
# 设置启动镜像名
BOOT_IMG_NAME ?= baremetal
@@ -15,8 +19,19 @@ BOOT_IMG_NAME ?= baremetal
# 指定编译freertos项目使用的makefile
include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk
+# 添加例程所需的配置(optional)
+USR_CONFIGS := USE_ETH=y \
+ ENABLE_F_GMAC=y \
+ F_GMAC_PHY_AR803X=y
+
# 完成编译
boot:
- make
+ make -j
@cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf
- @cp ./$(CONFIG_TARGET_NAME).bin $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).bin
+ @ls $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf -l
+
+build_all:
+ make build_ft2004_aarch32
+ make build_ft2004_aarch64
+ make build_d2000_aarch32
+ make build_d2000_aarch64
\ No newline at end of file
diff --git a/baremetal/example/gmac_test/sdkconfig b/baremetal/example/gmac_test/sdkconfig
index 17d24d095603b6387aca6964512b7edebf59bbb0..7b363bd5c0ea42787906f3d40de03e1fd6cb2c33 100644
--- a/baremetal/example/gmac_test/sdkconfig
+++ b/baremetal/example/gmac_test/sdkconfig
@@ -2,34 +2,31 @@
#
# Project Configuration
#
-CONFIG_TARGET_NAME="d2000_baremetal_a32"
+CONFIG_TARGET_NAME="d2000_baremetal_a64"
# end of Project Configuration
#
-# Board Setting
+# Platform Setting
#
#
# Arch Configuration
#
-CONFIG_TARGET_ARMV8_AARCH32=y
-# CONFIG_TARGET_ARMV8_AARCH64 is not set
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
# CONFIG_TARGET_ARMV7 is not set
CONFIG_USE_CACHE=y
CONFIG_USE_L3CACHE=y
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
-CONFIG_USE_AARCH64_L1_TO_AARCH32=y
# end of Arch Configuration
#
# Board Configuration
#
-CONFIG_TARGET_F2000_4=y
+# CONFIG_TARGET_F2000_4 is not set
# CONFIG_TARGET_E2000 is not set
-# CONFIG_TARGET_D2000 is not set
-# CONFIG_TARGET_EARY_UART0 is not set
-CONFIG_TARGET_EARY_UART1=y
+CONFIG_TARGET_D2000=y
# end of Board Configuration
#
@@ -67,12 +64,11 @@ CONFIG_F_GMAC_PHY_AR803X=y
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# end of Components Configuration
-# end of Board Setting
+# end of Platform Setting
#
# Building Option
#
-CONFIG_ENVI_UBUNTU_20_04=y
#
# Cross-Compiler Setting
@@ -83,16 +79,16 @@ CONFIG_COMPILER_NO_STD_STARUP=y
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
-CONFIG_LOG_INFO=y
+# CONFIG_LOG_INFO is not set
# CONFIG_LOG_WARN is not set
-# CONFIG_LOG_ERROR is not set
+CONFIG_LOG_ERROR=y
# CONFIG_LOG_NONE is not set
#
# Linker Options
#
-CONFIG_AARCH32_RAM_LD=y
-# CONFIG_AARCH64_RAM_LD is not set
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
# CONFIG_QEMU_AARCH32_RAM_LD is not set
# CONFIG_USER_DEFINED_LD is not set
CONFIG_LINK_SCRIPT_ROM=y
@@ -101,15 +97,16 @@ CONFIG_ROM_SIZE_MB=1
CONFIG_LINK_SCRIPT_RAM=y
CONFIG_RAM_START_UP_ADDR=0x81000000
CONFIG_RAM_SIZE_MB=64
-CONFIG_HEAP_SIZE=0x0400
-CONFIG_STACK_SIZE=0x1000
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
# end of Linker Options
# end of Building Option
#
# Library Configuration
#
-CONFIG_USE_LIBC=y
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
# end of Library Configuration
#
@@ -119,4 +116,5 @@ CONFIG_USE_LIBC=y
# CONFIG_USE_LETTER_SHELL is not set
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
# end of Third-Party Configuration
diff --git a/baremetal/example/gmac_test/sdkconfig.h b/baremetal/example/gmac_test/sdkconfig.h
index 4f89deb4ac1ccc1e2bccadeeb137b894d6bf2b14..37039b72175f23d33958da82ac6f3f22fd4b0f14 100644
--- a/baremetal/example/gmac_test/sdkconfig.h
+++ b/baremetal/example/gmac_test/sdkconfig.h
@@ -3,30 +3,27 @@
/* Project Configuration */
-#define CONFIG_TARGET_NAME "d2000_baremetal_a32"
+#define CONFIG_TARGET_NAME "d2000_baremetal_a64"
/* end of Project Configuration */
-/* Board Setting */
+/* Platform Setting */
/* Arch Configuration */
-#define CONFIG_TARGET_ARMV8_AARCH32
-/* CONFIG_TARGET_ARMV8_AARCH64 is not set */
+/* CONFIG_TARGET_ARMV8_AARCH32 is not set */
+#define CONFIG_TARGET_ARMV8_AARCH64
/* CONFIG_TARGET_ARMV7 is not set */
#define CONFIG_USE_CACHE
#define CONFIG_USE_L3CACHE
#define CONFIG_USE_MMU
/* CONFIG_USE_SYS_TICK is not set */
-#define CONFIG_USE_AARCH64_L1_TO_AARCH32
/* end of Arch Configuration */
/* Board Configuration */
-#define CONFIG_TARGET_F2000_4
+/* CONFIG_TARGET_F2000_4 is not set */
/* CONFIG_TARGET_E2000 is not set */
-/* CONFIG_TARGET_D2000 is not set */
-/* CONFIG_TARGET_EARY_UART0 is not set */
-#define CONFIG_TARGET_EARY_UART1
+#define CONFIG_TARGET_D2000
/* end of Board Configuration */
/* Components Configuration */
@@ -60,12 +57,10 @@
/* CONFIG_USE_DMA is not set */
/* CONFIG_USE_NAND is not set */
/* end of Components Configuration */
-/* end of Board Setting */
+/* end of Platform Setting */
/* Building Option */
-#define CONFIG_ENVI_UBUNTU_20_04
-
/* Cross-Compiler Setting */
#define CONFIG_COMPILER_NO_STD_STARUP
@@ -73,15 +68,15 @@
/* end of Cross-Compiler Setting */
/* CONFIG_LOG_VERBOS is not set */
/* CONFIG_LOG_DEBUG is not set */
-#define CONFIG_LOG_INFO
+/* CONFIG_LOG_INFO is not set */
/* CONFIG_LOG_WARN is not set */
-/* CONFIG_LOG_ERROR is not set */
+#define CONFIG_LOG_ERROR
/* CONFIG_LOG_NONE is not set */
/* Linker Options */
-#define CONFIG_AARCH32_RAM_LD
-/* CONFIG_AARCH64_RAM_LD is not set */
+/* CONFIG_AARCH32_RAM_LD is not set */
+#define CONFIG_AARCH64_RAM_LD
/* CONFIG_QEMU_AARCH32_RAM_LD is not set */
/* CONFIG_USER_DEFINED_LD is not set */
#define CONFIG_LINK_SCRIPT_ROM
@@ -90,14 +85,15 @@
#define CONFIG_LINK_SCRIPT_RAM
#define CONFIG_RAM_START_UP_ADDR 0x81000000
#define CONFIG_RAM_SIZE_MB 64
-#define CONFIG_HEAP_SIZE 0x0400
-#define CONFIG_STACK_SIZE 0x1000
+#define CONFIG_HEAP_SIZE 0x04000
+#define CONFIG_STACK_TOP_ADDR 0x82000000
/* end of Linker Options */
/* end of Building Option */
/* Library Configuration */
-#define CONFIG_USE_LIBC
+#define CONFIG_USE_G_LIBC
+/* CONFIG_USE_NEW_LIBC is not set */
/* end of Library Configuration */
/* Third-Party Configuration */
@@ -106,6 +102,7 @@
/* CONFIG_USE_LETTER_SHELL is not set */
/* CONFIG_USE_AMP is not set */
/* CONFIG_USE_YAFFS2 is not set */
+/* CONFIG_USE_SDMMC_CMD is not set */
/* end of Third-Party Configuration */
#endif
diff --git a/baremetal/example/gmac_test/test_gmac.c b/baremetal/example/gmac_test/test_gmac.c
index b49397a3241ec35ee1181c3b0ef4ef4c5eaecc50..79131376de05c336bc597c48a59e9a6bbd416576 100644
--- a/baremetal/example/gmac_test/test_gmac.c
+++ b/baremetal/example/gmac_test/test_gmac.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-08-23 17:30:57
- * @LastEditTime: 2021-08-25 15:58:02
+ * @LastEditTime: 2021-10-29 08:13:33
* @Description: This files is for
*
* @Modify History:
@@ -71,7 +71,7 @@ void EthLowLevelInput(GmacCtrl *pCtrl)
printf("frame received\r\n");
bufIdx = pCtrl->rxRing.descBufIdx;
length = (pCtrl->rxDesc[bufIdx].status & GMAC_DMA_RDES0_FRAME_LEN_MASK) >> GMAC_DMA_RDES0_FRAME_LEN_SHIFT;
- pRxBuf = (u8 *)pCtrl->rxDesc[bufIdx].buf1Addr;
+ pRxBuf = (u8 *)(uintptr)pCtrl->rxDesc[bufIdx].buf1Addr;
FtDumpHexWord((u32 *)pRxBuf, length);
/* give tx buf to DMA */
diff --git a/baremetal/example/i2c_eeprom/Kconfig b/baremetal/example/i2c_eeprom/Kconfig
deleted file mode 100644
index f85ee78f07a3268478f8c03feb7ba122af78c165..0000000000000000000000000000000000000000
--- a/baremetal/example/i2c_eeprom/Kconfig
+++ /dev/null
@@ -1,24 +0,0 @@
-mainmenu "Phytium Baremetal Configuration"
-
-menu "Project Configuration"
- config TARGET_NAME
- string "Build Target Name"
- default "baremetal"
- help
- Build Target name for the demo
-
- choice I2C_TEST_ITME
- prompt "I2C Test Item"
- default I2C_MASTER_SLAVE
-
- config I2C_MASTER_EEPROM
- bool
- prompt "I2C Master Write/Read EEPROM"
-
- config I2C_MASTER_SLAVE
- bool
- prompt "I2C Master Write/Read Slave"
- endchoice # I2C_TEST_ITME
-endmenu
-
-source "$(STANDALONE_SDK_ROOT)/Kconfig"
\ No newline at end of file
diff --git a/baremetal/example/i2c_eeprom/README.md b/baremetal/example/i2c_eeprom/README.md
deleted file mode 100644
index 8ff00d5e76ffaf552c8795c55fe67445716ce211..0000000000000000000000000000000000000000
--- a/baremetal/example/i2c_eeprom/README.md
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-# host侧设置
-- 重启host侧tftp服务器
-```
-sudo service tftpd-hpa restart
-```
-
-# 开发板侧设置
-
-## 使用go命令跳转
-- 关闭D-cache和I-cache
-```
-icache off
-dcache off
-```
-
-- 下载新版本到FT2000-4
-```
-setenv ipaddr 192.168.4.20
-setenv serverip 192.168.4.50
-setenv gatewayip 192.168.4.1
-tftpboot 0x80100000 ft2004_baremetal.bin
-dcache flush
-go 0x80100000
-```
-
-## 使用bootvx32命令跳转
-- 下载新版本到FT2000-4
-```
-setenv ipaddr 192.168.4.20
-setenv serverip 192.168.4.50
-setenv gatewayip 192.168.4.1
-tftpboot 80100000 ft2004_baremetal.bin
-bootvx32
-```
-
-# 使用bootelf命令跳转
-```
-setenv ipaddr 192.168.4.20
-setenv serverip 192.168.4.50
-setenv gatewayip 192.168.4.1
-tftpboot 0x90100000 baremetal.elf
-bootelf -p 0x90100000
-```
diff --git a/baremetal/example/i2c_eeprom/eeprom.c b/baremetal/example/i2c_eeprom/eeprom.c
deleted file mode 100644
index 69d8633a4c5a749ec96d6f8649d4435187394ac9..0000000000000000000000000000000000000000
--- a/baremetal/example/i2c_eeprom/eeprom.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2021 Phytium Information Technology, Inc.
- *
- * SPDX-License-Identifier: Apache-2.0.
- *
- * @Date: 2021-07-28 16:17:48
- * @LastEditTime: 2021-08-03 17:10:50
- * @Description: This files is for
- *
- * @Modify History:
- * Ver Who Date Changes
- * ----- ------ -------- --------------------------------------
- */
-#include
-#include "ft_debug.h"
-#include "dw_i2c.h"
-#include "dw_i2c_hw.h"
-#include "eeprom.h"
-#include "fsleep.h"
-
-#define BUF_LEN 64
-static u8 readBuf[BUF_LEN] __attribute__ ((aligned (4)));
-static u8 writeBuf[BUF_LEN] __attribute__((aligned(4))) =
- //"test i2c eeprom 2021-8-2 9:39";
- "0123456701234567012345670123456701234567";
-
-#define TEST_READ 1
-#define TEST_WRITE 1
-
-void I2cEeMasterWR()
-{
- u32 ret = I2C_SUCCESS;
- u32 slaveAddr = AT24C02_ADDR | AT24C02_CHIP_SEL;
- u32 offset = 0x00;
-
- printf("i2c eeprom read/write test....\r\n");
-
- memset(readBuf, 0, BUF_LEN);
- ret |= I2cEeMasterInit();
-
- if (I2C_SUCCESS == ret)
- {
- printf("write buf is \r\n");
- FtDumpHexByte(writeBuf, BUF_LEN);
- ret = I2cEeMasterWrite(slaveAddr, offset, writeBuf, BUF_LEN);
- printf("i2c write test result: 0x%x\r\n", ret);
- }
-
- fsleep_millisec(2000);
-
- if (I2C_SUCCESS == ret)
- {
- ret = I2cEeMasterRead(slaveAddr, offset, readBuf, BUF_LEN);
- printf("i2c read test result: 0x%x\r\n", ret);
- printf("read buf is \r\n");
- FtDumpHexByte(readBuf, BUF_LEN);
- }
-
- printf("test finished result: 0x%x", ret);
- while(1)
- {
-
- }
-}
-
-void I2cEeMaster2Slave()
-{
- u32 ret = I2C_SUCCESS;
- u32 slaveAddr = 0x0;
- u8 offset = 0x0;
-
- printf("i2c master/slave read/write test....\r\n");
-
- memset(readBuf, 0, BUF_LEN);
-
- ret |= I2cEeMasterInit();
- ret |= I2cEeSlaveInit();
-
- if (I2C_SUCCESS != ret)
- {
- printf("init failed !!!\r\n");
- return;
- }
-
- ret |= I2cEeMasterWrite(slaveAddr, offset, writeBuf, 0x16/*sizeof(writeBuf)*/);
- fsleep_millisec(2000);
- I2cEeSlaveReadBuf();
-
- if (I2C_SUCCESS == ret)
- {
- ret = I2cEeMasterRead(slaveAddr, offset, readBuf, 0x16);
- FtDumpHexByte(readBuf, 0x16);
- }
-
- printf("test finished result: 0x%x", ret);
- fsleep_millisec(1000);
- while(1)
- {
- fsleep_millisec(10);
- }
-}
\ No newline at end of file
diff --git a/baremetal/example/i2c_eeprom/eeprom_master.c b/baremetal/example/i2c_eeprom/eeprom_master.c
deleted file mode 100644
index 261f84f7e6d26c2efd51d1f623a017dd1b19538d..0000000000000000000000000000000000000000
--- a/baremetal/example/i2c_eeprom/eeprom_master.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 2021 Phytium Information Technology, Inc.
- *
- * SPDX-License-Identifier: Apache-2.0.
- *
- * @Date: 2021-07-28 15:33:35
- * @LastEditTime: 2021-08-04 08:30:32
- * @Description: This files is for
- *
- * @Modify History:
- * Ver Who Date Changes
- * ----- ------ -------- --------------------------------------
- */
-#include
-#include "sdkconfig.h"
-#include "parameters.h"
-#include "ft_assert.h"
-#include "dw_i2c.h"
-#include "dw_i2c_hw.h"
-#include "eeprom.h"
-#include "fsleep.h"
-
-#define EEPROM_LEN 128
-
-typedef struct
-{
- I2cCtrl master;
- u8 buf[EEPROM_LEN];
- u32 bufIdx;
- u32 bufLen;
-} I2cEepromMaster;
-
-I2cEepromMaster masterEeprom;
-
-static u32 I2cEeWriteRaw(I2cCtrl *pCtrl, I2cTransPack *pack)
-{
- FT_ASSERTZERONUM(pCtrl && pack);
- u32 ret = I2C_SUCCESS;
-
- if (pack->bufLen > AT24C02_BLK_SIZE)
- {
- return I2C_ERR_NOT_SUPPORT;
- }
-
- ret = I2cMasterWrite(pCtrl, pack);
- fsleep_millisec(200); /* wait write finish */
- return ret;
-}
-
-void I2cEeMasterReadDoneCB(void *pPara)
-{
- FT_ASSERTVOID(pPara);
- I2cCtrl *pCtrl = (I2cCtrl *)pPara;
- FT_ASSERTVOID(pCtrl->prv);
- I2cEepromMaster *pEeprom = (I2cEepromMaster *)pCtrl->prv;
- s32 rxValid;
-
- I2C_INFO("Master Read Done");
-
- rxValid = I2C_READ_REG32(pCtrl, I2C_RXFLR_OFFSET);
- while ((pEeprom->bufIdx < pEeprom->bufLen) && (rxValid > 0))
- {
- pEeprom->buf[pEeprom->bufIdx] = (I2C_DATA_MASK & I2C_READ_DATCMD(pCtrl));
- pEeprom->bufIdx++;
- rxValid--;
- fsleep_millisec(2);
-
- if (pEeprom->bufIdx != pEeprom->bufLen)
- {
- I2C_WRITE_DATCMD(pCtrl, I2C_DATA_CMD_RESTART | I2C_DATA_CMD_READ);
- }
- else
- {
- I2C_WRITE_DATCMD(pCtrl, I2C_DATA_CMD_STOP | I2C_DATA_CMD_READ);
- fsleep_millisec(2);
- I2cSetIntrruptMask(pCtrl, I2C_INTR_RX_FULL, FALSE);
- }
- }
-}
-
-void I2cEeMasterWriteDoneCB(void *pPara)
-{
- FT_ASSERTVOID(pPara);
- I2cCtrl *pCtrl = (I2cCtrl *)pPara;
- FT_ASSERTVOID(pCtrl->prv);
- I2cEepromMaster *pEeprom = (I2cEepromMaster *)pCtrl->prv;
-
- I2C_INFO("Write Done");
-
- if (pEeprom->bufIdx == pEeprom->bufLen)
- {
- I2C_WRITE_DATCMD(pCtrl, I2C_DATA_CMD_STOP);
- fsleep_millisec(2);
- I2cSetIntrruptMask(pCtrl, I2C_INTR_TX_EMPTY, FALSE);
- }
- else
- {
- I2C_WRITE_DATCMD(pCtrl, (I2C_DATA_MASK & pEeprom->buf[pEeprom->bufIdx]));
- fsleep_millisec(2);
- pEeprom->bufIdx++;
- }
-}
-
-static u32 I2cEeReadRaw(I2cCtrl *pCtrl, I2cTransPack *pack)
-{
- return I2cMasterRead(pCtrl, pack);
-}
-
-u32 I2cEeMasterWrite(u32 slaveAddr, u8 offset, u8 *pBuf, u32 bufLen)
-{
- I2cEepromMaster *pEeprom = &masterEeprom;
- I2cCtrl *pCtrl = &pEeprom->master;
- I2cTransPack pack;
- u32 ret = I2C_SUCCESS;
- const u8 transSize = AT24C02_BLK_SIZE;
- const u32 transTimes = bufLen / transSize;
- const u32 lastTransLen = bufLen % transSize;
- u8 loop;
- pCtrl->prv = pEeprom;
-
- memset(&pack, 0, sizeof(pack));
- pack.slaveAddr = slaveAddr;
- pack.addrLen = 1; /* use u8 offset */
-
- for (loop = 0; loop < transTimes; loop++)
- {
- pack.transBuf = pBuf + loop * transSize;
- pack.bufLen = transSize;
- pack.inChipAddr = offset + loop * transSize;
- I2C_INFO("write %d buf 0x%x len 0x%x", loop, pack.transBuf, pack.bufLen);
- ret = I2cEeWriteRaw(pCtrl, &pack);
-
- if (I2C_SUCCESS != ret)
- return ret;
- }
-
- if (0 != lastTransLen)
- {
- pack.transBuf = pBuf + transTimes * transSize;
- pack.bufLen = lastTransLen;
- pack.inChipAddr = offset + transTimes * transSize;
- I2C_INFO("write last buf 0x%x len 0x%x", pack.transBuf, pack.bufLen);
- ret = I2cEeWriteRaw(pCtrl, &pack);
- }
-
- return ret;
-}
-
-u32 I2cEeMasterRead(u32 slaveAddr, u8 offset, u8 *pBuf, u32 bufLen)
-{
- I2cEepromMaster *pEeprom = &masterEeprom;
- I2cCtrl *pCtrl = &pEeprom->master;
- I2cTransPack pack;
- u32 ret = I2C_SUCCESS;
- const u8 transSize = bufLen; //6; //4; //AT24C02_BLK_SIZE - 1;
- const u32 transTimes = bufLen / transSize;
- const u32 lastTransLen = bufLen % transSize;
- u8 loop;
- pCtrl->prv = pEeprom;
-
- memset(&pack, 0, sizeof(pack));
- pack.slaveAddr = slaveAddr;
- pack.addrLen = 1; /* use u8 offset */
-
- for (loop = 0; loop < transTimes; loop++)
- {
- pack.transBuf = pBuf + loop * transSize;
- pack.bufLen = transSize;
- pack.inChipAddr = offset + loop * transSize;
-
- ret = I2cEeReadRaw(pCtrl, &pack);
- if (I2C_SUCCESS != ret)
- return ret;
- }
-
- if (0 != lastTransLen)
- {
- pack.transBuf = pBuf + transTimes * transSize;
- pack.bufLen = lastTransLen;
- pack.inChipAddr = offset + transTimes * transSize;
- ret = I2cEeReadRaw(pCtrl, &pack);
- }
-
- return ret;
-}
-
-u32 I2cEeMasterInit()
-{
- I2cEepromMaster *pEeprom = &masterEeprom;
- I2cCtrl *pCtrl = &pEeprom->master;
- u32 i2cId = I2C_INSTANCE_0;
- u32 ret = I2C_SUCCESS;
-
- pEeprom->bufIdx = 0;
- pEeprom->bufLen = EEPROM_LEN;
-
- memset(pCtrl, 0, sizeof(I2cCtrl));
- pCtrl->config = *I2cLookupConfig(i2cId);
- ret = I2cInit(pCtrl, &pCtrl->config);
- I2C_INFO("i2c init result : 0x%x", ret);
- if (I2C_SUCCESS != ret)
- return ret;
-
- pCtrl->prv = pEeprom;
-
- I2cRegisterEvtCallback(pCtrl, I2C_EVT_MASTER_READ_DONE, I2cEeMasterReadDoneCB);
- I2cRegisterEvtCallback(pCtrl, I2C_EVT_MASTER_WRITE_DONE, I2cEeMasterWriteDoneCB);
-
- return ret;
-}
\ No newline at end of file
diff --git a/baremetal/example/i2c_eeprom/eeprom_slave.c b/baremetal/example/i2c_eeprom/eeprom_slave.c
deleted file mode 100644
index a6a7d1e14c73625f0c75adfb414f16cdbb1559ad..0000000000000000000000000000000000000000
--- a/baremetal/example/i2c_eeprom/eeprom_slave.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2021 Phytium Information Technology, Inc.
- *
- * SPDX-License-Identifier: Apache-2.0.
- *
- * @Date: 2021-07-26 16:27:32
- * @LastEditTime: 2021-08-04 08:30:59
- * @Description: This files is for
- *
- * @Modify History:
- * Ver Who Date Changes
- * ----- ------ -------- --------------------------------------
- */
-#include
-#include "sdkconfig.h"
-#include "parameters.h"
-#include "ft_assert.h"
-#include "dw_i2c.h"
-#include "dw_i2c_hw.h"
-
-#define EEPROM_LEN 128
-typedef struct
-{
- I2cCtrl slave;
- boolean firstWrite;
- u8 buf[EEPROM_LEN];
- u32 bufIdx;
-} I2cEepromSlave;
-
-I2cEepromSlave slaveEeprom;
-
-void I2cEeSlaveWriteReceivedCB(void *pPara)
-{
- FT_ASSERTVOID(pPara);
- I2cCtrl *pCtrl = (I2cCtrl *)pPara;
- I2cEepromSlave *pEeprom = (I2cEepromSlave *)pCtrl->prv;
-
- if (pEeprom->firstWrite)
- {
- pEeprom->bufIdx = pCtrl->curTrans; /* send slave addr in first write */
- pEeprom->firstWrite = FALSE;
- }
- else
- {
- I2C_INFO("buf[0x%x]: 0x%x", pEeprom->bufIdx, pCtrl->curTrans);
- pEeprom->buf[pEeprom->bufIdx++] = pCtrl->curTrans;
- }
-
- return;
-}
-
-void I2cEeSlaveReadRequested(void *pPara)
-{
- FT_ASSERTVOID(pPara);
- I2cCtrl *pCtrl = (I2cCtrl *)pPara;
- I2cEepromSlave *pEeprom = (I2cEepromSlave *)pCtrl->prv;
-
- /*
- * Do not increment bufIdx here, because we don't know if
- * this byte will be actually used. Read Linux I2C slave docs
- * for details.
- */
- pCtrl->curTrans = pEeprom->buf[pEeprom->bufIdx];
-
- return;
-}
-
-void I2cEeSlaveReadProcessed(void *pPara)
-{
- FT_ASSERTVOID(pPara);
- I2cCtrl *pCtrl = (I2cCtrl *)pPara;
- I2cEepromSlave *pEeprom = (I2cEepromSlave *)pCtrl->prv;
-
- I2C_INFO("Slave ReadProcessed");
-
- /* The previous byte made it to the bus, get next one */
- pEeprom->bufIdx++;
- I2cEeSlaveReadRequested(pPara);/* fallthrough */
-
- return;
-}
-
-void I2cEeSlaveStop(void *pPara)
-{
- FT_ASSERTVOID(pPara);
- I2cCtrl *pCtrl = (I2cCtrl *)pPara;
- I2cEepromSlave *pEeprom = (I2cEepromSlave *)pCtrl->prv;
-
- I2C_INFO("Slave Stop");
-
- pEeprom->firstWrite = TRUE;
- return;
-}
-
-void I2cEeSlaveWriteRequested(void *pPara)
-{
- FT_ASSERTVOID(pPara);
- I2cCtrl *pCtrl = (I2cCtrl *)pPara;
- I2cEepromSlave *pEeprom = (I2cEepromSlave *)pCtrl->prv;
-
- I2C_INFO("Slave WriteRequested");
-
- I2cEeSlaveStop(pPara);
- return;
-}
-
-u32 I2cEeSlaveInit()
-{
- I2cEepromSlave *pEeprom = &slaveEeprom;
- I2cCtrl *pCtrl = &pEeprom->slave;
- u32 i2cId = I2C_INSTANCE_1;
- u32 ret = I2C_SUCCESS;
-
- memset(pEeprom, 0, sizeof(I2cEepromSlave));
-
- pCtrl->config = *I2cLookupConfig(i2cId);
- ret = I2cInit(pCtrl, &pCtrl->config);
- if (I2C_SUCCESS != ret)
- return ret;
-
- pCtrl->prv = pEeprom;
-
- pEeprom->firstWrite = TRUE;
- I2cRegisterEvtCallback(pCtrl, I2C_EVT_SLAVE_READ_REQUESTED, I2cEeSlaveReadRequested);
- I2cRegisterEvtCallback(pCtrl, I2C_EVT_SLAVE_WRITE_REQUESTED, I2cEeSlaveWriteRequested);
- I2cRegisterEvtCallback(pCtrl, I2C_EVT_SLAVE_READ_PROCESSED, I2cEeSlaveReadProcessed);
- I2cRegisterEvtCallback(pCtrl, I2C_EVT_SLAVE_WRITE_RECEIVED, I2cEeSlaveWriteReceivedCB);
- I2cRegisterEvtCallback(pCtrl, I2C_EVT_SLAVE_STOP, I2cEeSlaveStop);
-
- I2cDumpInfo(pCtrl);
-
- return ret;
-}
-
-void I2cEeSlaveReadBuf()
-{
- I2cEepromSlave *pEeprom = &slaveEeprom;
- I2cCtrl *pCtrl = &pEeprom->slave;
-
- FtDumpHexByte(pEeprom->buf, EEPROM_LEN);
-}
\ No newline at end of file
diff --git a/baremetal/example/letter_shell_test/README.md b/baremetal/example/letter_shell_test/README.md
index 6a58eb18931e2ff316585abbca0593b2e1374d3e..15ea412a1f92a634a7f5a2d4b1e4ea85e6ef39a5 100644
--- a/baremetal/example/letter_shell_test/README.md
+++ b/baremetal/example/letter_shell_test/README.md
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-08-27 10:37:27
- * @LastEditTime: 2021-09-07 08:39:52
+ * @LastEditTime: 2021-10-29 09:12:19
* @Description: This files is for
*
* @Modify History:
@@ -126,5 +126,6 @@ bootelf -p 0x90100000
>记录例程的重大修改记录,标明修改发生的版本号
- 2021-09-07 :v0.1.0 添加example
+- 2021-10-29 : v0.1.8 修改makefile
diff --git a/configs/d2000_aarch32_amp_slave_defconfig b/baremetal/example/letter_shell_test/configs/d2000_aarch32_eg_configs
similarity index 67%
rename from configs/d2000_aarch32_amp_slave_defconfig
rename to baremetal/example/letter_shell_test/configs/d2000_aarch32_eg_configs
index c625c14210d580a9fed0fb5ef6823721dd18cd97..5b734063a0a16cc266ddf4d2fb3a786d0d2d72ac 100644
--- a/configs/d2000_aarch32_amp_slave_defconfig
+++ b/baremetal/example/letter_shell_test/configs/d2000_aarch32_eg_configs
@@ -1,16 +1,14 @@
#
-# Slave Core Configuration
-#
-CONFIG_TARGET_NAME="d2000_baremetal_slave"
-CONFIG_SLAVE_CORE_0=y
-# CONFIG_SLAVE_CORE_1 is not set
-# CONFIG_SLAVE_CORE_2 is not set
-# CONFIG_SLAVE_CORE_3 is not set
-# end of Slave Core Configuration
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a32"
+# CONFIG_UART_DRIVER_TEST is not set
+CONFIG_SHELL_START_UP_TEST=y
+# end of Project Configuration
#
-# Board Setting
+# Platform Setting
#
#
@@ -23,18 +21,7 @@ CONFIG_USE_CACHE=y
CONFIG_USE_L3CACHE=y
CONFIG_USE_MMU=y
# CONFIG_USE_SYS_TICK is not set
-CONFIG_USE_BAREMETAL_AMP=y
-
-#
-# Baremetal AMP Setting
-#
-# CONFIG_TARGET_AMP_MASTER is not set
-CONFIG_TARGET_AMP_SLAVE=y
-CONFIG_TARGET_AMP_SLAVE_CORE0=y
-# CONFIG_TARGET_AMP_SLAVE_CORE1 is not set
-# CONFIG_TARGET_AMP_SLAVE_CORE2 is not set
-# CONFIG_TARGET_AMP_SLAVE_CORE3 is not set
-# end of Baremetal AMP Setting
+CONFIG_USE_AARCH64_L1_TO_AARCH32=y
# end of Arch Configuration
#
@@ -68,14 +55,15 @@ CONFIG_ENABLE_Pl011_UART=y
# CONFIG_USE_TIMER is not set
# CONFIG_USE_SDMMC is not set
# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
# end of Components Configuration
-# end of Board Setting
+# end of Platform Setting
#
# Building Option
#
-CONFIG_ENVI_LINUX_X86_64=y
#
# Cross-Compiler Setting
@@ -86,25 +74,25 @@ CONFIG_COMPILER_NO_STD_STARUP=y
# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
-CONFIG_LOG_INFO=y
+# CONFIG_LOG_INFO is not set
# CONFIG_LOG_WARN is not set
-# CONFIG_LOG_ERROR is not set
+CONFIG_LOG_ERROR=y
# CONFIG_LOG_NONE is not set
#
# Linker Options
#
-# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH32_RAM_LD=y
# CONFIG_AARCH64_RAM_LD is not set
-# CONFIG_AARCH32_AMP_RAM_MASTER_LD is not set
-CONFIG_AARCH32_AMP_RAM_SLAVE_LD=y
# CONFIG_QEMU_AARCH32_RAM_LD is not set
# CONFIG_USER_DEFINED_LD is not set
-# CONFIG_LINK_SCRIPT_ROM is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
CONFIG_LINK_SCRIPT_RAM=y
-CONFIG_RAM_START_UP_ADDR=0x82100000
+CONFIG_RAM_START_UP_ADDR=0x81000000
CONFIG_RAM_SIZE_MB=64
-CONFIG_HEAP_SIZE=0x0400
+CONFIG_HEAP_SIZE=0x04000
CONFIG_STACK_SIZE=0x1000
# end of Linker Options
# end of Building Option
@@ -113,6 +101,7 @@ CONFIG_STACK_SIZE=0x1000
# Library Configuration
#
CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
# end of Library Configuration
#
@@ -126,4 +115,8 @@ CONFIG_USE_LETTER_SHELL=y
#
CONFIG_LS_PL011_UART=y
# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
# end of Third-Party Configuration
diff --git a/baremetal/example/letter_shell_test/configs/d2000_aarch64_eg_configs b/baremetal/example/letter_shell_test/configs/d2000_aarch64_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..ff14fdc519bc579e1a39cc31af3615b0a7d21308
--- /dev/null
+++ b/baremetal/example/letter_shell_test/configs/d2000_aarch64_eg_configs
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="d2000_baremetal_a64"
+# CONFIG_UART_DRIVER_TEST is not set
+CONFIG_SHELL_START_UP_TEST=y
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+# CONFIG_TARGET_E2000 is not set
+CONFIG_TARGET_D2000=y
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+# CONFIG_USE_IOMUX is not set
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+# CONFIG_USE_I2C is not set
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/letter_shell_test/configs/e2000_aarch32_eg_configs b/baremetal/example/letter_shell_test/configs/e2000_aarch32_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..0b9017af8f97dcc7dc7e197d95d3f07b221d306f
--- /dev/null
+++ b/baremetal/example/letter_shell_test/configs/e2000_aarch32_eg_configs
@@ -0,0 +1,122 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="e2000_baremetal_a32"
+# CONFIG_UART_DRIVER_TEST is not set
+CONFIG_SHELL_START_UP_TEST=y
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+CONFIG_TARGET_ARMV8_AARCH32=y
+# CONFIG_TARGET_ARMV8_AARCH64 is not set
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+CONFIG_USE_AARCH64_L1_TO_AARCH32=y
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+CONFIG_TARGET_E2000=y
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+# CONFIG_USE_IOMUX is not set
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+# CONFIG_USE_I2C is not set
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+CONFIG_AARCH32_RAM_LD=y
+# CONFIG_AARCH64_RAM_LD is not set
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_SIZE=0x1000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/letter_shell_test/configs/e2000_aarch64_eg_configs b/baremetal/example/letter_shell_test/configs/e2000_aarch64_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..4b96eacbc6992aeb93e5cdaa0a6daabbd9d3d067
--- /dev/null
+++ b/baremetal/example/letter_shell_test/configs/e2000_aarch64_eg_configs
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="e2000_baremetal_a64"
+# CONFIG_UART_DRIVER_TEST is not set
+CONFIG_SHELL_START_UP_TEST=y
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+# CONFIG_TARGET_F2000_4 is not set
+CONFIG_TARGET_E2000=y
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+# CONFIG_USE_IOMUX is not set
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+# CONFIG_USE_I2C is not set
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/letter_shell_test/configs/ft2004_aarch32_eg_configs b/baremetal/example/letter_shell_test/configs/ft2004_aarch32_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..2e87d80c5ef78539cae69e63d5889fe74d196651
--- /dev/null
+++ b/baremetal/example/letter_shell_test/configs/ft2004_aarch32_eg_configs
@@ -0,0 +1,122 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="ft2004_baremetal_a32"
+# CONFIG_UART_DRIVER_TEST is not set
+CONFIG_SHELL_START_UP_TEST=y
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+CONFIG_TARGET_ARMV8_AARCH32=y
+# CONFIG_TARGET_ARMV8_AARCH64 is not set
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+CONFIG_USE_AARCH64_L1_TO_AARCH32=y
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+CONFIG_TARGET_F2000_4=y
+# CONFIG_TARGET_E2000 is not set
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+# CONFIG_USE_IOMUX is not set
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+# CONFIG_USE_I2C is not set
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+CONFIG_AARCH32_RAM_LD=y
+# CONFIG_AARCH64_RAM_LD is not set
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_SIZE=0x1000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/letter_shell_test/configs/ft2004_aarch64_eg_configs b/baremetal/example/letter_shell_test/configs/ft2004_aarch64_eg_configs
new file mode 100644
index 0000000000000000000000000000000000000000..2bc9f8ab6d6593c0fcdf63fad40051dc3cd5a40c
--- /dev/null
+++ b/baremetal/example/letter_shell_test/configs/ft2004_aarch64_eg_configs
@@ -0,0 +1,121 @@
+
+#
+# Project Configuration
+#
+CONFIG_TARGET_NAME="ft2004_baremetal_a64"
+# CONFIG_UART_DRIVER_TEST is not set
+CONFIG_SHELL_START_UP_TEST=y
+# end of Project Configuration
+
+#
+# Platform Setting
+#
+
+#
+# Arch Configuration
+#
+# CONFIG_TARGET_ARMV8_AARCH32 is not set
+CONFIG_TARGET_ARMV8_AARCH64=y
+# CONFIG_TARGET_ARMV7 is not set
+CONFIG_USE_CACHE=y
+CONFIG_USE_L3CACHE=y
+CONFIG_USE_MMU=y
+# CONFIG_USE_SYS_TICK is not set
+# end of Arch Configuration
+
+#
+# Board Configuration
+#
+CONFIG_TARGET_F2000_4=y
+# CONFIG_TARGET_E2000 is not set
+# CONFIG_TARGET_D2000 is not set
+# end of Board Configuration
+
+#
+# Components Configuration
+#
+# CONFIG_USE_SPI is not set
+# CONFIG_USE_QSPI is not set
+CONFIG_USE_GIC=y
+CONFIG_EBABLE_GICV3=y
+CONFIG_USE_SERIAL=y
+
+#
+# Usart Configuration
+#
+CONFIG_ENABLE_Pl011_UART=y
+# end of Usart Configuration
+
+# CONFIG_USE_GPIO is not set
+# CONFIG_USE_IOMUX is not set
+# CONFIG_USE_ETH is not set
+# CONFIG_USE_CAN is not set
+# CONFIG_USE_I2C is not set
+# CONFIG_USE_TIMER is not set
+# CONFIG_USE_SDMMC is not set
+# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
+# CONFIG_USE_DMA is not set
+# CONFIG_USE_NAND is not set
+# end of Components Configuration
+# end of Platform Setting
+
+#
+# Building Option
+#
+
+#
+# Cross-Compiler Setting
+#
+CONFIG_COMPILER_NO_STD_STARUP=y
+# CONFIG_USE_EXT_COMPILER is not set
+# end of Cross-Compiler Setting
+
+# CONFIG_LOG_VERBOS is not set
+# CONFIG_LOG_DEBUG is not set
+# CONFIG_LOG_INFO is not set
+# CONFIG_LOG_WARN is not set
+CONFIG_LOG_ERROR=y
+# CONFIG_LOG_NONE is not set
+
+#
+# Linker Options
+#
+# CONFIG_AARCH32_RAM_LD is not set
+CONFIG_AARCH64_RAM_LD=y
+# CONFIG_QEMU_AARCH32_RAM_LD is not set
+# CONFIG_USER_DEFINED_LD is not set
+CONFIG_LINK_SCRIPT_ROM=y
+CONFIG_ROM_START_UP_ADDR=0x80100000
+CONFIG_ROM_SIZE_MB=1
+CONFIG_LINK_SCRIPT_RAM=y
+CONFIG_RAM_START_UP_ADDR=0x81000000
+CONFIG_RAM_SIZE_MB=64
+CONFIG_HEAP_SIZE=0x04000
+CONFIG_STACK_TOP_ADDR=0x82000000
+# end of Linker Options
+# end of Building Option
+
+#
+# Library Configuration
+#
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
+# end of Library Configuration
+
+#
+# Third-Party Configuration
+#
+# CONFIG_USE_LWIP is not set
+CONFIG_USE_LETTER_SHELL=y
+
+#
+# Letter Shell Configuration
+#
+CONFIG_LS_PL011_UART=y
+# end of Letter Shell Configuration
+
+# CONFIG_USE_AMP is not set
+# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
+# end of Third-Party Configuration
diff --git a/baremetal/example/letter_shell_test/makefile b/baremetal/example/letter_shell_test/makefile
index ab81bd11210e9c305b80e084473e85256487580f..1add6bf1212602fbac831c0ff6dbe77b30e02433 100644
--- a/baremetal/example/letter_shell_test/makefile
+++ b/baremetal/example/letter_shell_test/makefile
@@ -5,16 +5,31 @@ export USR_SRC_DIR ?= .
export USR_INC_DIR ?= .
# 用户定义的编译目标文件上传路径
-USR_BOOT_DIR ?= /mnt/d/tftboot/
+ifeq ($(OS),Windows_NT)
+ USR_BOOT_DIR ?= $(subst \,/, $(PHYTIUM_DEV_PATH))/tftp
+else
+ USR_BOOT_DIR ?= /mnt/d/phytium-dev/tftp
+endif
+
+# 指定编译freertos项目使用的makefile
+include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk
# 设置启动镜像名
BOOT_IMG_NAME ?= baremetal
-# 指定编译freertos项目使用的makefile
-include $(STANDALONE_SDK_ROOT)/make/build_baremetal.mk
+# 添加例程所需的配置(optional)
+USR_CONFIGS := USE_LETTER_SHELL=y
# 完成编译
boot:
- make
- # @cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf
- @cp ./$(CONFIG_TARGET_NAME).bin $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).bin
+ make -j
+ @cp ./$(CONFIG_TARGET_NAME).elf $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf
+ @ls $(USR_BOOT_DIR)/$(BOOT_IMG_NAME).elf -l
+
+build_all:
+ make build_ft2004_aarch32
+ make build_ft2004_aarch64
+ make build_d2000_aarch32
+ make build_d2000_aarch64
+ make build_e2000_aarch32
+ make build_e2000_aarch64
\ No newline at end of file
diff --git a/baremetal/example/letter_shell_test/sdkconfig b/baremetal/example/letter_shell_test/sdkconfig
index 583af6fbce9438356d3f7c4c8a357d12f10e5e72..4b96eacbc6992aeb93e5cdaa0a6daabbd9d3d067 100644
--- a/baremetal/example/letter_shell_test/sdkconfig
+++ b/baremetal/example/letter_shell_test/sdkconfig
@@ -2,13 +2,13 @@
#
# Project Configuration
#
-CONFIG_TARGET_NAME="ft2004_baremetal_a64"
+CONFIG_TARGET_NAME="e2000_baremetal_a64"
# CONFIG_UART_DRIVER_TEST is not set
CONFIG_SHELL_START_UP_TEST=y
# end of Project Configuration
#
-# Board Setting
+# Platform Setting
#
#
@@ -26,8 +26,8 @@ CONFIG_USE_MMU=y
#
# Board Configuration
#
-CONFIG_TARGET_F2000_4=y
-# CONFIG_TARGET_E2000 is not set
+# CONFIG_TARGET_F2000_4 is not set
+CONFIG_TARGET_E2000=y
# CONFIG_TARGET_D2000 is not set
# end of Board Configuration
@@ -54,15 +54,15 @@ CONFIG_ENABLE_Pl011_UART=y
# CONFIG_USE_TIMER is not set
# CONFIG_USE_SDMMC is not set
# CONFIG_USE_PCIE is not set
+# CONFIG_USE_WDT is not set
# CONFIG_USE_DMA is not set
# CONFIG_USE_NAND is not set
# end of Components Configuration
-# end of Board Setting
+# end of Platform Setting
#
# Building Option
#
-CONFIG_ENVI_LINUX=y
#
# Cross-Compiler Setting
@@ -71,11 +71,11 @@ CONFIG_COMPILER_NO_STD_STARUP=y
# CONFIG_USE_EXT_COMPILER is not set
# end of Cross-Compiler Setting
-CONFIG_LOG_VERBOS=y
+# CONFIG_LOG_VERBOS is not set
# CONFIG_LOG_DEBUG is not set
# CONFIG_LOG_INFO is not set
# CONFIG_LOG_WARN is not set
-# CONFIG_LOG_ERROR is not set
+CONFIG_LOG_ERROR=y
# CONFIG_LOG_NONE is not set
#
@@ -89,9 +89,9 @@ CONFIG_LINK_SCRIPT_ROM=y
CONFIG_ROM_START_UP_ADDR=0x80100000
CONFIG_ROM_SIZE_MB=1
CONFIG_LINK_SCRIPT_RAM=y
-CONFIG_RAM_START_UP_ADDR=0x80200000
+CONFIG_RAM_START_UP_ADDR=0x81000000
CONFIG_RAM_SIZE_MB=64
-CONFIG_HEAP_SIZE=0x0400
+CONFIG_HEAP_SIZE=0x04000
CONFIG_STACK_TOP_ADDR=0x82000000
# end of Linker Options
# end of Building Option
@@ -99,7 +99,8 @@ CONFIG_STACK_TOP_ADDR=0x82000000
#
# Library Configuration
#
-CONFIG_USE_LIBC=y
+CONFIG_USE_G_LIBC=y
+# CONFIG_USE_NEW_LIBC is not set
# end of Library Configuration
#
@@ -116,4 +117,5 @@ CONFIG_LS_PL011_UART=y
# CONFIG_USE_AMP is not set
# CONFIG_USE_YAFFS2 is not set
+# CONFIG_USE_SDMMC_CMD is not set
# end of Third-Party Configuration
diff --git a/baremetal/example/letter_shell_test/sdkconfig.h b/baremetal/example/letter_shell_test/sdkconfig.h
index 6850d7012adc1527573e9696d2d13e5ec01f8ff2..27c5dacb16d5aefd231b1c8e5c68abf40e4f15ef 100644
--- a/baremetal/example/letter_shell_test/sdkconfig.h
+++ b/baremetal/example/letter_shell_test/sdkconfig.h
@@ -3,12 +3,12 @@
/* Project Configuration */
-#define CONFIG_TARGET_NAME "d2000_baremetal_a64"
+#define CONFIG_TARGET_NAME "e2000_baremetal_a64"
/* CONFIG_UART_DRIVER_TEST is not set */
#define CONFIG_SHELL_START_UP_TEST
/* end of Project Configuration */
-/* Board Setting */
+/* Platform Setting */
/* Arch Configuration */
@@ -24,8 +24,8 @@
/* Board Configuration */
/* CONFIG_TARGET_F2000_4 is not set */
-/* CONFIG_TARGET_E2000 is not set */
-#define CONFIG_TARGET_D2000
+#define CONFIG_TARGET_E2000
+/* CONFIG_TARGET_D2000 is not set */
/* end of Board Configuration */
/* Components Configuration */
@@ -48,25 +48,24 @@
/* CONFIG_USE_TIMER is not set */
/* CONFIG_USE_SDMMC is not set */
/* CONFIG_USE_PCIE is not set */
+/* CONFIG_USE_WDT is not set */
/* CONFIG_USE_DMA is not set */
/* CONFIG_USE_NAND is not set */
/* end of Components Configuration */
-/* end of Board Setting */
+/* end of Platform Setting */
/* Building Option */
-#define CONFIG_ENVI_UBUNTU_20_04
-
/* Cross-Compiler Setting */
#define CONFIG_COMPILER_NO_STD_STARUP
/* CONFIG_USE_EXT_COMPILER is not set */
/* end of Cross-Compiler Setting */
-#define CONFIG_LOG_VERBOS
+/* CONFIG_LOG_VERBOS is not set */
/* CONFIG_LOG_DEBUG is not set */
/* CONFIG_LOG_INFO is not set */
/* CONFIG_LOG_WARN is not set */
-/* CONFIG_LOG_ERROR is not set */
+#define CONFIG_LOG_ERROR
/* CONFIG_LOG_NONE is not set */
/* Linker Options */
@@ -79,16 +78,17 @@
#define CONFIG_ROM_START_UP_ADDR 0x80100000
#define CONFIG_ROM_SIZE_MB 1
#define CONFIG_LINK_SCRIPT_RAM
-#define CONFIG_RAM_START_UP_ADDR 0x80200000
+#define CONFIG_RAM_START_UP_ADDR 0x81000000
#define CONFIG_RAM_SIZE_MB 64
-#define CONFIG_HEAP_SIZE 0x0400
+#define CONFIG_HEAP_SIZE 0x04000
#define CONFIG_STACK_TOP_ADDR 0x82000000
/* end of Linker Options */
/* end of Building Option */
/* Library Configuration */
-#define CONFIG_USE_LIBC
+#define CONFIG_USE_G_LIBC
+/* CONFIG_USE_NEW_LIBC is not set */
/* end of Library Configuration */
/* Third-Party Configuration */
@@ -102,6 +102,7 @@
/* end of Letter Shell Configuration */
/* CONFIG_USE_AMP is not set */
/* CONFIG_USE_YAFFS2 is not set */
+/* CONFIG_USE_SDMMC_CMD is not set */
/* end of Third-Party Configuration */
#endif
diff --git a/baremetal/example/libmetal_test/README.md b/baremetal/example/libmetal_test/README.md
index 5c2f5827ef0e379212592b81e23120dab7bbf81c..6da3adbcaed1d262216008f6d07a2cc55c467270 100644
--- a/baremetal/example/libmetal_test/README.md
+++ b/baremetal/example/libmetal_test/README.md
@@ -1,20 +1,10 @@
-
-
-
->本文档用于版本发布下测试基本功能
-
-# 编译测试
-
-1. 编译所有例程
-
-- cd到'baremetal/example', 运行'make'命令,确保所有例程没有error或者warning
-```
-$ make
--e +++ Compiling aarch32_timer_irq/....
--e +++ Compiled OK aarch32_timer_irq/....
--e +++ Compiling aarch32_uart_irq/....
--e +++ Compiled OK aarch32_uart_irq/....
--e +++ Compiling aarch64_uart_irq_send/....
--e +++ Compiled OK aarch64_uart_irq_send/....
--e +++ Compiling aarch32_hello_world/....
--e +++ Compiled OK aarch32_hello_world/....
--e +++ Compiling aarch32_cache_mmu_wr/....
--e +++ Compiled OK aarch32_cache_mmu_wr/....
--e +++ Compiling aarch32_qemu_debug/....
--e +++ Compiled OK aarch32_qemu_debug/....
-```
-
-# 功能测试
-
-1. 选择'baremetal/example/aarch32_cache_mmu_wr', 在当前支持的平台完成基本功能测试
\ No newline at end of file
diff --git a/doc/conventions/code_convention.md b/doc/conventions/code_convention.md
new file mode 100644
index 0000000000000000000000000000000000000000..d7ef90cea8c6ab559c8ade3799c20d4ba347e745
--- /dev/null
+++ b/doc/conventions/code_convention.md
@@ -0,0 +1,342 @@
+## 1. 头文件
+
+- 为保证唯一性, 头文件的命名应该基于所在项目源代码树的全路径. 例如, 项目 foo 中的头文件 foo/src/bar/baz.h 可按如下方式保护:
+
+``` c
+ #ifndef FOO_BAR_BAZ_H
+ #define FOO_BAR_BAZ_H
+ ...
+ #endif // FOO_BAR_BAZ_H
+```
+
+### 1.1 内联函数
+
+- 只有当函数只有 10 行甚至更少时才将其定义为内联函数.
+
+### 1.2 #include 的路径及顺序
+
+- 项目内头文件应按照项目源代码目录树结构排列, 避免使用 UNIX 特殊的快捷目录 . (当前目录) 或 .. (上级目录).
+
+-禁止包含用不到的头文件
+很多系统中头文件包含关系复杂,开发人员为了省事起见,可能不会去一一钻研,直接包含一切想到的头文件,甚至有些产品干脆发布了一个god.h,其中包含了所有头文件,然后发布给各个项目组使用,这种只图一时省事的做法,导致整个系统的编译时间进一步恶化,并对后来人的维护造成了巨大的麻烦。
+按字母顺序分别对每种类型的头文件进行二次排序是不错的主意。
+举例来说, `foo/internal/fooserver.c` 的包含次序如下:
+
+```
+#include "foo/public/fooserver.h" // 优先位置
+#include
+#include
+
+#include
+#include
+
+#include "base/basictypes.h"
+#include "base/commandlineflags.h"
+#include "foo/public/bar.h"
+```
+您所依赖的符号 (symbols) 被哪些头文件所定义,您就应该包含(include)哪些头文件,前置声明 (forward declarations) 情况除外。比如您要用到 bar.h 中的某个符号, 哪怕您所包含的 foo.h 已经包含了 bar.h, 也照样得包含 bar.h, 除非 foo.h 有明确说明它会自动向您提供 bar.h 中的 symbol. 不过,凡是 c 文件所对应的「相关头文件」已经包含的,就不用再重复包含进其 c 文件里面了,就像 foo.c 只包含 foo.h 就够了,不用再管后者所包含的其它内容.
+
+### 1.3 调用外部函数接口
+建议通过包含头文件的方式使用其他 .c 提供的接口,不建议在.c 中通过 extern 的方式使用外部函数接口、变量
+若a.c使用了b.c定义的foo()函数,则应当在b.h中声明extern int foo(int input);并在a.c中通过#include 来使用foo。不建议通过在a.c中直接写extern int foo(int input);来使用foo,后面这种写法容易在foo改变时可能导致声明和定义不一致。
+
+## 2. 函数
+
+### 2.1 参数顺序
+
+- 函数的参数顺序为: 输入参数在先, 后跟输出参数.
+
+- 输入参数通常是值参或 const 引用, 输出参数或输入/输出参数则一般为非 const 指针.
+
+- 特别要注意, 在加入新参数时不要因为它们是新参数就置于参数列表最后, 而是仍然要按照前述的规则, 即将新的输入参数也置于输出参数之前.
+
+### 2.2 编写简短函数
+
+- 我们倾向于编写简短, 凝练的函数.
+
+- 我们承认长函数有时是合理的, 因此并不硬性限制函数的长度. 如果函数超过 40 行, 可以思索一下能不能在不影响程序结构的前提下对其进行分割.
+
+## 3 命名约定
+
+### 3.1 通用命名规则
+
+- 函数命名, 变量命名, 文件命名要有描述性; 少用缩写.
+
+- 尽可能使用描述性的命名, 别心疼空间, 毕竟相比之下让代码易于新读者理解更重要. 不要用只有项目开发者能理解的缩写, 也不要通过砍掉几个字母来缩写单词.
+
+```
+int price_count_reader; // 无缩写
+int num_errors; // "num" 是一个常见的写法
+int num_dns_connections; // 人人都知道 "DNS" 是什么
+```
+错误示例:
+```
+int n; // 毫无意义.
+int nerr; // 含糊不清的缩写.
+int n_comp_conns; // 含糊不清的缩写.
+int wgc_connections; // 只有贵团队知道是什么意思.
+int pc_reader; // "pc" 有太多可能的解释了.
+int cstmr_id; // 删减了若干字母.
+```
+除了常见的通用缩写以外,不使用单词缩写,不得使用汉语拼音;寄存器缩写遵循芯片手册命名。
+一些单词有大家公认的缩写,常用单词的缩写必须统一。
+对于某个系统使用的专用缩写应该在注释或者某处做统一说明。
+```
+argument 可缩写为 arg
+buffer 可缩写为 buff
+address可缩写为 addr
+clock 可缩写为 clk
+command 可缩写为 cmd
+compare 可缩写为 cmp
+configuration 可缩写为 cfg
+device 可缩写为 dev
+error 可缩写为 err
+hexadecimal 可缩写为 hex
+increment 可缩写为 inc
+initialize 可缩写为 init
+maximum 可缩写为 max
+message 可缩写为 msg
+minimum 可缩写为 min
+parameter 可缩写为 para
+previous 可缩写为 prev
+register 可缩写为 reg
+semaphore 可缩写为 sem
+statistic 可缩写为 stat
+synchronize 可缩写为 sync
+```
+用正确的反义词组命名具有互斥意义的变量或相反动作的函数
+```
+add/remove begin/end create/destroy
+insert/delete first/last get/release
+increment/decrement put/get add/delete
+lock/unlock open/close min/max
+old/new start/stop next/previous
+source/target show/hide send/receive
+source/destination copy/paste up/down
+```
+### 3.2 文件命名
+
+- 文件名要全部小写, 使用下划线 (\_) 作为连接
+例如wdt的驱动文件命名为
+```
+fwdt/fwdt_hw.c
+```
+
+### 3.3 类型命名 (结构体,枚举等数据类型)
+所有类型命名 —— 结构体, 类型定义 (typedef), 枚举, 类型模板参数,
+均使用相同约定, 即以大写字母开始, 每个单词首字母均大写, 不包含下划线.
+例如:
+函数、结构体、宏、枚举的命名需要加上子模块名
+函数名定义:
+```
+void FWdtRefresh();
+```
+结构体名定义:
+```
+typedef struct
+{
+ UrlTableProperties *,
+ int
+}FWdtProperty;
+```
+枚举和宏命名参考函数名和结构体命名
+
+
+### 3.4 变量命名
+
+禁止使用单字节命名变量,但允许定义i 、j、k作为局部循环变量;
+
+- 变量 (包括函数参数) 和数据成员名一律小写, 单词之间用下划线连接. 结构体的成员变量和变量一致, 如:
+```
+a_struct_data_member, a_class_data_member*
+```
+
+* 普通变量命名
+
+```
+char table_name; /*用下划线.*/
+```
+
+- 结构体变量
+
+* 结构体数据成员可以和普通变量一样, 不用像类那样接下划线:
+
+```
+struct
+{
+ char name;
+ int num_entries;
+
+};
+```
+
+### 3.5 常量命名
+
+- const 的变量, 或在程序运行期间其值始终保持不变的, 基本类型的命名例如:
+
+```
+const int DAYS_IN_WEEK = 7;
+```
+
+### 3.6 函数命名
+注:参考 3.3 类型命名
+都以模块名开头FWdtxxxx
+- 常规函数使用大小写混合(大驼峰), 取值和设值函数则要求与变量名匹配:
+一般来说, 函数名的每个单词首字母大写 (即 “驼峰变量名” 或 “帕斯卡变量名”), 没有下划线.
+对于首字母缩写的单词, 更倾向于将它们视作一个单词进行首字母大写 (例如, 写作 FWdtStartRpc() 而非 FWdt_StartRPC()).
+```
+FWdtAddTableEntry()
+DeleteUrl()
+OpenFileOrDie()
+MyExcitingFunction()
+GetCurrentDirectory(DWORD buff_length, DWORD buff)
+
+```
+
+### 3.7 枚举命名
+
+- 单独的枚举值应该采用 const 常量 的命名方式 .
+
+- 常规函数使用大小写混合, 取值和设值函数则要求与变量名匹配:
+
+注: 枚举值和常量命名方式一致;
+```
+enum UrlTableErrors
+{
+ FWDT_OK = 0,
+ FWDT_ERR_OUT_OF_MEMORY,
+ FWDT_ERR_GENERAL,
+};
+```
+
+### 3.8 宏定义
+
+- 采用全大写
+
+```
+MY_MACRO_THAT_SCARES_SMALL_CHILDREN.
+```
+
+## 4 注释
+
+- 注释虽然写起来很痛苦, 但对保证代码可读性至关重要. 下面的规则描述了如何注释以及在哪儿注释. 当然也要记住: 注释固然很重要, 但最好的代码应当本身就是文档. 有意义的类型名和变量名, 要远胜过要用注释解释的含糊不清的名字.
+
+### 4.1 文件注释
+
+- 使用/* */
+
+### 4.2 文件注释
+
+- 在每一个文件开头加入版权公告.
+
+- 文件注释描述了该文件的内容. 如果一个文件只声明, 或实现, 或测试了一个对象, 并且这个对象已经在它的声明处进行了详细的注释, 那么就没必要再加上文件注释. 除此之外的其他文件都需要文件注释.
+
+法律公告和作者信息
+
+- 每个文件都应该包含许可证引用. 为项目选择合适的许可证版本.(比如, Apache 2.0, BSD, LGPL, GPL)
+
+- 开源版本
+
+```
+ * @ : Copyright (c) 2020 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-05-24 13:51:46
+ * @LastEditTime: 2021-05-24 14:00:36
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+
+```
+
+### 4.3 函数注释
+
+- 函数声明处的注释描述函数功能; 定义处的注释描述函数实现.
+
+- 基本上每个函数声明处前都应当加上注释, 描述函数的功能和用途. 只有在函数的功能简单而明显时才能省略这些注释(例如, 简单的取值和设值函数). 注释使用叙述式 (“Opens the file”) 而非指令式 (“Open the file”); 注释只是为了描述函数, 而不是命令函数做什么. 通常, 注释不会描述函数如何工作. 那是函数定义部分的事情.
+
+```
+- 函数的输入输出.
+ 对类成员函数而言: 函数调用期间对象是否需要保持引用参数, 是否会释放这些参数.
+ 函数是否分配了必须由调用者释放的空间.
+ 参数是否可以为空指针,参数的取值范围.
+ 是否存在函数使用上的性能隐患.
+```
+
+```
+/**
+ * @name: _set_cntfrq
+ * @msg: Set CNTFRQ,This register is provided so that software can discover the frequency of the system counter. It must
+ * be programmed with this value as part of system initialization.
+ * @param {u32} clock_frequency: , Indicates the system counter clock frequency, in Hz.
+ *
+ */
+```
+
+- 不要 从 .h 文件或其他地方的函数声明处直接复制注释. 简要重述函数功能是可以的, 但注释重点要放在如何实现上.
+- 注释不是为了名词解释(what),而是说明用途(why)
+
+### 4.4 变量注释
+
+- 通常变量名本身足以很好说明变量用途. 某些情况下, 也需要额外的注释说明.
+
+全局变量
+
+- 和数据成员一样, 所有全局变量也要注释说明含义及用途, 以及作为全局变量的原因. 比如:
+
+```
+/* The total number of tests cases that we run through in this regression test. */
+ const int NUM_TEST = 6;
+```
+全局变量要有较详细的注释,包括对其功能、取值范围以及存取时注意事项等的说明
+```
+/* The ErrorCode when SCCP translate */
+/* Global Title failure, as follows */ /* 变量作用、含义*/
+/* 0 -SUCCESS 1 -GT Table error */
+/* 2 -GT error Others -no use */ /* 变量取值范围*/
+/* only function SCCPTranslate() in */
+/* this modual can modify it, and other */
+/* module can visit it through call */
+/* the function GetGTTransErrorCode() */ /* 使用方法*/
+BYTE tranErrorCode;
+
+```
+
+### 4.5 实现注释
+
+注释应放在其代码上方相邻位置或右方,不可放在下面,如放于上方则需与其上面的代码用空行隔开,且与下方代码缩进相同;
+
+```
+/* active statistic task number */
+#define MAX_ACT_TASK_NUMBER 1000
+#define MAX_ACT_TASK_NUMBER 1000
+
+```
+可按如下形式说明枚举/数据/联合结构。
+
+```
+/* sccp interface with sccp user primitive message name */
+enum SCCP_USER_PRIMITIVE
+{
+ N_UNITDATA_IND, /* sccp notify sccp user unit data come */
+ N_NOTICE_IND, /* sccp notify user the No.7 network can not transmission this message */
+ N_UNITDATA_REQ, /* sccp user's unit data transmission request*/
+};
+
+```
+
+- 巧妙或复杂的代码段前要加注释. 比如:
+
+```
+/* Divide result by two, taking into account that x
+ contains the carry from the add. */
+for (int i = 0; i < result->size(); i++)
+{
+ x = (x << 8) + (*result)[i];
+ (*result)[i] = x >> 1;
+ x &= 1;
+}
+```
diff --git a/doc/baremetal.dio b/doc/design/baremetal.dio
similarity index 100%
rename from doc/baremetal.dio
rename to doc/design/baremetal.dio
diff --git a/doc/build.dio b/doc/design/build.dio
similarity index 100%
rename from doc/build.dio
rename to doc/design/build.dio
diff --git a/doc/driver.dio b/doc/design/driver.dio
similarity index 100%
rename from doc/driver.dio
rename to doc/design/driver.dio
diff --git a/doc/framework.dio b/doc/design/framework.dio
similarity index 100%
rename from doc/framework.dio
rename to doc/design/framework.dio
diff --git a/doc/design/freertos_system.dio b/doc/design/freertos_system.dio
new file mode 100644
index 0000000000000000000000000000000000000000..ee395bec82fd0ee88d80a73567d00a7174cc2339
--- /dev/null
+++ b/doc/design/freertos_system.dio
@@ -0,0 +1,175 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/design/freertos_system.png b/doc/design/freertos_system.png
new file mode 100644
index 0000000000000000000000000000000000000000..ed6d47af0dadd63ef425f25bde3e4fd158c70e64
Binary files /dev/null and b/doc/design/freertos_system.png differ
diff --git a/doc/design/freertos_system_deps.dio b/doc/design/freertos_system_deps.dio
new file mode 100644
index 0000000000000000000000000000000000000000..e1424158df1221252f63250b3151ff329d8c497e
--- /dev/null
+++ b/doc/design/freertos_system_deps.dio
@@ -0,0 +1,202 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/design/freertos_system_deps.png b/doc/design/freertos_system_deps.png
new file mode 100644
index 0000000000000000000000000000000000000000..5e85f2ac14ad3ae5f3a679eecc5c4f0cdf6d4a83
Binary files /dev/null and b/doc/design/freertos_system_deps.png differ
diff --git a/doc/middleware.dio b/doc/design/middleware.dio
similarity index 100%
rename from doc/middleware.dio
rename to doc/design/middleware.dio
diff --git a/doc/platform_test.dio b/doc/design/platform_test.dio
similarity index 100%
rename from doc/platform_test.dio
rename to doc/design/platform_test.dio
diff --git a/doc/system.dio b/doc/design/system.dio
similarity index 83%
rename from doc/system.dio
rename to doc/design/system.dio
index 7e92ce235b3783d915b1e278c533dab215baa628..1dc4317445012b268ce53ce48ec88ed504987900 100644
--- a/doc/system.dio
+++ b/doc/design/system.dio
@@ -1,6 +1,6 @@
-
+
@@ -67,6 +67,9 @@
+
+
+
@@ -94,6 +97,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/doc/system.png b/doc/design/system.png
similarity index 100%
rename from doc/system.png
rename to doc/design/system.png
diff --git a/doc/design/system_2.dio b/doc/design/system_2.dio
new file mode 100644
index 0000000000000000000000000000000000000000..acfab54e432dc03b8570bb163e9d40303cc5d5cf
--- /dev/null
+++ b/doc/design/system_2.dio
@@ -0,0 +1,163 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/design/system_2.png b/doc/design/system_2.png
new file mode 100644
index 0000000000000000000000000000000000000000..454443341ac0837552fd7e19608c33201bd03cb0
Binary files /dev/null and b/doc/design/system_2.png differ
diff --git a/doc/design/system_2_deps.dio b/doc/design/system_2_deps.dio
new file mode 100644
index 0000000000000000000000000000000000000000..7e5258f8f9ef86b114306b686322f39b756aa50d
--- /dev/null
+++ b/doc/design/system_2_deps.dio
@@ -0,0 +1,229 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/doc/design/system_2_deps.png b/doc/design/system_2_deps.png
new file mode 100644
index 0000000000000000000000000000000000000000..dbc5e89b2ff73cdeb92ec856e295e8148ac677b3
Binary files /dev/null and b/doc/design/system_2_deps.png differ
diff --git a/doc/driver_template/foox_hw.c b/doc/driver_template/foox_hw.c
new file mode 100644
index 0000000000000000000000000000000000000000..55cafd8acb2434d781011cfa7deee0c709fcdd6f
--- /dev/null
+++ b/doc/driver_template/foox_hw.c
@@ -0,0 +1,44 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 22:05:37
+ * @LastEditTime: 2021-10-21 13:59:09
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+#include "foox_hw.h"
+#include "fooxx.h"
+
+
+/***************************** Include Files *********************************/
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/************************** Variable Definitions *****************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+void FooxHwWrite(uintptr base, char byte)
+{
+
+}
+
+char FooxHwRead(uintptr base)
+{
+
+}
+
+void FooxxReset(Fooxx *instance_p)
+{
+
+}
diff --git a/doc/driver_template/foox_hw.h b/doc/driver_template/foox_hw.h
new file mode 100644
index 0000000000000000000000000000000000000000..43c700b3af8042a932c3e60caef20c4105f100ca
--- /dev/null
+++ b/doc/driver_template/foox_hw.h
@@ -0,0 +1,74 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 22:05:43
+ * @LastEditTime: 2021-10-21 13:56:52
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+#ifndef DRIVERS_XXXX_FOOXX_HW_H
+#define DRIVERS_XXXX_FOOXX_HW_H
+
+
+/* - 传入模块基地址,不能复杂结构体
+- hardware interface of device || low-level driver function prototypes
+
+- 包括驱动寄存器参数和low-level操作定义
+1. 定义寄存器偏移
+2. 对上提供该模块寄存器操作的接口
+3. 一些简单外设提供直接操作接口
+4. 可以定义一些状态的接口,用于响应驱动状态的变化
+
+note: 本文件不能引用fooxx.h
+*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/***************************** Include Files *********************************/
+
+#include "parameters.h"
+#include "ft_io.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/************************** Variable Definitions *****************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/** @name Register Map
+ *
+ * Register offsets from the base address of an SD device.
+ * @{
+ */
+
+#define FOOXX_XX_OFFSET
+
+/** @name FOOXX_XX_OFFSET Register
+ */
+
+#define FOOXX_XX_STATE
+
+
+#define FOOXX_READ_REG32(addr, reg_offset) FtIn32((addr) + (u32)(reg_offset))
+#define FOOXX_WRITE_REG32(addr, reg_offset, reg_value) FtOut32((addr) + (u32)(reg_offset), (u32)(reg_value))
+
+
+/************************** Function Prototypes ******************************/
+void FooxHwWrite(uintptr base,char byte);
+
+char FooxHwRead(uintptr base);
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/doc/driver_template/foox_options.c b/doc/driver_template/foox_options.c
new file mode 100644
index 0000000000000000000000000000000000000000..e27b4a23ecfc287b7da90a4efe160cefb013ad7b
--- /dev/null
+++ b/doc/driver_template/foox_options.c
@@ -0,0 +1,63 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-21 08:12:42
+ * @LastEditTime: 2021-10-21 09:02:12
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+/*
+ - The implementation of the options functions for the driver.
+ - 用户选项实现
+ 1. 速度参数配置
+ 2. 工作模式参数
+ 3. fifo功能
+ 1. 深度
+ 2. 使能
+ - 用户常用的功能寄存器读写动作,建议通过option提供快捷方式
+
+*/
+
+/***************************** Include Files *********************************/
+
+#include "fooxx.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Variable Definitions *****************************/
+
+/************************** Function Prototypes ******************************/
+
+
+
+u32 FXxxGetOptions(FXxx *instance_p)
+{
+
+}
+
+u32 FXxxSetOptions(FXxx *instance_p, u32 options)
+{
+
+}
+
+u32 FXxxSetData(FXxx *instance_p, void *data_struct)
+{
+
+}
+
+u32 FXxxGetOptions(FXxx *instance_p, void *data_struct)
+{
+
+}
+
+
diff --git a/doc/driver_template/foox_role.c b/doc/driver_template/foox_role.c
new file mode 100644
index 0000000000000000000000000000000000000000..0a91527a77afd0d4918abee96b284442e1e6b9b9
--- /dev/null
+++ b/doc/driver_template/foox_role.c
@@ -0,0 +1,40 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 22:29:50
+ * @LastEditTime: 2021-10-21 08:33:41
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+/*
+ - 一些驱动模块,直接操作硬件的I/O接口,无法实现有意义的操作,此时需要针对中间件或者用户使用习惯设计此模块 (i2c,nand,eth)
+ - 部分场景适用, 分角色的 I/O 操作
+ - 此模块的函数原型,在fooxx.h 中声明一次,方便用户或者中间件层调用
+
+*/
+
+
+/***************************** Include Files *********************************/
+
+#include "ft_io.h"
+#include "foox_hw.h"
+#include "fooxx.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+/************************** Variable Definitions *****************************/
+
+/*****************************************************************************/
+
diff --git a/doc/driver_template/fooxx.c b/doc/driver_template/fooxx.c
new file mode 100644
index 0000000000000000000000000000000000000000..9de58ea71d21326deb67ee206393dd3d79c0679f
--- /dev/null
+++ b/doc/driver_template/fooxx.c
@@ -0,0 +1,45 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 18:03:25
+ * @LastEditTime: 2021-10-21 13:58:46
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+/***************************** Include Files *********************************/
+
+#include "ft_io.h"
+#include "ft_error_code.h"
+#include "ft_types.h"
+#include "foox_hw.h"
+#include "fooxx.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+extern void FooxxReset(Fooxx *instance_p);
+
+/************************** Variable Definitions *****************************/
+
+/*****************************************************************************/
+
+/* 此文件主要为了完成用户对外接口,用户可以使用这些接口直接开始工作 */
+
+/* - 包括用户API的定义和实现
+ - 同时包含必要的OPTION方法,方便用户进行配置
+ - 如果驱动可以直接进行I/O操作,在此源文件下可以将API 进行实现 */
+
+FError FooxxCfgInitialize(Fooxx *instance_p, FooxxConfig *config_p)
+{
+
+}
\ No newline at end of file
diff --git a/doc/driver_template/fooxx.h b/doc/driver_template/fooxx.h
new file mode 100644
index 0000000000000000000000000000000000000000..e4d0b8c8a3f64974acc977a09985c6ec71a5b556
--- /dev/null
+++ b/doc/driver_template/fooxx.h
@@ -0,0 +1,97 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 18:22:37
+ * @LastEditTime: 2021-10-21 13:28:15
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+
+#ifndef DRIVERS_模块名_FOOXX_H
+#define DRIVERS_模块名_FOOXX_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/***************************** Include Files *********************************/
+
+#include "ft_types.h"
+#include "ft_assert.h"
+
+/************************** Constant Definitions *****************************/
+
+/* Configuration options */
+#define FOOXX_OPTION_XX
+
+/* Operational Mode */
+
+#define FOOXX_OPER_MODE_XX
+
+/**************************** Type Definitions *******************************/
+
+/**
+ * This typedef contains configuration information for the device.
+ */
+typedef struct
+{
+ u32 instance_id; /**< Device instance id */
+ uintptr base_addr; /**< Device base address */
+} FooxxConfig;
+
+/**
+ * This typedef contains driver instance data. The user is required to allocate a
+ * variable of this type for every device in the system. A pointer
+ * to a variable of this type is then passed to the driver API functions.
+ */
+typedef struct
+{
+ FooxxConfig config; /**< Current active configs */
+ u32 is_ready; /**< Device is initialized and ready */
+} Fooxx; /**< Device instance */
+
+/************************** Variable Definitions *****************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+/**
+ * @name: FXxxLookupConfig
+ * @msg: Get the device instance default configure
+ * @return {*}
+ * @param {u32} instance_id
+ */
+const FooxxConfig *FXxxLookupConfig(u32 instance_id);
+
+/*
+ * @name: FooxxCfgInitialize
+ * @msg: Initializes a specific instance such that it is ready to be used.
+ * @param {Fooxx} *instance_p is a pointer to the driver instance.
+ * @param {FooxxConfig} *config_p is a reference to a structure containing information
+ * about a specific driver.
+ * @return SUCCESS if initialization was successful
+ * ERROR
+ */
+FError FooxxCfgInitialize(Fooxx *instance_p, const FooxxConfig *cofig_p);
+
+/**
+ * @name: FooxxDeInitialize
+ * @msg: DeInitialization function for the device instance
+ * @return {*}
+ * @param {Fooxx} *instance_p
+ */
+void FooxxDeInitialize(Fooxx *instance_p);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/doc/driver_template/fooxx_g.c b/doc/driver_template/fooxx_g.c
new file mode 100644
index 0000000000000000000000000000000000000000..64402b9a9e6837e6fef2fc8d6db1f91d413ea256
--- /dev/null
+++ b/doc/driver_template/fooxx_g.c
@@ -0,0 +1,43 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 18:56:23
+ * @LastEditTime: 2021-10-21 11:32:53
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+/* - This file contains a configuration table that specifies the configuration
+- 驱动全局变量定义,包括静态配置参数 */
+
+/***************************** Include Files *********************************/
+
+#include "ft_types.h"
+#include "parameters.h"
+#include "fooxx.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+/************************** Variable Definitions *****************************/
+
+const FooxxConfig FOOXX_CONFIG_TBL[NUM] =
+{
+ {
+ .instance_id = 0, /* Id of device*/
+ .base_address = FOOXX_BASE,
+ },
+};
+
+
+/*****************************************************************************/
diff --git a/doc/driver_template/fooxx_sinit.c b/doc/driver_template/fooxx_sinit.c
new file mode 100644
index 0000000000000000000000000000000000000000..79cb0f45da5536ee228771b88789a1c71e1419e0
--- /dev/null
+++ b/doc/driver_template/fooxx_sinit.c
@@ -0,0 +1,51 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 21:56:34
+ * @LastEditTime: 2021-10-21 11:35:26
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+
+/* - This file contains the implementation of driver's static initialization functionality.
+- 驱动静态初始化 */
+
+/***************************** Include Files *********************************/
+
+#include "ft_types.h"
+#include "parameters.h"
+#include "fooxx.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Variable Definitions *****************************/
+
+extern const FooxxConfig FOOXX_CONFIG_TBL[NUM];
+
+/************************** Function Prototypes ******************************/
+const FooxxConfig *FooxxLookupConfig(u32 instance_id)
+{
+ const FooxxConfig *ptr = NULL;
+ u32 index;
+
+ for (index = 0; index < (u32)NUM; index++)
+ {
+ if (FOOXX_CONFIG_TBL[index].instance_id == instance_id)
+ {
+ ptr = &FOOXX_CONFIG_TBL[index];
+ break;
+ }
+ }
+
+ return (const FooxxConfig *)ptr;
+}
\ No newline at end of file
diff --git a/doc/reference/driver/i2c.md b/doc/reference/driver/i2c.md
new file mode 100644
index 0000000000000000000000000000000000000000..d1d85a5d618a464b52ebf18731df3ee9a7127877
--- /dev/null
+++ b/doc/reference/driver/i2c.md
@@ -0,0 +1,299 @@
+
+
+# I2C 驱动程序
+
+## 1. 概述
+
+
+- I2C 是一种串行同步半双工通信协议,总线上可以同时挂载多个主机和从机。I2C 总线由串行数据线 (SDA) 和串行时钟线 (SCL) 线构成。这些线都需要上拉电阻。
+
+- I2C 具有简单且制造成本低廉等优点,主要用于低速外围设备的短距离通信(一英尺以内)。
+
+- I2C 驱动支持的平台包括 FT2000/4、D2000。
+
+
+## 2. 驱动功能
+
+I2C 驱动程序管理在 I2C 总线上设备的通信,该驱动程序具备以下功能:
+
+- 在主机模式下读写字节
+- 支持从机模式
+
+## 3. 使用方法
+
+以下部分将指导您完成 I2C 驱动的硬件配置:
+
+- 1. I2C驱动支持 FT2000/4, D2000和E2000,在FT2000/4上完成测试
+- 2. FT2000/4, D2000上,使用I2C驱动需要打开IO复用,I2C0的引脚默认设置为给I2C使用,I2C1/I2C2/I2C3需要先设置IO复用才能使用
+- 3. FT2000/4, D2000上,I2C的参考时钟为48MHz, 不支持修改设置
+
+以下部分将指导您完成 I2C 驱动的软件配置:
+
+- 1. 配置驱动程序,新建应用工程,使能I2C驱动模块
+- 2. 设置配置参数,选择为 I2C 主机还是从机,调整默认的 I2C 通信参数(如时序、位序等)
+- 3. 配置中断服务
+- 4. 处理错误码
+- 5. 去使能驱动程序
+
+## 5. 应用示例
+
+### [fi2c_eeprom](../../../baremetal/example/fi2c_eeprom/README.md)
+
+### [fi2c_slave](../../../baremetal/example/fi2c_slave/README.md)
+
+
+## 6. API参考
+
+
+### 6.1. 用户数据结构
+
+- drivers/i2c/fi2c/fi2c.h
+
+```c
+
+typedef struct
+{
+ u32 instance_id; /**< Device instance id */
+ uintptr base_addr; /**< Device base address */
+ u32 irq_num; /**< Device intrrupt id */
+ u32 irq_prority; /**< Device intrrupt priority */
+ u32 ref_clk_hz; /**< Input reference clock frequency in Hz */
+ u32 work_mode; /**< Device work mode Slave or Master */
+ u32 slave_addr; /**< Slave Address writing/reading to/from */
+ u32 slave_addr_len; /**< Slave Address Bytes */
+ boolean use_7bit_addr; /**< Slave in-chip address offset in 7bit or 10bit */
+ u32 speed_rate; /* I2C speed rate */
+} FI2cConfig; /**< Device configure setting */
+```
+
+- I2C驱动实例配置
+
+```c
+
+typedef struct
+{
+ FI2cConfig config; /**< Current active configs */
+ u32 is_ready; /**< Device is initialized and ready */
+ /** only apply to master device **/
+ /**< Master intrrupt handler */
+ FI2cEvtHandler master_evt_handlers[FI2C_MASTER_INTR_EVT_NUM];
+
+ /** only apply to slave device **/
+ /**< Slave intrrupt handler */
+ FI2cEvtHandler slave_evt_handlers[FI2C_SLAVE_INTR_EVT_NUM];
+
+} FI2c; /**< Device instance */
+```
+
+- I2C驱动实例
+
+### 6.2 错误码定义
+
+- 模块错误码编号 `0x10b0000`
+
+- [0x0] FI2C_SUCCESS : fi2c success
+
+- [0x10b0001] FI2C_ERR_INVAL_PARM : fi2c invalid input parameters
+
+- [0x10b0002] FI2C_ERR_NOT_READY : fi2c driver not ready
+
+- [0x10b0001] FI2C_ERR_INVAL_PARM : fi2c invalid input parameters
+
+- [0x10b0003] FI2C_ERR_TIMEOUT : fi2c wait timeout
+
+- [0x10b0004] FI2C_ERR_NOT_SUPPORT : fi2c non support operation
+
+- [0x10b0005] FI2C_ERR_INVAL_STATE : fi2c invalid state
+
+### 6.3. 用户API接口
+
+
+```c
+const FI2cConfig *FI2cLookupConfig(u32 instance_id);
+```
+- 获取I2C驱动的默认配置参数
+
+Note:
+
+ - 用户需要修改配置参数时,可以通过修改返回的FI2cConfig副本,作为FI2cCfgInitialize函数的入参,
+
+Input:
+
+ - u32 instance_id, 当前控制的I2C控制器实例号
+
+Return:
+
+ - const FI2cConfig *, 返回驱动默认参数, NULL表示失败
+
+
+```c
+FError FI2cCfgInitialize(FI2c *instance_p, const FI2cConfig *cofig_p);
+```
+- 完成I2C驱动实例的初始化,使之可以使用
+
+Note:
+
+ - 此函数会将驱动实例中的所有数据全部重置,同时会进行I2C控制器的重置,请不要在I2C数据传输过程中调用此函数
+
+Input:
+
+ - FI2c *instance_p, I2C驱动实例数据
+
+ - const FI2cConfig *cofig_p, I2C驱动配置数据
+
+Return:
+
+ FError,参考6.2章错误码定义
+
+```c
+void FI2cDeInitialize(FI2c *instance_p);
+```
+
+- 完成I2C驱动实例去使能,清零实例数据
+
+Note:
+
+ - 此函数会将驱动实例中的所有数据全部重置,
+
+Input:
+
+ - FI2c *instance_p, I2C驱动实例数据
+
+Return:
+
+ 无
+
+```c
+const char *FI2cErrorToMessage(FError error);
+```
+
+- 获取I2C模块错误码对应的错误信息
+
+Note:
+
+ - 请输入属于FI2C模块的错误码,否则返回的错误信息为空
+
+Input:
+
+ - {FError} error, I2C输入错误码
+
+Return:
+
+ - {const char *}, 错误码信息,NULL表示失败
+
+```c
+FError FI2cMasterReadPoll(FI2c *instance_p, u32 inchip_addr, u8 *buf_p, int buf_len);
+```
+- I2C主机读,阻塞直到完成读操作或失败
+
+Note:
+ - 请先初始化I2C驱动再调用此函数
+ - 请在Master工作模式下调用此函数
+
+Input:
+ - @param {FI2c} *instance_p I2C驱动实例数据
+ - @param {u32} inchip_addr 从机的内部偏移地址
+ - @param {u8} *buf_p 读目的缓冲区
+ - @param {int} buf_len 读目的缓冲区长度
+
+Return:
+ - @return {FError *} 返回错误码
+
+
+```c
+FError FI2cMasterWritePoll(FI2c *instance_p, u32 inchip_addr, const u8 *buf_p, size_t buf_len);
+```
+- I2C主机写,阻塞直到完成写操作或失败
+
+Note:
+ - 请先初始化I2C驱动再调用此函数
+ - 请在Master工作模式下调用此函数
+
+Input:
+ - @param {FI2c} *instance_p I2C驱动实例数据
+ - @param {u32} inchip_addr 从机的内部偏移地址
+ - @param {u8} *buf_p 写源缓冲区
+ - @param {size_t} buf_len 写源缓冲区长度
+
+Return:
+ - @return {FError *} 返回错误码
+
+```c
+FError FI2cMasterSetupIntrrupt(FI2c *instance_p);
+```
+- 设置I2C主机的中断
+
+Note:
+ - 请先初始化I2C驱动再调用此函数
+ - 请在Master工作模式下调用此函数
+
+Input:
+ - {FI2c} *instance_p I2C驱动实例数据
+
+Return:
+ - {FError *} 返回错误码
+
+```c
+void FI2cMasterRegisterIntrruptHandler(FI2c *instance_p, u32 evt, FI2cEvtHandler handler);
+```
+- 注册I2C主机中断事件函数
+
+Note:
+ 无
+
+Input:
+ - @param {FI2c} *instance_p I2C驱动实例数据
+ - @param {u32} evt 中断事件,参考 FI2C_MASTER_INTR_EVT_NUM
+ - @param {FI2cEvtHandler} handler 中断事件回调函数
+
+Return:
+
+ 无
+
+```c
+FError FI2cSlaveSetupIntrrupt(FI2c *instance_p);
+```
+
+- 设置I2C从机的中断
+
+Note:
+ - 请先初始化I2C驱动再调用此函数
+ - 请在Slave工作模式下调用此函数
+
+Input:
+ - @param {FI2c} *instance_p I2C驱动实例数据
+ - @param {u32} evt 中断事件,参考 FI2C_MASTER_INTR_EVT_NUM
+ - @param {FI2cEvtHandler} handler 中断事件回调函数
+
+Return:
+ - {FError *} 返回错误码
+
+```c
+void FI2cSlaveRegisterIntrruptHandler(FI2c *instance_p, u32 evt, FI2cEvtHandler handler);
+```
+
+- 注册I2C从机中断事件函数
+
+Note:
+ 无
+
+Input:
+ - @param {FI2c} *instance_p I2C驱动实例数据
+ - @param {u32} evt 中断事件,参考 FI2C_SLAVE_INTR_EVT_NUM
+ - @param {FI2cEvtHandler} handler 中断事件回调函数
+
+Return:
+
+ 无
\ No newline at end of file
diff --git a/doc/reference/driver/template.md b/doc/reference/driver/template.md
new file mode 100644
index 0000000000000000000000000000000000000000..46779018edb1e1a0128732ccccea6b3363ec1446
--- /dev/null
+++ b/doc/reference/driver/template.md
@@ -0,0 +1,36 @@
+
+
+# XX 驱动程序
+
+## 1. 概述
+
+`XX的基本概念, XX驱动支持的硬件平台`
+
+## 2. 功能
+
+`XX驱动程序支持的功能,关联的源文件`
+
+## 3. 配置方法
+
+`XX驱动使用的一般过程和方法`
+`XX驱动的配置方法和参数设置`
+
+## 4 应用示例
+
+`XX驱动的example使用`
+
+## 4. API参考
+
+`XX驱动用户API说明`
\ No newline at end of file
diff --git a/baremetal/example/template-mingw64/main.c b/doc/reference/hw/template.md
similarity index 55%
rename from baremetal/example/template-mingw64/main.c
rename to doc/reference/hw/template.md
index 4c4738d1c67e8d9f799367bbcb94b721dd13c60b..58c726a749f8b06c81a35d6e1e2c07ba64852438 100644
--- a/baremetal/example/template-mingw64/main.c
+++ b/doc/reference/hw/template.md
@@ -1,20 +1,13 @@
-/*
+
diff --git a/doc/reference/sdk_reference.md b/doc/reference/sdk_reference.md
new file mode 100644
index 0000000000000000000000000000000000000000..1b411f6f531f9792b9b41ce42d949cefc00a1dbb
--- /dev/null
+++ b/doc/reference/sdk_reference.md
@@ -0,0 +1,56 @@
+
+
+# SDK参考手册
+
+`SDK参考手册模板`
+
+- 版本:v0.1
+
+## 1. SDK用户指南
+
+`提供使用API过程中可能遇到的问题,按照用户使用的一般顺序排列`
+
+### 1.1 配套目标平台
+
+### 1.2 使用构建系统
+
+### 1.3 使用驱动组件
+
+### 1.4 生成链接器脚本
+
+### 1.5 完成引导加载
+
+### 1.6 处理API错误码
+
+## 2. 组件使用指南
+
+`提供分模块的具体API说明,按照模块分类说明,模块内按照字母顺序排列,方便检索`
+
+### I2C
+
+(./driver_reference/i2c.md)
+
+
+
+## 3. 硬件使用指南
+
+`提供硬件平台的参考资料,按字母顺序排列`
+
+### D2000
+
+### E2000
+
+### FT2000/4
+
diff --git a/doc/install_linux_aarch64.md b/doc/reference/usr/install_linux_aarch64.md
similarity index 84%
rename from doc/install_linux_aarch64.md
rename to doc/reference/usr/install_linux_aarch64.md
index c5622881e6aa267e9d6a7df9783d0a9441ceba39..953c48a3ace27f95d5641e4ad27ddb2f4e56b06b 100644
--- a/doc/install_linux_aarch64.md
+++ b/doc/reference/usr/install_linux_aarch64.md
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-19 15:42:42
- * @LastEditTime: 2021-10-19 16:36:48
+ * @LastEditTime: 2021-11-01 10:20:17
* @Description: This files is for
*
* @Modify History:
@@ -20,12 +20,12 @@ Linux arm aarch64下通过通过下载SDK开发工具包完成安装,运行脚
Linux arm aarch64安装包集成了,
- `gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf.tar.xz`和`gcc-arm-10.3-2021.07-aarch64-arm-none-eabi.tar.xz`,aarch64交叉编译链,SDK安装过程中会被解压到DEV目录的`cross_tool`目录下
-- `update_sdk_dev.sh`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装
+- `setup_dev.py`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装
## 1.1 获取SDK的开发环境
-- [Linux arm aarch64](https://pan.baidu.com/s/1_k2gelNketsDD5bCkWo4Rg )
+- [Linux arm aarch64](https://pan.baidu.com/s/1BvhvWhk3-jx8tAcwrK8Xdw )
> 提取码:LA64
@@ -36,11 +36,11 @@ Linux arm aarch64安装包集成了,
- (1). 解压开发环境压缩包,形成DEV目录
-- (2). 进入DEV目录,运行`source ./update_sdk_dev.sh`,安装开发环境
+- (2). 进入DEV目录,运行`./setup_dev.py`,安装开发环境
-
+
--(3). 通过git拉取Phytium Standalone SDK的代码,如
+- (3). 通过git拉取Phytium Standalone SDK的代码,如
```
git clone https://gitee.com/phytium_embedded/phytium-standalone-sdk.git ./phytium-standalone-sdk
diff --git a/doc/install_linux_x86_64.md b/doc/reference/usr/install_linux_x86_64.md
similarity index 87%
rename from doc/install_linux_x86_64.md
rename to doc/reference/usr/install_linux_x86_64.md
index 73bbd25b66945d2d223e15ce80fb32a2148613fc..02dc1e31769aeb5dfbbd20793be48e4e88df02d0 100644
--- a/doc/install_linux_x86_64.md
+++ b/doc/reference/usr/install_linux_x86_64.md
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-19 15:42:42
- * @LastEditTime: 2021-10-19 16:36:13
+ * @LastEditTime: 2021-11-01 09:16:11
* @Description: This files is for
*
* @Modify History:
@@ -20,11 +20,11 @@ Linux x86_64下通过通过下载SDK开发工具包完成安装,运行脚本`s
Linux x86_64安装包集成了,
- `gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz`和`gcc-arm-10.3-2021.07-x86_64-arm-none-eabi.tar.xz`,aarch64交叉编译链,SDK安装过程中会被解压到DEV目录的`cross_tool`目录下
-- `update_sdk_dev.sh`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装
+- `setup_dev.py`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装
## 1.1 获取SDK的开发环境
-- [Linux x86_64](https://pan.baidu.com/s/1FhKiB_HxD0JCTOg-BGPoEg )
+- [Linux x86_64](https://pan.baidu.com/s/1uUrXUC90RA1PvGnSGAaMwA )
>提取码:LX64
@@ -37,9 +37,9 @@ Linux x86_64安装包集成了,

-- (2). 进入DEV目录,运行`source ./update_sdk_dev.sh`,安装开发环境
+- (2). 进入DEV目录,运行`./setup_dev.py`,安装开发环境
-
+
-(3). 通过git拉取Phytium Standalone SDK的代码,如
diff --git a/doc/install_windows.md b/doc/reference/usr/install_windows.md
similarity index 93%
rename from doc/install_windows.md
rename to doc/reference/usr/install_windows.md
index 3f1e3ba79553cabb4db14f766a4c359864e04a48..d617f627a9667aa15eb238338f1355a20d24a27f 100644
--- a/doc/install_windows.md
+++ b/doc/reference/usr/install_windows.md
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-10-19 15:01:34
- * @LastEditTime: 2021-10-19 16:40:46
+ * @LastEditTime: 2021-11-01 09:17:15
* @Description: This files is for
*
* @Modify History:
@@ -15,7 +15,7 @@
Windows 10 SDK开发环境集成了,
- `msys64`,Msys2 portable环境, 主要提供Windows上的shell命令行开发环境,包括了Cygwin (POSIX 兼容性层) 和 MinGW-w64(从"MinGW-生成")
-- `update_sdk_dev`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装
+- `setup_dev.py`, 安装脚本,主要的功能包括创建sdk的profile文件,创建`PHYTIUM_DEV_PATH`环境变量,通过git拉取SDK源码,以及完成SDK安装
- `gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf.tar.xz`和`gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi.tar.xz`, mingw64交叉编译链, SDK安装过程中会被解压到DEV目录的`cross_tool`目录下
- `tftp`, tftp工具, 提供tftp服务,用于开发板下载二进制镜像文件,主要的功能包括安装tftp32服务和配置tftp目录
- `run_msys2.cmd`,用于打开和配置msys2 shell的脚本,需要设置`PHYTIUM_DEV_PATH`后才能使用
@@ -25,7 +25,7 @@ Windows 10 SDK开发环境集成了,
## 1.1 获取SDK的开发环境
-- [Windows10](https://pan.baidu.com/s/1U4tmaM4ENJ305Xq11rI9-w )
+- [Windows10](https://pan.baidu.com/s/1jWtM6EkOJUef6erTpbUajw )
>提取码:WX64
- Windows环境下可以用通用的unzip工具解压,如7zip和winrar
@@ -36,9 +36,9 @@ Windows 10 SDK开发环境集成了,

-- (2). 进入DEV目录,双击脚本`run_msys2.cmd`, 进入msys2控制台, 运行`source ./update_sdk_dev.sh`,注册开发环境
+- (2). 进入DEV目录,双击脚本`run_msys2.cmd`, 进入msys2控制台, 运行`./setup_dev.py`,注册开发环境
-
+
-(3). DEV目录注册完成后,通过git拉取Phytium Standalone SDK的代码,如
diff --git a/doc/usage.md b/doc/reference/usr/usage.md
similarity index 100%
rename from doc/usage.md
rename to doc/reference/usr/usage.md
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 64e68ac5b6ff5a4dfd6f23072ec12028e3562abb..344ebd2227aabe995eb7aa121bcc6f5c65636758 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -1,4 +1,7 @@
-config USE_DW_I2C
+config USE_FI2C
bool
- prompt "Use DW I2C"
- default n
\ No newline at end of file
+ prompt "Use FI2C"
+ default n
+ depends on TARGET_F2000_4 || TARGET_D2000 || TARGET_E2000
+ help
+ Include FI2C driver component
\ No newline at end of file
diff --git a/drivers/i2c/dw_i2c/dw_i2c.c b/drivers/i2c/dw_i2c/dw_i2c.c
deleted file mode 100644
index 2249d02c40709690a94870df7817abb72167097c..0000000000000000000000000000000000000000
--- a/drivers/i2c/dw_i2c/dw_i2c.c
+++ /dev/null
@@ -1,760 +0,0 @@
-/*
- * Copyright (c) 2021 Phytium Information Technology, Inc.
- *
- * SPDX-License-Identifier: Apache-2.0.
- *
- * @Date: 2021-07-26 16:27:51
- * @LastEditTime: 2021-08-04 08:31:13
- * @Description: This files is for i2c ctrl function implementation
- *
- * @Modify History:
- * Ver Who Date Changes
- * ----- ------ -------- --------------------------------------
- * 1.0 Zhugengyu 2021/8/3 init
- */
-#include
-#include "kernel.h"
-#include "parameters.h"
-#include "sdkconfig.h"
-#include "ft_assert.h"
-#include "dw_i2c.h"
-#include "dw_i2c_hw.h"
-#include "fsleep.h"
-
-/* io mux definition for ft2000-4 */
-#ifdef CONFIG_TARGET_F2000_4
-#ifndef CONFIG_USE_IOMUX
- #error "please enable io mux module first!!"
-#endif
-#include "f_iomux.h"
-
-/* i2c io mux */
-#define I2C_0_SCL_MUX IOMUX_I2C_0_SCL_PAD
-#define I2C_0_SDA_MUX IOMUX_I2C_0_SDA_PAD
-#define I2C_0_SCL_FUN FUN0
-#define I2C_0_SDA_FUN FUN0
-
-#define I2C_1_SCL_MUX IOMUX_ALL_PLL_LOCK_PAD
-#define I2C_1_SDA_MUX IOMUX_ALL_PLL_LOCK_PAD
-#define I2C_1_SCL_FUN FUN2
-#define I2C_1_SDA_FUN FUN2
-
-#define I2C_2_SCL_MUX IOMUX_SWDO_SWJ_PAD
-#define I2C_2_SDA_MUX IOMUX_TDO_SWJ_PAD
-#define I2C_2_SCL_FUN FUN2
-#define I2C_2_SDA_FUN FUN2
-
-#define I2C_3_SCL_MUX IOMUX_HDT_MB_DONE_STATE_PAD
-#define I2C_3_SDA_MUX IOMUX_HDT_MB_FAIL_STATE_PAD
-#define I2C_3_SCL_FUN FUN2
-#define I2C_3_SDA_FUN FUN2
-
-#endif
-
-typedef struct
-{
- I2cSpeed speedMode;
- u32 sclLcnt;
- u32 sclHcnt;
- u32 sdaHold;
-}I2cSpeedConfig; /* speed related configs */
-
-typedef struct
-{
- u32 speed;
- u32 minSclHightimeNs;
- u32 minSclLowtimeNs;
- u32 defRisetimeNs;
- u32 defFalltimeNs;
-}I2cSpeedModeInfo; /* speed calculation related configs */
-
-/* info of i2c bus speed mode */
-static const I2cSpeedModeInfo speedModeInfo[I2C_SPEED_MODE_MAX] = {
- [I2C_STANDARD_SPEED] = {
- I2C_SPEED_STANDARD_RATE,
- I2C_MIN_SS_SCL_HIGHTIME,
- I2C_MIN_SS_SCL_LOWTIME,
- 1000,
- 300,
- },
- [I2C_FAST_SPEED] = {
- I2C_SPEED_FAST_RATE,
- I2C_MIN_FS_SCL_HIGHTIME,
- I2C_MIN_FS_SCL_LOWTIME,
- 300,
- 300,
- },
- [I2C_HIGH_SPEED] = {
- I2C_SPEED_HIGH_RATE,
- I2C_MIN_HS_SCL_HIGHTIME,
- I2C_MIN_HS_SCL_LOWTIME,
- 120,
- 120,
- },
-};
-
-/**
- * @name: I2cEnable
- * @msg: enable or disable i2c ctrl
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- * @param {boolean} enable
- */
-u32 I2cEnable(I2cCtrl *pCtrl, boolean enable)
-{
- FT_ASSERTZERONUM(pCtrl);
-
- u32 status = enable ? I2C_IC_ENABLE : I2C_IC_DISABLE;
- u32 timeout = I2C_TIMEOUT;
-
- do
- {
- I2C_ENABLE(pCtrl, status);
- if ((I2C_ENABLE_STAT(pCtrl) & I2C_IC_ENABLE_MASK) == status)
- {
- return I2C_SUCCESS;
- }
- } while (0 != timeout--);
-
- I2C_INFO("timeout in %sabling I2C adapter", enable ? "en" : "dis");
- return I2C_ERR_TIMEOUT;
-}
-
-/**
- * I2cCalcCounts() - Convert a period to a number of IC clk cycles
- *
- * @icClk: Input clock in Hz
- * @periodNs: Period to represent, in ns
- * @return calculated count
- */
-static uint32_t I2cCalcCounts(uint32_t busClk, uint32_t periodNs)
-{
- return DIV_ROUND_UP(busClk / 1000 * periodNs, NANO_TO_KILO);
-}
-
-/**
- * @name: I2cCalcTiming
- * @msg: calculate i2c bus speed parameters
- * @return {*}
- * @param {I2cSpeedConfig} *speedCfg
- * @param {u32} icClk
- * @param {u32} spkCnt
- */
-static u32 I2cCalcTiming(I2cSpeedConfig *speedCfg, u32 icClk, u32 spkCnt)
-{
- FT_ASSERTZERONUM(speedCfg);
- int fallCnt, riseCnt, minTlowCnt, minThighCnt;
- int hcnt, lcnt, periodCnt, diff, tot;
- int sdaHoldTimeNs, sclRiseTimeNs, sclFallTimeNs;
- I2cSpeed mode = speedCfg->speedMode;
-
- const I2cSpeedModeInfo *pInfo = &speedModeInfo[mode];
- periodCnt = icClk / pInfo->speed;
- sclRiseTimeNs = pInfo->defRisetimeNs;
- sclFallTimeNs = pInfo->defFalltimeNs;
- riseCnt = I2cCalcCounts(icClk, sclRiseTimeNs);
- fallCnt = I2cCalcCounts(icClk, sclFallTimeNs);
- minTlowCnt = I2cCalcCounts(icClk, pInfo->minSclLowtimeNs);
- minThighCnt = I2cCalcCounts(icClk, pInfo->minSclHightimeNs);
-
- I2C_INFO("i2c: mode %d, icClk %d, speed %d, period %d rise %d fall %d tlow %d thigh %d spk %d\n",
- mode, icClk, pInfo->speed, periodCnt, riseCnt, fallCnt,
- minTlowCnt, minThighCnt, spkCnt);
-
- /*
- * Back-solve for hcnt and lcnt according to the following equations:
- * SCL_High_time = [(HCNT + IC_*_SPKLEN + 7) * icClk] + SCL_Fall_time
- * SCL_Low_time = [(LCNT + 1) * icClk] - SCL_Fall_time + SCL_Rise_time
- */
- hcnt = minThighCnt - fallCnt - 7 - spkCnt;
- lcnt = minTlowCnt - riseCnt + fallCnt - 1;
-
- if (hcnt < 0 || lcnt < 0)
- {
- I2C_ERROR("i2c: bad counts. hcnt = %d lcnt = %d\n", hcnt, lcnt);
- return I2C_ERR_INVAL_PARM;
- }
-
- /*
- * Now add things back up to ensure the period is hit. If it is off,
- * split the difference and bias to lcnt for remainder
- */
- tot = hcnt + lcnt + 7 + spkCnt + riseCnt + 1;
-
- if (tot < periodCnt)
- {
- diff = (periodCnt - tot) / 2;
- hcnt += diff;
- lcnt += diff;
- tot = hcnt + lcnt + 7 + spkCnt + riseCnt + 1;
- lcnt += periodCnt - tot;
- }
-
- speedCfg->sclLcnt = lcnt;
- speedCfg->sclHcnt = hcnt;
-
- /* Use internal default unless other value is specified */
- sdaHoldTimeNs = I2C_DEFAULT_SDA_HOLD_TIME;
- speedCfg->sdaHold = I2cCalcCounts(icClk, sdaHoldTimeNs);
-
- I2C_INFO("i2c: hcnt = %d lcnt = %d sda hold = %d\n", hcnt, lcnt,
- speedCfg->sdaHold);
-
- return I2C_SUCCESS;
-}
-
-/**
- * @name: I2cCalcBusSpeed
- * @msg: calculate bus speed
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- * @param {u32} speed
- * @param {u32} busClk
- * @param {I2cSpeedConfig} *speedCfg
- */
-static u32 I2cCalcBusSpeed(I2cCtrl *pCtrl, u32 speed, u32 busClk, I2cSpeedConfig *speedCfg)
-{
- FT_ASSERTZERONUM(pCtrl && speedCfg);
- u32 spkCnt = 0;
- u32 ret = I2C_SUCCESS;
-
- if (I2C_SPEED_HIGH_RATE <= speed)
- {
- speedCfg->speedMode = I2C_HIGH_SPEED;
- }
- else if (I2C_SPEED_FAST_RATE <= speed)
- {
- speedCfg->speedMode = I2C_FAST_SPEED;
- }
- else if (I2C_SPEED_STANDARD_RATE <= speed)
- {
- speedCfg->speedMode = I2C_STANDARD_SPEED;
- }
- else
- {
- return I2C_ERR_INVAL_PARM;
- }
-
- spkCnt = (I2C_HIGH_SPEED == speedCfg->speedMode) ?
- I2C_READ_HS_SPKEN(pCtrl) :
- I2C_READ_FS_SPKEN(pCtrl);
-
- ret = I2cCalcTiming(speedCfg, busClk, spkCnt);
- return ret;
-}
-
-/**
- * @name: I2cSetBusSpeed
- * @msg: set i2c bus speed
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- * @param {u32} speed, speed mode
- * @param {u32} busClk, bus clk
- */
-static u32 I2cSetBusSpeed(I2cCtrl *pCtrl, u32 speed, u32 busClk)
-{
- FT_ASSERTZERONUM(pCtrl);
- u32 ret = I2C_SUCCESS;
- I2cSpeedConfig speedCfg;
- u32 enableStatus;
- u32 regVal;
-
- memset(&speedCfg, 0, sizeof(speedCfg));
- ret = I2cCalcBusSpeed(pCtrl, speed, busClk, &speedCfg);
- if (I2C_SUCCESS != ret)
- return ret;
-
- /* Get enable setting for restore later */
- enableStatus = I2C_ENABLE_STAT(pCtrl);
-
- /* to set speed cltr must be disabled */
- (void)I2cEnable(pCtrl, FALSE);
-
- /* clear speed mode bits */
- regVal = (I2C_READ_CON(pCtrl) & (~I2C_CON_SPEED_MASK));
-
- switch (speedCfg.speedMode)
- {
- case I2C_STANDARD_SPEED:
- regVal |= I2C_CON_STD_SPEED;
- I2C_WRITE_REG32(pCtrl, I2C_SS_SCL_HCNT_OFFSET, speedCfg.sclHcnt);
- I2C_WRITE_REG32(pCtrl, I2C_SS_SCL_LCNT_OFFSET, speedCfg.sclLcnt);
- break;
- case I2C_FAST_SPEED:
- regVal |= I2C_CON_FAST_SPEED;
- I2C_WRITE_REG32(pCtrl, I2C_FS_SCL_HCNT_OFFSET, speedCfg.sclHcnt);
- I2C_WRITE_REG32(pCtrl, I2C_FS_SCL_LCNT_OFFSET, speedCfg.sclLcnt);
- break;
- case I2C_HIGH_SPEED:
- regVal |= I2C_CON_HIGH_SPEED;
- I2C_WRITE_REG32(pCtrl, I2C_HS_SCL_HCNT_OFFSET, speedCfg.sclHcnt);
- I2C_WRITE_REG32(pCtrl, I2C_HS_SCL_LCNT_OFFSET, speedCfg.sclLcnt);
- break;
- default:
- ret |= I2C_ERR_INVAL_PARM;
- break;
- }
-
- I2C_WRITE_CON(pCtrl, regVal);
-
- /* Configure SDA Hold Time if required */
- if (0 != speedCfg.sdaHold)
- {
- I2C_WRITE_REG32(pCtrl, I2C_SDA_HOLD_OFFSET, speedCfg.sdaHold);
- }
-
- /* Restore back i2c now speed set */
- if (I2C_IC_ENABLE == enableStatus)
- {
- ret |= I2cEnable(pCtrl, TRUE);
- }
-
- return ret;
-}
-
-/**
- * @name: I2cReset
- * @msg: reset i2c reset
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- */
-u32 I2cReset(I2cCtrl *pCtrl)
-{
- FT_ASSERTZERONUM(pCtrl);
-
- I2cConfig *pConfig = &pCtrl->config;
- u32 regVal = 0;
- u32 ret = I2C_SUCCESS;
-
- ret = I2cEnable(pCtrl, FALSE);
-
- if (I2C_IS_MASTER(pCtrl))
- {
- regVal |= (pConfig->use7bitAddr) ? I2C_CON_MASTER_ADR_7BIT : I2C_CON_MASTER_ADR_10BIT;
- regVal |= I2C_CON_SLAVE_DISABLE;
- regVal |= I2C_CON_MASTER_MODE;
- regVal |= I2C_CON_RESTART_EN;
- /* set as standard speed first,
- set bus speed in following procedure */
- regVal |= I2C_CON_STD_SPEED;
- }
- else /* for slave mode */
- {
- regVal |= (pConfig->use7bitAddr) ? I2C_CON_SLAVE_ADR_7BIT : I2C_CON_SLAVE_ADR_10BIT;
- regVal |= I2C_CON_SLAVE_MODE;
- regVal |= I2C_CON_STD_SPEED;
- }
-
- I2C_WRITE_CON(pCtrl, regVal);
-
- I2C_WRITE_RX_TL(pCtrl, I2C_RX_TL_MASK & pConfig->rxThres);
- I2C_WRITE_TX_TL(pCtrl, I2C_TX_TL_MASK & pConfig->txThres);
- I2cSetIntrruptMask(pCtrl, I2C_INTR_ALL_MASK, FALSE); /* disable all intr */
-
- ret |= I2cSetBusSpeed(pCtrl, pConfig->busSpeed, pConfig->refClk);
- ret |= I2cEnable(pCtrl, TRUE);
-
- return ret;
-}
-
-/**
- * @name: I2cSetIoMux
- * @msg: set io mux
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- */
-static void I2cSetIoMux(I2cCtrl *pCtrl)
-{
-/* set io mux for ft2000-4 */
-#ifdef CONFIG_TARGET_F2000_4
- int sclPadOff, sdaPadOff;
- PadFun sclFun, sdaFun;
-
- switch (pCtrl->config.instanceId)
- {
- case I2C_INSTANCE_0:
- sclPadOff = I2C_0_SCL_MUX;
- sdaPadOff = I2C_0_SDA_MUX;
- sclFun = I2C_0_SCL_FUN;
- sdaFun = I2C_0_SDA_FUN;
- break;
- case I2C_INSTANCE_1:
- sclPadOff = I2C_1_SCL_MUX;
- sdaPadOff = I2C_1_SDA_MUX;
- sclFun = I2C_1_SCL_FUN;
- sdaFun = I2C_1_SDA_FUN;
- break;
- case I2C_INSTANCE_2:
- sclPadOff = I2C_2_SCL_MUX;
- sdaPadOff = I2C_2_SDA_MUX;
- sclFun = I2C_2_SCL_FUN;
- sdaFun = I2C_2_SDA_FUN;
- break;
- case I2C_INSTANCE_3:
- sclPadOff = I2C_3_SCL_MUX;
- sdaPadOff = I2C_3_SDA_MUX;
- sclFun = I2C_3_SCL_FUN;
- sdaFun = I2C_3_SDA_FUN;
- break;
- default:
- FT_ASSERTVOID(0);
- break;
- }
-
- FIomuxSetFun(sclPadOff, sclFun);
- FIomuxSetFun(sdaPadOff, sdaFun);
-#endif
-}
-
-extern u32 I2cEnableIntr(I2cCtrl *pCtrl);
-/**
- * @name: I2cInit
- * @msg: init i2c ctrl in slave / master mode
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- * @param {const I2cConfig} *pConfig
- */
-u32 I2cInit(I2cCtrl *pCtrl, const I2cConfig *pConfig)
-{
- FT_ASSERTZERONUM(pCtrl && pConfig);
- u32 ret = I2C_SUCCESS;
-
- if (pConfig != &pCtrl->config)
- pCtrl->config = *pConfig;
-
- I2cSetIoMux(pCtrl); /* set io mux */
-
- ret = I2cReset(pCtrl);
-
- if (I2C_SUCCESS == ret)
- {
- pCtrl->isReady = FT_COMPONENT_IS_READY;
- pCtrl->curTrans = 0;
- pCtrl->lastErr = 0;
- pCtrl->prv = NULL;
- ret = I2cEnableIntr(pCtrl);
- }
-
- return ret;
-}
-
-/**
- * @name: I2cWaitStatus
- * @msg: block wait stat occur
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- * @param {u32} statBit, stat to wait
- */
-static u32 I2cWaitStatus(I2cCtrl *pCtrl, u32 statBit)
-{
- FT_ASSERTZERONUM(pCtrl);
- u32 timeout = I2C_TIMEOUT;
-
- /* wait until statbit was set or timeout */
- do
- {
- fsleep_millisec(2); //wait 2 ms
- } while (!(I2C_STATUS(pCtrl) & statBit) && (0 != --timeout));
-
- return (0 != timeout) ?I2C_SUCCESS: I2C_ERR_TIMEOUT;
-}
-
-/**
- * @name: I2cWaitBusBusy
- * @msg: block wait bus busy
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- */
-static u32 I2cWaitBusBusy(I2cCtrl *pCtrl)
-{
- FT_ASSERTZERONUM(pCtrl);
- u32 timeout = I2C_TIMEOUT;
- u32 ret = I2C_SUCCESS;
-
- if ((I2C_STATUS(pCtrl) & I2C_STATUS_MST_ACTIVITY) &&
- (I2C_SUCCESS != I2cWaitStatus(pCtrl, I2C_STATUS_TFE)))
- {
- ret = I2C_ERR_TIMEOUT;
- I2C_ERROR("timeout in wait i2c bus busy");
- }
-
- return ret;
-}
-
-/**
- * @name: I2cSetAddr
- * @msg: set slave addr for master i2c ctrl
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- * @param {u8} slaveAddr
- */
-static void I2cSetAddr(I2cCtrl *pCtrl, u8 slaveAddr)
-{
- u32 regVal = 0;
- (void)I2cEnable(pCtrl, FALSE);
-
- if (I2C_IS_MASTER(pCtrl))
- {
- regVal |= slaveAddr & I2C_IC_TAR_MASK;
- I2C_WRITE_TAR(pCtrl, regVal);
- }
- else
- {
- regVal |= slaveAddr & I2C_IC_SAR_MASK;
- I2C_WRITE_SAR(pCtrl, regVal);
- }
-
- (void)I2cEnable(pCtrl, TRUE);
-}
-
-/**
- * @name: I2cTransStart
- * @msg: start i2c read/write transaction
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- * @param {const I2cTransPack} *pRead
- */
-static u32 I2cTransStart(I2cCtrl *pCtrl, const I2cTransPack *pRead)
-{
- FT_ASSERTZERONUM(pCtrl && pRead);
- u32 ret = I2C_SUCCESS;
- u32 addrLen = pRead->addrLen;
- u32 regVal;
-
- ret = I2cWaitBusBusy(pCtrl);
- if (I2C_SUCCESS != ret)
- return ret;
-
- I2cSetAddr(pCtrl, pRead->slaveAddr);
-
- while(addrLen)
- {
- if (I2C_SUCCESS != I2cWaitStatus(pCtrl, I2C_STATUS_TFNF))
- {
- ret = I2C_ERR_TIMEOUT;
- I2C_ERROR("timeout in trans start");
- break;
- }
-
- if (I2C_STATUS(pCtrl) & I2C_STATUS_TFNF)
- {
- addrLen--;
- regVal = (pRead->inChipAddr >> (addrLen * BITS_PER_BYTE)) & I2C_DATA_MASK;
- I2C_WRITE_DATCMD(pCtrl, regVal);
- }
- }
-
- return ret;
-}
-
-/**
- * @name: I2cFlushRxFifo
- * @msg: flush rx fifo by read
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- */
-static void I2cFlushRxFifo(I2cCtrl *pCtrl)
-{
- FT_ASSERTVOID(pCtrl);
- u32 regVal;
-
- while (I2C_STATUS(pCtrl) & I2C_STATUS_RFNE)
- {
- regVal = I2C_READ_DATCMD(pCtrl) & I2C_DATA_MASK;
- }
-}
-
-/**
- * @name: I2cTransStop
- * @msg: stop i2c read/write transaction
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- */
-static u32 I2cTransStop(I2cCtrl *pCtrl)
-{
- FT_ASSERTZERONUM(pCtrl);
- u32 regVal;
- u32 timeout = I2C_TIMEOUT;
- u32 ret = I2C_SUCCESS;
-
- I2C_INFO("GET MASTER STOP, stat: 0x%x, 0x%x",
- I2C_READ_INTR_STAT(pCtrl),
- I2C_READ_RAW_INTR_STAT(pCtrl));
- while (1)
- {
- if (I2C_READ_RAW_INTR_STAT(pCtrl) & I2C_INTR_STOP_DET)
- {
- regVal = I2C_READ_REG32(pCtrl, I2C_CLR_STOP_DET_OFFSET); /* read to clr intr status */
- break;
- }
- else if (0 == --timeout)
- {
- break;
- }
- }
-
- ret = I2cWaitBusBusy(pCtrl);
- if (I2C_SUCCESS == ret)
- {
- I2cFlushRxFifo(pCtrl);
- }
-
- return ret;
-}
-
-/**
- * @name: I2cMasterRead
- * @msg: trigger read transaction for master
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- * @param {I2cTransPack} *pRead, read buf and releated parameters
- */
-u32 I2cMasterRead(I2cCtrl *pCtrl, I2cTransPack *pRead)
-{
- FT_ASSERTZERONUM(pCtrl && pRead);
- u32 ret = I2C_SUCCESS;
- u32 bufLen = pRead->bufLen;
- u32 active = 0;
- int trans = (int)bufLen;
- int rxLimit, txLimit;
- u32 transTimout = 0;
- u32 regVal;
-
- ret = I2cTransStart(pCtrl, pRead);
- if (I2C_SUCCESS != ret)
- return ret;
-
- /* TODO:
- 触发一次发送之后去读一次fifo数据可能会无法完成,故触发与接收异步处理
- iic fifo 深度为8
- 还有很多不清楚的地方,目前尝试可以连续发送了,原因不明
- 主要时添加了 txLimit 判断,但是理论上没有关联
- */
- while (bufLen)
- {
- rxLimit = 8 - I2C_READ_REG32(pCtrl, I2C_RXFLR_OFFSET);
- txLimit = 8 - I2C_READ_REG32(pCtrl, I2C_TXFLR_OFFSET);
-
- if (rxLimit > 0 && txLimit > 0 && trans > 0) /* trans one byte if fifo has room */
- {
- if(trans == 1)
- {
- regVal = I2C_DATA_CMD_READ | I2C_DATA_CMD_STOP ;
- }
- else
- {
- regVal = I2C_DATA_CMD_READ;
- }
- I2C_WRITE_DATCMD(pCtrl, regVal);
-
- trans--;
- rxLimit--;
- }
-
- /* wait for rx data */
- if (I2C_STATUS(pCtrl) & I2C_STATUS_RFNE)
- {
- /* trans one byte */
- *pRead->transBuf++ = (u8)(I2C_READ_DATCMD(pCtrl) & I2C_DATA_MASK);
- bufLen--;
- transTimout = 0;
- }
- else if (I2C_TIMEOUT < ++transTimout)
- {
- ret = I2C_ERR_TIMEOUT;
- I2C_ERROR("timeout in i2c master read");
- break;
- }
-
- fsleep_millisec(2); //wait 2 ms, critical
- }
-
- if (I2C_SUCCESS == ret)
- {
- ret = I2cTransStop(pCtrl);
- }
-
- return ret;
-}
-
-/**
- * @name: I2cMasterWrite
- * @msg: i2c 发送多字节数据
- * * |slave_addr W|--|addr|--|slave_addr W|--|buffer|
- * @return {*}
- * @param {I2cCtrl} *pCtrl ,i2c ctrl blk
- * @param {I2cTransPack} *pWrite ,write ctrl blk
- */
-u32 I2cMasterWrite(I2cCtrl *pCtrl, I2cTransPack *pWrite)
-{
- FT_ASSERTZERONUM(pCtrl && pWrite);
- u32 ret = I2C_SUCCESS;
- u32 bufLen = pWrite->bufLen;
- u32 transTimout = 0;
- u32 regVal;
-
- ret = I2cTransStart(pCtrl, pWrite);
- if (I2C_SUCCESS != ret)
- return ret;
-
- while (bufLen)
- {
- if (I2C_STATUS(pCtrl) & I2C_STATUS_TFNF)
- {
- if (1 == bufLen)
- {
- regVal = (I2C_DATA_MASK & *pWrite->transBuf) |
- I2C_DATA_CMD_WRITE |
- I2C_DATA_CMD_STOP;
- I2C_INFO("Write Stop Singal");
- }
- else
- {
- regVal = (I2C_DATA_MASK & *pWrite->transBuf) |
- I2C_DATA_CMD_WRITE;
- }
- bufLen--;
-
- I2C_WRITE_DATCMD(pCtrl, regVal);
- pWrite->transBuf++;
- transTimout = 0;
- }
- else if (I2C_TIMEOUT < ++transTimout)
- {
- ret = I2C_ERR_TIMEOUT;
- I2C_ERROR("timeout in i2c master write");
- break;
- }
-
- fsleep_millisec(1); //wait 2 ms
- }
-
- if (I2C_SUCCESS == ret)
- {
- ret = I2cTransStop(pCtrl);
- }
-
- return ret;
-}
-
-/**
- * @name: I2cDumpInfo
- * @msg: dump i2c ctrl setting and status
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- */
-void I2cDumpInfo(I2cCtrl *pCtrl)
-{
- FT_ASSERTVOID(pCtrl);
- I2cConfig *pConfig = &pCtrl->config;
-
- I2C_INFO("=====basic info");
- I2C_INFO("work mode: %s", (I2C_MASTER == pConfig->workMode) ? "master" : "slave");
- I2C_INFO("ctrl id: %d, base addr: 0x%x", pConfig->instanceId, pConfig->baseAddr);
- I2C_INFO("=====status info");
- I2C_INFO("onoff: %s", I2C_ENABLE_STAT(pCtrl) ? "ON" : "OFF");
- I2C_INFO("ctrl reg: 0x%x", I2C_READ_CON(pCtrl));
- I2C_INFO("status reg: 0x%x", I2C_STATUS(pCtrl));
- I2C_INFO("intr mask: 0x%x", I2C_READ_INTR_MASK(pCtrl));
- I2C_INFO("intr status: 0x%x", I2C_READ_RAW_INTR_STAT(pCtrl));
-}
\ No newline at end of file
diff --git a/drivers/i2c/dw_i2c/dw_i2c.h b/drivers/i2c/dw_i2c/dw_i2c.h
deleted file mode 100644
index d3513a7d3d4fe37964d1270cad2594741f5a194b..0000000000000000000000000000000000000000
--- a/drivers/i2c/dw_i2c/dw_i2c.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2021 Phytium Information Technology, Inc.
- *
- * SPDX-License-Identifier: Apache-2.0.
- *
- * @Date: 2021-07-26 16:27:00
- * @LastEditTime: 2021-08-03 18:23:43
- * @Description: This files is for i2c ctrl function definition
- *
- * @Modify History:
- * Ver Who Date Changes
- * ----- ------ -------- --------------------------------------
- * 1.0 Zhugengyu 2021/8/3 init
- */
-#ifndef BSP_DRIVERS_DW_I2C_H
-#define BSP_DRIVERS_DW_I2C_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "ft_types.h"
-#include "ft_debug.h"
-#include "ft_error_code.h"
-
-typedef enum
-{
- I2C_MASTER = 0, /* i2c主设备 */
- I2C_SLAVE /* i2c从设备 */
-} I2cWorkMode; /* i2c 控制器工作模式 */
-
-typedef enum
-{
- I2C_STANDARD_SPEED = 0,
- I2C_FAST_SPEED,
- I2C_HIGH_SPEED,
-
- I2C_SPEED_MODE_MAX
-}I2cSpeed;/* i2c 总线传输速度模式,标准、快速和高速 */
-
-typedef enum
-{
- /* slave mode evt */
- I2C_EVT_SLAVE_READ_REQUESTED,
- I2C_EVT_SLAVE_WRITE_REQUESTED,
- I2C_EVT_SLAVE_READ_PROCESSED,
- I2C_EVT_SLAVE_WRITE_RECEIVED,
- I2C_EVT_SLAVE_STOP,
-
- /* master mode evt */
- I2C_EVT_MASTER_TRANS_ABORTED,
- I2C_EVT_MASTER_READ_DONE,
- I2C_EVT_MASTER_WRITE_DONE,
-
- MAX_I2C_INTR_EVT
-}I2cIntrEvent;/* i2c 中断事件 */
-
-typedef enum
-{
- I2C_SPEED_STANDARD_RATE = 100000, /* 100kb/s */
- I2C_SPEED_FAST_RATE = 400000, /* 400kb/s */
- I2C_SPEED_HIGH_RATE = 3400000, /* 3.4MB/s */
-}I2cSpeedRate;/* i2c 总线传输速度,标准、快速和高速 */
-typedef struct
-{
- u32 instanceId;/* i2c 控制器id */
- u32 baseAddr;/* i2c寄存器基地址 */
- u32 irqNum;/* i2c中断号 */
- u32 irqPrority;/* i2c中断优先级 */
- u32 workMode;/* i2c控制器工作模式 */
- u32 busSpeed;/* i2c总线速率 */
- u32 refClk;/* i2c中断优先级 */
- u32 rxThres;/* i2c rx fifo 中断阈值 */
- u32 txThres;/* i2c tx fifo 中断阈值 */
- boolean use7bitAddr;/* true: 使用7bit 地址,false: 使用10bit 地址 */
- char instanceName[12];/* instance name */
-}I2cConfig;/* i2c 主/从控制器配置 */
-
-typedef void (*I2cEvtHandler)(void *pCtrl);
-#define I2C_CALL_EVT_HANDLER(evt, pCtrl) \
- if (NULL != (pCtrl)->evtHandlers[(evt)]) \
- { \
- (pCtrl)->evtHandlers[evt]((pCtrl)); \
- }
-
-typedef struct
-{
- I2cConfig config;/* i2c 控制器配置 */
- u32 isReady;/* i2c 控制器初始化完成标志 */
- /* i2c trans 中间变量 */
- u32 curTrans;
- u32 lastErr;
- void *prv;
-
- I2cEvtHandler evtHandlers[MAX_I2C_INTR_EVT];/* i2c事件回调函数 */
-}I2cCtrl;
-
-typedef struct
-{
- u32 slaveAddr; /* i2c从设备地址 */
- u32 addrLen; /* i2c从设备地址长度(字节数) */
- u8 *transBuf; /* 读写数据存放地址 */
- u32 bufLen; /* 读写数据长度 */
- u8 inChipAddr; /* i2c从设备片内地址 */
-} I2cTransPack;
-
-const I2cConfig *I2cLookupConfig(u32 instanceId);
-u32 I2cInit(I2cCtrl *pCtrl, const I2cConfig *pConfig);
-void I2cRegisterEvtCallback(I2cCtrl *pCtrl, I2cIntrEvent evt, I2cEvtHandler handler);
-u32 I2cGetIntrruptMask(I2cCtrl *pCtrl);
-void I2cSetIntrruptMask(I2cCtrl *pCtrl, u32 mask, boolean enable);
-u32 I2cMasterRead(I2cCtrl *pCtrl, I2cTransPack *pRead);
-u32 I2cMasterWrite(I2cCtrl *pCtrl, I2cTransPack *pWrite);
-void I2cDumpInfo(I2cCtrl *pCtrl);
-
-#define I2C_SUCCESS FT_SUCCESS
-#define I2C_ERR_INVAL_PARM FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, BIT(1))
-#define I2C_ERR_NOT_READY FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, BIT(2))
-#define I2C_ERR_TIMEOUT FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, BIT(3))
-#define I2C_ERR_NOT_SUPPORT FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, BIT(4))
-
-#define I2C_DEBUG_TAG "I2C"
-#define I2C_ERROR(format, ...) FT_DEBUG_PRINT_E(I2C_DEBUG_TAG, format, ##__VA_ARGS__)
-#define I2C_INFO(format, ...) FT_DEBUG_PRINT_I(I2C_DEBUG_TAG, format, ##__VA_ARGS__)
-#define I2C_DEBUG(format, ...) FT_DEBUG_PRINT_D(I2C_DEBUG_TAG, format, ##__VA_ARGS__)
-
-#define I2C_TIMEOUT 500
-#define I2C_IS_MASTER(pCtrl) (I2C_MASTER == (pCtrl)->config.workMode)
-#define I2C_IS_SLAVE(pCtrl) (I2C_SLAVE == (pCtrl)->config.workMode)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
\ No newline at end of file
diff --git a/drivers/i2c/dw_i2c/dw_i2c_g.c b/drivers/i2c/dw_i2c/dw_i2c_g.c
deleted file mode 100644
index d34c3c1f3ee21bee340fd5d2d0c5ee130461edd4..0000000000000000000000000000000000000000
--- a/drivers/i2c/dw_i2c/dw_i2c_g.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2021 Phytium Information Technology, Inc.
- *
- * SPDX-License-Identifier: Apache-2.0.
- *
- * @Date: 2021-07-26 16:28:18
- * @LastEditTime: 2021-08-03 17:17:55
- * @Description: This files is for static config of i2c ctrl
- *
- * @Modify History:
- * Ver Who Date Changes
- * ----- ------ -------- --------------------------------------
- * 1.0 Zhugengyu 2021/8/3 init
- */
-#include "parameters.h"
-#include "dw_i2c.h"
-
-/* default configs of i2c ctrl */
-static I2cConfig I2cConfigTbl[I2C_INSTANCE_NUM] =
-{
- {
- .instanceId = I2C_INSTANCE_0,
- .baseAddr = I2C_0_BASEADDR,
- .irqNum = I2C_0_INTR_IRQ,
- .irqPrority = 0,
- .workMode = I2C_MASTER,
- .busSpeed = I2C_SPEED_STANDARD_RATE,
- .refClk = I2C_REF_CLK_HZ,
- .rxThres = 0,
- .txThres = 0,
- .use7bitAddr = TRUE,
- .instanceName = "I2C-0"
- },
-
- {
- .instanceId = I2C_INSTANCE_1,
- .baseAddr = I2C_1_BASEADDR,
- .irqNum = I2C_1_INTR_IRQ,
- .irqPrority = 1,
- .workMode = I2C_SLAVE,
- .busSpeed = I2C_SPEED_STANDARD_RATE,
- .refClk = I2C_REF_CLK_HZ,
- .rxThres = 0,
- .txThres = 0,
- .use7bitAddr = TRUE,
- .instanceName = "I2C-1"
- },
-
- {
- .instanceId = I2C_INSTANCE_2,
- .baseAddr = I2C_2_BASEADDR,
- .irqNum = I2C_2_INTR_IRQ,
- .irqPrority = 0,
- .workMode = I2C_MASTER,
- .busSpeed = I2C_SPEED_STANDARD_RATE,
- .refClk = I2C_REF_CLK_HZ,
- .rxThres = 0,
- .txThres = 0,
- .use7bitAddr = TRUE,
- .instanceName = "I2C-2"
- },
-
- {
- .instanceId = I2C_INSTANCE_3,
- .baseAddr = I2C_3_BASEADDR,
- .irqNum = I2C_3_INTR_IRQ,
- .irqPrority = 0,
- .workMode = I2C_MASTER,
- .busSpeed = I2C_SPEED_STANDARD_RATE,
- .refClk = I2C_REF_CLK_HZ,
- .rxThres = 0,
- .txThres = 0,
- .use7bitAddr = TRUE,
- .instanceName = "I2C-3"
- }
-};
-
-/**
- * @name: I2cLookupConfig
- * @msg: get i2c configs by id
- * @return {*}
- * @param {u32} instanceId, id of i2c ctrl
- */
-const I2cConfig *I2cLookupConfig(u32 instanceId)
-{
- I2cConfig *pConfig = NULL;
- u32 index;
-
- for (index = 0; index < (u32)I2C_INSTANCE_NUM; index++)
- {
- if (I2cConfigTbl[index].instanceId == instanceId)
- {
- pConfig = &I2cConfigTbl[index];
- break;
- }
- }
-
- return (I2cConfig *)pConfig;
-}
\ No newline at end of file
diff --git a/drivers/i2c/dw_i2c/dw_i2c_hw.h b/drivers/i2c/dw_i2c/dw_i2c_hw.h
deleted file mode 100644
index 5817ad94a8758c3f822856d030fa893d50157fc0..0000000000000000000000000000000000000000
--- a/drivers/i2c/dw_i2c/dw_i2c_hw.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright (c) 2021 Phytium Information Technology, Inc.
- *
- * SPDX-License-Identifier: Apache-2.0.
- *
- * @Date: 2021-07-26 16:27:42
- * @LastEditTime: 2021-08-04 11:44:20
- * @Description: This files is for low-level ctrl of i2c functions
- *
- * @Modify History:
- * Ver Who Date Changes
- * ----- ------ -------- --------------------------------------
- * 1.0 Zhugengyu 2021/8/3 init
- */
-#ifndef BSP_DRIVERS_DW_I2C_HW_H
-#define BSP_DRIVERS_DW_I2C_HW_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "kernel.h"
-#include "ft_types.h"
-#include "ft_io.h"
-#include "dw_i2c.h"
-
-/* Register Definition */
-#define I2C_CON_OFFSET 0x00
-#define I2C_TAR_OFFSET 0x04
-#define I2C_SAR_OFFSET 0x08
-#define I2C_HS_MADDR_OFFSET 0x0C
-#define I2C_DATA_CMD_OFFSET 0x10
-#define I2C_SS_SCL_HCNT_OFFSET 0x14
-#define I2C_SS_SCL_LCNT_OFFSET 0x18
-#define I2C_FS_SCL_HCNT_OFFSET 0x1C
-#define I2C_FS_SCL_LCNT_OFFSET 0x20
-#define I2C_HS_SCL_HCNT_OFFSET 0x24
-#define I2C_HS_SCL_LCNT_OFFSET 0x28
-#define I2C_INTR_STAT_OFFSET 0x2C
-#define I2C_INTR_MASK_OFFSET 0x30
-#define I2C_RAW_INTR_STAT_OFFSET 0x34
-#define I2C_RX_TL_OFFSET 0x38
-#define I2C_TX_TL_OFFSET 0x3C
-#define I2C_CLR_INTR_OFFSET 0x40
-#define I2C_CLR_RX_UNDER_OFFSET 0x44
-#define I2C_CLR_RX_OVER_OFFSET 0x48
-#define I2C_CLR_TX_OVER_OFFSET 0x4C
-#define I2C_CLR_RD_REQ_OFFSET 0x50
-#define I2C_CLR_TX_ABRT_OFFSET 0x54
-#define I2C_CLR_RX_DONE_OFFSET 0x58
-#define I2C_CLR_ACTIVITY_OFFSET 0x5c
-#define I2C_CLR_STOP_DET_OFFSET 0x60
-#define I2C_CLR_START_DET_OFFSET 0x64
-#define I2C_CLR_GEN_CALL_OFFSET 0x68
-#define I2C_ENABLE_OFFSET 0x6C
-#define I2C_STATUS_OFFSET 0x70
-#define I2C_TXFLR_OFFSET 0x74
-#define I2C_RXFLR_OFFSET 0x78
-#define I2C_SDA_HOLD_OFFSET 0x7c
-#define I2C_TX_ABRT_SOURCE_OFFSET 0x80
-#define I2C_SLV_DATA_NACK_ONLY_OFFSET 0x84
-#define I2C_DMA_CR_OFFSET 0x88
-#define I2C_DMA_TDLR_OFFSET 0x8c
-#define I2C_DMA_RDLR_OFFSET 0x90
-#define I2C_SDA_SETUP_OFFSET 0x94
-#define I2C_ACK_GENERAL_CALL_OFFSET 0x98
-#define I2C_ENABLE_STATUS_OFFSET 0x9C
-#define I2C_FS_SPKLEN_OFFSET 0xa0
-#define I2C_HS_SPKLEN_OFFSET 0xa4
-#define I2C_COMP_PARAM_1_OFFSET 0xf4
-#define I2C_COMP_VERSION_OFFSET 0xf8
-#define I2C_COMP_TYPE_OFFSET 0xfc
-
-//IC_CON
-#define I2C_CON_MASTER_MODE (0x1 << 0)
-#define I2C_CON_SLAVE_MODE (0x0 << 0)
-
-#define I2C_CON_SPEED_MASK GENMASK(2, 1)
-#define I2C_CON_STD_SPEED (0x1 << 1)
-#define I2C_CON_FAST_SPEED (0x2 << 1)
-#define I2C_CON_HIGH_SPEED (0x3 << 1)
-
-/* for slave mode */
-#define I2C_CON_SLAVE_ADR_7BIT (0x0 << 3)
-#define I2C_CON_SLAVE_ADR_10BIT (0x1 << 3)
-
-/* for master mode */
-#define I2C_CON_MASTER_ADR_7BIT (0x0 << 4)
-#define I2C_CON_MASTER_ADR_10BIT (0x1 << 4)
-
-#define I2C_CON_RESTART_EN (0x1 << 5)
-#define I2C_CON_SLAVE_DISABLE (0x1 << 6)
-
-//IC_TAR
-#define I2C_IC_TAR_MASK GENMASK(9, 0)
-#define I2C_GC_OR_START (0x1 << 10)
-#define I2C_SPECIAL (0x1 << 11)
-#define I2C_TAR_ADR_7BIT (0x0 << 12)
-#define I2C_TAR_ADR_10BIT (0x1 << 12)
-
-//IC_SAR
-#define I2C_IC_SAR_MASK GENMASK(9, 0) //Slave addr when in slave mode
-
-//IC_HS_MADDR
-#define I2C_IC_HS_MAR GENMASK(2, 0) //I2C High Speed模式主机编码
-
-//IC_DATA_CMD
-#define I2C_DATA_MASK GENMASK(7, 0)
-#define I2C_DATA_CMD_READ (0x1 << 8)
-#define I2C_DATA_CMD_WRITE (0x0 << 8)
-#define I2C_DATA_CMD_STOP (0x1 << 9)
-#define I2C_DATA_CMD_RESTART (0x1 << 10)
-
-//IC_INTR_MASK & IC_INTR_STAT & IC_RAW_INTR_STAT
-#define I2C_INTR_RX_UNDER (0x1 << 0)
-#define I2C_INTR_RX_OVER (0x1 << 1)
-#define I2C_INTR_RX_FULL (0x1 << 2)
-#define I2C_INTR_TX_OVER (0x1 << 3)
-#define I2C_INTR_TX_EMPTY (0x1 << 4)
-#define I2C_INTR_RD_REQ (0x1 << 5)
-#define I2C_INTR_TX_ABRT (0x1 << 6)
-#define I2C_INTR_RX_DONE (0x1 << 7)
-#define I2C_INTR_ACTIVITY (0x1 << 8)
-#define I2C_INTR_STOP_DET (0x1 << 9)
-#define I2C_INTR_START_DET (0x1 << 10)
-#define I2C_INTR_GEN_CALL (0x1 << 11)
-
-#define I2C_INTR_ALL_MASK 0x8FF
-#define I2C_INTR_MASTER_DEF_MASK (I2C_INTR_RX_FULL | I2C_INTR_TX_ABRT |\
- I2C_INTR_STOP_DET)
-#define I2C_INTR_SLAVE_DEF_MASK (I2C_INTR_RX_FULL | I2C_INTR_STOP_DET | \
- I2C_INTR_RD_REQ | I2C_INTR_RX_DONE | \
- I2C_INTR_RX_UNDER | I2C_INTR_TX_ABRT | \
- I2C_INTR_START_DET )
-
-//IC_RX_TL
-#define I2C_RX_TL_MASK GENMASK(7, 0)
-
-//IC_TX_TL
-#define I2C_TX_TL_MASK GENMASK(7, 0)
-
-//IC_ENABLE
-#define I2C_ENABLE_CONTROLLER 0x01
-#define I2C_DISABLE_CONTROLLER 0x00
-
-//IC_STATUS
-#define I2C_STATUS_ACTIVITY BIT(0)
-#define I2C_STATUS_TFNF BIT(1)
-#define I2C_STATUS_TFE BIT(2)
-#define I2C_STATUS_RFNE BIT(3)
-#define I2C_STATUS_RFF BIT(4)
-#define I2C_STATUS_MST_ACTIVITY BIT(5)
-#define I2C_STATUS_SLV_ACTIVITY BIT(6)
-
-//IC_ENABLE_STATUS
-#define I2C_IC_ENABLE (0x1 << 0)
-#define I2C_IC_DISABLE (0x0 << 0)
-#define I2C_IC_ENABLE_MASK (0x1 << 0)
-
-#define I2C_SLV_DISABLED_WHILE_BUSY (0x1 << 1)
-#define I2C_SLV_RX_DATA_LOST (0x1 << 2)
-
-/* High and low times in different speed modes (in ns) */
-#define I2C_MIN_SS_SCL_HIGHTIME 4000
-#define I2C_MIN_SS_SCL_LOWTIME 4700
-#define I2C_MIN_FS_SCL_HIGHTIME 600
-#define I2C_MIN_FS_SCL_LOWTIME 1300
-#define I2C_MIN_FP_SCL_HIGHTIME 500
-#define I2C_MIN_FP_SCL_LOWTIME 500
-#define I2C_MIN_HS_SCL_HIGHTIME 60
-#define I2C_MIN_HS_SCL_LOWTIME 160
-#define I2C_DEFAULT_SDA_HOLD_TIME 300
-
-/* I2C Register Operations */
-#define I2C_BASE_ADDR(pCtrl) ((pCtrl)->config.baseAddr)
-/**
- * @name: I2C_READ_REG32
- * @msg: 读取I2C寄存器
- * @param {u32} addr 定时器的基地址
- * @param {u32} reg_offset 定时器的寄存器的偏移
- * @return {u32} 寄存器参数
- */
-#define I2C_READ_REG32(pCtrl, reg_offset) FtIn32(I2C_BASE_ADDR(pCtrl) + (u32)(reg_offset))
-
-/**
- * @name: I2C_WRITE_REG32
- * @msg: 写入I2C寄存器
- * @param {u32} addr 定时器的基地址
- * @param {u32} reg_offset 定时器的寄存器的偏移
- * @param {u32} reg_value 写入寄存器参数
- * @return {void}
- */
-#define I2C_WRITE_REG32(pCtrl, reg_offset, reg_value) FtOut32(I2C_BASE_ADDR(pCtrl) + (u32)(reg_offset), (u32)(reg_value))
-
-#define I2C_ENABLE(pCtrl, regVal) I2C_WRITE_REG32(pCtrl, I2C_ENABLE_OFFSET, (regVal))
-#define I2C_ENABLE_STAT(pCtrl) I2C_READ_REG32(pCtrl, I2C_ENABLE_STATUS_OFFSET)
-#define I2C_STATUS(pCtrl) I2C_READ_REG32(pCtrl, I2C_STATUS_OFFSET)
-#define I2C_WRITE_CON(pCtrl, regVal) I2C_WRITE_REG32(pCtrl, I2C_CON_OFFSET, (regVal))
-#define I2C_READ_CON(pCtrl) I2C_READ_REG32(pCtrl, I2C_CON_OFFSET)
-#define I2C_WRITE_RX_TL(pCtrl, regVal) I2C_WRITE_REG32(pCtrl, I2C_RX_TL_OFFSET, (regVal))
-#define I2C_WRITE_TX_TL(pCtrl, regVal) I2C_WRITE_REG32(pCtrl, I2C_TX_TL_OFFSET, (regVal))
-#define I2C_WRITE_INTR_MASK(pCtrl, regVal) I2C_WRITE_REG32(pCtrl, I2C_INTR_MASK_OFFSET, (regVal))
-#define I2C_READ_INTR_MASK(pCtrl) I2C_READ_REG32(pCtrl, I2C_INTR_MASK_OFFSET)
-#define I2C_READ_FS_SPKEN(pCtrl) I2C_READ_REG32(pCtrl, I2C_FS_SPKLEN_OFFSET)
-#define I2C_READ_HS_SPKEN(pCtrl) I2C_READ_REG32(pCtrl, I2C_HS_SPKLEN_OFFSET)
-#define I2C_WRITE_TAR(pCtrl, regVal) I2C_WRITE_REG32(pCtrl, I2C_TAR_OFFSET, (regVal))
-#define I2C_WRITE_SAR(pCtrl, regVal) I2C_WRITE_REG32(pCtrl, I2C_SAR_OFFSET, (regVal))
-#define I2C_WRITE_DATCMD(pCtrl, regVal) I2C_WRITE_REG32(pCtrl, I2C_DATA_CMD_OFFSET, (regVal))
-#define I2C_READ_DATCMD(pCtrl) I2C_READ_REG32(pCtrl, I2C_DATA_CMD_OFFSET)
-#define I2C_READ_RAW_INTR_STAT(pCtrl) I2C_READ_REG32(pCtrl, I2C_RAW_INTR_STAT_OFFSET)
-#define I2C_READ_INTR_STAT(pCtrl) I2C_READ_REG32(pCtrl, I2C_INTR_STAT_OFFSET)
-#define I2C_CLEAR_ALL_IRQ(pCtrl) I2C_READ_REG32(pCtrl, I2C_CLR_INTR_OFFSET)
-
-u32 I2cEnable(I2cCtrl *pCtrl, boolean enable);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
\ No newline at end of file
diff --git a/drivers/i2c/dw_i2c/dw_i2c_intr.c b/drivers/i2c/dw_i2c/dw_i2c_intr.c
deleted file mode 100644
index 187753a90f220893f068c9f681b268b6bd973626..0000000000000000000000000000000000000000
--- a/drivers/i2c/dw_i2c/dw_i2c_intr.c
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright (c) 2021 Phytium Information Technology, Inc.
- *
- * SPDX-License-Identifier: Apache-2.0.
- *
- * @Date: 2021-07-26 16:27:59
- * @LastEditTime: 2021-09-06 14:56:15
- * @Description: This files is for intrrupt function of i2c ctrl
- *
- * @Modify History:
- * Ver Who Date Changes
- * ----- ------ -------- --------------------------------------
- * 1.0 Zhugengyu 2021/8/3 init
- */
-#include "parameters.h"
-#include "ft_assert.h"
-#include "dw_i2c.h"
-#include "dw_i2c_hw.h"
-// #include "gicv3.h"
-#include "interrupt.h"
-
-/**
- * @name: I2cClearIntrBits
- * @msg: read and clear intrrupt status bits
- * @return {*}
- * @param {I2cCtrl} *pCtrl, ctrl block of i2c
- */
-static u32 I2cClearIntrBits(I2cCtrl *pCtrl)
-{
- FT_ASSERTZERONUM(pCtrl);
-
- const u32 stat = I2C_READ_INTR_STAT(pCtrl);
-
- if (stat & I2C_INTR_TX_ABRT)
- {
- pCtrl->lastErr = I2C_READ_REG32(pCtrl, I2C_TX_ABRT_SOURCE_OFFSET); /* read out abort sources */
- I2C_READ_REG32(pCtrl, I2C_CLR_TX_ABRT_OFFSET);
- }
-
- if (stat & I2C_INTR_RX_UNDER)
- I2C_READ_REG32(pCtrl, I2C_CLR_RX_UNDER_OFFSET);
-
- if (stat & I2C_INTR_RX_OVER)
- I2C_READ_REG32(pCtrl, I2C_CLR_RX_OVER_OFFSET);
-
- if (stat & I2C_INTR_TX_OVER)
- I2C_READ_REG32(pCtrl, I2C_CLR_TX_OVER_OFFSET);
-
- if (stat & I2C_INTR_RX_DONE)
- I2C_READ_REG32(pCtrl, I2C_CLR_RX_DONE_OFFSET);
-
- if (stat & I2C_INTR_ACTIVITY)
- I2C_READ_REG32(pCtrl, I2C_CLR_ACTIVITY_OFFSET);
-
- if (stat & I2C_INTR_STOP_DET)
- I2C_READ_REG32(pCtrl, I2C_CLR_STOP_DET_OFFSET);
-
- if (stat & I2C_INTR_START_DET)
- I2C_READ_REG32(pCtrl, I2C_CLR_START_DET_OFFSET);
-
- if (stat & I2C_INTR_GEN_CALL)
- I2C_READ_REG32(pCtrl, I2C_CLR_GEN_CALL_OFFSET);
-
- return stat;
-}
-
-/**
- * @name: I2cDefaultEvtCb
- * @msg: default callback function of events
- * @return {*}
- * @param {void} *pPara, parameters, pass ctrl block pointer here
- */
-void I2cDefaultEvtCb(void *pPara)
-{
- FT_ASSERTVOID(pPara);
- I2cCtrl *pCtrl = (I2cCtrl *)pPara;
- const u32 status = I2C_READ_INTR_STAT(pCtrl);
-
- I2C_INFO("i2c id: 0x%x, intr cause: 0x%x", pCtrl->config.instanceId, status);
-}
-
-
-/**
- * @name: I2cRegisterEvtCallback
- * @msg: regist events callback function
- * @return {*}
- * @param {I2cCtrl} *pCtrl, i2c ctrl block
- * @param {I2cIntrEvent} evt, event
- * @param {I2cEvtHandler} handler, event callback function ptr
- */
-void I2cRegisterEvtCallback(I2cCtrl *pCtrl, I2cIntrEvent evt, I2cEvtHandler handler)
-{
- FT_ASSERTVOID(pCtrl && evt < MAX_I2C_INTR_EVT);
- pCtrl->evtHandlers[evt] = handler;
-}
-
-/**
- * @name: I2cSlaveIntrHandler
- * @msg: handle intrrupt for i2c ctrl in slave mode, refer to i2c_designware_slave.c of linux 4.9
- * @return {*}
- * @param {I2cCtrl} *pCtrl, i2c ctrl block
- */
-static void I2cSlaveIntrHandler(I2cCtrl *pCtrl)
-{
- FT_ASSERTVOID(pCtrl);
- I2cEvtHandler evtHandler;
- boolean slaveActive = (I2C_STATUS(pCtrl) & I2C_STATUS_SLV_ACTIVITY) ? TRUE : FALSE;
- u32 rawIntrStat = I2C_READ_RAW_INTR_STAT(pCtrl);
- u32 stat = I2cClearIntrBits(pCtrl);
- u32 enable = I2C_READ_REG32(pCtrl, I2C_ENABLE_OFFSET);
-
- if (!(enable & I2C_IC_ENABLE) || !(rawIntrStat & ~I2C_INTR_ACTIVITY) ||
- (I2C_SLAVE != pCtrl->config.workMode))
- {
- return;
- }
-
- /* when receive stop singal from master */
- if (rawIntrStat & I2C_INTR_STOP_DET)
- {
- I2C_CALL_EVT_HANDLER(I2C_EVT_SLAVE_WRITE_REQUESTED, pCtrl)
- }
-
- /* when receive RD Requst singal from master */
- if ((stat & I2C_INTR_RD_REQ) && slaveActive )
- {
- if (stat & I2C_INTR_RX_FULL)
- {
- pCtrl->curTrans = (I2C_DATA_MASK & I2C_READ_DATCMD(pCtrl));
- I2C_CALL_EVT_HANDLER(I2C_EVT_SLAVE_WRITE_RECEIVED, pCtrl)
- I2C_READ_REG32(pCtrl, I2C_CLR_RD_REQ_OFFSET);
- }
- else
- {
- I2C_READ_REG32(pCtrl, I2C_CLR_RD_REQ_OFFSET);
- I2C_READ_REG32(pCtrl, I2C_CLR_RX_UNDER_OFFSET);
- }
-
- I2C_CALL_EVT_HANDLER(I2C_EVT_SLAVE_READ_REQUESTED, pCtrl)
- I2C_WRITE_DATCMD(pCtrl, pCtrl->curTrans);
- }
-
- if (stat & I2C_INTR_RX_DONE)
- {
- I2C_CALL_EVT_HANDLER(I2C_EVT_SLAVE_READ_PROCESSED, pCtrl)
- I2C_READ_REG32(pCtrl, I2C_CLR_RX_DONE_OFFSET);
- I2C_CALL_EVT_HANDLER(I2C_EVT_SLAVE_STOP, pCtrl)
- return;
- }
-
- if (stat & I2C_INTR_RX_FULL)
- {
- pCtrl->curTrans = (I2C_DATA_MASK & I2C_READ_DATCMD(pCtrl));
- I2C_CALL_EVT_HANDLER(I2C_EVT_SLAVE_WRITE_RECEIVED, pCtrl)
- }
- else
- {
- I2C_CALL_EVT_HANDLER(I2C_EVT_SLAVE_STOP, pCtrl)
- }
-
- return;
-}
-
-/**
- * @name: I2cMasterIntrHandler
- * @msg: handle intrrupt for i2c ctrl in master mode,
- * refer to i2c_designware_master.c of linux 4.9
- * @return {*}
- * @param {I2cCtrl} *pCtrl, i2c ctrl block
- */
-static void I2cMasterIntrHandler(I2cCtrl *pCtrl)
-{
- FT_ASSERTVOID(pCtrl);
- I2cEvtHandler evtHandler;
- u32 rawIntrStat = I2C_READ_RAW_INTR_STAT(pCtrl);
- u32 stat = I2cClearIntrBits(pCtrl);
- u32 enable = I2C_READ_REG32(pCtrl, I2C_ENABLE_OFFSET);
-
- if (!(enable & I2C_IC_ENABLE) || !(rawIntrStat & ~I2C_INTR_ACTIVITY) ||
- (I2C_MASTER != pCtrl->config.workMode))
- {
- return;
- }
-
- if (stat & I2C_INTR_TX_ABRT) /* trans abort error */
- {
- pCtrl->lastErr = 0;
- pCtrl->lastErr |= I2C_READ_REG32(pCtrl, I2C_TX_ABRT_SOURCE_OFFSET);
- I2C_CALL_EVT_HANDLER(I2C_EVT_MASTER_TRANS_ABORTED, pCtrl)
- I2cSetIntrruptMask(pCtrl, I2C_INTR_ALL_MASK, FALSE); /* disable all intr */
- return;
- }
-
- if (stat & I2C_INTR_RX_FULL) /* rx complete */
- {
- I2C_CALL_EVT_HANDLER(I2C_EVT_MASTER_READ_DONE, pCtrl);
- }
-
- if (stat & I2C_INTR_TX_EMPTY) /* tx complete */
- {
- I2C_CALL_EVT_HANDLER(I2C_EVT_MASTER_WRITE_DONE, pCtrl);
- }
-
- return;
-}
-
-/**
- * @name: I2cIntrHandler
- * @msg: intrrput event entry for i2c ctrl in slave & master mode
- * @return {*}
- * @param {s32} vector, parameters from system intr handler
- * @param {void} *param
- */
-static void I2cIntrHandler(s32 vector, void *param)
-{
- FT_ASSERTVOID(param);
- I2cCtrl *pCtrl = (I2cCtrl *)param;
- I2cEvtHandler evtHandler;
-
- if (I2C_MASTER == pCtrl->config.workMode)
- {
- I2cMasterIntrHandler(pCtrl);
- }
- else if (I2C_SLAVE == pCtrl->config.workMode)
- {
- I2cSlaveIntrHandler(pCtrl);
- }
-
- return;
-}
-
-/**
- * @name: I2cEnableIntr
- * @msg: enable and setup intrrupt for slave & master i2c
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- */
-u32 I2cEnableIntr(I2cCtrl *pCtrl)
-{
- FT_ASSERTZERONUM(pCtrl);
-
- I2cConfig *pConfig = &pCtrl->config;
-
- /* disable all i2c irq */
- I2C_CLEAR_ALL_IRQ(pCtrl);
-
- /* umask i2c irq */
- InterruptSetPriority(pConfig->irqNum, pConfig->irqPrority);
- InterruptInstall(pConfig->irqNum, I2cIntrHandler, pCtrl, pConfig->instanceName);
-
- /* register intr callback */
- if (I2C_MASTER == pConfig->workMode)
- {
- I2cRegisterEvtCallback(pCtrl,
- I2C_EVT_MASTER_TRANS_ABORTED,
- I2cDefaultEvtCb);
- I2cRegisterEvtCallback(pCtrl,
- I2C_EVT_MASTER_READ_DONE,
- I2cDefaultEvtCb);
- I2cRegisterEvtCallback(pCtrl,
- I2C_EVT_MASTER_WRITE_DONE,
- I2cDefaultEvtCb);
-
- /* by default not enable master intr since there is no performance enhance expected */
- I2cSetIntrruptMask(pCtrl, I2C_INTR_MASTER_DEF_MASK, FALSE);
- }
- else if (I2C_SLAVE == pConfig->workMode)
- {
- I2cRegisterEvtCallback(pCtrl,
- I2C_EVT_SLAVE_READ_REQUESTED,
- I2cDefaultEvtCb);
- I2cRegisterEvtCallback(pCtrl,
- I2C_EVT_SLAVE_WRITE_REQUESTED,
- I2cDefaultEvtCb);
- I2cRegisterEvtCallback(pCtrl,
- I2C_EVT_SLAVE_READ_PROCESSED,
- I2cDefaultEvtCb);
- I2cRegisterEvtCallback(pCtrl,
- I2C_EVT_SLAVE_WRITE_RECEIVED,
- I2cDefaultEvtCb);
- I2cRegisterEvtCallback(pCtrl,
- I2C_EVT_SLAVE_STOP,
- I2cDefaultEvtCb);
-
- I2cSetIntrruptMask(pCtrl, I2C_INTR_SLAVE_DEF_MASK, TRUE);
-
- /* enable irq */
- InterruptUmask(pConfig->irqNum);
- }
- else
- {
- FT_ASSERTZERONUM(0);
- }
-
- return I2C_SUCCESS;
-}
-
-/**
- * @name: I2cGetIntrruptMask
- * @msg: get intrrupt mask bits
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- */
-u32 I2cGetIntrruptMask(I2cCtrl *pCtrl)
-{
- FT_ASSERTZERONUM(pCtrl);
- return I2C_READ_INTR_MASK(pCtrl);
-}
-
-/**
- * @name: I2cSetIntrruptMask
- * @msg: set intrrupt mask bits, enable or disable
- * @return {*}
- * @param {I2cCtrl} *pCtrl
- * @param {u32} mask, target intr
- * @param {boolean} enable, TRUE: enable, FALSE: disable
- */
-void I2cSetIntrruptMask(I2cCtrl *pCtrl, u32 mask, boolean enable)
-{
- FT_ASSERTVOID(pCtrl);
-
- /* These bits mask their corresponding interrupt status bits.
- They are active high; a value of 0 prevents a bit from generating an interrupt. */
- if (TRUE == enable)
- {
- I2C_WRITE_INTR_MASK(pCtrl, (mask | I2cGetIntrruptMask(pCtrl))); /* set 1, enable intr */
- }
- else
- {
- I2C_WRITE_INTR_MASK(pCtrl, ((~mask) & I2cGetIntrruptMask(pCtrl))); /* set 0, disable intr */
- }
-}
\ No newline at end of file
diff --git a/drivers/i2c/fi2c/fi2c.c b/drivers/i2c/fi2c/fi2c.c
new file mode 100644
index 0000000000000000000000000000000000000000..d5047ecc17201f30e062f0f78eda344c004f98e9
--- /dev/null
+++ b/drivers/i2c/fi2c/fi2c.c
@@ -0,0 +1,187 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 18:03:25
+ * @LastEditTime: 2021-10-29 15:11:10
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+/***************************** Include Files *********************************/
+#include
+#include "ft_io.h"
+#include "ft_error_code.h"
+#include "ft_types.h"
+#include "ft_debug.h"
+#include "fi2c_hw.h"
+#include "fi2c.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+#define FI2C_DEBUG_TAG "I2C"
+#define FI2C_ERROR(format, ...) FT_DEBUG_PRINT_E(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+#define FI2C_INFO(format, ...) FT_DEBUG_PRINT_I(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+#define FI2C_DEBUG(format, ...) FT_DEBUG_PRINT_D(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+
+/************************** Function Prototypes ******************************/
+
+static FError FI2cReset(FI2c *instance_p);
+
+/************************** Variable Definitions *****************************/
+static const char *FI2C_ERROR_CODE_MSG[FI2C_NUM_OF_ERR_CODE] =
+{
+ "FI2C_SUCCESS : fi2c success",
+ "FI2C_ERR_INVAL_PARM : fi2c invalid input parameters",
+ "FI2C_ERR_NOT_READY : fi2c driver not ready",
+ "FI2C_ERR_TIMEOUT : fi2c wait timeout",
+ "FI2C_ERR_NOT_SUPPORT : fi2c non support operation",
+ "FI2C_ERR_INVAL_STATE : fi2c invalid state"
+};
+
+/*****************************************************************************/
+
+/* 此文件主要为了完成用户对外接口,用户可以使用这些接口直接开始工作 */
+
+/* - 包括用户API的定义和实现
+ - 同时包含必要的OPTION方法,方便用户进行配置
+ - 如果驱动可以直接进行I/O操作,在此源文件下可以将API 进行实现 */
+
+/**
+ * @name: FI2cCfgInitialize
+ * @msg: 完成I2C驱动实例的初始化,使之可以使用
+ * @param {FI2c} *instance_p I2C驱动实例数据
+ * @param {FI2cConfig} *cofig_p I2C驱动配置数据
+ * @return SUCCESS if initialization was successful
+ * ERROR
+ */
+FError FI2cCfgInitialize(FI2c *instance_p, const FI2cConfig *input_config_p)
+{
+ FT_ASSERTZERONUM(instance_p && input_config_p);
+
+ FError ret = FI2C_SUCCESS;
+
+ /*
+ * If the device is started, disallow the initialize and return a Status
+ * indicating it is started. This allows the user to de-initialize the device
+ * and reinitialize, but prevents a user from inadvertently
+ * initializing.
+ */
+ if (FT_COMPONENT_IS_READY == instance_p->is_ready)
+ {
+ FI2C_ERROR("device is already initialized!!!");
+ return FI2C_ERR_INVAL_STATE;
+ }
+
+ /*
+ * Set default values and configuration data, including setting the
+ * callback handlers to stubs so the system will not crash should the
+ * application not assign its own callbacks.
+ */
+ FI2cDeInitialize(instance_p);
+ instance_p->config = *input_config_p;
+
+ /*
+ * Reset the device.
+ */
+ ret = FI2cReset(instance_p);
+ if (FI2C_SUCCESS == ret)
+ {
+ instance_p->is_ready = FT_COMPONENT_IS_READY;
+ }
+
+ return ret;
+}
+
+/**
+ * @name: FI2cDeInitialize
+ * @msg: 完成I2C驱动实例去使能,清零实例数据
+ * @return {*}
+ * @param {FI2c} *instance_p
+ */
+void FI2cDeInitialize(FI2c *instance_p)
+{
+ FT_ASSERTNONERETURN(instance_p);
+ instance_p->is_ready = 0;
+
+ memset(instance_p, 0, sizeof(*instance_p));
+}
+
+/**
+ * @name: FI2cReset
+ * @msg: 重置I2C控制器
+ * @return {*}
+ * @param {FI2c} *instance_p, I2C驱动实例数据
+ */
+static FError FI2cReset(FI2c *instance_p)
+{
+ FT_ASSERTZERONUM(instance_p);
+
+ FError ret = FI2C_SUCCESS;
+ FI2cConfig *config_p = &instance_p->config;
+ uintptr base_addr = config_p->base_addr;
+ u32 reg_val = 0;
+
+ ret = FI2cSetEnable(base_addr, FALSE); /* disable i2c ctrl */
+
+ if (FI2C_MASTER == config_p->work_mode)
+ {
+ reg_val |= (config_p->use_7bit_addr) ? FI2C_CON_MASTER_ADR_7BIT : FI2C_CON_MASTER_ADR_10BIT ;
+ reg_val |= FI2C_CON_SLAVE_DISABLE;
+ reg_val |= FI2C_CON_MASTER_MODE;
+ reg_val |= FI2C_CON_RESTART_EN;
+ }
+ else
+ {
+ reg_val |= (config_p->use_7bit_addr) ? FI2C_CON_SLAVE_ADR_7BIT : FI2C_CON_SLAVE_ADR_10BIT;
+ reg_val |= FI2C_CON_SLAVE_MODE;
+ }
+ reg_val |= FI2C_CON_STD_SPEED;
+
+ FI2C_WRITE_REG32(base_addr, FI2C_CON_OFFSET, reg_val);
+ FI2C_WRITE_REG32(base_addr, FI2C_RX_TL_OFFSET, 0);
+ FI2C_WRITE_REG32(base_addr, FI2C_TX_TL_OFFSET, 0);
+ FI2C_SET_INTRRUPT_MASK(base_addr, 0); /* disable all intr */
+
+ ret = FI2cSetSpeed(base_addr, config_p->speed_rate);
+
+ if (FI2C_SUCCESS == ret)
+ ret = FI2cSetEnable(base_addr, TRUE); /* enable i2c ctrl */
+
+ /* if init successed, and i2c is in slave mode, set slave address */
+ if ((FI2C_SUCCESS == ret) && (FI2C_SLAVE == config_p->work_mode))
+ ret = FI2cSetSar(base_addr, config_p->slave_addr);
+
+ return ret;
+}
+
+/**
+ * @name: FI2cErrorToMessage
+ * @msg: 获取I2C模块错误码对应的错误信息
+ * @return {const char *}, 错误码信息,NULL表示失败
+ * @param {FError} error, I2C输入错误码
+ */
+const char *FI2cErrorToMessage(FError error)
+{
+ const char *msg = NULL;
+ if (FI2C_SUCCESS != error && (FI2C_ERR_CODE_PREFIX != error & (FT_ERRCODE_SYS_MODULE_MASK | FT_ERRCODE_SUB_MODULE_MASK)) )
+ {
+ /* if input error do not belong to this module */
+ return msg;
+ }
+ u32 index = error & FT_ERRCODE_TAIL_VALUE_MASK;
+
+ if (index < FI2C_NUM_OF_ERR_CODE)
+ {
+ msg = FI2C_ERROR_CODE_MSG[index];
+ }
+
+ return msg;
+}
\ No newline at end of file
diff --git a/drivers/i2c/fi2c/fi2c.h b/drivers/i2c/fi2c/fi2c.h
new file mode 100644
index 0000000000000000000000000000000000000000..23b9b2ceeea2bc0ec5cc3c3d4b337af5ab7ee921
--- /dev/null
+++ b/drivers/i2c/fi2c/fi2c.h
@@ -0,0 +1,161 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 18:22:37
+ * @LastEditTime: 2021-10-29 14:41:31
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+
+#ifndef DRIVERS_I2C_FOOXX_H
+#define DRIVERS_I2C_FOOXX_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/***************************** Include Files *********************************/
+
+#include "ft_types.h"
+#include "ft_assert.h"
+#include "ft_error_code.h"
+
+/************************** Constant Definitions *****************************/
+#define FI2C_SUCCESS FT_SUCCESS
+#define FI2C_ERR_INVAL_PARM FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, 1)
+#define FI2C_ERR_NOT_READY FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, 2)
+#define FI2C_ERR_TIMEOUT FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, 3)
+#define FI2C_ERR_NOT_SUPPORT FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, 4)
+#define FI2C_ERR_INVAL_STATE FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, 5)
+
+/* add up new error code above and plust FI2C_ERR_CODE_MAX by ONE*/
+#define FI2C_ERR_CODE_MAX FT_MAKE_ERRCODE(ErrModBsp, ErrBspI2c, 6)
+#define FI2C_ERR_CODE_PREFIX FI2C_ERR_CODE_MAX & (FT_ERRCODE_SYS_MODULE_MASK | FT_ERRCODE_SUB_MODULE_MASK)
+#define FI2C_NUM_OF_ERR_CODE FI2C_ERR_CODE_MAX & FT_ERRCODE_TAIL_VALUE_MASK
+
+enum
+{
+ FI2C_MASTER = 0, /* i2c主设备 */
+ FI2C_SLAVE /* i2c从设备 */
+};
+
+enum
+{
+ FI2C_STANDARD_SPEED = 0,
+ FI2C_FAST_SPEED,
+ FI2C_HIGH_SPEED,
+
+ FI2C_SPEED_MODE_MAX
+};
+
+enum
+{
+ FI2C_SPEED_STANDARD_RATE = 100000, /* 100kb/s */
+ FI2C_SPEED_FAST_RATE = 400000, /* 400kb/s */
+ FI2C_SPEED_HIGH_RATE = 3400000 /* 3.4MB/s */
+};
+
+enum
+{
+ FI2C_EVT_MASTER_TRANS_ABORTED = 0,
+ FI2C_EVT_MASTER_READ_DONE,
+ FI2C_EVT_MASTER_WRITE_DONE,
+
+ FI2C_MASTER_INTR_EVT_NUM
+}; /* master mode evt */
+
+enum
+{
+ FI2C_EVT_SLAVE_READ_REQUESTED = 0,
+ FI2C_EVT_SLAVE_WRITE_REQUESTED,
+ FI2C_EVT_SLAVE_READ_PROCESSED,
+ FI2C_EVT_SLAVE_WRITE_RECEIVED,
+ FI2C_EVT_SLAVE_STOP,
+
+ FI2C_SLAVE_INTR_EVT_NUM
+}; /* slave mode evt */
+
+/**************************** Type Definitions *******************************/
+
+typedef struct
+{
+ u32 instance_id; /**< Device instance id */
+ uintptr base_addr; /**< Device base address */
+ u32 irq_num; /**< Device intrrupt id */
+ u32 irq_prority; /**< Device intrrupt priority */
+ u32 ref_clk_hz; /**< Input reference clock frequency in Hz */
+ u32 work_mode; /**< Device work mode Slave or Master */
+ u32 slave_addr; /**< Slave Address writing/reading to/from */
+ u32 slave_addr_len; /**< Slave Address Bytes */
+ boolean use_7bit_addr; /**< Slave in-chip address offset in 7bit or 10bit */
+ u32 speed_rate; /* I2C speed rate */
+} FI2cConfig; /**< Device configure setting */
+
+typedef void (*FI2cEvtHandler)(void *instance_p, void *param);
+
+typedef struct
+{
+ FI2cConfig config; /**< Current active configs */
+ u32 is_ready; /**< Device is initialized and ready */
+ /** only apply to master device **/
+ /**< Master intrrupt handler */
+ FI2cEvtHandler master_evt_handlers[FI2C_MASTER_INTR_EVT_NUM];
+
+ /** only apply to slave device **/
+ /**< Slave intrrupt handler */
+ FI2cEvtHandler slave_evt_handlers[FI2C_SLAVE_INTR_EVT_NUM];
+
+} FI2c; /**< Device instance */
+
+/************************** Variable Definitions *****************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+/* fi2c_sinit.c */
+/* 获取I2C驱动的默认配置参数 */
+const FI2cConfig *FI2cLookupConfig(u32 instance_id);
+
+/* fi2c.c */
+/* 完成I2C驱动实例的初始化,使之可以使用*/
+FError FI2cCfgInitialize(FI2c *instance_p, const FI2cConfig *cofig_p);
+
+/* 完成I2C驱动实例去使能,清零实例数据 */
+void FI2cDeInitialize(FI2c *instance_p);
+
+/* 获取I2C模块错误码对应的错误信息 */
+const char *FI2cErrorToMessage(FError error);
+
+/* fi2c_master.c */
+/* I2C主机读,阻塞直到完成读操作或失败 */
+FError FI2cMasterReadPoll(FI2c *instance_p, u32 inchip_addr, u8 *buf_p, int buf_len);
+
+/* I2C主机写,阻塞直到完成写操作或失败 */
+FError FI2cMasterWritePoll(FI2c *instance_p, u32 inchip_addr, const u8 *buf_p, size_t buf_len);
+
+/* fi2c_intr.c */
+/* 设置I2C主机的中断 */
+FError FI2cMasterSetupIntrrupt(FI2c *instance_p);
+
+/* 注册I2C主机中断事件函数 */
+void FI2cMasterRegisterIntrruptHandler(FI2c *instance_p, u32 evt, FI2cEvtHandler handler);
+
+/* 设置I2C从机的中断 */
+FError FI2cSlaveSetupIntrrupt(FI2c *instance_p);
+
+/* 注册I2C从机中断事件函数 */
+void FI2cSlaveRegisterIntrruptHandler(FI2c *instance_p, u32 evt, FI2cEvtHandler handler);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/drivers/i2c/fi2c/fi2c_g.c b/drivers/i2c/fi2c/fi2c_g.c
new file mode 100644
index 0000000000000000000000000000000000000000..fa4d9fedb605d17921f19d8a827f24e03836cd19
--- /dev/null
+++ b/drivers/i2c/fi2c/fi2c_g.c
@@ -0,0 +1,97 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 18:56:23
+ * @LastEditTime: 2021-10-29 14:42:25
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+/* - This file contains a configuration table that specifies the configuration
+- 驱动全局变量定义,包括静态配置参数 */
+
+/***************************** Include Files *********************************/
+
+#include "ft_types.h"
+#include "parameters.h"
+#include "fi2c.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Function Prototypes ******************************/
+
+/************************** Variable Definitions *****************************/
+/**
+ * @name: FI2C_CONFIG_TBL
+ * @msg: I2C驱动的默认配置参数
+ */
+const FI2cConfig FI2C_CONFIG_TBL[I2C_INSTANCE_NUM] =
+{
+ [I2C_INSTANCE_0] =
+ {
+ .instance_id = I2C_INSTANCE_0,
+ .base_addr = I2C_0_BASEADDR,
+ .irq_num = I2C_0_INTR_IRQ,
+ .irq_prority = 0,
+ .ref_clk_hz = I2C_REF_CLK_HZ,
+ .work_mode = FI2C_MASTER,
+ .slave_addr = 0,
+ .slave_addr_len = 1,
+ .use_7bit_addr = TRUE,
+ .speed_rate = FI2C_SPEED_STANDARD_RATE
+ },
+
+ [I2C_INSTANCE_1] =
+ {
+ .instance_id = I2C_INSTANCE_1,
+ .base_addr = I2C_1_BASEADDR,
+ .irq_num = I2C_1_INTR_IRQ,
+ .irq_prority = 0,
+ .ref_clk_hz = I2C_REF_CLK_HZ,
+ .work_mode = FI2C_MASTER,
+ .slave_addr = 0,
+ .slave_addr_len = 1,
+ .use_7bit_addr = TRUE,
+ .speed_rate = FI2C_SPEED_STANDARD_RATE
+ },
+
+ [I2C_INSTANCE_2] =
+ {
+ .instance_id = I2C_INSTANCE_2,
+ .base_addr = I2C_2_BASEADDR,
+ .irq_num = I2C_2_INTR_IRQ,
+ .irq_prority = 0,
+ .ref_clk_hz = I2C_REF_CLK_HZ,
+ .work_mode = FI2C_MASTER,
+ .slave_addr = 0,
+ .slave_addr_len = 1,
+ .use_7bit_addr = TRUE,
+ .speed_rate = FI2C_SPEED_STANDARD_RATE
+ },
+
+ [I2C_INSTANCE_3] =
+ {
+ .instance_id = I2C_INSTANCE_3,
+ .base_addr = I2C_3_BASEADDR,
+ .irq_num = I2C_3_INTR_IRQ,
+ .irq_prority = 0,
+ .ref_clk_hz = I2C_REF_CLK_HZ,
+ .work_mode = FI2C_MASTER,
+ .slave_addr = 0,
+ .slave_addr_len = 1,
+ .use_7bit_addr = TRUE,
+ .speed_rate = FI2C_SPEED_STANDARD_RATE
+ }
+};
+
+
+/*****************************************************************************/
diff --git a/drivers/i2c/fi2c/fi2c_hw.c b/drivers/i2c/fi2c/fi2c_hw.c
new file mode 100644
index 0000000000000000000000000000000000000000..0ec39243a0df5b8e54c5dcb8ea7ab325ba365516
--- /dev/null
+++ b/drivers/i2c/fi2c/fi2c_hw.c
@@ -0,0 +1,439 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 22:05:37
+ * @LastEditTime: 2021-10-29 15:02:23
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+/***************************** Include Files *********************************/
+#include
+#include "fsleep.h"
+#include "ft_debug.h"
+#include "ft_error_code.h"
+#include "ft_assert.h"
+#include "fi2c_hw.h"
+#include "fi2c.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+typedef struct
+{
+ u32 speed_mode;
+ u32 scl_lcnt;
+ u32 scl_hcnt;
+ u32 sda_hold;
+}FI2cSpeedCfg; /* speed related configs */
+
+typedef struct
+{
+ u32 speed;
+ u32 min_scl_hightime_ns;
+ u32 min_scl_lowtime_ns;
+ u32 def_risetime_ns;
+ u32 def_falltime_ns;
+}FI2cSpeedModeInfo; /* speed calculation related configs */
+
+/************************** Variable Definitions *****************************/
+static const FI2cSpeedModeInfo I2C_SPEED_CFG[FI2C_SPEED_MODE_MAX] =
+{
+ [FI2C_STANDARD_SPEED] = {
+ FI2C_SPEED_STANDARD_RATE,
+ 4000,
+ 4700,
+ 1000,
+ 300,
+ },
+ [FI2C_FAST_SPEED] = {
+ FI2C_SPEED_FAST_RATE,
+ 600,
+ 1300,
+ 300,
+ 300,
+ },
+ [FI2C_HIGH_SPEED] = {
+ FI2C_SPEED_HIGH_RATE,
+ 60,
+ 160,
+ 120,
+ 120,
+ },
+};
+
+/***************** Macros (Inline Functions) Definitions *********************/
+#define FI2C_DEBUG_TAG "I2C_HW"
+#define FI2C_ERROR(format, ...) FT_DEBUG_PRINT_E(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+#define FI2C_INFO(format, ...) FT_DEBUG_PRINT_I(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+#define FI2C_DEBUG(format, ...) FT_DEBUG_PRINT_D(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+
+#define FI2C_TIMEOUT 500
+
+/************************** Function Prototypes ******************************/
+/**
+ * @name: FI2cSetEnable
+ * @msg: 设置I2C控制器的使能状态
+ * @return {*}
+ * @param {uintptr} addr, I2c控制器基地址
+ * @param {boolean} enable, TRUE: 使能,FALSE: 去使能
+ */
+FError FI2cSetEnable(uintptr addr, boolean enable)
+{
+ u32 status = enable ? FI2C_IC_ENABLE : FI2C_IC_DISABLE;
+ u32 timeout = FI2C_TIMEOUT;
+
+ do
+ {
+ FI2C_WRITE_REG32(addr, FI2C_ENABLE_OFFSET, status);
+ if (((FI2C_READ_REG32(addr, FI2C_ENABLE_STATUS_OFFSET)) & FI2C_IC_ENABLE_MASK) == status)
+ {
+ return FI2C_SUCCESS;
+ }
+
+ } while (0 != timeout--);
+
+ FI2C_ERROR("timeout in %sabling I2C ctrl", enable ? "en" : "dis");
+ return FI2C_ERR_TIMEOUT;
+}
+
+/**
+ * @name: FI2cCalcTiming
+ * @msg: 计算I2C的上升沿下降沿配置
+ * @return {*}
+ * @param {u32} bus_clk_hz, I2C总线时钟速度 Hz,默认48MHz
+ * @param {u32} spk_cnt, spk数目
+ * @param {FI2cSpeedCfg} *speed_cfg_p,速度配置
+ */
+static FError FI2cCalcTiming(u32 bus_clk_hz, u32 spk_cnt, FI2cSpeedCfg *speed_cfg_p)
+{
+ FT_ASSERTZERONUM(speed_cfg_p);
+ u32 speed_mode = speed_cfg_p->speed_mode;
+ const FI2cSpeedModeInfo *info_p = &I2C_SPEED_CFG[speed_mode];
+ int fall_cnt, rise_cnt, min_t_low_cnt, min_t_high_cnt;
+ int hcnt, lcnt, period_cnt, diff, tot;
+ int sda_hold_time_ns, scl_rise_time_ns, scl_fall_time_ns;
+
+ period_cnt = bus_clk_hz / info_p->speed;
+ scl_rise_time_ns = info_p->def_risetime_ns;
+ scl_fall_time_ns = info_p->def_falltime_ns;
+
+ /* convert a period to a number of IC clk cycles */
+ rise_cnt = DIV_ROUND_UP(bus_clk_hz / 1000 * scl_rise_time_ns, NANO_TO_KILO);
+ fall_cnt = DIV_ROUND_UP(bus_clk_hz / 1000 * scl_fall_time_ns, NANO_TO_KILO);
+ min_t_low_cnt = DIV_ROUND_UP(bus_clk_hz / 1000 * info_p->min_scl_lowtime_ns, NANO_TO_KILO);
+ min_t_high_cnt = DIV_ROUND_UP(bus_clk_hz / 1000 * info_p->min_scl_hightime_ns, NANO_TO_KILO);
+
+ FI2C_INFO("i2c: mode %d, bus_clk %d, speed %d, period %d rise %d fall %d tlow %d thigh %d spk %d\n",
+ speed_mode, bus_clk_hz, info_p->speed, period_cnt, rise_cnt, fall_cnt,
+ min_t_low_cnt, min_t_high_cnt, spk_cnt);
+
+ /*
+ * Back-solve for hcnt and lcnt according to the following equations:
+ * SCL_High_time = [(HCNT + IC_*_SPKLEN + 7) * icClk] + SCL_Fall_time
+ * SCL_Low_time = [(LCNT + 1) * icClk] - SCL_Fall_time + SCL_Rise_time
+ */
+ hcnt = min_t_high_cnt - fall_cnt - 7 - spk_cnt;
+ lcnt = min_t_low_cnt - rise_cnt + fall_cnt - 1;
+
+ if (hcnt < 0 || lcnt < 0)
+ {
+ FI2C_ERROR("i2c: bad counts. hcnt = %d lcnt = %d\n", hcnt, lcnt);
+ return FI2C_ERR_INVAL_PARM;
+ }
+
+ /*
+ * Now add things back up to ensure the period is hit. If it is off,
+ * split the difference and bias to lcnt for remainder
+ */
+ tot = hcnt + lcnt + 7 + spk_cnt + rise_cnt + 1;
+
+ if (tot < period_cnt)
+ {
+ diff = (period_cnt - tot) / 2;
+ hcnt += diff;
+ lcnt += diff;
+ tot = hcnt + lcnt + 7 + spk_cnt + rise_cnt + 1;
+ lcnt += period_cnt - tot;
+ }
+
+ speed_cfg_p->scl_lcnt = lcnt;
+ speed_cfg_p->scl_hcnt = hcnt;
+ speed_cfg_p->sda_hold = DIV_ROUND_UP(bus_clk_hz / 1000 * 300, NANO_TO_KILO); /* Use internal default unless other value is specified */
+
+ FI2C_INFO("i2c: hcnt = %d lcnt = %d sda hold = %d\n",
+ speed_cfg_p->scl_hcnt,
+ speed_cfg_p->scl_lcnt,
+ speed_cfg_p->sda_hold);
+
+ return FI2C_SUCCESS;
+}
+
+/**
+ * @name: FI2cCalcSpeedCfg
+ * @msg: 计算I2C的速度配置
+ * @return {*}
+ * @param {uintptr} addr, I2C控制器基地址
+ * @param {u32} speed, I2C传输速率
+ * @param {u32} bus_clk_hz, I2C时钟频率
+ * @param {FI2cSpeedCfg} *speed_cfg_p, I2C速度配置
+ */
+static FError FI2cCalcSpeedCfg(uintptr addr, u32 speed, u32 bus_clk_hz, FI2cSpeedCfg *speed_cfg_p)
+{
+ FT_ASSERTZERONUM(speed_cfg_p);
+ u32 spk_cnt = 0;
+
+ if (FI2C_SPEED_HIGH_RATE <= speed)
+ speed_cfg_p->speed_mode = FI2C_HIGH_SPEED;
+ else if (FI2C_SPEED_FAST_RATE <= speed)
+ speed_cfg_p->speed_mode = FI2C_FAST_SPEED;
+ else if (FI2C_SPEED_STANDARD_RATE <= speed)
+ speed_cfg_p->speed_mode = FI2C_STANDARD_SPEED;
+ else
+ return FI2C_ERR_INVAL_PARM;
+
+ spk_cnt = (FI2C_HIGH_SPEED == speed_cfg_p->speed_mode) ?
+ FI2C_READ_REG32(addr, FI2C_HS_SPKLEN_OFFSET) :
+ FI2C_READ_REG32(addr, FI2C_FS_SPKLEN_OFFSET);
+
+ return FI2cCalcTiming(bus_clk_hz, spk_cnt, speed_cfg_p);
+}
+
+/**
+ * @name: FI2cSetSpeed
+ * @msg: 设置I2C控制器的速率
+ * @return {*}
+ * @param {uintptr} addr, I2C控制器基地址
+ * @param {u32} speed_rate, I2C传输速率
+ */
+FError FI2cSetSpeed(uintptr addr, u32 speed_rate)
+{
+ FError ret = FI2C_SUCCESS;
+ FI2cSpeedCfg speed_cfg;
+ u32 enable_status;
+ u32 reg_val;
+
+ memset(&speed_cfg, 0, sizeof(speed_cfg));
+ ret = FI2cCalcSpeedCfg(addr, speed_rate, I2C_REF_CLK_HZ, &speed_cfg);
+ if (FI2C_SUCCESS != ret)
+ return ret;
+
+ /* get enable setting for restore later */
+ enable_status = FI2cGetEnable(addr);
+
+ /* reset speed mode bits */
+ reg_val = ((FI2C_READ_REG32(addr, FI2C_CON_OFFSET))& (~FI2C_CON_SPEED_MASK));
+ switch (speed_cfg.speed_mode)
+ {
+ case FI2C_STANDARD_SPEED:
+ reg_val |= FI2C_CON_STD_SPEED;
+ FI2C_WRITE_REG32(addr, FI2C_SS_SCL_HCNT_OFFSET, speed_cfg.scl_hcnt);
+ FI2C_WRITE_REG32(addr, FI2C_SS_SCL_LCNT_OFFSET, speed_cfg.scl_lcnt);
+ break;
+ case FI2C_FAST_SPEED:
+ reg_val |= FI2C_CON_FAST_SPEED;
+ FI2C_WRITE_REG32(addr, FI2C_FS_SCL_HCNT_OFFSET, speed_cfg.scl_hcnt);
+ FI2C_WRITE_REG32(addr, FI2C_FS_SCL_LCNT_OFFSET, speed_cfg.scl_lcnt);
+ break;
+ case FI2C_HIGH_SPEED:
+ reg_val |= FI2C_CON_HIGH_SPEED;
+ FI2C_WRITE_REG32(addr, FI2C_HS_SCL_HCNT_OFFSET, speed_cfg.scl_hcnt);
+ FI2C_WRITE_REG32(addr, FI2C_HS_SCL_LCNT_OFFSET, speed_cfg.scl_lcnt);
+ break;
+ default:
+ ret |= FI2C_ERR_INVAL_PARM;
+ break;
+ }
+
+ FI2C_WRITE_REG32(addr, FI2C_CON_OFFSET, reg_val);
+
+ /* Configure SDA Hold Time if required */
+ if (0 != speed_cfg.sda_hold)
+ FI2C_WRITE_REG32(addr, FI2C_SDA_HOLD_OFFSET, speed_cfg.sda_hold);
+
+ /* Restore back i2c now speed set */
+ if (FI2C_IC_ENABLE == enable_status)
+ {
+ ret |= FI2cSetEnable(addr, TRUE);
+ }
+
+ return ret;
+}
+
+/**
+ * @name: FI2cWaitStatus
+ * @msg: 等待特定的I2C状态位直到状态不存在或者超时
+ * @return {*}
+ * @param {uintptr} addr, I2C控制器基地址
+ * @param {u32} stat_bit, I2C状态位
+ */
+FError FI2cWaitStatus(uintptr addr, u32 stat_bit)
+{
+ u32 timeout = 0;
+
+ /* wait until statbit was set or timeout */
+ do
+ {
+ fsleep_millisec(2); //wait 2 ms
+ } while (!((FI2C_READ_REG32(addr, FI2C_STATUS_OFFSET)) & stat_bit) && (FI2C_TIMEOUT > ++timeout));
+
+ if (FI2C_TIMEOUT <= timeout)
+ {
+ FI2C_ERROR("timeout when wait status: 0x%x", stat_bit);
+ return FI2C_ERR_TIMEOUT;
+ }
+
+ return FI2C_SUCCESS;
+}
+
+/**
+ * @name: FI2cWaitBusBusy
+ * @msg: 等待I2C总线忙
+ * @return {*}
+ * @param {uintptr} addr, I2C控制器基地址
+ */
+FError FI2cWaitBusBusy(uintptr addr)
+{
+ u32 timeout = FI2C_TIMEOUT;
+ u32 ret = FI2C_SUCCESS;
+
+ if (((FI2C_READ_REG32(addr, FI2C_STATUS_OFFSET)) & FI2C_STATUS_MST_ACTIVITY) &&
+ (FI2C_SUCCESS != FI2cWaitStatus(addr, FI2C_STATUS_TFE)))
+ {
+ ret = FI2C_ERR_TIMEOUT;
+ FI2C_ERROR("timeout when wait i2c bus busy");
+ }
+
+ return ret;
+}
+
+/**
+ * @name: FI2cSetTar
+ * @msg: 设置与I2C主机通信的从机地址
+ * @return {*}
+ * @param {uintptr} addr, I2C控制器基地址
+ * @param {u32} tar_addr, I2C从机地址
+ */
+FError FI2cSetTar(uintptr addr, u32 tar_addr)
+{
+ u32 enable_status = FI2cGetEnable(addr);
+ u32 ret = FI2C_SUCCESS;
+ u32 reg_val = 0;
+
+ if (FI2C_IC_ENABLE == enable_status)
+ ret = FI2cSetEnable(addr, FALSE);
+
+ if (FI2C_SUCCESS == ret)
+ FI2C_WRITE_REG32(addr, FI2C_TAR_OFFSET, (tar_addr & FI2C_IC_TAR_MASK));
+
+ if (FI2C_IC_ENABLE == enable_status)
+ ret = FI2cSetEnable(addr, TRUE);
+
+ return ret;
+}
+
+/**
+ * @name: FI2cSetSar
+ * @msg: 从机模式下,设置I2C地址
+ * @return {*}
+ * @param {uintptr} addr, I2C控制器基地址
+ * @param {u32} sar_addr, 作为从机的地址
+ */
+FError FI2cSetSar(uintptr addr, u32 sar_addr)
+{
+ u32 enable_status = FI2cGetEnable(addr);
+ u32 ret = FI2C_SUCCESS;
+ u32 reg_val = 0;
+
+ if (FI2C_IC_ENABLE == enable_status)
+ ret = FI2cSetEnable(addr, FALSE);
+
+ if (FI2C_SUCCESS == ret)
+ FI2C_WRITE_REG32(addr, FI2C_SAR_OFFSET, (sar_addr & FI2C_IC_SAR_MASK));
+
+ if (FI2C_IC_ENABLE == enable_status)
+ ret = FI2cSetEnable(addr, TRUE);
+
+ return ret;
+}
+
+/**
+ * @name: FI2cFlushRxFifo
+ * @msg: 等待接收Fifo传输完成
+ * @return {*}
+ * @param {uintptr} addr, I2C控制器基地址
+ */
+FError FI2cFlushRxFifo(uintptr addr)
+{
+ u8 data;
+ int timeout = 0;
+ FError ret = FI2C_SUCCESS;
+
+ /* read data to trigger trans until fifo empty */
+ while (FI2C_GET_STATUS(addr) & FI2C_STATUS_RFNE)
+ {
+ data = FI2C_READ_DATA(addr);
+
+ if (FI2C_TIMEOUT < ++timeout)
+ {
+ ret = FI2C_TIMEOUT;
+ FI2C_ERROR("timeout when flush fifo");
+ break;
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * @name: FI2cClearIntrBits
+ * @msg: 清除中断状态位,返回清除前的中断状态
+ * @return {*}
+ * @param {uintptr} addr, I2C控制器基地址
+ * @param {u32} *last_err_p, Abort错误
+ */
+u32 FI2cClearIntrBits(uintptr addr, u32 *last_err_p)
+{
+ FT_ASSERTZERONUM(last_err_p);
+
+ const u32 stat = FI2C_READ_INTR_STAT(addr);
+
+ /* read to clr intrrupt status bits */
+ if (stat & FI2C_INTR_TX_ABRT)
+ {
+ *last_err_p = FI2C_READ_REG32(addr, FI2C_TX_ABRT_SOURCE_OFFSET); /* read out abort sources */
+ FI2C_READ_REG32(addr, FI2C_CLR_TX_ABRT_OFFSET);
+ }
+
+ if (stat & FI2C_INTR_RX_UNDER)
+ FI2C_READ_REG32(addr, FI2C_CLR_RX_UNDER_OFFSET);
+
+ if (stat & FI2C_INTR_RX_OVER)
+ FI2C_READ_REG32(addr, FI2C_CLR_RX_OVER_OFFSET);
+
+ if (stat & FI2C_INTR_TX_OVER)
+ FI2C_READ_REG32(addr, FI2C_CLR_TX_OVER_OFFSET);
+
+ if (stat & FI2C_INTR_RX_DONE)
+ FI2C_READ_REG32(addr, FI2C_CLR_RX_DONE_OFFSET);
+
+ if (stat & FI2C_INTR_ACTIVITY)
+ FI2C_READ_REG32(addr, FI2C_CLR_ACTIVITY_OFFSET);
+
+ if (stat & FI2C_INTR_STOP_DET)
+ FI2C_READ_REG32(addr, FI2C_CLR_STOP_DET_OFFSET);
+
+ if (stat & FI2C_INTR_START_DET)
+ FI2C_READ_REG32(addr, FI2C_CLR_START_DET_OFFSET);
+
+ if (stat & FI2C_INTR_GEN_CALL)
+ FI2C_READ_REG32(addr, FI2C_CLR_GEN_CALL_OFFSET);
+
+ return stat;
+}
\ No newline at end of file
diff --git a/drivers/i2c/fi2c/fi2c_hw.h b/drivers/i2c/fi2c/fi2c_hw.h
new file mode 100644
index 0000000000000000000000000000000000000000..ebe887cc590a748b7931de1657034176cebb27ce
--- /dev/null
+++ b/drivers/i2c/fi2c/fi2c_hw.h
@@ -0,0 +1,247 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 22:05:43
+ * @LastEditTime: 2021-10-29 15:02:32
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+#ifndef DRIVERS_I2C_FI2C_HW_H
+#define DRIVERS_I2C_FI2C_HW_H
+
+/* - 传入模块基地址,不能复杂结构体
+- hardware interface of device || low-level driver function prototypes
+
+- 包括驱动寄存器参数和low-level操作定义
+1. 定义寄存器偏移
+2. 对上提供该模块寄存器操作的接口
+3. 一些简单外设提供直接操作接口
+4. 可以定义一些状态的接口,用于响应驱动状态的变化 */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/***************************** Include Files *********************************/
+
+#include "parameters.h"
+#include "ft_io.h"
+#include "ft_error_code.h"
+#include "kernel.h"
+
+/************************** Constant Definitions *****************************/
+
+/** @name Register Map
+ *
+ * Register offsets from the base address of an SD device.
+ * @{
+ */
+#define FI2C_CON_OFFSET 0x00
+#define FI2C_TAR_OFFSET 0x04
+#define FI2C_SAR_OFFSET 0x08
+#define FI2C_HS_MADDR_OFFSET 0x0C
+#define FI2C_DATA_CMD_OFFSET 0x10
+#define FI2C_SS_SCL_HCNT_OFFSET 0x14
+#define FI2C_SS_SCL_LCNT_OFFSET 0x18
+#define FI2C_FS_SCL_HCNT_OFFSET 0x1C
+#define FI2C_FS_SCL_LCNT_OFFSET 0x20
+#define FI2C_HS_SCL_HCNT_OFFSET 0x24
+#define FI2C_HS_SCL_LCNT_OFFSET 0x28
+#define FI2C_INTR_STAT_OFFSET 0x2C
+#define FI2C_INTR_MASK_OFFSET 0x30
+#define FI2C_RAW_INTR_STAT_OFFSET 0x34
+#define FI2C_RX_TL_OFFSET 0x38
+#define FI2C_TX_TL_OFFSET 0x3C
+#define FI2C_CLR_INTR_OFFSET 0x40
+#define FI2C_CLR_RX_UNDER_OFFSET 0x44
+#define FI2C_CLR_RX_OVER_OFFSET 0x48
+#define FI2C_CLR_TX_OVER_OFFSET 0x4C
+#define FI2C_CLR_RD_REQ_OFFSET 0x50
+#define FI2C_CLR_TX_ABRT_OFFSET 0x54
+#define FI2C_CLR_RX_DONE_OFFSET 0x58
+#define FI2C_CLR_ACTIVITY_OFFSET 0x5c
+#define FI2C_CLR_STOP_DET_OFFSET 0x60
+#define FI2C_CLR_START_DET_OFFSET 0x64
+#define FI2C_CLR_GEN_CALL_OFFSET 0x68
+#define FI2C_ENABLE_OFFSET 0x6C
+#define FI2C_STATUS_OFFSET 0x70
+#define FI2C_TXFLR_OFFSET 0x74
+#define FI2C_RXFLR_OFFSET 0x78
+#define FI2C_SDA_HOLD_OFFSET 0x7c
+#define FI2C_TX_ABRT_SOURCE_OFFSET 0x80
+#define FI2C_SLV_DATA_NACK_ONLY_OFFSET 0x84
+#define FI2C_DMA_CR_OFFSET 0x88
+#define FI2C_DMA_TDLR_OFFSET 0x8c
+#define FI2C_DMA_RDLR_OFFSET 0x90
+#define FI2C_SDA_SETUP_OFFSET 0x94
+#define FI2C_ACK_GENERAL_CALL_OFFSET 0x98
+#define FI2C_ENABLE_STATUS_OFFSET 0x9C
+#define FI2C_FS_SPKLEN_OFFSET 0xa0
+#define FI2C_HS_SPKLEN_OFFSET 0xa4
+#define FI2C_COMP_PARAM_1_OFFSET 0xf4
+#define FI2C_COMP_VERSION_OFFSET 0xf8
+#define FI2C_COMP_TYPE_OFFSET 0xfc
+
+/** @name FI2C_CON_OFFSET Register
+ */
+#define FI2C_CON_MASTER_MODE (0x1 << 0)
+#define FI2C_CON_SLAVE_MODE (0x0 << 0)
+
+#define FI2C_CON_SPEED_MASK GENMASK(2, 1)
+#define FI2C_CON_STD_SPEED (0x1 << 1)
+#define FI2C_CON_FAST_SPEED (0x2 << 1)
+#define FI2C_CON_HIGH_SPEED (0x3 << 1)
+
+/* for slave mode */
+#define FI2C_CON_SLAVE_ADR_7BIT (0x0 << 3)
+#define FI2C_CON_SLAVE_ADR_10BIT (0x1 << 3)
+
+/* for master mode */
+#define FI2C_CON_MASTER_ADR_7BIT (0x0 << 4)
+#define FI2C_CON_MASTER_ADR_10BIT (0x1 << 4)
+
+#define FI2C_CON_RESTART_EN (0x1 << 5)
+#define FI2C_CON_SLAVE_DISABLE (0x1 << 6)
+
+/** @name FI2C_IC_TAR_OFFSET Register
+ */
+#define FI2C_IC_TAR_MASK GENMASK(9, 0)
+#define FI2C_GC_OR_START (0x1 << 10)
+#define FI2C_SPECIAL (0x1 << 11)
+#define FI2C_TAR_ADR_7BIT (0x0 << 12)
+#define FI2C_TAR_ADR_10BIT (0x1 << 12)
+
+/** @name FI2C_IC_SAR_OFFSET Register
+ */
+#define FI2C_IC_SAR_MASK GENMASK(9, 0) //Slave addr when in slave mode
+
+/** @name FI2C_IC_HS_MADDR_OFFSET Register
+ */
+#define FI2C_IC_HS_MAR GENMASK(2, 0) //I2C High Speed模式主机编码
+
+/** @name FI2C_IC_DATA_CMD_OFFSET Register
+ */
+#define FI2C_DATA_MASK GENMASK(7, 0)
+#define FI2C_DATA_CMD_READ (0x1 << 8)
+#define FI2C_DATA_CMD_WRITE (0x0 << 8)
+#define FI2C_DATA_CMD_STOP (0x1 << 9)
+#define FI2C_DATA_CMD_RESTART (0x1 << 10)
+
+/** @name FI2C_IC_INTR_MASK_OFFSET Register
+ * @name FI2C_IC_INTR_STAT_OFFSET Register
+ * @name FI2C_IC_RAW_INTR_STAT_OFFSET Register
+ */
+#define FI2C_INTR_RX_UNDER (0x1 << 0) /* 接收缓冲区为空 */
+#define FI2C_INTR_RX_OVER (0x1 << 1) /* 接收缓冲区大小达到 IC_RX_BUFFER_DEPTH ,且还继续从外部接收数据 */
+#define FI2C_INTR_RX_FULL (0x1 << 2) /* 接收缓冲区大于等于 IC_RX_TL 中设定的门限值(RX_TL) */
+#define FI2C_INTR_TX_OVER (0x1 << 3) /* 发送缓冲区大小达到 IC_TX_BUFFER_DEPTH,并且还在尝试写数据 */
+#define FI2C_INTR_TX_EMPTY (0x1 << 4) /* 发送缓冲区小于等于 IC_TX_TL 寄存器中设定的门限值 */
+#define FI2C_INTR_RD_REQ (0x1 << 5) /* 读请求标志 */
+#define FI2C_INTR_TX_ABRT (0x1 << 6) /* I2C 不能完成FIFO内容的传输 */
+#define FI2C_INTR_RX_DONE (0x1 << 7) /* Slave工作模式下,规定时间内没有Master的回应,通信结束 */
+#define FI2C_INTR_ACTIVITY (0x1 << 8) /* I2C 控制器的活动状态 */
+#define FI2C_INTR_STOP_DET (0x1 << 9) /* I2C 总线接口上是否产生了 STOP */
+#define FI2C_INTR_START_DET (0x1 << 10) /* I2C 总线接口上是否产生了 START 或 RESTART */
+#define FI2C_INTR_GEN_CALL (0x1 << 11) /* I2C 总线接口上接收并识别到General Call格式 */
+
+#define FI2C_INTR_ALL_MASK 0x8FF
+#define FI2C_INTR_MASTER_DEF_MASK (I2C_INTR_RX_FULL | FI2C_INTR_TX_ABRT |\
+ FI2C_INTR_STOP_DET)
+#define FI2C_INTR_SLAVE_DEF_MASK (I2C_INTR_RX_FULL | FI2C_INTR_STOP_DET | \
+ FI2C_INTR_RD_REQ | FI2C_INTR_RX_DONE | \
+ FI2C_INTR_RX_UNDER | FI2C_INTR_TX_ABRT | \
+ FI2C_INTR_START_DET )
+
+/** @name FI2C_IC_RX_TL_OFFSET Register
+ */
+#define FI2C_RX_TL_MASK GENMASK(7, 0)
+
+/** @name FI2C_IC_TX_TL_OFFSET Register
+ */
+#define FI2C_TX_TL_MASK GENMASK(7, 0)
+
+/** @name FI2C_IC_ENABLE_OFFSET Register
+ */
+#define FI2C_ENABLE_CONTROLLER (0x1 << 0)
+#define FI2C_DISABLE_CONTROLLER (0x0 << 0)
+
+/** @name FI2C_IC_STATUS_OFFSET Register
+ */
+#define FI2C_STATUS_ACTIVITY (0x1 << 0)
+#define FI2C_STATUS_TFNF (0x1 << 1)
+#define FI2C_STATUS_TFE (0x1 << 2)
+#define FI2C_STATUS_RFNE (0x1 << 3)
+#define FI2C_STATUS_RFF (0x1 << 4)
+#define FI2C_STATUS_MST_ACTIVITY (0x1 << 5)
+#define FI2C_STATUS_SLV_ACTIVITY (0x1 << 6)
+
+/** @name FI2C_IC_ENABLE_STATUS_OFFSET Register
+ */
+#define FI2C_IC_ENABLE (0x1 << 0)
+#define FI2C_IC_DISABLE (0x0 << 0)
+#define FI2C_IC_ENABLE_MASK (0x1 << 0)
+
+#define FI2C_SLV_DISABLED_WHILE_BUSY (0x1 << 1)
+#define FI2C_SLV_RX_DATA_LOST (0x1 << 2)
+
+/* High and low times in different speed modes (in ns) */
+#define FI2C_MIN_SS_SCL_HIGHTIME 4000
+#define FI2C_MIN_SS_SCL_LOWTIME 4700
+#define FI2C_MIN_FS_SCL_HIGHTIME 600
+#define FI2C_MIN_FS_SCL_LOWTIME 1300
+#define FI2C_MIN_FP_SCL_HIGHTIME 500
+#define FI2C_MIN_FP_SCL_LOWTIME 500
+#define FI2C_MIN_HS_SCL_HIGHTIME 60
+#define FI2C_MIN_HS_SCL_LOWTIME 160
+#define FI2C_DEFAULT_SDA_HOLD_TIME 300
+
+#define FI2C_READ_REG32(addr, reg_offset) FtIn32((addr) + (u32)(reg_offset))
+#define FI2C_WRITE_REG32(addr, reg_offset, reg_value) FtOut32((addr) + (u32)(reg_offset), (u32)(reg_value))
+
+/**************************** Type Definitions *******************************/
+
+/************************** Variable Definitions *****************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+#define FI2C_GET_INTRRUPT_MASK(addr) FI2C_READ_REG32((addr), FI2C_INTR_MASK_OFFSET)
+
+#define FI2C_SET_INTRRUPT_MASK(addr, mask) FI2C_WRITE_REG32((addr), FI2C_INTR_MASK_OFFSET, (mask))
+
+#define FI2C_CLEAR_INTR_STATUS(addr) FI2C_READ_REG32((addr), FI2C_CLR_INTR_OFFSET)
+
+#define FI2C_GET_STATUS(addr) FI2C_READ_REG32((addr), FI2C_STATUS_OFFSET)
+
+#define FI2C_READ_DATA(addr) (u8)(FI2C_DATA_MASK & FI2C_READ_REG32(addr, FI2C_DATA_CMD_OFFSET))
+
+#define FI2C_WRITE_DATA(addr, dat) FI2C_WRITE_REG32((addr), FI2C_DATA_CMD_OFFSET, (dat))
+
+#define FI2C_READ_INTR_STAT(addr) FI2C_READ_REG32((addr), FI2C_INTR_STAT_OFFSET)
+
+#define FI2C_READ_RAW_INTR_STAT(addr) FI2C_READ_REG32((addr), FI2C_RAW_INTR_STAT_OFFSET)
+
+inline static u32 FI2cGetEnable(uintptr addr)
+{
+ return FI2C_READ_REG32(addr, FI2C_ENABLE_STATUS_OFFSET);
+}
+
+/************************** Function Prototypes ******************************/
+FError FI2cSetEnable(uintptr addr, boolean enable);
+FError FI2cSetSpeed(uintptr addr, u32 speed_rate);
+FError FI2cWaitStatus(uintptr addr, u32 stat_bit);
+FError FI2cWaitBusBusy(uintptr addr);
+FError FI2cSetTar(uintptr addr, u32 tar_addr);
+FError FI2cSetSar(uintptr addr, u32 sar_addr);
+FError FI2cFlushRxFifo(uintptr addr);
+u32 FI2cClearIntrBits(uintptr addr, u32 *last_err_p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
diff --git a/drivers/i2c/fi2c/fi2c_intr.c b/drivers/i2c/fi2c/fi2c_intr.c
new file mode 100644
index 0000000000000000000000000000000000000000..738d3c53fbbc83eda301561623ac7fa6f9543592
--- /dev/null
+++ b/drivers/i2c/fi2c/fi2c_intr.c
@@ -0,0 +1,337 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-29 14:31:03
+ * @LastEditTime: 2021-10-29 15:02:18
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+/***************************** Include Files *********************************/
+#include
+#include "ft_io.h"
+#include "ft_error_code.h"
+#include "ft_types.h"
+#include "ft_debug.h"
+#include "interrupt.h"
+#include "fi2c_hw.h"
+#include "fi2c.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+#define FI2C_DEBUG_TAG "I2C"
+#define FI2C_ERROR(format, ...) FT_DEBUG_PRINT_E(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+#define FI2C_INFO(format, ...) FT_DEBUG_PRINT_I(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+#define FI2C_DEBUG(format, ...) FT_DEBUG_PRINT_D(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+
+/************************** Function Prototypes ******************************/
+static inline void FI2cMasterCallEvtHandler(FI2c *instance_p, u32 evt, void *para)
+{
+ FT_ASSERTVOID(instance_p);
+ FT_ASSERTVOID(evt < FI2C_MASTER_INTR_EVT_NUM);
+
+ if (instance_p->master_evt_handlers[evt])
+ {
+ instance_p->master_evt_handlers[evt](instance_p, para);
+ }
+}
+
+static inline void FI2cSlaveCallEvtHandler(FI2c *instance_p, u32 evt, void *para)
+{
+ FT_ASSERTVOID(instance_p);
+ FT_ASSERTVOID(evt < FI2C_SLAVE_INTR_EVT_NUM);
+ FT_ASSERTVOID(para);
+
+ if (instance_p->slave_evt_handlers[evt])
+ {
+ instance_p->slave_evt_handlers[evt](instance_p, para);
+ }
+}
+
+/************************** Variable Definitions *****************************/
+
+/*****************************************************************************/
+static void FI2cStubHandler(void *instance_p, void *param)
+{
+ FT_ASSERTVOID(instance_p);
+ FI2c *instance = (FI2c *)(instance_p);
+ uintptr base_addr = instance->config.base_addr;
+
+ FI2C_INFO("id: %d ,intr cause: 0x%x",
+ instance->config.instance_id,
+ FI2C_READ_INTR_STAT(base_addr));
+}
+
+/**
+ * @name: FI2cMasterIntrHandler
+ * @msg: 主机模式下的I2C中断响应函数
+ * @return {*}
+ * @param {s32} vector
+ * @param {void} *param, 中断输入参数
+ */
+static void FI2cMasterIntrHandler(s32 vector, void *param)
+{
+ FT_ASSERTVOID(param);
+ FI2c *instance_p = (FI2c *)param;
+ uintptr base_addr = instance_p->config.base_addr;
+ u32 last_err = 0;
+ u32 stat = FI2cClearIntrBits(base_addr, &last_err);
+ u32 raw_stat = FI2C_READ_RAW_INTR_STAT(base_addr);
+ u32 enabled = FI2C_READ_REG32(base_addr, FI2C_ENABLE_OFFSET);
+ u32 val = 0;
+
+ FT_ASSERTVOID(FI2C_MASTER == instance_p->config.work_mode);
+
+ if (!(enabled & FI2C_IC_ENABLE) || !(raw_stat & ~FI2C_INTR_ACTIVITY))
+ {
+ return;
+ }
+
+ if (stat & FI2C_INTR_TX_ABRT) /* trans abort error */
+ {
+ FI2C_ERROR("last error: 0x%x", last_err);
+ FI2C_ERROR("abort source: 0x%x", FI2C_READ_REG32(base_addr, FI2C_TX_ABRT_SOURCE_OFFSET));
+ FI2cMasterCallEvtHandler(instance_p, FI2C_EVT_MASTER_TRANS_ABORTED, &val);
+ FI2C_SET_INTRRUPT_MASK(base_addr, 0); /* disable all intr */
+ return;
+ }
+
+ if (stat & FI2C_INTR_RX_FULL) /* rx complete */
+ {
+ FI2cMasterCallEvtHandler(instance_p, FI2C_EVT_MASTER_READ_DONE, &val);
+ return;
+ }
+
+ if (stat & FI2C_INTR_TX_EMPTY) /* tx complete */
+ {
+ FI2cMasterCallEvtHandler(instance_p, FI2C_EVT_MASTER_WRITE_DONE, &val);
+ return;
+ }
+
+ return;
+}
+
+/**
+ * @name: FI2cMasterRegisterIntrruptHandler
+ * @msg: 注册I2C主机中断事件函数
+ * @return {*}
+ * @param {FI2c} *instance_p I2C驱动实例数据
+ * @param {u32} evt 中断事件,参考 FI2C_MASTER_INTR_EVT_NUM
+ * @param {FI2cEvtHandler} handler 中断事件回调函数
+ */
+void FI2cMasterRegisterIntrruptHandler(FI2c *instance_p, u32 evt, FI2cEvtHandler handler)
+{
+ FT_ASSERTVOID(instance_p && evt < FI2C_MASTER_INTR_EVT_NUM);
+ instance_p->master_evt_handlers[evt] = handler;
+}
+
+/**
+ * @name: FI2cMasterSetupIntrrupt
+ * @msg: 设置I2C主机的中断
+ * @return {FError *} 返回错误码
+ * @param {FI2c} *instance_p I2C驱动实例数据
+ */
+FError FI2cMasterSetupIntrrupt(FI2c *instance_p)
+{
+ FT_ASSERTZERONUM(instance_p);
+ FI2cConfig *config_p = &instance_p->config;
+ uintptr base_addr =config_p->base_addr;
+ u32 evt;
+ u32 mask;
+
+ if (FT_COMPONENT_IS_READY != instance_p->is_ready)
+ {
+ FI2C_ERROR("i2c driver not ready");
+ return FI2C_ERR_NOT_READY;
+ }
+
+ if (FI2C_MASTER != instance_p->config.work_mode)
+ {
+ FI2C_ERROR("i2c work mode shall be master");
+ return FI2C_ERR_INVAL_STATE;
+ }
+
+ /* disable all i2c irq */
+ FI2C_CLEAR_INTR_STATUS(base_addr);
+
+ /* umask i2c irq */
+ InterruptSetPriority(config_p->irq_num, config_p->irq_prority);
+
+ /* register intr callback */
+ InterruptInstall(config_p->irq_num,
+ FI2cMasterIntrHandler,
+ instance_p,
+ NULL);
+
+ for (evt = FI2C_EVT_MASTER_TRANS_ABORTED; evt < FI2C_MASTER_INTR_EVT_NUM; evt++)
+ {
+ FI2cMasterRegisterIntrruptHandler(instance_p, evt, FI2cStubHandler);
+ }
+
+ mask = FI2C_GET_INTRRUPT_MASK(base_addr);
+ mask &= ~(FI2C_INTR_RX_FULL | FI2C_INTR_TX_ABRT | FI2C_INTR_STOP_DET);
+ FI2C_SET_INTRRUPT_MASK(base_addr, mask);
+
+ /* enable irq */
+ InterruptUmask(config_p->irq_num);
+
+ return FI2C_SUCCESS;
+}
+
+/**
+ * @name: FI2cSlaveIntrHandler
+ * @msg: I2C从机的中断响应函数
+ * @return {*}
+ * @param {s32} vector
+ * @param {void} *param, 输入参数
+ */
+static void FI2cSlaveIntrHandler(s32 vector, void *param)
+{
+ FT_ASSERTVOID(param);
+ FI2c *instance_p = (FI2c *)param;
+ uintptr base_addr = instance_p->config.base_addr;
+ u32 last_err = 0;
+
+ u32 stat = FI2C_READ_INTR_STAT(base_addr);
+ u32 raw_stat = FI2C_READ_RAW_INTR_STAT(base_addr);
+ u32 enabled = FI2C_READ_REG32(base_addr, FI2C_ENABLE_OFFSET);
+ boolean slave_active = (FI2C_GET_STATUS(base_addr) & FI2C_STATUS_SLV_ACTIVITY) ? TRUE : FALSE;
+ u8 val = 0;
+ u32 reg_val;
+
+ FT_ASSERTVOID(FI2C_SLAVE == instance_p->config.work_mode);
+
+ if (!(enabled & FI2C_IC_ENABLE) || !(raw_stat & ~FI2C_INTR_ACTIVITY))
+ {
+ return;
+ }
+
+ if ((stat & FI2C_INTR_RX_FULL) && (stat & FI2C_INTR_STOP_DET))
+ {
+ FI2cSlaveCallEvtHandler(instance_p, FI2C_EVT_SLAVE_WRITE_REQUESTED, &val);
+ }
+
+ if (stat & FI2C_INTR_RD_REQ)
+ {
+ if (slave_active)
+ {
+ if (stat & FI2C_INTR_RX_FULL)
+ {
+ val = FI2C_READ_DATA(base_addr);
+ FI2cSlaveCallEvtHandler(instance_p,
+ FI2C_EVT_SLAVE_WRITE_RECEIVED,
+ &val);
+ FI2C_READ_REG32(base_addr, FI2C_CLR_RD_REQ_OFFSET);
+ stat = FI2cClearIntrBits(base_addr, &last_err);
+ }
+ else
+ {
+ FI2C_READ_REG32(base_addr, FI2C_CLR_RD_REQ_OFFSET);
+ FI2C_READ_REG32(base_addr, FI2C_CLR_RX_UNDER_OFFSET);
+ stat = FI2cClearIntrBits(base_addr, &last_err);
+ }
+
+ FI2cSlaveCallEvtHandler(instance_p, FI2C_EVT_SLAVE_READ_REQUESTED, &val);
+ reg_val = val;
+ FI2C_WRITE_DATA(base_addr, reg_val);
+ }
+ }
+
+ if (stat & FI2C_INTR_RX_DONE)
+ {
+ FI2cSlaveCallEvtHandler(instance_p, FI2C_EVT_SLAVE_READ_PROCESSED, &val);
+ FI2C_READ_REG32(base_addr, FI2C_CLR_RX_DONE_OFFSET);
+ FI2cSlaveCallEvtHandler(instance_p, FI2C_EVT_SLAVE_STOP, &val);
+ return;
+ }
+
+ if (stat & FI2C_INTR_RX_FULL)
+ {
+ val = FI2C_READ_DATA(base_addr);
+ FI2cSlaveCallEvtHandler(instance_p, FI2C_EVT_SLAVE_WRITE_RECEIVED, &val);
+ }
+ else
+ {
+ FI2cSlaveCallEvtHandler(instance_p, FI2C_EVT_SLAVE_STOP, &val);
+ stat = FI2cClearIntrBits(base_addr, &last_err);
+ }
+
+ return;
+}
+
+/**
+ * @name: FI2cSlaveRegisterIntrruptHandler
+ * @msg: 注册I2C从机中断事件函数
+ * @return {*}
+ * @param {FI2c} *instance_p I2C驱动实例数据
+ * @param {u32} evt 中断事件,参考 FI2C_SLAVE_INTR_EVT_NUM
+ * @param {FI2cEvtHandler} handler 中断事件回调函数
+ */
+void FI2cSlaveRegisterIntrruptHandler(FI2c *instance_p, u32 evt, FI2cEvtHandler handler)
+{
+ FT_ASSERTVOID(instance_p && evt < FI2C_SLAVE_INTR_EVT_NUM);
+ instance_p->slave_evt_handlers[evt] = handler;
+}
+
+/**
+ * @name: FI2cSlaveSetupIntrrupt
+ * @msg: 设置I2C从机的中断
+ * @return {FError *} 返回错误码
+ * @param {FI2c} *instance_p
+ */
+FError FI2cSlaveSetupIntrrupt(FI2c *instance_p)
+{
+ FT_ASSERTZERONUM(instance_p);
+ FI2cConfig *config_p = &instance_p->config;
+ uintptr base_addr =config_p->base_addr;
+ u32 evt;
+ u32 mask;
+
+ if (FT_COMPONENT_IS_READY != instance_p->is_ready)
+ {
+ FI2C_ERROR("i2c driver not ready");
+ return FI2C_ERR_NOT_READY;
+ }
+
+ if (FI2C_SLAVE != instance_p->config.work_mode)
+ {
+ FI2C_ERROR("i2c work mode shall be slave");
+ return FI2C_ERR_INVAL_STATE;
+ }
+
+ /* disable all i2c irq */
+ FI2C_CLEAR_INTR_STATUS(base_addr);
+
+ /* umask i2c irq */
+ InterruptSetPriority(config_p->irq_num, config_p->irq_prority);
+
+ /* register intr callback */
+ InterruptInstall(config_p->irq_num,
+ FI2cSlaveIntrHandler,
+ instance_p,
+ NULL);
+
+ for (evt = FI2C_EVT_SLAVE_READ_REQUESTED; evt < FI2C_SLAVE_INTR_EVT_NUM; evt++)
+ {
+ FI2cSlaveRegisterIntrruptHandler(instance_p, evt, FI2cStubHandler);
+ }
+
+ mask = FI2C_GET_INTRRUPT_MASK(base_addr);
+ mask |= (FI2C_INTR_RX_FULL | FI2C_INTR_STOP_DET |
+ FI2C_INTR_RD_REQ | FI2C_INTR_RX_DONE |
+ FI2C_INTR_RX_UNDER | FI2C_INTR_TX_ABRT |
+ FI2C_INTR_START_DET );
+ FI2C_SET_INTRRUPT_MASK(base_addr, mask);
+
+ /* enable irq */
+ InterruptUmask(config_p->irq_num);
+
+ return FI2C_SUCCESS;
+}
\ No newline at end of file
diff --git a/drivers/i2c/fi2c/fi2c_master.c b/drivers/i2c/fi2c/fi2c_master.c
new file mode 100644
index 0000000000000000000000000000000000000000..0f8f8ecec3eaf54b1d5d87a1af430d2aaf16fa48
--- /dev/null
+++ b/drivers/i2c/fi2c/fi2c_master.c
@@ -0,0 +1,279 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 22:29:50
+ * @LastEditTime: 2021-10-29 15:04:56
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+/*
+ - 一些驱动模块,直接操作硬件的I/O接口,无法实现有意义的操作,此时需要针对中间件或者用户使用习惯设计此模块 (i2c,nand,eth)
+ - 部分场景适用, 分角色的 I/O 操作
+ - 此模块的函数原型,在fooxx.h 中声明一次,方便用户或者中间件层调用
+
+*/
+
+
+/***************************** Include Files *********************************/
+
+#include "ft_io.h"
+#include "fsleep.h"
+#include "ft_debug.h"
+#include "fi2c_hw.h"
+#include "fi2c.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+#define FI2C_DEBUG_TAG "I2C_MASTER"
+#define FI2C_ERROR(format, ...) FT_DEBUG_PRINT_E(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+#define FI2C_INFO(format, ...) FT_DEBUG_PRINT_I(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+#define FI2C_DEBUG(format, ...) FT_DEBUG_PRINT_D(FI2C_DEBUG_TAG, format, ##__VA_ARGS__)
+
+#define FI2C_TIMEOUT 500
+
+/************************** Function Prototypes ******************************/
+
+/************************** Variable Definitions *****************************/
+
+/*****************************************************************************/
+/**
+ * @name: FI2cMasterStartTrans
+ * @msg: I2C主机开始传输
+ * @return {*}
+ * @param {FI2c} *instance_p, I2C驱动实例数据
+ * @param {u32} inchip_addr, 从机的片内偏移
+ */
+static FError FI2cMasterStartTrans(FI2c *instance_p, u32 inchip_addr)
+{
+ FT_ASSERTZERONUM(instance_p);
+ uintptr base_addr = instance_p->config.base_addr;
+ FError ret = FI2C_SUCCESS;
+ u32 addr_len = instance_p->config.slave_addr_len;
+
+ ret = FI2cWaitBusBusy(base_addr);
+ if (FI2C_SUCCESS != ret)
+ return ret;
+
+ ret = FI2cSetTar(base_addr, instance_p->config.slave_addr);
+ if (FI2C_SUCCESS != ret)
+ return ret;
+
+ while (addr_len)
+ {
+ ret = FI2cWaitStatus(base_addr, FI2C_STATUS_TFNF);
+ if (FI2C_SUCCESS != ret)
+ break;
+
+ if (FI2C_GET_STATUS(base_addr) & FI2C_STATUS_TFNF)
+ {
+ addr_len--;
+ FI2C_WRITE_REG32(base_addr, FI2C_DATA_CMD_OFFSET,
+ (inchip_addr >> (addr_len * BITS_PER_BYTE)) & FI2C_DATA_MASK);
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * @name: FI2cMasterStopTrans
+ * @msg: I2C主机结束传输
+ * @return {*}
+ * @param {FI2c} *instance_p, I2C驱动实例数据
+ */
+static FError FI2cMasterStopTrans(FI2c *instance_p)
+{
+ FT_ASSERTZERONUM(instance_p);
+ FError ret = FI2C_SUCCESS;
+ uintptr base_addr = instance_p->config.base_addr;
+ u32 reg_val;
+ u32 timeout = 0;
+
+ FI2C_INFO("GET MASTER STOP, stat: 0x%x, 0x%x", FI2C_READ_INTR_STAT(base_addr),
+ FI2C_READ_RAW_INTR_STAT(base_addr));
+
+ while (TRUE)
+ {
+ if (FI2C_READ_RAW_INTR_STAT(base_addr) & FI2C_INTR_STOP_DET)
+ {
+ reg_val = FI2C_READ_REG32(base_addr, FI2C_CLR_STOP_DET_OFFSET); /* read to clr intr status */
+ break;
+ }
+ else if (FI2C_TIMEOUT < ++timeout)
+ {
+ break; /* wait timeout, but no error code ret */
+ }
+ }
+
+ ret = FI2cWaitBusBusy(base_addr);
+ if (FI2C_SUCCESS == ret)
+ ret = FI2cFlushRxFifo(base_addr);
+
+ return ret;
+}
+
+/**
+ * @name: FI2cMasterReadPoll
+ * @msg: I2C主机读,阻塞直到完成读操作或失败
+ * @return {FError *} 返回错误码
+ * @param {FI2c} *instance_p I2C驱动实例数据
+ * @param {u32} inchip_addr 从机的内部偏移地址
+ * @param {u8} *buf_p 读目的缓冲区
+ * @param {int} buf_len 读目的缓冲区长度
+ */
+FError FI2cMasterReadPoll(FI2c *instance_p, u32 inchip_addr, u8 *buf_p, int buf_len)
+{
+ FT_ASSERTZERONUM(instance_p && buf_p);
+ FError ret = FI2C_SUCCESS;
+ int buf_idx = buf_len;
+ int trans = buf_len;
+ int rx_limit, tx_limit;
+ uintptr base_addr = instance_p->config.base_addr;
+ u32 reg_val;
+ u32 trans_timeout = 0;
+
+ if (FT_COMPONENT_IS_READY != instance_p->is_ready)
+ {
+ FI2C_ERROR("i2c driver not ready");
+ return FI2C_ERR_NOT_READY;
+ }
+
+ if (FI2C_MASTER != instance_p->config.work_mode)
+ {
+ FI2C_ERROR("i2c work mode shall be master");
+ return FI2C_ERR_INVAL_STATE;
+ }
+
+ ret = FI2cMasterStartTrans(instance_p, inchip_addr);
+ if (FI2C_SUCCESS != ret)
+ return ret;
+
+ while (buf_idx)
+ {
+ rx_limit = 8 - FI2C_READ_REG32(base_addr, FI2C_RXFLR_OFFSET);
+ tx_limit = 8 - FI2C_READ_REG32(base_addr, FI2C_TXFLR_OFFSET);
+
+ if (rx_limit > 0 && tx_limit > 0 && trans > 0) /* trans one byte if fifo has room */
+ {
+ if(trans == 1)
+ {
+ reg_val = FI2C_DATA_CMD_READ | FI2C_DATA_CMD_STOP ;
+ }
+ else
+ {
+ reg_val = FI2C_DATA_CMD_READ;
+ }
+ FI2C_WRITE_REG32(base_addr, FI2C_DATA_CMD_OFFSET, reg_val);
+
+ trans--;
+ rx_limit--;
+ }
+
+ if (FI2C_GET_STATUS(base_addr) & FI2C_STATUS_RFNE)
+ {
+ /* trans one byte */
+ *buf_p++ = FI2C_READ_DATA(base_addr);
+ buf_idx--;
+ trans_timeout = 0;
+ }
+ else if (FI2C_TIMEOUT < (++trans_timeout))
+ {
+ ret = FI2C_ERR_TIMEOUT;
+ FI2C_ERROR("timeout in i2c master read");
+ break;
+ }
+
+ fsleep_millisec(2); //wait 2 ms, critical
+ }
+
+ if (FI2C_SUCCESS == ret)
+ {
+ ret = FI2cMasterStopTrans(instance_p);
+ }
+
+ return ret;
+}
+
+/**
+ * @name: FI2cMasterWritePoll
+ * @msg: I2C主机写,阻塞直到完成写操作或失败
+ * @return {FError *} 返回错误码
+ * @param {FI2c} *instance_p I2C驱动实例数据
+ * @param {u32} inchip_addr 从机的内部偏移地址
+ * @param {u8} *buf_p 写源缓冲区
+ * @param {size_t} buf_len 写源缓冲区长度
+ */
+FError FI2cMasterWritePoll(FI2c *instance_p, u32 inchip_addr, const u8 *buf_p, size_t buf_len)
+{
+ FT_ASSERTZERONUM(instance_p && buf_p);
+ FError ret = FI2C_SUCCESS;
+ int buf_idx = buf_len;
+ int trans = buf_len;
+ uintptr base_addr = instance_p->config.base_addr;
+ u32 reg_val;
+ u32 trans_timeout = 0;
+
+ if (FT_COMPONENT_IS_READY != instance_p->is_ready)
+ {
+ FI2C_ERROR("i2c driver not ready");
+ return FI2C_ERR_NOT_READY;
+ }
+
+ if (FI2C_MASTER != instance_p->config.work_mode)
+ {
+ FI2C_ERROR("i2c work mode shall be master");
+ return FI2C_ERR_INVAL_STATE;
+ }
+
+ ret = FI2cMasterStartTrans(instance_p, inchip_addr);
+ if (FI2C_SUCCESS != ret)
+ return ret;
+
+ while (buf_idx)
+ {
+ if (FI2C_GET_STATUS(base_addr) & FI2C_STATUS_TFNF)
+ {
+ if (1 == buf_idx)
+ {
+ reg_val = (FI2C_DATA_MASK & *buf_p) |
+ FI2C_DATA_CMD_WRITE |
+ FI2C_DATA_CMD_STOP;
+ FI2C_INFO("Write Stop Singal");
+ }
+ else
+ {
+ reg_val = (FI2C_DATA_MASK & *buf_p) |
+ FI2C_DATA_CMD_WRITE;
+ }
+ buf_idx--;
+
+ FI2C_WRITE_REG32(base_addr, FI2C_DATA_CMD_OFFSET, reg_val);
+ buf_p++;
+ trans_timeout = 0;
+ }
+ else if (FI2C_TIMEOUT < ++trans_timeout)
+ {
+ ret = FI2C_ERR_TIMEOUT;
+ FI2C_ERROR("timeout in i2c master write");
+ break;
+ }
+
+ fsleep_millisec(2); //wait 2 ms
+ }
+
+ if (FI2C_SUCCESS == ret)
+ {
+ ret = FI2cMasterStopTrans(instance_p);
+ }
+
+ return ret;
+}
\ No newline at end of file
diff --git a/drivers/i2c/fi2c/fi2c_sinit.c b/drivers/i2c/fi2c/fi2c_sinit.c
new file mode 100644
index 0000000000000000000000000000000000000000..dfbd403f5b0aee7feea470efe0f67b00ae861995
--- /dev/null
+++ b/drivers/i2c/fi2c/fi2c_sinit.c
@@ -0,0 +1,57 @@
+/*
+ * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+ *
+ * SPDX-License-Identifier: Apache-2.0.
+ *
+ * @Date: 2021-10-20 21:56:34
+ * @LastEditTime: 2021-10-29 14:35:47
+ * @Description: This files is for
+ *
+ * @Modify History:
+ * Ver Who Date Changes
+ * ----- ------ -------- --------------------------------------
+ */
+
+
+/* - This file contains the implementation of driver's static initialization functionality.
+- 驱动静态初始化 */
+
+/***************************** Include Files *********************************/
+
+#include "ft_types.h"
+#include "parameters.h"
+#include "fi2c.h"
+
+/************************** Constant Definitions *****************************/
+
+/**************************** Type Definitions *******************************/
+
+/***************** Macros (Inline Functions) Definitions *********************/
+
+/************************** Variable Definitions *****************************/
+
+extern const FI2cConfig FI2C_CONFIG_TBL[I2C_INSTANCE_NUM];
+
+/************************** Function Prototypes ******************************/
+/**
+ * @name: FI2cLookupConfig
+ * @msg: 获取I2C驱动的默认配置参数
+ * @return {const FI2cConfig*} 驱动默认参数
+ * @param {u32} instance_id, 当前控制的I2C控制器实例号
+ */
+const FI2cConfig *FI2cLookupConfig(u32 instance_id)
+{
+ const FI2cConfig *ptr = NULL;
+ u32 index;
+
+ for (index = 0; index < (u32)I2C_INSTANCE_NUM; index++)
+ {
+ if (FI2C_CONFIG_TBL[index].instance_id == instance_id)
+ {
+ ptr = &FI2C_CONFIG_TBL[index];
+ break;
+ }
+ }
+
+ return (const FI2cConfig *)ptr;
+}
\ No newline at end of file
diff --git a/drivers/iomux/Kconfig b/drivers/iomux/Kconfig
index a6d2aba92c0f77d0622698aa0a50c46fbe35d9ba..c9170ba7f1cc6192e667691f5a397eda28963e78 100644
--- a/drivers/iomux/Kconfig
+++ b/drivers/iomux/Kconfig
@@ -1,8 +1,6 @@
-menu "IOMUX Configuration"
- config ENABLE_FIOMUX
- bool
- prompt "Use FIOMUX"
- default n
+config ENABLE_FIOMUX
+ bool
+ prompt "Use FIOMUX"
+ default n
-endmenu
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 47b041de54ce7082dc391ce8ff31af2f8c843667..ef7589feda9894b378d659a3552793bd56ad43e9 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -2,22 +2,19 @@
menu "SPI Configuration"
config ENABLE_FSPI
bool
- prompt "Use FSPI uart"
+ prompt "Use FSPI"
default n
- if ENABLE_FSPI
- choice
- prompt "SPI Work Mode Selection"
- optional
- # default SPI_POLLING_MODE
- # help
- # Select SPI Work Mode as Polling or Interrupt
-
- config SPI_POLLING_MODE
- bool "Polling"
- config SPI_IRQ_MODE
- bool "Interrupt"
- endchoice
- endif
+ choice FSPI_WORKMODE
+ prompt "SPI Work Mode Selection"
+ default SPI_POLLING_MODE
+ help
+ Select SPI Work Mode as Polling or Interrupt
+
+ config SPI_POLLING_MODE
+ bool "Polling"
+ config SPI_IRQ_MODE
+ bool "Interrupt"
+ endchoice
endmenu
diff --git a/install.py b/install.py
index a2a78f6cbb60acbce9a60c02c58ba166a6c52ba4..4845b5b62237bb3bdfacb29750a36fbe5dc77658 100755
--- a/install.py
+++ b/install.py
@@ -26,92 +26,38 @@ import tarfile
import re
import shutil
-### platform constant
-platform_tags = ["Linux_X86_64" "Linux_AARCH64" "Msys2"]
-linux_x86 = 0
-linux_aarch64 = 1
-windows_msys2 = 2
-
### environment constant
-sdk_profile_path = "/etc/profile.d/phytium_standalone_sdk.sh"
-
-# check file attributes
-def is_readable(path, user):
- user_info = pwd.getpwnam(user)
- uid = user_info.pw_uid
- gid = user_info.pw_gid
- s = os.stat(path)
- mode = s[stat.ST_MODE]
- return (((s[stat.ST_UID] == uid) and (mode & stat.S_IRUSR > 0)) or ((s[stat.ST_GID] == gid) and (mode & stat.S_IRGRP > 0)) or (mode & stat.S_IROTH > 0))
-
-def is_writable(path, user):
- user_info = pwd.getpwnam(user)
- uid = user_info.pw_uid
- gid = user_info.pw_gid
- s = os.stat(path)
- mode = s[stat.ST_MODE]
- return (((s[stat.ST_UID] == uid) and (mode & stat.S_IWUSR > 0)) or((s[stat.ST_GID] == gid) and (mode & stat.S_IWGRP > 0)) or (mode & stat.S_IWOTH > 0))
+sdk_profile_path = "/etc/profile.d/phytium_dev.sh"
-def is_executable(path, user):
- user_info = pwd.getpwnam(user)
- uid = user_info.pw_uid
- gid = user_info.pw_gid
- s = os.stat(path)
- mode = s[stat.ST_MODE]
- return (((s[stat.ST_UID] == uid) and (mode & stat.S_IXUSR > 0)) or ((s[stat.ST_GID] == gid) and (mode & stat.S_IXGRP > 0)) or (mode & stat.S_IXOTH > 0))
+### functions
+def rm_line(str, file_path):
+ with open(file_path,'r+') as f:
+ lines = [line for line in f.readlines() if str not in line]
+ f.seek(0)
+ f.truncate(0)
+ f.writelines(lines)
-def un_tar(src_path, dst_dir):
- print("- untar {} in progress...".format(src_path))
- tar = tarfile.open(name=src_path)
-
- for member_info in tar.getmembers():
- print("- extracting: " + member_info.name)
- tar.extract(member=member_info, path=dst_dir)
-
- tar.close()
+def ap_line(str, file_path):
+ with open(file_path, 'a') as f:
+ f.write(str + '\n')
#################################################################
# STEP 1: Check environment
-# check install environment
-if (platform.system() == 'Linux' ) and (platform.processor() == 'x86_64'):
- install_platform = linux_x86
-elif (platform.system() == 'Linux' ) and (platform.processor() == 'aarch64'):
- install_platform = linux_aarch64
-elif (re.search('MSYS_NT', platform.system()).span() == (0, len('MSYS_NT'))):
- install_platform = windows_msys2
-else:
- print("[1]: Platform not support !!! ")
- exit()
-
-# features for msys2 platform, windows platform do not support online
phytium_dev_path = os.environ.get("PHYTIUM_DEV_PATH")
-# to compatible with Windows path, replace \\ with /
-phytium_dev_path = '/'.join(phytium_dev_path.split('\\'))
-if (None == phytium_dev_path):
- print("[1]: Please set 'PHYTIUM_DEV_PATH' first!!!")
+if None == phytium_dev_path or not os.path.exists(phytium_dev_path):
+ print("[1]: Failed: Phytium Dev Path not setup {}!!!".format(phytium_dev_path))
exit()
-# create '/etc/profile.d/phytium_standalone_sdk.sh' need sudo right, ask user to create it first
-if not os.path.exists(sdk_profile_path):
- if (install_platform == linux_x86) or (install_platform == linux_aarch64):
- print("[1]: Please create sdk profile with 'sudo touch {}' first".format(sdk_profile_path))
- print("then 'sudo chmod 666 {}'".format(sdk_profile_path))
- else: # for Windows msys2
- print("[1]: Please create sdk profile with 'touch {}' first".format(sdk_profile_path))
- print("then 'chmod 666 {}'".format(sdk_profile_path))
-
+aarch32_cc_path = os.environ.get("AARCH32_CROSS_PATH")
+if None == aarch32_cc_path or not os.path.exists(aarch32_cc_path):
+ print("[1]: Failed: AARCH32 CC not setup {} !!!".format(aarch32_cc_path))
exit()
-# get current user to install, profile depends on user
-usr = getpass.getuser()
-if (install_platform == windows_msys2):
- # arch is not able to get for msys2
- print("[1]: Usr: {}, OS: {}, Type: {}".format(usr, platform.system(), install_platform))
-else:
- print("[1]: Usr: {}, OS: {}, Arch: {}, Type: {}".format(usr, platform.system(), platform.processor(), install_platform))
-
-print("[1]: Enviroment variables will set at {}".format(sdk_profile_path))
+aarch64_cc_path = os.environ.get("AARCH64_CROSS_PATH")
+if None == aarch64_cc_path or not os.path.exists(aarch64_cc_path):
+ print("[1]: Failed: AARCH64 CC not setup {} !!!".format(aarch64_cc_path))
+ exit()
# get absoulte path current pwd to install sdk
install_path, install_script = os.path.split(os.path.abspath(__file__))
@@ -135,142 +81,19 @@ os.system("chmod +x ./lib/Kconfiglib/*.py --silent ")
## STEP 2: reset environment
# remove environment variables
-try:
- sdk_profile = open(sdk_profile_path, "w")
- sdk_profile.truncate()
-except Exception as ex:
- print(ex)
- print("[1]: Create SDK profile {} failed !!!!".format(sdk_profile_path))
- exit()
-
-# remove environment from old profile for compatible
-old_profile_path = os.environ.get('HOME') + '/.profile'
-os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING START/d' "+ old_profile_path)
-os.system("sed -i '/export AARCH32_CROSS_PATH=/d' " + old_profile_path)
-os.system("sed -i '/export PATH=\$PATH:\$AARCH32_CROSS_PATH/d' " + old_profile_path)
-os.system("sed -i '/export AARCH64_CROSS_PATH=/d' " + old_profile_path)
-os.system("sed -i '/export PATH=\$PATH:\$AARCH64_CROSS_PATH/d' " + old_profile_path)
-os.system("sed -i '/export STANDALONE_SDK_ROOT=/d' " + old_profile_path)
-os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING END/d' "+ old_profile_path)
-
-# remove environment variables
-# os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING START/d' "+ sdk_profile_path)
-# os.system("sed -i '/export AARCH32_CROSS_PATH=/d' " + sdk_profile_path)
-# os.system("sed -i '/export PATH=\$PATH:\$AARCH32_CROSS_PATH/d' " + sdk_profile_path)
-# os.system("sed -i '/export AARCH64_CROSS_PATH=/d' " + sdk_profile_path)
-# os.system("sed -i '/export PATH=\$PATH:\$AARCH64_CROSS_PATH/d' " + sdk_profile_path)
-# os.system("sed -i '/export STANDALONE_SDK_ROOT=/d' " + sdk_profile_path)
-# os.system("sed -i '/### PHYTIUM STANDALONE SDK SETTING END/d' "+ sdk_profile_path)
+rm_line('### PHYTIUM STANDALONE SDK SETTING START', sdk_profile_path)
+rm_line('export STANDALONE_SDK_ROOT=', sdk_profile_path)
+rm_line('### PHYTIUM STANDALONE SDK SETTING END', sdk_profile_path)
print("[2]: Reset environment")
-## STEP 3: get cross-platform compiler
-cc_install_path = phytium_dev_path + '/' + 'cross_tool' + '/'
-
-# set cc package name, download url and install dst dir
-if (install_platform == linux_x86):
-
- aarch32_cc = 'gcc-arm-10.3-2021.07-x86_64-arm-none-eabi'
- aarch64_cc = 'gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf'
-
- # cc package name
- aarch32_cc_pack = aarch32_cc + '.tar.xz'
- aarch64_cc_pack = aarch64_cc + '.tar.xz'
-
- aarch32_cc_install_path = cc_install_path + aarch32_cc
- aarch64_cc_install_path = cc_install_path + aarch64_cc
-
-elif (install_platform == linux_aarch64):
-
- aarch32_cc = 'gcc-arm-10.3-2021.07-aarch64-arm-none-eabi'
- aarch64_cc = 'gcc-arm-10.3-2021.07-aarch64-aarch64-none-elf'
-
- # cc package name
- aarch32_cc_pack = aarch32_cc + '.tar.xz'
- aarch64_cc_pack = aarch64_cc + '.tar.xz'
-
- aarch32_cc_install_path = cc_install_path + aarch32_cc
- aarch64_cc_install_path = cc_install_path + aarch64_cc
-
-elif (install_platform == windows_msys2):
-
- aarch32_cc = 'gcc-arm-10.3-2021.07-mingw-w64-i686-arm-none-eabi'
- aarch64_cc = 'gcc-arm-10.3-2021.07-mingw-w64-i686-aarch64-none-elf'
-
- # cc package name
- aarch32_cc_pack = aarch32_cc + '.tar.xz'
- aarch64_cc_pack = aarch64_cc + '.tar.xz'
-
- aarch32_cc_install_path = cc_install_path + aarch32_cc
- aarch64_cc_install_path = cc_install_path + aarch64_cc
-
-
-print("[3]: Download and install CC....")
-
-# check if cc has already been installed
-aarch32_cc_is_installed = os.path.exists(aarch32_cc_install_path)
-aarch64_cc_is_installed = os.path.exists(aarch64_cc_install_path)
-
-# cc download target
-# aarch32_cc_dl_dst = cc_install_path + aarch32_cc_pack
-# aarch64_cc_dl_dst = cc_install_path + aarch64_cc_pack
-
-aarch32_cc_dl_dst = phytium_dev_path + '/' + aarch32_cc_pack
-aarch64_cc_dl_dst = phytium_dev_path + '/' + aarch64_cc_pack
-
-#########################################
-if not os.path.exists(aarch32_cc_dl_dst):
- print("[3]: Failed, AARCH32 CC package {} non found !!!".format(aarch32_cc_dl_dst))
- exit()
-
-if not os.path.exists(aarch64_cc_dl_dst):
- print("[3]: Failed, AARCH64 CC package {} non found !!!".format(aarch64_cc_dl_dst))
- exit()
-
-## STEP 4:install cc
-# untar aarch32 cc
-if not aarch32_cc_is_installed:
- if os.path.exists(aarch32_cc_dl_dst):
- print("[4]: Install AARCH32 CC...")
- un_tar(aarch32_cc_dl_dst, cc_install_path)
-
-# write aarch32 cc path
-if os.path.exists(aarch32_cc_install_path):
- print("[4]: AARCH32 CC install success at {}".format(aarch32_cc_install_path))
-else:
- print("[4]: AARCH32 CC install failed !!!")
- exit()
-
-# untar aarch64 cc
-if not aarch64_cc_is_installed:
- if os.path.exists(aarch64_cc_dl_dst):
- print("[4]: Install AARCH64 CC...")
- un_tar(aarch64_cc_dl_dst, cc_install_path)
-
-# write aarch64 cc path
-if os.path.exists(aarch64_cc_install_path):
- print("[4]: AARCH64 CC install success at {}".format(aarch64_cc_install_path))
-else:
- print("[4]: AARCH64 CC install failed !!!")
- exit()
-
-print("[4]: GNU CC version: 10.3.1-2021.07")
-
-## STEP 5: write environment variables
+## STEP 3: write environment variables
os.environ['STANDALONE_SDK_ROOT'] = standalone_sdk_path
-os.environ['AARCH32_CROSS_PATH'] = aarch32_cc_install_path
-os.environ['AARCH64_CROSS_PATH'] = aarch64_cc_install_path
-
-os.system("echo \"### PHYTIUM STANDALONE SDK SETTING START\" >> {}".format(sdk_profile_path))
-os.system("echo \"export AARCH32_CROSS_PATH={}\" >> {}".format(aarch32_cc_install_path, sdk_profile_path))
-os.system("echo \"export PATH=\$PATH:\$AARCH32_CROSS_PATH/bin\">> {}".format(sdk_profile_path))
-os.system("echo \"export AARCH64_CROSS_PATH={}\" >> {}".format(aarch64_cc_install_path, sdk_profile_path))
-os.system("echo \"export PATH=\$PATH:\$AARCH64_CROSS_PATH/bin\">> {}".format(sdk_profile_path))
-os.system("echo \"export STANDALONE_SDK_ROOT={}\" >> {}".format(standalone_sdk_path, sdk_profile_path))
-os.system("echo \"### PHYTIUM STANDALONE SDK SETTING END\" >> {}".format(sdk_profile_path))
+ap_line('### PHYTIUM STANDALONE SDK SETTING START', sdk_profile_path)
+ap_line('export STANDALONE_SDK_ROOT={}'.format(standalone_sdk_path), sdk_profile_path)
+ap_line('### PHYTIUM STANDALONE SDK SETTING END', sdk_profile_path)
## STEP 5: display success message and enable environment
print("[5]: Success!!! Standalone SDK is Install at {}".format(standalone_sdk_path))
print("[5]: SDK Environment Variables is in {}".format(sdk_profile_path))
-print("[5]: Phytium Standalone SDK Setup Done for {}!!!".format(usr))
print("[5]: Input 'source {}' or Reboot System to Active SDK".format(sdk_profile_path))
\ No newline at end of file
diff --git a/lib/Kconfiglib/setconfig.py b/lib/Kconfiglib/setconfig.py
index f9cf5cd314da242b5d8827065fa40601a89b581c..d1bdef7879cf39bc783e4aa11d450f200a1eeac9 100755
--- a/lib/Kconfiglib/setconfig.py
+++ b/lib/Kconfiglib/setconfig.py
@@ -84,6 +84,11 @@ def main():
"value '{}'. Check the symbol's dependencies, and make "
"sure that it has a prompt."
.format(name, value, sym.str_value))
+
+ # add this to enable unset item
+ if value == "n" or value == "N":
+ print("unset symbol {}".format(name))
+ sym.set_value("n")
print(kconf.write_config())
diff --git a/make/build_all.mk b/make/build_all.mk
new file mode 100644
index 0000000000000000000000000000000000000000..40eff4eae05ec01479b0ffd918e597f36c413afb
--- /dev/null
+++ b/make/build_all.mk
@@ -0,0 +1,104 @@
+# /*
+# * @ : Copyright (c) 2021 Phytium Information Technology, Inc.
+# *
+# * SPDX-License-Identifier: Apache-2.0.
+# *
+# * @Date: 2021-10-28 14:51:27
+# * @LastEditTime: 2021-10-28 15:04:55
+# * @Description: This files is for build images for all platform
+# *
+# * @Modify History:
+# * Ver Who Date Changes
+# * ----- ------ -------- --------------------------------------
+# */
+
+BUILD_ALL_DIR := $(STANDALONE_DIR)/tools/test_utility/output
+CUR_EG = $(notdir $(shell pwd))
+BUILD_ALL_OUTPUT_DIR := $(BUILD_ALL_DIR)
+EG_CONFIGS_DIR := ./configs
+
+# 根据setup生成例程默认配置
+.PHONY: eg_setup_ft2004_aarch32 eg_setup_ft2004_aarch64 eg_setup_d2000_aarch32 eg_setup_d2000_aarch64 eg_setup_all
+eg_setup_ft2004_aarch32:
+ make config_ft2004_aarch32
+ make setup
+ make -j && cp ./sdkconfig $(EG_CONFIGS_DIR)/ft2004_aarch32_eg_configs -f && ls $(EG_CONFIGS_DIR)/ft2004_aarch32_eg_configs -l
+
+eg_setup_ft2004_aarch64:
+ make config_ft2004_aarch64
+ make setup
+ make -j && cp ./sdkconfig $(EG_CONFIGS_DIR)/ft2004_aarch64_eg_configs -f && ls $(EG_CONFIGS_DIR)/ft2004_aarch64_eg_configs -l
+
+eg_setup_d2000_aarch32:
+ make config_d2000_aarch32
+ make setup
+ make -j && cp ./sdkconfig $(EG_CONFIGS_DIR)/d2000_aarch32_eg_configs -f && ls $(EG_CONFIGS_DIR)/d2000_aarch32_eg_configs -l
+
+eg_setup_d2000_aarch64:
+ make config_d2000_aarch64
+ make setup
+ make -j && cp ./sdkconfig $(EG_CONFIGS_DIR)/d2000_aarch64_eg_configs -f && ls $(EG_CONFIGS_DIR)/d2000_aarch64_eg_configs -l
+
+eg_setup_e2000_aarch32:
+ make config_e2000_aarch32
+ make setup
+ make -j && cp ./sdkconfig $(EG_CONFIGS_DIR)/e2000_aarch32_eg_configs -f && ls $(EG_CONFIGS_DIR)/e2000_aarch32_eg_configs -l
+
+eg_setup_e2000_aarch64:
+ make config_e2000_aarch64
+ make setup
+ make -j && cp ./sdkconfig $(EG_CONFIGS_DIR)/e2000_aarch64_eg_configs -f && ls $(EG_CONFIGS_DIR)/e2000_aarch64_eg_configs -l
+
+.PHONY: eg_setup_ft2004 eg_setup_d2000 eg_setup_e2000
+eg_setup_ft2004: eg_setup_ft2004_aarch32 eg_setup_ft2004_aarch64
+eg_setup_d2000: eg_setup_d2000_aarch32 eg_setup_d2000_aarch64
+eg_setup_e2000: eg_setup_e2000_aarch32 eg_setup_e2000_aarch64
+
+# 根据例程默认,编译各平台的镜像
+.PHONY: build_ft2004_aarch32 build_ft2004_aarch64 build_d2000_aarch32 build_d2000_aarch64
+build_ft2004_aarch32:
+ @echo $(BUILD_ALL_OUTPUT_DIR)
+ exit
+ @echo "========Building for FT2000/4 AARCH32 Start============="
+ @mkdir $(BUILD_ALL_OUTPUT_DIR) -p
+ make ldconfig LDCONFIG_ARG=$(EG_CONFIGS_DIR)/ft2004_aarch32_eg_configs
+ make clean && make -j && mv ./*.elf $(BUILD_ALL_OUTPUT_DIR)/$(CUR_EG)_ft2004_aarch32.elf -f
+ @echo "==============FT2000/4 AARCH32======================="
+
+build_ft2004_aarch64:
+ @echo "=======Building for FT2000/4 AARCH64 Start==============="
+ @mkdir $(BUILD_ALL_OUTPUT_DIR) -p
+ make ldconfig LDCONFIG_ARG=$(EG_CONFIGS_DIR)/ft2004_aarch64_eg_configs
+ make clean && make -j && mv ./*.elf $(BUILD_ALL_OUTPUT_DIR)/$(CUR_EG)_ft2004_aarch64.elf -f
+ @echo "==============FT2000/4 AARCH64======================="
+
+build_d2000_aarch32:
+ @echo "=======Building for D2000 AARCH32===================="
+ @mkdir $(BUILD_ALL_OUTPUT_DIR) -p
+ make ldconfig LDCONFIG_ARG=$(EG_CONFIGS_DIR)/d2000_aarch32_eg_configs
+ make clean && make -j && mv ./*.elf $(BUILD_ALL_OUTPUT_DIR)/$(CUR_EG)_d2000_aarch32.elf -f
+ @echo "==============D2000 AARCH32======================="
+
+build_d2000_aarch64:
+ @echo "========Building for D2000 AARCH64==================="
+ @mkdir $(BUILD_ALL_OUTPUT_DIR) -p
+ make ldconfig LDCONFIG_ARG=$(EG_CONFIGS_DIR)/d2000_aarch64_eg_configs
+ make clean && make -j && mv ./*.elf $(BUILD_ALL_OUTPUT_DIR)/$(CUR_EG)_d2000_aarch64.elf -f
+ @echo "==============D2000 AARCH64========================="
+
+build_e2000_aarch32:
+ @echo "=======Building for E2000 AARCH32===================="
+ @mkdir $(BUILD_ALL_OUTPUT_DIR) -p
+ make ldconfig LDCONFIG_ARG=$(EG_CONFIGS_DIR)/e2000_aarch32_eg_configs
+ make clean && make -j && mv ./*.elf $(BUILD_ALL_OUTPUT_DIR)/$(CUR_EG)_e2000_aarch32.elf -f
+ @echo "==============E2000 AARCH32======================="
+
+build_e2000_aarch64:
+ @echo "========Building for E2000 AARCH64==================="
+ @mkdir $(BUILD_ALL_OUTPUT_DIR) -p
+ make ldconfig LDCONFIG_ARG=$(EG_CONFIGS_DIR)/e2000_aarch64_eg_configs
+ make clean && make -j && mv ./*.elf $(BUILD_ALL_OUTPUT_DIR)/$(CUR_EG)_e2000_aarch64.elf -f
+ @echo "==============E2000 AARCH64========================="
+
+setup:
+ make setconfig SETCONFIG_ARG="$(USR_CONFIGS)"
\ No newline at end of file
diff --git a/make/build_baremetal.mk b/make/build_baremetal.mk
index 594a158164abf5d5f12f8266aca303676357e66e..cf0eccdef890e469ab366eae247222351c640ae9 100755
--- a/make/build_baremetal.mk
+++ b/make/build_baremetal.mk
@@ -10,3 +10,4 @@ include $(STANDALONE_DIR)/make/complier.mk
include $(STANDALONE_DIR)/make/buildinfo.mk
include $(STANDALONE_DIR)/make/packsource.mk
include $(STANDALONE_DIR)/make/menuconfig.mk
+include $(STANDALONE_DIR)/make/build_all.mk
\ No newline at end of file
diff --git a/make/ld/Kconfig b/make/ld/Kconfig
index b831ac842bf6bef57c3ffeda0fc6c141c5e34fb9..0b568cd81f0a53db2f78c86e55499a758d1a18df 100644
--- a/make/ld/Kconfig
+++ b/make/ld/Kconfig
@@ -86,20 +86,18 @@ menu "Linker Options"
help
Assign Heap size in Linkscript
- if TARGET_ARMV8_AARCH32
- config STACK_SIZE
- hex "Stack Size"
- default "0x1000"
- help
- Assign Stack size in Linkscript
- endif
+ config STACK_SIZE
+ hex "Stack Size"
+ depends on TARGET_ARMV8_AARCH32
+ default "0x1000"
+ help
+ Assign Stack size in Linkscript
- if TARGET_ARMV8_AARCH64
- config STACK_TOP_ADDR
- hex "Stack Top Address"
- default "0x82000000"
- help
- Assign Stack top address in Linkscript
- endif
+ config STACK_TOP_ADDR
+ hex "Stack Top Address"
+ depends on TARGET_ARMV8_AARCH64
+ default "0x82000000"
+ help
+ Assign Stack top address in Linkscript
endmenu
diff --git a/make/menuconfig.mk b/make/menuconfig.mk
index 88800466c887203f8295f7d60b1d8ebbd2225fb7..0cbe2d1fd7f63f89cdfa579b24086673fdc1a376 100755
--- a/make/menuconfig.mk
+++ b/make/menuconfig.mk
@@ -12,11 +12,15 @@
# ----- ------ -------- --------------------------------------
#
-.PHONY: menuconfig oldconfig alldefconfig savedefconfig lddefconfig genconfig
+.PHONY: menuconfig oldconfig alldefconfig savedefconfig lddefconfig genconfig setconfig ldconfig
menuconfig:
$(STANDALONE_DIR)/lib/Kconfiglib/menuconfig.py
$(STANDALONE_DIR)/lib/Kconfiglib/genconfig.py
+setconfig:
+ $(STANDALONE_DIR)/lib/Kconfiglib/setconfig.py $(SETCONFIG_ARG)
+ $(STANDALONE_DIR)/lib/Kconfiglib/genconfig.py
+
genconfig:
$(STANDALONE_DIR)/lib/Kconfiglib/genconfig.py
@@ -38,6 +42,11 @@ lddefconfig:
cp $(STANDALONE_DIR)/configs/$(DEF_KCONFIG) ./$(KCONFIG_CONFIG) -f
@echo "get default configs at " $(STANDALONE_DIR)/configs/$(DEF_KCONFIG)
+ldconfig:
+ cp $(LDCONFIG_ARG) ./$(KCONFIG_CONFIG) -f
+ @echo "get configs at " $(LDCONFIG_ARG)
+ $(STANDALONE_DIR)/lib/Kconfiglib/genconfig.py
+
# load default configs,then generate sdkconfig.h, and clean build targets
# support platform
# FT2000/4 AARCH32/AARCH64
diff --git a/standalone.mk b/standalone.mk
index 63c8fcaf9183124518a94032fd41f859126c4cc1..d57cd5d99a672e098ca13cd053619665cd4e46e6 100644
--- a/standalone.mk
+++ b/standalone.mk
@@ -127,9 +127,9 @@ ifdef CONFIG_ENABLE_F_PCIE
endif
# i2c
-ifdef CONFIG_USE_DW_I2C
- SRC_DIR += $(CUR_DIR)/drivers/i2c/dw_i2c
- INC_DIR += $(CUR_DIR)/drivers/i2c/dw_i2c
+ifdef CONFIG_USE_FI2C
+ SRC_DIR += $(CUR_DIR)/drivers/i2c/fi2c
+ INC_DIR += $(CUR_DIR)/drivers/i2c/fi2c
endif
# sdmmc
diff --git a/third-party/letter-shell-3.1/port/shell_port.c b/third-party/letter-shell-3.1/port/shell_port.c
index ae83ef90652bd8dbe091536c0de5d761608a2caf..65875e66eadc2b0cd7b990970d61401867317f53 100644
--- a/third-party/letter-shell-3.1/port/shell_port.c
+++ b/third-party/letter-shell-3.1/port/shell_port.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-08-27 16:10:29
- * @LastEditTime: 2021-09-26 16:25:50
+ * @LastEditTime: 2021-10-29 15:11:53
* @Description: This files is for
*
* @Modify History:
@@ -54,7 +54,7 @@ void LSUserShellLoop(void)
* @msg: 获取上一条命令的执行返回值
* @return {*}
*/
-int LSUserGetLastRet()
+int LSUserGetLastRet(void)
{
return shell.lastRet;
}
diff --git a/third-party/letter-shell-3.1/port/shell_port.h b/third-party/letter-shell-3.1/port/shell_port.h
index 4851ab04b301e6788b76e9459d6c166a6e986a3d..df218eb021e2dbbd0da81e647d1ca75334f001e2 100644
--- a/third-party/letter-shell-3.1/port/shell_port.h
+++ b/third-party/letter-shell-3.1/port/shell_port.h
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0.
*
* @Date: 2021-08-27 16:10:29
- * @LastEditTime: 2021-09-26 16:26:04
+ * @LastEditTime: 2021-10-29 15:12:00
* @Description: This files is for
*
* @Modify History:
@@ -20,9 +20,9 @@
extern Shell shell;
void LSUserShellLoop(void);
void LSUserExec(const char *cmd);
-int LSUserGetLastRet();
+int LSUserGetLastRet(void);
void LSUserSetResult(u32 result);
-u32 LSUserGetResult();
+u32 LSUserGetResult(void);
void LSUserSlient(boolean slient);
boolean LSUserIsSlient(void);
#define LSUserPrintf(format, ... ) \
diff --git a/third-party/letter-shell-3.1/src/shell_cfg.h b/third-party/letter-shell-3.1/src/shell_cfg.h
index 19bb55a17770acba119f8a5fe982f11dbdb481db..05aa78af04a30d02151680887cb8b94b8838bf24 100644
--- a/third-party/letter-shell-3.1/src/shell_cfg.h
+++ b/third-party/letter-shell-3.1/src/shell_cfg.h
@@ -142,7 +142,7 @@
/**
* @brief shell默认用户
*/
-#define SHELL_DEFAULT_USER "letter"
+#define SHELL_DEFAULT_USER "phytium"
/**
* @brief shell默认用户密码
diff --git a/tools/test_utility/README.md b/tools/test_utility/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..5403343dfbba5918674263c07e04e8c55f37f795
--- /dev/null
+++ b/tools/test_utility/README.md
@@ -0,0 +1,175 @@
+
+
+>本文档用于说明版本发布前test_utility的使用,以及新增模块需要添加的test_utility支持
+>按照文档的步骤可以保证
+```
+1. 所有例程在各支持平台和执行模式下编译通过
+2. 例程中的功能可以进行集中测试
+```
+
+# 核心方法简述
+
+## test_utility 会做下列工作
+- test_utility 会扫描所有的例程,加载例程中各平台的默认配置
+- test_utility 会编译例程中的`build_all`编译目标,生成多个镜像
+- test_utility 会将编译生成的多个镜像复制到 test_utility 下的output目录
+
+## 开发者需要做的工作
+
+- 在例程测试基本功能通过后,为所有支持的平台准备一份配置文件,放置在指定位置
+- 在例程makefile新增`build_all`编译目标,编译`build_all.mk`中的一个或多个目标
+- 将例程的目录添加到 test_utility 的 makefile 中
+- 将测试中用到的脚本和命令备注在本文最后一章“目前支持的测试例程”中,方便后续测试
+- 使用镜像完成集中测试工作
+
+# 新增例程
+
+## 新增支持平台的配置文件
+
+- 对于新增例程,需要添加例程支持平台的配置文件,给test_utility统一编译使用
+
+- 以`baremetal/example/fi2c_slave`例程为例,支持的平台包括FT2000/4和D2000,因此需要新增以下四个配置文件,放置在例程的configs目录下,同时命名为,
+
+```
+ft2004_aarch32_eg_configs
+ft2004_aarch64_eg_configs
+d2000_aarch32_eg_configs
+d2000_aarch64_eg_configs
+```
+>configs文件夹和配置文件名不能改
+
+- 注意配置中的`CONFIG_TARGET_NAME`要按照 `例程文件名 + 平台 + baremetal + 执行模式`来命名,否则脚本无法识别
+> 如`baremetal/example/fi2c_slave`例程, ft2000/4的aarch32镜像需要命名为 fi2c_slave_d2000_baremetal_a32
+
+
+
+## 新增一个编译目标`build_all`用于全平台编译
+
+- 在例程的makefile文件中,新增`build_all`目标,将`build_all.mk`中支持的平台加入
+- 以`baremetal/example/fi2c_slave`例程为例,支持的平台包括FT2000/4和D2000,因此将以下四个编译目标
+
+> 按照实际情况设置编译目标,如果平台不支持,不要添加
+
+```
+# 编译所有支持的平台
+.PHONY: build_all
+build_all:
+ make build_ft2004_aarch32
+ make build_ft2004_aarch64
+ make build_ft2004_aarch32
+ make build_d2000_aarch32
+ make build_d2000_aarch64
+```
+
+## 使用`make eg_setup_ft2004`等命令快速生成例程的配置
+
+- 加载ft2004平台的默认配置
+- 添加例程的特有配置
+- 编译aarch32和aarch64镜像
+- 如果编译成功,将config文件移动到./configs文件夹下备份
+
+## 在test_utiltiy中加入例程
+
+- 在test_utiltiy的makefile中将例程的目录加入
+- 如下图所示,加入`baremetal/example/fi2c_slave`的目录,用相对路径和绝对路径都可以
+
+
+
+# 使用test_utility
+
+## 清理掉全平台编译结果
+
+- cd 到 `tools/test_utility` 目录
+```
+make clean_all
+```
+
+
+## 编译所有例程的全平台镜像
+```
+make build_all
+```
+
+
+## 编译生成全平台镜像
+
+- 编译完成后,获得所有平台的镜像,编译过程中发生错误,编译会立即停止,如下图所示
+
+
+
+- 编译错误后立即停止,方便排查问题
+
+
+
+## 下载镜像完成测试
+
+- 下载镜像到开发板,结合各例程的README开展测试
+```
+setenv ipaddr 192.168.4.20
+setenv serverip 192.168.4.50
+setenv gatewayip 192.168.4.1
+tftpboot 0x90100000 baremetal.elf
+bootelf -p 0x90100000
+```
+
+# 目前支持的测试例程
+
+- 设置ip
+```
+setenv ipaddr 192.168.4.20
+setenv serverip 192.168.4.50
+setenv gatewayip 192.168.4.1
+```
+
+- 跳转启动
+```
+bootelf -p 0x90100000
+```
+
+## fi2c_slave
+
+- ft2004
+```
+tftpboot 0x90100000 fi2c_eeprom_ft2004_aarch32.elf
+tftpboot 0x90100000 fi2c_eeprom_ft2004_aarch64.elf
+```
+
+- d2000
+```
+tftpboot 0x90100000 fi2c_slave_d2000_baremetal_a32.elf
+tftpboot 0x90100000 fi2c_slave_d2000_baremetal_a64.elf
+```
+
+## fi2c_eeprom
+
+- ft2004
+```
+tftpboot 0x90100000 fi2c_eeprom_ft2004_baremetal_a32.elf
+tftpboot 0x90100000 fi2c_eeprom_ft2004_baremetal_a64.elf
+```
+
+- d2000
+```
+tftpboot 0x90100000 fi2c_eeprom_d2000_baremetal_a32.elf
+tftpboot 0x90100000 fi2c_eeprom_d2000_baremetal_a64.elf
+```
+
+# 生成例程的默认配置
+
+```
+make config_ft2004_aarch32
+make setup
+make -j && cp ./sdkconfig ./configs/ft2004_aarch32_eg_configs -f
+```
\ No newline at end of file
diff --git a/tools/test_utility/makefile b/tools/test_utility/makefile
new file mode 100644
index 0000000000000000000000000000000000000000..dca6573bb0c9a71ddae647192cf6e0e023ffb5f2
--- /dev/null
+++ b/tools/test_utility/makefile
@@ -0,0 +1,28 @@
+# Compiling all examples
+TOPTARGETS := all clean build_all
+
+SUBDIRS := $(STANDALONE_SDK_ROOT)/baremetal/example/fi2c_eeprom \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/fi2c_slave \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/gmac_test \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/letter_shell_test \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/libmetal_test/core0 \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/libmetal_test/core1 \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/lwip_test \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/newlibc_test \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/nand_flash_test \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/qspi_nor_flash \
+ $(STANDALONE_SDK_ROOT)/baremetal/example/spi_test
+
+$(TOPTARGETS): $(SUBDIRS)
+ @for DIR in $(SUBDIRS); do \
+ echo -e "\033[44;37;1m +++ Compiling $$DIR...\033[0m"; \
+ cd $$DIR; \
+ $(MAKE) $$DIR $(MAKECMDGOALS) || exit $$?; \
+ echo -e "\033[44;37;1m +++ Compiled OK $$DIR...\033[0m"; \
+ done
+
+.PHONY: $(TOPTARGETS) $(SUBDIRS)
+
+clean_all:
+ @echo "remove dir ./output"
+ @rm ./output -rf
\ No newline at end of file