Compare commits

...

28 Commits

Author SHA1 Message Date
Copilot
d39a439603 [klibc] 将函数签名与标准 libc 对齐以修复类型冲突 #10890 2025-11-07 15:48:51 +08:00
wdfk-prog
4ee00eba9b feat[ulog]: 增加 Kconfig 选项以控制 Finsh/MSH 命令 2025-11-07 11:16:46 +08:00
CYFS
934c8195f4 [serialv2]:Fixed the issue where the serialv2 terminal did not have the enable stream mode 2025-11-07 09:52:55 +08:00
RyanCW
97f316f5d0 [bsp][gd32][serial_v2] 增加GD32F5支持 (#10840)
[bsp][gd32][serial_v2] 增加 GD32F5 支持
2025-11-07 09:28:59 +08:00
wdfk-prog
55306ad133 fix(finsh): Correct stack usage display format in list_thread command 2025-11-06 19:50:17 +08:00
lhxj
e3640ffc3d fix(doc): Exclude 'src/utest/perf/README.md' from Doxygen build (RT-Thread#10888)
Problem description:
The file 'src/utest/perf/README.md' was incorrectly appearing as a root-level page in the Doxygen documentation output.

Problem analysis:
This file was unintentionally included by the Doxygen build process following commit 7499790. It is an internal README for performance tests and is not intended to be part of the generated documentation.

Solution:
The issue is resolved by explicitly excluding this file from the build. The path '../src/utest/perf/README.md' has been added to the EXCLUDE list in both 'documentation/Doxyfile.1.9.1' and 'documentation/Doxyfile.1.9.8'.

This issue was originally introduced by the following commit:
Commit: 7499790
Title: utest: core: move perf testcase from example to src

Signed-off-by: lhxj <2743257167@qq.com>
2025-11-06 10:43:28 +08:00
kurisaw
fa6f86eda3 [ci]: disable the post-ci-status enabling option for regarding the relevant CI 2025-11-04 11:16:13 +08:00
Yuqiang Wang
925eab78df [ci]: disable auto-run status ci 2025-11-04 08:22:42 +08:00
CYFS
e458c0df7e Add a token to fix the 403 error 2025-11-02 16:31:46 +08:00
Yucai Liu
c91a7f46f5 [libcpu/arm/cortex-m33]: Fix incorrect CPU architecture in GCC context switch
The context_gcc.S file was incorrectly marked as cortex-m4 in both the
doxygen comment and .cpu directive, while the IAR and KEIL versions
correctly specify cortex-m33. This file uses ARMv8-M specific features
(PSPLIM register, TrustZone support) that are not available in Cortex-M4.

Changes:
- Update doxygen group from cortex-m4 to cortex-m33
- Change .cpu directive from cortex-m4 to cortex-m33
2025-11-02 16:23:31 +08:00
CYFS
d3ba09a0d7 [log]Update V5.2.2 Released Changelog. 2025-10-31 16:36:32 +08:00
Yuqiang Wang
ba509f92c2 [ci]: Introduce a regular inspection mechanism for abnormal CI reports (#10852) 2025-10-30 09:19:36 +08:00
Ze-Hou
666fa243f2 feature: k230: Add other existing drivers to the ci.attachconfig.yml file (#10869)
Resolve issue #10857

Signed-off-by: Ze-Hou <yingkezhou@qq.com>
2025-10-30 06:20:37 +08:00
Copilot
a10922b01b [Feature] Add automated CI results comment to pull requests (#10856)
* Initial plan

* Add CI results comment workflow

Co-authored-by: supperthomas <60349489+supperthomas@users.noreply.github.com>

* Improve CI results comment formatting and PR detection

Co-authored-by: supperthomas <60349489+supperthomas@users.noreply.github.com>

* Add documentation for CI results comment feature

Co-authored-by: supperthomas <60349489+supperthomas@users.noreply.github.com>

* Add ToolsCI and pkgs_test to monitored workflows

Co-authored-by: supperthomas <60349489+supperthomas@users.noreply.github.com>

* Add immediate CI status comment via direct workflow integration

Co-authored-by: supperthomas <60349489+supperthomas@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: supperthomas <60349489+supperthomas@users.noreply.github.com>
2025-10-30 06:18:47 +08:00
PandaFeng
6d4e2aa2fe [bsp/stm32h7]: Add STM32H7 fdcan driver. #10767 2025-10-29 22:59:33 +08:00
Ze-Hou
9e3127982d bsp: k230: add i2c driver
Requirement: The BSP for the k230 platform in the RT-Thread repository
        does not yet have an I2C driver.

        Solution: Provide I2C driver for the k230 platform in the RT-Thread
        repository.
        1. support i2c master mode

Signed-off-by: Ze-Hou <yingkezhou@qq.com>
2025-10-29 13:33:11 +08:00
WangShun
e4f014eb96 [bsp/xuantie] 添加E901BSP #10836 2025-10-29 13:31:38 +08:00
CYFS
6a9a1df437 [components]:utilize the clang-format-ignore mechanism (#10860) 2025-10-28 15:17:04 +08:00
HZY0117
0017ad1255 移除HAL_Drivers/config/ra2a1 2025-10-28 14:20:26 +08:00
ryancw
007b221366 [utest] when enabling utest, force the logging feature to be enabled. 2025-10-28 14:15:52 +08:00
ache
36bf8f656b feat:clang format ignore migration 2025-10-28 14:13:56 +08:00
hzy0117
c553df5a3c [bsp][renesas]:pwm_config里新增对BSP_USING_PWM10到BSP_USING_PWM12的定义 (#10859)
* [BSP][renesas][rsoc][fix]:移除HAL_Drivers/config/ra2a1,add pwm configuration items

* 在pwm_config里新增对BSP_USING_PWM10到BSP_USING_PWM12的定义
2025-10-28 14:05:59 +08:00
westcity-YOLO
858ed95cd2 修复gd32f5系列adc问题增加条件编译 2025-10-27 17:34:50 +08:00
rbb666
0dd90619c7 cherryusb:Adapt the usbd_kinetis_delay_ms interface in usb_glue_mcx. 2025-10-27 17:31:55 +08:00
rbb666
258395a552 cherryusb:Add the missing header files for bsp/frdm-mcxa156. 2025-10-27 17:31:55 +08:00
rbb666
ab5afb3689 cherryusb:Fixed the issue where the USB device in the cdc_rndis_template example could not enable DHCP. 2025-10-27 17:31:55 +08:00
wdfk-prog
e5556be19f fix:[ulog][backend]filter不应与ULOG_USING_COLOR及ULOG_USING_SYSLOG配置有关 2025-10-27 17:09:09 +08:00
R b b666
ff973e548b Fixed: ci build errors for hpm* bsp. (#10854) 2025-10-27 09:33:12 +08:00
181 changed files with 11429 additions and 872 deletions

View File

@@ -482,6 +482,7 @@
"RTT_BSP": "xuantie",
"RTT_TOOL_CHAIN": "sourcery-Xuantie-900-gcc-elf-newlib",
"SUB_RTT_BSP": [
"xuantie/smartl/e901",
"xuantie/smartl/e902",
"xuantie/smartl/e906",
"xuantie/smartl/e907",

139
.github/workflows/README_CI_RESULTS.md vendored Normal file
View File

@@ -0,0 +1,139 @@
# CI Results Comment Workflow
## Overview / 概述
This feature automatically posts CI test results as comments on Pull Requests, making it easier for contributors and reviewers to see the status of all CI checks at a glance.
此功能自动将 CI 测试结果作为评论发布到 Pull Request 中,使贡献者和审阅者更容易一目了然地看到所有 CI 检查的状态。
## Implementation / 实现方式
The feature uses **two complementary approaches** to ensure CI results are always visible:
该功能使用**两种互补方法**来确保 CI 结果始终可见:
### 1. Direct Workflow Integration (Immediate) / 直接工作流集成(立即生效)
Each main CI workflow includes a `post-ci-status` job that:
每个主要 CI 工作流都包含一个 `post-ci-status` 作业,它:
- ✅ Works immediately on PR branches (no merge required) / 立即在 PR 分支上生效(无需合并)
- 📝 Updates a single comment with workflow status / 使用工作流状态更新单个评论
- 🔄 Runs after each workflow completes / 在每个工作流完成后运行
**Modified Workflows:**
- `bsp_buildings.yml`
- `static_code_analysis.yml`
- `format_check.yml`
- `utest_auto_run.yml`
### 2. Workflow Run Trigger (After Merge) / 工作流运行触发器(合并后)
The `ci_results_comment.yml` workflow:
`ci_results_comment.yml` 工作流:
- ⏰ Triggers when CI workflows complete / 在 CI 工作流完成时触发
- 📊 Provides comprehensive summary of all workflows / 提供所有工作流的全面摘要
- 🔍 Shows detailed job-level information / 显示详细的作业级信息
- ⚠️ **Only works after merged to master** / **仅在合并到 master 后才有效**
## Features / 功能特性
1. **Automatic Updates / 自动更新**: The comment is automatically created when CI workflows complete and updated as new workflows finish.
/ 当 CI 工作流完成时自动创建评论,并在新工作流完成时更新。
2. **Comprehensive Summary / 全面总结**: Shows the status of all major CI workflows including:
/ 显示所有主要 CI 工作流的状态,包括:
- RT-Thread BSP Static Build Check / BSP 静态构建检查
- Static code analysis / 静态代码分析
- Check File Format and License / 文件格式和许可证检查
- utest_auto_run / 单元测试自动运行
3. **Status Indicators / 状态指示器**:
- ✅ Success / 成功
- ❌ Failure / 失败
- 🟠 Queued / 排队中
- 🟡 In Progress / 进行中
- ⏭️ Skipped / 已跳过
4. **Detailed Information / 详细信息**: Expandable sections show individual job results within each workflow.
/ 可展开的部分显示每个工作流中的各个作业结果。
## How It Works / 工作原理
1. The workflow is triggered when any of the monitored CI workflows complete.
/ 当任何受监控的 CI 工作流完成时,将触发此工作流。
2. It collects the status of all workflows and jobs for the associated Pull Request.
/ 它收集关联 Pull Request 的所有工作流和作业的状态。
3. A formatted comment is posted (or updated if one already exists) with the current CI status.
/ 发布(或更新已存在的)格式化评论,显示当前 CI 状态。
## Comment Format / 评论格式
The comment includes:
评论包括:
- **Overall Summary / 总体摘要**: Quick statistics showing count of passed, failed, queued, in-progress, and skipped workflows.
/ 快速统计数据,显示通过、失败、排队、进行中和跳过的工作流数量。
- **Detailed Results / 详细结果**: Collapsible sections for each workflow with links to individual jobs.
/ 每个工作流的可折叠部分,包含指向各个作业的链接。
## Benefits / 优势
1. **Visibility / 可见性**: Contributors can immediately see which CI checks have passed or failed without navigating to the Actions tab.
/ 贡献者无需导航到 Actions 选项卡即可立即查看哪些 CI 检查通过或失败。
2. **Efficiency / 效率**: Reviewers can quickly assess the CI status before reviewing the code.
/ 审阅者可以在审查代码之前快速评估 CI 状态。
3. **Transparency / 透明度**: All stakeholders have a clear view of the PR's CI status.
/ 所有利益相关者都可以清楚地了解 PR 的 CI 状态。
## Permissions Required / 所需权限
The workflow requires the following permissions:
工作流需要以下权限:
- `pull-requests: write` - To create and update comments / 创建和更新评论
- `issues: write` - To post comments on PR issues / 在 PR 问题上发布评论
- `actions: read` - To read workflow run status / 读取工作流运行状态
- `checks: read` - To read check run status / 读取检查运行状态
## Configuration / 配置
The workflow monitors the following workflows by default:
工作流默认监控以下工作流:
```yaml
workflows:
- "RT-Thread BSP Static Build Check"
- "Static code analysis"
- "Check File Format and License"
- "utest_auto_run"
```
To add more workflows to monitor, edit the `.github/workflows/ci_results_comment.yml` file and add workflow names to the `workflows` list.
要监控更多工作流,请编辑 `.github/workflows/ci_results_comment.yml` 文件并将工作流名称添加到 `workflows` 列表中。
## Troubleshooting / 故障排除
### Comment not appearing / 评论未出现
1. Ensure the workflow has the required permissions / 确保工作流具有所需权限
2. Check that the PR is from a branch in the repository (not a fork) / 检查 PR 是否来自存储库中的分支(而非分支)
3. Verify the workflow is enabled in the repository settings / 验证工作流在存储库设置中已启用
### Comment not updating / 评论未更新
1. The comment updates when a monitored workflow completes / 当受监控的工作流完成时,评论会更新
2. Check the Actions tab to see if the workflow is running / 检查 Actions 选项卡以查看工作流是否正在运行
3. Look for errors in the workflow logs / 在工作流日志中查找错误
## Contributing / 贡献
Contributions to improve this workflow are welcome! Please follow the standard contribution process outlined in the CONTRIBUTING.md file.
欢迎改进此工作流的贡献!请遵循 CONTRIBUTING.md 文件中概述的标准贡献流程。

View File

@@ -13,9 +13,6 @@ name: RT-Thread BSP Static Build Check
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the RT-Thread organization master branch
on:
# Runs at 16:00 UTC (BeiJing 00:00) every day
schedule:
- cron: '0 16 * * *'
push:
branches:
- master
@@ -46,6 +43,12 @@ on:
types:
- online-pkgs-static-building-trigger-event
workflow_dispatch:
inputs:
trigger_type:
description: '触发类型'
required: false
default: 'manual'
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -177,10 +180,10 @@ jobs:
- name: Install Xuantie-900-gcc-elf-newlib Tools
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-Xuantie-900-gcc-elf-newlib' && success() }}
run: |
wget -q https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1744884010580/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2-20250410.tar.gz
sudo tar -zxvf Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2-20250410.tar.gz -C /opt
/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2/bin/riscv64-unknown-elf-gcc --version
echo "RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.0.2/bin" >> $GITHUB_ENV
wget -q https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource//1751370399722/Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0-20250627.tar.gz
sudo tar -zxvf Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0-20250627.tar.gz -C /opt
/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0/bin/riscv64-unknown-elf-gcc --version
echo "RTT_EXEC_PATH=/opt/Xuantie-900-gcc-elf-newlib-x86_64-V3.2.0/bin" >> $GITHUB_ENV
- name: Install Xuantie-900-gcc-linux-musl Tools
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-Xuantie-900-gcc-linux-musl' && success() }}
@@ -288,4 +291,17 @@ jobs:
uses: actions/upload-artifact@main
with:
name: 00_all_bsp_output_${{ github.sha }}
path: output/
path: output/
# # Post CI status to PR comment
# post-ci-status:
# needs: build
# if: always() && github.event_name == 'pull_request' && github.repository_owner == 'RT-Thread'
# uses: ./.github/workflows/post_ci_status.yml
# with:
# workflow_name: "RT-Thread BSP Static Build Check"
# workflow_status: ${{ needs.build.result }}
# pr_number: ${{ github.event.pull_request.number }}
# permissions:
# pull-requests: write
# issues: write

303
.github/workflows/ci_results_comment.yml vendored Normal file
View File

@@ -0,0 +1,303 @@
#
# Copyright (c) 2025, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0
#
# Change Logs:
# Date Author Notes
# 2025-10-27 GitHub Copilot Post CI results to PR comments
name: CI Results Comment
# on:
# workflow_run:
# workflows:
# - "RT-Thread BSP Static Build Check"
# - "Static code analysis"
# - "Check File Format and License"
# - "utest_auto_run"
# - "ToolsCI"
# - "pkgs_test"
# types:
# - completed
permissions:
pull-requests: write
issues: write
actions: read
checks: read
jobs:
comment-ci-results:
runs-on: ubuntu-22.04
if: github.event.workflow_run.event == 'pull_request' && github.repository_owner == 'RT-Thread'
steps:
- name: Get PR number
id: get-pr
uses: actions/github-script@v7
with:
script: |
// Get PR number from workflow_run
const prNumber = context.payload.workflow_run.pull_requests[0]?.number;
if (!prNumber) {
console.log('No PR found in workflow_run');
// Fallback: search for PR by branch
const pulls = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${context.payload.workflow_run.head_branch}`
});
if (pulls.data.length === 0) {
console.log('No open PR found for this branch');
return null;
}
const pr = pulls.data[0];
console.log(`Found PR #${pr.number}`);
return pr.number;
}
console.log(`Found PR #${prNumber}`);
return prNumber;
- name: Get workflow run details
if: steps.get-pr.outputs.result != 'null'
id: workflow-details
uses: actions/github-script@v7
with:
script: |
const prNumber = ${{ steps.get-pr.outputs.result }};
if (!prNumber) {
return { success: false, message: 'No PR found' };
}
// Get all workflow runs for this PR
const workflowRuns = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
event: 'pull_request',
per_page: 100
});
// Filter runs for this specific PR
const prRuns = workflowRuns.data.workflow_runs.filter(run => {
return run.pull_requests.some(pr => pr.number === prNumber);
});
// Get the latest run for each workflow
const workflowMap = new Map();
for (const run of prRuns) {
const existing = workflowMap.get(run.name);
if (!existing || new Date(run.created_at) > new Date(existing.created_at)) {
workflowMap.set(run.name, run);
}
}
// Prepare results summary
const results = [];
for (const [name, run] of workflowMap) {
let status = '🟡';
let statusText = 'In Progress';
if (run.status === 'completed') {
if (run.conclusion === 'success') {
status = '✅';
statusText = 'Success';
} else if (run.conclusion === 'failure') {
status = '❌';
statusText = 'Failure';
} else if (run.conclusion === 'cancelled') {
status = '⏭️';
statusText = 'Cancelled';
} else if (run.conclusion === 'skipped') {
status = '⏭️';
statusText = 'Skipped';
}
} else if (run.status === 'queued') {
status = '🟠';
statusText = 'Queued';
}
results.push({
name: name,
status: status,
statusText: statusText,
url: run.html_url,
conclusion: run.conclusion,
runId: run.id
});
}
return {
success: true,
results: results,
prNumber: prNumber
};
- name: Get job details
if: steps.get-pr.outputs.result != 'null'
id: job-details
uses: actions/github-script@v7
with:
script: |
const workflowDetails = ${{ steps.workflow-details.outputs.result }};
if (!workflowDetails || !workflowDetails.success) {
return { jobs: [] };
}
const allJobs = [];
for (const result of workflowDetails.results) {
try {
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: result.runId,
per_page: 100
});
for (const job of jobs.data.jobs) {
let jobStatus = '⌛';
if (job.status === 'completed') {
if (job.conclusion === 'success') {
jobStatus = '✅';
} else if (job.conclusion === 'failure') {
jobStatus = '❌';
} else if (job.conclusion === 'skipped') {
jobStatus = '⏭️';
}
} else if (job.status === 'in_progress') {
jobStatus = '🔄';
} else if (job.status === 'queued') {
jobStatus = '🟠';
}
allJobs.push({
workflow: result.name,
name: job.name,
status: jobStatus,
conclusion: job.conclusion || job.status,
url: job.html_url
});
}
} catch (error) {
console.log(`Error getting jobs for workflow ${result.name}: ${error.message}`);
}
}
return { jobs: allJobs };
- name: Post or update comment
if: steps.get-pr.outputs.result != 'null'
uses: actions/github-script@v7
with:
script: |
const prNumber = ${{ steps.get-pr.outputs.result }};
const workflowDetails = ${{ steps.workflow-details.outputs.result }};
const jobDetails = ${{ steps.job-details.outputs.result }};
if (!workflowDetails || !workflowDetails.success) {
console.log('No workflow details available');
return;
}
// Prepare comment body
const now = new Date();
const timestamp = now.toISOString();
const results = workflowDetails.results;
const jobs = jobDetails.jobs || [];
let commentBody = '<!-- CI Results Comment -->\n';
commentBody += '## 🤖 CI Test Results\n\n';
commentBody += `**Last Updated:** ${timestamp}\n\n`;
commentBody += '### Test Spec & Results:\n\n';
commentBody += '✅ Success | ❌ Failure | 🟠 Queued | 🟡 Progress | ⏭️ Skipped | ⚠️ Quarantine\n\n';
// Group jobs by workflow
const jobsByWorkflow = new Map();
for (const job of jobs) {
if (!jobsByWorkflow.has(job.workflow)) {
jobsByWorkflow.set(job.workflow, []);
}
jobsByWorkflow.get(job.workflow).push(job);
}
// Calculate overall statistics
let totalSuccess = 0;
let totalFailure = 0;
let totalQueued = 0;
let totalProgress = 0;
let totalSkipped = 0;
for (const result of results) {
if (result.conclusion === 'success') totalSuccess++;
else if (result.conclusion === 'failure') totalFailure++;
else if (result.statusText === 'Queued') totalQueued++;
else if (result.statusText === 'In Progress') totalProgress++;
else if (result.conclusion === 'skipped' || result.conclusion === 'cancelled') totalSkipped++;
}
// Summary line
commentBody += '#### Overall Summary\n\n';
commentBody += `- ✅ **Success:** ${totalSuccess}\n`;
commentBody += `- ❌ **Failure:** ${totalFailure}\n`;
commentBody += `- 🟠 **Queued:** ${totalQueued}\n`;
commentBody += `- 🟡 **In Progress:** ${totalProgress}\n`;
commentBody += `- ⏭️ **Skipped:** ${totalSkipped}\n\n`;
commentBody += '---\n\n';
commentBody += '### Detailed Results\n\n';
// Build detailed results
for (const result of results) {
commentBody += `<details>\n`;
commentBody += `<summary>${result.status} <strong>${result.name}</strong> - ${result.statusText}</summary>\n\n`;
commentBody += `**Workflow:** [${result.name}](${result.url})\n\n`;
// Show jobs for this workflow
const workflowJobs = jobsByWorkflow.get(result.name) || [];
if (workflowJobs.length > 0) {
commentBody += '**Jobs:**\n\n';
for (const job of workflowJobs) {
commentBody += `- ${job.status} [${job.name}](${job.url})\n`;
}
}
commentBody += '\n</details>\n\n';
}
commentBody += '\n---\n';
commentBody += '*🤖 This comment is automatically generated and updated by the CI system.*\n';
// Check if comment already exists
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
const existingComment = comments.data.find(comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('<!-- CI Results Comment -->')
);
if (existingComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: commentBody
});
console.log(`Updated comment ${existingComment.id} on PR #${prNumber}`);
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody
});
console.log(`Created new comment on PR #${prNumber}`);
}

View File

@@ -29,4 +29,17 @@ jobs:
shell: bash
run: |
pip install click chardet PyYaml
python tools/ci/file_check.py check 'https://github.com/RT-Thread/rt-thread' 'master'
python tools/ci/file_check.py check 'https://github.com/RT-Thread/rt-thread' 'master'
# # Post CI status to PR comment
# post-ci-status:
# needs: scancode_job
# if: always() && github.event_name == 'pull_request' && github.repository_owner == 'RT-Thread'
# uses: ./.github/workflows/post_ci_status.yml
# with:
# workflow_name: "Check File Format and License"
# workflow_status: ${{ needs.scancode_job.result }}
# pr_number: ${{ github.event.pull_request.number }}
# permissions:
# pull-requests: write
# issues: write

110
.github/workflows/post_ci_status.yml vendored Normal file
View File

@@ -0,0 +1,110 @@
#
# Copyright (c) 2025, RT-Thread Development Team
#
# SPDX-License-Identifier: Apache-2.0
#
# Change Logs:
# Date Author Notes
# 2025-10-27 GitHub Copilot Reusable workflow to post CI status
name: Post CI Status Comment
# on:
# workflow_call:
# inputs:
# workflow_name:
# description: 'Name of the workflow'
# required: true
# type: string
# workflow_status:
# description: 'Status of the workflow (success/failure)'
# required: true
# type: string
# pr_number:
# description: 'Pull request number'
# required: true
# type: number
permissions:
pull-requests: write
issues: write
jobs:
post-comment:
runs-on: ubuntu-22.04
if: github.repository_owner == 'RT-Thread'
steps:
- name: Post or update CI status comment
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const prNumber = ${{ inputs.pr_number }};
const workflowName = '${{ inputs.workflow_name }}';
const workflowStatus = '${{ inputs.workflow_status }}';
// Status emoji mapping
const statusEmoji = workflowStatus === 'success' ? '✅' : '❌';
const timestamp = new Date().toISOString();
// Try to find existing comment
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
const botComment = comments.data.find(comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('<!-- CI Status Comment -->')
);
// Get all workflow runs for this PR to build comprehensive status
let allStatuses = {};
if (botComment) {
// Parse existing statuses from comment
const statusRegex = /- (✅|❌|🟡) \*\*(.+?)\*\*/g;
let match;
while ((match = statusRegex.exec(botComment.body)) !== null) {
allStatuses[match[2]] = match[1];
}
}
// Update current workflow status
allStatuses[workflowName] = statusEmoji;
// Build comment body
let commentBody = '<!-- CI Status Comment -->\n';
commentBody += '## 🤖 CI Test Results\n\n';
commentBody += `**Last Updated:** ${timestamp}\n\n`;
commentBody += '### Workflow Status:\n\n';
for (const [name, emoji] of Object.entries(allStatuses)) {
commentBody += `- ${emoji} **${name}**\n`;
}
commentBody += '\n---\n';
commentBody += '✅ Success | ❌ Failure | 🟡 In Progress\n\n';
commentBody += '*This comment is automatically updated as CI workflows complete.*\n';
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
console.log(`Updated comment ${botComment.id} on PR #${prNumber}`);
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody
});
console.log(`Created new comment on PR #${prNumber}`);
}

