Skip to content

Develop/nn#8

Merged
00lllooolll00 merged 5 commits into
masterfrom
develop/nn
Feb 11, 2026
Merged

Develop/nn#8
00lllooolll00 merged 5 commits into
masterfrom
develop/nn

Conversation

@00lllooolll00

Copy link
Copy Markdown
Collaborator

添加了GD32F470ZGT6作为试例

Copilot AI review requested due to automatic review settings February 11, 2026 01:42
@00lllooolll00 00lllooolll00 merged commit 4aad73a into master Feb 11, 2026
8 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

添加 GD32F470ZGT6 作为工程试例,并引入对应的 GD32F4xx 标准外设库与 CMSIS 头文件/启动与基础运行时支持文件,方便在仓库内直接编译运行该 MCU 示例工程。

Changes:

  • 新增 GD32F470ZGT6 的 Driver/Inc 外设寄存器与外设驱动头文件(FMC/EXTI/DMA/DCI/DBG/DAC/CTC/CRC 等)
  • 新增 CMSIS Core 相关头文件与 GD32F4xx Device 头文件(含 system/gd32f4xx.h)
  • 新增示例工程 Core 源码(main、systick、syscall、中断处理)与 CMake 集成

Reviewed changes

Copilot reviewed 40 out of 124 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
L1_MCU/GD32F470ZGT6/Driver/Inc/gd32f4xx_fmc.h 新增 FMC/Option Byte 相关寄存器与 API 声明
L1_MCU/GD32F470ZGT6/Driver/Inc/gd32f4xx_exti.h 新增 EXTI 寄存器/枚举与 API 声明
L1_MCU/GD32F470ZGT6/Driver/Inc/gd32f4xx_dma.h 新增 DMA 寄存器/宏/结构体与 API 声明
L1_MCU/GD32F470ZGT6/Driver/Inc/gd32f4xx_dci.h 新增 DCI 寄存器/宏/结构体与 API 声明
L1_MCU/GD32F470ZGT6/Driver/Inc/gd32f4xx_dbg.h 新增 DBG 寄存器/宏与 API 声明
L1_MCU/GD32F470ZGT6/Driver/Inc/gd32f4xx_dac.h 新增 DAC 寄存器/宏与 API 声明
L1_MCU/GD32F470ZGT6/Driver/Inc/gd32f4xx_ctc.h 新增 CTC 寄存器/宏与 API 声明
L1_MCU/GD32F470ZGT6/Driver/Inc/gd32f4xx_crc.h 新增 CRC 寄存器与 API 声明
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Include/tz_context.h 引入 TrustZone context 管理声明(CMSIS)
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Include/pmu_armv8.h 引入 PMU API 与事件定义(CMSIS)
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Include/pac_armv81.h 引入 PAC key 访问接口(CMSIS)
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Include/mpu_armv8.h 引入 Armv8-M MPU API(CMSIS)
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Include/mpu_armv7.h 引入 Armv7-M MPU API(CMSIS)
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Include/cmsis_version.h 新增 CMSIS 版本宏定义
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Include/cmsis_compiler.h 新增 CMSIS 编译器抽象层 header
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Include/cmsis_armcc.h 新增 ARMCC 相关 CMSIS 编译器支持
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Include/cachel1_armv7.h 新增 L1 Cache API(CMSIS)
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Device/GD/GD32F4xx/Include/system_gd32f4xx.h 新增 SystemInit/SystemCoreClockUpdate 声明
L1_MCU/GD32F470ZGT6/Driver/CMSIS/Device/GD/GD32F4xx/Include/gd32f4xx.h 新增 Device header(IRQ、基地址、寄存器访问宏等)
L1_MCU/GD32F470ZGT6/Core/Src/systick.c 新增 SysTick 初始化、Delay与 tick 维护实现
L1_MCU/GD32F470ZGT6/Core/Src/syscall.c 新增 newlib syscall stub(_sbrk/_write 等)
L1_MCU/GD32F470ZGT6/Core/Src/main.c 新增示例 main 入口与 Error_Handler
L1_MCU/GD32F470ZGT6/Core/Src/gd32f4xx_it.c 新增异常处理函数(HardFault/MemManage 等)
L1_MCU/GD32F470ZGT6/Core/Inc/systick.h 新增 systick 对外声明
L1_MCU/GD32F470ZGT6/Core/Inc/main.h 新增工程公共头与断言宏
L1_MCU/GD32F470ZGT6/Core/Inc/gd32f4xx_libopt.h 新增库裁剪/聚合包含头
L1_MCU/GD32F470ZGT6/Core/Inc/gd32f4xx_it.h 新增异常/中断处理函数声明
L1_MCU/GD32F470ZGT6/CMakeLists.txt 将该示例接入构建系统并设置 include/defs/sources

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#define ARM_PMU_MVE_LDST_MULTI_SPEC 0x025D /*!< MVE memory instruction targeting multiple registers speculatively executed */
#define ARM_PMU_MVE_LD_MULTI_RETIRED 0x0260 /*!< MVE memory load instruction targeting multiple registers architecturally executed */
#define ARM_PMU_MVE_LD_MULTI_SPEC 0x0261 /*!< MVE memory load instruction targeting multiple registers speculatively executed */
#define ARM_PMU_MVE_ST_MULTI_RETIRED 0x0261 /*!< MVE memory store instruction targeting multiple registers architecturally executed */

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ARM_PMU_MVE_ST_MULTI_RETIREDARM_PMU_MVE_LD_MULTI_SPEC 使用了相同的事件号 0x0261,会导致事件统计混乱;请修正 ST_MULTI_RETIRED 的事件编码为正确值(并检查相邻 ST_MULTI_SPEC 的编码一致性)。

