Skip to content

Commit df1c633

Browse files
committed
Update.
1 parent 9e6a3b8 commit df1c633

File tree

26 files changed

+657
-23
lines changed

26 files changed

+657
-23
lines changed

docs/code_gen/stm32/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ xr_cubemx_cfg -d .
3434
[INFO] LibXR submodule already exists. Checking for updates...
3535
[INFO] [OK] cd . && git submodule update --init --recursive
3636
[INFO] LibXR submodule updated.
37-
Found .ioc file: .\atom.ioc
37+
Found .ioc file: ./atom.ioc
3838
Parsing .ioc file...
39-
[INFO] [OK] xr_parse_ioc -d . -o .\.config.yaml
39+
[INFO] [OK] xr_parse_ioc -d . -o ./.config.yaml
4040
Generating C++ code...
41-
[INFO] [OK] xr_gen_code_stm32 -i .\.config.yaml -o .\User\app_main.cpp
41+
[INFO] [OK] xr_gen_code_stm32 -i ./.config.yaml -o ./User/app_main.cpp
4242
Modifying STM32 interrupt files...
43-
[INFO] [OK] xr_stm32_it .\Core/Src
43+
[INFO] [OK] xr_stm32_it ./Core/Src
4444
[INFO] [OK] xr_stm32_cmake .
4545
[INFO] [Pass] All tasks completed successfully!
4646
```
@@ -62,7 +62,7 @@ Modifying STM32 interrupt files...
6262
├── Core/Src/stm32f1xx_it.c # 补丁后的中断处理函数
6363
├── cmake/LibXR.CMake # LibXR 构建配置
6464
├── CMakeLists.txt # 自动集成 LibXR
65-
└── Middlewares\Third_Party\LibXR # Git 子模块:LibXR 本体
65+
└── Middlewares/Third_Party/LibXR # Git 子模块:LibXR 本体
6666
```
6767

6868
---

docs/code_gen/stm32/adc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ ADC:
4343
可直接修改该文件。如需应用更新配置,请执行以下任一命令以重新生成代码:
4444
`xr_cubemx_cfg -d .`
4545
46-
`xr_gen_code_stm32 -i .\.config.yaml -o .\User\app_main.cpp`
46+
`xr_gen_code_stm32 -i ./.config.yaml -o ./User/app_main.cpp`

docs/code_gen/stm32/can.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ FDCAN:
3636
可直接修改该配置文件。如需应用更改,请执行以下命令重新生成代码:
3737
`xr_cubemx_cfg -d .`
3838
39-
`xr_gen_code_stm32 -i .\.config.yaml -o .\User\app_main.cpp`
39+
`xr_gen_code_stm32 -i ./.config.yaml -o ./User/app_main.cpp`

docs/code_gen/stm32/i2c.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ I2C:
3333
可直接修改该文件。如需应用更新配置,请执行以下任一命令以重新生成代码:
3434
`xr_cubemx_cfg -d .`
3535
36-
`xr_gen_code_stm32 -i .\.config.yaml -o .\User\app_main.cpp`
36+
`xr_gen_code_stm32 -i ./.config.yaml -o ./User/app_main.cpp`

docs/code_gen/stm32/spi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ SPI:
3131
可直接修改该文件。如需应用更新配置,请执行以下任一命令以重新生成代码:
3232
`xr_cubemx_cfg -d .`
3333
34-
`xr_gen_code_stm32 -i .\.config.yaml -o .\User\app_main.cpp`
34+
`xr_gen_code_stm32 -i ./.config.yaml -o ./User/app_main.cpp`

docs/code_gen/stm32/timer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ PlatformInit(2, 512);
4242

4343
## 配置文件
4444

45-
对于非裸机环境,会在`User\libxr_config.yaml`中生成如下配置:
45+
对于非裸机环境,会在`User/libxr_config.yaml`中生成如下配置:
4646