View File

@@ -0,0 +1,200 @@
name: Weekly CI Scheduler
on:
# Runs at 08:00 Beijing time every day
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
debug:
description: 'Debug mode'
required: false
default: 'false'
env:
TARGET_WORKFLOWS: '["RT-Thread BSP Static Build Check", "utest_auto_run"]'
DISCUSSION_CATEGORY: "Github Action Exception Reports"
jobs:
trigger-and-monitor:
name: Trigger and Monitor CIs
runs-on: ubuntu-latest
outputs:
failed_workflows: ${{ steps.collect-results.outputs.failed_workflows }}
total_workflows: ${{ steps.collect-results.outputs.total_workflows }}
has_results: ${{ steps.collect-results.outputs.has_results }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Record start time
id: start-time
run: |
echo "start_time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
echo "Start time: $(date -u +'%Y-%m-%dT%H:%M:%SZ')"
- name: Trigger CI workflows directly
id: trigger-ci
run: |
python tools/ci/scheduled-ci-trigger/trigger_workflows_direct.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_WORKFLOWS: ${{ env.TARGET_WORKFLOWS }}
- name: Wait for workflows to appear
id: wait-for-workflows
run: |
echo "Waiting for workflows to appear in API..."
python tools/ci/scheduled-ci-trigger/wait_for_workflows.py "${{ steps.start-time.outputs.start_time }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_WORKFLOWS: ${{ env.TARGET_WORKFLOWS }}
- name: Monitor CI workflows
id: monitor-ci
run: |
python tools/ci/scheduled-ci-trigger/monitor_workflows.py "${{ steps.start-time.outputs.start_time }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TARGET_WORKFLOWS: ${{ env.TARGET_WORKFLOWS }}
- name: Collect monitoring results
id: collect-results
run: |
echo "Checking for monitoring results..."
if [ -f "monitoring_results.json" ]; then
echo "monitoring_results.json found"
FAILED_COUNT=$(python -c "import json; data=json.load(open('monitoring_results.json')); print(len([w for w in data if w.get('conclusion') == 'failure']))")
TOTAL_COUNT=$(python -c "import json; data=json.load(open('monitoring_results.json')); print(len(data))")
echo "failed_workflows=$FAILED_COUNT" >> $GITHUB_OUTPUT
echo "total_workflows=$TOTAL_COUNT" >> $GITHUB_OUTPUT
echo "has_results=true" >> $GITHUB_OUTPUT
echo "Results: $FAILED_COUNT failed out of $TOTAL_COUNT total"
else
echo "monitoring_results.json not found"
echo "failed_workflows=0" >> $GITHUB_OUTPUT
echo "total_workflows=0" >> $GITHUB_OUTPUT
echo "has_results=false" >> $GITHUB_OUTPUT
fi
- name: Generate detailed report
if: steps.collect-results.outputs.has_results == 'true' && steps.collect-results.outputs.failed_workflows != '0'
id: generate-report
run: |
echo "Generating detailed report..."
python tools/ci/scheduled-ci-trigger/generate_report.py
echo "Report generation completed"
- name: Upload report artifact
if: steps.collect-results.outputs.has_results == 'true' && steps.collect-results.outputs.failed_workflows != '0'
uses: actions/upload-artifact@v4
with:
name: ci-failure-report
path: |
monitoring_results.json
failure_details.md
retention-days: 7
create-discussion:
name: Create Discussion Report
needs: trigger-and-monitor
if: needs.trigger-and-monitor.outputs.has_results == 'true' && needs.trigger-and-monitor.outputs.failed_workflows != '0'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download report artifact
uses: actions/download-artifact@v4
with:
name: ci-failure-report
- name: Create Discussion
uses: actions/github-script@v6
env:
DISCUSSION_CATEGORY: ${{ env.DISCUSSION_CATEGORY }}
with:
script: |
const fs = require('fs');
const reportPath = './failure_details.md';
let reportContent = fs.readFileSync(reportPath, 'utf8');
// 提取日期从第一行: # YYYYMMDD_ci_integration-failed-report
const lines = reportContent.split('\n');
const firstLine = lines[0].trim();
const dateMatch = firstLine.match(/# (\d{8})_ci_integration-failed-report/);
if (!dateMatch) {
console.error('Failed to extract date from first line:', firstLine);
process.exit(1);
}
const dateString = dateMatch[1];
const discussionTitle = `${dateString}_ci_integration-failed-report`;
// === 关键修复:移除第一行(用于提取的隐藏行) ===
reportContent = lines.slice(1).join('\n').trim();
// 获取仓库ID和分类ID
const getRepoQuery = `
query($owner: String!, $repo: String!) {
repository(owner: $owner, name: $repo) {
id
discussionCategories(first: 20) {
nodes {
id
name
}
}
}
}
`;
const repoData = await github.graphql(getRepoQuery, {
owner: context.repo.owner,
repo: context.repo.repo
});
const repositoryId = repoData.repository.id;
const categories = repoData.repository.discussionCategories.nodes;
const targetCategory = categories.find(cat => cat.name === process.env.DISCUSSION_CATEGORY);
if (!targetCategory) {
console.error('Category not found:', process.env.DISCUSSION_CATEGORY);
process.exit(1);
}
const createDiscussionMutation = `
mutation($repositoryId: ID!, $categoryId: ID!, $title: String!, $body: String!) {
createDiscussion(input: {
repositoryId: $repositoryId
categoryId: $categoryId
title: $title
body: $body
}) {
discussion {
id
title
url
}
}
}
`;
const result = await github.graphql(createDiscussionMutation, {
repositoryId: repositoryId,
categoryId: targetCategory.id,
title: discussionTitle,
body: reportContent // 使用清理后的内容(无第一行)
});
console.log('Discussion created successfully:', result.createDiscussion.discussion.url);

View File

@@ -54,4 +54,17 @@ jobs:
sudo make install FILESDIR=/usr/local/share/Cppcheck
cppcheck --version
cd ..
python tools/ci/cpp_check.py check
python tools/ci/cpp_check.py check
# # Post CI status to PR comment
# post-ci-status:
# needs: scancode_job
# if: always() && github.event_name == 'pull_request' && github.repository_owner == 'RT-Thread'
# uses: ./.github/workflows/post_ci_status.yml
# with:
# workflow_name: "Static code analysis"
# workflow_status: ${{ needs.scancode_job.result }}
# pr_number: ${{ github.event.pull_request.number }}
# permissions:
# pull-requests: write
# issues: write

View File

@@ -18,6 +18,13 @@ on:
- documentation/**
- '**/README.md'
- '**/README_zh.md'
workflow_dispatch:
inputs:
trigger_type:
description: '触发类型'
required: false
default: 'manual'
type: string
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -297,4 +304,16 @@ jobs:
echo "=========================================================================================="
break
fi
done
done
# # Post CI status to PR comment
# post-ci-status:
# needs: test
# if: always() && github.event_name == 'pull_request' && github.repository_owner == 'RT-Thread'
# uses: ./.github/workflows/post_ci_status.yml
# with:
# workflow_name: "utest_auto_run"
# workflow_status: ${{ needs.test.result }}
# pr_number: ${{ github.event.pull_request.number }}
# permissions:
# pull-requests: write
# issues: write

View File

@@ -1,3 +1,184 @@
# RT-Thread v5.2.2 Released
Change Log Since v5.2.1 Release.
## Kernel
* Fix scheduling exception caused by interrupt preemption in rt_schedule.[(#10715)](https://github.com/RT-Thread/rt-thread/pull/10715)
* Fix the legacy issue related to the length of the object name version.[(#10537)](https://github.com/RT-Thread/rt-thread/pull/10537)
* Fixed buffer overflow vulnerability in object.[(#10523)](https://github.com/RT-Thread/rt-thread/pull/10523)
* Add up scheduler critical switch flag.[(#10581)](https://github.com/RT-Thread/rt-thread/pull/10581)
* Update the default value of RT_NAME_MAX to 12.[(#10839)](https://github.com/RT-Thread/rt-thread/pull/10839)
* Feat the rt_scheduler lock nest uses atomic operations.[(#10621)](https://github.com/RT-Thread/rt-thread/pull/10621)
## Components
* **Drivers**
* **Serial:**
* serial_v1
* Fix correct data loss logic when RX ring buffer is full.
* serial_v2
* Fix the bug of RX flush under DMA.
* Add serial V2 buffer configuration via Kconfig.
* Feat optimize serial v2. [(#10603)](https://github.com/RT-Thread/rt-thread/pull/10603)
* Feat modify the default configuration of the RT_SERIAL_CONFIG_DEFAULT structure to support parameters in the absence of DMA configuration.
* **RTC:**
* Add the alarm using local time for calculation.
* **CAN:**
* Fixed the issue where the thread calling CAN int TX was suspended when CAN at the bottom layer failed to work.
* Feat: Implement non-blocking send mechanism and enhance CAN driver functionality.
* **SPI:**
* Add SPI device detach function.[(#10733)](https://github.com/RT-Thread/rt-thread/pull/10733)
* Update and fix up the SPI.
* **ADC:**
* Fixed cppcheck error.
* Remove build warnings.
* **ktime:**
* Remove unused rt_ktime_hrtimer_getcnt for hrtimer.
* **wlan:**
* Update SECURITY_UNKNOWN value.
* **LWP**
* Fix potential signal handler infinite loop for riscv.
* Feat: Restore TP register in arch_thread_signal_enter to fix user-mode memory access.
* **Libc**
* Add comments for some pthread functions.
* pthreads: Fix pthread_cond_timedwait lacks timeout wakeup.
* ensure compatibility with newlib <3.4.0 by handling removed __sdidinit. [(#10791)](https://github.com/RT-Thread/rt-thread/pull/10791)
* **DFS**
* **DFS v2**:
* Fix bugs for function _get_parent_path(). [(#10539)](https://github.com/RT-Thread/rt-thread/pull/10539)
* **Net**
* **SAL/Socket:**
* Fixed CI compilation failure in sal/src/sal_socket.c.
* Fix memory leak when sal_socket failed.
* improve the error return of sal.
* **Netdev:**
* Fixed compilation errors when enabling IPv6 and IPv4 dual-stack support.
* Fixed netdev_unregister missing correct return value. [(#10693)](https://github.com/RT-Thread/rt-thread/pull/10693)
* Expose netdev_set_dns and netdev_set_if. [(#10128)](https://github.com/RT-Thread/rt-thread/pull/10128)
* **AT:**
* at_client add deInit port. [(#10598)](https://github.com/RT-Thread/rt-thread/pull/10598)
* **Finsh:**
* Fixed clear out the useless copy operations. [(#10699)](https://github.com/RT-Thread/rt-thread/pull/10699)
* Feat add support for the Home, Insert, Delete and End keys, and improve input mode processing.[(#10595)](https://github.com/RT-Thread/rt-thread/pull/10595)
* Feat: Add new features (delete by word, switch cursor, etc.).
* **USB:**
* Update (cherryusb): update to v1.5.1.
* Fixed several issues related to cherryusb.[(#10844)](https://github.com/RT-Thread/rt-thread/pull/10844)
* **Ulog:**
* Fix:filter should not be associated with ULOG_USING_COLOR and ULOG_USING_SYSLOG configurations.
* **IPC:**
* Pass rt_tick_t for RT_TIMER_CTRL_SET_TIME and RT_TIMER_CTRL_GET_TIME.[(#10717)](https://github.com/RT-Thread/rt-thread/pull/10717)
## DM
* NVME: fix up the QUEUE alloc error no check.
* Thermal: Fix up the C99, 6.8.1 Labeled statements p4; Fix up the PWM-FAN remove handle data ptr.
* PCI: Add SoC PCI Kconfig import; Multiple PCI-related fixes; Fix and optimize interrupt-related issues.
* WDT: Support related to Intel 6300ESB/Synopsys Watchdog, etc.
## Libcpu
* **AArch64:**
* Fix up MMU and linker warning.
* Fix rt_aspace_init error when KERNEL_VADDR_START >= 0x80000000.
* Add the configuration of libcpu/aarch64 KERNEL ASPACE START.
* Update Hypercall API.
* Remove unused rt_hw_set_gtimer_frq.
* **Cortex-M33:**
* Fix the M33 assembly syntax errors and fix the compilation error of BSP.
* Added HardFault_Handler to save floating point registers.
* **Cortex-M4:**
* Fixed compilation error.
* Added HardFault_Handler to save floating point registers.
* **Cortex-M3:**
* The parameter passed to the unified rt_exception_hook is exception_stack. [(#10619)](https://github.com/RT-Thread/rt-thread/pull/10619)
* **RISC-V:**
* Fix type mismatch of `_query`.
* Fix the support for RV32E. RV32E does not support the s2 register. Modify it to the s1 register.
* Use volatile RW for claim and complete.
* Add spaces to fix `Wliteral-suffix`.
* Add comment for the round down of symb_pc.
* Remove `rt_hw_cpu_id` in `cpuport.h` to fix error.
## Tools
* Add support for package.json, refactor BuildPackage function to handle new format.
* Add documents for tools script; Add NG for tools. [(#10572)](https://github.com/RT-Thread/rt-thread/pull/10572)
* Add workspace generation for RT-Thread root directory.
* Add vsc_workspace target in scons.
* Add DTC (Devicetree Compiler) tools.
* Add clang-format formatting script for CI.
* Optimize the file opening method.
* Clang format ignore migration.
* Improve[clang-format]: optimize the formatting logic for RT-Thread coding standard.
## Action
* Fixed CI: ARDUINO_ADAFRUIT_SENSORLAB compilation failure issue.
* Fixed CI compilation failure in sal/src/sal_socket.c.[(#10854)](https://github.com/RT-Thread/rt-thread/pull/10854)
* Merge same tag with different paths, remove Path display from CI comment.
* Add Copilot review title keywords.
* Add concurrency control to GitHub Actions. [(#10761)](https://github.com/RT-Thread/rt-thread/pull/10761)
* integrate utest run ci. [(#10748)](https://github.com/RT-Thread/rt-thread/pull/10748)
* Improve the comment instructions for the PR format bot.[(#10747)](https://github.com/RT-Thread/rt-thread/pull/10747)
## Documents
* **Doxygen:**
* Fix some document issues.
* Update naming rule for utest-case.
* Update doc for env to latest.
* Update some document content.
* Group name all in lowercase. [(#10530)](https://github.com/RT-Thread/rt-thread/pull/10530)
* Grouping and page optimization related to device driver.
* use layout to control the HTML display.
* Add doxygen comments for scheduler. [(#10366)](https://github.com/RT-Thread/rt-thread/pull/10366) and lwp
* update doxygen version to v1.9.8 .
## Utest
* Add netdev/lwip/filesystem/memory pool/SAL/system performance API test case.
* Support autocomplete of utest cases for `utest_run`. [(#10701)](https://github.com/RT-Thread/rt-thread/pull/10701)
* Feat:reorganize utest menu.
* Feat:rename files and update naming according to new rule.
* Feat:reorganize utest framework structure (initial version).
* Feat:unify config name. [(#10808)](https://github.com/RT-Thread/rt-thread/pull/10808)
* Feat:integrate test cases into utest framework. [(#10665)](https://github.com/RT-Thread/rt-thread/pull/10665)
* Move driver-related test cases under `drivers`.
* Move and enhance C++ test cases.
## BSP
* Some driver issues have been resolved and some driver support has been added.
* **Added/Updated BSPs:**
* **xuantie**
* E901
* **Renesas:**
* ek-ra6e2
* ek-ra4e2
* ek-ra2a1
* ek-ra2e2
* ek-ra4m1
* **GD32:**
* gd32h759i-eval
* gd32470i-eval
* gd32e230-lckfb
* **NXP:**
* MCX E247
* FRDM-MCXE247
* FRDM-MCXA346
* **HPMicro:**
* hpm6p00evk
* hpm5e00evk
* **Phytium**
* **Raspberry RP2350**
# RT-Thread v5.2.1 Released
Change Log Since v5.2.0 Release

View File

@@ -4,6 +4,7 @@ menu "RT-Thread Utestcases"
bool "RT-Thread Utestcases"
default n
select RT_USING_UTEST
select RT_USING_DEBUG if !RT_USING_ULOG
if RT_USING_UTESTCASES

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/psoc6-evaluationkit-062S2/libs/TARGET_RTT-062S2/

View File

@@ -1,6 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- TARGET_RTT-062S2

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/**/libraries/

View File

@@ -1,6 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- libraries

View File

@@ -1,6 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- libraries

View File

@@ -0,0 +1,6 @@
# clang-format ignore file
/libraries/APM32F0xx_Library/
/libraries/APM32F10x_Library/
/libraries/APM32F4xx_Library/
/libraries/APM32E10x_Library/
/libraries/APM32S10x_Library/

View File

@@ -1,10 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- APM32F0xx_Library
- APM32F10x_Library
- APM32F4xx_Library
- APM32E10x_Library
- APM32S10x_Library

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/libraries/CMSIS/

View File

@@ -1,6 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- CMSIS

View File

@@ -0,0 +1,3 @@
# clang-format ignore file
/libraries/bl_mcu_sdk/drivers/
/libraries/bl_mcu_sdk/tools/

View File

@@ -1,7 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- drivers
- tools

View File

@@ -0,0 +1,7 @@
# clang-format ignore file
/Libraries/core_v_hal_libraries/bmsis/
/Libraries/core_v_hal_libraries/core_v_hal/
/Libraries/core_v_hal_libraries/core_v_udma_driver/
/Libraries/core_v_hal_libraries/bmsis/core-v-mcu/source/core-v-mcu.c
/Libraries/core_v_hal_libraries/bmsis/core-v-mcu/source/crt0.S
/Libraries/core_v_hal_libraries/bmsis/core-v-mcu/source/vectors.S

View File

@@ -1,8 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- bmsis
- core_v_hal
- core_v_udma_driver

View File

@@ -1,8 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- core-v-mcu.c
- crt0.S
- vectors.S

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/drivers/libraries/

View File

@@ -1,6 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- libraries

View File

@@ -0,0 +1,3 @@
# clang-format ignore file
/**/libraries/

View File

@@ -1,4 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
dir_path:
- libraries

View File

@@ -1,4 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
dir_path:
- libraries

View File

@@ -1,4 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
dir_path:
- libraries

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/libraries/

View File

@@ -1,6 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- libraries

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/libraries/FT32F0xx/

View File

@@ -1,6 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- FT32F0xx

View File

@@ -34,55 +34,63 @@ menu "On-chip Peripheral Drivers"
config BSP_UART0_RX_USING_DMA
bool "Enable UART0 RX DMA"
depends on BSP_USING_UART0
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART0 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART0_TX_USING_DMA
bool "Enable UART0 TX DMA"
depends on BSP_USING_UART0
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART0 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART0_DMA_PING_BUFSIZE
int "Set UART0 RX DMA ping-pong buffer size"
range 16 65535
depends on BSP_USING_UART0 && RT_USING_SERIAL_V2 && BSP_UART0_RX_USING_DMA
default 64
config BSP_UART0_RX_BUFSIZE
int "Set UART0 RX buffer size"
range 64 65535
depends on BSP_USING_UART0 && RT_USING_SERIAL_V2
default 64
default 128
config BSP_UART0_TX_BUFSIZE
int "Set UART0 TX buffer size"
range 0 65535
range 64 65535
depends on BSP_USING_UART0 && RT_USING_SERIAL_V2
default 0
default 128
config BSP_USING_UART1
bool "Enable UART1"
default n
default y
config BSP_UART1_RX_USING_DMA
bool "Enable UART1 RX DMA"
depends on BSP_USING_UART1
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART1 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART1_TX_USING_DMA
bool "Enable UART1 TX DMA"
depends on BSP_USING_UART1
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART1 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART1_DMA_PING_BUFSIZE
int "Set UART1 RX DMA ping-pong buffer size"
range 16 65535
depends on BSP_USING_UART1 && RT_USING_SERIAL_V2 && BSP_UART1_RX_USING_DMA
default 64
config BSP_UART1_RX_BUFSIZE
int "Set UART1 RX buffer size"
range 64 65535
depends on BSP_USING_UART1 && RT_USING_SERIAL_V2
default 64
default 128
config BSP_UART1_TX_BUFSIZE
int "Set UART1 TX buffer size"
range 0 65535
range 64 65535
depends on BSP_USING_UART1 && RT_USING_SERIAL_V2
default 0
default 128
config BSP_USING_UART2
bool "Enable UART2"
@@ -90,27 +98,31 @@ menu "On-chip Peripheral Drivers"
config BSP_UART2_RX_USING_DMA
bool "Enable UART2 RX DMA"
depends on BSP_USING_UART2
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART2 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART2_TX_USING_DMA
bool "Enable UART2 TX DMA"
depends on BSP_USING_UART2
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART2 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART2_DMA_PING_BUFSIZE
int "Set UART2 RX DMA ping-pong buffer size"
range 16 65535
depends on BSP_USING_UART2 && RT_USING_SERIAL_V2 && BSP_UART2_RX_USING_DMA
default 64
config BSP_UART2_RX_BUFSIZE
int "Set UART2 RX buffer size"
range 64 65535
depends on BSP_USING_UART2 && RT_USING_SERIAL_V2
default 64
default 128
config BSP_UART2_TX_BUFSIZE
int "Set UART2 TX buffer size"
range 0 65535
range 64 65535
depends on BSP_USING_UART2 && RT_USING_SERIAL_V2
default 0
default 128
config BSP_USING_UART3
bool "Enable UART3"
@@ -118,27 +130,31 @@ menu "On-chip Peripheral Drivers"
config BSP_UART3_RX_USING_DMA
bool "Enable UART3 RX DMA"
depends on BSP_USING_UART3
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART3 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART3_TX_USING_DMA
bool "Enable UART3 TX DMA"
depends on BSP_USING_UART3
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART3 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART3_DMA_PING_BUFSIZE
int "Set UART3 RX DMA ping-pong buffer size"
range 16 65535
depends on BSP_USING_UART3 && RT_USING_SERIAL_V2 && BSP_UART3_RX_USING_DMA
default 64
config BSP_UART3_RX_BUFSIZE
int "Set UART3 RX buffer size"
range 64 65535
depends on BSP_USING_UART3 && RT_USING_SERIAL_V2
default 64
default 128
config BSP_UART3_TX_BUFSIZE
int "Set UART3 TX buffer size"
range 0 65535
range 64 65535
depends on BSP_USING_UART3 && RT_USING_SERIAL_V2
default 0
default 128
config BSP_USING_UART4
bool "Enable UART4"
@@ -146,27 +162,31 @@ menu "On-chip Peripheral Drivers"
config BSP_UART4_RX_USING_DMA
bool "Enable UART4 RX DMA"
depends on BSP_USING_UART4
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART4 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART4_TX_USING_DMA
bool "Enable UART4 TX DMA"
depends on BSP_USING_UART4
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART4 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART4_DMA_PING_BUFSIZE
int "Set UART4 RX DMA ping-pong buffer size"
range 16 65535
depends on BSP_USING_UART4 && RT_USING_SERIAL_V2 && BSP_UART4_RX_USING_DMA
default 64
config BSP_UART4_RX_BUFSIZE
int "Set UART4 RX buffer size"
range 64 65535
depends on BSP_USING_UART4 && RT_USING_SERIAL_V2
default 64
default 128
config BSP_UART4_TX_BUFSIZE
int "Set UART4 TX buffer size"
range 0 65535
range 64 65535
depends on BSP_USING_UART4 && RT_USING_SERIAL_V2
default 0
default 128
config BSP_USING_UART5
bool "Enable UART5"
@@ -174,27 +194,31 @@ menu "On-chip Peripheral Drivers"
config BSP_UART5_RX_USING_DMA
bool "Enable UART5 RX DMA"
depends on BSP_USING_UART5
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART5 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART5_TX_USING_DMA
bool "Enable UART5 TX DMA"
depends on BSP_USING_UART5
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART5 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART5_DMA_PING_BUFSIZE
int "Set UART5 RX DMA ping-pong buffer size"
range 16 65535
depends on BSP_USING_UART5 && RT_USING_SERIAL_V2 && BSP_UART5_RX_USING_DMA
default 64
config BSP_UART5_RX_BUFSIZE
int "Set UART5 RX buffer size"
range 64 65535
depends on BSP_USING_UART5 && RT_USING_SERIAL_V2
default 64
default 128
config BSP_UART5_TX_BUFSIZE
int "Set UART5 TX buffer size"
range 0 65535
range 64 65535
depends on BSP_USING_UART5 && RT_USING_SERIAL_V2
default 0
default 128
config BSP_USING_UART6
bool "Enable UART6"
@@ -202,55 +226,63 @@ menu "On-chip Peripheral Drivers"
config BSP_UART6_RX_USING_DMA
bool "Enable UART6 RX DMA"
depends on BSP_USING_UART6
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART6 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART6_TX_USING_DMA
bool "Enable UART6 TX DMA"
depends on BSP_USING_UART6
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART6 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART6_DMA_PING_BUFSIZE
int "Set UART6 RX DMA ping-pong buffer size"
range 16 65535
depends on BSP_USING_UART6 && RT_USING_SERIAL_V2 && BSP_UART6_RX_USING_DMA
default 64
config BSP_UART6_RX_BUFSIZE
int "Set UART6 RX buffer size"
range 64 65535
depends on BSP_USING_UART6 && RT_USING_SERIAL_V2
default 64
default 128
config BSP_UART6_TX_BUFSIZE
int "Set UART6 TX buffer size"
range 0 65535
range 64 65535
depends on BSP_USING_UART6 && RT_USING_SERIAL_V2
default 0
default 128
config BSP_USING_UART7
config BSP_USING_UART7
bool "Enable UART7"
default n
config BSP_UART7_RX_USING_DMA
bool "Enable UART7 RX DMA"
depends on BSP_USING_UART7
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART7 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART7_TX_USING_DMA
bool "Enable UART7 TX DMA"
depends on BSP_USING_UART7
select RT_SERIAL_USING_DMA
depends on BSP_USING_UART7 && RT_USING_SERIAL_V2 && RT_SERIAL_USING_DMA
default n
config BSP_UART7_DMA_PING_BUFSIZE
int "Set UART7 RX DMA ping-pong buffer size"
range 16 65535
depends on BSP_USING_UART7 && RT_USING_SERIAL_V2 && BSP_UART7_RX_USING_DMA
default 64
config BSP_UART7_RX_BUFSIZE
int "Set UART7 RX buffer size"
range 64 65535
depends on BSP_USING_UART7 && RT_USING_SERIAL_V2
default 64
default 128
config BSP_UART7_TX_BUFSIZE
int "Set UART7 TX buffer size"
range 0 65535
range 64 65535
depends on BSP_USING_UART7 && RT_USING_SERIAL_V2
default 0
default 128
endif
menuconfig BSP_USING_SPI

View File

@@ -1,9 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- GD32F10x_Firmware_Library
- GD32F20x_Firmware_Library
- GD32F30x_Firmware_Library
- GD32F4xx_Firmware_Library

View File

@@ -100,7 +100,7 @@ static void gd32_adc_gpio_init(rcu_periph_enum adc_clk, rt_base_t pin)
/* enable ADC clock */
rcu_periph_clock_enable(adc_clk);
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x || defined SOC_SERIES_GD32F5xx
/* configure adc pin */
gpio_mode_set(PIN_GDPORT(pin), GPIO_MODE_ANALOG, GPIO_PUPD_NONE, PIN_GDPIN(pin));
#else
@@ -139,7 +139,7 @@ static rt_err_t gd32_adc_enabled(struct rt_adc_device *device, rt_int8_t channel
adc_data_alignment_config(adc_periph, ADC_DATAALIGN_RIGHT);
#endif
#if defined SOC_SERIES_GD32F4xx
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32F5xx
adc_channel_length_config(adc_periph, ADC_ROUTINE_CHANNEL, 1);
adc_external_trigger_source_config(adc_periph, ADC_ROUTINE_CHANNEL, ADC_EXTTRIG_ROUTINE_EXTI_11);
adc_external_trigger_config(adc_periph, ADC_ROUTINE_CHANNEL, ENABLE);
@@ -202,7 +202,7 @@ static rt_err_t gd32_adc_convert(struct rt_adc_device *device, rt_int8_t channel
#else
adc_flag_clear(adc_periph, ADC_FLAG_EOC | ADC_FLAG_STRC);
#endif
#if defined SOC_SERIES_GD32F4xx
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32F5xx
adc_routine_channel_config(adc_periph, 0, channel, ADC_SAMPLETIME_480);
adc_software_trigger_enable(adc_periph, ADC_ROUTINE_CHANNEL);
#elif defined SOC_SERIES_GD32E23x

View File

@@ -263,7 +263,6 @@ static void dma_recv_isr (struct rt_serial_device *serial)
RT_ASSERT(serial != RT_NULL);
uart = rt_container_of(serial, struct gd32_uart, serial);
recv_len = 0;
level = rt_hw_interrupt_disable();
#if defined SOC_SERIES_GD32E23x
counter = dma_transfer_number_get(uart->dma.rx.channel);
@@ -297,21 +296,14 @@ static void usart_isr (struct rt_serial_device *serial)
if (usart_interrupt_flag_get(uart->periph, USART_INT_FLAG_RBNE) != RESET)
{
struct rt_serial_rx_fifo *rx_fifo;
rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx;
RT_ASSERT(rx_fifo != RT_NULL);
char chr = usart_data_receive(uart->periph);
rt_hw_serial_control_isr(serial, RT_HW_SERIAL_CTRL_PUTC, &chr);
rt_uint8_t chr = usart_data_receive(uart->periph);
rt_hw_serial_control_isr(serial, RT_HW_SERIAL_CTRL_PUTC, (void *)&chr);
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
/* Clear RXNE interrupt flag */
usart_interrupt_flag_clear(uart->periph, USART_INT_FLAG_RBNE);
}
else if (usart_interrupt_flag_get(uart->periph, USART_INT_FLAG_TBE) != RESET)
{
rt_uint8_t put_char = 0;
if (rt_hw_serial_control_isr(serial, RT_HW_SERIAL_CTRL_GETC, &put_char) == RT_EOK)
if (rt_hw_serial_control_isr(serial, RT_HW_SERIAL_CTRL_GETC, (void *)&put_char) == RT_EOK)
{
usart_data_transmit(uart->periph, put_char);
}
@@ -320,7 +312,6 @@ static void usart_isr (struct rt_serial_device *serial)
usart_interrupt_disable(uart->periph, USART_INT_TBE);
usart_interrupt_enable(uart->periph, USART_INT_TC);
}
usart_interrupt_flag_clear(uart->periph, USART_INT_FLAG_TBE);
}
else if (usart_interrupt_flag_get(uart->periph, USART_INT_FLAG_TC) != RESET)
{
@@ -334,10 +325,9 @@ static void usart_isr (struct rt_serial_device *serial)
#ifdef RT_SERIAL_USING_DMA
else if (usart_interrupt_flag_get(uart->periph, USART_INT_FLAG_IDLE) != RESET)
{
volatile uint8_t data = (uint8_t)usart_data_receive(uart->periph);
volatile uint8_t idle_clear_dummy = (uint8_t)usart_data_receive(uart->periph);
RT_UNUSED(idle_clear_dummy);
dma_recv_isr(serial);
usart_interrupt_flag_clear(uart->periph, USART_INT_FLAG_IDLE);
}
#endif
@@ -595,8 +585,8 @@ void UART7_IRQHandler (void)
}
#endif /* BSP_USING_UART7 */
#if define SOC_SERIES_GD32E23x
#if define BSP_UART0_RX_USING_DMA || define BSP_UART0_TX_USING_DMA
#if defined SOC_SERIES_GD32E23x
#if defined BSP_UART0_RX_USING_DMA || defined BSP_UART0_TX_USING_DMA
void DMA_Channel1_2_IRQHandler(void)
{
/* enter interrupt */
@@ -906,6 +896,9 @@ static void _uart_dma_receive (struct gd32_uart *uart, rt_uint8_t *buffer, rt_ui
dma_interrupt_enable(uart->dma.rx.channel, DMA_CHXCTL_HTFIE);
dma_interrupt_enable(uart->dma.rx.channel, DMA_CHXCTL_FTFIE);
/* enable circular mode */
dma_circulation_enable(uart->dma.rx.channel);
/* enable dma channel */
dma_channel_enable(uart->dma.rx.channel);
@@ -953,7 +946,11 @@ static void _uart_dma_receive (struct gd32_uart *uart, rt_uint8_t *buffer, rt_ui
usart_interrupt_enable(uart->periph, USART_INT_IDLE);
/* enable dma receive */
#if defined SOC_SERIES_GD32F5xx
usart_dma_receive_config(uart->periph, USART_DENR_ENABLE);
#else
usart_dma_receive_config(uart->periph, USART_RECEIVE_DMA_ENABLE);
#endif
#endif
}
@@ -972,7 +969,11 @@ static void _uart_dma_transmit (struct gd32_uart *uart, rt_uint8_t *buffer, rt_u
DMA_CHCNT(uart->dma.tx.periph, uart->dma.tx.channel) = size;
/* enable dma transmit */
#if defined SOC_SERIES_GD32F5xx
usart_dma_transmit_config(uart->periph, USART_DENT_ENABLE);
#else
usart_dma_transmit_config(uart->periph, USART_TRANSMIT_DMA_ENABLE);
#endif
/* enable dma channel */
dma_channel_enable(uart->dma.tx.periph, uart->dma.tx.channel);
@@ -1057,7 +1058,7 @@ static void gd32_dma_config (struct rt_serial_device *serial, rt_ubase_t flag)
if (flag == RT_DEVICE_FLAG_DMA_RX)
{
rt_uint8_t *ptr = NULL;
rt_hw_serial_control_isr(serial, RT_HW_SERIAL_CTRL_GET_DMA_PING_BUF, &ptr);
rt_hw_serial_control_isr(serial, RT_HW_SERIAL_CTRL_GET_DMA_PING_BUF, (void *)&ptr);
/* start dma transfer */
_uart_dma_receive(uart, ptr, serial->config.dma_ping_bufsz);

View File

@@ -32,12 +32,12 @@ struct gd32_uart
rcu_periph_enum tx_gpio_clk;
rcu_periph_enum rx_gpio_clk;
uint32_t tx_port;
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x || defined SOC_SERIES_GD32F5xx
uint16_t tx_af;
#endif
uint16_t tx_pin;
uint32_t rx_port;
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x
#if defined SOC_SERIES_GD32F4xx || defined SOC_SERIES_GD32E23x || defined SOC_SERIES_GD32F5xx
uint16_t rx_af;
#endif
uint16_t rx_pin;

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/libraries/hc32_drivers/

View File

@@ -1,9 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- hc32f4a0_ddl
- hc32f460_ddl
- hc32f448_ddl
- hc32f472_ddl

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/Libraries/

View File

@@ -1,9 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
file_path:
dir_path:
- libraries

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/Libraries/

View File

@@ -1,7 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- Libraries

View File

@@ -0,0 +1,2 @@
# clang-format ignore file
/libraries/

View File

@@ -1,9 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
file_path:
dir_path:
- libraries

View File

@@ -0,0 +1,3 @@
# clang-format ignore file
/**/startup/
/libraries/hpm_sdk/

View File

@@ -1,27 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- hpm6200evk/startup
- hpm6200evk/board
- hpm6300evk/startup
- hpm6300evk/board
- hpm6750evk/startup
- hpm6750evk/board
- hpm6750evk2/startup
- hpm6750evk2/board
- hpm6750evkmini/startup
- hpm6750evkmini/board
- hpm5300evk/startup
- hpm5300evk/board
- hpm5301evklite/startup
- hpm5301evklite/board
- hpm6800evk/startup
- hpm6800evk/board
- hpm6e00evk/startup
- hpm6e00evk/board
- hpm6p00evk/startup
- hpm6p00evk/board
- hpm5e00evk/startup
- hpm5e00evk/board

View File

@@ -624,6 +624,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -718,6 +719,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -875,6 +877,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -923,6 +935,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -310,6 +310,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -624,6 +624,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -718,6 +719,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -875,6 +877,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -923,6 +935,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -311,6 +311,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -624,6 +624,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -718,6 +719,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -875,6 +877,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -923,6 +935,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -312,6 +312,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -624,6 +624,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -718,6 +719,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -875,6 +877,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -923,6 +935,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -311,6 +311,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -626,6 +626,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -720,6 +721,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -877,6 +879,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -925,6 +937,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -312,6 +312,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -623,6 +623,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -717,6 +718,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -873,6 +875,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -921,6 +933,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set
@@ -1409,7 +1422,7 @@ CONFIG_BSP_UART0_TX_BUFSIZE=0
# CONFIG_BSP_USING_PDMA is not set
# CONFIG_BSP_USING_GPTMR is not set
# CONFIG_BSP_USING_I2C is not set
# CONFIG_BSP_USING_FEMC is not set
CONFIG_BSP_USING_FEMC=y
CONFIG_INIT_EXT_RAM_FOR_DATA=y
# CONFIG_BSP_USING_XPI_FLASH is not set
# CONFIG_BSP_USING_PWM is not set

View File

@@ -310,6 +310,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */
@@ -401,6 +407,7 @@
#define BSP_USING_UART0
#define BSP_UART0_RX_BUFSIZE 128
#define BSP_UART0_TX_BUFSIZE 0
#define BSP_USING_FEMC
#define INIT_EXT_RAM_FOR_DATA
/* end of On-chip Peripheral Drivers */
/* end of Hardware Drivers Config */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -651,6 +651,7 @@ CONFIG_RT_USING_POSIX_POLL=y
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -745,6 +746,7 @@ CONFIG_RT_USING_POSIX_POLL=y
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -902,6 +904,16 @@ CONFIG_RT_USING_POSIX_POLL=y
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -950,6 +962,7 @@ CONFIG_RT_USING_POSIX_POLL=y
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -323,6 +323,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -627,6 +627,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -721,6 +722,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -878,6 +880,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -926,6 +938,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -312,6 +312,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -628,6 +628,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -722,6 +723,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -879,6 +881,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -927,6 +939,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -315,6 +315,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -624,6 +624,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -718,6 +719,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -875,6 +877,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -923,6 +935,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -311,6 +311,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -628,6 +628,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_RVBACKTRACE is not set
# CONFIG_PKG_USING_HPATCHLITE is not set
# CONFIG_PKG_USING_THREAD_METRIC is not set
# CONFIG_PKG_USING_UORB is not set
# end of tools packages
#
@@ -722,6 +723,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_R_RHEALSTONE is not set
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# end of system packages
#
@@ -879,6 +881,16 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# end of GD32 Drivers
#
# HPMicro SDK
#
CONFIG_PKG_USING_HPM_SDK=y
CONFIG_PKG_HPM_SDK_PATH="/packages/peripherals/hal-sdk/hpmicro/hpm_sdk"
CONFIG_PKG_USING_HPM_SDK_V110=y
# CONFIG_PKG_USING_HPM_SDK_LATEST_VERSION is not set
CONFIG_PKG_HPM_SDK_VER="v1.10.0"
# end of HPMicro SDK
# end of HAL & SDK Drivers
#
@@ -927,6 +939,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
# CONFIG_PKG_USING_MLX90393 is not set
# CONFIG_PKG_USING_MLX90392 is not set
# CONFIG_PKG_USING_MLX90394 is not set
# CONFIG_PKG_USING_MLX90396 is not set
# CONFIG_PKG_USING_MLX90397 is not set
# CONFIG_PKG_USING_MS5611 is not set
# CONFIG_PKG_USING_MAX31865 is not set

View File

@@ -315,6 +315,12 @@
/* GD32 Drivers */
/* end of GD32 Drivers */
/* HPMicro SDK */
#define PKG_USING_HPM_SDK
#define PKG_USING_HPM_SDK_V110
/* end of HPMicro SDK */
/* end of HAL & SDK Drivers */
/* sensors drivers */

View File

@@ -78,6 +78,8 @@ if CROSS_TOOL == 'gcc':
PLATFORM = 'gcc'
if os.getenv('RTT_RISCV_TOOLCHAIN'):
EXEC_PATH = os.getenv('RTT_RISCV_TOOLCHAIN')
elif RTT_EXEC_PATH:
EXEC_PATH = RTT_EXEC_PATH
else:
EXEC_PATH = r'/opt/riscv-gnu-gcc/bin'
else:

View File

@@ -0,0 +1,4 @@
# clang-format ignore file
/libraries/HT32_STD_1xxxx_FWLib/
/libraries/HT32_STD_5xxxx_FWLib/
/libraries/usbd_library/

View File

@@ -1,8 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- HT32_STD_1xxxx_FWLib
- HT32_STD_5xxxx_FWLib
- usbd_library

View File

@@ -0,0 +1,48 @@
scons.args: &scons
scons_arg:
- '--strict'
devices.i2c:
<<: *scons
kconfig:
- CONFIG_RT_USING_I2C=y
- CONFIG_BSP_USING_I2C=y
- CONFIG_BSP_USING_I2C0=y
devices.adc:
<<: *scons
kconfig:
- CONFIG_RT_USING_ADC=y
- CONFIG_BSP_USING_ADC=y
devices.hwtimer:
<<: *scons
kconfig:
- CONFIG_RT_USING_HWTIMER=y
- CONFIG_BSP_USING_TIMERS=y
- CONFIG_BSP_USING_TIMER0=y
devices.pdma:
<<: *scons
kconfig:
- CONFIG_RT_USING_PDMA=y
- CONFIG_BSP_USING_PDMA=y
- CONFIG_BSP_USING_PDMA_CHANNEL0=y
devices.pwm:
<<: *scons
kconfig:
- CONFIG_RT_USING_PWM=y
- CONFIG_BSP_USING_PWM=y
- CONFIG_BSP_USING_PWM0=y
devices.rtc:
<<: *scons
kconfig:
- CONFIG_RT_USING_RTC=y
- CONFIG_BSP_USING_RTC=y
devices.ts:
<<: *scons
kconfig:
- CONFIG_RT_USING_TS=y
- CONFIG_BSP_USING_TS=y
devices.wdt:
<<: *scons
kconfig:
- CONFIG_RT_USING_WDT=y
- CONFIG_BSP_USING_WDT=y
- CONFIG_BSP_USING_WDT0=y

View File

@@ -227,6 +227,7 @@ CONFIG_FINSH_THREAD_STACK_SIZE=8192
CONFIG_FINSH_USING_HISTORY=y
CONFIG_FINSH_HISTORY_LINES=5
# CONFIG_FINSH_USING_WORD_OPERATION is not set
# CONFIG_FINSH_USING_FUNC_EXT is not set
CONFIG_FINSH_USING_SYMTAB=y
CONFIG_FINSH_CMD_SIZE=80
CONFIG_MSH_USING_BUILT_IN_COMMANDS=y
@@ -425,6 +426,7 @@ CONFIG_RT_USING_POSIX_TIMER=y
#
CONFIG_RT_USING_SAL=y
CONFIG_SAL_INTERNET_CHECK=y
CONFIG_SOCKET_TABLE_STEP_LEN=4
#
# Docking with protocol stacks
@@ -1617,6 +1619,7 @@ CONFIG_PKG_ZLIB_VER="latest"
#
# Drivers Configuration
#
# CONFIG_BSP_USING_I2C is not set
# CONFIG_BSP_USING_RTC is not set
# CONFIG_BSP_USING_ADC is not set
# CONFIG_BSP_USING_TS is not set

View File

@@ -1,4 +1,31 @@
menu "Drivers Configuration"
menuconfig BSP_USING_I2C
bool "Enable I2C"
select RT_USING_I2C
default n
if BSP_USING_I2C
config BSP_USING_I2C0
bool "Enable I2C0"
default n
config BSP_USING_I2C1
bool "Enable I2C1"
default n
config BSP_USING_I2C2
bool "Enable I2C2"
default n
config BSP_USING_I2C3
bool "Enable I2C3"
default n
config BSP_USING_I2C4
bool "Enable I2C4"
default n
endif
config BSP_USING_RTC
bool "Enable RTC"

View File

@@ -0,0 +1,11 @@
# RT-Thread building script for I2C component
from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = [cwd]
group = DefineGroup('I2C', src, depend = ['BSP_USING_I2C'], CPPPATH = CPPPATH)
Return('group')

View File

@@ -0,0 +1,528 @@
/* Copyright (c) 2023, Canaan Bright Sight Co., Ltd
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <rtthread.h>
#include <rthw.h>
#include <rtdevice.h>
#include <riscv_io.h>
#include <ioremap.h>
#include "board.h"
#include "drv_i2c.h"
#include "sysctl_clk.h"
#undef DBG_TAG
#undef DBG_LVL
#define DBG_TAG "drv_i2c"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
struct _i2c_speed_cfg
{
rt_uint16_t hcnt;
rt_uint16_t lcnt;
rt_uint16_t spklen;
};
struct k230_i2c_dev
{
struct rt_i2c_bus_device dev;
const char *name;
rt_ubase_t base;
size_t size;
int vector;
rt_uint32_t clock;
struct rt_i2c_msg *msg;
struct _i2c_speed_cfg speed_cfg;
};
static rt_size_t k230_i2c_get_timer(rt_size_t base)
{
return rt_tick_get() - base ;
}
static void k230_i2c_enable(struct k230_i2c_dev *dev, rt_bool_t enable)
{
volatile i2c_t *i2c = (i2c_t *)dev->base;
rt_uint32_t en_value = enable ? 1 : 0;
int timeout = 100;
do
{
i2c->enable.enable = en_value;
if(i2c->enable_status.en == en_value)
{
return;
}
/*
* Wait 10 times the signaling period of the highest I2C
* transfer supported by the driver (for 400KHz this is
* 25us) as described in the DesignWare I2C databook.
*/
rt_hw_us_delay(25);
}while(timeout--);
LOG_E("timeout in %s i2c\n", enable ? "enable" : "disable");
}
static void k230_i2c_set_bus_timeout(struct k230_i2c_dev *dev, rt_uint32_t timeout)
{
float tick = 0;
tick = RT_TICK_PER_SECOND / 1000.0f; /* ms to tick */
dev->dev.timeout = (rt_uint32_t)(timeout * tick);
}
static int k230_i2c_set_bus_speed(struct k230_i2c_dev *dev, rt_uint32_t speed)
{
volatile i2c_t *i2c = (i2c_t *)dev->base;
rt_uint32_t i2c_spd, period, spklen, ft;
/*
* Calculate clock counts for I2C speed
* hcnt + lcnt + spklen + 7 + 1 + fall_time * clk = clk / speed
* fall_time = 10ns
* spklen = 0~50ns
*/
spklen = dev->clock * 10 / 1e9;
ft = dev->clock * 10 / 1e9;
period = dev->clock / speed;
period = period - spklen - 7 - 1 - ft;
dev->speed_cfg.lcnt = period / 2;
dev->speed_cfg.hcnt = period - dev->speed_cfg.lcnt;
dev->speed_cfg.spklen = spklen;
if(speed <= I2C_STANDARD_SPEED_UP)
{
i2c_spd = I2C_SPEED_MODE_STANDARD;
}
else if(speed <= I2C_FAST_SPEED_UP)
{
i2c_spd = I2C_SPEED_MODE_FAST;
}
else if(speed <= I2C_MAX_SPEED_UP)
{
i2c_spd = I2C_SPEED_MODE_MAX;
}
else
{
return -RT_EINVAL;
}
/* to set speed cltr must be disabled */
k230_i2c_enable(dev, RT_FALSE);
switch(i2c_spd)
{
case I2C_SPEED_MODE_STANDARD:
i2c->ss_ufm_scl_hcnt.cnt = dev->speed_cfg.hcnt;
i2c->ss_ufm_scl_lcnt.cnt = dev->speed_cfg.lcnt;
i2c->fs_ufm_spklen.spklen = dev->speed_cfg.spklen;
break;
case I2C_SPEED_MODE_FAST:
i2c->fs_scl_hcnt_ufm_tbuf_cnt.cnt = dev->speed_cfg.hcnt;
i2c->fs_scl_lcnt.cnt = dev->speed_cfg.lcnt;
i2c->fs_ufm_spklen.spklen = dev->speed_cfg.spklen;
break;
case I2C_SPEED_MODE_MAX:
i2c->hs_scl_hcnt.cnt = dev->speed_cfg.hcnt;
i2c->hs_scl_lcnt.cnt = dev->speed_cfg.lcnt;
i2c->hs_spklen.spklen = dev->speed_cfg.spklen;
break;
default: break;
}
i2c->con.speed = i2c_spd;
/* Enable back i2c now speed set */
k230_i2c_enable(dev, RT_TRUE);
return RT_EOK;
}
static void k230_i2c_set_addr(struct k230_i2c_dev *dev)
{
volatile i2c_t *i2c = (i2c_t *)dev->base;
rt_uint16_t i2c_addr = dev->msg->addr;
/* Disable i2c */
k230_i2c_enable(dev, RT_FALSE);
if(dev->msg->flags & RT_I2C_ADDR_10BIT || dev->dev.flags & RT_I2C_ADDR_10BIT)
{
i2c->tar.master_10bit_addr = 1;
i2c_addr &= 0x3FF;
}
else
{
i2c->tar.master_10bit_addr = 0;
i2c_addr &= 0x7F;
}
i2c->tar.tar = i2c_addr;
/* Enable i2c */
k230_i2c_enable(dev, RT_TRUE);
}
static void k230_i2c_flush_rxfifo(struct k230_i2c_dev *dev)
{
volatile i2c_t *i2c = (i2c_t *)dev->base;
while(i2c->status.rfne)
{
readl(&i2c->data_cmd);
}
}
static int k230_i2c_wait_for_bus_busy(struct k230_i2c_dev *dev)
{
rt_size_t start_time = k230_i2c_get_timer(0);
volatile i2c_t *i2c = (i2c_t *)dev->base;
while((i2c->status.mst_activity) || !(i2c->status.tfe))
{
/* Evaluate timeout */
if(k230_i2c_get_timer(start_time) > (rt_size_t)dev->dev.timeout * I2C_TX_FIFO_SIZE)
{
return -RT_ETIMEOUT;
}
}
return RT_EOK;
}
static int k230_i2c_xfer_init(struct k230_i2c_dev *dev)
{
volatile i2c_t *i2c = (i2c_t *)dev->base;
rt_uint8_t addr = 0;
if(k230_i2c_wait_for_bus_busy(dev) != RT_EOK)
{
return -RT_EBUSY;
}
k230_i2c_set_addr(dev);
return RT_EOK;
}
static int k230_i2c_xfer_finish(struct k230_i2c_dev *dev)
{
volatile i2c_t *i2c = (i2c_t *)dev->base;
rt_uint32_t start_stop_det = k230_i2c_get_timer(0);
while (1)
{
if(i2c->raw_intr_stat.stop_det)
{
readl(&i2c->clr_stop_det);
break;
}
else if (k230_i2c_get_timer(start_stop_det) > dev->dev.timeout)
{
break;
}
}
if (k230_i2c_wait_for_bus_busy(dev) != RT_EOK)
{
return -RT_EBUSY;
}
k230_i2c_flush_rxfifo(dev);
return RT_EOK;
}
static int _k230_i2c_read(struct k230_i2c_dev *dev)
{
volatile i2c_t *i2c = (i2c_t *)dev->base;
rt_size_t start_time_rx = 0;
rt_uint32_t recv_len = dev->msg->len;
rt_uint32_t tran_len = dev->msg->len;
rt_uint8_t *buffer = dev->msg->buf;
rt_uint32_t cmd = 0;
/* If no start condition is sent before reading, then send a repeated start. */
if(dev->msg->flags & RT_I2C_NO_START)
{
cmd |= I2C_DATA_CMD_RESTART;
}
else
{
if(k230_i2c_xfer_init(dev) != RT_EOK)
{
return -RT_EBUSY;
}
}
start_time_rx = k230_i2c_get_timer(0);
while(recv_len || tran_len)
{
if (tran_len)
{
while(i2c->status.tfnf == 0);
/* Write stop when the last byte */
cmd = tran_len == 1 ? cmd | I2C_DATA_CMD_STOP : cmd;
/* Write to data cmd register to trigger i2c */
writel(cmd | I2C_DATA_CMD_READ, &i2c->data_cmd);
cmd = 0;
tran_len--;
}
if(i2c->status.rfne)
{
*buffer++ = i2c->data_cmd.dat;
recv_len--;
start_time_rx = k230_i2c_get_timer(0);
}
else if(k230_i2c_get_timer(start_time_rx) > dev->dev.timeout)
{
return -RT_ETIMEOUT;
}
}
return k230_i2c_xfer_finish(dev);
}
static int _k230_i2c_write(struct k230_i2c_dev *dev)
{
volatile i2c_t *i2c = (i2c_t *)dev->base;
rt_size_t start_time_tx = 0;
rt_uint32_t tran_len = dev->msg->len;
rt_uint8_t *buffer = dev->msg->buf;
rt_uint32_t cmd = 0;
rt_uint32_t cut = 0;
if (k230_i2c_xfer_init(dev) != RT_EOK)
{
return -RT_EBUSY;
}
start_time_tx = k230_i2c_get_timer(0);
while(tran_len)
{
if(i2c->status.tfnf)
{
/* If there is no stop flag, the stop condition will not be sent at the last byte. */
if(tran_len == 1 && !(dev->msg->flags & RT_I2C_NO_STOP))
{
cmd |= I2C_DATA_CMD_STOP;
}
else
{
cmd &= ~I2C_DATA_CMD_STOP;
}
cmd |= *buffer++;
writel(cmd, &i2c->data_cmd);
cmd = 0;
tran_len--;
start_time_tx = k230_i2c_get_timer(0);
}
else if(k230_i2c_get_timer(start_time_tx) > dev->dev.timeout)
{
return -RT_ETIMEOUT;
}
}
if (dev->msg->flags & RT_I2C_NO_STOP)
{
return RT_EOK;
}
if (k230_i2c_wait_for_bus_busy(dev) != RT_EOK)
{
return -RT_EBUSY;
}
return RT_EOK;
}
static rt_ssize_t k230_i2c_xfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num)
{
struct k230_i2c_dev *i2c_dev = rt_container_of(bus, struct k230_i2c_dev, dev);
volatile i2c_t *i2c = (i2c_t *)i2c_dev->base;
int ret;
rt_ssize_t send_mesgs = num;
for (; num > 0; num--, msgs++)
{
i2c_dev->msg = msgs;
if(msgs->flags & RT_I2C_RD)
{
ret = _k230_i2c_read(i2c_dev);
}
else
{
ret = _k230_i2c_write(i2c_dev);
}
if (ret != RT_EOK)
{
return -RT_EIO;
}
}
return send_mesgs;
}
static rt_err_t k230_i2c_control(struct rt_i2c_bus_device *bus, int cmd, void *args)
{
struct k230_i2c_dev *i2c_dev = rt_container_of(bus, struct k230_i2c_dev, dev);
rt_uint32_t arg = *(rt_uint32_t *)args;
rt_err_t ret;
RT_ASSERT(bus != RT_NULL);
switch (cmd)
{
/* set 10-bit addr mode */
case RT_I2C_DEV_CTRL_10BIT:
if(arg & RT_I2C_ADDR_10BIT)
{
i2c_dev->dev.flags |= RT_I2C_ADDR_10BIT;
}
else
{
i2c_dev->dev.flags &= ~RT_I2C_ADDR_10BIT;
}
break;
case RT_I2C_DEV_CTRL_TIMEOUT:
k230_i2c_set_bus_timeout(i2c_dev, arg);
break;
case RT_I2C_DEV_CTRL_CLK:
ret = k230_i2c_set_bus_speed(i2c_dev, arg);
if (ret != RT_EOK)
{
return -RT_EIO;
}
break;
default: break;
}
return RT_EOK;
}
static void k230_i2c_master_init(struct k230_i2c_dev *dev)
{
volatile i2c_t *i2c = (i2c_t *)dev->base;
/* Disable i2c */
k230_i2c_enable(dev, RT_FALSE);
i2c->con.slave_disable = 1;
i2c->con.restart_en = 1;
i2c->con.master_mode = 1;
i2c->tx_tl.tl = I2C_TX_TL;
i2c->rx_tl.tl = I2C_RX_TL;
i2c->intr_mask.m_stop_det = 1;
/* Enable i2c */
k230_i2c_enable(dev, RT_TRUE);
}
static const struct rt_i2c_bus_device_ops k230_i2c_ops =
{
.master_xfer = k230_i2c_xfer,
.i2c_bus_control = k230_i2c_control,
};
static struct k230_i2c_dev k230_i2c_devs[] =
{
#ifdef BSP_USING_I2C0
{
.name = "i2c0",
.base = I2C0_BASE_ADDR,
.size = I2C0_IO_SIZE,
.vector = K230_IRQ_I2C0,
},
#endif
#ifdef BSP_USING_I2C1
{
.name = "i2c1",
.base = I2C1_BASE_ADDR,
.size = I2C1_IO_SIZE,
.vector = K230_IRQ_I2C1,
},
#endif
#ifdef BSP_USING_I2C2
{
.name = "i2c2",
.base = I2C2_BASE_ADDR,
.size = I2C2_IO_SIZE,
.vector = K230_IRQ_I2C2,
},
#endif
#ifdef BSP_USING_I2C3
{
.name = "i2c3",
.base = I2C3_BASE_ADDR,
.size = I2C3_IO_SIZE,
.vector = K230_IRQ_I2C3,
},
#endif
#ifdef BSP_USING_I2C4
{
.name = "i2c4",
.base = I2C4_BASE_ADDR,
.size = I2C4_IO_SIZE,
.vector = K230_IRQ_I2C4,
},
#endif
};
int rt_hw_i2c_init(void)
{
int i;
for (i = 0; i < sizeof(k230_i2c_devs) / sizeof(k230_i2c_devs[0]); i++)
{
k230_i2c_devs[i].base = (rt_ubase_t)rt_ioremap((void *)k230_i2c_devs[i].base, k230_i2c_devs[i].size);
k230_i2c_devs[i].dev.ops = &k230_i2c_ops;
k230_i2c_devs[i].clock = sysctl_clk_get_leaf_freq(SYSCTL_CLK_I2C0_CORE + i);
k230_i2c_master_init(&k230_i2c_devs[i]);
k230_i2c_set_bus_timeout(&k230_i2c_devs[i], I2C_DEFAULT_TIMEOUT);
k230_i2c_set_bus_speed(&k230_i2c_devs[i], I2C_DEFAULT_SPEED);
rt_i2c_bus_device_register(&k230_i2c_devs[i].dev, k230_i2c_devs[i].name);
LOG_I("i2c%d master mode, i2c%d clock=%dHz\n", i, i, k230_i2c_devs[i].clock);
}
return RT_EOK;
}
INIT_DEVICE_EXPORT(rt_hw_i2c_init);

View File

@@ -0,0 +1,704 @@
/* Copyright (c) 2023, Canaan Bright Sight Co., Ltd
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __DRV_I2C_H__
#define __DRV_I2C_H__
#include <stdint.h>
#define BIT(x) (1<<(x))
/* Speed Selection */
#define I2C_SPEED_MODE_STANDARD 1
#define I2C_SPEED_MODE_FAST 2
#define I2C_SPEED_MODE_MAX 3
#define I2C_MAX_SPEED_UP 3400000
#define I2C_FAST_SPEED_UP 1000000
#define I2C_STANDARD_SPEED_UP 100000
#define I2C_DEFAULT_SPEED 400000
#define I2C_DEFAULT_TIMEOUT 8 /* 8ms */
/* i2c data cmd definition */
#define I2C_DATA_CMD_READ BIT(8)
#define I2C_DATA_CMD_STOP BIT(9)
#define I2C_DATA_CMD_RESTART BIT(10)
#define I2C_DATA_CMD_FIRST_DATA_BYTE BIT(11)
/* i2c fifo size */
#define I2C_TX_FIFO_SIZE 32 /* 32 * 32bit */
#define I2C_RX_FIFO_SIZE 32 /* 64 * 8bit */
/* fifo threshold register definitions */
#define I2C_TL0 0x00
#define I2C_TL1 0x01
#define I2C_TL2 0x02
#define I2C_TL3 0x03
#define I2C_TL4 0x04
#define I2C_TL5 0x05
#define I2C_TL6 0x06
#define I2C_TL7 0x07
#define I2C_RX_TL I2C_TL0
#define I2C_TX_TL I2C_TL0
/* i2c control register(offset address 0x00) */
typedef struct _i2c_ic_con
{
uint32_t master_mode : 1;
uint32_t speed : 2;
uint32_t slave_10bit_addr : 1;
uint32_t master_10bit_addr : 1;
uint32_t restart_en : 1;
uint32_t slave_disable : 1;
uint32_t stop_det_ifaddressed : 1;
uint32_t tx_empty_ctrl : 1;
uint32_t rx_fifo_full_hld_ctrl : 1;
uint32_t stop_det_if_master_active : 1;
uint32_t bus_clear_feature_ctrl : 1;
uint32_t rsvd_1 : 4; /* reserved */
uint32_t optional_sar_ctrl : 1;
uint32_t smbus_slave_quick_en : 1;
uint32_t smbus_arp_en : 1;
uint32_t smbus_persisent_slv_addr_en : 1;
uint32_t rsvd_2 : 12; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_con_t;
/* i2c target address register(offset address 0x04) */
typedef struct _i2c_ic_tar
{
uint32_t tar : 10;
uint32_t gc_or_start : 1;
uint32_t special : 1;
uint32_t master_10bit_addr : 1;
uint32_t device_id : 1;
uint32_t rsvd_1 : 2; /* reserved */
uint32_t smbus_quick_cmd : 1;
uint32_t rsvd_2 : 15; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_tar_t;
/* i2c slave address register(offset address 0x08) */
typedef struct _i2c_ic_sar
{
uint32_t sar : 10;
uint32_t rsvd : 22; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_sar_t;
/* i2c high speed master mode code address register(offset address 0x0c) */
typedef struct _i2c_ic_hs_maddr
{
uint32_t mar : 3;
uint32_t rsvd : 29; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_hs_maddr_t;
/* i2c rx/tx data buffer and command register(offset address 0x10) */
typedef struct _i2c_ic_data_cmd
{
uint32_t dat : 8;
uint32_t cmd : 1;
uint32_t stop : 1;
uint32_t restart : 1;
uint32_t first_data_byte : 1;
uint32_t rsvd : 20; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_data_cmd_t;
/* i2c standard/ultra-fast speed clock scl high count register(offset address 0x14) */
typedef struct _i2c_ic_ss_ufm_scl_hcnt
{
uint32_t cnt : 16;
uint32_t rsvd : 16; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_ss_ufm_scl_hcnt_t;
/* i2c standard/ultra-fast speed clock scl low count register(offset address 0x18) */
typedef struct _i2c_ic_ss_ufm_scl_lcnt
{
uint32_t cnt : 16;
uint32_t rsvd : 16; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_ss_ufm_scl_lcnt_t;
/* i2c fast mode speed clock scl low count/ultra-fast mode speed tbuf idle count register(offset address 0x1c) */
typedef struct _i2c_ic_fs_scl_hcnt_ufm_tbuf_cnt
{
uint32_t cnt : 16;
uint32_t rsvd : 16; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_fs_scl_hcnt_ufm_tbuf_cnt_t;
/* i2c fast mode clock scl low count register(offset address 0x20) */
typedef struct _i2c_ic_fs_scl_lcnt
{
uint32_t cnt : 16;
uint32_t rsvd : 16; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_fs_scl_lcnt_t;
/* i2c high speed mode clock scl high count register(offset address 0x24) */
typedef struct _i2c_ic_hs_scl_hcnt
{
uint32_t cnt : 16;
uint32_t rsvd : 16; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_hs_scl_hcnt_t;
/* i2c high speed mode clock scl low count register(offset address 0x28) */
typedef struct _i2c_ic_hs_scl_lcnt
{
uint32_t cnt : 16;
uint32_t rsvd : 16; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_hs_scl_lcnt_t;
/* i2c interrupt status register(offset address 0x2c) */
typedef struct _i2c_ic_intr_stat
{
uint32_t r_rx_under : 1;
uint32_t r_rx_over : 1;
uint32_t r_rx_full : 1;
uint32_t r_tx_over : 1;
uint32_t r_tx_empty : 1;
uint32_t r_rd_req : 1;
uint32_t r_tx_abrt : 1;
uint32_t r_rx_done : 1;
uint32_t r_activity : 1;
uint32_t r_stop_det : 1;
uint32_t r_start_det : 1;
uint32_t r_gen_call : 1;
uint32_t r_restart_det : 1;
uint32_t r_master_on_hold : 1;
uint32_t r_slc_stuck_at_low : 1;
uint32_t rsvd : 17; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_intr_stat_t;
/* i2c interrupt mask register(offset address 0x30) */
typedef struct _i2c_ic_intr_mask
{
uint32_t m_rx_under : 1;
uint32_t m_rx_over : 1;
uint32_t m_rx_full : 1;
uint32_t m_tx_over : 1;
uint32_t m_tx_empty : 1;
uint32_t m_rd_req : 1;
uint32_t m_tx_abrt : 1;
uint32_t m_rx_done : 1;
uint32_t m_activity : 1;
uint32_t m_stop_det : 1;
uint32_t m_start_det : 1;
uint32_t m_gen_call : 1;
uint32_t m_restart_det : 1;
uint32_t m_master_on_hold : 1;
uint32_t m_slc_stuck_at_low : 1;
uint32_t rsvd : 17; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_intr_mask_t;
/* i2c raw interrupt status register(offset address 0x34) */
typedef struct _i2c_ic_raw_intr_stat
{
uint32_t rx_under : 1;
uint32_t rx_over : 1;
uint32_t rx_full : 1;
uint32_t tx_over : 1;
uint32_t tx_empty : 1;
uint32_t rd_req : 1;
uint32_t tx_abrt : 1;
uint32_t rx_done : 1;
uint32_t activity : 1;
uint32_t stop_det : 1;
uint32_t start_det : 1;
uint32_t gen_call : 1;
uint32_t restart_det : 1;
uint32_t master_on_hold : 1;
uint32_t scl_stuck_at_low : 1;
uint32_t rsvd : 17; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_raw_intr_stat_t;
/* i2c receive FIFO threshold register(offset address 0x38) */
typedef struct _i2c_ic_rx_tl
{
uint32_t tl : 8;
uint32_t rsvd : 24; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_rx_tl_t;
/* i2c transmit FIFO threshold register(offset address 0x3c) */
typedef struct _i2c_ic_tx_tl
{
uint32_t tl : 8;
uint32_t rsvd : 24; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_tx_tl_t;
/* i2c clear combined and individual interrupt register(offset address 0x40) */
typedef struct _i2c_ic_clr_intr
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_intr_t;
/* i2c clear rx under interrupt register(offset address 0x44) */
typedef struct _i2c_ic_clr_rx_under
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_rx_under_t;
/* i2c clear rx over interrupt register(offset address 0x48) */
typedef struct _i2c_ic_clr_rx_over
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_rx_over_t;
/* i2c clear tx over interrupt register(offset address 0x4c) */
typedef struct _i2c_ic_clr_tx_over
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_tx_over_t;
/* i2c clear rd req interrupt register(offset address 0x50) */
typedef struct _i2c_ic_clr_rd_req
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_rd_req_t;
/* i2c clear tx abrt interrupt register(offset address 0x54) */
typedef struct _i2c_ic_clr_tx_abrt
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_tx_abrt_t;
/* i2c clear rx done interrupt register(offset address 0x58) */
typedef struct _i2c_ic_clr_rx_done
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_rx_done_t;
/* i2c clear activity interrupt register(offset address 0x5c) */
typedef struct _i2c_ic_clr_activity
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_activity_t;
/* i2c clear stop det interrupt register(offset address 0x60) */
typedef struct _i2c_clr_stop_det
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_stop_det_t;
/* i2c clear start det interrupt register(offset address 0x64) */
typedef struct _i2c_ic_clr_start_det
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_start_det_t;
/* i2c clear gen call interrupt register(offset address 0x68) */
typedef struct _i2c_ic_clr_gen_call
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_gen_call_t;
/* i2c enable register(offset address 0x6c) */
typedef struct _i2c_ic_enable
{
uint32_t enable : 1;
uint32_t abort : 1;
uint32_t tx_cmd_block : 1;
uint32_t sda_stuck_recovery_enable : 1;
uint32_t rsvd_1 : 12; /* reserved */
uint32_t smbus_clk_reset : 1;
uint32_t smbus_suspned_en : 1;
uint32_t smbus_alert_en : 1;
uint32_t rsvd_2 : 13; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_enable_t;
/* i2c status register(offset address 0x70) */
typedef struct _i2c_ic_status
{
uint32_t activity : 1;
uint32_t tfnf : 1;
uint32_t tfe : 1;
uint32_t rfne : 1;
uint32_t rff : 1;
uint32_t mst_activity : 1;
uint32_t slv_activity : 1;
uint32_t mst_hold_tx_fifo_empty : 1;
uint32_t mst_hold_rx_fifo_full : 1;
uint32_t slv_hold_tx_fifo_empty : 1;
uint32_t slv_hold_rx_fifo_full : 1;
uint32_t sda_stuck_not_recovered : 1;
uint32_t rsvd_1 : 4; /* reserved */
uint32_t smbus_quick_cmd_bit : 1;
uint32_t smbus_slave_addr_valid : 1;
uint32_t smbus_slave_addr_resolved : 1;
uint32_t smbus_suspend_status : 1;
uint32_t smbus_alert : 1;
uint32_t rsvd_2 : 11; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_status_t;
/* i2c transmit fifo level register(offset address 0x74) */
typedef struct _i2c_ic_txflr
{
uint32_t txflr : 5;
uint32_t rsvd : 27; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_txflr_t;
/* i2c receive fifo level register(offset address 0x78) */
typedef struct _i2c_ic_rxflr
{
uint32_t rxflr : 5;
uint32_t rsvd : 27; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_rxflr_t;
/* i2c sda hold time length register(offset address 0x7c) */
typedef struct _i2c_ic_sda_hold
{
uint32_t tx_hold : 16;
uint32_t rx_hold : 8;
uint32_t rsvd : 8; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_sda_hold_t;
/* i2c transmit abort source register(offset address 0x80) */
typedef struct _i2c_ic_tx_abrt_source
{
uint32_t abrt_7b_addr_noack : 1;
uint32_t abrt_10addr1_noack : 1;
uint32_t abrt_10addr2_noack : 1;
uint32_t abrt_txdata_noack : 1;
uint32_t abrt_gcall_noack : 1;
uint32_t abrt_gcall_read : 1;
uint32_t abrt_hs_ackdet : 1;
uint32_t abrt_sbyte_ackdet : 1;
uint32_t abrt_hs_norstrt : 1;
uint32_t abrt_sbyte_norstrt : 1;
uint32_t abrt_10b_rd_norstrt : 1;
uint32_t abrt_master_dis : 1;
uint32_t abrt_lost : 1;
uint32_t abrt_slvflush_txfifo : 1;
uint32_t abrt_slv_arblost : 1;
uint32_t abrt_slvrd_intx : 1;
uint32_t abrt_user_abrt : 1;
uint32_t abrt_sda_stuck_at_low : 1;
uint32_t abrt_device_noack : 1;
uint32_t abrt_device_slvaddr_noack : 1;
uint32_t abrt_device_write : 1;
uint32_t rsvd : 2; /* reserved */
uint32_t tx_flush_cnt : 9;
} __attribute__((packed, aligned(4))) i2c_ic_tx_abrt_source_t;
/* i2c generate slave data nack register(offset address 0x84) */
typedef struct _i2c_ic_slv_data_nack_only
{
uint32_t nack : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_slv_data_nack_only_t;
/* i2c dma control register(offset address 0x88) */
typedef struct _i2c_ic_dma_cr
{
uint32_t rdmae : 1;
uint32_t tdmae : 1;
uint32_t rsvd : 30; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_dma_cr_t;
/* i2c dma transmit data level register(offset address 0x8c) */
typedef struct _i2c_ic_dma_tdlr
{
uint32_t dmatdl : 5;
uint32_t rsvd : 27; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_dma_tdlr_t;
/* i2c dma receive data level register(offset address 0x90) */
typedef struct _i2c_ic_dma_rdlr
{
uint32_t dmardl : 5;
uint32_t rsvd : 27; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_dma_rdlr_t;
/* i2c sda setup register(offset address 0x94) */
typedef struct _i2c_ic_sda_setup
{
uint32_t setup : 8;
uint32_t rsvd : 24; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_sda_setup_t;
/* i2c ack general call register(offset address 0x98) */
typedef struct _i2c_ic_ack_general_call
{
uint32_t ask : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_ack_general_call_t;
/* i2c enable status register(offset address 0x9c) */
typedef struct _i2c_ic_enable_status
{
uint32_t en : 1;
uint32_t slv_disabled_while_busy : 1;
uint32_t slv_rx_data_lost : 1;
uint32_t rsvd : 29; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_enable_status_t;
/* i2c ss, fs, or fm+/ufm spike suppression limit register(offset address 0xa0) */
typedef struct _i2c_ic_fs_ufm_spklen
{
uint32_t spklen : 8;
uint32_t rsvd : 24; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_fs_ufm_spklen_t;
/* i2c hs spike suppression limit register(offset address 0xa4) */
typedef struct _i2c_ic_hs_spklen
{
uint32_t spklen : 8;
uint32_t rsvd : 24; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_hs_spklen_t;
/* i2c clear restart det interrupt register(offset address 0xa8) */
typedef struct _i2c_ic_clr_restart_det
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_restart_det_t;
/* i2c scl stuck at low timeout register(offset address 0xac) */
typedef struct _i2c_ic_scl_stuck_at_low_timeout
{
uint32_t timeout : 32;
} __attribute__((packed, aligned(4))) i2c_ic_scl_stuck_at_low_timeout_t;
/* i2c sda stuck at low timeout register(offset address 0xb0) */
typedef struct _i2c_ic_sda_stuck_at_low_timeout
{
uint32_t timeout : 32;
} __attribute__((packed, aligned(4))) i2c_ic_sda_stuck_at_low_timeout_t;
/* i2c clear scl stuck at low detect interrupt register(offset address 0xb4) */
typedef struct _i2c_ic_clr_slc_stuck_det
{
uint32_t clr : 1;
uint32_t rsvd : 31; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_slc_stuck_det_t;
/* i2c device id register(offset address 0xb8) */
typedef struct _i2c_ic_device_id
{
uint32_t device_id : 24;
uint32_t rsvd : 8; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_device_id_t;
/* i2c smbus slave clock extend timeout register(offset address 0xbc) */
typedef struct _i2c_ic_smbus_clk_low_sext
{
uint32_t timeout : 32;
} __attribute__((packed, aligned(4))) i2c_ic_smbus_clk_low_sext_t;
/* i2c smbus master clock extend timeout register(offset address 0xc0) */
typedef struct _i2c_ic_smbus_clk_low_mext
{
uint32_t timeout : 32;
} __attribute__((packed, aligned(4))) i2c_ic_smbus_clk_low_mext_t;
/* i2c smbus master thigh max bus-idle count register(offset address 0xc4) */
typedef struct _i2c_ic_smbus_thigh_max_idle_count
{
uint32_t cnt : 16;
uint32_t rsvd : 16; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_smbus_thigh_max_idle_count_t;
/* i2c smbus interrupt status register(offset address 0xc8) */
typedef struct _i2c_ic_smbus_intr_stat
{
uint32_t r_slv_clock_extnd_timeout : 1;
uint32_t r_mst_clock_extnd_timeout : 1;
uint32_t r_quick_cmd_det : 1;
uint32_t r_host_notify_mst_det : 1;
uint32_t r_arp_prepare_cmd_det : 1;
uint32_t r_arp_rst_cmd_det : 1;
uint32_t r_arp_get_udid_cmd_det : 1;
uint32_t r_arp_assgn_addr_cmd_det : 1;
uint32_t r_slv_rx_pec_nack : 1;
uint32_t r_smbus_suspend_det : 1;
uint32_t r_smbus_alert_det : 1;
uint32_t rsvd : 21; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_smbus_intr_stat_t;
/* i2c smbus interrupt mask register(offset address 0xcc) */
typedef struct _i2c_ic_smbus_intr_mask
{
uint32_t m_slv_clock_extnd_timeout : 1;
uint32_t m_mst_clock_extnd_timeout : 1;
uint32_t m_quick_cmd_det : 1;
uint32_t m_host_notify_mst_det : 1;
uint32_t m_arp_prepare_cmd_det : 1;
uint32_t m_arp_rst_cmd_det : 1;
uint32_t m_arp_get_udid_cmd_det : 1;
uint32_t m_arp_assgn_addr_cmd_det : 1;
uint32_t m_slv_rx_pec_nack : 1;
uint32_t m_smbus_suspend_det : 1;
uint32_t m_smbus_alert_det : 1;
uint32_t rsvd : 21; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_smbus_intr_mask_t;
/* i2c smbus raw interrupt status register(offset address 0xd0) */
typedef struct _i2c_ic_smbus_raw_intr_stat
{
uint32_t slv_clock_extnd_timeout : 1;
uint32_t mst_clock_extnd_timeout : 1;
uint32_t quick_cmd_det : 1;
uint32_t host_notify_mst_det : 1;
uint32_t arp_prepare_cmd_det : 1;
uint32_t arp_rst_cmd_det : 1;
uint32_t arp_get_udid_cmd_det : 1;
uint32_t arp_assgn_addr_cmd_det : 1;
uint32_t slv_rx_pec_nack : 1;
uint32_t smbus_suspend_det : 1;
uint32_t smbus_alert_det : 1;
uint32_t rsvd : 21; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_smbus_raw_intr_stat_t;
/* i2c smbus clear interrupt register(offset address 0xd4) */
typedef struct _i2c_ic_clr_smbus_intr
{
uint32_t slv_clock_extnd_timeout : 1;
uint32_t mst_clock_extnd_timeout : 1;
uint32_t quick_cmd_det : 1;
uint32_t host_notify_mst_det : 1;
uint32_t arp_prepare_cmd_det : 1;
uint32_t arp_rst_cmd_det : 1;
uint32_t arp_get_udid_cmd_det : 1;
uint32_t arp_assgn_addr_cmd_det : 1;
uint32_t slv_rx_pec_nack : 1;
uint32_t smbus_suspend_det : 1;
uint32_t smbus_alert_det : 1;
uint32_t rsvd : 21; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_clr_smbus_intr_t;
/* i2c optional slave address register(offset address 0xd8) */
typedef struct _i2c_ic_optional_sar
{
uint32_t sar : 7;
uint32_t rsvd : 25; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_optional_sar_t;
/* i2c smbus udid lsb register(offset address 0xdc) */
typedef struct _i2c_ic_smbus_udid_lsb
{
uint32_t udid_lsb : 32;
} __attribute__((packed, aligned(4))) i2c_ic_smbus_udid_lsb_t;
/* i2c component parameter 1 register(offset address 0xf4) */
typedef struct _i2c_ic_comp_param_1
{
uint32_t apb_data_width : 2;
uint32_t max_speed_mode : 2;
uint32_t hc_count_values : 1;
uint32_t intr_io : 1;
uint32_t has_dma : 1;
uint32_t add_encoded_params : 1;
uint32_t rx_buffer_depth : 8;
uint32_t tx_buffer_depth : 8;
uint32_t rsvd : 8; /* reserved */
} __attribute__((packed, aligned(4))) i2c_ic_comp_param_1_t;
/* i2c component version register(offset address 0xf8) */
typedef struct _i2c_ic_comp_version
{
uint32_t version : 32;
} __attribute__((packed, aligned(4))) i2c_ic_comp_version_t;
/* i2c component type register(offset address 0xfc) */
typedef struct _i2c_ic_comp_type
{
uint32_t type : 32;
} __attribute__((packed, aligned(4))) i2c_ic_comp_type_t;
/* i2c register */
typedef struct _i2c
{
i2c_ic_con_t con; /* 0x00 */
i2c_ic_tar_t tar; /* 0x04 */
i2c_ic_sar_t sar; /* 0x08 */
i2c_ic_hs_maddr_t hs_maddr; /* 0x0c */
i2c_ic_data_cmd_t data_cmd; /* 0x10 */
i2c_ic_ss_ufm_scl_hcnt_t ss_ufm_scl_hcnt; /* 0x14 */
i2c_ic_ss_ufm_scl_lcnt_t ss_ufm_scl_lcnt; /* 0x18 */
i2c_ic_fs_scl_hcnt_ufm_tbuf_cnt_t fs_scl_hcnt_ufm_tbuf_cnt; /* 0x1c */
i2c_ic_fs_scl_lcnt_t fs_scl_lcnt; /* 0x20 */
i2c_ic_hs_scl_hcnt_t hs_scl_hcnt; /* 0x24 */
i2c_ic_hs_scl_lcnt_t hs_scl_lcnt; /* 0x28 */
i2c_ic_intr_stat_t intr_stat; /* 0x2c */
i2c_ic_intr_mask_t intr_mask; /* 0x30 */
i2c_ic_raw_intr_stat_t raw_intr_stat; /* 0x34 */
i2c_ic_rx_tl_t rx_tl; /* 0x38 */
i2c_ic_tx_tl_t tx_tl; /* 0x3c */
i2c_ic_clr_intr_t clr_intr; /* 0x40 */
i2c_ic_clr_rx_under_t clr_rx_under; /* 0x44 */
i2c_ic_clr_rx_over_t clr_rx_over; /* 0x48 */
i2c_ic_clr_tx_over_t clr_tx_over; /* 0x4c */
i2c_ic_clr_rd_req_t clr_rd_req; /* 0x50 */
i2c_ic_clr_tx_abrt_t clr_tx_abrt; /* 0x54 */
i2c_ic_clr_rx_done_t clr_rx_done; /* 0x58 */
i2c_ic_clr_activity_t clr_activity; /* 0x5c */
i2c_ic_clr_stop_det_t clr_stop_det; /* 0x60 */
i2c_ic_clr_start_det_t clr_start_det; /* 0x64 */
i2c_ic_clr_gen_call_t clr_gen_call; /* 0x68 */
i2c_ic_enable_t enable; /* 0x6c */
i2c_ic_status_t status; /* 0x70 */
i2c_ic_txflr_t txflr; /* 0x74 */
i2c_ic_rxflr_t rxflr; /* 0x78 */
i2c_ic_sda_hold_t sda_hold; /* 0x7c */
i2c_ic_tx_abrt_source_t tx_abrt_source; /* 0x80 */
i2c_ic_slv_data_nack_only_t slv_data_nack_only; /* 0x84 */
i2c_ic_dma_cr_t dma_cr; /* 0x88 */
i2c_ic_dma_tdlr_t dma_tdlr; /* 0x8c */
i2c_ic_dma_rdlr_t dma_rdlr; /* 0x90 */
i2c_ic_sda_setup_t sda_setup; /* 0x94 */
i2c_ic_ack_general_call_t ack_general_call; /* 0x98 */
i2c_ic_enable_status_t enable_status; /* 0x9c */
i2c_ic_fs_ufm_spklen_t fs_ufm_spklen; /* 0xa0 */
i2c_ic_hs_spklen_t hs_spklen; /* 0xa4 */
i2c_ic_clr_restart_det_t clr_restart_det; /* 0xa8 */
i2c_ic_scl_stuck_at_low_timeout_t scl_stuck_at_low_timeout; /* 0xac */
i2c_ic_sda_stuck_at_low_timeout_t sda_stuck_at_low_timeout; /* 0xb0 */
i2c_ic_clr_slc_stuck_det_t clr_slc_stuck_det; /* 0xb4 */
i2c_ic_device_id_t device_id; /* 0xb8 */
i2c_ic_smbus_clk_low_sext_t smbus_clk_low_sext; /* 0xbc */
i2c_ic_smbus_clk_low_mext_t smbus_clk_low_mext; /* 0xc0 */
i2c_ic_smbus_thigh_max_idle_count_t smbus_thigh_max_idle_count; /* 0xc4 */
i2c_ic_smbus_intr_stat_t smbus_intr_stat; /* 0xc8 */
i2c_ic_smbus_intr_mask_t smbus_intr_mask; /* 0xcc */
i2c_ic_smbus_raw_intr_stat_t smbus_raw_intr_stat; /* 0xd0 */
i2c_ic_clr_smbus_intr_t clr_smbus_intr; /* 0xd4 */
i2c_ic_optional_sar_t optional_sar; /* 0xd8 */
i2c_ic_smbus_udid_lsb_t smbus_udid_lsb; /* 0xdc */
uint32_t rsvd_1[5]; /* 0xe0-0xf0 reserved */
i2c_ic_comp_param_1_t comp_param_1; /* 0xf4 */
i2c_ic_comp_version_t comp_version; /* 0xf8 */
i2c_ic_comp_type_t comp_type; /* 0xfc */
} __attribute__((packed, aligned(4))) i2c_t;
#endif /* __DRV_I2C_H__ */

View File

@@ -29,7 +29,10 @@ if GetDepend('BSP_UTEST_DRIVERS'):
if GetDepend('BSP_USING_RTC'):
src += ['test_rtc.c']
if GetDepend('BSP_USING_I2C'):
src += ['test_i2c.c']
group = DefineGroup('utestcases', src, depend = [''])
Return('group')

View File

@@ -0,0 +1,204 @@
/* Copyright (c) 2023, Canaan Bright Sight Co., Ltd
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <utest.h>
#include <string.h>
#include "drv_i2c.h"
#include "drv_pinctrl.h"
#include "drv_gpio.h"
/*
* 测试K230 I2C的主从机通信在这里采用I2C0作为测试对象
*
* 硬件平台:
* 测试的硬件平台为庐山派开发板使用的I2C0引脚是GPIO048(SCL)
* 和GPIO049(SDA)。
*
* 测试说明:
* 1. 测试I2C0主机模式
* 主机模式下主机向从机发送16字节数据不包括写读地址
* 然后再读取回来进行校验共执行两次分别是400kHz和1MHz速率。
* 注使用的从机为AT24C08 EEPROM设备地址为0x50。
*/
#define I2C_NAME "i2c0"
#define TARGET_ADDR 0x50
#define TEST_BUFFER_SIZE 16
#define I2C_SCL_PIN 48
#define I2C_SDA_PIN 49
#define I2C_SCL_PIN_AF IOMUX_FUNC4
#define I2C_SDA_PIN_AF IOMUX_FUNC4
static void test_i2c0_deinit_pin(void)
{
k230_pinctrl_set_function(I2C_SCL_PIN, IOMUX_FUNC1);
k230_pinctrl_set_function(I2C_SDA_PIN, IOMUX_FUNC1);
k230_pinctrl_set_oe(I2C_SCL_PIN, 0);
k230_pinctrl_set_oe(I2C_SDA_PIN, 0);
k230_pinctrl_set_ie(I2C_SCL_PIN, 1);
k230_pinctrl_set_ie(I2C_SDA_PIN, 1);
kd_pin_mode(I2C_SCL_PIN, GPIO_DM_INPUT);
kd_pin_mode(I2C_SDA_PIN, GPIO_DM_INPUT);
}
static void test_i2c0_init_pin(void)
{
k230_pinctrl_set_function(I2C_SCL_PIN, I2C_SCL_PIN_AF); // I2C0_SCL
k230_pinctrl_set_function(I2C_SDA_PIN, I2C_SDA_PIN_AF); // I2C0_SDA
k230_pinctrl_set_oe(I2C_SCL_PIN, 1);
k230_pinctrl_set_oe(I2C_SDA_PIN, 1);
k230_pinctrl_set_ie(I2C_SCL_PIN, 1);
k230_pinctrl_set_ie(I2C_SDA_PIN, 1);
}
static int test_i2c_check_pin(void)
{
test_i2c0_deinit_pin();
if(kd_pin_read(I2C_SCL_PIN) != 1 || kd_pin_read(I2C_SDA_PIN) != 1)
{
LOG_W("i2c bus is not idle, try to recover it.");
k230_pinctrl_set_oe(I2C_SCL_PIN, 1);
kd_pin_mode(I2C_SCL_PIN, GPIO_DM_OUTPUT);
for(rt_uint8_t i = 0; i < 9; i++)
{
kd_pin_write(I2C_SCL_PIN, 0);
rt_hw_us_delay(2);
kd_pin_write(I2C_SCL_PIN, 1);
rt_hw_us_delay(2);
}
k230_pinctrl_set_oe(I2C_SCL_PIN, 0);
kd_pin_mode(I2C_SCL_PIN, GPIO_DM_INPUT);
}
if(kd_pin_read(I2C_SCL_PIN) != 1 || kd_pin_read(I2C_SDA_PIN) != 1)
{
LOG_E("i2c bus recover failed");
return -RT_ERROR;
}
LOG_I("i2c bus(pin: %u, %u) is idle, init i2c bus pin", I2C_SCL_PIN, I2C_SDA_PIN);
test_i2c0_init_pin();
return RT_EOK;
}
static void _test_i2c0_master(rt_uint8_t *buffer_w, rt_uint8_t *buffer_r, rt_uint32_t size, rt_uint32_t speed)
{
rt_err_t ret = RT_EOK;
struct rt_i2c_bus_device *dev;
struct rt_i2c_msg msgs[2];
dev = rt_i2c_bus_device_find(I2C_NAME);
uassert_not_null(dev);
rt_i2c_control(dev, RT_I2C_DEV_CTRL_CLK, (void *)&speed);
msgs[0].addr = TARGET_ADDR;
msgs[0].flags = RT_I2C_WR;
msgs[0].buf = buffer_w;
msgs[0].len = size + 1;
if(rt_i2c_transfer(dev, msgs, 1) != 1)
{
LOG_E("i2c transfer failed");
uassert_true(0);
}
rt_thread_mdelay(10);
msgs[0].addr = TARGET_ADDR;
msgs[0].flags = RT_I2C_WR | RT_I2C_NO_STOP;
msgs[0].buf = &buffer_r[0];
msgs[0].len = 1;
msgs[1].addr = TARGET_ADDR;
msgs[1].flags = RT_I2C_RD | RT_I2C_NO_START;
msgs[1].buf = &buffer_r[1];
msgs[1].len = size;
if(rt_i2c_transfer(dev, msgs, 2) != 2)
{
LOG_E("i2c transfer failed");
uassert_true(0);
}
LOG_I("Read data:\n");
for(rt_uint8_t i = 1; i < size + 1; i++)
{
LOG_I("0x%02X ", buffer_r[i]);
}
uassert_buf_equal(buffer_w + 1, buffer_r + 1, size);
}
static void test_i2c0_master(void)
{
rt_uint8_t buffer_w[TEST_BUFFER_SIZE + 1];
rt_uint8_t buffer_r[TEST_BUFFER_SIZE + 1];
rt_uint32_t size = TEST_BUFFER_SIZE;
rt_uint32_t speed = 400000; // 400kHz
memset(buffer_w + 1, 0xAA, TEST_BUFFER_SIZE);
buffer_w[0] = 0x00; // memory address
memset(buffer_r, 0x00, TEST_BUFFER_SIZE + 1);
_test_i2c0_master(buffer_w, buffer_r, size, speed);
speed = 1000000; // 1MHz
memset(buffer_w + 1, 0x55, TEST_BUFFER_SIZE);
buffer_w[0] = 0x00; // memory address
memset(buffer_r, 0x00, TEST_BUFFER_SIZE + 1);
_test_i2c0_master(buffer_w, buffer_r, size, speed);
}
static void testcase(void)
{
LOG_I("This is a i2c test case.\n");
UTEST_UNIT_RUN(test_i2c0_master);
}
static rt_err_t utest_tc_init(void)
{
return test_i2c_check_pin();
}
static rt_err_t utest_tc_cleanup(void)
{
LOG_I("i2c bus pin deinit.\n");
test_i2c0_deinit_pin();
return RT_EOK;
}
UTEST_TC_EXPORT(testcase, "bsp.k230.drivers.i2c", utest_tc_init, utest_tc_cleanup, 100);

View File

@@ -276,6 +276,7 @@
#define RT_USING_SAL
#define SAL_INTERNET_CHECK
#define SOCKET_TABLE_STEP_LEN 4
/* Docking with protocol stacks */

View File

@@ -10,6 +10,8 @@
#ifndef CHERRYUSB_CONFIG_H
#define CHERRYUSB_CONFIG_H
#include <rtthread.h>
/* ================ USB common Configuration ================ */
#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)

View File

@@ -1,11 +1,4 @@
# .clang-format-ignore File Description:
# ----------------------------------------------------------------------------------------
# 1. Used to specify which files or directories should be skipped by the clang-format tool.
# 2. Follows syntax rules similar to .gitignore.
# 3. Supports wildcard patterns and path matching.
# 4. clang-format will recursively apply the .clang-format-ignore rules.
# Renesas Vendor library
**/ra/
**/ra_cfg/
**/ra_gen/
# clang-format ignore file
/**/ra/
/**/ra_cfg/
/**/ra_gen/

View File

@@ -1,6 +0,0 @@
# files format check exclude path, please follow the instructions below to modify;
# If you need to exclude an entire folder, add the folder path in dir_path;
# If you need to exclude a file, add the path to the file in file_path.
dir_path:
- bsp-template

View File

@@ -1,42 +0,0 @@
/*
* Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-08-17 CYFS first version
*/
#ifndef __ADC_CONFIG_H__
#define __ADC_CONFIG_H__
#include <rtthread.h>
#include <rtdevice.h>
#include "hal_data.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BSP_USING_ADC0) || defined(BSP_USING_ADC1)
struct rt_adc_dev
{
struct rt_adc_ops ops;
struct rt_adc_device adc_device;
};
struct ra_adc_map
{
const char *device_name;
const adc_cfg_t *g_cfg;
const adc_ctrl_t *g_ctrl;
const adc_channel_cfg_t *g_channel_cfg;
};
#endif
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -1,48 +0,0 @@
/*
* Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-08-17 CYFS first version
*/
#ifndef __CAN_CONFIG_H__
#define __CAN_CONFIG_H__
#include <rtthread.h>
#include "hal_data.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(BSP_USING_CAN0)
#ifndef CAN0_CONFIG
#define CAN0_CONFIG \
{ \
.name = "can0", \
.num_of_mailboxs = CAN_NO_OF_MAILBOXES_g_can0, \
.p_api_ctrl = &g_can0_ctrl, \
.p_cfg = &g_can0_cfg, \
}
#endif /* CAN0_CONFIG */
#endif /* BSP_USING_CAN0 */
#if defined(BSP_USING_CAN1)
#ifndef CAN1_CONFIG
#define CAN1_CONFIG \
{ \
.name = "can1", \
.num_of_mailboxs = CAN_NO_OF_MAILBOXES_g_can1, \
.p_api_ctrl = &g_can1_ctrl, \
.p_cfg = &g_can1_cfg, \
}
#endif /* CAN1_CONFIG */
#endif /* BSP_USING_CAN1 */
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,41 +0,0 @@
/*
* Copyright (c) 2006-2025, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2025-08-17 CYFS first version
*/
#ifndef __DAC_CONFIG_H__
#define __DAC_CONFIG_H__
#include <rtthread.h>
#include <rtdevice.h>
#include "hal_data.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef BSP_USING_DAC
struct ra_dac_map
{
char name;
const struct st_dac_cfg *g_cfg;
const struct st_dac_instance_ctrl *g_ctrl;
};
struct ra_dac_dev
{
rt_dac_device_t ra_dac_device_t;
struct ra_dac_map *ra_dac_map_dev;
};
#endif
#endif
#ifdef __cplusplus
}
#endif

Some files were not shown because too many files have changed in this diff Show More