Suggested change
#define ARM_PMU_MVE_ST_MULTI_RETIRED 0x0261 /*!< MVE memory store instruction targeting multiple registers architecturally executed */
#define ARM_PMU_MVE_ST_MULTI_RETIRED 0x0264 /*!< MVE memory store instruction targeting multiple registers architecturally executed */

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +16
void SysTick_Init(void)
{
/* setup systick timer for 1000Hz interrupts */
if (SysTick_Config(SystemCoreClock / 1000U)) {
/* capture error */
while (1) {
}
}
/* configure the systick handler priority */
NVIC_SetPriority(SysTick_IRQn, 0x00U);
}

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delay() 依赖 delayTick 在 SysTick 中断中递减(通过 Tick_Inc()),但当前变更中未看到 SysTick_Handler() 调用 Tick_Inc() 的实现位置;若未实现/未绑定到向量表,将导致 Delay() 永久阻塞。建议在 SysTick_Handler() 中调用 Tick_Inc()(或直接在 handler 内维护 uwTick/delayTick),并确保该 handler 确实被链接并用于向量表。

Copilot uses AI. Check for mistakes.
Comment on lines +23 to +29
void Delay(uint32_t xms)
{
delayTick = xms;

while (delayTick) {
}
}

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delay() 依赖 delayTick 在 SysTick 中断中递减(通过 Tick_Inc()),但当前变更中未看到 SysTick_Handler() 调用 Tick_Inc() 的实现位置;若未实现/未绑定到向量表,将导致 Delay() 永久阻塞。建议在 SysTick_Handler() 中调用 Tick_Inc()(或直接在 handler 内维护 uwTick/delayTick),并确保该 handler 确实被链接并用于向量表。

Copilot uses AI. Check for mistakes.
uwTick++;
if (delayTick) {
delayTick--;
}

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delay() 依赖 delayTick 在 SysTick 中断中递减(通过 Tick_Inc()),但当前变更中未看到 SysTick_Handler() 调用 Tick_Inc() 的实现位置;若未实现/未绑定到向量表,将导致 Delay() 永久阻塞。建议在 SysTick_Handler() 中调用 Tick_Inc()(或直接在 handler 内维护 uwTick/delayTick),并确保该 handler 确实被链接并用于向量表。