4747
```yaml
4848
software_timer:
@@ -53,4 +53,4 @@ software_timer:
5353
可直接修改该文件。如需应用更新配置,请执行以下任一命令以重新生成代码:
5454
`xr_cubemx_cfg -d .`
5555
56-
`xr_gen_code_stm32 -i .\.config.yaml -o .\User\app_main.cpp`
56+
`xr_gen_code_stm32 -i ./.config.yaml -o ./User/app_main.cpp`

docs/code_gen/stm32/uart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ USB:
6464
可直接修改该文件。如需应用更新配置,请执行以下任一命令以重新生成代码:
6565
`xr_cubemx_cfg -d .`
6666
67-
`xr_gen_code_stm32 -i .\.config.yaml -o .\User\app_main.cpp`
67+
`xr_gen_code_stm32 -i ./.config.yaml -o ./User/app_main.cpp`

docs/code_gen/xrobot_inter.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
id: code-gen-xrobot-inter
3+
title: 与XRobot集成
4+
sidebar_position: 2
5+
---
6+
7+
# 与XRobot集成
8+
9+
在代码生成时加入`--xrobot`选项,可以生成对应的硬件容器(LibXR::HardwareContainer)以供XRobot初始化。
10+
11+
## 示例
12+
13+
```bash
14+
xr_gen_code_stm32 -i .\.config.yaml -o .\User\app_main.cpp --xrobot
15+
[INFO] Detected FreeRTOS configuration
16+
[INFO] FlashLayout is generated and injected, MCU: STM32G431KBU6
17+
[INFO] Flash layout map written to: .\User\flash_map.hpp
18+
[INFO] Successfully generated: .\User
19+
[INFO] Generated header file: app_main.h
20+
```
21+
22+
会在app_main.cpp中额外生成以下代码:
23+
24+
```cpp
25+
LibXR::HardwareContainer<
26+
LibXR::Entry<LibXR::PowerManager>,
27+
...
28+
> peripherals{
29+
LibXR::Entry<LibXR::PowerManager>(power_manager)
30+
...
31+
};
32+
33+
XRobotMain(peripherals);
34+
```
35+
36+
同时在libxr_config.yaml中添加外设别名,上层代码可依靠这些别名访问外设:
37+
38+
```yaml
39+
device_aliases:
40+
power_manager:
41+
type: PowerManager
42+
aliases:
43+
- power_manager
44+
LED:
45+
type: GPIO
46+
aliases:
47+
- LED
48+
- led_red
49+
...
50+
```

docs/proj_man/add_mod.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
id: proj-man-add-mod
3+
title: 添加模块
4+
sidebar_position: 4
5+
---
6+
7+
# 添加模块
8+
9+
通过`xrobot_add_mod`工具可以快速添加一个新模块到仓库,或者从仓库中选择一个模块创建实例。
10+
11+
## 使用方法
12+
13+
### 添加远程模块到仓库
14+
15+
--version可以省略,使用时要确保对应分支存在。
16+
17+
```bash
18+
$ xrobot_add_mod https://github.com/yourorg/BlinkLED.git --version main
19+
[SUCCESS] Added repo module 'BlinkLED' to Modules/modules.yaml
20+
```
21+
22+
然后拉取模块:
23+
24+
```bash
25+
$ xrobot_init_mod
26+
[INFO] Cloning new module: BlinkLED
27+
Cloning into 'Modules/BlinkLED'...
28+
remote: Enumerating objects: 22, done.
29+
remote: Counting objects: 100% (22/22), done.
30+
remote: Compressing objects: 100% (15/15), done.
31+
remote: Total 22 (delta 7), reused 22 (delta 7), pack-reused 0 (from 0)
32+
Receiving objects: 100% (22/22), done.
33+
Resolving deltas: 100% (7/7), done.
34+
[SUCCESS] All modules processed
35+
```
36+
37+
### 创建模块实例
38+
39+
```bash
40+
$ xrobot_add_mod BlinkLED
41+
[SUCCESS] Appended module instance 'BlinkLED' to User/xrobot.yaml
42+
43+
# 重新生成代码
44+
$ xrobot_gen_main
45+
...
46+
```

docs/proj_man/create_mod.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
id: proj-man-create-mod
3+
title: 快速创建模块
4+
sidebar_position: 3
5+
---
6+
7+
XRobot 提供了快速创建模块的工具 `xrobot_create_mod`,可以从模板中快速创建一个新模块,用于快速开发模块,无需手动创建模块仓库和模块头文件。
8+
9+
## 使用方法
10+
11+
```bash
12+
$ xrobot_create_mod MySensor --desc "IMU interface module" --hw imu scl sda
13+
[OK] Module MySensor generated at Modules/MySensor
14+
```
15+
16+
通过xrobot_mod_parser查看模块信息:
17+
18+
```bash
19+
$ xrobot_mod_parser --path ./Modules/MySensor/
20+
21+
=== Module: MySensor ===
22+
Description : IMU interface module
23+
24+
Constructor Args :
25+
- name = your_arg_name_here
26+
27+
Required Hardware : imu scl sda
28+
```
29+
30+
模块的目录结构如下:
31+
32+
```bash
33+
Modules/
34+
└── BlinkLED/
35+
├── BlinkLED.hpp # 带 manifest 的头文件
36+
├── README.md # 模块文档
37+
└── CMakeLists.txt # 构建配置
38+
```
39+
40+
标准的MANIFEST(模块信息)格式如下:
41+
42+
```yaml
43+
// clang-format off
44+
/* === MODULE MANIFEST ===
45+
module_name: BlinkLED
46+
module_description: 控制 LED 闪烁的简单模块 / A simple module to control LED blinking
47+
constructor_args:
48+
- blink_cycle: 250
49+
required_hardware: led/LED/led1/LED1
50+
repository: https://github.com/xrobot-org/BlinkLED
51+
=== END MANIFEST === */
52+
// clang-format on
53+
```

0 commit comments

Comments
 (0)