Suggested change
}
}
}
/**
* @brief SysTick中断服务函数
*
* 在每次SysTick中断时调用Tick_Inc以更新uwTick和delayTick
*/
void SysTick_Handler(void)
{
Tick_Inc();

Copilot uses AI. Check for mistakes.
*/
void DebugMon_Handler(void)
{
}

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gd32f4xx_it.h 声明了 SysTick_Handler/SVC_Handler/PendSV_Handler,但本文件目前只实现到 DebugMon_Handler;如果启动文件未提供这些中断的弱定义,可能直接导致链接错误;即使有弱定义,SysTick 也可能无法驱动 Delay()/GetTick() 的逻辑。建议在本文件补齐至少 SysTick_Handler()(并按需补齐其它声明)。

Suggested change
}
}
/*!
\brief this function handles SVC exception
\param[in] none
\param[out] none
\retval none
*/
void SVC_Handler(void)
{
}
/*!
\brief this function handles PendSV exception
\param[in] none
\param[out] none
\retval none
*/
void PendSV_Handler(void)
{
}
/*!
\brief this function handles SysTick interrupt
\param[in] none
\param[out] none
\retval none
*/
void SysTick_Handler(void)
{
}

Copilot uses AI. Check for mistakes.
#define DMA_INTF_SDEIF BIT(2) /*!< single data mode exception flag */
#define DMA_INTF_TAEIF BIT(3) /*!< transfer access error flag */
#define DMA_INTF_HTFIF BIT(4) /*!< half transfer finish flag */
#define DMA_INTF_FTFIF BIT(5) /*!< full transger finish flag */

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

存在明显的拼写/命名问题会影响可读性与使用准确性:如 DMA_CHXM1ADDR_M0ADDR 用于 memory1 却命名为 M0ADDR,容易误用;同时多处注释拼写错误(transger/tranfer/peipheral)。建议至少修正 DMA_CHXM1ADDR_M0ADDR 的宏名称(或补充别名兼容),并统一注释拼写。

Copilot uses AI. Check for mistakes.
/* DMA_CHxCTL,x=0..7 */
#define DMA_CHXCTL_CHEN BIT(0) /*!< channel x enable */
#define DMA_CHXCTL_SDEIE BIT(1) /*!< enable bit for channel x single data mode exception interrupt */
#define DMA_CHXCTL_TAEIE BIT(2) /*!< enable bit for channel x tranfer access error interrupt */

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

存在明显的拼写/命名问题会影响可读性与使用准确性:如 DMA_CHXM1ADDR_M0ADDR 用于 memory1 却命名为 M0ADDR,容易误用;同时多处注释拼写错误(transger/tranfer/peipheral)。建议至少修正 DMA_CHXM1ADDR_M0ADDR 的宏名称(或补充别名兼容),并统一注释拼写。

Copilot uses AI. Check for mistakes.
#define DMA_CHXCTL_CMEN BIT(8) /*!< circulation mode */
#define DMA_CHXCTL_PNAGA BIT(9) /*!< next address generation algorithm of peripheral */
#define DMA_CHXCTL_MNAGA BIT(10) /*!< next address generation algorithm of memory */
#define DMA_CHXCTL_PWIDTH BITS(11, 12) /*!< transfer width of peipheral */

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

存在明显的拼写/命名问题会影响可读性与使用准确性:如 DMA_CHXM1ADDR_M0ADDR 用于 memory1 却命名为 M0ADDR,容易误用;同时多处注释拼写错误(transger/tranfer/peipheral)。建议至少修正 DMA_CHXM1ADDR_M0ADDR 的宏名称(或补充别名兼容),并统一注释拼写。

Copilot uses AI. Check for mistakes.
#define DMA_CHXM0ADDR_M0ADDR BITS(0, 31) /*!< memory 0 base address */

/* DMA_CHxM1ADDR,x=0..7 */
#define DMA_CHXM1ADDR_M0ADDR BITS(0, 31) /*!< memory 1 base address */

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

存在明显的拼写/命名问题会影响可读性与使用准确性:如 DMA_CHXM1ADDR_M0ADDR 用于 memory1 却命名为 M0ADDR,容易误用;同时多处注释拼写错误(transger/tranfer/peipheral)。建议至少修正 DMA_CHXM1ADDR_M0ADDR 的宏名称(或补充别名兼容),并统一注释拼写。

Copilot uses AI. Check for mistakes.
{
delayTick = xms;

while (delayTick) {

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delay() 采用空循环忙等会持续占用 CPU(且在开启更高优化时更难观察行为)。在裸机场景建议在循环体内加入低功耗等待(例如 __WFI())或至少加入编译器屏障/空操作以降低功耗并改善实时性。

Suggested change
while (delayTick) {
while (delayTick) {
__WFI();

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants