Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5567c7412d | |||
| fbe76bbdd5 | |||
| b0aa9ffc96 | |||
| 6fbe09eec9 | |||
| be80b9dcb1 | |||
| 5e9b140db8 | |||
| edfcc0991c | |||
| aceacbdba1 | |||
| b107a3169c | |||
| 495fbe4298 | |||
| a0b27d34a0 | |||
| 31a3da48fa | |||
| efb88ea367 | |||
| c5b2bdd2d2 | |||
| d5b2506269 | |||
| 6f4ba247a4 | |||
| ac04bfc923 | |||
| da0f8ef72c | |||
| 9fd748c512 | |||
| fd1fae8ad7 | |||
| 1ef1ba9490 | |||
| 81594c6520 | |||
| 1808f9916f | |||
| 14a532290d | |||
| e5fffaccdf | |||
| 0f4f89eae4 | |||
| 105aafbaf7 | |||
| 3b6f52de63 | |||
| 0abda47013 | |||
| 9efa2cdc59 | |||
| 68c64959c7 | |||
| 7ee96bc08d | |||
| 4996b451d9 | |||
| d5803ca7dd | |||
| eb57a564ef |
@@ -0,0 +1,174 @@
|
|||||||
|
# TCP2UART Debug Handoff
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This log records the debugging work completed so far for:
|
||||||
|
|
||||||
|
- UART1 config/debug path on `COM9`
|
||||||
|
- UART2/UART3 transparent UART paths on `COM8`/`COM7`
|
||||||
|
- CH390 and lwIP bring-up status
|
||||||
|
|
||||||
|
The goal is to preserve the usable conclusions and avoid repeating invalid test paths after context cleanup.
|
||||||
|
|
||||||
|
## Final State Summary
|
||||||
|
|
||||||
|
### Confirmed working
|
||||||
|
|
||||||
|
- HSE clock path is working on the current board/chip/crystal combination.
|
||||||
|
- ST-Link + RTT debugging works.
|
||||||
|
- Firmware boots and RTT shows stable startup output.
|
||||||
|
- UART2 and UART3 TX paths were validated earlier by host-side observation:
|
||||||
|
- `COM8` receives UART2 debug output.
|
||||||
|
- `COM7` receives UART3 debug output.
|
||||||
|
- UART1 config path is working in the current cleaned firmware when the host sends commands with a line ending that the parser actually consumes.
|
||||||
|
- `AT+?` over UART1 was successfully validated when sent with `\n`.
|
||||||
|
|
||||||
|
### Confirmed not yet working
|
||||||
|
|
||||||
|
- CH390 is still not operating normally.
|
||||||
|
- Current one-shot RTT report still shows abnormal values:
|
||||||
|
- `CH390 VID=0x3A3A PID=0xCCCC REV=0x00 NSR=0x00 LINK=0`
|
||||||
|
- Therefore lwIP / Ethernet / TCP end-to-end validation remains blocked by CH390 low-level failure.
|
||||||
|
|
||||||
|
## Most Important Lessons Learned
|
||||||
|
|
||||||
|
### 1. UART1 config failures were partly test-method failures
|
||||||
|
|
||||||
|
Several earlier negative conclusions about UART1 config were caused by the debug method rather than firmware defects.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
- Sending `AT+?` without the line ending expected by the current parser caused false negatives.
|
||||||
|
- Frequent open/close cycles on the serial port changed timing and control-line behavior.
|
||||||
|
- Breakpoints in RX callback / parser code prevented reply transmission and created false "no response" results.
|
||||||
|
- Heavy RTT logging inside hot UART paths distorted timing and even corrupted RTT control state once.
|
||||||
|
|
||||||
|
### 2. UART1 parser expects terminators
|
||||||
|
|
||||||
|
`config_uart_rx_byte()` only dispatches a command when it sees `\r` or `\n`.
|
||||||
|
|
||||||
|
Successful command form that was confirmed:
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+?\n
|
||||||
|
```
|
||||||
|
|
||||||
|
Do not assume `AT+?` without line ending is valid for this firmware.
|
||||||
|
|
||||||
|
### 3. Cleaned firmware state is preferable for future work
|
||||||
|
|
||||||
|
Temporary UART diagnostics were removed again after debugging:
|
||||||
|
|
||||||
|
- removed boot markers like `BOOT_UARTx_OK`
|
||||||
|
- removed periodic UART spam
|
||||||
|
- removed UART1 byte echo
|
||||||
|
- removed temporary `config_diag` counters
|
||||||
|
|
||||||
|
Useful RTT remains:
|
||||||
|
|
||||||
|
- `TCP2UART boot`
|
||||||
|
- HSE fallback warning if used
|
||||||
|
- CH390 one-shot status report
|
||||||
|
|
||||||
|
## Relevant Code Changes Left In Place
|
||||||
|
|
||||||
|
These are intentional and should remain unless there is a specific reason to change them.
|
||||||
|
|
||||||
|
### UART1 config path
|
||||||
|
|
||||||
|
- `App/config.c`
|
||||||
|
- config handle is back on `huart1`
|
||||||
|
- `config_uart_rx_byte()` assembles frames from UART1 bytes
|
||||||
|
- `config_poll()` dispatches a pending complete frame to `config_try_process_frame()`
|
||||||
|
- `config_try_process_frame()` calls `config_process_at_cmd()` and transmits the response on UART1
|
||||||
|
|
||||||
|
- `Core/Src/stm32f1xx_it.c`
|
||||||
|
- `HAL_UART_RxCpltCallback()` for `huart1` feeds the received byte into `config_uart_rx_byte()` and rearms `HAL_UART_Receive_IT()`
|
||||||
|
|
||||||
|
### RTT boot diagnostics
|
||||||
|
|
||||||
|
- `Core/Src/main.c`
|
||||||
|
- retains RTT boot banner
|
||||||
|
- retains one-shot CH390 report
|
||||||
|
- no temporary UART spam remains
|
||||||
|
|
||||||
|
## Current Firmware Behavior Worth Remembering
|
||||||
|
|
||||||
|
### UART1
|
||||||
|
|
||||||
|
- UART1 is used for config/debug interaction.
|
||||||
|
- UART1 parser is line-oriented.
|
||||||
|
- Use a terminal that sends `LF` or `CRLF` explicitly.
|
||||||
|
|
||||||
|
### UART2 / UART3
|
||||||
|
|
||||||
|
- UART2 and UART3 are for bridge channels, not the config path.
|
||||||
|
- Earlier mapping observed during testing:
|
||||||
|
- `COM8` aligned with UART2 TX activity
|
||||||
|
- `COM7` aligned with UART3 TX activity
|
||||||
|
|
||||||
|
### CH390
|
||||||
|
|
||||||
|
- Still unresolved at the low level.
|
||||||
|
- Do not spend time on lwIP / TCP behavior until CH390 register reads look sane.
|
||||||
|
|
||||||
|
## Recommended Next Debug Order
|
||||||
|
|
||||||
|
### Priority 1: Preserve UART1 config as known-good
|
||||||
|
|
||||||
|
Before touching UART1 code again:
|
||||||
|
|
||||||
|
1. Open `COM9` at `115200 8N1`
|
||||||
|
2. Send:
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+?\n
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Confirm a full config dump is returned.
|
||||||
|
|
||||||
|
If this fails again, check the terminal's actual line ending first before changing code.
|
||||||
|
|
||||||
|
### Priority 2: Re-verify UART2/UART3 only if needed
|
||||||
|
|
||||||
|
If bridge debugging resumes, first confirm the host can actually open `COM7` and `COM8`.
|
||||||
|
Host-side availability was inconsistent during the previous session and caused false negatives.
|
||||||
|
|
||||||
|
### Priority 3: Resume CH390 low-level debugging
|
||||||
|
|
||||||
|
This is the real remaining blocker.
|
||||||
|
|
||||||
|
Suggested next steps:
|
||||||
|
|
||||||
|
1. Focus on SPI-level sanity before lwIP.
|
||||||
|
2. Re-check CH390 reset / CS / SPI timing and electrical path.
|
||||||
|
3. Verify whether SPI mode is correct for the actual hardware.
|
||||||
|
4. Confirm register reads from CH390 return plausible values before attempting link/TCP tests.
|
||||||
|
|
||||||
|
## What Not To Repeat
|
||||||
|
|
||||||
|
- Do not judge UART1 config by sending commands without a terminator.
|
||||||
|
- Do not leave breakpoints inside UART RX callback or parser while expecting normal replies.
|
||||||
|
- Do not flood RTT inside hot UART receive paths.
|
||||||
|
- Do not conclude lwIP is broken before CH390 identity reads are sane.
|
||||||
|
- Do not trust `Win32_SerialPort` alone for COM availability; sometimes `mode COMx` / `Get-PnpDevice -Class Ports` gives a different picture.
|
||||||
|
|
||||||
|
## Known Useful Commands
|
||||||
|
|
||||||
|
### UART1 config test
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+?\n
|
||||||
|
```
|
||||||
|
|
||||||
|
### Optional follow-ups
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+BAUD1=115200\n
|
||||||
|
AT+SAVE\n
|
||||||
|
AT+RESET\n
|
||||||
|
```
|
||||||
|
|
||||||
|
## One-Line Handoff
|
||||||
|
|
||||||
|
UART1 config is working when tested correctly with a terminator; CH390 is still the unresolved core issue and should be the next serious debug target.
|
||||||
+16
@@ -7,6 +7,7 @@
|
|||||||
*.map
|
*.map
|
||||||
*.lst
|
*.lst
|
||||||
*.out
|
*.out
|
||||||
|
*.log
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
.vscode/
|
.vscode/
|
||||||
@@ -27,6 +28,9 @@ Release/
|
|||||||
MDK-ARM/DebugConfig/
|
MDK-ARM/DebugConfig/
|
||||||
MDK-ARM/TCP2UART/
|
MDK-ARM/TCP2UART/
|
||||||
|
|
||||||
|
# CMake build
|
||||||
|
build/
|
||||||
|
|
||||||
# OS
|
# OS
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
Desktop.ini
|
Desktop.ini
|
||||||
@@ -34,3 +38,15 @@ Desktop.ini
|
|||||||
|
|
||||||
# 项目文档
|
# 项目文档
|
||||||
项目计划.md
|
项目计划.md
|
||||||
|
|
||||||
|
# Local debug handoff logs
|
||||||
|
.debug/
|
||||||
|
|
||||||
|
# Local packet captures
|
||||||
|
WiresharkLog/
|
||||||
|
|
||||||
|
# Local build/session artifacts
|
||||||
|
.embeddedskills/
|
||||||
|
uv4_stdout.txt
|
||||||
|
MDK-ARM/EventRecorderStub.scvd
|
||||||
|
MDK-ARM/build_capture.txt
|
||||||
|
|||||||
+18
-13
File diff suppressed because one or more lines are too long
+455
@@ -0,0 +1,455 @@
|
|||||||
|
# TCP2UART AT 固件使用手册
|
||||||
|
|
||||||
|
## 1. 文档范围
|
||||||
|
|
||||||
|
本文档定义 `TCP2UART` 项目的最终 AT 外部协议。
|
||||||
|
|
||||||
|
本文档只描述最终协议模型,不保留任何历史展开式实例字段,不包含测试记录,不讨论旧版兼容命令。
|
||||||
|
|
||||||
|
适用对象:
|
||||||
|
|
||||||
|
- 上位机开发人员
|
||||||
|
- 联调与测试人员
|
||||||
|
- 固件接口实现人员
|
||||||
|
|
||||||
|
## 2. 设备与接口
|
||||||
|
|
||||||
|
- 主控:`STM32F103R8T6`
|
||||||
|
- 以太网芯片:`CH390D`
|
||||||
|
- 配置口:`USART1`
|
||||||
|
- 数据口:`USART2`、`USART3`
|
||||||
|
|
||||||
|
职责划分:
|
||||||
|
|
||||||
|
- `USART1`:AT 配置口
|
||||||
|
- `USART2 / USART3`:业务数据口,可工作于普通透传或 MUX 透传模式
|
||||||
|
|
||||||
|
## 3. 最终协议模型
|
||||||
|
|
||||||
|
本项目最终控制协议由三部分组成:
|
||||||
|
|
||||||
|
1. `MUX`:全局数据承载模式开关
|
||||||
|
2. `NET`:全局静态网络配置记录
|
||||||
|
3. `LINK[ROLE]`:按角色名组织的链路配置记录(`S1/S2/C1/C2`)
|
||||||
|
|
||||||
|
约束如下:
|
||||||
|
|
||||||
|
- 设备只有一张网卡,因此本地网络参数只配置一次
|
||||||
|
- DHCP 不属于最终协议范围
|
||||||
|
- 所有 AT 文本命令必须以 `\r\n` 结尾
|
||||||
|
- 当 `DSTMASK=0x00` 时,MUX 数据口中的系统控制帧进入 AT 解析路径,其控制文本同样必须以 `\r\n` 结尾
|
||||||
|
|
||||||
|
## 4. MUX 帧格式
|
||||||
|
|
||||||
|
当 `MUX=1` 时,数据口使用如下帧格式:
|
||||||
|
|
||||||
|
```text
|
||||||
|
SYNC | LEN_H | LEN_L | SRCID | DSTMASK | PAYLOAD | TAIL
|
||||||
|
```
|
||||||
|
|
||||||
|
字段定义:
|
||||||
|
|
||||||
|
- `SYNC`:帧起始标记,建议固定为 `0x7E`
|
||||||
|
- `LEN_H / LEN_L`:`PAYLOAD` 长度,高字节在前
|
||||||
|
- `SRCID`:单字节源端点 ID
|
||||||
|
- `DSTMASK`:单字节目标端点位图
|
||||||
|
- `PAYLOAD`:负载数据
|
||||||
|
- `TAIL`:帧结束标记,建议固定为 `0x7F`
|
||||||
|
|
||||||
|
规则:
|
||||||
|
|
||||||
|
- `DSTMASK != 0x00`:业务数据帧
|
||||||
|
- `DSTMASK = 0x00`:系统控制帧
|
||||||
|
- 系统控制帧的 `PAYLOAD` 为 AT 文本,必须以 `\r\n` 结束
|
||||||
|
|
||||||
|
## 5. 统一端点编码
|
||||||
|
|
||||||
|
`UART` 与 `TCP` 逻辑实例统一进入同一套编码空间:
|
||||||
|
|
||||||
|
| 端点 | 编码 |
|
||||||
|
|------|------|
|
||||||
|
| `C1` | `0x01` |
|
||||||
|
| `C2` | `0x02` |
|
||||||
|
| `UART2` | `0x04` |
|
||||||
|
| `UART3` | `0x08` |
|
||||||
|
| `S1` | `0x10` |
|
||||||
|
| `S2` | `0x20` |
|
||||||
|
|
||||||
|
说明:
|
||||||
|
|
||||||
|
- `SRCID` 必须为单一端点值
|
||||||
|
- `DSTMASK` 可以是一个或多个端点编码按位或的结果
|
||||||
|
- `DSTMASK=0x00` 保留给系统控制帧
|
||||||
|
|
||||||
|
## 6. AT 命令总则
|
||||||
|
|
||||||
|
### 6.1 命令结尾
|
||||||
|
|
||||||
|
所有 AT 命令均必须以 `\r\n` 结尾。
|
||||||
|
|
||||||
|
例如:
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT\r\n
|
||||||
|
AT+MUX?\r\n
|
||||||
|
AT+NET=192.168.1.100,255.255.255.0,192.168.1.1,02:00:00:00:00:01\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6.2 持久化规则
|
||||||
|
|
||||||
|
参数设置成功后只写入当前运行配置,不会自动写入 Flash。
|
||||||
|
|
||||||
|
若要掉电保持,必须执行:
|
||||||
|
|
||||||
|
1. `AT+SAVE\r\n`
|
||||||
|
2. `AT+RESET\r\n`
|
||||||
|
|
||||||
|
### 6.3 响应风格
|
||||||
|
|
||||||
|
- 成功:`OK`
|
||||||
|
- 需要保存后生效时,允许追加提示文本
|
||||||
|
- 失败:`ERROR: <reason>`
|
||||||
|
|
||||||
|
## 7. 默认配置
|
||||||
|
|
||||||
|
### 7.1 MUX 默认值
|
||||||
|
|
||||||
|
```text
|
||||||
|
MUX = 0
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7.2 NET 默认值
|
||||||
|
|
||||||
|
```text
|
||||||
|
NET = 192.168.1.100,255.255.255.0,192.168.1.1,02:00:00:00:00:01
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7.3 LINK 默认值
|
||||||
|
|
||||||
|
```text
|
||||||
|
LINK:S1 = 1,8080,0.0.0.0,0,U0
|
||||||
|
LINK:S2 = 0,8081,0.0.0.0,0,U1
|
||||||
|
LINK:C1 = 1,9001,192.168.1.200,9000,U1
|
||||||
|
LINK:C2 = 0,9002,192.168.1.201,9001,U0
|
||||||
|
```
|
||||||
|
|
||||||
|
说明:
|
||||||
|
|
||||||
|
- `S1/S2/C1/C2` 为对外可见角色名
|
||||||
|
- 内部索引映射由固件管理,不对外暴露
|
||||||
|
|
||||||
|
UART 记号约定:
|
||||||
|
|
||||||
|
- `U0 = USART2`
|
||||||
|
- `U1 = USART3`
|
||||||
|
|
||||||
|
### 7.4 BAUD 默认值
|
||||||
|
|
||||||
|
```text
|
||||||
|
BAUD = U0,115200 / U1,115200
|
||||||
|
```
|
||||||
|
|
||||||
|
## 8. AT 命令定义
|
||||||
|
|
||||||
|
### 8.1 测试设备在线
|
||||||
|
|
||||||
|
命令:
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
返回:
|
||||||
|
|
||||||
|
```text
|
||||||
|
OK
|
||||||
|
```
|
||||||
|
|
||||||
|
### 8.2 查询摘要
|
||||||
|
|
||||||
|
命令:
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+?\r\n
|
||||||
|
AT+QUERY\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
推荐返回格式:
|
||||||
|
|
||||||
|
```text
|
||||||
|
+NET:IP=192.168.1.100,MASK=255.255.255.0,GW=192.168.1.1,MAC=02:00:00:00:00:01
|
||||||
|
+LINK:S1,EN=1,LPORT=8080,RIP=0.0.0.0,RPORT=0,UART=U0
|
||||||
|
+LINK:S2,EN=0,LPORT=8081,RIP=0.0.0.0,RPORT=0,UART=U1
|
||||||
|
+LINK:C1,EN=1,LPORT=9001,RIP=192.168.1.200,RPORT=9000,UART=U1
|
||||||
|
+LINK:C2,EN=0,LPORT=9002,RIP=192.168.1.201,RPORT=9001,UART=U0
|
||||||
|
+MUX:0
|
||||||
|
+MAP:UART2=0x04,UART3=0x08,C1=0x01,C2=0x02,S1=0x10,S2=0x20
|
||||||
|
+BAUD:U0=115200,U1=115200
|
||||||
|
OK
|
||||||
|
```
|
||||||
|
|
||||||
|
### 8.3 MUX 类命令
|
||||||
|
|
||||||
|
#### 设置 MUX
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+MUX=1\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
参数:
|
||||||
|
|
||||||
|
- `0`:普通透传模式
|
||||||
|
- `1`:MUX 透传模式
|
||||||
|
|
||||||
|
查询:
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+MUX?\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
返回示例:
|
||||||
|
|
||||||
|
```text
|
||||||
|
+MUX:1
|
||||||
|
OK
|
||||||
|
```
|
||||||
|
|
||||||
|
### 8.4 NET 类命令
|
||||||
|
|
||||||
|
#### 设置 NET
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+NET=192.168.1.100,255.255.255.0,192.168.1.1,02:00:00:00:00:01\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
字段顺序:
|
||||||
|
|
||||||
|
```text
|
||||||
|
IP,MASK,GW,MAC
|
||||||
|
```
|
||||||
|
|
||||||
|
查询:
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+NET?\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
返回示例:
|
||||||
|
|
||||||
|
```text
|
||||||
|
+NET:IP=192.168.1.100,MASK=255.255.255.0,GW=192.168.1.1,MAC=02:00:00:00:00:01
|
||||||
|
OK
|
||||||
|
```
|
||||||
|
|
||||||
|
**MAC 设置说明:**
|
||||||
|
|
||||||
|
当MAC设置为全0时,固件将使用硬件MAC地址,此时通过AT+?查询到的MAC地址即为当前生效的硬件MAC地址。
|
||||||
|
|
||||||
|
### 8.5 BAUD 类命令
|
||||||
|
|
||||||
|
#### 查询 UART 波特率
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+BAUD?\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
返回示例:
|
||||||
|
|
||||||
|
```text
|
||||||
|
+BAUD:U0=115200,U1=115200
|
||||||
|
OK
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 设置 UART 波特率
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+BAUD=U0,115200\r\n
|
||||||
|
AT+BAUD=U1,38400\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
字段顺序:
|
||||||
|
|
||||||
|
```text
|
||||||
|
UART,BAUDRATE
|
||||||
|
```
|
||||||
|
|
||||||
|
字段说明:
|
||||||
|
|
||||||
|
- `UART`:`U0/U1`
|
||||||
|
- `BAUDRATE`:范围 `1200~921600`
|
||||||
|
|
||||||
|
说明:
|
||||||
|
|
||||||
|
- 该命令只更新当前运行配置记录,不会立即重初始化 `USART2/USART3`
|
||||||
|
- 执行 `AT+SAVE` 后再执行 `AT+RESET`,重启时按保存值生效
|
||||||
|
|
||||||
|
### 8.6 LINK 类命令
|
||||||
|
|
||||||
|
#### 设置单条 LINK 记录
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+LINK=S1,1,8080,0.0.0.0,0,U0\r\n
|
||||||
|
AT+LINK=C1,1,9001,192.168.1.200,9000,U1\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
字段顺序:
|
||||||
|
|
||||||
|
```text
|
||||||
|
ROLE,EN,LPORT,RIP,RPORT,UART
|
||||||
|
```
|
||||||
|
|
||||||
|
字段说明:
|
||||||
|
|
||||||
|
- `ROLE`:链路角色名,固定为 `S1/S2/C1/C2`
|
||||||
|
- `EN`:`0/1`
|
||||||
|
- `LPORT`:本地端口
|
||||||
|
- `RIP`:对端 IP
|
||||||
|
- `RPORT`:对端端口
|
||||||
|
- `UART`:`U0/U1`
|
||||||
|
|
||||||
|
说明:
|
||||||
|
|
||||||
|
- `Server` 与 `Client` 共用同一条 `LINK` 记录模型
|
||||||
|
- `Server` 中 `RIP/RPORT` 可作为允许接入的对端约束或预设对端信息
|
||||||
|
- `Client` 中 `RIP/RPORT` 表示远端目标地址与端口
|
||||||
|
|
||||||
|
#### 查询单条 LINK
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+LINK=S1\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
返回示例:
|
||||||
|
|
||||||
|
```text
|
||||||
|
+LINK:S1,EN=1,LPORT=8080,RIP=0.0.0.0,RPORT=0,UART=U0
|
||||||
|
OK
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 查询全部 LINK
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+LINK?\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
返回示例:
|
||||||
|
|
||||||
|
```text
|
||||||
|
+LINK:S1,EN=1,LPORT=8080,RIP=0.0.0.0,RPORT=0,UART=U0
|
||||||
|
+LINK:S2,EN=0,LPORT=8081,RIP=0.0.0.0,RPORT=0,UART=U1
|
||||||
|
+LINK:C1,EN=1,LPORT=9001,RIP=192.168.1.200,RPORT=9000,UART=U1
|
||||||
|
+LINK:C2,EN=0,LPORT=9002,RIP=192.168.1.201,RPORT=9001,UART=U0
|
||||||
|
OK
|
||||||
|
```
|
||||||
|
|
||||||
|
## 9. 保存与复位命令
|
||||||
|
|
||||||
|
### 9.1 保存配置
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+SAVE\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
成功返回:
|
||||||
|
|
||||||
|
```text
|
||||||
|
OK: Configuration saved
|
||||||
|
```
|
||||||
|
|
||||||
|
### 9.2 软件复位
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+RESET\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
返回:
|
||||||
|
|
||||||
|
```text
|
||||||
|
OK: Resetting...
|
||||||
|
```
|
||||||
|
|
||||||
|
### 9.3 恢复默认值
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+DEFAULT\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
返回:
|
||||||
|
|
||||||
|
```text
|
||||||
|
OK: Defaults restored
|
||||||
|
```
|
||||||
|
|
||||||
|
## 10. 常见错误返回
|
||||||
|
|
||||||
|
| 场景 | 返回 |
|
||||||
|
|------|------|
|
||||||
|
| 未知命令 | `ERROR: Unknown command` |
|
||||||
|
| 非法端口 | `ERROR: Invalid port` |
|
||||||
|
| 非法波特率 | `ERROR: Invalid baudrate` |
|
||||||
|
| 非法 IP 地址 | `ERROR: Invalid IP format` |
|
||||||
|
| 非法掩码 | `ERROR: Invalid mask format` |
|
||||||
|
| 非法网关 | `ERROR: Invalid gateway format` |
|
||||||
|
| 非法远端 IP | `ERROR: Invalid remote IP format` |
|
||||||
|
| 非法 MAC | `ERROR: Invalid MAC format` |
|
||||||
|
| 非法 `SRCID` / `DSTMASK` | `ERROR: Invalid route field` |
|
||||||
|
| Flash 保存失败 | `ERROR: Save failed` |
|
||||||
|
|
||||||
|
## 11. 推荐配置流程
|
||||||
|
|
||||||
|
```text
|
||||||
|
AT+NET=192.168.1.123,255.255.255.0,192.168.1.1,02:00:00:00:00:01\r\n
|
||||||
|
AT+LINK=S1,1,10001,0.0.0.0,0,U1\r\n
|
||||||
|
AT+LINK=S2,1,10003,0.0.0.0,0,U1\r\n
|
||||||
|
AT+LINK=C1,1,20001,192.168.1.201,10002,U0\r\n
|
||||||
|
AT+MUX=1\r\n
|
||||||
|
AT+SAVE\r\n
|
||||||
|
AT+RESET\r\n
|
||||||
|
```
|
||||||
|
|
||||||
|
## 12. 故障排查建议
|
||||||
|
|
||||||
|
### 12.1 发送 `AT` 没有返回
|
||||||
|
|
||||||
|
优先检查:
|
||||||
|
|
||||||
|
1. 是否连接到 `USART1`
|
||||||
|
2. 串口参数是否为 `115200 8N1`
|
||||||
|
3. 是否严格使用 `\r\n` 作为命令结尾
|
||||||
|
4. 接线是否正确
|
||||||
|
5. 设备是否正常上电运行
|
||||||
|
|
||||||
|
### 12.2 设置成功但重启后参数丢失
|
||||||
|
|
||||||
|
检查是否漏掉以下步骤:
|
||||||
|
|
||||||
|
1. `AT+SAVE\r\n`
|
||||||
|
2. `AT+RESET\r\n`
|
||||||
|
|
||||||
|
### 12.3 MUX 模式数据口有丢包
|
||||||
|
|
||||||
|
若 `MUX=1` 下出现“主机侧已发送,但设备对端收到数量明显偏少”的现象,优先按以下顺序检查:
|
||||||
|
|
||||||
|
1. 固件版本是否已经包含 `2026-04-18` 的 MUX 丢包修复。
|
||||||
|
2. MUX 帧是否完整,尤其是:
|
||||||
|
- `SYNC=0x7E`
|
||||||
|
- `LEN_H/LEN_L`
|
||||||
|
- `SRCID`
|
||||||
|
- `DSTMASK`
|
||||||
|
- `TAIL=0x7F`
|
||||||
|
3. 上位机发送方式是否把一帧拆成多个不连续小片段,或在帧间插入无效字节。
|
||||||
|
4. TCP 对端是否出现拥塞、窗口缩小或应用层不及时取数,导致发送路径出现背压。
|
||||||
|
5. RTT 中是否存在链路错误、发送失败或持续重连现象。
|
||||||
|
|
||||||
|
当前版本的修复点如下:
|
||||||
|
|
||||||
|
1. MUX 解析器改为在整帧完整到齐前不推进 UART RX ring 读指针,避免半帧被破坏性消费。
|
||||||
|
2. TCP 发送路径与 UART 写入路径不再把背压和短写静默视为成功,便于及早暴露链路承载问题。
|
||||||
|
|
||||||
|
现场回归结果:在修复后的固件中,MUX 模式持续发送 `670` 包,接收端 `670` 包全部到达,`0` 丢包。
|
||||||
|
|
||||||
|
## 13. 相关文件
|
||||||
|
|
||||||
|
- AT 命令实现:[config.c](/D:/code/STM32Project/TCP2UART/App/config.c)
|
||||||
|
- 配置结构与默认值:[config.h](/D:/code/STM32Project/TCP2UART/App/config.h)
|
||||||
|
- 调试与测试记录:[uart-ch390-debug-handoff.md](/D:/code/STM32Project/TCP2UART/uart-ch390-debug-handoff.md)
|
||||||
+902
@@ -0,0 +1,902 @@
|
|||||||
|
/**
|
||||||
|
* @file config.c
|
||||||
|
* @brief Bare-metal final AT configuration module implementation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "flash_param.h"
|
||||||
|
#include "../Core/Inc/usart.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define CONFIG_TX_BUFFER_SIZE 512u
|
||||||
|
#define CONFIG_CMD_MAX_LEN 160u
|
||||||
|
|
||||||
|
#define CONFIG_UART_HANDLE huart1
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t magic;
|
||||||
|
uint16_t version;
|
||||||
|
uint16_t reserved;
|
||||||
|
uint8_t mac[6];
|
||||||
|
uint8_t dhcp_enable;
|
||||||
|
uint8_t reserved2;
|
||||||
|
uint8_t ip[4];
|
||||||
|
uint8_t mask[4];
|
||||||
|
uint8_t gw[4];
|
||||||
|
uint16_t server_port;
|
||||||
|
uint16_t reserved3;
|
||||||
|
uint8_t remote_ip[4];
|
||||||
|
uint16_t remote_port;
|
||||||
|
uint16_t reconnect_interval;
|
||||||
|
uint32_t uart2_baudrate;
|
||||||
|
uint32_t uart3_baudrate;
|
||||||
|
uint8_t uart2_databits;
|
||||||
|
uint8_t uart2_stopbits;
|
||||||
|
uint8_t uart2_parity;
|
||||||
|
uint8_t uart3_databits;
|
||||||
|
uint8_t uart3_stopbits;
|
||||||
|
uint8_t uart3_parity;
|
||||||
|
uint16_t reserved4;
|
||||||
|
uint32_t crc;
|
||||||
|
} legacy_device_config_v2_t;
|
||||||
|
|
||||||
|
static device_config_t g_config;
|
||||||
|
static volatile bool g_reset_requested;
|
||||||
|
static uint8_t g_uart_cmd_buffer[CONFIG_CMD_MAX_LEN];
|
||||||
|
static uint16_t g_uart_cmd_len;
|
||||||
|
static bool g_uart_rx_seen_cr;
|
||||||
|
static char g_pending_cmd_buffer[CONFIG_CMD_MAX_LEN];
|
||||||
|
static volatile uint16_t g_pending_cmd_len;
|
||||||
|
static volatile bool g_pending_cmd_ready;
|
||||||
|
static char g_at_response_buffer[CONFIG_TX_BUFFER_SIZE];
|
||||||
|
static char g_cmd_parse_buffer[CONFIG_CMD_MAX_LEN];
|
||||||
|
static char g_cmd_work_buffer[CONFIG_CMD_MAX_LEN];
|
||||||
|
|
||||||
|
static uint32_t config_calc_crc(const device_config_t *cfg)
|
||||||
|
{
|
||||||
|
return flash_param_crc32(cfg, offsetof(device_config_t, crc));
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *skip_whitespace(const char *str)
|
||||||
|
{
|
||||||
|
while (*str == ' ' || *str == '\t') {
|
||||||
|
++str;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void trim_trailing(char *str)
|
||||||
|
{
|
||||||
|
int len = (int)strlen(str);
|
||||||
|
|
||||||
|
while (len > 0 && (str[len - 1] == ' ' || str[len - 1] == '\t' || str[len - 1] == '\r' || str[len - 1] == '\n')) {
|
||||||
|
str[--len] = '\0';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool equals_ignore_case(const char *a, const char *b)
|
||||||
|
{
|
||||||
|
while (*a != '\0' && *b != '\0') {
|
||||||
|
char c1 = *a++;
|
||||||
|
char c2 = *b++;
|
||||||
|
|
||||||
|
if (c1 >= 'a' && c1 <= 'z') {
|
||||||
|
c1 -= 32;
|
||||||
|
}
|
||||||
|
if (c2 >= 'a' && c2 <= 'z') {
|
||||||
|
c2 -= 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c1 != c2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (*a == '\0' && *b == '\0');
|
||||||
|
}
|
||||||
|
|
||||||
|
static int prefix_equals_ignore_case(const char *str, const char *prefix)
|
||||||
|
{
|
||||||
|
while (*prefix != '\0') {
|
||||||
|
char c1 = *str++;
|
||||||
|
char c2 = *prefix++;
|
||||||
|
|
||||||
|
if (c1 >= 'a' && c1 <= 'z') {
|
||||||
|
c1 -= 32;
|
||||||
|
}
|
||||||
|
if (c2 >= 'a' && c2 <= 'z') {
|
||||||
|
c2 -= 32;
|
||||||
|
}
|
||||||
|
if (c1 != c2) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_u32_value(const char *value, uint32_t min_value, uint32_t max_value, uint32_t *parsed_value)
|
||||||
|
{
|
||||||
|
char *endptr;
|
||||||
|
unsigned long parsed;
|
||||||
|
|
||||||
|
if (value == NULL || parsed_value == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
parsed = strtoul(value, &endptr, 10);
|
||||||
|
if (endptr == value || *skip_whitespace(endptr) != '\0') {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (parsed < min_value || parsed > max_value) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*parsed_value = (uint32_t)parsed;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_link_uart(const char *value, uint8_t *uart)
|
||||||
|
{
|
||||||
|
if (equals_ignore_case(value, "U0")) {
|
||||||
|
*uart = LINK_UART_U0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(value, "U1")) {
|
||||||
|
*uart = LINK_UART_U1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *link_uart_to_str(uint8_t uart)
|
||||||
|
{
|
||||||
|
return (uart == LINK_UART_U1) ? "U1" : "U0";
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *link_index_to_name(uint32_t index)
|
||||||
|
{
|
||||||
|
switch (index) {
|
||||||
|
case CONFIG_LINK_S1:
|
||||||
|
return "S1";
|
||||||
|
case CONFIG_LINK_S2:
|
||||||
|
return "S2";
|
||||||
|
case CONFIG_LINK_C1:
|
||||||
|
return "C1";
|
||||||
|
case CONFIG_LINK_C2:
|
||||||
|
return "C2";
|
||||||
|
default:
|
||||||
|
return "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int parse_link_name(const char *value, uint32_t *index)
|
||||||
|
{
|
||||||
|
if (value == NULL || index == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (equals_ignore_case(value, "S1")) {
|
||||||
|
*index = CONFIG_LINK_S1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(value, "S2")) {
|
||||||
|
*index = CONFIG_LINK_S2;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(value, "C1")) {
|
||||||
|
*index = CONFIG_LINK_C1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(value, "C2")) {
|
||||||
|
*index = CONFIG_LINK_C2;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool parse_command_with_value(const char *cmd, const char *name, const char **value)
|
||||||
|
{
|
||||||
|
size_t name_len;
|
||||||
|
|
||||||
|
if (cmd == NULL || name == NULL || value == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
name_len = strlen(name);
|
||||||
|
if (!prefix_equals_ignore_case(cmd, name)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (cmd[name_len] != '=') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*value = skip_whitespace(cmd + name_len + 1u);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *config_next_token(char **cursor)
|
||||||
|
{
|
||||||
|
char *start;
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
if (cursor == NULL || *cursor == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
start = *cursor;
|
||||||
|
while (*start == ' ' || *start == '\t') {
|
||||||
|
++start;
|
||||||
|
}
|
||||||
|
if (*start == '\0') {
|
||||||
|
*cursor = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
end = start;
|
||||||
|
while (*end != '\0' && *end != ',') {
|
||||||
|
++end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*end == ',') {
|
||||||
|
*end = '\0';
|
||||||
|
*cursor = end + 1;
|
||||||
|
} else {
|
||||||
|
*cursor = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
trim_trailing(start);
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_link_defaults(void)
|
||||||
|
{
|
||||||
|
static const uint8_t zero_ip[4] = {0u, 0u, 0u, 0u};
|
||||||
|
static const uint8_t c1_ip[4] = {192u, 168u, 1u, 200u};
|
||||||
|
static const uint8_t c2_ip[4] = {192u, 168u, 1u, 201u};
|
||||||
|
|
||||||
|
memset(g_config.links, 0, sizeof(g_config.links));
|
||||||
|
|
||||||
|
g_config.links[CONFIG_LINK_S1].enabled = 1u;
|
||||||
|
g_config.links[CONFIG_LINK_S1].uart = LINK_UART_U0;
|
||||||
|
g_config.links[CONFIG_LINK_S1].local_port = 8080u;
|
||||||
|
memcpy(g_config.links[CONFIG_LINK_S1].remote_ip, zero_ip, sizeof(zero_ip));
|
||||||
|
|
||||||
|
g_config.links[CONFIG_LINK_S2].enabled = 0u;
|
||||||
|
g_config.links[CONFIG_LINK_S2].uart = LINK_UART_U1;
|
||||||
|
g_config.links[CONFIG_LINK_S2].local_port = 8081u;
|
||||||
|
memcpy(g_config.links[CONFIG_LINK_S2].remote_ip, zero_ip, sizeof(zero_ip));
|
||||||
|
|
||||||
|
g_config.links[CONFIG_LINK_C1].enabled = 1u;
|
||||||
|
g_config.links[CONFIG_LINK_C1].uart = LINK_UART_U1;
|
||||||
|
g_config.links[CONFIG_LINK_C1].local_port = 9001u;
|
||||||
|
memcpy(g_config.links[CONFIG_LINK_C1].remote_ip, c1_ip, sizeof(c1_ip));
|
||||||
|
g_config.links[CONFIG_LINK_C1].remote_port = 9000u;
|
||||||
|
|
||||||
|
g_config.links[CONFIG_LINK_C2].enabled = 0u;
|
||||||
|
g_config.links[CONFIG_LINK_C2].uart = LINK_UART_U0;
|
||||||
|
g_config.links[CONFIG_LINK_C2].local_port = 9002u;
|
||||||
|
memcpy(g_config.links[CONFIG_LINK_C2].remote_ip, c2_ip, sizeof(c2_ip));
|
||||||
|
g_config.links[CONFIG_LINK_C2].remote_port = 9001u;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void migrate_legacy_config(const legacy_device_config_v2_t *legacy)
|
||||||
|
{
|
||||||
|
config_set_defaults();
|
||||||
|
|
||||||
|
memcpy(g_config.net.mac, legacy->mac, sizeof(g_config.net.mac));
|
||||||
|
memcpy(g_config.net.ip, legacy->ip, sizeof(g_config.net.ip));
|
||||||
|
memcpy(g_config.net.mask, legacy->mask, sizeof(g_config.net.mask));
|
||||||
|
memcpy(g_config.net.gw, legacy->gw, sizeof(g_config.net.gw));
|
||||||
|
g_config.uart_baudrate[0] = legacy->uart2_baudrate;
|
||||||
|
g_config.uart_baudrate[1] = legacy->uart3_baudrate;
|
||||||
|
g_config.mux_mode = MUX_MODE_RAW;
|
||||||
|
|
||||||
|
g_config.links[CONFIG_LINK_S1].enabled = (legacy->server_port != 0u) ? 1u : 0u;
|
||||||
|
g_config.links[CONFIG_LINK_S1].uart = LINK_UART_U0;
|
||||||
|
g_config.links[CONFIG_LINK_S1].local_port = legacy->server_port;
|
||||||
|
memset(g_config.links[CONFIG_LINK_S1].remote_ip, 0, sizeof(g_config.links[CONFIG_LINK_S1].remote_ip));
|
||||||
|
g_config.links[CONFIG_LINK_S1].remote_port = 0u;
|
||||||
|
|
||||||
|
g_config.links[CONFIG_LINK_S2].enabled = 0u;
|
||||||
|
|
||||||
|
g_config.links[CONFIG_LINK_C1].enabled = (legacy->remote_port != 0u) ? 1u : 0u;
|
||||||
|
g_config.links[CONFIG_LINK_C1].uart = LINK_UART_U1;
|
||||||
|
g_config.links[CONFIG_LINK_C1].local_port = 8081u;
|
||||||
|
memcpy(g_config.links[CONFIG_LINK_C1].remote_ip, legacy->remote_ip, sizeof(g_config.links[CONFIG_LINK_C1].remote_ip));
|
||||||
|
g_config.links[CONFIG_LINK_C1].remote_port = legacy->remote_port;
|
||||||
|
|
||||||
|
g_config.links[CONFIG_LINK_C2].enabled = 0u;
|
||||||
|
g_config.crc = config_calc_crc(&g_config);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool try_load_legacy_config(void)
|
||||||
|
{
|
||||||
|
legacy_device_config_v2_t legacy;
|
||||||
|
uint32_t expected_crc;
|
||||||
|
|
||||||
|
if (flash_param_read(&legacy, sizeof(legacy)) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
expected_crc = flash_param_crc32(&legacy, offsetof(legacy_device_config_v2_t, crc));
|
||||||
|
if (legacy.magic != CONFIG_MAGIC || legacy.version != 0x0002u || legacy.crc != expected_crc) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
migrate_legacy_config(&legacy);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static at_result_t handle_summary_query(char *response, uint16_t max_len)
|
||||||
|
{
|
||||||
|
char ip_str[16];
|
||||||
|
char mask_str[16];
|
||||||
|
char gw_str[16];
|
||||||
|
char mac_str[18];
|
||||||
|
char rip_str[CONFIG_LINK_COUNT][16];
|
||||||
|
|
||||||
|
config_ip_to_str(g_config.net.ip, ip_str);
|
||||||
|
config_ip_to_str(g_config.net.mask, mask_str);
|
||||||
|
config_ip_to_str(g_config.net.gw, gw_str);
|
||||||
|
config_mac_to_str(g_config.net.mac, mac_str);
|
||||||
|
for (uint32_t i = 0; i < CONFIG_LINK_COUNT; ++i) {
|
||||||
|
config_ip_to_str(g_config.links[i].remote_ip, rip_str[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(response, max_len,
|
||||||
|
"+NET:IP=%s,MASK=%s,GW=%s,MAC=%s\r\n"
|
||||||
|
"+LINK:S1,EN=%u,LPORT=%u,RIP=%s,RPORT=%u,UART=%s\r\n"
|
||||||
|
"+LINK:S2,EN=%u,LPORT=%u,RIP=%s,RPORT=%u,UART=%s\r\n"
|
||||||
|
"+LINK:C1,EN=%u,LPORT=%u,RIP=%s,RPORT=%u,UART=%s\r\n"
|
||||||
|
"+LINK:C2,EN=%u,LPORT=%u,RIP=%s,RPORT=%u,UART=%s\r\n"
|
||||||
|
"+MUX:%u\r\n"
|
||||||
|
"+MAP:UART2=0x04,UART3=0x08,C1=0x01,C2=0x02,S1=0x10,S2=0x20\r\n"
|
||||||
|
"+BAUD:U0=%lu,U1=%lu\r\n"
|
||||||
|
"OK\r\n",
|
||||||
|
ip_str, mask_str, gw_str, mac_str,
|
||||||
|
g_config.links[0].enabled, g_config.links[0].local_port, rip_str[0], g_config.links[0].remote_port, link_uart_to_str(g_config.links[0].uart),
|
||||||
|
g_config.links[1].enabled, g_config.links[1].local_port, rip_str[1], g_config.links[1].remote_port, link_uart_to_str(g_config.links[1].uart),
|
||||||
|
g_config.links[2].enabled, g_config.links[2].local_port, rip_str[2], g_config.links[2].remote_port, link_uart_to_str(g_config.links[2].uart),
|
||||||
|
g_config.links[3].enabled, g_config.links[3].local_port, rip_str[3], g_config.links[3].remote_port, link_uart_to_str(g_config.links[3].uart),
|
||||||
|
g_config.mux_mode,
|
||||||
|
(unsigned long)g_config.uart_baudrate[0],
|
||||||
|
(unsigned long)g_config.uart_baudrate[1]);
|
||||||
|
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static at_result_t handle_net_query(char *response, uint16_t max_len)
|
||||||
|
{
|
||||||
|
char ip_str[16];
|
||||||
|
char mask_str[16];
|
||||||
|
char gw_str[16];
|
||||||
|
char mac_str[18];
|
||||||
|
|
||||||
|
config_ip_to_str(g_config.net.ip, ip_str);
|
||||||
|
config_ip_to_str(g_config.net.mask, mask_str);
|
||||||
|
config_ip_to_str(g_config.net.gw, gw_str);
|
||||||
|
config_mac_to_str(g_config.net.mac, mac_str);
|
||||||
|
snprintf(response, max_len, "+NET:IP=%s,MASK=%s,GW=%s,MAC=%s\r\nOK\r\n", ip_str, mask_str, gw_str, mac_str);
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static at_result_t handle_baud_query(char *response, uint16_t max_len)
|
||||||
|
{
|
||||||
|
snprintf(response,
|
||||||
|
max_len,
|
||||||
|
"+BAUD:U0=%lu,U1=%lu\r\nOK\r\n",
|
||||||
|
(unsigned long)g_config.uart_baudrate[0],
|
||||||
|
(unsigned long)g_config.uart_baudrate[1]);
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static at_result_t handle_link_query(uint32_t index, char *response, uint16_t max_len)
|
||||||
|
{
|
||||||
|
char rip_str[16];
|
||||||
|
|
||||||
|
if (index >= CONFIG_LINK_COUNT) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid route field\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
config_ip_to_str(g_config.links[index].remote_ip, rip_str);
|
||||||
|
snprintf(response,
|
||||||
|
max_len,
|
||||||
|
"+LINK:%s,EN=%u,LPORT=%u,RIP=%s,RPORT=%u,UART=%s\r\nOK\r\n",
|
||||||
|
link_index_to_name(index),
|
||||||
|
g_config.links[index].enabled,
|
||||||
|
g_config.links[index].local_port,
|
||||||
|
rip_str,
|
||||||
|
g_config.links[index].remote_port,
|
||||||
|
link_uart_to_str(g_config.links[index].uart));
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static at_result_t handle_all_link_query(char *response, uint16_t max_len)
|
||||||
|
{
|
||||||
|
char rip_str[CONFIG_LINK_COUNT][16];
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < CONFIG_LINK_COUNT; ++i) {
|
||||||
|
config_ip_to_str(g_config.links[i].remote_ip, rip_str[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(response,
|
||||||
|
max_len,
|
||||||
|
"+LINK:S1,EN=%u,LPORT=%u,RIP=%s,RPORT=%u,UART=%s\r\n"
|
||||||
|
"+LINK:S2,EN=%u,LPORT=%u,RIP=%s,RPORT=%u,UART=%s\r\n"
|
||||||
|
"+LINK:C1,EN=%u,LPORT=%u,RIP=%s,RPORT=%u,UART=%s\r\n"
|
||||||
|
"+LINK:C2,EN=%u,LPORT=%u,RIP=%s,RPORT=%u,UART=%s\r\n"
|
||||||
|
"OK\r\n",
|
||||||
|
g_config.links[0].enabled, g_config.links[0].local_port, rip_str[0], g_config.links[0].remote_port, link_uart_to_str(g_config.links[0].uart),
|
||||||
|
g_config.links[1].enabled, g_config.links[1].local_port, rip_str[1], g_config.links[1].remote_port, link_uart_to_str(g_config.links[1].uart),
|
||||||
|
g_config.links[2].enabled, g_config.links[2].local_port, rip_str[2], g_config.links[2].remote_port, link_uart_to_str(g_config.links[2].uart),
|
||||||
|
g_config.links[3].enabled, g_config.links[3].local_port, rip_str[3], g_config.links[3].remote_port, link_uart_to_str(g_config.links[3].uart));
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int config_init(void)
|
||||||
|
{
|
||||||
|
flash_param_init();
|
||||||
|
return config_load();
|
||||||
|
}
|
||||||
|
|
||||||
|
int config_load(void)
|
||||||
|
{
|
||||||
|
if (flash_param_read(&g_config, sizeof(g_config)) == 0 &&
|
||||||
|
g_config.magic == CONFIG_MAGIC &&
|
||||||
|
g_config.version == CONFIG_VERSION &&
|
||||||
|
g_config.crc == config_calc_crc(&g_config)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (try_load_legacy_config()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
config_set_defaults();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int config_save(void)
|
||||||
|
{
|
||||||
|
g_config.magic = CONFIG_MAGIC;
|
||||||
|
g_config.version = CONFIG_VERSION;
|
||||||
|
g_config.crc = config_calc_crc(&g_config);
|
||||||
|
return flash_param_write(&g_config, sizeof(g_config));
|
||||||
|
}
|
||||||
|
|
||||||
|
void config_set_defaults(void)
|
||||||
|
{
|
||||||
|
const uint8_t default_ip[] = DEFAULT_NET_IP;
|
||||||
|
const uint8_t default_mask[] = DEFAULT_NET_MASK;
|
||||||
|
const uint8_t default_gw[] = DEFAULT_NET_GW;
|
||||||
|
const uint8_t default_mac[] = DEFAULT_NET_MAC;
|
||||||
|
|
||||||
|
memset(&g_config, 0, sizeof(g_config));
|
||||||
|
g_config.magic = CONFIG_MAGIC;
|
||||||
|
g_config.version = CONFIG_VERSION;
|
||||||
|
g_config.mux_mode = MUX_MODE_RAW;
|
||||||
|
memcpy(g_config.net.ip, default_ip, sizeof(g_config.net.ip));
|
||||||
|
memcpy(g_config.net.mask, default_mask, sizeof(g_config.net.mask));
|
||||||
|
memcpy(g_config.net.gw, default_gw, sizeof(g_config.net.gw));
|
||||||
|
memcpy(g_config.net.mac, default_mac, sizeof(g_config.net.mac));
|
||||||
|
set_link_defaults();
|
||||||
|
g_config.uart_baudrate[0] = DEFAULT_UART_BAUDRATE;
|
||||||
|
g_config.uart_baudrate[1] = DEFAULT_UART_BAUDRATE;
|
||||||
|
g_config.crc = config_calc_crc(&g_config);
|
||||||
|
}
|
||||||
|
|
||||||
|
const device_config_t *config_get(void)
|
||||||
|
{
|
||||||
|
return &g_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
device_config_t *config_get_mutable(void)
|
||||||
|
{
|
||||||
|
return &g_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
at_result_t config_process_at_cmd(const char *cmd, char *response, uint16_t max_len)
|
||||||
|
{
|
||||||
|
const char *value;
|
||||||
|
const char *p;
|
||||||
|
|
||||||
|
if (cmd == NULL || response == NULL || max_len == 0u) {
|
||||||
|
return AT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
strncpy(g_cmd_work_buffer, cmd, sizeof(g_cmd_work_buffer) - 1u);
|
||||||
|
g_cmd_work_buffer[sizeof(g_cmd_work_buffer) - 1u] = '\0';
|
||||||
|
trim_trailing(g_cmd_work_buffer);
|
||||||
|
p = skip_whitespace(g_cmd_work_buffer);
|
||||||
|
|
||||||
|
if ((p[0] != 'A' && p[0] != 'a') || (p[1] != 'T' && p[1] != 't')) {
|
||||||
|
snprintf(response, max_len, "ERROR: Unknown command\r\n");
|
||||||
|
return AT_UNKNOWN_CMD;
|
||||||
|
}
|
||||||
|
if (p[2] == '\0') {
|
||||||
|
snprintf(response, max_len, "OK\r\n");
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
if (p[2] != '+') {
|
||||||
|
snprintf(response, max_len, "ERROR: Unknown command\r\n");
|
||||||
|
return AT_UNKNOWN_CMD;
|
||||||
|
}
|
||||||
|
|
||||||
|
p += 3;
|
||||||
|
|
||||||
|
if ((equals_ignore_case(p, "?") || equals_ignore_case(p, "QUERY"))) {
|
||||||
|
return handle_summary_query(response, max_len);
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(p, "SAVE")) {
|
||||||
|
if (config_save() != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Save failed\r\n");
|
||||||
|
return AT_SAVE_FAILED;
|
||||||
|
}
|
||||||
|
snprintf(response, max_len, "OK: Configuration saved\r\n");
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(p, "RESET")) {
|
||||||
|
g_reset_requested = true;
|
||||||
|
snprintf(response, max_len, "OK: Resetting...\r\n");
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(p, "DEFAULT")) {
|
||||||
|
config_set_defaults();
|
||||||
|
snprintf(response, max_len, "OK: Defaults restored\r\n");
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(p, "MUX?")) {
|
||||||
|
snprintf(response, max_len, "+MUX:%u\r\nOK\r\n", g_config.mux_mode);
|
||||||
|
return AT_OK;
|
||||||
|
}
|
||||||
|
if (parse_command_with_value(p, "MUX", &value)) {
|
||||||
|
uint32_t mux_value;
|
||||||
|
if (parse_u32_value(value, 0u, 1u, &mux_value) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid value\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
g_config.mux_mode = (uint8_t)mux_value;
|
||||||
|
snprintf(response, max_len, "OK\r\n");
|
||||||
|
return AT_NEED_REBOOT;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(p, "BAUD?")) {
|
||||||
|
return handle_baud_query(response, max_len);
|
||||||
|
}
|
||||||
|
if (parse_command_with_value(p, "BAUD", &value)) {
|
||||||
|
char value_copy[32];
|
||||||
|
char *cursor;
|
||||||
|
char *token;
|
||||||
|
uint8_t uart;
|
||||||
|
uint32_t baudrate;
|
||||||
|
|
||||||
|
strncpy(value_copy, value, sizeof(value_copy) - 1u);
|
||||||
|
value_copy[sizeof(value_copy) - 1u] = '\0';
|
||||||
|
cursor = value_copy;
|
||||||
|
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || parse_link_uart(token, &uart) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid route field\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || parse_u32_value(token, 1200u, 921600u, &baudrate) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid baudrate\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
if (config_next_token(&cursor) != NULL) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid value\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_config.uart_baudrate[uart] = baudrate;
|
||||||
|
return handle_baud_query(response, max_len) == AT_OK ? AT_NEED_REBOOT : AT_ERROR;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(p, "NET?")) {
|
||||||
|
return handle_net_query(response, max_len);
|
||||||
|
}
|
||||||
|
if (parse_command_with_value(p, "NET", &value)) {
|
||||||
|
char value_copy[96];
|
||||||
|
char *token;
|
||||||
|
char *cursor;
|
||||||
|
uint8_t ip[4];
|
||||||
|
uint8_t mask[4];
|
||||||
|
uint8_t gw[4];
|
||||||
|
uint8_t mac[6];
|
||||||
|
|
||||||
|
strncpy(value_copy, value, sizeof(value_copy) - 1u);
|
||||||
|
value_copy[sizeof(value_copy) - 1u] = '\0';
|
||||||
|
cursor = value_copy;
|
||||||
|
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || config_str_to_ip(token, ip) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid IP format\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || config_str_to_ip(token, mask) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid mask format\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || config_str_to_ip(token, gw) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid gateway format\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || config_str_to_mac(token, mac) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid MAC format\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
if (config_next_token(&cursor) != NULL) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid value\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(g_config.net.ip, ip, sizeof(ip));
|
||||||
|
memcpy(g_config.net.mask, mask, sizeof(mask));
|
||||||
|
memcpy(g_config.net.gw, gw, sizeof(gw));
|
||||||
|
memcpy(g_config.net.mac, mac, sizeof(mac));
|
||||||
|
snprintf(response, max_len, "OK\r\n");
|
||||||
|
return AT_NEED_REBOOT;
|
||||||
|
}
|
||||||
|
if (equals_ignore_case(p, "LINK?")) {
|
||||||
|
return handle_all_link_query(response, max_len);
|
||||||
|
}
|
||||||
|
if (parse_command_with_value(p, "LINK", &value)) {
|
||||||
|
char value_copy[96];
|
||||||
|
char *cursor;
|
||||||
|
char *token;
|
||||||
|
uint32_t index;
|
||||||
|
uint32_t enabled;
|
||||||
|
uint32_t local_port;
|
||||||
|
uint32_t remote_port;
|
||||||
|
uint8_t rip[4];
|
||||||
|
uint8_t uart;
|
||||||
|
|
||||||
|
strncpy(value_copy, value, sizeof(value_copy) - 1u);
|
||||||
|
value_copy[sizeof(value_copy) - 1u] = '\0';
|
||||||
|
cursor = value_copy;
|
||||||
|
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || parse_link_name(token, &index) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid route field\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL) {
|
||||||
|
return handle_link_query(index, response, max_len);
|
||||||
|
}
|
||||||
|
if (parse_u32_value(token, 0u, 1u, &enabled) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid value\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || parse_u32_value(token, 1u, 65535u, &local_port) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid port\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || config_str_to_ip(token, rip) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid remote IP format\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || parse_u32_value(token, 0u, 65535u, &remote_port) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid port\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
token = config_next_token(&cursor);
|
||||||
|
if (token == NULL || parse_link_uart(token, &uart) != 0) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid route field\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
if (config_next_token(&cursor) != NULL) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid value\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_config.links[index].enabled = (uint8_t)enabled;
|
||||||
|
g_config.links[index].local_port = (uint16_t)local_port;
|
||||||
|
memcpy(g_config.links[index].remote_ip, rip, sizeof(rip));
|
||||||
|
g_config.links[index].remote_port = (uint16_t)remote_port;
|
||||||
|
g_config.links[index].uart = uart;
|
||||||
|
if (handle_link_query(index, response, max_len) != AT_OK) {
|
||||||
|
snprintf(response, max_len, "ERROR: Invalid route field\r\n");
|
||||||
|
return AT_INVALID_PARAM;
|
||||||
|
}
|
||||||
|
return AT_NEED_REBOOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(response, max_len, "ERROR: Unknown command\r\n");
|
||||||
|
return AT_UNKNOWN_CMD;
|
||||||
|
}
|
||||||
|
|
||||||
|
void config_ip_to_str(const uint8_t *ip, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int config_str_to_ip(const char *str, uint8_t *ip)
|
||||||
|
{
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
int c;
|
||||||
|
int d;
|
||||||
|
|
||||||
|
if (sscanf(str, "%d.%d.%d.%d", &a, &b, &c, &d) != 4) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (a < 0 || a > 255 || b < 0 || b > 255 || c < 0 || c > 255 || d < 0 || d > 255) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ip[0] = (uint8_t)a;
|
||||||
|
ip[1] = (uint8_t)b;
|
||||||
|
ip[2] = (uint8_t)c;
|
||||||
|
ip[3] = (uint8_t)d;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void config_mac_to_str(const uint8_t *mac, char *str)
|
||||||
|
{
|
||||||
|
sprintf(str, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
int config_str_to_mac(const char *str, uint8_t *mac)
|
||||||
|
{
|
||||||
|
int a[6];
|
||||||
|
|
||||||
|
if (sscanf(str, "%x:%x:%x:%x:%x:%x", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]) != 6 &&
|
||||||
|
sscanf(str, "%x-%x-%x-%x-%x-%x", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]) != 6) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; ++i) {
|
||||||
|
if (a[i] < 0 || a[i] > 255) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
mac[i] = (uint8_t)a[i];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void config_poll(void)
|
||||||
|
{
|
||||||
|
if (g_pending_cmd_ready) {
|
||||||
|
uint16_t len = g_pending_cmd_len;
|
||||||
|
g_pending_cmd_ready = false;
|
||||||
|
g_pending_cmd_len = 0u;
|
||||||
|
(void)config_try_process_frame((const uint8_t *)g_pending_cmd_buffer, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void config_uart_rx_byte(uint8_t byte)
|
||||||
|
{
|
||||||
|
if (byte == '\r') {
|
||||||
|
g_uart_rx_seen_cr = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (byte == '\n') {
|
||||||
|
if (g_uart_rx_seen_cr && g_uart_cmd_len > 0u) {
|
||||||
|
if (!g_pending_cmd_ready) {
|
||||||
|
memcpy(g_pending_cmd_buffer, g_uart_cmd_buffer, g_uart_cmd_len);
|
||||||
|
g_pending_cmd_buffer[g_uart_cmd_len] = '\0';
|
||||||
|
g_pending_cmd_len = g_uart_cmd_len;
|
||||||
|
g_pending_cmd_ready = true;
|
||||||
|
}
|
||||||
|
g_uart_cmd_len = 0u;
|
||||||
|
}
|
||||||
|
g_uart_rx_seen_cr = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_uart_rx_seen_cr) {
|
||||||
|
g_uart_cmd_len = 0u;
|
||||||
|
g_uart_rx_seen_cr = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_uart_cmd_len < (CONFIG_CMD_MAX_LEN - 1u)) {
|
||||||
|
g_uart_cmd_buffer[g_uart_cmd_len++] = byte;
|
||||||
|
g_uart_cmd_buffer[g_uart_cmd_len] = '\0';
|
||||||
|
} else {
|
||||||
|
g_uart_cmd_len = 0u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool config_build_response_frame(const uint8_t *data,
|
||||||
|
uint16_t len,
|
||||||
|
char *response,
|
||||||
|
uint16_t max_len,
|
||||||
|
at_result_t *result)
|
||||||
|
{
|
||||||
|
if (data == NULL || response == NULL || len < 2u || max_len == 0u) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (len >= CONFIG_CMD_MAX_LEN) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(g_cmd_parse_buffer, data, len);
|
||||||
|
g_cmd_parse_buffer[len] = '\0';
|
||||||
|
if (((g_cmd_parse_buffer[0] != 'A') && (g_cmd_parse_buffer[0] != 'a')) ||
|
||||||
|
((g_cmd_parse_buffer[1] != 'T') && (g_cmd_parse_buffer[1] != 't'))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*result = config_process_at_cmd(g_cmd_parse_buffer, response, max_len);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool config_try_process_frame(const uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
at_result_t result = AT_ERROR;
|
||||||
|
|
||||||
|
if (!config_build_response_frame(data, len, g_at_response_buffer, sizeof(g_at_response_buffer), &result)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HAL_UART_Transmit(&CONFIG_UART_HANDLE,
|
||||||
|
(uint8_t *)g_at_response_buffer,
|
||||||
|
(uint16_t)strlen(g_at_response_buffer),
|
||||||
|
1000u) != HAL_OK) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == AT_NEED_REBOOT) {
|
||||||
|
static const char hint[] = "Note: Use AT+SAVE then AT+RESET to apply changes\r\n";
|
||||||
|
if (HAL_UART_Transmit(&CONFIG_UART_HANDLE,
|
||||||
|
(uint8_t *)hint,
|
||||||
|
sizeof(hint) - 1u,
|
||||||
|
1000u) != HAL_OK) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool config_is_reset_requested(void)
|
||||||
|
{
|
||||||
|
return g_reset_requested;
|
||||||
|
}
|
||||||
|
|
||||||
|
void config_clear_reset_requested(void)
|
||||||
|
{
|
||||||
|
g_reset_requested = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t config_link_index_to_endpoint(uint8_t index)
|
||||||
|
{
|
||||||
|
switch (index) {
|
||||||
|
case CONFIG_LINK_S1:
|
||||||
|
return ENDPOINT_S1;
|
||||||
|
case CONFIG_LINK_S2:
|
||||||
|
return ENDPOINT_S2;
|
||||||
|
case CONFIG_LINK_C1:
|
||||||
|
return ENDPOINT_C1;
|
||||||
|
case CONFIG_LINK_C2:
|
||||||
|
return ENDPOINT_C2;
|
||||||
|
default:
|
||||||
|
return 0u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t config_uart_index_to_endpoint(uint8_t uart_index)
|
||||||
|
{
|
||||||
|
return (uart_index == LINK_UART_U1) ? ENDPOINT_UART3 : ENDPOINT_UART2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool config_endpoint_is_single(uint8_t endpoint)
|
||||||
|
{
|
||||||
|
return endpoint == ENDPOINT_C1 || endpoint == ENDPOINT_C2 ||
|
||||||
|
endpoint == ENDPOINT_UART2 || endpoint == ENDPOINT_UART3 ||
|
||||||
|
endpoint == ENDPOINT_S1 || endpoint == ENDPOINT_S2;
|
||||||
|
}
|
||||||
+114
@@ -0,0 +1,114 @@
|
|||||||
|
/**
|
||||||
|
* @file config.h
|
||||||
|
* @brief Final AT configuration model for TCP2UART.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CONFIG_H__
|
||||||
|
#define __CONFIG_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CONFIG_MAGIC 0x54435055u
|
||||||
|
#define CONFIG_VERSION 0x0003u
|
||||||
|
|
||||||
|
#define CONFIG_UART_COUNT 2u
|
||||||
|
#define CONFIG_LINK_COUNT 4u
|
||||||
|
|
||||||
|
#define CONFIG_LINK_S1 0u
|
||||||
|
#define CONFIG_LINK_S2 1u
|
||||||
|
#define CONFIG_LINK_C1 2u
|
||||||
|
#define CONFIG_LINK_C2 3u
|
||||||
|
|
||||||
|
#define ENDPOINT_C1 0x01u
|
||||||
|
#define ENDPOINT_C2 0x02u
|
||||||
|
#define ENDPOINT_UART2 0x04u
|
||||||
|
#define ENDPOINT_UART3 0x08u
|
||||||
|
#define ENDPOINT_S1 0x10u
|
||||||
|
#define ENDPOINT_S2 0x20u
|
||||||
|
|
||||||
|
#define LINK_UART_U0 0u
|
||||||
|
#define LINK_UART_U1 1u
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MUX_MODE_RAW = 0,
|
||||||
|
MUX_MODE_FRAME = 1
|
||||||
|
} mux_mode_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t ip[4];
|
||||||
|
uint8_t mask[4];
|
||||||
|
uint8_t gw[4];
|
||||||
|
uint8_t mac[6];
|
||||||
|
uint8_t reserved[2];
|
||||||
|
} net_config_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t enabled;
|
||||||
|
uint8_t uart;
|
||||||
|
uint16_t local_port;
|
||||||
|
uint8_t remote_ip[4];
|
||||||
|
uint16_t remote_port;
|
||||||
|
uint16_t reserved;
|
||||||
|
} link_config_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t magic;
|
||||||
|
uint16_t version;
|
||||||
|
uint8_t mux_mode;
|
||||||
|
uint8_t reserved0;
|
||||||
|
net_config_t net;
|
||||||
|
link_config_t links[CONFIG_LINK_COUNT];
|
||||||
|
uint32_t uart_baudrate[CONFIG_UART_COUNT];
|
||||||
|
uint32_t crc;
|
||||||
|
} device_config_t;
|
||||||
|
|
||||||
|
#define DEFAULT_NET_IP {192, 168, 1, 100}
|
||||||
|
#define DEFAULT_NET_MASK {255, 255, 255, 0}
|
||||||
|
#define DEFAULT_NET_GW {192, 168, 1, 1}
|
||||||
|
#define DEFAULT_NET_MAC {0x02, 0x00, 0x00, 0x00, 0x00, 0x01}
|
||||||
|
#define DEFAULT_UART_BAUDRATE 115200u
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
AT_OK = 0,
|
||||||
|
AT_ERROR,
|
||||||
|
AT_INVALID_PARAM,
|
||||||
|
AT_UNKNOWN_CMD,
|
||||||
|
AT_SAVE_FAILED,
|
||||||
|
AT_NEED_REBOOT
|
||||||
|
} at_result_t;
|
||||||
|
|
||||||
|
int config_init(void);
|
||||||
|
int config_load(void);
|
||||||
|
int config_save(void);
|
||||||
|
void config_set_defaults(void);
|
||||||
|
const device_config_t *config_get(void);
|
||||||
|
device_config_t *config_get_mutable(void);
|
||||||
|
at_result_t config_process_at_cmd(const char *cmd, char *response, uint16_t max_len);
|
||||||
|
void config_poll(void);
|
||||||
|
void config_uart_rx_byte(uint8_t byte);
|
||||||
|
bool config_try_process_frame(const uint8_t *data, uint16_t len);
|
||||||
|
bool config_build_response_frame(const uint8_t *data,
|
||||||
|
uint16_t len,
|
||||||
|
char *response,
|
||||||
|
uint16_t max_len,
|
||||||
|
at_result_t *result);
|
||||||
|
bool config_is_reset_requested(void);
|
||||||
|
void config_clear_reset_requested(void);
|
||||||
|
void config_ip_to_str(const uint8_t *ip, char *str);
|
||||||
|
int config_str_to_ip(const char *str, uint8_t *ip);
|
||||||
|
void config_mac_to_str(const uint8_t *mac, char *str);
|
||||||
|
int config_str_to_mac(const char *str, uint8_t *mac);
|
||||||
|
uint8_t config_link_index_to_endpoint(uint8_t index);
|
||||||
|
uint8_t config_uart_index_to_endpoint(uint8_t uart_index);
|
||||||
|
bool config_endpoint_is_single(uint8_t endpoint);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __CONFIG_H__ */
|
||||||
@@ -0,0 +1,247 @@
|
|||||||
|
/**
|
||||||
|
* @file flash_param.c
|
||||||
|
* @brief Flash parameter storage module implementation
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "flash_param.h"
|
||||||
|
#include "stm32f1xx_hal.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
* Private Definitions
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* CRC32 polynomial (IEEE 802.3) */
|
||||||
|
#define CRC32_POLYNOMIAL 0xEDB88320
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
* Private Variables
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
* Private Functions
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Unlock Flash for writing
|
||||||
|
*/
|
||||||
|
static HAL_StatusTypeDef flash_unlock(void)
|
||||||
|
{
|
||||||
|
return HAL_FLASH_Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Lock Flash after writing
|
||||||
|
*/
|
||||||
|
static void flash_lock(void)
|
||||||
|
{
|
||||||
|
HAL_FLASH_Lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erase Flash page
|
||||||
|
*/
|
||||||
|
static HAL_StatusTypeDef flash_erase_page(uint32_t page_addr)
|
||||||
|
{
|
||||||
|
FLASH_EraseInitTypeDef erase_init;
|
||||||
|
uint32_t page_error;
|
||||||
|
HAL_StatusTypeDef status;
|
||||||
|
|
||||||
|
erase_init.TypeErase = FLASH_TYPEERASE_PAGES;
|
||||||
|
erase_init.PageAddress = page_addr;
|
||||||
|
erase_init.NbPages = 1;
|
||||||
|
|
||||||
|
status = HAL_FLASHEx_Erase(&erase_init, &page_error);
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Program Flash half-word (16-bit)
|
||||||
|
*/
|
||||||
|
static HAL_StatusTypeDef flash_program_halfword(uint32_t addr, uint16_t data)
|
||||||
|
{
|
||||||
|
return HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, addr, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
* Public Functions
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize Flash parameter storage
|
||||||
|
*/
|
||||||
|
int flash_param_init(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read parameters from Flash
|
||||||
|
*/
|
||||||
|
int flash_param_read(void *data, uint32_t len)
|
||||||
|
{
|
||||||
|
if (data == NULL || len == 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if length exceeds available space */
|
||||||
|
if (len > FLASH_PARAM_PAGE_SIZE)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Direct memory read from Flash */
|
||||||
|
memcpy(data, (const void *)FLASH_PARAM_START_ADDR, len);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write parameters to Flash
|
||||||
|
*/
|
||||||
|
int flash_param_write(const void *data, uint32_t len)
|
||||||
|
{
|
||||||
|
HAL_StatusTypeDef status;
|
||||||
|
uint32_t addr;
|
||||||
|
const uint8_t *src;
|
||||||
|
uint16_t halfword;
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
if (data == NULL || len == 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if length exceeds available space */
|
||||||
|
if (len > FLASH_PARAM_PAGE_SIZE)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock Flash */
|
||||||
|
status = flash_unlock();
|
||||||
|
if (status != HAL_OK)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Erase the page */
|
||||||
|
status = flash_erase_page(FLASH_PARAM_START_ADDR);
|
||||||
|
if (status != HAL_OK)
|
||||||
|
{
|
||||||
|
flash_lock();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Program Flash (half-word at a time for STM32F1) */
|
||||||
|
addr = FLASH_PARAM_START_ADDR;
|
||||||
|
src = (const uint8_t *)data;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i += 2)
|
||||||
|
{
|
||||||
|
/* Build half-word (little-endian) */
|
||||||
|
halfword = src[i];
|
||||||
|
if (i + 1 < len)
|
||||||
|
{
|
||||||
|
halfword |= ((uint16_t)src[i + 1]) << 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
halfword |= 0xFF00; /* Pad with 0xFF */
|
||||||
|
}
|
||||||
|
|
||||||
|
status = flash_program_halfword(addr, halfword);
|
||||||
|
if (status != HAL_OK)
|
||||||
|
{
|
||||||
|
flash_lock();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lock Flash */
|
||||||
|
flash_lock();
|
||||||
|
|
||||||
|
/* Verify write */
|
||||||
|
if (memcmp((const void *)FLASH_PARAM_START_ADDR, data, len) != 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erase parameter storage area
|
||||||
|
*/
|
||||||
|
int flash_param_erase(void)
|
||||||
|
{
|
||||||
|
HAL_StatusTypeDef status;
|
||||||
|
|
||||||
|
/* Unlock Flash */
|
||||||
|
status = flash_unlock();
|
||||||
|
if (status != HAL_OK)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Erase the page */
|
||||||
|
status = flash_erase_page(FLASH_PARAM_START_ADDR);
|
||||||
|
|
||||||
|
/* Lock Flash */
|
||||||
|
flash_lock();
|
||||||
|
|
||||||
|
return (status == HAL_OK) ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Calculate CRC32
|
||||||
|
*/
|
||||||
|
uint32_t flash_param_crc32(const void *data, uint32_t len)
|
||||||
|
{
|
||||||
|
const uint8_t *p = (const uint8_t *)data;
|
||||||
|
uint32_t crc = 0xFFFFFFFF;
|
||||||
|
uint32_t i;
|
||||||
|
uint32_t j;
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
{
|
||||||
|
crc ^= p[i];
|
||||||
|
for (j = 0; j < 8u; ++j)
|
||||||
|
{
|
||||||
|
if ((crc & 1u) != 0u)
|
||||||
|
{
|
||||||
|
crc = (crc >> 1) ^ CRC32_POLYNOMIAL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
crc >>= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return crc ^ 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Verify parameter storage integrity
|
||||||
|
*/
|
||||||
|
int flash_param_verify(void)
|
||||||
|
{
|
||||||
|
uint32_t magic;
|
||||||
|
|
||||||
|
/* Read magic number */
|
||||||
|
memcpy(&magic, (const void *)FLASH_PARAM_START_ADDR, sizeof(magic));
|
||||||
|
|
||||||
|
/* Check if Flash is erased (all 0xFF) */
|
||||||
|
if (magic == 0xFFFFFFFF)
|
||||||
|
{
|
||||||
|
return -1; /* Empty/erased */
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* @file flash_param.h
|
||||||
|
* @brief Flash parameter storage module for TCP2UART
|
||||||
|
*
|
||||||
|
* Stores configuration parameters in STM32F103 internal Flash.
|
||||||
|
* Uses the last page of Flash (1KB) for parameter storage.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __FLASH_PARAM_H__
|
||||||
|
#define __FLASH_PARAM_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Flash configuration for STM32F103R8 (64KB Flash) */
|
||||||
|
#define FLASH_PARAM_PAGE_SIZE 1024 /* 1KB per page for STM32F103 */
|
||||||
|
#define FLASH_PARAM_START_ADDR 0x0800FC00 /* Last 1KB of 64KB Flash */
|
||||||
|
#define FLASH_PARAM_END_ADDR 0x08010000 /* End of Flash */
|
||||||
|
|
||||||
|
/* For STM32F103RC (256KB), use: 0x0803FC00 */
|
||||||
|
/* For STM32F103RB (128KB), use: 0x0801FC00 */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize Flash parameter storage
|
||||||
|
* @return 0 on success, negative on error
|
||||||
|
*/
|
||||||
|
int flash_param_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read parameters from Flash
|
||||||
|
* @param data Output buffer
|
||||||
|
* @param len Length to read
|
||||||
|
* @return 0 on success, negative on error
|
||||||
|
*/
|
||||||
|
int flash_param_read(void *data, uint32_t len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write parameters to Flash
|
||||||
|
* @param data Data to write
|
||||||
|
* @param len Length to write
|
||||||
|
* @return 0 on success, negative on error
|
||||||
|
*
|
||||||
|
* Note: This function will erase the Flash page before writing.
|
||||||
|
*/
|
||||||
|
int flash_param_write(const void *data, uint32_t len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Erase parameter storage area
|
||||||
|
* @return 0 on success, negative on error
|
||||||
|
*/
|
||||||
|
int flash_param_erase(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Calculate CRC32 for data
|
||||||
|
* @param data Data buffer
|
||||||
|
* @param len Data length
|
||||||
|
* @return CRC32 value
|
||||||
|
*/
|
||||||
|
uint32_t flash_param_crc32(const void *data, uint32_t len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Verify parameter storage integrity
|
||||||
|
* @return 0 if valid, negative if invalid or corrupted
|
||||||
|
*/
|
||||||
|
int flash_param_verify(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __FLASH_PARAM_H__ */
|
||||||
@@ -0,0 +1,314 @@
|
|||||||
|
/**
|
||||||
|
* @file tcp_client.c
|
||||||
|
* @brief Indexed lwIP RAW TCP client manager.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcp_client.h"
|
||||||
|
|
||||||
|
#include "../Core/Inc/main.h"
|
||||||
|
#include "../Drivers/LwIP/src/include/lwip/ip_addr.h"
|
||||||
|
#include "../Drivers/LwIP/src/include/lwip/pbuf.h"
|
||||||
|
#include "../Drivers/LwIP/src/include/lwip/tcp.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
struct tcp_pcb *pcb;
|
||||||
|
uint8_t rx_ring[TCP_CLIENT_RX_BUFFER_SIZE];
|
||||||
|
uint16_t rx_head;
|
||||||
|
uint16_t rx_tail;
|
||||||
|
uint32_t next_retry_ms;
|
||||||
|
uint8_t index;
|
||||||
|
tcp_client_instance_config_t config;
|
||||||
|
tcp_client_status_t status;
|
||||||
|
} tcp_client_ctx_t;
|
||||||
|
|
||||||
|
static tcp_client_ctx_t g_clients[TCP_CLIENT_INSTANCE_COUNT];
|
||||||
|
|
||||||
|
static uint16_t ring_free(uint16_t head, uint16_t tail, uint16_t size)
|
||||||
|
{
|
||||||
|
return (head >= tail) ? (uint16_t)(size - head + tail - 1u) : (uint16_t)(tail - head - 1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
static err_t tcp_client_on_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||||
|
{
|
||||||
|
tcp_client_ctx_t *ctx = (tcp_client_ctx_t *)arg;
|
||||||
|
struct pbuf *q;
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
if (p != NULL) {
|
||||||
|
pbuf_free(p);
|
||||||
|
}
|
||||||
|
return ERR_ARG;
|
||||||
|
}
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
if (p != NULL) {
|
||||||
|
pbuf_free(p);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if (p == NULL) {
|
||||||
|
tcp_arg(pcb, NULL);
|
||||||
|
tcp_recv(pcb, NULL);
|
||||||
|
tcp_sent(pcb, NULL);
|
||||||
|
tcp_err(pcb, NULL);
|
||||||
|
tcp_abort(pcb);
|
||||||
|
ctx->pcb = NULL;
|
||||||
|
ctx->status.state = TCP_CLIENT_STATE_DISCONNECTED;
|
||||||
|
ctx->next_retry_ms = HAL_GetTick() + ctx->config.reconnect_interval_ms;
|
||||||
|
return ERR_ABRT;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (q = p; q != NULL; q = q->next) {
|
||||||
|
const uint8_t *src = (const uint8_t *)q->payload;
|
||||||
|
for (uint16_t i = 0; i < q->len; ++i) {
|
||||||
|
if (ring_free(ctx->rx_head, ctx->rx_tail, TCP_CLIENT_RX_BUFFER_SIZE) == 0u) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ctx->rx_ring[ctx->rx_head] = src[i];
|
||||||
|
ctx->rx_head = (uint16_t)((ctx->rx_head + 1u) % TCP_CLIENT_RX_BUFFER_SIZE);
|
||||||
|
ctx->status.rx_bytes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tcp_recved(pcb, p->tot_len);
|
||||||
|
pbuf_free(p);
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static err_t tcp_client_on_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
|
||||||
|
{
|
||||||
|
tcp_client_ctx_t *ctx = (tcp_client_ctx_t *)arg;
|
||||||
|
(void)pcb;
|
||||||
|
if (ctx != NULL) {
|
||||||
|
ctx->status.tx_bytes += len;
|
||||||
|
}
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tcp_client_on_err(void *arg, err_t err)
|
||||||
|
{
|
||||||
|
tcp_client_ctx_t *ctx = (tcp_client_ctx_t *)arg;
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx->pcb = NULL;
|
||||||
|
ctx->status.state = TCP_CLIENT_STATE_DISCONNECTED;
|
||||||
|
ctx->status.errors++;
|
||||||
|
ctx->next_retry_ms = HAL_GetTick() + ctx->config.reconnect_interval_ms;
|
||||||
|
(void)err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static err_t tcp_client_on_connected(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||||
|
{
|
||||||
|
tcp_client_ctx_t *ctx = (tcp_client_ctx_t *)arg;
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return ERR_ARG;
|
||||||
|
}
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
ctx->pcb = NULL;
|
||||||
|
ctx->status.state = TCP_CLIENT_STATE_DISCONNECTED;
|
||||||
|
ctx->status.errors++;
|
||||||
|
ctx->next_retry_ms = HAL_GetTick() + ctx->config.reconnect_interval_ms;
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->pcb = pcb;
|
||||||
|
ctx->status.state = TCP_CLIENT_STATE_CONNECTED;
|
||||||
|
tcp_nagle_disable(pcb);
|
||||||
|
tcp_arg(pcb, ctx);
|
||||||
|
tcp_recv(pcb, tcp_client_on_recv);
|
||||||
|
tcp_sent(pcb, tcp_client_on_sent);
|
||||||
|
tcp_err(pcb, tcp_client_on_err);
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_client_init_all(void)
|
||||||
|
{
|
||||||
|
memset(g_clients, 0, sizeof(g_clients));
|
||||||
|
for (uint8_t i = 0; i < TCP_CLIENT_INSTANCE_COUNT; ++i) {
|
||||||
|
g_clients[i].index = i;
|
||||||
|
g_clients[i].status.state = TCP_CLIENT_STATE_IDLE;
|
||||||
|
g_clients[i].config.reconnect_interval_ms = TCP_CLIENT_RECONNECT_DELAY_MS;
|
||||||
|
g_clients[i].config.auto_reconnect = true;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_client_config(uint8_t instance, const tcp_client_instance_config_t *config)
|
||||||
|
{
|
||||||
|
if (instance >= TCP_CLIENT_INSTANCE_COUNT || config == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
g_clients[instance].config = *config;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_client_connect(uint8_t instance)
|
||||||
|
{
|
||||||
|
struct tcp_pcb *pcb;
|
||||||
|
ip_addr_t remote_addr;
|
||||||
|
err_t err;
|
||||||
|
tcp_client_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (instance >= TCP_CLIENT_INSTANCE_COUNT) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ctx = &g_clients[instance];
|
||||||
|
if (!ctx->config.enabled) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ctx->pcb != NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcb = tcp_new_ip_type(IPADDR_TYPE_V4);
|
||||||
|
if (pcb == NULL) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
ctx->status.state = TCP_CLIENT_STATE_ERROR;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (ctx->config.local_port != 0u) {
|
||||||
|
err = tcp_bind(pcb, IP_ANY_TYPE, ctx->config.local_port);
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
tcp_abort(pcb);
|
||||||
|
ctx->status.state = TCP_CLIENT_STATE_DISCONNECTED;
|
||||||
|
ctx->status.errors++;
|
||||||
|
ctx->next_retry_ms = HAL_GetTick() + ctx->config.reconnect_interval_ms;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IP_ADDR4(&remote_addr,
|
||||||
|
ctx->config.remote_ip[0],
|
||||||
|
ctx->config.remote_ip[1],
|
||||||
|
ctx->config.remote_ip[2],
|
||||||
|
ctx->config.remote_ip[3]);
|
||||||
|
|
||||||
|
ctx->status.state = TCP_CLIENT_STATE_CONNECTING;
|
||||||
|
tcp_arg(pcb, ctx);
|
||||||
|
tcp_err(pcb, tcp_client_on_err);
|
||||||
|
err = tcp_connect(pcb, &remote_addr, ctx->config.remote_port, tcp_client_on_connected);
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
tcp_err(pcb, NULL);
|
||||||
|
tcp_abort(pcb);
|
||||||
|
ctx->status.state = TCP_CLIENT_STATE_DISCONNECTED;
|
||||||
|
ctx->status.errors++;
|
||||||
|
ctx->next_retry_ms = HAL_GetTick() + ctx->config.reconnect_interval_ms;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->pcb = pcb;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_client_disconnect(uint8_t instance)
|
||||||
|
{
|
||||||
|
tcp_client_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (instance >= TCP_CLIENT_INSTANCE_COUNT) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ctx = &g_clients[instance];
|
||||||
|
if (ctx->pcb != NULL) {
|
||||||
|
tcp_arg(ctx->pcb, NULL);
|
||||||
|
tcp_recv(ctx->pcb, NULL);
|
||||||
|
tcp_sent(ctx->pcb, NULL);
|
||||||
|
tcp_err(ctx->pcb, NULL);
|
||||||
|
tcp_abort(ctx->pcb);
|
||||||
|
ctx->pcb = NULL;
|
||||||
|
}
|
||||||
|
ctx->status.state = TCP_CLIENT_STATE_DISCONNECTED;
|
||||||
|
ctx->rx_head = 0u;
|
||||||
|
ctx->rx_tail = 0u;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_client_send(uint8_t instance, const uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
err_t err;
|
||||||
|
tcp_client_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (instance >= TCP_CLIENT_INSTANCE_COUNT || data == NULL || len == 0u) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ctx = &g_clients[instance];
|
||||||
|
if (ctx->pcb == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (tcp_sndbuf(ctx->pcb) < len) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
err = tcp_write(ctx->pcb, data, len, TCP_WRITE_FLAG_COPY);
|
||||||
|
if (err == ERR_MEM) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
err = tcp_output(ctx->pcb);
|
||||||
|
if (err == ERR_MEM) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return (int)len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_client_recv(uint8_t instance, uint8_t *data, uint16_t max_len)
|
||||||
|
{
|
||||||
|
uint16_t copied = 0u;
|
||||||
|
tcp_client_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (instance >= TCP_CLIENT_INSTANCE_COUNT || data == NULL || max_len == 0u) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ctx = &g_clients[instance];
|
||||||
|
while (copied < max_len && ctx->rx_tail != ctx->rx_head) {
|
||||||
|
data[copied++] = ctx->rx_ring[ctx->rx_tail];
|
||||||
|
ctx->rx_tail = (uint16_t)((ctx->rx_tail + 1u) % TCP_CLIENT_RX_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
return (int)copied;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tcp_client_is_connected(uint8_t instance)
|
||||||
|
{
|
||||||
|
return (instance < TCP_CLIENT_INSTANCE_COUNT) &&
|
||||||
|
(g_clients[instance].pcb != NULL) &&
|
||||||
|
(g_clients[instance].status.state == TCP_CLIENT_STATE_CONNECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_client_get_status(uint8_t instance, tcp_client_status_t *status)
|
||||||
|
{
|
||||||
|
if (instance < TCP_CLIENT_INSTANCE_COUNT && status != NULL) {
|
||||||
|
*status = g_clients[instance].status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_client_poll(void)
|
||||||
|
{
|
||||||
|
uint32_t now = HAL_GetTick();
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < TCP_CLIENT_INSTANCE_COUNT; ++i) {
|
||||||
|
tcp_client_ctx_t *ctx = &g_clients[i];
|
||||||
|
if (!ctx->config.enabled || !ctx->config.auto_reconnect || tcp_client_is_connected(i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ((ctx->pcb != NULL) && (ctx->status.state == TCP_CLIENT_STATE_CONNECTING)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (now >= ctx->next_retry_ms) {
|
||||||
|
ctx->status.reconnect_count++;
|
||||||
|
ctx->next_retry_ms = now + ctx->config.reconnect_interval_ms;
|
||||||
|
(void)tcp_client_connect(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* @file tcp_client.h
|
||||||
|
* @brief Indexed lwIP RAW TCP client manager.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __TCP_CLIENT_H__
|
||||||
|
#define __TCP_CLIENT_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TCP_CLIENT_INSTANCE_COUNT 2u
|
||||||
|
#define TCP_CLIENT_RX_BUFFER_SIZE 512u
|
||||||
|
#define TCP_CLIENT_RECONNECT_DELAY_MS 3000u
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TCP_CLIENT_STATE_IDLE = 0,
|
||||||
|
TCP_CLIENT_STATE_CONNECTING,
|
||||||
|
TCP_CLIENT_STATE_CONNECTED,
|
||||||
|
TCP_CLIENT_STATE_DISCONNECTED,
|
||||||
|
TCP_CLIENT_STATE_ERROR
|
||||||
|
} tcp_client_state_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t remote_ip[4];
|
||||||
|
uint16_t local_port;
|
||||||
|
uint16_t remote_port;
|
||||||
|
uint16_t reconnect_interval_ms;
|
||||||
|
bool enabled;
|
||||||
|
bool auto_reconnect;
|
||||||
|
} tcp_client_instance_config_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tcp_client_state_t state;
|
||||||
|
uint32_t rx_bytes;
|
||||||
|
uint32_t tx_bytes;
|
||||||
|
uint32_t reconnect_count;
|
||||||
|
uint32_t errors;
|
||||||
|
} tcp_client_status_t;
|
||||||
|
|
||||||
|
int tcp_client_init_all(void);
|
||||||
|
int tcp_client_config(uint8_t instance, const tcp_client_instance_config_t *config);
|
||||||
|
int tcp_client_connect(uint8_t instance);
|
||||||
|
int tcp_client_disconnect(uint8_t instance);
|
||||||
|
int tcp_client_send(uint8_t instance, const uint8_t *data, uint16_t len);
|
||||||
|
int tcp_client_recv(uint8_t instance, uint8_t *data, uint16_t max_len);
|
||||||
|
bool tcp_client_is_connected(uint8_t instance);
|
||||||
|
void tcp_client_get_status(uint8_t instance, tcp_client_status_t *status);
|
||||||
|
void tcp_client_poll(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __TCP_CLIENT_H__ */
|
||||||
@@ -0,0 +1,282 @@
|
|||||||
|
/**
|
||||||
|
* @file tcp_server.c
|
||||||
|
* @brief Indexed lwIP RAW TCP server manager.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tcp_server.h"
|
||||||
|
|
||||||
|
#include "../Drivers/LwIP/src/include/lwip/pbuf.h"
|
||||||
|
#include "../Drivers/LwIP/src/include/lwip/tcp.h"
|
||||||
|
|
||||||
|
#include "SEGGER_RTT.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
struct tcp_pcb *listen_pcb;
|
||||||
|
struct tcp_pcb *client_pcb;
|
||||||
|
uint8_t rx_ring[TCP_SERVER_RX_BUFFER_SIZE];
|
||||||
|
uint16_t rx_head;
|
||||||
|
uint16_t rx_tail;
|
||||||
|
uint8_t index;
|
||||||
|
tcp_server_instance_config_t config;
|
||||||
|
tcp_server_status_t status;
|
||||||
|
} tcp_server_ctx_t;
|
||||||
|
|
||||||
|
static tcp_server_ctx_t g_servers[TCP_SERVER_INSTANCE_COUNT];
|
||||||
|
|
||||||
|
static uint16_t ring_free(uint16_t head, uint16_t tail, uint16_t size)
|
||||||
|
{
|
||||||
|
return (head >= tail) ? (uint16_t)(size - head + tail - 1u) : (uint16_t)(tail - head - 1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
static err_t tcp_server_on_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||||
|
{
|
||||||
|
tcp_server_ctx_t *ctx = (tcp_server_ctx_t *)arg;
|
||||||
|
struct pbuf *q;
|
||||||
|
|
||||||
|
if (ctx == NULL) {
|
||||||
|
if (p != NULL) {
|
||||||
|
pbuf_free(p);
|
||||||
|
}
|
||||||
|
return ERR_ARG;
|
||||||
|
}
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
if (p != NULL) {
|
||||||
|
pbuf_free(p);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
if (p == NULL) {
|
||||||
|
tcp_arg(pcb, NULL);
|
||||||
|
tcp_recv(pcb, NULL);
|
||||||
|
tcp_sent(pcb, NULL);
|
||||||
|
tcp_err(pcb, NULL);
|
||||||
|
tcp_abort(pcb);
|
||||||
|
ctx->client_pcb = NULL;
|
||||||
|
ctx->status.state = ctx->config.enabled ? TCP_SERVER_STATE_LISTENING : TCP_SERVER_STATE_IDLE;
|
||||||
|
return ERR_ABRT;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (q = p; q != NULL; q = q->next) {
|
||||||
|
const uint8_t *src = (const uint8_t *)q->payload;
|
||||||
|
for (uint16_t i = 0; i < q->len; ++i) {
|
||||||
|
if (ring_free(ctx->rx_head, ctx->rx_tail, TCP_SERVER_RX_BUFFER_SIZE) == 0u) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ctx->rx_ring[ctx->rx_head] = src[i];
|
||||||
|
ctx->rx_head = (uint16_t)((ctx->rx_head + 1u) % TCP_SERVER_RX_BUFFER_SIZE);
|
||||||
|
ctx->status.rx_bytes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tcp_recved(pcb, p->tot_len);
|
||||||
|
pbuf_free(p);
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static err_t tcp_server_on_sent(void *arg, struct tcp_pcb *pcb, u16_t len)
|
||||||
|
{
|
||||||
|
tcp_server_ctx_t *ctx = (tcp_server_ctx_t *)arg;
|
||||||
|
(void)pcb;
|
||||||
|
if (ctx != NULL) {
|
||||||
|
ctx->status.tx_bytes += len;
|
||||||
|
}
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tcp_server_on_err(void *arg, err_t err)
|
||||||
|
{
|
||||||
|
tcp_server_ctx_t *ctx = (tcp_server_ctx_t *)arg;
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ctx->client_pcb = NULL;
|
||||||
|
ctx->status.state = ctx->config.enabled ? TCP_SERVER_STATE_LISTENING : TCP_SERVER_STATE_IDLE;
|
||||||
|
ctx->status.errors++;
|
||||||
|
SEGGER_RTT_printf(0, "TCP server[%u] connection error=%d\r\n", ctx->index, (int)err);
|
||||||
|
}
|
||||||
|
|
||||||
|
static err_t tcp_server_on_accept(void *arg, struct tcp_pcb *newpcb, err_t err)
|
||||||
|
{
|
||||||
|
tcp_server_ctx_t *ctx = (tcp_server_ctx_t *)arg;
|
||||||
|
|
||||||
|
if (ctx == NULL || err != ERR_OK) {
|
||||||
|
return (ctx == NULL) ? ERR_ARG : err;
|
||||||
|
}
|
||||||
|
if (ctx->client_pcb != NULL) {
|
||||||
|
tcp_abort(newpcb);
|
||||||
|
return ERR_ABRT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->client_pcb = newpcb;
|
||||||
|
ctx->status.state = TCP_SERVER_STATE_CONNECTED;
|
||||||
|
ctx->status.connections++;
|
||||||
|
tcp_nagle_disable(newpcb);
|
||||||
|
tcp_arg(newpcb, ctx);
|
||||||
|
tcp_recv(newpcb, tcp_server_on_recv);
|
||||||
|
tcp_sent(newpcb, tcp_server_on_sent);
|
||||||
|
tcp_err(newpcb, tcp_server_on_err);
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_server_init_all(void)
|
||||||
|
{
|
||||||
|
memset(g_servers, 0, sizeof(g_servers));
|
||||||
|
for (uint8_t i = 0; i < TCP_SERVER_INSTANCE_COUNT; ++i) {
|
||||||
|
g_servers[i].index = i;
|
||||||
|
g_servers[i].status.state = TCP_SERVER_STATE_IDLE;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_server_config(uint8_t instance, const tcp_server_instance_config_t *config)
|
||||||
|
{
|
||||||
|
if (instance >= TCP_SERVER_INSTANCE_COUNT || config == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
g_servers[instance].config = *config;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_server_start(uint8_t instance)
|
||||||
|
{
|
||||||
|
struct tcp_pcb *pcb;
|
||||||
|
err_t err;
|
||||||
|
tcp_server_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (instance >= TCP_SERVER_INSTANCE_COUNT) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ctx = &g_servers[instance];
|
||||||
|
if (!ctx->config.enabled) {
|
||||||
|
ctx->status.state = TCP_SERVER_STATE_IDLE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (ctx->listen_pcb != NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcb = tcp_new_ip_type(IPADDR_TYPE_V4);
|
||||||
|
if (pcb == NULL) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tcp_bind(pcb, IP_ANY_TYPE, ctx->config.port);
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
tcp_abort(pcb);
|
||||||
|
ctx->status.errors++;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->listen_pcb = tcp_listen_with_backlog(pcb, 1);
|
||||||
|
if (ctx->listen_pcb == NULL) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tcp_arg(ctx->listen_pcb, ctx);
|
||||||
|
tcp_accept(ctx->listen_pcb, tcp_server_on_accept);
|
||||||
|
ctx->status.state = TCP_SERVER_STATE_LISTENING;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_server_stop(uint8_t instance)
|
||||||
|
{
|
||||||
|
tcp_server_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (instance >= TCP_SERVER_INSTANCE_COUNT) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ctx = &g_servers[instance];
|
||||||
|
|
||||||
|
if (ctx->client_pcb != NULL) {
|
||||||
|
tcp_arg(ctx->client_pcb, NULL);
|
||||||
|
tcp_recv(ctx->client_pcb, NULL);
|
||||||
|
tcp_sent(ctx->client_pcb, NULL);
|
||||||
|
tcp_err(ctx->client_pcb, NULL);
|
||||||
|
tcp_abort(ctx->client_pcb);
|
||||||
|
ctx->client_pcb = NULL;
|
||||||
|
}
|
||||||
|
if (ctx->listen_pcb != NULL) {
|
||||||
|
tcp_arg(ctx->listen_pcb, NULL);
|
||||||
|
tcp_accept(ctx->listen_pcb, NULL);
|
||||||
|
if (tcp_close(ctx->listen_pcb) != ERR_OK) {
|
||||||
|
tcp_abort(ctx->listen_pcb);
|
||||||
|
}
|
||||||
|
ctx->listen_pcb = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->status.state = TCP_SERVER_STATE_IDLE;
|
||||||
|
ctx->rx_head = 0u;
|
||||||
|
ctx->rx_tail = 0u;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_server_send(uint8_t instance, const uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
err_t err;
|
||||||
|
tcp_server_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (instance >= TCP_SERVER_INSTANCE_COUNT || data == NULL || len == 0u) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ctx = &g_servers[instance];
|
||||||
|
if (ctx->client_pcb == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (tcp_sndbuf(ctx->client_pcb) < len) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = tcp_write(ctx->client_pcb, data, len, TCP_WRITE_FLAG_COPY);
|
||||||
|
if (err == ERR_MEM) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
err = tcp_output(ctx->client_pcb);
|
||||||
|
if (err == ERR_MEM) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
ctx->status.errors++;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return (int)len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tcp_server_recv(uint8_t instance, uint8_t *data, uint16_t max_len)
|
||||||
|
{
|
||||||
|
uint16_t copied = 0u;
|
||||||
|
tcp_server_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (instance >= TCP_SERVER_INSTANCE_COUNT || data == NULL || max_len == 0u) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ctx = &g_servers[instance];
|
||||||
|
while (copied < max_len && ctx->rx_tail != ctx->rx_head) {
|
||||||
|
data[copied++] = ctx->rx_ring[ctx->rx_tail];
|
||||||
|
ctx->rx_tail = (uint16_t)((ctx->rx_tail + 1u) % TCP_SERVER_RX_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
return (int)copied;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tcp_server_is_connected(uint8_t instance)
|
||||||
|
{
|
||||||
|
return (instance < TCP_SERVER_INSTANCE_COUNT) && (g_servers[instance].client_pcb != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tcp_server_get_status(uint8_t instance, tcp_server_status_t *status)
|
||||||
|
{
|
||||||
|
if (instance < TCP_SERVER_INSTANCE_COUNT && status != NULL) {
|
||||||
|
*status = g_servers[instance].status;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
* @file tcp_server.h
|
||||||
|
* @brief Indexed lwIP RAW TCP server manager.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __TCP_SERVER_H__
|
||||||
|
#define __TCP_SERVER_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define TCP_SERVER_INSTANCE_COUNT 2u
|
||||||
|
#define TCP_SERVER_RX_BUFFER_SIZE 512u
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TCP_SERVER_STATE_IDLE = 0,
|
||||||
|
TCP_SERVER_STATE_LISTENING,
|
||||||
|
TCP_SERVER_STATE_CONNECTED,
|
||||||
|
TCP_SERVER_STATE_ERROR
|
||||||
|
} tcp_server_state_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t port;
|
||||||
|
bool enabled;
|
||||||
|
} tcp_server_instance_config_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tcp_server_state_t state;
|
||||||
|
uint32_t rx_bytes;
|
||||||
|
uint32_t tx_bytes;
|
||||||
|
uint32_t connections;
|
||||||
|
uint32_t errors;
|
||||||
|
} tcp_server_status_t;
|
||||||
|
|
||||||
|
int tcp_server_init_all(void);
|
||||||
|
int tcp_server_config(uint8_t instance, const tcp_server_instance_config_t *config);
|
||||||
|
int tcp_server_start(uint8_t instance);
|
||||||
|
int tcp_server_stop(uint8_t instance);
|
||||||
|
int tcp_server_send(uint8_t instance, const uint8_t *data, uint16_t len);
|
||||||
|
int tcp_server_recv(uint8_t instance, uint8_t *data, uint16_t max_len);
|
||||||
|
bool tcp_server_is_connected(uint8_t instance);
|
||||||
|
void tcp_server_get_status(uint8_t instance, tcp_server_status_t *status);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __TCP_SERVER_H__ */
|
||||||
@@ -0,0 +1,458 @@
|
|||||||
|
/**
|
||||||
|
* @file uart_trans.c
|
||||||
|
* @brief Bare-metal UART DMA/IDLE transport and MUX helpers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "uart_trans.h"
|
||||||
|
|
||||||
|
#include "../Core/Inc/usart.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define UART_MUX_SYNC 0x7Eu
|
||||||
|
#define UART_MUX_TAIL 0x7Fu
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UART_HandleTypeDef *huart;
|
||||||
|
uint8_t rx_dma_buffer[UART_RX_DMA_BUFFER_SIZE];
|
||||||
|
uint8_t tx_dma_buffer[UART_TX_DMA_BUFFER_SIZE];
|
||||||
|
uint8_t rx_ring[UART_RX_RING_BUFFER_SIZE];
|
||||||
|
uint8_t tx_ring[UART_TX_RING_BUFFER_SIZE];
|
||||||
|
volatile uint16_t rx_dma_read_index;
|
||||||
|
volatile uint16_t rx_head;
|
||||||
|
volatile uint16_t rx_tail;
|
||||||
|
volatile uint16_t tx_head;
|
||||||
|
volatile uint16_t tx_tail;
|
||||||
|
volatile uint16_t tx_dma_len;
|
||||||
|
volatile bool tx_busy;
|
||||||
|
uart_config_t config;
|
||||||
|
uart_stats_t stats;
|
||||||
|
bool initialized;
|
||||||
|
bool running;
|
||||||
|
} uart_channel_ctx_t;
|
||||||
|
|
||||||
|
static uart_channel_ctx_t g_channels[UART_CHANNEL_MAX];
|
||||||
|
|
||||||
|
static uint16_t ring_used(uint16_t head, uint16_t tail, uint16_t size)
|
||||||
|
{
|
||||||
|
return (head >= tail) ? (head - tail) : (size - tail + head);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint16_t ring_free(uint16_t head, uint16_t tail, uint16_t size)
|
||||||
|
{
|
||||||
|
return (uint16_t)(size - ring_used(head, tail, size) - 1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ring_peek_byte(const uart_channel_ctx_t *ctx, uint16_t offset, uint8_t *out)
|
||||||
|
{
|
||||||
|
uint16_t head;
|
||||||
|
uint16_t tail;
|
||||||
|
|
||||||
|
if (ctx == NULL || out == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
head = ctx->rx_head;
|
||||||
|
tail = ctx->rx_tail;
|
||||||
|
if (offset >= ring_used(head, tail, UART_RX_RING_BUFFER_SIZE)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*out = ctx->rx_ring[(tail + offset) % UART_RX_RING_BUFFER_SIZE];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ring_peek_span(const uart_channel_ctx_t *ctx, uint16_t offset, uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
if (ctx == NULL || data == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t i = 0u; i < len; ++i) {
|
||||||
|
if (!ring_peek_byte(ctx, (uint16_t)(offset + i), &data[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ring_drop_bytes(uart_channel_ctx_t *ctx, uint16_t len)
|
||||||
|
{
|
||||||
|
if (ctx == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (len > 0u && ctx->rx_tail != ctx->rx_head) {
|
||||||
|
ctx->rx_tail = (uint16_t)((ctx->rx_tail + 1u) % UART_RX_RING_BUFFER_SIZE);
|
||||||
|
--len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int apply_uart_config(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
uart_channel_ctx_t *ctx = &g_channels[channel];
|
||||||
|
if (ctx->huart == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx->running) {
|
||||||
|
HAL_UART_DMAStop(ctx->huart);
|
||||||
|
ctx->running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->huart->Init.BaudRate = ctx->config.baudrate;
|
||||||
|
ctx->huart->Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
|
ctx->huart->Init.StopBits = UART_STOPBITS_1;
|
||||||
|
ctx->huart->Init.Parity = UART_PARITY_NONE;
|
||||||
|
return (HAL_UART_Init(ctx->huart) == HAL_OK) ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void process_rx_snapshot(uart_channel_t channel, uint16_t dma_write_index)
|
||||||
|
{
|
||||||
|
uart_channel_ctx_t *ctx = &g_channels[channel];
|
||||||
|
|
||||||
|
while (ctx->rx_dma_read_index != dma_write_index) {
|
||||||
|
uint16_t next_head = (uint16_t)((ctx->rx_head + 1u) % UART_RX_RING_BUFFER_SIZE);
|
||||||
|
if (next_head == ctx->rx_tail) {
|
||||||
|
ctx->stats.errors++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->rx_ring[ctx->rx_head] = ctx->rx_dma_buffer[ctx->rx_dma_read_index];
|
||||||
|
ctx->rx_head = next_head;
|
||||||
|
ctx->rx_dma_read_index = (uint16_t)((ctx->rx_dma_read_index + 1u) % UART_RX_DMA_BUFFER_SIZE);
|
||||||
|
ctx->stats.rx_bytes++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void kick_tx(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
uart_channel_ctx_t *ctx = &g_channels[channel];
|
||||||
|
uint16_t available;
|
||||||
|
uint16_t chunk;
|
||||||
|
|
||||||
|
if (!ctx->running || ctx->tx_busy) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
available = ring_used(ctx->tx_head, ctx->tx_tail, UART_TX_RING_BUFFER_SIZE);
|
||||||
|
if (available == 0u) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
chunk = available;
|
||||||
|
if (chunk > UART_TX_DMA_BUFFER_SIZE) {
|
||||||
|
chunk = UART_TX_DMA_BUFFER_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint16_t i = 0; i < chunk; ++i) {
|
||||||
|
ctx->tx_dma_buffer[i] = ctx->tx_ring[ctx->tx_tail];
|
||||||
|
ctx->tx_tail = (uint16_t)((ctx->tx_tail + 1u) % UART_TX_RING_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->tx_dma_len = chunk;
|
||||||
|
ctx->tx_busy = true;
|
||||||
|
ctx->stats.tx_packets++;
|
||||||
|
|
||||||
|
if (HAL_UART_Transmit_DMA(ctx->huart, ctx->tx_dma_buffer, chunk) != HAL_OK) {
|
||||||
|
ctx->tx_busy = false;
|
||||||
|
ctx->stats.errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int uart_trans_init(void)
|
||||||
|
{
|
||||||
|
memset(g_channels, 0, sizeof(g_channels));
|
||||||
|
g_channels[UART_CHANNEL_U0].huart = &huart2;
|
||||||
|
g_channels[UART_CHANNEL_U1].huart = &huart3;
|
||||||
|
g_channels[UART_CHANNEL_U0].config.baudrate = UART_DEFAULT_BAUDRATE;
|
||||||
|
g_channels[UART_CHANNEL_U1].config.baudrate = UART_DEFAULT_BAUDRATE;
|
||||||
|
g_channels[UART_CHANNEL_U0].initialized = true;
|
||||||
|
g_channels[UART_CHANNEL_U1].initialized = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int uart_trans_config(uart_channel_t channel, const uart_config_t *config)
|
||||||
|
{
|
||||||
|
if (channel >= UART_CHANNEL_MAX || config == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
g_channels[channel].config = *config;
|
||||||
|
return apply_uart_config(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
int uart_trans_start(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
uart_channel_ctx_t *ctx;
|
||||||
|
|
||||||
|
if (channel >= UART_CHANNEL_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx = &g_channels[channel];
|
||||||
|
if (!ctx->initialized || ctx->huart == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->rx_dma_read_index = 0u;
|
||||||
|
ctx->rx_head = 0u;
|
||||||
|
ctx->rx_tail = 0u;
|
||||||
|
ctx->tx_head = 0u;
|
||||||
|
ctx->tx_tail = 0u;
|
||||||
|
ctx->tx_dma_len = 0u;
|
||||||
|
ctx->tx_busy = false;
|
||||||
|
memset(&ctx->stats, 0, sizeof(ctx->stats));
|
||||||
|
|
||||||
|
__HAL_UART_ENABLE_IT(ctx->huart, UART_IT_IDLE);
|
||||||
|
if (HAL_UART_Receive_DMA(ctx->huart, ctx->rx_dma_buffer, UART_RX_DMA_BUFFER_SIZE) != HAL_OK) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->running = true;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int uart_trans_stop(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
if (channel >= UART_CHANNEL_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
HAL_UART_DMAStop(g_channels[channel].huart);
|
||||||
|
g_channels[channel].running = false;
|
||||||
|
g_channels[channel].tx_busy = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_trans_poll(void)
|
||||||
|
{
|
||||||
|
kick_tx(UART_CHANNEL_U0);
|
||||||
|
kick_tx(UART_CHANNEL_U1);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t uart_trans_rx_available(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
if (channel >= UART_CHANNEL_MAX) {
|
||||||
|
return 0u;
|
||||||
|
}
|
||||||
|
return ring_used(g_channels[channel].rx_head, g_channels[channel].rx_tail, UART_RX_RING_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t uart_trans_read(uart_channel_t channel, uint8_t *data, uint16_t max_len)
|
||||||
|
{
|
||||||
|
uart_channel_ctx_t *ctx;
|
||||||
|
uint16_t copied = 0u;
|
||||||
|
|
||||||
|
if (channel >= UART_CHANNEL_MAX || data == NULL || max_len == 0u) {
|
||||||
|
return 0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx = &g_channels[channel];
|
||||||
|
while (copied < max_len && ctx->rx_tail != ctx->rx_head) {
|
||||||
|
data[copied++] = ctx->rx_ring[ctx->rx_tail];
|
||||||
|
ctx->rx_tail = (uint16_t)((ctx->rx_tail + 1u) % UART_RX_RING_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
if (copied > 0u) {
|
||||||
|
ctx->stats.rx_packets++;
|
||||||
|
}
|
||||||
|
return copied;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t uart_trans_write(uart_channel_t channel, const uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
uart_channel_ctx_t *ctx;
|
||||||
|
uint16_t written = 0u;
|
||||||
|
|
||||||
|
if (channel >= UART_CHANNEL_MAX || data == NULL || len == 0u) {
|
||||||
|
return 0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx = &g_channels[channel];
|
||||||
|
while (written < len && ring_free(ctx->tx_head, ctx->tx_tail, UART_TX_RING_BUFFER_SIZE) > 0u) {
|
||||||
|
ctx->tx_ring[ctx->tx_head] = data[written++];
|
||||||
|
ctx->tx_head = (uint16_t)((ctx->tx_head + 1u) % UART_TX_RING_BUFFER_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (written < len) {
|
||||||
|
ctx->stats.errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
kick_tx(channel);
|
||||||
|
return written;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_trans_get_stats(uart_channel_t channel, uart_stats_t *stats)
|
||||||
|
{
|
||||||
|
if (channel < UART_CHANNEL_MAX && stats != NULL) {
|
||||||
|
*stats = g_channels[channel].stats;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_trans_reset_stats(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
if (channel < UART_CHANNEL_MAX) {
|
||||||
|
memset(&g_channels[channel].stats, 0, sizeof(g_channels[channel].stats));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_trans_idle_handler(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
UART_HandleTypeDef *huart;
|
||||||
|
uint16_t dma_write_index;
|
||||||
|
|
||||||
|
if (channel >= UART_CHANNEL_MAX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
huart = g_channels[channel].huart;
|
||||||
|
g_channels[channel].stats.idle_events++;
|
||||||
|
dma_write_index = (uint16_t)(UART_RX_DMA_BUFFER_SIZE - __HAL_DMA_GET_COUNTER(huart->hdmarx));
|
||||||
|
if (dma_write_index >= UART_RX_DMA_BUFFER_SIZE) {
|
||||||
|
dma_write_index = 0u;
|
||||||
|
}
|
||||||
|
process_rx_snapshot(channel, dma_write_index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_trans_rx_half_cplt_handler(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
if (channel >= UART_CHANNEL_MAX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_channels[channel].stats.rx_half_events++;
|
||||||
|
process_rx_snapshot(channel, UART_RX_DMA_BUFFER_SIZE / 2u);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_trans_rx_cplt_handler(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
if (channel >= UART_CHANNEL_MAX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_channels[channel].stats.rx_full_events++;
|
||||||
|
process_rx_snapshot(channel, 0u);
|
||||||
|
}
|
||||||
|
|
||||||
|
void uart_trans_tx_cplt_handler(uart_channel_t channel)
|
||||||
|
{
|
||||||
|
if (channel >= UART_CHANNEL_MAX) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
g_channels[channel].tx_busy = false;
|
||||||
|
g_channels[channel].stats.tx_bytes += g_channels[channel].tx_dma_len;
|
||||||
|
g_channels[channel].tx_dma_len = 0u;
|
||||||
|
kick_tx(channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool uart_mux_try_extract_frame(uart_channel_t channel, uart_mux_frame_t *frame)
|
||||||
|
{
|
||||||
|
uart_channel_ctx_t *ctx;
|
||||||
|
uint8_t header[4];
|
||||||
|
uint8_t tail_byte;
|
||||||
|
uint16_t available;
|
||||||
|
uint16_t payload_len;
|
||||||
|
uint16_t sync_offset;
|
||||||
|
uint16_t total_len;
|
||||||
|
|
||||||
|
if (channel >= UART_CHANNEL_MAX || frame == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx = &g_channels[channel];
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
available = uart_trans_rx_available(channel);
|
||||||
|
if (available < 6u) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_offset = available;
|
||||||
|
for (uint16_t i = 0u; i < available; ++i) {
|
||||||
|
uint8_t byte = 0u;
|
||||||
|
if (!ring_peek_byte(ctx, i, &byte)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (byte == UART_MUX_SYNC) {
|
||||||
|
sync_offset = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sync_offset == available) {
|
||||||
|
ring_drop_bytes(ctx, available);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sync_offset > 0u) {
|
||||||
|
ring_drop_bytes(ctx, sync_offset);
|
||||||
|
available = (uint16_t)(available - sync_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (available < 6u) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ring_peek_span(ctx, 1u, header, sizeof(header))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
payload_len = (uint16_t)(((uint16_t)header[0] << 8) | header[1]);
|
||||||
|
if (payload_len > sizeof(frame->payload)) {
|
||||||
|
ring_drop_bytes(ctx, 1u);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
total_len = (uint16_t)(payload_len + 6u);
|
||||||
|
if (available < total_len) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ring_peek_byte(ctx, (uint16_t)(total_len - 1u), &tail_byte)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (tail_byte != UART_MUX_TAIL) {
|
||||||
|
ring_drop_bytes(ctx, 1u);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame->src_id = header[2];
|
||||||
|
frame->dst_mask = header[3];
|
||||||
|
frame->payload_len = payload_len;
|
||||||
|
if (payload_len > 0u) {
|
||||||
|
if (!ring_peek_span(ctx, 5u, frame->payload, payload_len)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ring_drop_bytes(ctx, total_len);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool uart_mux_encode_frame(uint8_t src_id,
|
||||||
|
uint8_t dst_mask,
|
||||||
|
const uint8_t *payload,
|
||||||
|
uint16_t payload_len,
|
||||||
|
uint8_t *out,
|
||||||
|
uint16_t *out_len,
|
||||||
|
uint16_t out_capacity)
|
||||||
|
{
|
||||||
|
uint16_t frame_len;
|
||||||
|
|
||||||
|
if (out == NULL || out_len == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
frame_len = (uint16_t)(payload_len + 6u);
|
||||||
|
if (frame_len > out_capacity) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
out[0] = UART_MUX_SYNC;
|
||||||
|
out[1] = (uint8_t)(payload_len >> 8);
|
||||||
|
out[2] = (uint8_t)(payload_len & 0xFFu);
|
||||||
|
out[3] = src_id;
|
||||||
|
out[4] = dst_mask;
|
||||||
|
if (payload_len > 0u && payload != NULL) {
|
||||||
|
memcpy(&out[5], payload, payload_len);
|
||||||
|
}
|
||||||
|
out[5 + payload_len] = UART_MUX_TAIL;
|
||||||
|
*out_len = frame_len;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/**
|
||||||
|
* @file uart_trans.h
|
||||||
|
* @brief Bare-metal UART DMA/IDLE transport and MUX framing helpers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __UART_TRANS_H__
|
||||||
|
#define __UART_TRANS_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
UART_CHANNEL_U0 = 0,
|
||||||
|
UART_CHANNEL_U1 = 1,
|
||||||
|
UART_CHANNEL_MAX
|
||||||
|
} uart_channel_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t src_id;
|
||||||
|
uint8_t dst_mask;
|
||||||
|
uint16_t payload_len;
|
||||||
|
uint8_t payload[256];
|
||||||
|
} uart_mux_frame_t;
|
||||||
|
|
||||||
|
#define UART_RX_DMA_BUFFER_SIZE 256u
|
||||||
|
#define UART_TX_DMA_BUFFER_SIZE 256u
|
||||||
|
#define UART_RX_RING_BUFFER_SIZE 512u
|
||||||
|
#define UART_TX_RING_BUFFER_SIZE 384u
|
||||||
|
#define UART_DEFAULT_BAUDRATE 115200u
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t baudrate;
|
||||||
|
} uart_config_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t rx_bytes;
|
||||||
|
uint32_t tx_bytes;
|
||||||
|
uint32_t rx_packets;
|
||||||
|
uint32_t tx_packets;
|
||||||
|
uint32_t idle_events;
|
||||||
|
uint32_t rx_half_events;
|
||||||
|
uint32_t rx_full_events;
|
||||||
|
uint32_t errors;
|
||||||
|
} uart_stats_t;
|
||||||
|
|
||||||
|
int uart_trans_init(void);
|
||||||
|
int uart_trans_config(uart_channel_t channel, const uart_config_t *config);
|
||||||
|
int uart_trans_start(uart_channel_t channel);
|
||||||
|
int uart_trans_stop(uart_channel_t channel);
|
||||||
|
void uart_trans_poll(void);
|
||||||
|
uint16_t uart_trans_rx_available(uart_channel_t channel);
|
||||||
|
uint16_t uart_trans_read(uart_channel_t channel, uint8_t *data, uint16_t max_len);
|
||||||
|
uint16_t uart_trans_write(uart_channel_t channel, const uint8_t *data, uint16_t len);
|
||||||
|
void uart_trans_get_stats(uart_channel_t channel, uart_stats_t *stats);
|
||||||
|
void uart_trans_reset_stats(uart_channel_t channel);
|
||||||
|
void uart_trans_idle_handler(uart_channel_t channel);
|
||||||
|
void uart_trans_rx_half_cplt_handler(uart_channel_t channel);
|
||||||
|
void uart_trans_rx_cplt_handler(uart_channel_t channel);
|
||||||
|
void uart_trans_tx_cplt_handler(uart_channel_t channel);
|
||||||
|
bool uart_mux_try_extract_frame(uart_channel_t channel, uart_mux_frame_t *frame);
|
||||||
|
bool uart_mux_encode_frame(uint8_t src_id,
|
||||||
|
uint8_t dst_mask,
|
||||||
|
const uint8_t *payload,
|
||||||
|
uint16_t payload_len,
|
||||||
|
uint8_t *out,
|
||||||
|
uint16_t *out_len,
|
||||||
|
uint16_t out_capacity);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __UART_TRANS_H__ */
|
||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
# CH390 最终结论报告
|
||||||
|
|
||||||
|
## 结论
|
||||||
|
|
||||||
|
本轮循环调试的最终结论是:
|
||||||
|
|
||||||
|
1. 当前工程中的主要软件问题已经完成收敛和清理。
|
||||||
|
2. CH390D 驱动、lwIP `netif`、ARP 与 ICMP 基本链路已经在实机上打通。
|
||||||
|
3. 本轮最终根因已确认不是普通软件逻辑错误,而是 CH390D 相关供电滤波电容虚焊,导致供电不稳定。
|
||||||
|
|
||||||
|
## 已完成的软件侧工作
|
||||||
|
|
||||||
|
本轮已完成并验证的事项包括:
|
||||||
|
|
||||||
|
1. 修复 PHY 访问无超时导致的永久卡死风险。
|
||||||
|
2. 修复未初始化 IWDG 句柄刷新导致的 HardFault。
|
||||||
|
3. 清理 CH390 运行时中断屏蔽范围,消除阻塞式 SPI 访问造成的运行时假死。
|
||||||
|
4. 重构 CH390 运行时所有权,避免多层并发触达底层 SPI 路径。
|
||||||
|
5. 在 `main()` 中移除重复 CH390 复位,避免启动阶段额外复位噪声。
|
||||||
|
6. 清理已确认 warning 来源,避免无效变量继续污染构建结果。
|
||||||
|
7. 增加 CH390 identity gate,避免在无效寄存器读回前继续执行默认配置和 PHY 初始化。
|
||||||
|
8. 曾增加 bit-bang 诊断读用于快速隔离问题,该临时调试路径已在当前代码中移除。
|
||||||
|
|
||||||
|
## 实机关键证据
|
||||||
|
|
||||||
|
### 1. MCU 自身正常工作
|
||||||
|
|
||||||
|
已验证:
|
||||||
|
|
||||||
|
1. RTT 正常输出。
|
||||||
|
2. 主循环正常运行。
|
||||||
|
3. `TIM4` 心跳正常。
|
||||||
|
4. 运行期不再出现此前已修复的 HardFault 和“长时间假死”症状。
|
||||||
|
|
||||||
|
### 2. 最终硬件根因已定位
|
||||||
|
|
||||||
|
最终实板排查结果:
|
||||||
|
|
||||||
|
1. 板载一颗 CH390D 供电相关滤波电容存在虚焊。
|
||||||
|
2. 该问题导致 CH390D 供电不稳定,表现为寄存器读写、链路状态和报文收发在调试过程中不一致。
|
||||||
|
3. 修复硬件后,实机已观察到:
|
||||||
|
- `VID=0x1C00`、`PID=0x9151`、`REV=0x2B`
|
||||||
|
- PHY 寄存器稳定可读
|
||||||
|
- `lwIP netif` 能进入 `LINK_UP`
|
||||||
|
- 设备可接收 ARP request 并发出 ARP reply
|
||||||
|
- 设备可接收 ICMP Echo Request 并发出 Echo Reply
|
||||||
|
|
||||||
|
### 3. 历史 bit-bang 对照结果(已归档)
|
||||||
|
|
||||||
|
在早期调试中,曾绕过 STM32 硬件 SPI 外设、直接用 GPIO 软件时序读取 `VIDL/VIDH/PIDL/PIDH/CHIPR`,RTT 输出为:
|
||||||
|
|
||||||
|
```text
|
||||||
|
CH390 bitbang VIDL=0xFF VIDH=0xFF PIDL=0xFF PIDH=0xFF CHIPR=0xFF
|
||||||
|
```
|
||||||
|
|
||||||
|
该历史证据用于定位阶段,当前仅保留结论,不再保留对应代码路径。它说明:
|
||||||
|
|
||||||
|
1. 在硬件未修复前,单看软件现象会误导排查方向。
|
||||||
|
2. 电源完整性问题会放大为看似“SPI/IRQ/RX/TX 都可疑”的复合症状。
|
||||||
|
|
||||||
|
## 外部参考对结论的支撑
|
||||||
|
|
||||||
|
对公开 CH390 / DM9051 实现的对照结果表明:
|
||||||
|
|
||||||
|
1. CH390 SPI 访问时序、模式选择和 RX SRAM 连续事务仍然值得严格对照参考实现。
|
||||||
|
2. 但本项目最终问题并非“参考实现缺失”,而是硬件供电缺陷放大了调试噪声。
|
||||||
|
3. 外部参考对软件排查有帮助,但不能替代板级供电与焊接检查。
|
||||||
|
|
||||||
|
## 当前最可信判断
|
||||||
|
|
||||||
|
最终确认的板级问题为:
|
||||||
|
|
||||||
|
1. CH390D 供电滤波电容虚焊。
|
||||||
|
2. 该虚焊导致供电稳定性不足,从而引出不稳定的寄存器读写、链路与收发行为。
|
||||||
|
|
||||||
|
## 版本库状态
|
||||||
|
|
||||||
|
本轮已创建一个阶段性 checkpoint commit:
|
||||||
|
|
||||||
|
1. `1808f99` `fix: harden CH390 bring-up diagnostics`
|
||||||
|
|
||||||
|
该提交记录了:
|
||||||
|
|
||||||
|
1. warning 清理
|
||||||
|
2. 移除重复复位
|
||||||
|
3. CH390 早期 identity gate
|
||||||
|
4. 链路变化稳定等待
|
||||||
|
|
||||||
|
## 推荐的下一步
|
||||||
|
|
||||||
|
后续更高价值的工作不再是继续怀疑 CH390 是否“完全不通”,而是:
|
||||||
|
|
||||||
|
1. 在硬件问题修复后补充长时间稳定性测试。
|
||||||
|
2. 验证 TCP Server / TCP Client 业务流量与桥接逻辑在修复硬件后的行为。
|
||||||
|
3. 保持驱动层日志最小化,仅在重新排障时按需开启详细 RTT。
|
||||||
|
|
||||||
|
## 收尾说明
|
||||||
|
|
||||||
|
本轮循环的退出条件已经满足:软件主路径已验证,且硬件根因已定位。
|
||||||
|
|
||||||
|
因此当前最合理的结论是:
|
||||||
|
|
||||||
|
1. CH390D 驱动、lwIP `netif`、ARP 和 ICMP 基本链路已在实机打通。
|
||||||
|
2. 本轮真正拦路的不是普通软件逻辑,而是板级供电滤波电容虚焊。
|
||||||
|
3. 后续应在硬件修复后的稳定板卡上继续推进应用层联调与文档收口。
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
|
#
|
||||||
|
# This file is generated only once,
|
||||||
|
# and is not re-generated if converter is called multiple times.
|
||||||
|
#
|
||||||
|
# User is free to modify the file as much as necessary
|
||||||
|
#
|
||||||
|
|
||||||
|
# Setup compiler settings
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_C_EXTENSIONS ON)
|
||||||
|
|
||||||
|
|
||||||
|
# Define the build type
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Set the project name
|
||||||
|
set(CMAKE_PROJECT_NAME TCP2UART)
|
||||||
|
|
||||||
|
# Enable compile command to ease indexing with e.g. clangd
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
||||||
|
|
||||||
|
# Core project settings
|
||||||
|
project(${CMAKE_PROJECT_NAME})
|
||||||
|
message("Build type: " ${CMAKE_BUILD_TYPE})
|
||||||
|
|
||||||
|
# Enable CMake support for ASM and C languages
|
||||||
|
enable_language(C ASM)
|
||||||
|
|
||||||
|
# Create an executable object type
|
||||||
|
add_executable(${CMAKE_PROJECT_NAME})
|
||||||
|
|
||||||
|
# Add STM32CubeMX generated sources
|
||||||
|
add_subdirectory(cmake/stm32cubemx)
|
||||||
|
|
||||||
|
# Link directories setup
|
||||||
|
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE
|
||||||
|
# Add user defined library search paths
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add sources to executable
|
||||||
|
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
|
||||||
|
# Add user sources here
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add include paths
|
||||||
|
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
|
||||||
|
# Add user defined include paths
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add project symbols (macros)
|
||||||
|
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
|
||||||
|
# Add user defined symbols
|
||||||
|
)
|
||||||
|
|
||||||
|
# Remove wrong libob.a library dependency when using cpp files
|
||||||
|
list(REMOVE_ITEM CMAKE_C_IMPLICIT_LINK_LIBRARIES ob)
|
||||||
|
|
||||||
|
# Add linked libraries
|
||||||
|
target_link_libraries(${CMAKE_PROJECT_NAME}
|
||||||
|
stm32cubemx
|
||||||
|
|
||||||
|
# Add user defined libraries
|
||||||
|
)
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"hidden": true,
|
||||||
|
"generator": "Ninja",
|
||||||
|
"binaryDir": "${sourceDir}/build/${presetName}",
|
||||||
|
"toolchainFile": "${sourceDir}/cmake/gcc-arm-none-eabi.cmake",
|
||||||
|
"cacheVariables": {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug",
|
||||||
|
"inherits": "default",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Release",
|
||||||
|
"inherits": "default",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Release"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buildPresets": [
|
||||||
|
{
|
||||||
|
"name": "Debug",
|
||||||
|
"configurePreset": "Debug"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Release",
|
||||||
|
"configurePreset": "Release"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
#define configTICK_RATE_HZ ((TickType_t)1000)
|
#define configTICK_RATE_HZ ((TickType_t)1000)
|
||||||
#define configMAX_PRIORITIES ( 56 )
|
#define configMAX_PRIORITIES ( 56 )
|
||||||
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
|
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
|
||||||
#define configTOTAL_HEAP_SIZE ((size_t)3072)
|
#define configTOTAL_HEAP_SIZE ((size_t)8192) /* Fit R8 RAM budget with dynamic tasks */
|
||||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||||
#define configUSE_TRACE_FACILITY 1
|
#define configUSE_TRACE_FACILITY 1
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
@@ -74,6 +74,8 @@
|
|||||||
#define configUSE_RECURSIVE_MUTEXES 1
|
#define configUSE_RECURSIVE_MUTEXES 1
|
||||||
#define configUSE_COUNTING_SEMAPHORES 1
|
#define configUSE_COUNTING_SEMAPHORES 1
|
||||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||||
|
#define configUSE_STREAM_BUFFERS 1 /* Enable StreamBuffer for UART data transfer */
|
||||||
|
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 1
|
||||||
|
|
||||||
/* Co-routine definitions. */
|
/* Co-routine definitions. */
|
||||||
#define configUSE_CO_ROUTINES 0
|
#define configUSE_CO_ROUTINES 0
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ extern "C" {
|
|||||||
void Error_Handler(void);
|
void Error_Handler(void);
|
||||||
|
|
||||||
/* USER CODE BEGIN EFP */
|
/* USER CODE BEGIN EFP */
|
||||||
|
void Debug_TrapWithRttHint(const char *tag);
|
||||||
|
|
||||||
/* USER CODE END EFP */
|
/* USER CODE END EFP */
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
/*#define HAL_SMARTCARD_MODULE_ENABLED */
|
||||||
#define HAL_SPI_MODULE_ENABLED
|
#define HAL_SPI_MODULE_ENABLED
|
||||||
/*#define HAL_SRAM_MODULE_ENABLED */
|
/*#define HAL_SRAM_MODULE_ENABLED */
|
||||||
/*#define HAL_TIM_MODULE_ENABLED */
|
#define HAL_TIM_MODULE_ENABLED
|
||||||
#define HAL_UART_MODULE_ENABLED
|
#define HAL_UART_MODULE_ENABLED
|
||||||
/*#define HAL_USART_MODULE_ENABLED */
|
/*#define HAL_USART_MODULE_ENABLED */
|
||||||
/*#define HAL_WWDG_MODULE_ENABLED */
|
/*#define HAL_WWDG_MODULE_ENABLED */
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ void DMA1_Channel4_IRQHandler(void);
|
|||||||
void DMA1_Channel5_IRQHandler(void);
|
void DMA1_Channel5_IRQHandler(void);
|
||||||
void DMA1_Channel6_IRQHandler(void);
|
void DMA1_Channel6_IRQHandler(void);
|
||||||
void DMA1_Channel7_IRQHandler(void);
|
void DMA1_Channel7_IRQHandler(void);
|
||||||
|
void TIM4_IRQHandler(void);
|
||||||
void SPI1_IRQHandler(void);
|
void SPI1_IRQHandler(void);
|
||||||
void USART1_IRQHandler(void);
|
void USART1_IRQHandler(void);
|
||||||
void USART2_IRQHandler(void);
|
void USART2_IRQHandler(void);
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tim.h
|
||||||
|
* @brief This file contains all the function prototypes for the tim.c file
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __TIM_H__
|
||||||
|
#define __TIM_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim4;
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
|
void MX_TIM4_Init(void);
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Prototypes */
|
||||||
|
|
||||||
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __TIM_H__ */
|
||||||
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
/* USER CODE BEGIN Header */
|
|
||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
* File Name : freertos.c
|
|
||||||
* Description : Code for freertos applications
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2026 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
/* USER CODE END Header */
|
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "FreeRTOS.h"
|
|
||||||
#include "task.h"
|
|
||||||
#include "main.h"
|
|
||||||
#include "cmsis_os.h"
|
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN Includes */
|
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PTD */
|
|
||||||
|
|
||||||
/* USER CODE END PTD */
|
|
||||||
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PD */
|
|
||||||
|
|
||||||
/* USER CODE END PD */
|
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PM */
|
|
||||||
|
|
||||||
/* USER CODE END PM */
|
|
||||||
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN Variables */
|
|
||||||
|
|
||||||
/* USER CODE END Variables */
|
|
||||||
/* Definitions for defaultTask */
|
|
||||||
osThreadId_t defaultTaskHandle;
|
|
||||||
const osThreadAttr_t defaultTask_attributes = {
|
|
||||||
.name = "defaultTask",
|
|
||||||
.stack_size = 128 * 4,
|
|
||||||
.priority = (osPriority_t) osPriorityNormal,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN FunctionPrototypes */
|
|
||||||
|
|
||||||
/* USER CODE END FunctionPrototypes */
|
|
||||||
|
|
||||||
void StartDefaultTask(void *argument);
|
|
||||||
|
|
||||||
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief FreeRTOS initialization
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void MX_FREERTOS_Init(void) {
|
|
||||||
/* USER CODE BEGIN Init */
|
|
||||||
|
|
||||||
/* USER CODE END Init */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_MUTEX */
|
|
||||||
/* add mutexes, ... */
|
|
||||||
/* USER CODE END RTOS_MUTEX */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
|
||||||
/* add semaphores, ... */
|
|
||||||
/* USER CODE END RTOS_SEMAPHORES */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_TIMERS */
|
|
||||||
/* start timers, add new ones, ... */
|
|
||||||
/* USER CODE END RTOS_TIMERS */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_QUEUES */
|
|
||||||
/* add queues, ... */
|
|
||||||
/* USER CODE END RTOS_QUEUES */
|
|
||||||
|
|
||||||
/* Create the thread(s) */
|
|
||||||
/* creation of defaultTask */
|
|
||||||
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
|
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_THREADS */
|
|
||||||
/* add threads, ... */
|
|
||||||
/* USER CODE END RTOS_THREADS */
|
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_EVENTS */
|
|
||||||
/* add events, ... */
|
|
||||||
/* USER CODE END RTOS_EVENTS */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* USER CODE BEGIN Header_StartDefaultTask */
|
|
||||||
/**
|
|
||||||
* @brief Function implementing the defaultTask thread.
|
|
||||||
* @param argument: Not used
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
/* USER CODE END Header_StartDefaultTask */
|
|
||||||
void StartDefaultTask(void *argument)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN StartDefaultTask */
|
|
||||||
/* Infinite loop */
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
osDelay(1);
|
|
||||||
}
|
|
||||||
/* USER CODE END StartDefaultTask */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Private application code --------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN Application */
|
|
||||||
|
|
||||||
/* USER CODE END Application */
|
|
||||||
|
|
||||||
+15
-1
@@ -56,6 +56,9 @@ void MX_GPIO_Init(void)
|
|||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
|
||||||
|
|
||||||
/*Configure GPIO pin : PC13 */
|
/*Configure GPIO pin : PC13 */
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_13;
|
GPIO_InitStruct.Pin = GPIO_PIN_13;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
@@ -65,7 +68,7 @@ void MX_GPIO_Init(void)
|
|||||||
|
|
||||||
/*Configure GPIO pin : PB0 */
|
/*Configure GPIO pin : PB0 */
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
GPIO_InitStruct.Pin = GPIO_PIN_0;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
@@ -76,6 +79,17 @@ void MX_GPIO_Init(void)
|
|||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : PA4 */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_4;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* EXTI interrupt init*/
|
||||||
|
HAL_NVIC_SetPriority(EXTI0_IRQn, 6, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ void MX_IWDG_Init(void)
|
|||||||
|
|
||||||
/* USER CODE END IWDG_Init 1 */
|
/* USER CODE END IWDG_Init 1 */
|
||||||
hiwdg.Instance = IWDG;
|
hiwdg.Instance = IWDG;
|
||||||
hiwdg.Init.Prescaler = IWDG_PRESCALER_4;
|
hiwdg.Init.Prescaler = IWDG_PRESCALER_64;
|
||||||
hiwdg.Init.Reload = 4095;
|
hiwdg.Init.Reload = 4095;
|
||||||
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
|
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
|
||||||
{
|
{
|
||||||
|
|||||||
+549
-105
@@ -4,136 +4,567 @@
|
|||||||
* @file : main.c
|
* @file : main.c
|
||||||
* @brief : Main program body
|
* @brief : Main program body
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2026 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
*/
|
||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "cmsis_os.h"
|
|
||||||
#include "dma.h"
|
#include "dma.h"
|
||||||
#include "iwdg.h"
|
#include "iwdg.h"
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
|
#include "tim.h"
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "CH390.h"
|
||||||
|
#include "CH390_Interface.h"
|
||||||
|
#include "SEGGER_RTT.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "ethernetif.h"
|
||||||
|
#include "ch390_runtime.h"
|
||||||
|
#include "lwip/init.h"
|
||||||
|
#include "lwip/timeouts.h"
|
||||||
|
#include "tcp_client.h"
|
||||||
|
#include "tcp_server.h"
|
||||||
|
#include "uart_trans.h"
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PTD */
|
|
||||||
|
|
||||||
/* USER CODE END PTD */
|
|
||||||
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN PD */
|
/* USER CODE BEGIN PD */
|
||||||
|
#define LED_PIN GPIO_PIN_13
|
||||||
|
#define LED_PORT GPIOC
|
||||||
|
#define APP_ROUTE_BUFFER_SIZE 256u
|
||||||
|
#define STACK_GUARD_WORD 0xA5A5A5A5u
|
||||||
|
#define APP_HEALTH_CHECK_INTERVAL_MS 5000u
|
||||||
/* USER CODE END PD */
|
/* USER CODE END PD */
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PM */
|
|
||||||
|
|
||||||
/* USER CODE END PM */
|
|
||||||
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
/* USER CODE BEGIN PV */
|
/* USER CODE BEGIN PV */
|
||||||
|
static volatile uint16_t g_led_blink_ticks = 0;
|
||||||
|
static uint8_t g_clock_fallback_to_hsi = 0u;
|
||||||
|
volatile uint8_t g_uart1_rx_probe_byte = 0u;
|
||||||
|
static uint8_t g_stack_guard_reported = 0u;
|
||||||
|
static uint8_t g_mux_response_frame[272];
|
||||||
|
static uint8_t g_links_started = 0u;
|
||||||
/* USER CODE END PV */
|
/* USER CODE END PV */
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
void SystemClock_Config(void);
|
void SystemClock_Config(void);
|
||||||
void MX_FREERTOS_Init(void);
|
|
||||||
/* USER CODE BEGIN PFP */
|
/* USER CODE BEGIN PFP */
|
||||||
|
static void LED_Init(void);
|
||||||
|
static void LED_StartBlink(void);
|
||||||
|
static void BootDiag_ReportCh390(void);
|
||||||
|
static void App_Init(void);
|
||||||
|
static void App_Poll(void);
|
||||||
|
static void App_ConfigureLinks(const device_config_t *cfg);
|
||||||
|
static void App_RouteRawUartTraffic(void);
|
||||||
|
static void App_RouteMuxUartTraffic(void);
|
||||||
|
static void App_RouteTcpTraffic(void);
|
||||||
|
static void StackGuard_Init(void);
|
||||||
|
static void StackGuard_Check(void);
|
||||||
|
static bool App_SendToUart(uint8_t uart_index, uint8_t src_id, uint8_t dst_mask, const uint8_t *data, uint16_t len);
|
||||||
|
static bool App_SendTcpServerPayload(uint8_t instance, const uint8_t *data, uint16_t len);
|
||||||
|
static bool App_SendTcpClientPayload(uint8_t instance, const uint8_t *data, uint16_t len);
|
||||||
/* USER CODE END PFP */
|
/* USER CODE END PFP */
|
||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
|
extern uint32_t Stack_Mem[];
|
||||||
|
|
||||||
|
static void LED_Init(void)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(LED_PORT, LED_PIN, GPIO_PIN_SET);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StackGuard_Init(void)
|
||||||
|
{
|
||||||
|
Stack_Mem[0] = STACK_GUARD_WORD;
|
||||||
|
g_stack_guard_reported = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StackGuard_Check(void)
|
||||||
|
{
|
||||||
|
if (Stack_Mem[0] != STACK_GUARD_WORD) {
|
||||||
|
if (g_stack_guard_reported == 0u) {
|
||||||
|
g_stack_guard_reported = 1u;
|
||||||
|
SEGGER_RTT_WriteString(0, "ERROR: Main stack guard overwritten\r\n");
|
||||||
|
}
|
||||||
|
__disable_irq();
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void LED_StartBlink(void)
|
||||||
|
{
|
||||||
|
if (HAL_TIM_Base_Start_IT(&htim4) != HAL_OK) {
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LED_Toggle(void)
|
||||||
|
{
|
||||||
|
HAL_GPIO_TogglePin(LED_PORT, LED_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||||
|
{
|
||||||
|
if (htim->Instance == TIM4) {
|
||||||
|
g_led_blink_ticks++;
|
||||||
|
if (g_led_blink_ticks >= 1000u) {
|
||||||
|
g_led_blink_ticks = 0u;
|
||||||
|
LED_Toggle();
|
||||||
|
if (hiwdg.Instance == IWDG) {
|
||||||
|
HAL_IWDG_Refresh(&hiwdg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void BootDiag_ReportCh390(void)
|
||||||
|
{
|
||||||
|
ch390_diag_t diag;
|
||||||
|
const device_config_t *cfg = config_get();
|
||||||
|
uint8_t mac_hw[6];
|
||||||
|
|
||||||
|
ch390_runtime_get_diag(&diag);
|
||||||
|
ch390_get_mac(mac_hw);
|
||||||
|
|
||||||
|
SEGGER_RTT_printf(0,
|
||||||
|
"CH390 VID=0x%04X PID=0x%04X REV=0x%02X LINK=%u MAC=%02X:%02X:%02X:%02X:%02X:%02X\r\n",
|
||||||
|
diag.vendor_id,
|
||||||
|
diag.product_id,
|
||||||
|
diag.revision,
|
||||||
|
diag.link_up,
|
||||||
|
mac_hw[0], mac_hw[1], mac_hw[2], mac_hw[3], mac_hw[4], mac_hw[5]);
|
||||||
|
SEGGER_RTT_printf(0,
|
||||||
|
"NET cfg IP=%u.%u.%u.%u MASK=%u.%u.%u.%u GW=%u.%u.%u.%u MUX=%u\r\n",
|
||||||
|
cfg->net.ip[0], cfg->net.ip[1], cfg->net.ip[2], cfg->net.ip[3],
|
||||||
|
cfg->net.mask[0], cfg->net.mask[1], cfg->net.mask[2], cfg->net.mask[3],
|
||||||
|
cfg->net.gw[0], cfg->net.gw[1], cfg->net.gw[2], cfg->net.gw[3],
|
||||||
|
cfg->mux_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void App_ConfigureLinks(const device_config_t *cfg)
|
||||||
|
{
|
||||||
|
tcp_server_instance_config_t server_cfg;
|
||||||
|
tcp_client_instance_config_t client_cfg;
|
||||||
|
|
||||||
|
(void)tcp_server_init_all();
|
||||||
|
(void)tcp_client_init_all();
|
||||||
|
|
||||||
|
server_cfg.enabled = (cfg->links[CONFIG_LINK_S1].enabled != 0u);
|
||||||
|
server_cfg.port = cfg->links[CONFIG_LINK_S1].local_port;
|
||||||
|
(void)tcp_server_config(0u, &server_cfg);
|
||||||
|
|
||||||
|
server_cfg.enabled = (cfg->links[CONFIG_LINK_S2].enabled != 0u);
|
||||||
|
server_cfg.port = cfg->links[CONFIG_LINK_S2].local_port;
|
||||||
|
(void)tcp_server_config(1u, &server_cfg);
|
||||||
|
|
||||||
|
memcpy(client_cfg.remote_ip, cfg->links[CONFIG_LINK_C1].remote_ip, sizeof(client_cfg.remote_ip));
|
||||||
|
client_cfg.local_port = cfg->links[CONFIG_LINK_C1].local_port;
|
||||||
|
client_cfg.remote_port = cfg->links[CONFIG_LINK_C1].remote_port;
|
||||||
|
client_cfg.reconnect_interval_ms = TCP_CLIENT_RECONNECT_DELAY_MS;
|
||||||
|
client_cfg.enabled = (cfg->links[CONFIG_LINK_C1].enabled != 0u);
|
||||||
|
client_cfg.auto_reconnect = true;
|
||||||
|
(void)tcp_client_config(0u, &client_cfg);
|
||||||
|
|
||||||
|
memcpy(client_cfg.remote_ip, cfg->links[CONFIG_LINK_C2].remote_ip, sizeof(client_cfg.remote_ip));
|
||||||
|
client_cfg.local_port = cfg->links[CONFIG_LINK_C2].local_port;
|
||||||
|
client_cfg.remote_port = cfg->links[CONFIG_LINK_C2].remote_port;
|
||||||
|
client_cfg.enabled = (cfg->links[CONFIG_LINK_C2].enabled != 0u);
|
||||||
|
(void)tcp_client_config(1u, &client_cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void App_StartLinksIfNeeded(void)
|
||||||
|
{
|
||||||
|
int any_failed;
|
||||||
|
|
||||||
|
if ((g_links_started != 0u) || !netif_is_link_up(&ch390_netif)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
any_failed = 0;
|
||||||
|
for (uint8_t i = 0; i < TCP_SERVER_INSTANCE_COUNT; ++i) {
|
||||||
|
if (tcp_server_start(i) != 0) {
|
||||||
|
any_failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < TCP_CLIENT_INSTANCE_COUNT; ++i) {
|
||||||
|
if (tcp_client_connect(i) != 0) {
|
||||||
|
any_failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (any_failed) {
|
||||||
|
SEGGER_RTT_WriteString(0, "NET links start partially failed, will retry\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_links_started = 1u;
|
||||||
|
SEGGER_RTT_WriteString(0, "NET links started after link-up\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void App_StopLinksIfNeeded(void)
|
||||||
|
{
|
||||||
|
if (netif_is_link_up(&ch390_netif)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_links_started != 0u) {
|
||||||
|
for (uint8_t i = 0; i < TCP_CLIENT_INSTANCE_COUNT; ++i) {
|
||||||
|
(void)tcp_client_disconnect(i);
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < TCP_SERVER_INSTANCE_COUNT; ++i) {
|
||||||
|
(void)tcp_server_stop(i);
|
||||||
|
}
|
||||||
|
SEGGER_RTT_WriteString(0, "NET links stopped after link-down\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_links_started = 0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void App_Init(void)
|
||||||
|
{
|
||||||
|
const device_config_t *cfg;
|
||||||
|
ip4_addr_t ipaddr;
|
||||||
|
ip4_addr_t netmask;
|
||||||
|
ip4_addr_t gateway;
|
||||||
|
uart_config_t uart_cfg;
|
||||||
|
|
||||||
|
(void)config_init();
|
||||||
|
cfg = config_get();
|
||||||
|
|
||||||
|
(void)uart_trans_init();
|
||||||
|
uart_cfg.baudrate = cfg->uart_baudrate[0];
|
||||||
|
(void)uart_trans_config(UART_CHANNEL_U0, &uart_cfg);
|
||||||
|
uart_cfg.baudrate = cfg->uart_baudrate[1];
|
||||||
|
(void)uart_trans_config(UART_CHANNEL_U1, &uart_cfg);
|
||||||
|
(void)uart_trans_start(UART_CHANNEL_U0);
|
||||||
|
(void)uart_trans_start(UART_CHANNEL_U1);
|
||||||
|
|
||||||
|
SEGGER_RTT_Init();
|
||||||
|
StackGuard_Init();
|
||||||
|
SEGGER_RTT_WriteString(0, "\r\nTCP2UART boot\r\n");
|
||||||
|
if (g_clock_fallback_to_hsi != 0u) {
|
||||||
|
SEGGER_RTT_WriteString(0, "WARN: HSE start failed, fallback to HSI PLL\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
lwip_init();
|
||||||
|
IP4_ADDR(&ipaddr, cfg->net.ip[0], cfg->net.ip[1], cfg->net.ip[2], cfg->net.ip[3]);
|
||||||
|
IP4_ADDR(&netmask, cfg->net.mask[0], cfg->net.mask[1], cfg->net.mask[2], cfg->net.mask[3]);
|
||||||
|
IP4_ADDR(&gateway, cfg->net.gw[0], cfg->net.gw[1], cfg->net.gw[2], cfg->net.gw[3]);
|
||||||
|
lwip_netif_init(&ipaddr, &netmask, &gateway);
|
||||||
|
App_ConfigureLinks(cfg);
|
||||||
|
BootDiag_ReportCh390();
|
||||||
|
|
||||||
|
if (HAL_UART_Receive_IT(&huart1, (uint8_t *)&g_uart1_rx_probe_byte, 1u) != HAL_OK) {
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool App_SendTcpServerPayload(uint8_t instance, const uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
return tcp_server_send(instance, data, len) == (int)len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool App_SendTcpClientPayload(uint8_t instance, const uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
return tcp_client_send(instance, data, len) == (int)len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool App_SendToUart(uint8_t uart_index, uint8_t src_id, uint8_t dst_mask, const uint8_t *data, uint16_t len)
|
||||||
|
{
|
||||||
|
const device_config_t *cfg = config_get();
|
||||||
|
uart_channel_t channel = (uart_index == LINK_UART_U1) ? UART_CHANNEL_U1 : UART_CHANNEL_U0;
|
||||||
|
uint16_t written;
|
||||||
|
|
||||||
|
if (cfg->mux_mode == MUX_MODE_FRAME) {
|
||||||
|
uint8_t frame[APP_ROUTE_BUFFER_SIZE + 6u];
|
||||||
|
uint16_t frame_len = 0u;
|
||||||
|
if (uart_mux_encode_frame(src_id, dst_mask, data, len, frame, &frame_len, sizeof(frame))) {
|
||||||
|
written = uart_trans_write(channel, frame, frame_len);
|
||||||
|
return written == frame_len;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
written = uart_trans_write(channel, data, len);
|
||||||
|
return written == len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void App_RouteTcpTraffic(void)
|
||||||
|
{
|
||||||
|
const device_config_t *cfg = config_get();
|
||||||
|
uint8_t buffer[APP_ROUTE_BUFFER_SIZE];
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < TCP_SERVER_INSTANCE_COUNT; ++i) {
|
||||||
|
int rc = tcp_server_recv(i, buffer, sizeof(buffer));
|
||||||
|
if (rc > 0) {
|
||||||
|
uint8_t link_index = (i == 0u) ? CONFIG_LINK_S1 : CONFIG_LINK_S2;
|
||||||
|
if (!App_SendToUart(cfg->links[link_index].uart,
|
||||||
|
config_link_index_to_endpoint(link_index),
|
||||||
|
config_uart_index_to_endpoint(cfg->links[link_index].uart),
|
||||||
|
buffer,
|
||||||
|
(uint16_t)rc)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < TCP_CLIENT_INSTANCE_COUNT; ++i) {
|
||||||
|
int rc = tcp_client_recv(i, buffer, sizeof(buffer));
|
||||||
|
if (rc > 0) {
|
||||||
|
uint8_t link_index = (i == 0u) ? CONFIG_LINK_C1 : CONFIG_LINK_C2;
|
||||||
|
if (!App_SendToUart(cfg->links[link_index].uart,
|
||||||
|
config_link_index_to_endpoint(link_index),
|
||||||
|
config_uart_index_to_endpoint(cfg->links[link_index].uart),
|
||||||
|
buffer,
|
||||||
|
(uint16_t)rc)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void App_RouteRawUartTraffic(void)
|
||||||
|
{
|
||||||
|
const device_config_t *cfg = config_get();
|
||||||
|
uint8_t buffer[APP_ROUTE_BUFFER_SIZE];
|
||||||
|
uint16_t len;
|
||||||
|
|
||||||
|
len = uart_trans_read(UART_CHANNEL_U0, buffer, sizeof(buffer));
|
||||||
|
if (len > 0u) {
|
||||||
|
bool routed_ok = true;
|
||||||
|
for (uint8_t i = 0; i < CONFIG_LINK_COUNT; ++i) {
|
||||||
|
bool sent = true;
|
||||||
|
if (cfg->links[i].enabled == 0u || cfg->links[i].uart != LINK_UART_U0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i == CONFIG_LINK_S1) {
|
||||||
|
sent = App_SendTcpServerPayload(0u, buffer, len);
|
||||||
|
} else if (i == CONFIG_LINK_S2) {
|
||||||
|
sent = App_SendTcpServerPayload(1u, buffer, len);
|
||||||
|
} else if (i == CONFIG_LINK_C1) {
|
||||||
|
sent = App_SendTcpClientPayload(0u, buffer, len);
|
||||||
|
} else if (i == CONFIG_LINK_C2) {
|
||||||
|
sent = App_SendTcpClientPayload(1u, buffer, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sent) {
|
||||||
|
routed_ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!routed_ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
len = uart_trans_read(UART_CHANNEL_U1, buffer, sizeof(buffer));
|
||||||
|
if (len > 0u) {
|
||||||
|
bool routed_ok = true;
|
||||||
|
for (uint8_t i = 0; i < CONFIG_LINK_COUNT; ++i) {
|
||||||
|
bool sent = true;
|
||||||
|
if (cfg->links[i].enabled == 0u || cfg->links[i].uart != LINK_UART_U1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i == CONFIG_LINK_S1) {
|
||||||
|
sent = App_SendTcpServerPayload(0u, buffer, len);
|
||||||
|
} else if (i == CONFIG_LINK_S2) {
|
||||||
|
sent = App_SendTcpServerPayload(1u, buffer, len);
|
||||||
|
} else if (i == CONFIG_LINK_C1) {
|
||||||
|
sent = App_SendTcpClientPayload(0u, buffer, len);
|
||||||
|
} else if (i == CONFIG_LINK_C2) {
|
||||||
|
sent = App_SendTcpClientPayload(1u, buffer, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sent) {
|
||||||
|
routed_ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!routed_ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void App_RouteMuxUartTraffic(void)
|
||||||
|
{
|
||||||
|
uart_mux_frame_t frame;
|
||||||
|
const device_config_t *cfg = config_get();
|
||||||
|
bool routed_ok;
|
||||||
|
|
||||||
|
while (uart_mux_try_extract_frame(UART_CHANNEL_U0, &frame)) {
|
||||||
|
#if defined(DEBUG) && (DEBUG != 0)
|
||||||
|
SEGGER_RTT_printf(0, "Mux frame from UART0: src_id=%u dst_mask=0x%02X len=%u\r\n", frame.src_id, frame.dst_mask, frame.payload_len);
|
||||||
|
#endif
|
||||||
|
if (frame.dst_mask == 0u) {
|
||||||
|
at_result_t result;
|
||||||
|
char *response_text = (char *)&g_mux_response_frame[5];
|
||||||
|
if (config_build_response_frame(frame.payload, frame.payload_len, response_text, (uint16_t)(sizeof(g_mux_response_frame) - 6u), &result)) {
|
||||||
|
uint16_t response_len = (uint16_t)strlen(response_text);
|
||||||
|
uint16_t frame_len = 0u;
|
||||||
|
if (uart_mux_encode_frame(config_uart_index_to_endpoint(LINK_UART_U0), 0u, (const uint8_t *)response_text, response_len, g_mux_response_frame, &frame_len, sizeof(g_mux_response_frame))) {
|
||||||
|
if (uart_trans_write(UART_CHANNEL_U0, g_mux_response_frame, frame_len) != frame_len) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result == AT_NEED_REBOOT) {
|
||||||
|
static const char hint[] = "Note: Use AT+SAVE then AT+RESET to apply changes\r\n";
|
||||||
|
response_len = (uint16_t)strlen(hint);
|
||||||
|
if (uart_mux_encode_frame(config_uart_index_to_endpoint(LINK_UART_U0), 0u, (const uint8_t *)hint, response_len, g_mux_response_frame, &frame_len, sizeof(g_mux_response_frame))) {
|
||||||
|
if (uart_trans_write(UART_CHANNEL_U0, g_mux_response_frame, frame_len) != frame_len) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
routed_ok = true;
|
||||||
|
if ((frame.dst_mask & ENDPOINT_S1) != 0u) {
|
||||||
|
routed_ok = App_SendTcpServerPayload(0u, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
if ((frame.dst_mask & ENDPOINT_S2) != 0u) {
|
||||||
|
routed_ok = App_SendTcpServerPayload(1u, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
if ((frame.dst_mask & ENDPOINT_C1) != 0u) {
|
||||||
|
routed_ok = App_SendTcpClientPayload(0u, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
if ((frame.dst_mask & ENDPOINT_C2) != 0u) {
|
||||||
|
routed_ok = App_SendTcpClientPayload(1u, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
if ((frame.dst_mask & ENDPOINT_UART3) != 0u && cfg->links[CONFIG_LINK_S2].uart == LINK_UART_U1) {
|
||||||
|
routed_ok = App_SendToUart(LINK_UART_U1, frame.src_id, ENDPOINT_UART3, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!routed_ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (uart_mux_try_extract_frame(UART_CHANNEL_U1, &frame)) {
|
||||||
|
#if defined(DEBUG) && (DEBUG != 0)
|
||||||
|
SEGGER_RTT_printf(0, "Mux frame from UART1: src_id=%u dst_mask=0x%02X len=%u\r\n", frame.src_id, frame.dst_mask, frame.payload_len);
|
||||||
|
#endif
|
||||||
|
if (frame.dst_mask == 0u) {
|
||||||
|
at_result_t result;
|
||||||
|
char *response_text = (char *)&g_mux_response_frame[5];
|
||||||
|
if (config_build_response_frame(frame.payload, frame.payload_len, response_text, (uint16_t)(sizeof(g_mux_response_frame) - 6u), &result)) {
|
||||||
|
uint16_t response_len = (uint16_t)strlen(response_text);
|
||||||
|
uint16_t frame_len = 0u;
|
||||||
|
if (uart_mux_encode_frame(config_uart_index_to_endpoint(LINK_UART_U1), 0u, (const uint8_t *)response_text, response_len, g_mux_response_frame, &frame_len, sizeof(g_mux_response_frame))) {
|
||||||
|
if (uart_trans_write(UART_CHANNEL_U1, g_mux_response_frame, frame_len) != frame_len) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result == AT_NEED_REBOOT) {
|
||||||
|
static const char hint[] = "Note: Use AT+SAVE then AT+RESET to apply changes\r\n";
|
||||||
|
response_len = (uint16_t)strlen(hint);
|
||||||
|
if (uart_mux_encode_frame(config_uart_index_to_endpoint(LINK_UART_U1), 0u, (const uint8_t *)hint, response_len, g_mux_response_frame, &frame_len, sizeof(g_mux_response_frame))) {
|
||||||
|
if (uart_trans_write(UART_CHANNEL_U1, g_mux_response_frame, frame_len) != frame_len) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
routed_ok = true;
|
||||||
|
if ((frame.dst_mask & ENDPOINT_S1) != 0u) {
|
||||||
|
routed_ok = App_SendTcpServerPayload(0u, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
if ((frame.dst_mask & ENDPOINT_S2) != 0u) {
|
||||||
|
routed_ok = App_SendTcpServerPayload(1u, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
if ((frame.dst_mask & ENDPOINT_C1) != 0u) {
|
||||||
|
routed_ok = App_SendTcpClientPayload(0u, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
if ((frame.dst_mask & ENDPOINT_C2) != 0u) {
|
||||||
|
routed_ok = App_SendTcpClientPayload(1u, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
if ((frame.dst_mask & ENDPOINT_UART2) != 0u) {
|
||||||
|
routed_ok = App_SendToUart(LINK_UART_U0, frame.src_id, ENDPOINT_UART2, frame.payload, frame.payload_len) && routed_ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!routed_ok) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void App_Poll(void)
|
||||||
|
{
|
||||||
|
static uint32_t s_health_check_tick;
|
||||||
|
uint32_t now;
|
||||||
|
|
||||||
|
ethernetif_poll();
|
||||||
|
ethernetif_check_link();
|
||||||
|
sys_check_timeouts();
|
||||||
|
App_StopLinksIfNeeded();
|
||||||
|
App_StartLinksIfNeeded();
|
||||||
|
tcp_client_poll();
|
||||||
|
uart_trans_poll();
|
||||||
|
StackGuard_Check();
|
||||||
|
config_poll();
|
||||||
|
App_RouteTcpTraffic();
|
||||||
|
|
||||||
|
if (config_get()->mux_mode == MUX_MODE_FRAME) {
|
||||||
|
App_RouteMuxUartTraffic();
|
||||||
|
} else {
|
||||||
|
App_RouteRawUartTraffic();
|
||||||
|
}
|
||||||
|
|
||||||
|
now = HAL_GetTick();
|
||||||
|
if ((now - s_health_check_tick) >= APP_HEALTH_CHECK_INTERVAL_MS) {
|
||||||
|
s_health_check_tick = now;
|
||||||
|
ch390_runtime_health_check(&ch390_netif);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config_is_reset_requested()) {
|
||||||
|
config_clear_reset_requested();
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief The application entry point.
|
|
||||||
* @retval int
|
|
||||||
*/
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
|
||||||
|
|
||||||
/* MCU Configuration--------------------------------------------------------*/
|
|
||||||
|
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
|
||||||
HAL_Init();
|
HAL_Init();
|
||||||
|
|
||||||
/* USER CODE BEGIN Init */
|
|
||||||
|
|
||||||
/* USER CODE END Init */
|
|
||||||
|
|
||||||
/* Configure the system clock */
|
|
||||||
SystemClock_Config();
|
SystemClock_Config();
|
||||||
|
|
||||||
/* USER CODE BEGIN SysInit */
|
|
||||||
|
|
||||||
/* USER CODE END SysInit */
|
|
||||||
|
|
||||||
/* Initialize all configured peripherals */
|
|
||||||
MX_GPIO_Init();
|
MX_GPIO_Init();
|
||||||
MX_DMA_Init();
|
MX_DMA_Init();
|
||||||
MX_IWDG_Init();
|
|
||||||
MX_USART1_UART_Init();
|
MX_USART1_UART_Init();
|
||||||
MX_USART2_UART_Init();
|
MX_USART2_UART_Init();
|
||||||
MX_USART3_UART_Init();
|
MX_USART3_UART_Init();
|
||||||
MX_SPI1_Init();
|
MX_SPI1_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
MX_TIM4_Init();
|
||||||
|
MX_IWDG_Init();
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
LED_Init();
|
||||||
|
LED_StartBlink();
|
||||||
|
App_Init();
|
||||||
|
|
||||||
/* Init scheduler */
|
|
||||||
osKernelInitialize(); /* Call init function for freertos objects (in cmsis_os2.c) */
|
|
||||||
MX_FREERTOS_Init();
|
|
||||||
|
|
||||||
/* Start scheduler */
|
|
||||||
osKernelStart();
|
|
||||||
|
|
||||||
/* We should never get here as control is now taken by the scheduler */
|
|
||||||
|
|
||||||
/* Infinite loop */
|
|
||||||
/* USER CODE BEGIN WHILE */
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
/* USER CODE END WHILE */
|
App_Poll();
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
|
||||||
}
|
}
|
||||||
/* USER CODE END 3 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief System Clock Configuration
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void SystemClock_Config(void)
|
void SystemClock_Config(void)
|
||||||
{
|
{
|
||||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||||
|
|
||||||
/** Initializes the RCC Oscillators according to the specified parameters
|
g_clock_fallback_to_hsi = 0u;
|
||||||
* in the RCC_OscInitTypeDef structure.
|
|
||||||
*/
|
|
||||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
|
||||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||||
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
|
RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
|
||||||
@@ -142,13 +573,20 @@ void SystemClock_Config(void)
|
|||||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
|
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
|
||||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||||
{
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_HSI;
|
||||||
Error_Handler();
|
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
|
||||||
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
|
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
||||||
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||||
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2;
|
||||||
|
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16;
|
||||||
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
g_clock_fallback_to_hsi = 1u;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes the CPU, AHB and APB buses clocks
|
|
||||||
*/
|
|
||||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
@@ -162,37 +600,43 @@ void SystemClock_Config(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 4 */
|
#ifdef __GNUC__
|
||||||
|
int _write(int file, char *ptr, int len)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
return (int)SEGGER_RTT_Write(0, ptr, (unsigned)len);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int fputc(int ch, FILE *f)
|
||||||
|
{
|
||||||
|
(void)f;
|
||||||
|
SEGGER_RTT_PutChar(0, (char)ch);
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* USER CODE END 4 */
|
void Debug_TrapWithRttHint(const char *tag)
|
||||||
|
{
|
||||||
|
SEGGER_RTT_WriteString(0, "\r\nTRAP: ");
|
||||||
|
SEGGER_RTT_WriteString(0, tag);
|
||||||
|
SEGGER_RTT_WriteString(0, "\r\n");
|
||||||
|
__disable_irq();
|
||||||
|
__BKPT(0);
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function is executed in case of error occurrence.
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void Error_Handler(void)
|
void Error_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN Error_Handler_Debug */
|
Debug_TrapWithRttHint("Error_Handler");
|
||||||
/* User can add his own implementation to report the HAL error return state */
|
|
||||||
__disable_irq();
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
/* USER CODE END Error_Handler_Debug */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FULL_ASSERT
|
#ifdef USE_FULL_ASSERT
|
||||||
/**
|
|
||||||
* @brief Reports the name of the source file and the source line number
|
|
||||||
* where the assert_param error has occurred.
|
|
||||||
* @param file: pointer to the source file name
|
|
||||||
* @param line: assert_param error line source number
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
void assert_failed(uint8_t *file, uint32_t line)
|
void assert_failed(uint8_t *file, uint32_t line)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN 6 */
|
(void)file;
|
||||||
/* User can add his own implementation to report the file name and line number,
|
(void)line;
|
||||||
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
Debug_TrapWithRttHint("assert_failed");
|
||||||
/* USER CODE END 6 */
|
|
||||||
}
|
}
|
||||||
#endif /* USE_FULL_ASSERT */
|
#endif
|
||||||
|
|||||||
+15
-7
@@ -41,10 +41,10 @@ void MX_SPI1_Init(void)
|
|||||||
hspi1.Init.Mode = SPI_MODE_MASTER;
|
hspi1.Init.Mode = SPI_MODE_MASTER;
|
||||||
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
|
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
|
||||||
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
|
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||||
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
|
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; /* Match CH390 runtime baseline: CPOL=Low */
|
||||||
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
|
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE; /* Match CH390 runtime baseline: CPHA=1Edge (Mode 0) */
|
||||||
hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT;
|
hspi1.Init.NSS = SPI_NSS_SOFT; /* Software CS control for CH390 */
|
||||||
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
|
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; /* 72MHz/2 = 36MHz, max SPI1 clock at current APB2 */
|
||||||
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||||
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||||
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||||
@@ -73,20 +73,28 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
|||||||
|
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
/**SPI1 GPIO Configuration
|
/**SPI1 GPIO Configuration
|
||||||
PA4 ------> SPI1_NSS
|
PA4 ------> GPIO_Output
|
||||||
PA5 ------> SPI1_SCK
|
PA5 ------> SPI1_SCK
|
||||||
PA6 ------> SPI1_MISO
|
PA6 ------> SPI1_MISO
|
||||||
PA7 ------> SPI1_MOSI
|
PA7 ------> SPI1_MOSI
|
||||||
*/
|
*/
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7;
|
/* SCK and MOSI as AF Push-Pull */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* MISO as Input */
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
GPIO_InitStruct.Pin = GPIO_PIN_6;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_4;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* SPI1 interrupt Init */
|
/* SPI1 interrupt Init */
|
||||||
HAL_NVIC_SetPriority(SPI1_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(SPI1_IRQn, 5, 0);
|
||||||
@@ -109,7 +117,7 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
|
|||||||
__HAL_RCC_SPI1_CLK_DISABLE();
|
__HAL_RCC_SPI1_CLK_DISABLE();
|
||||||
|
|
||||||
/**SPI1 GPIO Configuration
|
/**SPI1 GPIO Configuration
|
||||||
PA4 ------> SPI1_NSS
|
PA4 ------> GPIO_Output
|
||||||
PA5 ------> SPI1_SCK
|
PA5 ------> SPI1_SCK
|
||||||
PA6 ------> SPI1_MISO
|
PA6 ------> SPI1_MISO
|
||||||
PA7 ------> SPI1_MOSI
|
PA7 ------> SPI1_MOSI
|
||||||
|
|||||||
@@ -71,8 +71,6 @@ void HAL_MspInit(void)
|
|||||||
__HAL_RCC_PWR_CLK_ENABLE();
|
__HAL_RCC_PWR_CLK_ENABLE();
|
||||||
|
|
||||||
/* System interrupt init*/
|
/* System interrupt init*/
|
||||||
/* PendSV_IRQn interrupt configuration */
|
|
||||||
HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
|
|
||||||
|
|
||||||
/** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
/** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
||||||
*/
|
*/
|
||||||
|
|||||||
+73
-233
@@ -4,60 +4,17 @@
|
|||||||
* @file stm32f1xx_it.c
|
* @file stm32f1xx_it.c
|
||||||
* @brief Interrupt Service Routines.
|
* @brief Interrupt Service Routines.
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2026 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
*/
|
||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "stm32f1xx_it.h"
|
#include "stm32f1xx_it.h"
|
||||||
#include "FreeRTOS.h"
|
#include "ethernetif.h"
|
||||||
#include "task.h"
|
#include "uart_trans.h"
|
||||||
/* Private includes ----------------------------------------------------------*/
|
#include "config.h"
|
||||||
/* USER CODE BEGIN Includes */
|
|
||||||
/* USER CODE END Includes */
|
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN TD */
|
|
||||||
|
|
||||||
/* USER CODE END TD */
|
|
||||||
|
|
||||||
/* Private define ------------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PD */
|
|
||||||
|
|
||||||
/* USER CODE END PD */
|
|
||||||
|
|
||||||
/* Private macro -------------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PM */
|
|
||||||
|
|
||||||
/* USER CODE END PM */
|
|
||||||
|
|
||||||
/* Private variables ---------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PV */
|
|
||||||
|
|
||||||
/* USER CODE END PV */
|
|
||||||
|
|
||||||
/* Private function prototypes -----------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN PFP */
|
|
||||||
|
|
||||||
/* USER CODE END PFP */
|
|
||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
|
||||||
/* USER CODE BEGIN 0 */
|
|
||||||
|
|
||||||
/* USER CODE END 0 */
|
|
||||||
|
|
||||||
/* External variables --------------------------------------------------------*/
|
|
||||||
extern SPI_HandleTypeDef hspi1;
|
extern SPI_HandleTypeDef hspi1;
|
||||||
|
extern TIM_HandleTypeDef htim4;
|
||||||
extern DMA_HandleTypeDef hdma_usart1_rx;
|
extern DMA_HandleTypeDef hdma_usart1_rx;
|
||||||
extern DMA_HandleTypeDef hdma_usart1_tx;
|
extern DMA_HandleTypeDef hdma_usart1_tx;
|
||||||
extern DMA_HandleTypeDef hdma_usart2_rx;
|
extern DMA_HandleTypeDef hdma_usart2_rx;
|
||||||
@@ -67,270 +24,153 @@ extern DMA_HandleTypeDef hdma_usart3_tx;
|
|||||||
extern UART_HandleTypeDef huart1;
|
extern UART_HandleTypeDef huart1;
|
||||||
extern UART_HandleTypeDef huart2;
|
extern UART_HandleTypeDef huart2;
|
||||||
extern UART_HandleTypeDef huart3;
|
extern UART_HandleTypeDef huart3;
|
||||||
/* USER CODE BEGIN EV */
|
extern volatile uint8_t g_uart1_rx_probe_byte;
|
||||||
|
|
||||||
/* USER CODE END EV */
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
|
||||||
/******************************************************************************/
|
|
||||||
/**
|
|
||||||
* @brief This function handles Non maskable interrupt.
|
|
||||||
*/
|
|
||||||
void NMI_Handler(void)
|
void NMI_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
Debug_TrapWithRttHint("NMI_Handler");
|
||||||
|
|
||||||
/* USER CODE END NonMaskableInt_IRQn 0 */
|
|
||||||
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
/* USER CODE END NonMaskableInt_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles Hard fault interrupt.
|
|
||||||
*/
|
|
||||||
void HardFault_Handler(void)
|
void HardFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN HardFault_IRQn 0 */
|
Debug_TrapWithRttHint("HardFault_Handler");
|
||||||
|
|
||||||
/* USER CODE END HardFault_IRQn 0 */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
|
|
||||||
/* USER CODE END W1_HardFault_IRQn 0 */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles Memory management fault.
|
|
||||||
*/
|
|
||||||
void MemManage_Handler(void)
|
void MemManage_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
Debug_TrapWithRttHint("MemManage_Handler");
|
||||||
|
|
||||||
/* USER CODE END MemoryManagement_IRQn 0 */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
|
|
||||||
/* USER CODE END W1_MemoryManagement_IRQn 0 */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles Prefetch fault, memory access fault.
|
|
||||||
*/
|
|
||||||
void BusFault_Handler(void)
|
void BusFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN BusFault_IRQn 0 */
|
Debug_TrapWithRttHint("BusFault_Handler");
|
||||||
|
|
||||||
/* USER CODE END BusFault_IRQn 0 */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
|
|
||||||
/* USER CODE END W1_BusFault_IRQn 0 */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles Undefined instruction or illegal state.
|
|
||||||
*/
|
|
||||||
void UsageFault_Handler(void)
|
void UsageFault_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
Debug_TrapWithRttHint("UsageFault_Handler");
|
||||||
|
|
||||||
/* USER CODE END UsageFault_IRQn 0 */
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
|
|
||||||
/* USER CODE END W1_UsageFault_IRQn 0 */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles Debug monitor.
|
|
||||||
*/
|
|
||||||
void DebugMon_Handler(void)
|
void DebugMon_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END DebugMonitor_IRQn 0 */
|
|
||||||
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END DebugMonitor_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles System tick timer.
|
|
||||||
*/
|
|
||||||
void SysTick_Handler(void)
|
void SysTick_Handler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END SysTick_IRQn 0 */
|
|
||||||
HAL_IncTick();
|
HAL_IncTick();
|
||||||
#if (INCLUDE_xTaskGetSchedulerState == 1 )
|
|
||||||
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)
|
|
||||||
{
|
|
||||||
#endif /* INCLUDE_xTaskGetSchedulerState */
|
|
||||||
xPortSysTickHandler();
|
|
||||||
#if (INCLUDE_xTaskGetSchedulerState == 1 )
|
|
||||||
}
|
|
||||||
#endif /* INCLUDE_xTaskGetSchedulerState */
|
|
||||||
/* USER CODE BEGIN SysTick_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END SysTick_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* STM32F1xx Peripheral Interrupt Handlers */
|
|
||||||
/* Add here the Interrupt Handlers for the used peripherals. */
|
|
||||||
/* For the available peripheral interrupt handler names, */
|
|
||||||
/* please refer to the startup file (startup_stm32f1xx.s). */
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles DMA1 channel2 global interrupt.
|
|
||||||
*/
|
|
||||||
void DMA1_Channel2_IRQHandler(void)
|
void DMA1_Channel2_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel2_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel2_IRQn 0 */
|
|
||||||
HAL_DMA_IRQHandler(&hdma_usart3_tx);
|
HAL_DMA_IRQHandler(&hdma_usart3_tx);
|
||||||
/* USER CODE BEGIN DMA1_Channel2_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel2_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles DMA1 channel3 global interrupt.
|
|
||||||
*/
|
|
||||||
void DMA1_Channel3_IRQHandler(void)
|
void DMA1_Channel3_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel3_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel3_IRQn 0 */
|
|
||||||
HAL_DMA_IRQHandler(&hdma_usart3_rx);
|
HAL_DMA_IRQHandler(&hdma_usart3_rx);
|
||||||
/* USER CODE BEGIN DMA1_Channel3_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel3_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles DMA1 channel4 global interrupt.
|
|
||||||
*/
|
|
||||||
void DMA1_Channel4_IRQHandler(void)
|
void DMA1_Channel4_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel4_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel4_IRQn 0 */
|
|
||||||
HAL_DMA_IRQHandler(&hdma_usart1_tx);
|
HAL_DMA_IRQHandler(&hdma_usart1_tx);
|
||||||
/* USER CODE BEGIN DMA1_Channel4_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel4_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles DMA1 channel5 global interrupt.
|
|
||||||
*/
|
|
||||||
void DMA1_Channel5_IRQHandler(void)
|
void DMA1_Channel5_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel5_IRQn 0 */
|
|
||||||
HAL_DMA_IRQHandler(&hdma_usart1_rx);
|
HAL_DMA_IRQHandler(&hdma_usart1_rx);
|
||||||
/* USER CODE BEGIN DMA1_Channel5_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel5_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles DMA1 channel6 global interrupt.
|
|
||||||
*/
|
|
||||||
void DMA1_Channel6_IRQHandler(void)
|
void DMA1_Channel6_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel6_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel6_IRQn 0 */
|
|
||||||
HAL_DMA_IRQHandler(&hdma_usart2_rx);
|
HAL_DMA_IRQHandler(&hdma_usart2_rx);
|
||||||
/* USER CODE BEGIN DMA1_Channel6_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel6_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles DMA1 channel7 global interrupt.
|
|
||||||
*/
|
|
||||||
void DMA1_Channel7_IRQHandler(void)
|
void DMA1_Channel7_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel7_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel7_IRQn 0 */
|
|
||||||
HAL_DMA_IRQHandler(&hdma_usart2_tx);
|
HAL_DMA_IRQHandler(&hdma_usart2_tx);
|
||||||
/* USER CODE BEGIN DMA1_Channel7_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END DMA1_Channel7_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void TIM4_IRQHandler(void)
|
||||||
* @brief This function handles SPI1 global interrupt.
|
{
|
||||||
*/
|
HAL_TIM_IRQHandler(&htim4);
|
||||||
|
}
|
||||||
|
|
||||||
void SPI1_IRQHandler(void)
|
void SPI1_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN SPI1_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI1_IRQn 0 */
|
|
||||||
HAL_SPI_IRQHandler(&hspi1);
|
HAL_SPI_IRQHandler(&hspi1);
|
||||||
/* USER CODE BEGIN SPI1_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END SPI1_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles USART1 global interrupt.
|
|
||||||
*/
|
|
||||||
void USART1_IRQHandler(void)
|
void USART1_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN USART1_IRQn 0 */
|
|
||||||
|
|
||||||
/* USER CODE END USART1_IRQn 0 */
|
|
||||||
HAL_UART_IRQHandler(&huart1);
|
HAL_UART_IRQHandler(&huart1);
|
||||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END USART1_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles USART2 global interrupt.
|
|
||||||
*/
|
|
||||||
void USART2_IRQHandler(void)
|
void USART2_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN USART2_IRQn 0 */
|
if (__HAL_UART_GET_FLAG(&huart2, UART_FLAG_IDLE))
|
||||||
|
{
|
||||||
/* USER CODE END USART2_IRQn 0 */
|
__HAL_UART_CLEAR_IDLEFLAG(&huart2);
|
||||||
|
uart_trans_idle_handler(UART_CHANNEL_U0);
|
||||||
|
}
|
||||||
HAL_UART_IRQHandler(&huart2);
|
HAL_UART_IRQHandler(&huart2);
|
||||||
/* USER CODE BEGIN USART2_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END USART2_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This function handles USART3 global interrupt.
|
|
||||||
*/
|
|
||||||
void USART3_IRQHandler(void)
|
void USART3_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN USART3_IRQn 0 */
|
if (__HAL_UART_GET_FLAG(&huart3, UART_FLAG_IDLE))
|
||||||
|
{
|
||||||
/* USER CODE END USART3_IRQn 0 */
|
__HAL_UART_CLEAR_IDLEFLAG(&huart3);
|
||||||
|
uart_trans_idle_handler(UART_CHANNEL_U1);
|
||||||
|
}
|
||||||
HAL_UART_IRQHandler(&huart3);
|
HAL_UART_IRQHandler(&huart3);
|
||||||
/* USER CODE BEGIN USART3_IRQn 1 */
|
|
||||||
|
|
||||||
/* USER CODE END USART3_IRQn 1 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
void EXTI0_IRQHandler(void)
|
||||||
|
{
|
||||||
|
if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_0))
|
||||||
|
{
|
||||||
|
__HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_0);
|
||||||
|
ethernetif_set_irq_pending();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
||||||
|
{
|
||||||
|
if (huart == &huart2)
|
||||||
|
{
|
||||||
|
uart_trans_tx_cplt_handler(UART_CHANNEL_U0);
|
||||||
|
}
|
||||||
|
else if (huart == &huart3)
|
||||||
|
{
|
||||||
|
uart_trans_tx_cplt_handler(UART_CHANNEL_U1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||||
|
{
|
||||||
|
if (huart == &huart1)
|
||||||
|
{
|
||||||
|
config_uart_rx_byte(g_uart1_rx_probe_byte);
|
||||||
|
(void)HAL_UART_Receive_IT(&huart1, (uint8_t *)&g_uart1_rx_probe_byte, 1u);
|
||||||
|
}
|
||||||
|
else if (huart == &huart2)
|
||||||
|
{
|
||||||
|
uart_trans_rx_cplt_handler(UART_CHANNEL_U0);
|
||||||
|
}
|
||||||
|
else if (huart == &huart3)
|
||||||
|
{
|
||||||
|
uart_trans_rx_cplt_handler(UART_CHANNEL_U1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
|
||||||
|
{
|
||||||
|
if (huart == &huart2)
|
||||||
|
{
|
||||||
|
uart_trans_rx_half_cplt_handler(UART_CHANNEL_U0);
|
||||||
|
}
|
||||||
|
else if (huart == &huart3)
|
||||||
|
{
|
||||||
|
uart_trans_rx_half_cplt_handler(UART_CHANNEL_U1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,245 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file syscalls.c
|
||||||
|
* @author Auto-generated by STM32CubeMX
|
||||||
|
* @brief Minimal System calls file
|
||||||
|
*
|
||||||
|
* For more information about which c-functions
|
||||||
|
* need which of these lowlevel functions
|
||||||
|
* please consult the Newlib or Picolibc libc-manual
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020-2025 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes */
|
||||||
|
#include "main.h"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/times.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Variables */
|
||||||
|
extern int __io_putchar(int ch) __attribute__((weak));
|
||||||
|
extern int __io_getchar(void) __attribute__((weak));
|
||||||
|
|
||||||
|
|
||||||
|
char *__env[1] = { 0 };
|
||||||
|
char **environ = __env;
|
||||||
|
|
||||||
|
|
||||||
|
/* Functions */
|
||||||
|
void initialise_monitor_handles()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int _getpid(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _kill(int pid, int sig)
|
||||||
|
{
|
||||||
|
(void)pid;
|
||||||
|
(void)sig;
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _exit (int status)
|
||||||
|
{
|
||||||
|
_kill(status, -1);
|
||||||
|
Debug_TrapWithRttHint("_exit");
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((weak)) int _read(int file, char *ptr, int len)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
int DataIdx;
|
||||||
|
|
||||||
|
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||||
|
{
|
||||||
|
*ptr++ = __io_getchar();
|
||||||
|
}
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((weak)) int _write(int file, char *ptr, int len)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
int DataIdx;
|
||||||
|
|
||||||
|
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||||
|
{
|
||||||
|
__io_putchar(*ptr++);
|
||||||
|
}
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _close(int file)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int _fstat(int file, struct stat *st)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
st->st_mode = S_IFCHR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _isatty(int file)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _lseek(int file, int ptr, int dir)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
(void)ptr;
|
||||||
|
(void)dir;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _open(char *path, int flags, ...)
|
||||||
|
{
|
||||||
|
(void)path;
|
||||||
|
(void)flags;
|
||||||
|
/* Pretend like we always fail */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _wait(int *status)
|
||||||
|
{
|
||||||
|
(void)status;
|
||||||
|
errno = ECHILD;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _unlink(char *name)
|
||||||
|
{
|
||||||
|
(void)name;
|
||||||
|
errno = ENOENT;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
clock_t _times(struct tms *buf)
|
||||||
|
{
|
||||||
|
(void)buf;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _stat(const char *file, struct stat *st)
|
||||||
|
{
|
||||||
|
(void)file;
|
||||||
|
st->st_mode = S_IFCHR;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _link(char *old, char *new)
|
||||||
|
{
|
||||||
|
(void)old;
|
||||||
|
(void)new;
|
||||||
|
errno = EMLINK;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _fork(void)
|
||||||
|
{
|
||||||
|
errno = EAGAIN;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int _execve(char *name, char **argv, char **env)
|
||||||
|
{
|
||||||
|
(void)name;
|
||||||
|
(void)argv;
|
||||||
|
(void)env;
|
||||||
|
errno = ENOMEM;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Picolibc Specific Section ---
|
||||||
|
#if defined(__PICOLIBC__)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Picolibc helper function to output a character to a FILE stream.
|
||||||
|
* This redirects the output to the low-level __io_putchar function.
|
||||||
|
* @param c Character to write.
|
||||||
|
* @param file FILE stream pointer (ignored).
|
||||||
|
* @retval int The character written.
|
||||||
|
*/
|
||||||
|
static int starm_putc(char c, FILE *file)
|
||||||
|
{
|
||||||
|
(void) file;
|
||||||
|
__io_putchar(c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Picolibc helper function to input a character from a FILE stream.
|
||||||
|
* This redirects the input from the low-level __io_getchar function.
|
||||||
|
* @param file FILE stream pointer (ignored).
|
||||||
|
* @retval int The character read, cast to an unsigned char then int.
|
||||||
|
*/
|
||||||
|
static int starm_getc(FILE *file)
|
||||||
|
{
|
||||||
|
unsigned char c;
|
||||||
|
(void) file;
|
||||||
|
c = __io_getchar();
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define and initialize the standard I/O streams for Picolibc.
|
||||||
|
// FDEV_SETUP_STREAM connects the starm_putc and starm_getc helper functions to a FILE structure.
|
||||||
|
// _FDEV_SETUP_RW indicates the stream is for reading and writing.
|
||||||
|
static FILE __stdio = FDEV_SETUP_STREAM(starm_putc,
|
||||||
|
starm_getc,
|
||||||
|
NULL,
|
||||||
|
_FDEV_SETUP_RW);
|
||||||
|
|
||||||
|
// Assign the standard stream pointers (stdin, stdout, stderr) to the initialized stream.
|
||||||
|
// Picolibc uses these pointers for standard I/O operations (printf, scanf, etc.).
|
||||||
|
FILE *const stdin = &__stdio;
|
||||||
|
__strong_reference(stdin, stdout);
|
||||||
|
__strong_reference(stdin, stderr);
|
||||||
|
|
||||||
|
// Create strong aliases mapping standard C library function names (without underscore)
|
||||||
|
// to the implemented system call stubs (with underscore). Picolibc uses these
|
||||||
|
// standard names internally, so this linking is required.
|
||||||
|
__strong_reference(_read, read);
|
||||||
|
__strong_reference(_write, write);
|
||||||
|
__strong_reference(_times, times);
|
||||||
|
__strong_reference(_execve, execve);
|
||||||
|
__strong_reference(_fork, fork);
|
||||||
|
__strong_reference(_link, link);
|
||||||
|
__strong_reference(_unlink, unlink);
|
||||||
|
__strong_reference(_stat, stat);
|
||||||
|
__strong_reference(_wait, wait);
|
||||||
|
__strong_reference(_open, open);
|
||||||
|
__strong_reference(_close, close);
|
||||||
|
__strong_reference(_lseek, lseek);
|
||||||
|
__strong_reference(_isatty, isatty);
|
||||||
|
__strong_reference(_fstat, fstat);
|
||||||
|
__strong_reference(_exit, exit);
|
||||||
|
__strong_reference(_kill, kill);
|
||||||
|
__strong_reference(_getpid, getpid);
|
||||||
|
|
||||||
|
#endif //__PICOLIBC__
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file sysmem.c
|
||||||
|
* @author Generated by STM32CubeMX
|
||||||
|
* @brief System Memory calls file
|
||||||
|
*
|
||||||
|
* For more information about which C functions
|
||||||
|
* need which of these lowlevel functions
|
||||||
|
* please consult the Newlib or Picolibc libc manual
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* Copyright (c) 2025 STMicroelectronics.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This software is licensed under terms that can be found in the LICENSE file
|
||||||
|
* in the root directory of this software component.
|
||||||
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Includes */
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pointer to the current high watermark of the heap usage
|
||||||
|
*/
|
||||||
|
static uint8_t *__sbrk_heap_end = NULL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief _sbrk() allocates memory to the newlib heap and is used by malloc
|
||||||
|
* and others from the C library
|
||||||
|
*
|
||||||
|
* @verbatim
|
||||||
|
* ############################################################################
|
||||||
|
* # .data # .bss # newlib heap # MSP stack #
|
||||||
|
* # # # # Reserved by _Min_Stack_Size #
|
||||||
|
* ############################################################################
|
||||||
|
* ^-- RAM start ^-- _end _estack, RAM end --^
|
||||||
|
* @endverbatim
|
||||||
|
*
|
||||||
|
* This implementation starts allocating at the '_end' linker symbol
|
||||||
|
* The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack
|
||||||
|
* The implementation considers '_estack' linker symbol to be RAM end
|
||||||
|
* NOTE: If the MSP stack, at any point during execution, grows larger than the
|
||||||
|
* reserved size, please increase the '_Min_Stack_Size'.
|
||||||
|
*
|
||||||
|
* @param incr Memory size
|
||||||
|
* @return Pointer to allocated memory
|
||||||
|
*/
|
||||||
|
void *_sbrk(ptrdiff_t incr)
|
||||||
|
{
|
||||||
|
extern uint8_t _end; /* Symbol defined in the linker script */
|
||||||
|
extern uint8_t _estack; /* Symbol defined in the linker script */
|
||||||
|
extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */
|
||||||
|
const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size;
|
||||||
|
const uint8_t *max_heap = (uint8_t *)stack_limit;
|
||||||
|
uint8_t *prev_heap_end;
|
||||||
|
|
||||||
|
/* Initialize heap end at first call */
|
||||||
|
if (NULL == __sbrk_heap_end)
|
||||||
|
{
|
||||||
|
__sbrk_heap_end = &_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Protect heap from growing into the reserved MSP stack */
|
||||||
|
if (__sbrk_heap_end + incr > max_heap)
|
||||||
|
{
|
||||||
|
errno = ENOMEM;
|
||||||
|
return (void *)-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
prev_heap_end = __sbrk_heap_end;
|
||||||
|
__sbrk_heap_end += incr;
|
||||||
|
|
||||||
|
return (void *)prev_heap_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(__PICOLIBC__)
|
||||||
|
// Picolibc expects syscalls without the leading underscore.
|
||||||
|
// This creates a strong alias so that
|
||||||
|
// calls to `sbrk()` are resolved to our `_sbrk()` implementation.
|
||||||
|
__strong_reference(_sbrk, sbrk);
|
||||||
|
#endif
|
||||||
+100
@@ -0,0 +1,100 @@
|
|||||||
|
/* USER CODE BEGIN Header */
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file tim.c
|
||||||
|
* @brief This file provides code for the configuration of the TIM instances.
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header */
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "tim.h"
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 0 */
|
||||||
|
|
||||||
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
|
TIM_HandleTypeDef htim4;
|
||||||
|
|
||||||
|
/* TIM4 init function */
|
||||||
|
void MX_TIM4_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM4_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_Init 0 */
|
||||||
|
|
||||||
|
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||||
|
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM4_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_Init 1 */
|
||||||
|
htim4.Instance = TIM4;
|
||||||
|
htim4.Init.Prescaler = 7199;
|
||||||
|
htim4.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim4.Init.Period = 9;
|
||||||
|
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
if (HAL_TIM_Base_Init(&htim4) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
|
if (HAL_TIM_ConfigClockSource(&htim4, &sClockSourceConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN TIM4_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_Init 2 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(tim_baseHandle->Instance==TIM4)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM4_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspInit 0 */
|
||||||
|
/* TIM4 clock enable */
|
||||||
|
__HAL_RCC_TIM4_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* TIM4 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(TIM4_IRQn, 6, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(TIM4_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM4_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(tim_baseHandle->Instance==TIM4)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM4_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_TIM4_CLK_DISABLE();
|
||||||
|
|
||||||
|
/* TIM4 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(TIM4_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM4_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM4_MspDeInit 1 */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
/* USER CODE END 1 */
|
||||||
+2
-2
@@ -220,7 +220,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
|||||||
hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE;
|
hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||||
hdma_usart2_rx.Init.Mode = DMA_NORMAL;
|
hdma_usart2_rx.Init.Mode = DMA_CIRCULAR;
|
||||||
hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW;
|
hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||||
if (HAL_DMA_Init(&hdma_usart2_rx) != HAL_OK)
|
if (HAL_DMA_Init(&hdma_usart2_rx) != HAL_OK)
|
||||||
{
|
{
|
||||||
@@ -283,7 +283,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
|||||||
hdma_usart3_rx.Init.MemInc = DMA_MINC_ENABLE;
|
hdma_usart3_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
hdma_usart3_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
hdma_usart3_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
hdma_usart3_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
hdma_usart3_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||||
hdma_usart3_rx.Init.Mode = DMA_NORMAL;
|
hdma_usart3_rx.Init.Mode = DMA_CIRCULAR;
|
||||||
hdma_usart3_rx.Init.Priority = DMA_PRIORITY_LOW;
|
hdma_usart3_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||||
if (HAL_DMA_Init(&hdma_usart3_rx) != HAL_OK)
|
if (HAL_DMA_Init(&hdma_usart3_rx) != HAL_OK)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,632 @@
|
|||||||
|
/********************************** (C) COPYRIGHT *****************************
|
||||||
|
* File Name : CH390.c
|
||||||
|
* Author : WCH
|
||||||
|
* Version : V1.1
|
||||||
|
* Date : 2024/08/20
|
||||||
|
* Description : CH390 Ethernet controller source file
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||||
|
* Attention: This software (modified or not) and binary are used for
|
||||||
|
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||||
|
******************************************************************************/
|
||||||
|
#include "CH390.h"
|
||||||
|
#include "CH390_Interface.h"
|
||||||
|
|
||||||
|
#define CH390_PHY_BUSY_TIMEOUT_LOOPS 2000u
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_receive_packet
|
||||||
|
* @brief Receive packet
|
||||||
|
* @param buff - Size equal to CH390_PKT_MAX
|
||||||
|
* @param rx_status - Output abnormal status while receiving packet.
|
||||||
|
* It has the same meaning as RSR(06h).
|
||||||
|
* @return Packet length
|
||||||
|
*/
|
||||||
|
uint32_t ch390_receive_packet(uint8_t *buff, uint8_t *rx_status)
|
||||||
|
{
|
||||||
|
uint8_t rx_ready;
|
||||||
|
uint16_t rx_len = 0;
|
||||||
|
uint8_t ReceiveData[4];
|
||||||
|
|
||||||
|
// Check packet ready or not
|
||||||
|
ch390_read_reg(CH390_MRCMDX);
|
||||||
|
rx_ready = ch390_read_reg(CH390_MRCMDX);
|
||||||
|
|
||||||
|
// if rxbyte != 1 or 0 reset pointer
|
||||||
|
if (rx_ready & CH390_PKT_ERR)
|
||||||
|
{
|
||||||
|
// Reset RX FIFO pointer
|
||||||
|
uint8_t rcr = ch390_read_reg(CH390_RCR);
|
||||||
|
ch390_write_reg(CH390_RCR, rcr & ~RCR_RXEN); //RX disable
|
||||||
|
ch390_write_reg(CH390_MPTRCR, 0x01); //Reset RX FIFO pointer
|
||||||
|
ch390_write_reg(CH390_MRRH, 0x0c);
|
||||||
|
ch390_delay_us(1000);
|
||||||
|
ch390_write_reg(CH390_RCR, rcr | RCR_RXEN); //RX Enable
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (!(rx_ready & CH390_PKT_RDY))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ch390_read_mem(ReceiveData, 4);
|
||||||
|
|
||||||
|
*rx_status = ReceiveData[1];
|
||||||
|
rx_len = ReceiveData[2] | (ReceiveData[3] << 8);
|
||||||
|
|
||||||
|
if(rx_len <= CH390_PKT_MAX)
|
||||||
|
{
|
||||||
|
ch390_read_mem(buff, rx_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*rx_status & 0x3f) || (rx_len > CH390_PKT_MAX))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return rx_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_send_packet
|
||||||
|
* @brief Send packet
|
||||||
|
* @param buff - Data to be sent
|
||||||
|
* @param length - Less than 3k bytes.
|
||||||
|
*/
|
||||||
|
void ch390_send_packet(uint8_t *buff, uint16_t length)
|
||||||
|
{
|
||||||
|
// Write data to SRAM
|
||||||
|
ch390_write_mem(buff, length);
|
||||||
|
// Wait until last transmit complete
|
||||||
|
while(ch390_read_reg(CH390_TCR) & TCR_TXREQ);
|
||||||
|
// Set current packet length
|
||||||
|
ch390_write_reg(CH390_TXPLL, length & 0xff);
|
||||||
|
ch390_write_reg(CH390_TXPLH, (length >> 8) & 0xff);
|
||||||
|
// Issue transmit request
|
||||||
|
ch390_send_request();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_send_request
|
||||||
|
* @brief Issue transmit request
|
||||||
|
*/
|
||||||
|
void ch390_send_request()
|
||||||
|
{
|
||||||
|
uint8_t tcr = ch390_read_reg(CH390_TCR);
|
||||||
|
ch390_write_reg(CH390_TCR, tcr | TCR_TXREQ);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_drop_packet
|
||||||
|
* @brief Drop packet in RX SRAM if don't want to read it. This function
|
||||||
|
* modify the memory data read pointer and skip specified length
|
||||||
|
* @param len - Skip length, length of the current packet.
|
||||||
|
*/
|
||||||
|
void ch390_drop_packet(uint16_t len)
|
||||||
|
{
|
||||||
|
uint16_t mdr = ch390_read_reg(CH390_MRRL) | (ch390_read_reg(CH390_MRRH) << 8);
|
||||||
|
#ifdef CH390_INTERFACE_16_BIT
|
||||||
|
mdr = mdr + (len + 1) / 2 * 2;
|
||||||
|
#else
|
||||||
|
mdr = mdr + len;
|
||||||
|
#endif
|
||||||
|
mdr = mdr < 0x4000 ? mdr : mdr - 0x3400;
|
||||||
|
ch390_write_reg(CH390_MRRL, mdr & 0xff);
|
||||||
|
ch390_write_reg(CH390_MRRH, (mdr >> 8) & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_read_phy
|
||||||
|
* @brief Read PHY register
|
||||||
|
* @param reg - PHY register address
|
||||||
|
*/
|
||||||
|
uint16_t ch390_read_phy(uint8_t reg)
|
||||||
|
{
|
||||||
|
uint32_t timeout = CH390_PHY_BUSY_TIMEOUT_LOOPS;
|
||||||
|
|
||||||
|
ch390_write_reg(CH390_EPAR, CH390_PHY | reg);
|
||||||
|
// Chose PHY, send read command
|
||||||
|
ch390_write_reg(CH390_EPCR, EPCR_ERPRR | EPCR_EPOS);
|
||||||
|
while ((ch390_read_reg(CH390_EPCR) & EPCR_ERRE) != 0u) {
|
||||||
|
if (timeout-- == 0u) {
|
||||||
|
ch390_write_reg(CH390_EPCR, 0x00);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clear read command
|
||||||
|
ch390_write_reg(CH390_EPCR, 0x00);
|
||||||
|
return (ch390_read_reg(CH390_EPDRH) << 8) |
|
||||||
|
(ch390_read_reg(CH390_EPDRL) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_write_phy
|
||||||
|
* @brief Write PHY register
|
||||||
|
* @param reg - PHY register address
|
||||||
|
* @param value - Value to be written
|
||||||
|
*/
|
||||||
|
void ch390_write_phy(uint8_t reg, uint16_t value)
|
||||||
|
{
|
||||||
|
uint32_t timeout = CH390_PHY_BUSY_TIMEOUT_LOOPS;
|
||||||
|
|
||||||
|
ch390_write_reg(CH390_EPAR, CH390_PHY | reg);
|
||||||
|
ch390_write_reg(CH390_EPDRL, (value & 0xff)); // Low byte
|
||||||
|
ch390_write_reg(CH390_EPDRH, ((value >> 8) & 0xff)); // High byte
|
||||||
|
// Chose PHY, send write command
|
||||||
|
ch390_write_reg(CH390_EPCR, 0x0A);
|
||||||
|
while ((ch390_read_reg(CH390_EPCR) & EPCR_ERRE) != 0u) {
|
||||||
|
if (timeout-- == 0u) {
|
||||||
|
ch390_write_reg(CH390_EPCR, 0x00);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clear write command
|
||||||
|
ch390_write_reg(CH390_EPCR, 0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_write_eeprom
|
||||||
|
* @brief Write EEPROM register
|
||||||
|
* @param reg - EEPROM register address
|
||||||
|
* @param value - Value to be written
|
||||||
|
*/
|
||||||
|
void ch390_write_eeprom(uint8_t reg, uint16_t value)
|
||||||
|
{
|
||||||
|
ch390_write_reg(CH390_EPAR, reg);
|
||||||
|
ch390_write_reg(CH390_EPDRL, (value & 0xff)); // Low byte
|
||||||
|
ch390_write_reg(CH390_EPDRH, ((value >> 8) & 0xff)); // High byte
|
||||||
|
// Chose EEPROM, send write command
|
||||||
|
ch390_write_reg(CH390_EPCR, EPCR_ERPRW);
|
||||||
|
while(ch390_read_reg(CH390_EPCR) & 0x01);
|
||||||
|
// Clear write command
|
||||||
|
ch390_write_reg(CH390_EPCR, 0x00);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_software_reset
|
||||||
|
* @brief Software reset CH390 by NCR
|
||||||
|
*/
|
||||||
|
void ch390_software_reset()
|
||||||
|
{
|
||||||
|
ch390_write_reg(CH390_NCR, NCR_RST);
|
||||||
|
ch390_delay_us(10);
|
||||||
|
ch390_write_reg(CH390_NCR, 0);
|
||||||
|
ch390_write_reg(CH390_NCR, NCR_RST);
|
||||||
|
ch390_delay_us(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_default_config
|
||||||
|
* @brief Config CH390 with default options:
|
||||||
|
* LED mode 1;
|
||||||
|
* Enable transmit check sum generation;
|
||||||
|
* Enable RX;
|
||||||
|
* Enable all interrupt and PAR
|
||||||
|
*/
|
||||||
|
void ch390_default_config()
|
||||||
|
{
|
||||||
|
// CH390 has built-in MAC, this is not necessary
|
||||||
|
// uint8_t mac_addr[6] = { 0x50, 0x54, 0x7B, 0x84, 0x00, 0x73 };
|
||||||
|
// Multicast address hash table
|
||||||
|
uint8_t multicase_addr[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
|
|
||||||
|
ch390_set_phy_mode(CH390_AUTO);
|
||||||
|
ch390_write_reg(CH390_INTCR, (uint8_t)(INCR_TYPE_OD | INCR_POL_L));
|
||||||
|
// Clear status
|
||||||
|
ch390_write_reg(CH390_NSR, NSR_WAKEST | NSR_TX2END | NSR_TX1END);
|
||||||
|
ch390_write_reg(CH390_ISR, 0xFF); // Clear interrupt status
|
||||||
|
ch390_write_reg(CH390_TCR2, 0x80); // LED mode 1
|
||||||
|
ch390_write_reg(CH390_TCSCR, TCSCR_ALL); // Enable check sum generation
|
||||||
|
|
||||||
|
// ch390_set_mac_address(mac_addr);
|
||||||
|
ch390_set_multicast(multicase_addr);
|
||||||
|
|
||||||
|
// Enable only the interrupts needed by the NO_SYS polling path.
|
||||||
|
ch390_write_reg(CH390_IMR, (uint8_t)(IMR_PRI | IMR_LNKCHGI | IMR_ROOI | IMR_ROI));
|
||||||
|
// Enable RX with the reference receive filter.
|
||||||
|
ch390_write_reg(CH390_RCR, RCR_DIS_CRC | RCR_RXEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_set_phy_mode
|
||||||
|
* @brief Set PHY mode and enable PHY.
|
||||||
|
* PHY mode: Auto-negotiation, 10M/100M, full-duplex/half-duplex
|
||||||
|
* @param mode - PHY mode
|
||||||
|
*/
|
||||||
|
void ch390_set_phy_mode(enum ch390_phy_mode mode)
|
||||||
|
{
|
||||||
|
uint16_t BMCR_value = 0;
|
||||||
|
uint16_t ANAR_value = 0;
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case CH390_10MFD:
|
||||||
|
BMCR_value = 0x1100;
|
||||||
|
ANAR_value = 0x41;
|
||||||
|
break;
|
||||||
|
case CH390_100MFD:
|
||||||
|
BMCR_value = 0x3100;
|
||||||
|
ANAR_value = 0x101;
|
||||||
|
break;
|
||||||
|
case CH390_AUTO:
|
||||||
|
BMCR_value = 0x1000;
|
||||||
|
ANAR_value = 0x01E1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ch390_write_phy(CH390_PHY_BMCR, BMCR_value);
|
||||||
|
ch390_write_phy(CH390_PHY_ANAR, ANAR_value);
|
||||||
|
ch390_write_reg(CH390_GPR, 0x00); // Enable PHY
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_set_mac_address
|
||||||
|
* @brief Set mac address
|
||||||
|
* @param mac_addr - 6-byte length mac address array
|
||||||
|
*/
|
||||||
|
void ch390_set_mac_address(uint8_t *mac_addr)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
for (i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
ch390_write_reg(CH390_PAR + i, mac_addr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_set_multicast
|
||||||
|
* @brief Set multicast address hash table
|
||||||
|
* @param multicast_addr - 8-byte length multicast address hash table array
|
||||||
|
*/
|
||||||
|
void ch390_set_multicast(uint8_t *multicast_hash)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
ch390_write_reg(CH390_MAR + i, multicast_hash[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief reflect an 8bit value.
|
||||||
|
* Only for "ch390_compute_hash_bit"
|
||||||
|
*/
|
||||||
|
static uint8_t reflect_8(uint8_t val)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
uint8_t resVal = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
if ((val & (1 << i)) != 0)
|
||||||
|
{
|
||||||
|
resVal |= 1 << (7 - i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return resVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Calculate the corresponding hash bit of the MAC address.
|
||||||
|
* Only for "ch390_set_hash_bit"
|
||||||
|
* @param mac - Destination address
|
||||||
|
* @return Hash bit number
|
||||||
|
*/
|
||||||
|
static uint8_t ch390_compute_hash_bit(uint8_t *mac)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
const uint32_t poly = 0x4C11DB7;
|
||||||
|
uint32_t crc = 0xffffffff;
|
||||||
|
|
||||||
|
int byte_i = 0;
|
||||||
|
for(byte_i = 0; byte_i < 6; byte_i++)
|
||||||
|
{
|
||||||
|
uint8_t cur_byte = reflect_8(mac[byte_i]);
|
||||||
|
crc ^= cur_byte << 24;
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
if ((crc & 0x80000000) != 0)
|
||||||
|
{
|
||||||
|
crc = (crc << 1) ^ poly;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
crc <<= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (crc ^ 0xffffffff) >> 26;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set MAR bit for a particular MAC address
|
||||||
|
* @param mac - Destination address
|
||||||
|
*/
|
||||||
|
void ch390_set_hash_bit(uint8_t *mac)
|
||||||
|
{
|
||||||
|
uint8_t bit = ch390_compute_hash_bit(mac);
|
||||||
|
uint8_t mar = CH390_MAR + bit / 8;
|
||||||
|
|
||||||
|
uint8_t mar_val = ch390_read_reg(mar);
|
||||||
|
mar_val |= 1 << (bit % 8);
|
||||||
|
ch390_write_reg(mar, mar_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_mac
|
||||||
|
* @brief Get mac address
|
||||||
|
* @param mac_addr - 6-byte length mac address output
|
||||||
|
*/
|
||||||
|
void ch390_get_mac(uint8_t *mac_addr)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
for (i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
mac_addr[i] = ch390_read_reg(CH390_PAR + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_multicast
|
||||||
|
* @brief Get multicast address hash table
|
||||||
|
* @param multicast_addr - 8-byte length multicast address hash table output
|
||||||
|
*/
|
||||||
|
void ch390_get_multicast(uint8_t *multicast_hash)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
multicast_hash[i] = ch390_read_reg(CH390_MAR + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_vendor_id
|
||||||
|
* @brief Get vendor ID
|
||||||
|
* @return Vendor ID
|
||||||
|
*/
|
||||||
|
uint16_t ch390_get_vendor_id()
|
||||||
|
{
|
||||||
|
uint16_t id;
|
||||||
|
id = (ch390_read_reg(CH390_VIDL) & 0xff);
|
||||||
|
id |= ch390_read_reg(CH390_VIDH) << 8;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_product_id
|
||||||
|
* @brief Get product ID
|
||||||
|
* @return Product ID
|
||||||
|
*/
|
||||||
|
uint16_t ch390_get_product_id()
|
||||||
|
{
|
||||||
|
uint16_t id;
|
||||||
|
id = (ch390_read_reg(CH390_PIDL) & 0xff);
|
||||||
|
id |= ch390_read_reg(CH390_PIDH) << 8;
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_revision
|
||||||
|
* @brief Get chip revision
|
||||||
|
* @return Chip revision
|
||||||
|
*/
|
||||||
|
uint8_t ch390_get_revision()
|
||||||
|
{
|
||||||
|
return ch390_read_reg(CH390_CHIPR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_interrupt_config
|
||||||
|
* @brief Interrupt configuration
|
||||||
|
* @param mask - Interrupt to be enabled, see "CH390.h" IMR_xxx
|
||||||
|
*/
|
||||||
|
void ch390_interrupt_config(uint8_t mask)
|
||||||
|
{
|
||||||
|
ch390_write_reg(CH390_IMR, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_rx_enable
|
||||||
|
* @brief Enable or disable packet receive
|
||||||
|
* @param op - 0: disable 1: enable
|
||||||
|
*/
|
||||||
|
void ch390_rx_enable(int op)
|
||||||
|
{
|
||||||
|
uint8_t rcr = ch390_read_reg(CH390_RCR);
|
||||||
|
|
||||||
|
if(op == 0)
|
||||||
|
rcr &= ~RCR_RXEN;
|
||||||
|
else
|
||||||
|
rcr |= RCR_RXEN;
|
||||||
|
|
||||||
|
ch390_write_reg(CH390_RCR, rcr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_rx_filter_config
|
||||||
|
* @brief Configure receive filter.
|
||||||
|
* @param config - See "CH390.h" RCR_xxx
|
||||||
|
*/
|
||||||
|
void ch390_rx_filter_config(uint8_t config)
|
||||||
|
{
|
||||||
|
uint8_t rcr = ch390_read_reg(CH390_RCR) & RCR_RXEN;
|
||||||
|
ch390_write_reg(CH390_RCR, rcr | config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_wakeup_config
|
||||||
|
* @brief Enable or disable wakeup_function
|
||||||
|
* @param events - Events that trigger wakeup
|
||||||
|
* WCR_LINKEN - Link status change
|
||||||
|
* WCR_SAMPLEEN - Sample frame
|
||||||
|
* WCR_MAGICEN - Magic packet
|
||||||
|
* 0 - Disable wakeup function
|
||||||
|
*/
|
||||||
|
void ch390_wakeup_config(uint8_t events)
|
||||||
|
{
|
||||||
|
uint8_t ncr = ch390_read_reg(CH390_NCR);
|
||||||
|
if(events)
|
||||||
|
ncr |= NCR_WAKEEN;
|
||||||
|
else {
|
||||||
|
ncr &= ~NCR_WAKEEN;
|
||||||
|
}
|
||||||
|
ch390_write_reg(CH390_NCR, ncr);
|
||||||
|
ch390_write_reg(CH390_WCR, events);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_wake_notify
|
||||||
|
* @brief Wait for Magic Packet or Sample Frame and discard all
|
||||||
|
* other packets.
|
||||||
|
* If the application needs to use Wake On LAN, call this
|
||||||
|
* function every time before MCU enters low power mode.
|
||||||
|
* An external interrupt signal is accessible on WOL pin
|
||||||
|
* when wake up event occurred.
|
||||||
|
*/
|
||||||
|
void ch390_wake_notify(void)
|
||||||
|
{
|
||||||
|
uint8_t ncr = ch390_read_reg(CH390_NCR);
|
||||||
|
ch390_write_reg(CH390_NCR, ncr ^ 0x10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_loop_back_enable
|
||||||
|
* @brief Enable loop back mode
|
||||||
|
* @param op - 0: disable 1: enable
|
||||||
|
*/
|
||||||
|
void ch390_loop_back_enable(int op)
|
||||||
|
{
|
||||||
|
uint8_t ncr = ch390_read_reg(CH390_NCR) & ~0x06;
|
||||||
|
|
||||||
|
if(op == 1) ncr |= NCR_LBK_MAC;
|
||||||
|
|
||||||
|
ch390_write_reg(CH390_NCR, ncr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_duplex_mode
|
||||||
|
* @brief Get current duplex mode of the internal PHY
|
||||||
|
* @return 0: Half-duplex 1: Full-duplex
|
||||||
|
*/
|
||||||
|
int ch390_get_duplex_mode()
|
||||||
|
{
|
||||||
|
return !!(ch390_read_reg(CH390_NCR) & NCR_FDX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_phy_speed
|
||||||
|
* @brief Get the speed of the internal PHY.
|
||||||
|
* Only valid after PHY linked
|
||||||
|
* @return 0: 100Mbps 1: 10Mbps
|
||||||
|
*/
|
||||||
|
int ch390_get_phy_speed()
|
||||||
|
{
|
||||||
|
return !!(ch390_read_reg(CH390_NSR) & NSR_SPEED);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_link_status
|
||||||
|
* @brief Get link status of the internal PHY
|
||||||
|
* @return 0: Link failed 1: Link OK
|
||||||
|
*/
|
||||||
|
int ch390_get_link_status()
|
||||||
|
{
|
||||||
|
uint8_t nsr = ch390_read_reg(CH390_NSR);
|
||||||
|
return !!(nsr & NSR_LINKST);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_sleep_control
|
||||||
|
* @brief Enter or exit sleep mode
|
||||||
|
* @param op - 0: Power up 1: Power down
|
||||||
|
*/
|
||||||
|
void ch390_sleep_control(int op)
|
||||||
|
{
|
||||||
|
if(op)
|
||||||
|
{
|
||||||
|
ch390_write_reg(CH390_SCCR, 0x01);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ch390_read_reg(CH390_RSCCR);
|
||||||
|
ch390_delay_us(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef CH390_INTERFACE_16_BIT
|
||||||
|
/**
|
||||||
|
* @name ch390_gpio_config
|
||||||
|
* @brief Config the input/output direction of GPIO1~3
|
||||||
|
* In 8-bit mode, GPIO4~6 are output only
|
||||||
|
* @param GPIOx - CH390_GPIO1 ~ CH390_GPIO3
|
||||||
|
* dir - 0: Input 1: Output
|
||||||
|
*/
|
||||||
|
void ch390_gpio_config(uint8_t GPIOx, uint8_t dir)
|
||||||
|
{
|
||||||
|
uint8_t gpcr = ch390_read_reg(CH390_GPCR);
|
||||||
|
if(dir)
|
||||||
|
{
|
||||||
|
gpcr |= GPIOx;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gpcr &= ~GPIOx;
|
||||||
|
}
|
||||||
|
ch390_write_reg(CH390_GPCR, gpcr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_gpio_write_bit
|
||||||
|
* @brief Sets or clears the selected gpio bit.
|
||||||
|
* In SPI mode, only GPIO1~3 are available
|
||||||
|
* @param GPIOx - CH390_GPIO1 ~ CH390_GPIO6
|
||||||
|
* level - 0: Clear pin 1: Set pin
|
||||||
|
*/
|
||||||
|
void ch390_gpio_write_bit(uint8_t GPIOx, uint8_t level)
|
||||||
|
{
|
||||||
|
uint8_t gpr = ch390_read_reg(CH390_GPR);
|
||||||
|
if(level)
|
||||||
|
{
|
||||||
|
gpr |= GPIOx;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gpr &= ~GPIOx;
|
||||||
|
}
|
||||||
|
ch390_write_reg(CH390_GPR, gpr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_gpio_read_bit
|
||||||
|
* @brief Read gpio input, only CH390_GPIO1 ~ 3 are available
|
||||||
|
* @param GPIOx - CH390_GPIO1 ~ CH390_GPIO3
|
||||||
|
* @return Input pin value
|
||||||
|
*/
|
||||||
|
uint8_t ch390_gpio_read_bit(uint8_t GPIOx)
|
||||||
|
{
|
||||||
|
uint8_t gpr = ch390_read_reg(CH390_GPR);
|
||||||
|
return !!(gpr & GPIOx);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_int_pin_config
|
||||||
|
* @brief Configure INT pin output type and polarity
|
||||||
|
* @param type - INCR_TYPE_OD: Open drain output
|
||||||
|
* INCR_TYPE_PP: Push pull output
|
||||||
|
* pol - INCR_POL_L: Active low
|
||||||
|
* INCR_POL_H: Active high
|
||||||
|
*/
|
||||||
|
void ch390_int_pin_config(uint8_t type, uint8_t pol)
|
||||||
|
{
|
||||||
|
ch390_write_reg(CH390_INTCR, type | pol);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_int_status
|
||||||
|
* @brief Get CH390 interrupt status and clear them
|
||||||
|
* @return Interrupt status
|
||||||
|
*/
|
||||||
|
uint8_t ch390_get_int_status()
|
||||||
|
{
|
||||||
|
uint8_t int_status = ch390_read_reg(CH390_ISR);
|
||||||
|
// Clear interrupt status by write 1
|
||||||
|
ch390_write_reg(CH390_ISR, int_status);
|
||||||
|
return int_status;
|
||||||
|
}
|
||||||
@@ -0,0 +1,623 @@
|
|||||||
|
/********************************** (C) COPYRIGHT *****************************
|
||||||
|
* File Name : CH390.h
|
||||||
|
* Author : WCH
|
||||||
|
* Version : V1.1
|
||||||
|
* Date : 2024/08/20
|
||||||
|
* Description : CH390 Ethernet controller header file
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||||
|
* Attention: This software (modified or not) and binary are used for
|
||||||
|
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||||
|
******************************************************************************/
|
||||||
|
#ifndef __CH390_H
|
||||||
|
#define __CH390_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
* Interface selection
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define CH390_INTERFACE_SPI // CH390H/CH390D
|
||||||
|
// #define CH390_INTERFACE_8_BIT // CH390L/CH390F 8-bit mode
|
||||||
|
// #define CH390_INTERFACE_16_BIT // CH390L 16-bit mode
|
||||||
|
|
||||||
|
/* PHY mode definition */
|
||||||
|
enum ch390_phy_mode
|
||||||
|
{
|
||||||
|
CH390_10MFD, // 10M full-duplex
|
||||||
|
CH390_100MFD, // 100M full-duplex
|
||||||
|
CH390_AUTO, // Auto negotiation
|
||||||
|
};
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
* Register definition
|
||||||
|
*
|
||||||
|
* There are some differences between the register definitions of
|
||||||
|
* CH390H and CH390L
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CH390_INTERFACE_SPI
|
||||||
|
#define CH390_NCR 0x00
|
||||||
|
#define NCR_WAKEEN (1<<6) // Enable wakeup function
|
||||||
|
#define NCR_FDX (1<<3) // Duplex mode of the internal PHY
|
||||||
|
#define NCR_LBK_MAC (1<<1) // MAC loop-back
|
||||||
|
#define NCR_RST (1<<0) // Softwate reset
|
||||||
|
#define CH390_NSR 0x01
|
||||||
|
#define NSR_SPEED (1<<7) // Speed of internal PHY
|
||||||
|
#define NSR_LINKST (1<<6) // Link status of internal PHY
|
||||||
|
#define NSR_WAKEST (1<<5) // Wakeup event status
|
||||||
|
#define NSR_TX2END (1<<3) // Tx packet B complete status
|
||||||
|
#define NSR_TX1END (1<<2) // Tx packet A complete status
|
||||||
|
#define NSR_RXOV (1<<1) // Rx fifo overflow
|
||||||
|
#define NSR_RXRDY (1<<0)
|
||||||
|
#define CH390_TCR 0x02
|
||||||
|
#define TCR_TJDIS (1<<6) // Transmit jabber timer
|
||||||
|
#define TCR_PAD_DIS2 (1<<4) // PAD appends for packet B
|
||||||
|
#define TCR_CRC_DIS2 (1<<3) // CRC appends for packet B
|
||||||
|
#define TCR_PAD_DIS1 (1<<2) // PAD appends for packet A
|
||||||
|
#define TCR_CRC_DIS1 (1<<1) // CRC appends for packet A
|
||||||
|
#define TCR_TXREQ (1<<0) // Tx request
|
||||||
|
#define CH390_TSRA 0x03
|
||||||
|
#define CH390_TSRB 0x04
|
||||||
|
#define TSR_TJTO (1<<7) // Transmit jabber time out
|
||||||
|
#define TSR_LC (1<<6) // Loss of carrier
|
||||||
|
#define TSR_NC (1<<5) // No carrier
|
||||||
|
#define TSR_LCOL (1<<4) // Late collision
|
||||||
|
#define TSR_COL (1<<3) // Collision packet
|
||||||
|
#define TSR_EC (1<<2) // Excessive collision
|
||||||
|
#define CH390_RCR 0x05
|
||||||
|
#define RCR_DEFAULT 0x00 // Default settings
|
||||||
|
#define RCR_WTDIS (1<<6) // Disable 2048 bytes watch dog
|
||||||
|
#define RCR_DIS_CRC (1<<4) // Discard CRC error packet
|
||||||
|
#define RCR_ALL (1<<3) // Pass all multicast
|
||||||
|
#define RCR_RUNT (1<<2) // Pass runt packet
|
||||||
|
#define RCR_PRMSC (1<<1) // Promiscuous mode
|
||||||
|
#define RCR_RXEN (1<<0) // Enable RX
|
||||||
|
#define CH390_RSR 0x06
|
||||||
|
#define RSR_RF (1<<7) // Rnt frame
|
||||||
|
#define RSR_MF (1<<6) // Multicast frame
|
||||||
|
#define RSR_LCS (1<<5) // Late collision seen
|
||||||
|
#define RSR_RWTO (1<<4) // Receive watchdog time-out
|
||||||
|
#define RSR_PLE (1<<3) // Physical layer error
|
||||||
|
#define RSR_AE (1<<2) // Alignment error
|
||||||
|
#define RSR_CE (1<<1) // CRC error
|
||||||
|
#define RSR_FOE (1<<0) // FIFO overflow error
|
||||||
|
#define CH390_ROCR 0x07
|
||||||
|
#define CH390_BPTR 0x08
|
||||||
|
#define CH390_FCTR 0x09
|
||||||
|
#define FCTR_HWOT(ot) (( ot & 0xf ) << 4)
|
||||||
|
#define FCTR_LWOT(ot) ( ot & 0xf )
|
||||||
|
#define CH390_FCR 0x0A
|
||||||
|
#define CH390_EPCR 0x0B
|
||||||
|
#define EPCR_REEP (1<<5) // Reload EEPROM
|
||||||
|
#define EPCR_EPOS (1<<3) // EEPROM or PHY operation select
|
||||||
|
#define EPCR_ERPRR (1<<2) // EEPROM or PHY read command
|
||||||
|
#define EPCR_ERPRW (1<<1) // EEPROM or PHY write command
|
||||||
|
#define EPCR_ERRE (1<<0) // EEPROM or PHY access status
|
||||||
|
#define CH390_EPAR 0x0C
|
||||||
|
#define CH390_EPDRL 0x0D
|
||||||
|
#define CH390_EPDRH 0x0E
|
||||||
|
#define CH390_WCR 0x0F
|
||||||
|
#define WCR_LINKEN (1<<5) // Link status change wakeup
|
||||||
|
#define WCR_SAMPLEEN (1<<4) // Sample frame wakeup
|
||||||
|
#define WCR_MAGICEN (1<<3) // Magic packet wakeup
|
||||||
|
#define WCR_LINKST (1<<2) // Link status change event
|
||||||
|
#define WCR_SAMPLEST (1<<1) // Sample frame event
|
||||||
|
#define WCR_MAGICST (1<<0) // Magic packet event
|
||||||
|
#define CH390_PAR 0x10
|
||||||
|
#define CH390_MAR 0x16
|
||||||
|
#define CH390_GPCR 0x1E
|
||||||
|
#define CH390_GPR 0x1F
|
||||||
|
#define CH390_TRPAL 0x22
|
||||||
|
#define CH390_TRPAH 0x23
|
||||||
|
#define CH390_RWPAL 0x24
|
||||||
|
#define CH390_RWPAH 0x25
|
||||||
|
#define CH390_VIDL 0x28
|
||||||
|
#define CH390_VIDH 0x29
|
||||||
|
#define CH390_PIDL 0x2A
|
||||||
|
#define CH390_PIDH 0x2B
|
||||||
|
#define CH390_CHIPR 0x2C
|
||||||
|
#define CH390_TCR2 0x2D
|
||||||
|
#define CH390_ATCR 0x30
|
||||||
|
#define CH390_TCSCR 0x31
|
||||||
|
#define TCSCR_ALL 0x1F
|
||||||
|
#define TCSCR_IPv6TCPCSE (1<<4) // IPv6 TCP checksum generation
|
||||||
|
#define TCSCR_IPv6UDPCSE (1<<3) // IPv6 UDP checksum generation
|
||||||
|
#define TCSCR_UDPCSE (1<<2) // UDP checksum generation
|
||||||
|
#define TCSCR_TCPCSE (1<<1) // TCP checksum generation
|
||||||
|
#define TCSCR_IPCSE (1<<0) // IP checksum generation
|
||||||
|
#define CH390_RCSCSR 0x32
|
||||||
|
#define RCSCSR_UDPS (1<<7) // UDP checksum status
|
||||||
|
#define RCSCSR_TCPS (1<<6) // TCP checksum status
|
||||||
|
#define RCSCSR_IPS (1<<5) // IP checksum status
|
||||||
|
#define RCSCSR_UDPP (1<<4) // UDP packet of current received packet
|
||||||
|
#define RCSCSR_TCPP (1<<3) // TCP packet of current received packet
|
||||||
|
#define RCSCSR_IPP (1<<2) // IP packet of current received packet
|
||||||
|
#define RCSCSR_RCSEN (1<<1) // Receive checksum checking enable
|
||||||
|
#define RCSCSR_DCSE (1<<0) // Discard checksum error packet
|
||||||
|
#define CH390_MPAR 0x33
|
||||||
|
#define CH390_SBCR 0x38
|
||||||
|
#define CH390_INTCR 0x39
|
||||||
|
#define INCR_TYPE_OD 0x02
|
||||||
|
#define INCR_TYPE_PP 0x00
|
||||||
|
#define INCR_POL_L 0x01
|
||||||
|
#define INCR_POL_H 0x00
|
||||||
|
#define CH390_ALNCR 0x4A
|
||||||
|
#define CH390_SCCR 0x50
|
||||||
|
#define CH390_RSCCR 0x51
|
||||||
|
#define CH390_RLENCR 0x52
|
||||||
|
#define CH390_BCASTCR 0x53
|
||||||
|
#define CH390_INTCKCR 0x54
|
||||||
|
#define CH390_MPTRCR 0x55
|
||||||
|
#define CH390_MLEDCR 0x57
|
||||||
|
#define CH390_MRCMDX 0x70
|
||||||
|
#define CH390_MRCMDX1 0x71
|
||||||
|
#define CH390_MRCMD 0x72
|
||||||
|
#define CH390_MRRL 0x74
|
||||||
|
#define CH390_MRRH 0x75
|
||||||
|
#define CH390_MWCMDX 0x76
|
||||||
|
#define CH390_MWCMD 0x78
|
||||||
|
#define CH390_MWRL 0x7A
|
||||||
|
#define CH390_MWRH 0x7B
|
||||||
|
#define CH390_TXPLL 0x7C
|
||||||
|
#define CH390_TXPLH 0x7D
|
||||||
|
#define CH390_ISR 0x7E
|
||||||
|
#define ISR_LNKCHG (1<<5) // Link status change
|
||||||
|
#define ISR_ROO (1<<3) // Receive overflow counter overflow
|
||||||
|
#define ISR_ROS (1<<2) // Receive overflow
|
||||||
|
#define ISR_PT (1<<1) // Packet transmitted
|
||||||
|
#define ISR_PR (1<<0) // Packet received
|
||||||
|
#define CH390_IMR 0x7F
|
||||||
|
#define IMR_NONE 0x00 // Disable all interrupt
|
||||||
|
#define IMR_ALL 0xFF // Enable all interrupt
|
||||||
|
#define IMR_PAR (1<<7) // Pointer auto-return mode
|
||||||
|
#define IMR_LNKCHGI (1<<5) // Enable link status change interrupt
|
||||||
|
#define IMR_UDRUNI (1<<4) // Enable transmit under-run interrupt
|
||||||
|
#define IMR_ROOI (1<<3) // Enable receive overflow counter overflow interrupt
|
||||||
|
#define IMR_ROI (1<<2) // Enable receive overflow interrupt
|
||||||
|
#define IMR_PTI (1<<1) // Enable packet transmitted interrupt
|
||||||
|
#define IMR_PRI (1<<0) // Enable packet received interrupt
|
||||||
|
|
||||||
|
// SPI commands
|
||||||
|
#define OPC_REG_W 0x80 // Register Write
|
||||||
|
#define OPC_REG_R 0x00 // Register Read
|
||||||
|
#define OPC_MEM_DMY_R 0x70 // Memory Dummy Read
|
||||||
|
#define OPC_MEM_WRITE 0xF8 // Memory Write
|
||||||
|
#define OPC_MEM_READ 0x72 // Memory Read
|
||||||
|
|
||||||
|
// GPIO
|
||||||
|
#define CH390_GPIO1 0x02
|
||||||
|
#define CH390_GPIO2 0x04
|
||||||
|
#define CH390_GPIO3 0x08
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define CH390_NCR 0x00
|
||||||
|
#define NCR_WAKEEN (1<<6) // Enable wakeup function
|
||||||
|
#define NCR_FDX (1<<3) // Duplex mode of the internal PHY
|
||||||
|
#define NCR_LBK_MAC (1<<1) // MAC loop-back
|
||||||
|
#define NCR_RST (1<<0) // Softwate reset
|
||||||
|
#define CH390_NSR 0x01
|
||||||
|
#define NSR_SPEED (1<<7) // Speed of internal PHY
|
||||||
|
#define NSR_LINKST (1<<6) // Link status of internal PHY
|
||||||
|
#define NSR_WAKEST (1<<5) // Wakeup event status
|
||||||
|
#define NSR_TX2END (1<<3) // Tx packet B complete status
|
||||||
|
#define NSR_TX1END (1<<2) // Tx packet A complete status
|
||||||
|
#define NSR_RXOV (1<<1) // Rx fifo overflow
|
||||||
|
#define CH390_TCR 0x02
|
||||||
|
#define TCR_TJDIS (1<<6) // Transmit jabber timer
|
||||||
|
#define TCR_PAD_DIS2 (1<<4) // PAD appends for packet B
|
||||||
|
#define TCR_CRC_DIS2 (1<<3) // CRC appends for packet B
|
||||||
|
#define TCR_PAD_DIS1 (1<<2) // PAD appends for packet A
|
||||||
|
#define TCR_CRC_DIS1 (1<<1) // CRC appends for packet A
|
||||||
|
#define TCR_TXREQ (1<<0) // Tx request
|
||||||
|
#define CH390_TSRA 0x03
|
||||||
|
#define CH390_TSRB 0x04
|
||||||
|
#define TSR_TJTO (1<<7) // Transmit jabber time out
|
||||||
|
#define TSR_LC (1<<6) // Loss of carrier
|
||||||
|
#define TSR_NC (1<<5) // No carrier
|
||||||
|
#define TSR_LCOL (1<<4) // Late collision
|
||||||
|
#define TSR_COL (1<<3) // Collision packet
|
||||||
|
#define TSR_EC (1<<2) // Excessive collision
|
||||||
|
#define CH390_RCR 0x05
|
||||||
|
#define RCR_DEFAULT 0x00 // Default settings
|
||||||
|
#define RCR_WTDIS (1<<6) // Disable 2048 bytes watch dog
|
||||||
|
#define RCR_DIS_CRC (1<<4) // Discard CRC error packet
|
||||||
|
#define RCR_ALL (1<<3) // Pass all multicast
|
||||||
|
#define RCR_RUNT (1<<2) // Pass runt packet
|
||||||
|
#define RCR_PRMSC (1<<1) // Promiscuous mode
|
||||||
|
#define RCR_RXEN (1<<0) // Enable RX
|
||||||
|
#define CH390_RSR 0x06
|
||||||
|
#define RSR_RF (1<<7) // Rnt frame
|
||||||
|
#define RSR_MF (1<<6) // Multicast frame
|
||||||
|
#define RSR_LCS (1<<5) // Late collision seen
|
||||||
|
#define RSR_RWTO (1<<4) // Receive watchdog time-out
|
||||||
|
#define RSR_PLE (1<<3) // Physical layer error
|
||||||
|
#define RSR_AE (1<<2) // Alignment error
|
||||||
|
#define RSR_CE (1<<1) // CRC error
|
||||||
|
#define RSR_FOE (1<<0) // FIFO overflow error
|
||||||
|
#define CH390_ROCR 0x07
|
||||||
|
#define CH390_BPTR 0x08
|
||||||
|
#define CH390_FCTR 0x09
|
||||||
|
#define FCTR_HWOT(ot) (( ot & 0xf ) << 4)
|
||||||
|
#define FCTR_LWOT(ot) ( ot & 0xf )
|
||||||
|
#define CH390_FCR 0x0A
|
||||||
|
#define CH390_EPCR 0x0B
|
||||||
|
#define EPCR_REEP (1<<5) // Reload EEPROM
|
||||||
|
#define EPCR_EPOS (1<<3) // EEPROM or PHY operation select
|
||||||
|
#define EPCR_ERPRR (1<<2) // EEPROM or PHY read command
|
||||||
|
#define EPCR_ERPRW (1<<1) // EEPROM or PHY write command
|
||||||
|
#define EPCR_ERRE (1<<0) // EEPROM or PHY access status
|
||||||
|
#define CH390_EPAR 0x0C
|
||||||
|
#define CH390_EPDRL 0x0D
|
||||||
|
#define CH390_EPDRH 0x0E
|
||||||
|
#define CH390_WCR 0x0F
|
||||||
|
#define WCR_LINKEN (1<<5) // Link status change wakeup
|
||||||
|
#define WCR_SAMPLEEN (1<<4) // Sample frame wakeup
|
||||||
|
#define WCR_MAGICEN (1<<3) // Magic packet wakeup
|
||||||
|
#define WCR_LINKST (1<<2) // Link status change event
|
||||||
|
#define WCR_SAMPLEST (1<<1) // Sample frame event
|
||||||
|
#define WCR_MAGICST (1<<0) // Magic packet event
|
||||||
|
#define CH390_PAR 0x10
|
||||||
|
#define CH390_MAR 0x16
|
||||||
|
#define CH390_GPCR 0x1E
|
||||||
|
#define CH390_GPR 0x1F
|
||||||
|
#define CH390_TRPAL 0x22
|
||||||
|
#define CH390_TRPAH 0x23
|
||||||
|
#define CH390_RWPAL 0x24
|
||||||
|
#define CH390_RWPAH 0x25
|
||||||
|
#define CH390_VIDL 0x28
|
||||||
|
#define CH390_VIDH 0x29
|
||||||
|
#define CH390_PIDL 0x2A
|
||||||
|
#define CH390_PIDH 0x2B
|
||||||
|
#define CH390_CHIPR 0x2C
|
||||||
|
#define CH390_TCR2 0x2D
|
||||||
|
#define CH390_ETXCSR 0x30
|
||||||
|
#define CH390_TCSCR 0x31
|
||||||
|
#define TCSCR_ALL 0x1F
|
||||||
|
#define TCSCR_IPv6TCPCSE (1<<4) // IPv6 TCP checksum generation
|
||||||
|
#define TCSCR_IPv6UDPCSE (1<<3) // IPv6 UDP checksum generation
|
||||||
|
#define TCSCR_UDPCSE (1<<2) // UDP checksum generation
|
||||||
|
#define TCSCR_TCPCSE (1<<1) // TCP checksum generation
|
||||||
|
#define TCSCR_IPCSE (1<<0) // IP checksum generation
|
||||||
|
#define CH390_RCSCSR 0x32
|
||||||
|
#define RCSCSR_UDPS (1<<7) // UDP checksum status
|
||||||
|
#define RCSCSR_TCPS (1<<6) // TCP checksum status
|
||||||
|
#define RCSCSR_IPS (1<<5) // IP checksum status
|
||||||
|
#define RCSCSR_UDPP (1<<4) // UDP packet of current received packet
|
||||||
|
#define RCSCSR_TCPP (1<<3) // TCP packet of current received packet
|
||||||
|
#define RCSCSR_IPP (1<<2) // IP packet of current received packet
|
||||||
|
#define RCSCSR_RCSEN (1<<1) // Receive checksum checking enable
|
||||||
|
#define RCSCSR_DCSE (1<<0) // Discard checksum error packet
|
||||||
|
#define CH390_MPAR 0x33
|
||||||
|
#define CH390_LEDCR 0x34
|
||||||
|
#define CH390_INTCR 0x39
|
||||||
|
#define INCR_TYPE_OD 0x02
|
||||||
|
#define INCR_TYPE_PP 0x00
|
||||||
|
#define INCR_POL_L 0x01
|
||||||
|
#define INCR_POL_H 0x00
|
||||||
|
#define CH390_SCCR 0x50
|
||||||
|
#define CH390_RSCCR 0x51
|
||||||
|
#define CH390_RLENCR 0x52
|
||||||
|
#define CH390_BCASTCR 0x53
|
||||||
|
#define CH390_MPTRCR 0x55
|
||||||
|
#define CH390_MRCMDX 0xF0
|
||||||
|
#define CH390_MRCMDX1 0xF1
|
||||||
|
#define CH390_MRCMD 0xF2
|
||||||
|
#define CH390_MRRL 0xF4
|
||||||
|
#define CH390_MRRH 0xF5
|
||||||
|
#define CH390_MWCMDX 0xF6
|
||||||
|
#define CH390_MWCMD 0xF8
|
||||||
|
#define CH390_MWRL 0xFA
|
||||||
|
#define CH390_MWRH 0xFB
|
||||||
|
#define CH390_TXPLL 0xFC
|
||||||
|
#define CH390_TXPLH 0xFD
|
||||||
|
#define CH390_ISR 0xFE
|
||||||
|
#define ISR_IOMODE (1<<7) // Parallel interface mode
|
||||||
|
#define ISR_LNKCHG (1<<5) // Link status change
|
||||||
|
#define ISR_UDRUN (1<<4) // Transmit under-run
|
||||||
|
#define ISR_ROO (1<<3) // Receive overflow counter overflow
|
||||||
|
#define ISR_ROS (1<<2) // Receive overflow
|
||||||
|
#define ISR_PT (1<<1) // Packet transmitted
|
||||||
|
#define ISR_PR (1<<0) // Packet received
|
||||||
|
#define CH390_IMR 0xFF
|
||||||
|
#define IMR_NONE 0x00 // Disable all interrupt
|
||||||
|
#define IMR_ALL 0xFF // Enable all interrupt
|
||||||
|
#define IMR_PAR (1<<7) // Pointer auto-return mode
|
||||||
|
#define IMR_LNKCHGI (1<<5) // Enable link status change interrupt
|
||||||
|
#define IMR_UDRUNI (1<<4) // Enable transmit under-run interrupt
|
||||||
|
#define IMR_ROOI (1<<3) // Enable receive overflow counter overflow interrupt
|
||||||
|
#define IMR_ROI (1<<2) // Enable receive overflow interrupt
|
||||||
|
#define IMR_PTI (1<<1) // Enable packet transmitted interrupt
|
||||||
|
#define IMR_PRI (1<<0) // Enable packet received interrupt
|
||||||
|
|
||||||
|
// GPIO
|
||||||
|
#define CH390_GPIO1 0x02
|
||||||
|
#define CH390_GPIO2 0x04
|
||||||
|
#define CH390_GPIO3 0x08
|
||||||
|
#define CH390_GPIO4 0x10
|
||||||
|
#define CH390_GPIO5 0x20
|
||||||
|
#define CH390_GPIO6 0x40
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PHY registers
|
||||||
|
#define CH390_PHY 0x40
|
||||||
|
#define CH390_PHY_BMCR 0x00
|
||||||
|
#define CH390_PHY_BMSR 0x01
|
||||||
|
#define CH390_PHY_PHYID1 0x02
|
||||||
|
#define CH390_PHY_PHYID2 0x03
|
||||||
|
#define CH390_PHY_ANAR 0x04
|
||||||
|
#define CH390_PHY_ANLPAR 0x05
|
||||||
|
#define CH390_PHY_ANER 0x06
|
||||||
|
#define CH390_PHY_PAGE_SEL 0x1F
|
||||||
|
|
||||||
|
// Packet status
|
||||||
|
#define CH390_PKT_NONE 0x00 /* No packet received */
|
||||||
|
#define CH390_PKT_RDY 0x01 /* Packet ready to receive */
|
||||||
|
#define CH390_PKT_ERR 0xFE /* Un-stable states */
|
||||||
|
#define CH390_PKT_MAX 1536 /* Received packet max size */
|
||||||
|
#define CH390_PKT_MIN 64
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
* Functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_receive_packet
|
||||||
|
* @brief Receive packet
|
||||||
|
* @param buff - Size equal to CH390_PKT_MAX
|
||||||
|
* @param rx_status - Output abnormal status while receiving packet.
|
||||||
|
* It has the same format as RSR(06h).
|
||||||
|
* @return Packet length
|
||||||
|
*/
|
||||||
|
uint32_t ch390_receive_packet(uint8_t *buff, uint8_t *rx_status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_send_packet
|
||||||
|
* @brief Send packet
|
||||||
|
* @param buff - Data to be sent
|
||||||
|
* @param length - Less than 3k bytes.
|
||||||
|
*/
|
||||||
|
void ch390_send_packet(uint8_t *buff, uint16_t length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_send_request
|
||||||
|
* @brief Issue transmit request
|
||||||
|
*/
|
||||||
|
void ch390_send_request(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_drop_packet
|
||||||
|
* @brief Drop packet in RX SRAM if don't want to read it. This function
|
||||||
|
* modify the memory data read pointer and skip specified length
|
||||||
|
* @param len - Skip length, length of the current packet.
|
||||||
|
*/
|
||||||
|
void ch390_drop_packet(uint16_t len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_read_phy
|
||||||
|
* @brief Read PHY register
|
||||||
|
* @param reg - PHY register address
|
||||||
|
*/
|
||||||
|
uint16_t ch390_read_phy(uint8_t reg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_write_phy
|
||||||
|
* @brief Write PHY register
|
||||||
|
* @param reg - PHY register address
|
||||||
|
* @param value - Value to be written
|
||||||
|
*/
|
||||||
|
void ch390_write_phy(uint8_t reg, uint16_t value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_write_eeprom
|
||||||
|
* @brief Write EEPROM register
|
||||||
|
* @param reg - EEPROM register address
|
||||||
|
* @param value - Value to be written
|
||||||
|
*/
|
||||||
|
void ch390_write_eeprom(uint8_t reg, uint16_t value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_software_reset
|
||||||
|
* @brief Software reset CH390 by NCR
|
||||||
|
*/
|
||||||
|
void ch390_software_reset(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_default_config
|
||||||
|
* @brief Config CH390 with default options:
|
||||||
|
* LED mode 1;
|
||||||
|
* Enable transmit check sum generation;
|
||||||
|
* Enable RX;
|
||||||
|
* Enable all interrupt and PAR
|
||||||
|
*/
|
||||||
|
void ch390_default_config(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_set_phy_mode
|
||||||
|
* @brief Set PHY mode and enable PHY.
|
||||||
|
* PHY mode: Auto-negotiation, 10M/100M, full-duplex/half-duplex
|
||||||
|
* @param mode - PHY mode
|
||||||
|
*/
|
||||||
|
void ch390_set_phy_mode(enum ch390_phy_mode mode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_set_mac_address
|
||||||
|
* @brief Set mac address
|
||||||
|
* @param mac_addr - 6-byte length mac address array
|
||||||
|
*/
|
||||||
|
void ch390_set_mac_address(uint8_t *mac_addr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_set_multicast
|
||||||
|
* @brief Set multicast address hash table
|
||||||
|
* @param multicast_addr - 8-byte length multicast address hash table array
|
||||||
|
*/
|
||||||
|
void ch390_set_multicast(uint8_t *multicast_hash);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set MAR bit for a particular MAC address
|
||||||
|
* @param mac - Destination address
|
||||||
|
*/
|
||||||
|
void ch390_set_hash_bit(uint8_t *mac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_mac
|
||||||
|
* @brief Get mac address
|
||||||
|
* @param mac_addr - 6 bytes mac address output
|
||||||
|
*/
|
||||||
|
void ch390_get_mac(uint8_t *mac_addr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_multicast
|
||||||
|
* @brief Get multicast address hash table
|
||||||
|
* @param multicast_addr - 8-byte length multicast address hash table output
|
||||||
|
*/
|
||||||
|
void ch390_get_multicast(uint8_t *multicast_addr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_vendor_id
|
||||||
|
* @brief Get vendor ID
|
||||||
|
* @return Vendor ID
|
||||||
|
*/
|
||||||
|
uint16_t ch390_get_vendor_id(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_product_id
|
||||||
|
* @brief Get product ID
|
||||||
|
* @return Product ID
|
||||||
|
*/
|
||||||
|
uint16_t ch390_get_product_id(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_revision
|
||||||
|
* @brief Get chip revision
|
||||||
|
* @return Chip revision
|
||||||
|
*/
|
||||||
|
uint8_t ch390_get_revision(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_interrupt_config
|
||||||
|
* @brief Interrupt configuration
|
||||||
|
* @param mask - Interrupt to be enabled, see "CH390.h" IMR_xxx
|
||||||
|
*/
|
||||||
|
void ch390_interrupt_config(uint8_t mask);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_rx_enable
|
||||||
|
* @brief Enable or disable packet receive
|
||||||
|
* @param op - 0: disable 1: enable
|
||||||
|
*/
|
||||||
|
void ch390_rx_enable(int op);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_rx_filter_config
|
||||||
|
* @brief Configure receive filter.
|
||||||
|
* @param config - See "CH390.h" RCR_xxx
|
||||||
|
*/
|
||||||
|
void ch390_rx_filter_config(uint8_t config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_wakeup_config
|
||||||
|
* @brief Enable or disable wakeup_function
|
||||||
|
* @param events - Events that trigger wakeup,
|
||||||
|
* WCR_LINKEN - Link status change
|
||||||
|
* WCR_SAMPLEEN - Sample frame
|
||||||
|
* WCR_MAGICEN - Magic packet
|
||||||
|
* 0 - Disable wakeup function
|
||||||
|
*/
|
||||||
|
void ch390_wakeup_config(uint8_t events);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_wake_notify
|
||||||
|
* @brief Wait for Magic Packet or Sample Frame and discard all
|
||||||
|
* other packets.
|
||||||
|
* If the application needs to use Wake On LAN, call this
|
||||||
|
* function before MCU enters low power mode. An external
|
||||||
|
* interrupt signal is accessible on WOL pin when wake
|
||||||
|
* up event occurred.
|
||||||
|
*/
|
||||||
|
void ch390_wake_notify(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_loop_back_enable
|
||||||
|
* @brief Enable loop back mode
|
||||||
|
* @param op - 0: disable 1: enable
|
||||||
|
*/
|
||||||
|
void ch390_loop_back_enable(int op);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_duplex_mode
|
||||||
|
* @brief Get current duplex mode of the internal PHY
|
||||||
|
* @return 0: Half-duplex 1: Full-duplex
|
||||||
|
*/
|
||||||
|
int ch390_get_duplex_mode(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_phy_speed
|
||||||
|
* @brief Get the speed of the internal PHY.
|
||||||
|
* Only valid after PHY linked
|
||||||
|
* @return 0: 100Mbps 1: 10Mbps
|
||||||
|
*/
|
||||||
|
int ch390_get_phy_speed(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_link_status
|
||||||
|
* @brief Get link status of the internal PHY
|
||||||
|
* @return 0: Link failed 1: Link OK
|
||||||
|
*/
|
||||||
|
int ch390_get_link_status(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_sleep_control
|
||||||
|
* @brief Enter or exit sleep mode
|
||||||
|
* @param op - 0: Power up 1: Power down
|
||||||
|
*/
|
||||||
|
void ch390_sleep_control(int op);
|
||||||
|
|
||||||
|
#ifndef CH390_INTERFACE_16_BIT
|
||||||
|
/**
|
||||||
|
* @name ch390_gpio_config
|
||||||
|
* @brief Config the input/output direction of GPIO1~3
|
||||||
|
* Only GPIO1~3 can be defined as input, GPIO4~6 are output only
|
||||||
|
* @param GPIOx - CH390_GPIO1 ~ CH390_GPIO3
|
||||||
|
* dir - 0: Input 1: Output
|
||||||
|
*/
|
||||||
|
void ch390_gpio_config(uint8_t GPIOx, uint8_t dir);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_gpio_write_bit
|
||||||
|
* @brief Sets or clears the selected gpio bit.
|
||||||
|
* @param GPIOx - CH390_GPIO1 ~ CH390_GPIO6
|
||||||
|
* level - 0: Clear pin 1: Set pin
|
||||||
|
*/
|
||||||
|
void ch390_gpio_write_bit(uint8_t GPIOx, uint8_t level);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_gpio_read_bit
|
||||||
|
* @brief Read gpio input, only CH390_GPIO1 ~ 3 are available
|
||||||
|
* @param GPIOx - CH390_GPIO1 ~ CH390_GPIO3
|
||||||
|
* @return Input pin value
|
||||||
|
*/
|
||||||
|
uint8_t ch390_gpio_read_bit(uint8_t GPIOx);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_int_pin_config
|
||||||
|
* @brief Configure INT pin output type and polarity
|
||||||
|
* @param type - INCR_TYPE_OD: Open drain output
|
||||||
|
* INCR_TYPE_PP: Push pull output
|
||||||
|
* pol - INCR_POL_L: Active low
|
||||||
|
* INCR_POL_H: Active high
|
||||||
|
*/
|
||||||
|
void ch390_int_pin_config(uint8_t type, uint8_t pol);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_get_int_status
|
||||||
|
* @brief Get CH390 interrupt status and clear them
|
||||||
|
* @return Interrupt status
|
||||||
|
*/
|
||||||
|
uint8_t ch390_get_int_status(void);
|
||||||
|
|
||||||
|
#endif /* __CH390_H */
|
||||||
@@ -0,0 +1,384 @@
|
|||||||
|
/********************************** (C) COPYRIGHT *****************************
|
||||||
|
* File Name : CH390_Interface.c
|
||||||
|
* Author : WCH (Modified for STM32 HAL)
|
||||||
|
* Version : V1.1
|
||||||
|
* Date : 2024/08/20
|
||||||
|
* Description : CH390 interface for STM32 HAL Library (SPI mode)
|
||||||
|
******************************************************************************
|
||||||
|
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||||
|
* Attention: This software (modified or not) and binary are used for
|
||||||
|
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||||
|
*
|
||||||
|
* Modified for STM32F103 HAL Library with FreeRTOS support.
|
||||||
|
******************************************************************************/
|
||||||
|
#include "stm32f1xx_hal.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "CH390.h"
|
||||||
|
#include "CH390_Interface.h"
|
||||||
|
#include "SEGGER_RTT.h"
|
||||||
|
|
||||||
|
/* FreeRTOS includes */
|
||||||
|
#ifdef USE_FREERTOS
|
||||||
|
#include "FreeRTOS.h"
|
||||||
|
#include "task.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file defines CH390 operation interface using STM32 HAL Library.
|
||||||
|
* Only SPI mode is implemented for this project.
|
||||||
|
*
|
||||||
|
* Hardware connections:
|
||||||
|
* - PA4: SPI1_NSS (directly controlled as GPIO for CS)
|
||||||
|
* - PA5: SPI1_SCK
|
||||||
|
* - PA6: SPI1_MISO
|
||||||
|
* - PA7: SPI1_MOSI
|
||||||
|
* - PB0: CH390 INT (EXTI0)
|
||||||
|
* - PB1: CH390 RST
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CH390_INTERFACE_SPI
|
||||||
|
|
||||||
|
/* GPIO Pin Definitions - matching CubeMX configuration */
|
||||||
|
#define CH390_CS_PORT GPIOA
|
||||||
|
#define CH390_CS_PIN GPIO_PIN_4
|
||||||
|
|
||||||
|
#define CH390_RST_PORT GPIOB
|
||||||
|
#define CH390_RST_PIN GPIO_PIN_1
|
||||||
|
|
||||||
|
#define CH390_INT_PORT GPIOB
|
||||||
|
#define CH390_INT_PIN GPIO_PIN_0
|
||||||
|
|
||||||
|
#define CH390_SCK_PORT GPIOA
|
||||||
|
#define CH390_SCK_PIN GPIO_PIN_5
|
||||||
|
#define CH390_MISO_PORT GPIOA
|
||||||
|
#define CH390_MISO_PIN GPIO_PIN_6
|
||||||
|
#define CH390_MOSI_PORT GPIOA
|
||||||
|
#define CH390_MOSI_PIN GPIO_PIN_7
|
||||||
|
|
||||||
|
/* External SPI handle from spi.c */
|
||||||
|
extern SPI_HandleTypeDef hspi1;
|
||||||
|
|
||||||
|
/* Timeout for SPI operations (ms) */
|
||||||
|
#define SPI_TIMEOUT 100
|
||||||
|
#define CH390_SPI_CHUNK_SIZE 64u
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
* Low-level GPIO operations
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set CS pin state
|
||||||
|
* @param state 0=low (select), 1=high (deselect)
|
||||||
|
*/
|
||||||
|
static inline void ch390_cs(uint8_t state)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(CH390_CS_PORT, CH390_CS_PIN,
|
||||||
|
state ? GPIO_PIN_SET : GPIO_PIN_RESET);
|
||||||
|
ch390_delay_us(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set RST pin state
|
||||||
|
* @param state 0=low (reset), 1=high (normal)
|
||||||
|
*/
|
||||||
|
static inline void ch390_rst(uint8_t state)
|
||||||
|
{
|
||||||
|
HAL_GPIO_WritePin(CH390_RST_PORT, CH390_RST_PIN,
|
||||||
|
state ? GPIO_PIN_SET : GPIO_PIN_RESET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
* SPI Communication
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Exchange one byte over SPI
|
||||||
|
* @param byte Byte to send
|
||||||
|
* @return Received byte
|
||||||
|
*/
|
||||||
|
static uint8_t ch390_spi_exchange_byte(uint8_t byte)
|
||||||
|
{
|
||||||
|
uint8_t rx_data = 0;
|
||||||
|
if (HAL_SPI_TransmitReceive(&hspi1, &byte, &rx_data, 1, SPI_TIMEOUT) != HAL_OK)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return rx_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ch390_spi_read_bytes(uint8_t *data, uint16_t length)
|
||||||
|
{
|
||||||
|
static const uint8_t dummy_tx[CH390_SPI_CHUNK_SIZE] = {0};
|
||||||
|
|
||||||
|
while (length > 0u)
|
||||||
|
{
|
||||||
|
uint16_t chunk = (length > CH390_SPI_CHUNK_SIZE) ? CH390_SPI_CHUNK_SIZE : length;
|
||||||
|
if (HAL_SPI_TransmitReceive(&hspi1, (uint8_t *)dummy_tx, data, chunk, SPI_TIMEOUT) != HAL_OK)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
data += chunk;
|
||||||
|
length = (uint16_t)(length - chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ch390_spi_apply_mode(uint32_t polarity, uint32_t phase)
|
||||||
|
{
|
||||||
|
hspi1.Init.CLKPolarity = polarity;
|
||||||
|
hspi1.Init.CLKPhase = phase;
|
||||||
|
hspi1.Init.NSS = SPI_NSS_SOFT;
|
||||||
|
if (HAL_SPI_Init(&hspi1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read a dummy byte (send 0x00)
|
||||||
|
* @return Received byte
|
||||||
|
*/
|
||||||
|
#define ch390_spi_dummy_read() ch390_spi_exchange_byte(0x00)
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
* Public Interface Functions
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize CH390 GPIO pins
|
||||||
|
* @note CS and RST pins are configured here. SPI pins are handled by CubeMX.
|
||||||
|
* INT pin (PB0) is configured as EXTI in CubeMX.
|
||||||
|
*/
|
||||||
|
void ch390_gpio_init(void)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
|
||||||
|
/* Enable GPIO clocks */
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* Configure CS pin (PA4) as GPIO output - we control it manually */
|
||||||
|
/* Note: CubeMX may configure PA4 as SPI1_NSS, we need to reconfigure it */
|
||||||
|
HAL_GPIO_WritePin(CH390_CS_PORT, CH390_CS_PIN, GPIO_PIN_SET); /* Deselect */
|
||||||
|
GPIO_InitStruct.Pin = CH390_CS_PIN;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(CH390_CS_PORT, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* Configure RST pin (PB1) as output */
|
||||||
|
HAL_GPIO_WritePin(CH390_RST_PORT, CH390_RST_PIN, GPIO_PIN_SET); /* Not reset */
|
||||||
|
GPIO_InitStruct.Pin = CH390_RST_PIN;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(CH390_RST_PORT, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* INT pin (PB0) is configured as EXTI input by CubeMX */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize CH390 interrupt (EXTI0 on PB0)
|
||||||
|
* @note EXTI and NVIC are configured in CubeMX. This function can enable/disable.
|
||||||
|
*/
|
||||||
|
void ch390_interrupt_init(void)
|
||||||
|
{
|
||||||
|
/* EXTI0 is configured in CubeMX for PB0 */
|
||||||
|
/* NVIC priority should be >= configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY */
|
||||||
|
/* for FreeRTOS compatibility */
|
||||||
|
HAL_NVIC_SetPriority(EXTI0_IRQn, 6, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize SPI for CH390
|
||||||
|
* @note SPI1 is already initialized by CubeMX. This function reconfigures
|
||||||
|
* for CH390 requirements (Mode 3: CPOL=High, CPHA=2Edge).
|
||||||
|
*/
|
||||||
|
void ch390_spi_init(void)
|
||||||
|
{
|
||||||
|
/* SPI1 is initialized by MX_SPI1_Init() in main.c */
|
||||||
|
/* Reference CH390 SPI path uses mode 3. */
|
||||||
|
ch390_spi_apply_mode(SPI_POLARITY_HIGH, SPI_PHASE_2EDGE);
|
||||||
|
SEGGER_RTT_WriteString(0, "CH390 SPI mode=3 (CPOL=1 CPHA=1)\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get CH390 interrupt pin state
|
||||||
|
* @return Non-zero if INT pin is high (active low interrupt)
|
||||||
|
*/
|
||||||
|
uint16_t ch390_get_int_pin(void)
|
||||||
|
{
|
||||||
|
return HAL_GPIO_ReadPin(CH390_INT_PORT, CH390_INT_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Delay in microseconds
|
||||||
|
* @param time Delay time in microseconds
|
||||||
|
* @note Uses DWT cycle counter for accurate timing if available,
|
||||||
|
* otherwise falls back to simple loop delay.
|
||||||
|
*/
|
||||||
|
void ch390_delay_us(uint32_t time)
|
||||||
|
{
|
||||||
|
#ifdef USE_FREERTOS
|
||||||
|
/* For FreeRTOS, if delay is long enough, use vTaskDelay */
|
||||||
|
if (time >= 1000)
|
||||||
|
{
|
||||||
|
/* Convert to milliseconds and use FreeRTOS delay if in task context */
|
||||||
|
if (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING)
|
||||||
|
{
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(time / 1000));
|
||||||
|
time = time % 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Short delay using DWT or simple loop */
|
||||||
|
if (time > 0)
|
||||||
|
{
|
||||||
|
/* Simple delay loop - approximately calibrated for 72MHz */
|
||||||
|
/* Each iteration is roughly 1/9 us at 72MHz */
|
||||||
|
volatile uint32_t count = time * 9;
|
||||||
|
while (count--)
|
||||||
|
{
|
||||||
|
__NOP();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Hardware reset CH390 by pulling RST pin low
|
||||||
|
*/
|
||||||
|
void ch390_hardware_reset(void)
|
||||||
|
{
|
||||||
|
ch390_delay_us(10000); /* Short delay before reset */
|
||||||
|
ch390_rst(0); /* Assert reset (low) */
|
||||||
|
ch390_delay_us(3000); /* Hold reset for 3ms to satisfy datasheet minimum */
|
||||||
|
ch390_rst(1); /* Release reset (high) */
|
||||||
|
ch390_delay_us(50000); /* Wait 50ms for CH390 to initialize reliably */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------------
|
||||||
|
* CH390 Register/Memory Access Functions (SPI Mode)
|
||||||
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read a CH390 register
|
||||||
|
* @param reg Register address
|
||||||
|
* @return Register value
|
||||||
|
*/
|
||||||
|
uint8_t ch390_read_reg(uint8_t reg)
|
||||||
|
{
|
||||||
|
uint8_t value;
|
||||||
|
|
||||||
|
ch390_cs(0); /* CS low - select */
|
||||||
|
ch390_spi_exchange_byte(reg | OPC_REG_R); /* Send read command */
|
||||||
|
value = ch390_spi_dummy_read(); /* Read register value */
|
||||||
|
ch390_cs(1); /* CS high - deselect */
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write a CH390 register
|
||||||
|
* @param reg Register address
|
||||||
|
* @param value Value to write
|
||||||
|
*/
|
||||||
|
void ch390_write_reg(uint8_t reg, uint8_t value)
|
||||||
|
{
|
||||||
|
ch390_cs(0); /* CS low - select */
|
||||||
|
(void)ch390_spi_exchange_byte(reg | OPC_REG_W);
|
||||||
|
(void)ch390_spi_exchange_byte(value);
|
||||||
|
ch390_cs(1); /* CS high - deselect */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read data from CH390 RX SRAM
|
||||||
|
* @param data Buffer to store received data
|
||||||
|
* @param length Number of bytes to read
|
||||||
|
*/
|
||||||
|
void ch390_read_mem(uint8_t *data, int length)
|
||||||
|
{
|
||||||
|
if (data == NULL || length <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ch390_cs(0); /* CS low - select */
|
||||||
|
ch390_spi_exchange_byte(OPC_MEM_READ); /* Send memory read command */
|
||||||
|
|
||||||
|
(void)ch390_spi_read_bytes(data, (uint16_t)length);
|
||||||
|
|
||||||
|
ch390_cs(1); /* CS high - deselect */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read data from CH390 RX SRAM using DMA (for larger transfers)
|
||||||
|
* @param data Buffer to store received data
|
||||||
|
* @param length Number of bytes to read
|
||||||
|
* @note Falls back to polling mode for small transfers
|
||||||
|
*/
|
||||||
|
void ch390_read_mem_dma(uint8_t *data, int length)
|
||||||
|
{
|
||||||
|
/* For small transfers, use polling mode */
|
||||||
|
if (length < 64)
|
||||||
|
{
|
||||||
|
ch390_read_mem(data, length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For larger transfers, could use DMA - currently using polling */
|
||||||
|
/* TODO: Implement DMA transfer if needed for performance */
|
||||||
|
ch390_read_mem(data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write data to CH390 TX SRAM
|
||||||
|
* @param data Data buffer to send
|
||||||
|
* @param length Number of bytes to write
|
||||||
|
*/
|
||||||
|
void ch390_write_mem(uint8_t *data, int length)
|
||||||
|
{
|
||||||
|
if (data == NULL || length <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ch390_cs(0); /* CS low - select */
|
||||||
|
ch390_spi_exchange_byte(OPC_MEM_WRITE); /* Send memory write command */
|
||||||
|
|
||||||
|
(void)HAL_SPI_Transmit(&hspi1, data, (uint16_t)length, SPI_TIMEOUT);
|
||||||
|
|
||||||
|
ch390_cs(1); /* CS high - deselect */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Write data to CH390 TX SRAM using DMA (for larger transfers)
|
||||||
|
* @param data Data buffer to send
|
||||||
|
* @param length Number of bytes to write
|
||||||
|
* @note Falls back to polling mode for small transfers
|
||||||
|
*/
|
||||||
|
void ch390_write_mem_dma(uint8_t *data, int length)
|
||||||
|
{
|
||||||
|
/* For small transfers, use polling mode */
|
||||||
|
if (length < 64)
|
||||||
|
{
|
||||||
|
ch390_write_mem(data, length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* For larger transfers, could use DMA - currently using polling */
|
||||||
|
/* TODO: Implement DMA transfer if needed for performance */
|
||||||
|
ch390_write_mem(data, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* CH390_INTERFACE_SPI */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Non-SPI modes (8-bit/16-bit parallel) are not implemented for this project.
|
||||||
|
* This project uses SPI interface only.
|
||||||
|
*/
|
||||||
|
#error "This project only supports CH390 SPI interface. Please define CH390_INTERFACE_SPI in CH390.h"
|
||||||
|
|
||||||
|
#endif /* CH390_INTERFACE_SPI */
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/********************************** (C) COPYRIGHT *******************************
|
||||||
|
* File Name : CH390.h
|
||||||
|
* Author : WCH
|
||||||
|
* Version : V1.0
|
||||||
|
* Date : 2024/08/20
|
||||||
|
* Description : CH390 interface header file
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __CH390_INTERFACE_H
|
||||||
|
#define __CH390_INTERFACE_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "CH390.h"
|
||||||
|
|
||||||
|
void ch390_gpio_init(void);
|
||||||
|
void ch390_interrupt_init(void);
|
||||||
|
void ch390_spi_init(void);
|
||||||
|
|
||||||
|
uint16_t ch390_get_int_pin(void);
|
||||||
|
void ch390_delay_us(uint32_t time);
|
||||||
|
void ch390_hardware_reset(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_read_reg
|
||||||
|
* @brief Read register
|
||||||
|
* @param reg - Target register address
|
||||||
|
* @return Register value
|
||||||
|
*/
|
||||||
|
uint8_t ch390_read_reg(uint8_t reg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_write_reg
|
||||||
|
* @brief Write register
|
||||||
|
* @param reg - Target register address
|
||||||
|
* @param value - Value to be written
|
||||||
|
*/
|
||||||
|
void ch390_write_reg(uint8_t reg, uint8_t value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_read_mem
|
||||||
|
* @brief Read data from RX SRAM
|
||||||
|
* @param data - Data buffer
|
||||||
|
* @param length - Length to read
|
||||||
|
*/
|
||||||
|
void ch390_read_mem(uint8_t *data, int length);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name ch390_write_mem
|
||||||
|
* @brief Write data to TX SRAM
|
||||||
|
* @param data - Data buffer
|
||||||
|
* @param length - Length to write
|
||||||
|
*/
|
||||||
|
void ch390_write_mem(uint8_t *data, int length);
|
||||||
|
|
||||||
|
#endif /* __CH390_INTERFACE_H */
|
||||||
@@ -0,0 +1,520 @@
|
|||||||
|
#include "ch390_runtime.h"
|
||||||
|
|
||||||
|
#include "CH390.h"
|
||||||
|
#include "CH390_Interface.h"
|
||||||
|
#include "SEGGER_RTT.h"
|
||||||
|
#include "ethernetif.h"
|
||||||
|
#include "stm32f1xx_hal.h"
|
||||||
|
#include "lwip/etharp.h"
|
||||||
|
#include "lwip/pbuf.h"
|
||||||
|
#include "lwip/stats.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static void ch390_runtime_dispatch_frame(struct netif *netif, struct pbuf *p)
|
||||||
|
{
|
||||||
|
if ((p != NULL) && (netif->input(p, netif) != ERR_OK)) {
|
||||||
|
pbuf_free(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t ch390_runtime_drain_rx(struct netif *netif, uint8_t max_frames)
|
||||||
|
{
|
||||||
|
struct pbuf *p;
|
||||||
|
uint8_t drained = 0u;
|
||||||
|
|
||||||
|
while (drained < max_frames) {
|
||||||
|
p = ch390_runtime_input_frame(netif);
|
||||||
|
if (p == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ch390_runtime_dispatch_frame(netif, p);
|
||||||
|
drained++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return drained;
|
||||||
|
}
|
||||||
|
|
||||||
|
static volatile uint8_t g_ch390_irq_pending;
|
||||||
|
static uint8_t g_ch390_ready;
|
||||||
|
static ch390_diag_t g_diag;
|
||||||
|
static uint8_t g_tx_consecutive_timeout;
|
||||||
|
static uint8_t g_chip_reset_count;
|
||||||
|
static uint8_t g_link_restart_pending;
|
||||||
|
|
||||||
|
#define TX_BUSY_WAIT_TIMEOUT_MS 10u
|
||||||
|
#define TX_TIMEOUT_RESET_THRESHOLD 6u
|
||||||
|
#define HEALTH_FAIL_THRESHOLD 3u
|
||||||
|
#define RESTART_PENDING_FLAG 0x01u
|
||||||
|
#define HEALTH_FAIL_SHIFT 4u
|
||||||
|
#define HEALTH_FAIL_MASK 0xF0u
|
||||||
|
|
||||||
|
static bool ch390_mac_address_valid(const uint8_t *mac);
|
||||||
|
|
||||||
|
static uint8_t ch390_runtime_is_restart_pending(void)
|
||||||
|
{
|
||||||
|
return (uint8_t)(g_link_restart_pending & RESTART_PENDING_FLAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ch390_runtime_set_restart_pending(void)
|
||||||
|
{
|
||||||
|
g_link_restart_pending = (uint8_t)(g_link_restart_pending | RESTART_PENDING_FLAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ch390_runtime_clear_restart_pending(void)
|
||||||
|
{
|
||||||
|
g_link_restart_pending = (uint8_t)(g_link_restart_pending & (uint8_t)(~RESTART_PENDING_FLAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t ch390_runtime_get_health_fail_count(void)
|
||||||
|
{
|
||||||
|
return (uint8_t)((g_link_restart_pending & HEALTH_FAIL_MASK) >> HEALTH_FAIL_SHIFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ch390_runtime_set_health_fail_count(uint8_t count)
|
||||||
|
{
|
||||||
|
g_link_restart_pending = (uint8_t)((g_link_restart_pending & (uint8_t)(~HEALTH_FAIL_MASK)) |
|
||||||
|
(uint8_t)((count << HEALTH_FAIL_SHIFT) & HEALTH_FAIL_MASK));
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t ch390_runtime_probe_identity(void)
|
||||||
|
{
|
||||||
|
g_diag.vendor_id = ch390_get_vendor_id();
|
||||||
|
g_diag.product_id = ch390_get_product_id();
|
||||||
|
g_diag.revision = ch390_get_revision();
|
||||||
|
g_diag.phy_bmcr = ch390_read_phy(CH390_PHY_BMCR);
|
||||||
|
g_diag.phy_bmsr = ch390_read_phy(CH390_PHY_BMSR);
|
||||||
|
g_diag.phy_id1 = ch390_read_phy(CH390_PHY_PHYID1);
|
||||||
|
g_diag.phy_id2 = ch390_read_phy(CH390_PHY_PHYID2);
|
||||||
|
g_diag.phy_anar = ch390_read_phy(CH390_PHY_ANAR);
|
||||||
|
g_diag.phy_anlpar = ch390_read_phy(CH390_PHY_ANLPAR);
|
||||||
|
g_diag.phy_aner = ch390_read_phy(CH390_PHY_ANER);
|
||||||
|
g_diag.nsr = ch390_read_reg(CH390_NSR);
|
||||||
|
g_diag.ncr = ch390_read_reg(CH390_NCR);
|
||||||
|
g_diag.rcr = ch390_read_reg(CH390_RCR);
|
||||||
|
g_diag.imr = ch390_read_reg(CH390_IMR);
|
||||||
|
g_diag.intcr = ch390_read_reg(CH390_INTCR);
|
||||||
|
g_diag.gpr = ch390_read_reg(CH390_GPR);
|
||||||
|
g_diag.isr = ch390_read_reg(CH390_ISR);
|
||||||
|
g_diag.phy_speed_10m = 0u;
|
||||||
|
g_diag.phy_full_duplex = 0u;
|
||||||
|
g_diag.link_up = (uint8_t)0u;
|
||||||
|
g_diag.id_valid = (uint8_t)((g_diag.vendor_id != 0x0000u) &&
|
||||||
|
(g_diag.vendor_id != 0xFFFFu) &&
|
||||||
|
(g_diag.product_id != 0x0000u) &&
|
||||||
|
(g_diag.product_id != 0xFFFFu));
|
||||||
|
return g_diag.id_valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ch390_runtime_prepare_netif(struct netif *netif)
|
||||||
|
{
|
||||||
|
struct ethernetif *ethernetif;
|
||||||
|
|
||||||
|
if (netif == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
||||||
|
netif->mtu = 1500;
|
||||||
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
|
||||||
|
|
||||||
|
ethernetif = (struct ethernetif *)netif->state;
|
||||||
|
if (ethernetif != NULL) {
|
||||||
|
ethernetif->rx_len = 0u;
|
||||||
|
ethernetif->rx_status = 0u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ch390_runtime_sync_mac(struct netif *netif)
|
||||||
|
{
|
||||||
|
if (netif == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch390_mac_address_valid(netif->hwaddr)) {
|
||||||
|
ch390_set_mac_address(netif->hwaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
ch390_get_mac(netif->hwaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ch390_runtime_refresh_diag(void)
|
||||||
|
{
|
||||||
|
uint8_t id_valid = ch390_runtime_probe_identity();
|
||||||
|
g_diag.int_pin = (uint8_t)ch390_get_int_pin();
|
||||||
|
|
||||||
|
if (id_valid != 0u) {
|
||||||
|
g_diag.phy_speed_10m = (uint8_t)ch390_get_phy_speed();
|
||||||
|
g_diag.phy_full_duplex = (uint8_t)ch390_get_duplex_mode();
|
||||||
|
g_diag.link_up = (uint8_t)ch390_get_link_status();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct pbuf *ch390_runtime_input_frame(struct netif *netif)
|
||||||
|
{
|
||||||
|
struct ethernetif *ethernetif = (struct ethernetif *)netif->state;
|
||||||
|
struct pbuf *p = NULL;
|
||||||
|
struct pbuf *q;
|
||||||
|
uint16_t len;
|
||||||
|
uint16_t frame_len;
|
||||||
|
uint8_t rcr;
|
||||||
|
uint8_t rx_ready;
|
||||||
|
uint8_t rx_header[4];
|
||||||
|
ch390_read_reg(CH390_MRCMDX);
|
||||||
|
rx_ready = ch390_read_reg(CH390_MRCMDX);
|
||||||
|
|
||||||
|
if (rx_ready & CH390_PKT_ERR) {
|
||||||
|
rcr = ch390_read_reg(CH390_RCR);
|
||||||
|
ch390_write_reg(CH390_RCR, (uint8_t)(rcr & (uint8_t)(~RCR_RXEN)));
|
||||||
|
ch390_write_reg(CH390_MPTRCR, 0x01u);
|
||||||
|
ch390_write_reg(CH390_MRRH, 0x0Cu);
|
||||||
|
ch390_delay_us(1000u);
|
||||||
|
ch390_write_reg(CH390_RCR, (uint8_t)(rcr | RCR_RXEN));
|
||||||
|
ethernetif->rx_len = 0u;
|
||||||
|
LINK_STATS_INC(link.drop);
|
||||||
|
g_diag.rx_packets_drop++;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((rx_ready & CH390_PKT_RDY) == 0u) {
|
||||||
|
ethernetif->rx_len = 0u;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_diag.rx_ready_hits++;
|
||||||
|
|
||||||
|
ch390_read_mem(rx_header, 4);
|
||||||
|
ethernetif->rx_status = rx_header[1];
|
||||||
|
frame_len = (uint16_t)((uint16_t)rx_header[2] | ((uint16_t)rx_header[3] << 8));
|
||||||
|
|
||||||
|
if ((ethernetif->rx_status & 0x3Fu) != 0u || frame_len == 0u || frame_len > CH390_PKT_MAX) {
|
||||||
|
ethernetif->rx_len = 0u;
|
||||||
|
ch390_drop_packet(frame_len);
|
||||||
|
LINK_STATS_INC(link.drop);
|
||||||
|
g_diag.rx_packets_drop++;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ethernetif->rx_len = frame_len;
|
||||||
|
len = ethernetif->rx_len;
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
len += ETH_PAD_SIZE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
|
||||||
|
if (p != NULL) {
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
pbuf_remove_header(p, ETH_PAD_SIZE);
|
||||||
|
#endif
|
||||||
|
for (q = p; q != NULL; q = q->next) {
|
||||||
|
ch390_read_mem((uint8_t *)q->payload, q->len);
|
||||||
|
}
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
pbuf_add_header(p, ETH_PAD_SIZE);
|
||||||
|
#endif
|
||||||
|
LINK_STATS_INC(link.recv);
|
||||||
|
g_diag.rx_packets_ok++;
|
||||||
|
|
||||||
|
g_diag.last_frame_len = frame_len;
|
||||||
|
g_diag.last_payload_len = p->tot_len;
|
||||||
|
} else {
|
||||||
|
ch390_drop_packet(ethernetif->rx_len);
|
||||||
|
LINK_STATS_INC(link.memerr);
|
||||||
|
LINK_STATS_INC(link.drop);
|
||||||
|
g_diag.rx_packets_drop++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ch390_mac_address_valid(const uint8_t *mac)
|
||||||
|
{
|
||||||
|
if (mac == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (uint8_t i = 0; i < ETHARP_HWADDR_LEN; ++i) {
|
||||||
|
if (mac[i] == 0u) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ch390_runtime_init(struct netif *netif, const uint8_t *mac)
|
||||||
|
{
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: gpio\r\n");
|
||||||
|
ch390_gpio_init();
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: spi\r\n");
|
||||||
|
ch390_spi_init();
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: reset\r\n");
|
||||||
|
ch390_hardware_reset();
|
||||||
|
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: probe\r\n");
|
||||||
|
g_ch390_ready = ch390_runtime_probe_identity();
|
||||||
|
if (g_ch390_ready == 0u) {
|
||||||
|
ch390_runtime_prepare_netif(netif);
|
||||||
|
netif_set_link_down(netif);
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: invalid chip id\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: default\r\n");
|
||||||
|
ch390_default_config();
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: mac\r\n");
|
||||||
|
if (ch390_mac_address_valid(mac)) {
|
||||||
|
ch390_set_mac_address((uint8_t *)mac);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (mac != NULL) {
|
||||||
|
ch390_get_mac((uint8_t *)mac);
|
||||||
|
SEGGER_RTT_printf(0, "ETH init: invalid MAC in config, using hardware MAC: %02X:%02X:%02X:%02X:%02X:%02X\r\n",
|
||||||
|
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: no MAC in config\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: getmac\r\n");
|
||||||
|
ch390_runtime_prepare_netif(netif);
|
||||||
|
ch390_get_mac(netif->hwaddr);
|
||||||
|
|
||||||
|
ch390_runtime_refresh_diag();
|
||||||
|
g_ch390_ready = g_diag.id_valid;
|
||||||
|
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: irq\r\n");
|
||||||
|
ch390_interrupt_init();
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH init: done\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void ch390_runtime_set_irq_pending(void)
|
||||||
|
{
|
||||||
|
g_ch390_irq_pending = 1u;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ch390_runtime_is_irq_pending(void)
|
||||||
|
{
|
||||||
|
return g_ch390_irq_pending;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ch390_runtime_poll(struct netif *netif)
|
||||||
|
{
|
||||||
|
uint8_t int_status;
|
||||||
|
uint8_t rx_ready;
|
||||||
|
uint8_t rx_budget;
|
||||||
|
uint8_t rx_hint;
|
||||||
|
|
||||||
|
if (!g_ch390_ready) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_diag.rx_poll_calls++;
|
||||||
|
|
||||||
|
rx_budget = 1u;
|
||||||
|
rx_hint = 0u;
|
||||||
|
|
||||||
|
if ((g_ch390_irq_pending != 0u) || (ch390_get_int_pin() == GPIO_PIN_RESET)) {
|
||||||
|
g_ch390_irq_pending = 0u;
|
||||||
|
int_status = ch390_get_int_status();
|
||||||
|
|
||||||
|
if ((int_status & ISR_LNKCHG) != 0u) {
|
||||||
|
ch390_runtime_check_link(netif);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((int_status & ISR_ROS) != 0u) {
|
||||||
|
LINK_STATS_INC(link.err);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((int_status & (ISR_PR | ISR_ROS | ISR_ROO)) != 0u) {
|
||||||
|
rx_hint = 1u;
|
||||||
|
rx_budget = 8u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ch390_read_reg(CH390_MRCMDX);
|
||||||
|
rx_ready = ch390_read_reg(CH390_MRCMDX);
|
||||||
|
if ((rx_ready & CH390_PKT_RDY) != 0u) {
|
||||||
|
rx_hint = 1u;
|
||||||
|
if (rx_budget < 4u) {
|
||||||
|
rx_budget = 4u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rx_hint != 0u) {
|
||||||
|
(void)ch390_runtime_drain_rx(netif, rx_budget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ch390_runtime_check_link(struct netif *netif)
|
||||||
|
{
|
||||||
|
uint8_t link_up;
|
||||||
|
static uint8_t s_last_reported = 0xFFu;
|
||||||
|
|
||||||
|
if (!g_ch390_ready) {
|
||||||
|
netif_set_link_down(netif);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch390_runtime_is_restart_pending() != 0u) {
|
||||||
|
netif_set_link_down(netif);
|
||||||
|
ch390_runtime_clear_restart_pending();
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH restart pending: hold link down for app recycle\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ch390_runtime_refresh_diag();
|
||||||
|
link_up = (uint8_t)ch390_get_link_status();
|
||||||
|
|
||||||
|
if (link_up != s_last_reported) {
|
||||||
|
SEGGER_RTT_printf(0,
|
||||||
|
"ETH link %s nsr=0x%02X bmsr=0x%04X anlpar=0x%04X\r\n",
|
||||||
|
link_up ? "up" : "down",
|
||||||
|
g_diag.nsr,
|
||||||
|
g_diag.phy_bmsr,
|
||||||
|
g_diag.phy_anlpar);
|
||||||
|
s_last_reported = link_up;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (link_up) {
|
||||||
|
if (!netif_is_link_up(netif)) {
|
||||||
|
netif_set_link_up(netif);
|
||||||
|
}
|
||||||
|
} else if (netif_is_link_up(netif)) {
|
||||||
|
netif_set_link_down(netif);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err_t ch390_runtime_output(struct netif *netif, struct pbuf *p)
|
||||||
|
{
|
||||||
|
struct pbuf *q;
|
||||||
|
uint32_t start_tick;
|
||||||
|
|
||||||
|
if (!g_ch390_ready) {
|
||||||
|
LINK_STATS_INC(link.drop);
|
||||||
|
return ERR_IF;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
pbuf_remove_header(p, ETH_PAD_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
start_tick = HAL_GetTick();
|
||||||
|
while (ch390_read_reg(CH390_TCR) & TCR_TXREQ) {
|
||||||
|
if ((HAL_GetTick() - start_tick) > TX_BUSY_WAIT_TIMEOUT_MS) {
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
pbuf_add_header(p, ETH_PAD_SIZE);
|
||||||
|
#endif
|
||||||
|
LINK_STATS_INC(link.drop);
|
||||||
|
g_diag.tx_packets_timeout++;
|
||||||
|
if (g_tx_consecutive_timeout < 0xFFu) {
|
||||||
|
g_tx_consecutive_timeout++;
|
||||||
|
}
|
||||||
|
if (g_tx_consecutive_timeout >= TX_TIMEOUT_RESET_THRESHOLD) {
|
||||||
|
(void)ch390_runtime_emergency_reset(netif);
|
||||||
|
}
|
||||||
|
return ERR_TIMEOUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_tx_consecutive_timeout = 0u;
|
||||||
|
|
||||||
|
for (q = p; q != NULL; q = q->next) {
|
||||||
|
ch390_write_mem((uint8_t *)q->payload, q->len);
|
||||||
|
}
|
||||||
|
|
||||||
|
ch390_write_reg(CH390_TXPLL, p->tot_len & 0xFFu);
|
||||||
|
ch390_write_reg(CH390_TXPLH, (p->tot_len >> 8) & 0xFFu);
|
||||||
|
ch390_send_request();
|
||||||
|
|
||||||
|
#if ETH_PAD_SIZE
|
||||||
|
pbuf_add_header(p, ETH_PAD_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LINK_STATS_INC(link.xmit);
|
||||||
|
g_diag.tx_packets_ok++;
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ch390_runtime_get_diag(ch390_diag_t *diag)
|
||||||
|
{
|
||||||
|
if (diag != NULL) {
|
||||||
|
ch390_runtime_refresh_diag();
|
||||||
|
*diag = g_diag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ch390_runtime_is_ready(void)
|
||||||
|
{
|
||||||
|
return g_ch390_ready != 0u;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ch390_runtime_emergency_reset(struct netif *netif)
|
||||||
|
{
|
||||||
|
SEGGER_RTT_printf(0, "ETH emergency reset (tx_timeout=%u resets=%u)\r\n",
|
||||||
|
g_tx_consecutive_timeout, g_chip_reset_count);
|
||||||
|
|
||||||
|
if (netif != NULL) {
|
||||||
|
netif_set_link_down(netif);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_chip_reset_count < 0xFFu) {
|
||||||
|
g_chip_reset_count++;
|
||||||
|
}
|
||||||
|
g_tx_consecutive_timeout = 0u;
|
||||||
|
|
||||||
|
ch390_software_reset();
|
||||||
|
ch390_delay_us(5000u);
|
||||||
|
ch390_default_config();
|
||||||
|
ch390_runtime_prepare_netif(netif);
|
||||||
|
ch390_runtime_sync_mac(netif);
|
||||||
|
g_ch390_irq_pending = 0u;
|
||||||
|
|
||||||
|
ch390_runtime_refresh_diag();
|
||||||
|
g_ch390_ready = g_diag.id_valid;
|
||||||
|
|
||||||
|
if (g_ch390_ready == 0u) {
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH emergency reset: chip not responding\r\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ch390_runtime_set_health_fail_count(0u);
|
||||||
|
ch390_runtime_set_restart_pending();
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH emergency reset: OK\r\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ch390_runtime_health_check(struct netif *netif)
|
||||||
|
{
|
||||||
|
uint16_t vid;
|
||||||
|
uint8_t fail_count;
|
||||||
|
|
||||||
|
if (!g_ch390_ready) {
|
||||||
|
SEGGER_RTT_WriteString(0, "ETH health: chip not ready, attempting reset\r\n");
|
||||||
|
(void)ch390_runtime_emergency_reset(netif);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Verify chip is still responding by reading vendor ID */
|
||||||
|
vid = ch390_get_vendor_id();
|
||||||
|
if (vid == 0x0000u || vid == 0xFFFFu) {
|
||||||
|
fail_count = ch390_runtime_get_health_fail_count();
|
||||||
|
if (fail_count < 0x0Fu) {
|
||||||
|
fail_count++;
|
||||||
|
}
|
||||||
|
ch390_runtime_set_health_fail_count(fail_count);
|
||||||
|
if (fail_count >= HEALTH_FAIL_THRESHOLD) {
|
||||||
|
SEGGER_RTT_printf(0, "ETH health: invalid VID=0x%04X streak=%u, attempting reset\r\n",
|
||||||
|
vid,
|
||||||
|
fail_count);
|
||||||
|
ch390_runtime_set_health_fail_count(0u);
|
||||||
|
(void)ch390_runtime_emergency_reset(netif);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ch390_runtime_set_health_fail_count(0u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ch390_runtime_get_reset_count(void)
|
||||||
|
{
|
||||||
|
return g_chip_reset_count;
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
#ifndef __CH390_RUNTIME_H__
|
||||||
|
#define __CH390_RUNTIME_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "lwip/err.h"
|
||||||
|
|
||||||
|
struct netif;
|
||||||
|
struct pbuf;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t vendor_id;
|
||||||
|
uint16_t product_id;
|
||||||
|
uint8_t revision;
|
||||||
|
uint16_t phy_bmcr;
|
||||||
|
uint16_t phy_bmsr;
|
||||||
|
uint16_t phy_id1;
|
||||||
|
uint16_t phy_id2;
|
||||||
|
uint16_t phy_anar;
|
||||||
|
uint16_t phy_anlpar;
|
||||||
|
uint16_t phy_aner;
|
||||||
|
uint8_t nsr;
|
||||||
|
uint8_t ncr;
|
||||||
|
uint8_t rcr;
|
||||||
|
uint8_t imr;
|
||||||
|
uint8_t intcr;
|
||||||
|
uint8_t gpr;
|
||||||
|
uint8_t isr;
|
||||||
|
uint8_t int_pin;
|
||||||
|
uint8_t phy_speed_10m;
|
||||||
|
uint8_t phy_full_duplex;
|
||||||
|
uint8_t link_up;
|
||||||
|
uint8_t id_valid;
|
||||||
|
uint32_t rx_poll_calls;
|
||||||
|
uint32_t rx_ready_hits;
|
||||||
|
uint32_t rx_packets_ok;
|
||||||
|
uint32_t rx_packets_drop;
|
||||||
|
uint32_t tx_packets_ok;
|
||||||
|
uint32_t tx_packets_timeout;
|
||||||
|
uint32_t rx_arp_frames;
|
||||||
|
uint32_t rx_ip_frames;
|
||||||
|
uint32_t rx_other_frames;
|
||||||
|
uint32_t rx_unicast_self_frames;
|
||||||
|
uint32_t rx_broadcast_frames;
|
||||||
|
uint32_t rx_multicast_frames;
|
||||||
|
uint16_t last_frame_len;
|
||||||
|
uint16_t last_payload_len;
|
||||||
|
uint16_t last_eth_type;
|
||||||
|
} ch390_diag_t;
|
||||||
|
|
||||||
|
void ch390_runtime_init(struct netif *netif, const uint8_t *mac);
|
||||||
|
struct pbuf *ch390_runtime_input_frame(struct netif *netif);
|
||||||
|
void ch390_runtime_set_irq_pending(void);
|
||||||
|
uint8_t ch390_runtime_is_irq_pending(void);
|
||||||
|
void ch390_runtime_poll(struct netif *netif);
|
||||||
|
void ch390_runtime_check_link(struct netif *netif);
|
||||||
|
err_t ch390_runtime_output(struct netif *netif, struct pbuf *p);
|
||||||
|
void ch390_runtime_get_diag(ch390_diag_t *diag);
|
||||||
|
bool ch390_runtime_is_ready(void);
|
||||||
|
bool ch390_runtime_emergency_reset(struct netif *netif);
|
||||||
|
void ch390_runtime_health_check(struct netif *netif);
|
||||||
|
uint8_t ch390_runtime_get_reset_count(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,313 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f100xb.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F100xB Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_IRQHandler ; ADC1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15
|
|
||||||
DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16
|
|
||||||
DCD TIM1_TRG_COM_TIM17_IRQHandler ; TIM1 Trigger and Commutation and TIM17
|
|
||||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
DCD CEC_IRQHandler ; HDMI-CEC
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC underrun
|
|
||||||
DCD TIM7_IRQHandler ; TIM7
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_UP_TIM16_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_TRG_COM_TIM17_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT CEC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM6_DAC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM7_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM1_BRK_TIM15_IRQHandler
|
|
||||||
TIM1_UP_TIM16_IRQHandler
|
|
||||||
TIM1_TRG_COM_TIM17_IRQHandler
|
|
||||||
TIM1_CC_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
CEC_IRQHandler
|
|
||||||
TIM6_DAC_IRQHandler
|
|
||||||
TIM7_IRQHandler
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,344 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f100xe.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F100xE Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system and also configure the external
|
|
||||||
;* SRAM mounted on STM32100E-EVAL board to be used as data
|
|
||||||
;* memory (optional, to be enabled by user)
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_IRQHandler ; ADC1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD TIM1_BRK_TIM15_IRQHandler ; TIM1 Break and TIM15
|
|
||||||
DCD TIM1_UP_TIM16_IRQHandler ; TIM1 Update and TIM16
|
|
||||||
DCD TIM1_TRG_COM_TIM17_IRQHandler ; TIM1 Trigger and Commutation and TIM17
|
|
||||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
DCD CEC_IRQHandler ; HDMI CEC
|
|
||||||
DCD TIM12_IRQHandler ; TIM12
|
|
||||||
DCD TIM13_IRQHandler ; TIM13
|
|
||||||
DCD TIM14_IRQHandler ; TIM14
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM5_IRQHandler ; TIM5
|
|
||||||
DCD SPI3_IRQHandler ; SPI3
|
|
||||||
DCD UART4_IRQHandler ; UART4
|
|
||||||
DCD UART5_IRQHandler ; UART5
|
|
||||||
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC underrun
|
|
||||||
DCD TIM7_IRQHandler ; TIM7
|
|
||||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
|
|
||||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
|
|
||||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
|
|
||||||
DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5
|
|
||||||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel5
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_BRK_TIM15_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_UP_TIM16_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_TRG_COM_TIM17_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT CEC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM12_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM13_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM14_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM5_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI3_IRQHandler [WEAK]
|
|
||||||
EXPORT UART4_IRQHandler [WEAK]
|
|
||||||
EXPORT UART5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM6_DAC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM7_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel4_5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel5_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM1_BRK_TIM15_IRQHandler
|
|
||||||
TIM1_UP_TIM16_IRQHandler
|
|
||||||
TIM1_TRG_COM_TIM17_IRQHandler
|
|
||||||
TIM1_CC_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
CEC_IRQHandler
|
|
||||||
TIM12_IRQHandler
|
|
||||||
TIM13_IRQHandler
|
|
||||||
TIM14_IRQHandler
|
|
||||||
TIM5_IRQHandler
|
|
||||||
SPI3_IRQHandler
|
|
||||||
UART4_IRQHandler
|
|
||||||
UART5_IRQHandler
|
|
||||||
TIM6_DAC_IRQHandler
|
|
||||||
TIM7_IRQHandler
|
|
||||||
DMA2_Channel1_IRQHandler
|
|
||||||
DMA2_Channel2_IRQHandler
|
|
||||||
DMA2_Channel3_IRQHandler
|
|
||||||
DMA2_Channel4_5_IRQHandler
|
|
||||||
DMA2_Channel5_IRQHandler
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,276 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f101x6.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F101x6 Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_IRQHandler ; ADC1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler routine
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,286 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f101xb.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F101xB Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_IRQHandler ; ADC1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,324 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f101xe.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F101xE Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_IRQHandler ; ADC1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD FSMC_IRQHandler ; FSMC
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM5_IRQHandler ; TIM5
|
|
||||||
DCD SPI3_IRQHandler ; SPI3
|
|
||||||
DCD UART4_IRQHandler ; UART4
|
|
||||||
DCD UART5_IRQHandler ; UART5
|
|
||||||
DCD TIM6_IRQHandler ; TIM6
|
|
||||||
DCD TIM7_IRQHandler ; TIM7
|
|
||||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
|
|
||||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
|
|
||||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
|
|
||||||
DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT FSMC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM5_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI3_IRQHandler [WEAK]
|
|
||||||
EXPORT UART4_IRQHandler [WEAK]
|
|
||||||
EXPORT UART5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM6_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM7_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel4_5_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
FSMC_IRQHandler
|
|
||||||
TIM5_IRQHandler
|
|
||||||
SPI3_IRQHandler
|
|
||||||
UART4_IRQHandler
|
|
||||||
UART5_IRQHandler
|
|
||||||
TIM6_IRQHandler
|
|
||||||
TIM7_IRQHandler
|
|
||||||
DMA2_Channel1_IRQHandler
|
|
||||||
DMA2_Channel2_IRQHandler
|
|
||||||
DMA2_Channel3_IRQHandler
|
|
||||||
DMA2_Channel4_5_IRQHandler
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,336 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f101xg.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F101xG Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_IRQHandler ; ADC1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD TIM9_IRQHandler ; TIM9
|
|
||||||
DCD TIM10_IRQHandler ; TIM10
|
|
||||||
DCD TIM11_IRQHandler ; TIM11
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM12_IRQHandler ; TIM12
|
|
||||||
DCD TIM13_IRQHandler ; TIM13
|
|
||||||
DCD TIM14_IRQHandler ; TIM14
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD FSMC_IRQHandler ; FSMC
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM5_IRQHandler ; TIM5
|
|
||||||
DCD SPI3_IRQHandler ; SPI3
|
|
||||||
DCD UART4_IRQHandler ; UART4
|
|
||||||
DCD UART5_IRQHandler ; UART5
|
|
||||||
DCD TIM6_IRQHandler ; TIM6
|
|
||||||
DCD TIM7_IRQHandler ; TIM7
|
|
||||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
|
|
||||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
|
|
||||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
|
|
||||||
DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM9_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM10_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM11_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM12_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM13_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM14_IRQHandler [WEAK]
|
|
||||||
EXPORT FSMC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM5_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI3_IRQHandler [WEAK]
|
|
||||||
EXPORT UART4_IRQHandler [WEAK]
|
|
||||||
EXPORT UART5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM6_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM7_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel4_5_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM9_IRQHandler
|
|
||||||
TIM10_IRQHandler
|
|
||||||
TIM11_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
TIM12_IRQHandler
|
|
||||||
TIM13_IRQHandler
|
|
||||||
TIM14_IRQHandler
|
|
||||||
FSMC_IRQHandler
|
|
||||||
TIM5_IRQHandler
|
|
||||||
SPI3_IRQHandler
|
|
||||||
UART4_IRQHandler
|
|
||||||
UART5_IRQHandler
|
|
||||||
TIM6_IRQHandler
|
|
||||||
TIM7_IRQHandler
|
|
||||||
DMA2_Channel1_IRQHandler
|
|
||||||
DMA2_Channel2_IRQHandler
|
|
||||||
DMA2_Channel3_IRQHandler
|
|
||||||
DMA2_Channel4_5_IRQHandler
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,283 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f102x6.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F102x6 Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_IRQHandler ; ADC1
|
|
||||||
DCD USB_HP_IRQHandler ; USB High Priority
|
|
||||||
DCD USB_LP_IRQHandler ; USB Low Priority
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler routine
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_HP_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_LP_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT USBWakeUp_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_IRQHandler
|
|
||||||
USB_HP_IRQHandler
|
|
||||||
USB_LP_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
USBWakeUp_IRQHandler
|
|
||||||
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,293 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f102xb.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F102xB Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_IRQHandler ; ADC1
|
|
||||||
DCD USB_HP_IRQHandler ; USB High Priority
|
|
||||||
DCD USB_LP_IRQHandler ; USB Low Priority
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_HP_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_LP_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT USBWakeUp_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_IRQHandler
|
|
||||||
USB_HP_IRQHandler
|
|
||||||
USB_LP_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
USBWakeUp_IRQHandler
|
|
||||||
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,295 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f103x6.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F103x6 Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_2_IRQHandler ; ADC1_2
|
|
||||||
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
|
|
||||||
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
|
|
||||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
|
||||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD TIM1_BRK_IRQHandler ; TIM1 Break
|
|
||||||
DCD TIM1_UP_IRQHandler ; TIM1 Update
|
|
||||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
|
||||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler routine
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_2_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_BRK_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_UP_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT USBWakeUp_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_2_IRQHandler
|
|
||||||
USB_HP_CAN1_TX_IRQHandler
|
|
||||||
USB_LP_CAN1_RX0_IRQHandler
|
|
||||||
CAN1_RX1_IRQHandler
|
|
||||||
CAN1_SCE_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM1_BRK_IRQHandler
|
|
||||||
TIM1_UP_IRQHandler
|
|
||||||
TIM1_TRG_COM_IRQHandler
|
|
||||||
TIM1_CC_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
USBWakeUp_IRQHandler
|
|
||||||
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,354 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f103xe.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F103xE Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_2_IRQHandler ; ADC1 & ADC2
|
|
||||||
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
|
|
||||||
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
|
|
||||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
|
||||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD TIM1_BRK_IRQHandler ; TIM1 Break
|
|
||||||
DCD TIM1_UP_IRQHandler ; TIM1 Update
|
|
||||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
|
||||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
|
||||||
DCD TIM8_BRK_IRQHandler ; TIM8 Break
|
|
||||||
DCD TIM8_UP_IRQHandler ; TIM8 Update
|
|
||||||
DCD TIM8_TRG_COM_IRQHandler ; TIM8 Trigger and Commutation
|
|
||||||
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
|
|
||||||
DCD ADC3_IRQHandler ; ADC3
|
|
||||||
DCD FSMC_IRQHandler ; FSMC
|
|
||||||
DCD SDIO_IRQHandler ; SDIO
|
|
||||||
DCD TIM5_IRQHandler ; TIM5
|
|
||||||
DCD SPI3_IRQHandler ; SPI3
|
|
||||||
DCD UART4_IRQHandler ; UART4
|
|
||||||
DCD UART5_IRQHandler ; UART5
|
|
||||||
DCD TIM6_IRQHandler ; TIM6
|
|
||||||
DCD TIM7_IRQHandler ; TIM7
|
|
||||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
|
|
||||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
|
|
||||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
|
|
||||||
DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_2_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_BRK_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_UP_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT USBWakeUp_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM8_BRK_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM8_UP_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM8_TRG_COM_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM8_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC3_IRQHandler [WEAK]
|
|
||||||
EXPORT FSMC_IRQHandler [WEAK]
|
|
||||||
EXPORT SDIO_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM5_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI3_IRQHandler [WEAK]
|
|
||||||
EXPORT UART4_IRQHandler [WEAK]
|
|
||||||
EXPORT UART5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM6_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM7_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel4_5_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_2_IRQHandler
|
|
||||||
USB_HP_CAN1_TX_IRQHandler
|
|
||||||
USB_LP_CAN1_RX0_IRQHandler
|
|
||||||
CAN1_RX1_IRQHandler
|
|
||||||
CAN1_SCE_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM1_BRK_IRQHandler
|
|
||||||
TIM1_UP_IRQHandler
|
|
||||||
TIM1_TRG_COM_IRQHandler
|
|
||||||
TIM1_CC_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
USBWakeUp_IRQHandler
|
|
||||||
TIM8_BRK_IRQHandler
|
|
||||||
TIM8_UP_IRQHandler
|
|
||||||
TIM8_TRG_COM_IRQHandler
|
|
||||||
TIM8_CC_IRQHandler
|
|
||||||
ADC3_IRQHandler
|
|
||||||
FSMC_IRQHandler
|
|
||||||
SDIO_IRQHandler
|
|
||||||
TIM5_IRQHandler
|
|
||||||
SPI3_IRQHandler
|
|
||||||
UART4_IRQHandler
|
|
||||||
UART5_IRQHandler
|
|
||||||
TIM6_IRQHandler
|
|
||||||
TIM7_IRQHandler
|
|
||||||
DMA2_Channel1_IRQHandler
|
|
||||||
DMA2_Channel2_IRQHandler
|
|
||||||
DMA2_Channel3_IRQHandler
|
|
||||||
DMA2_Channel4_5_IRQHandler
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,354 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f103xg.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F103xG Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_2_IRQHandler ; ADC1 & ADC2
|
|
||||||
DCD USB_HP_CAN1_TX_IRQHandler ; USB High Priority or CAN1 TX
|
|
||||||
DCD USB_LP_CAN1_RX0_IRQHandler ; USB Low Priority or CAN1 RX0
|
|
||||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
|
||||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
|
|
||||||
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
|
|
||||||
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
|
|
||||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm through EXTI Line
|
|
||||||
DCD USBWakeUp_IRQHandler ; USB Wakeup from suspend
|
|
||||||
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
|
|
||||||
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
|
|
||||||
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
|
|
||||||
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
|
|
||||||
DCD ADC3_IRQHandler ; ADC3
|
|
||||||
DCD FSMC_IRQHandler ; FSMC
|
|
||||||
DCD SDIO_IRQHandler ; SDIO
|
|
||||||
DCD TIM5_IRQHandler ; TIM5
|
|
||||||
DCD SPI3_IRQHandler ; SPI3
|
|
||||||
DCD UART4_IRQHandler ; UART4
|
|
||||||
DCD UART5_IRQHandler ; UART5
|
|
||||||
DCD TIM6_IRQHandler ; TIM6
|
|
||||||
DCD TIM7_IRQHandler ; TIM7
|
|
||||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
|
|
||||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
|
|
||||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
|
|
||||||
DCD DMA2_Channel4_5_IRQHandler ; DMA2 Channel4 & Channel5
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT SystemInit
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_2_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_HP_CAN1_TX_IRQHandler [WEAK]
|
|
||||||
EXPORT USB_LP_CAN1_RX0_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_BRK_TIM9_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_UP_TIM10_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_TRG_COM_TIM11_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT USBWakeUp_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM8_BRK_TIM12_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM8_UP_TIM13_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM8_TRG_COM_TIM14_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM8_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC3_IRQHandler [WEAK]
|
|
||||||
EXPORT FSMC_IRQHandler [WEAK]
|
|
||||||
EXPORT SDIO_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM5_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI3_IRQHandler [WEAK]
|
|
||||||
EXPORT UART4_IRQHandler [WEAK]
|
|
||||||
EXPORT UART5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM6_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM7_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel4_5_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_2_IRQHandler
|
|
||||||
USB_HP_CAN1_TX_IRQHandler
|
|
||||||
USB_LP_CAN1_RX0_IRQHandler
|
|
||||||
CAN1_RX1_IRQHandler
|
|
||||||
CAN1_SCE_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM1_BRK_TIM9_IRQHandler
|
|
||||||
TIM1_UP_TIM10_IRQHandler
|
|
||||||
TIM1_TRG_COM_TIM11_IRQHandler
|
|
||||||
TIM1_CC_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
USBWakeUp_IRQHandler
|
|
||||||
TIM8_BRK_TIM12_IRQHandler
|
|
||||||
TIM8_UP_TIM13_IRQHandler
|
|
||||||
TIM8_TRG_COM_TIM14_IRQHandler
|
|
||||||
TIM8_CC_IRQHandler
|
|
||||||
ADC3_IRQHandler
|
|
||||||
FSMC_IRQHandler
|
|
||||||
SDIO_IRQHandler
|
|
||||||
TIM5_IRQHandler
|
|
||||||
SPI3_IRQHandler
|
|
||||||
UART4_IRQHandler
|
|
||||||
UART5_IRQHandler
|
|
||||||
TIM6_IRQHandler
|
|
||||||
TIM7_IRQHandler
|
|
||||||
DMA2_Channel1_IRQHandler
|
|
||||||
DMA2_Channel2_IRQHandler
|
|
||||||
DMA2_Channel3_IRQHandler
|
|
||||||
DMA2_Channel4_5_IRQHandler
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,362 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f105xc.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F105xC Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_2_IRQHandler ; ADC1 and ADC2
|
|
||||||
DCD CAN1_TX_IRQHandler ; CAN1 TX
|
|
||||||
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
|
|
||||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
|
||||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD TIM1_BRK_IRQHandler ; TIM1 Break
|
|
||||||
DCD TIM1_UP_IRQHandler ; TIM1 Update
|
|
||||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
|
||||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC alarm through EXTI line
|
|
||||||
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM5_IRQHandler ; TIM5
|
|
||||||
DCD SPI3_IRQHandler ; SPI3
|
|
||||||
DCD UART4_IRQHandler ; UART4
|
|
||||||
DCD UART5_IRQHandler ; UART5
|
|
||||||
DCD TIM6_IRQHandler ; TIM6
|
|
||||||
DCD TIM7_IRQHandler ; TIM7
|
|
||||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
|
|
||||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
|
|
||||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
|
|
||||||
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel4
|
|
||||||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel5
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD CAN2_TX_IRQHandler ; CAN2 TX
|
|
||||||
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
|
|
||||||
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
|
|
||||||
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
|
|
||||||
DCD OTG_FS_IRQHandler ; USB OTG FS
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT SystemInit
|
|
||||||
IMPORT __main
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_2_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_TX_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_RX0_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_BRK_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_UP_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM5_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI3_IRQHandler [WEAK]
|
|
||||||
EXPORT UART4_IRQHandler [WEAK]
|
|
||||||
EXPORT UART5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM6_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM7_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN2_TX_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN2_RX0_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN2_RX1_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN2_SCE_IRQHandler [WEAK]
|
|
||||||
EXPORT OTG_FS_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_2_IRQHandler
|
|
||||||
CAN1_TX_IRQHandler
|
|
||||||
CAN1_RX0_IRQHandler
|
|
||||||
CAN1_RX1_IRQHandler
|
|
||||||
CAN1_SCE_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM1_BRK_IRQHandler
|
|
||||||
TIM1_UP_IRQHandler
|
|
||||||
TIM1_TRG_COM_IRQHandler
|
|
||||||
TIM1_CC_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
OTG_FS_WKUP_IRQHandler
|
|
||||||
TIM5_IRQHandler
|
|
||||||
SPI3_IRQHandler
|
|
||||||
UART4_IRQHandler
|
|
||||||
UART5_IRQHandler
|
|
||||||
TIM6_IRQHandler
|
|
||||||
TIM7_IRQHandler
|
|
||||||
DMA2_Channel1_IRQHandler
|
|
||||||
DMA2_Channel2_IRQHandler
|
|
||||||
DMA2_Channel3_IRQHandler
|
|
||||||
DMA2_Channel4_IRQHandler
|
|
||||||
DMA2_Channel5_IRQHandler
|
|
||||||
CAN2_TX_IRQHandler
|
|
||||||
CAN2_RX0_IRQHandler
|
|
||||||
CAN2_RX1_IRQHandler
|
|
||||||
CAN2_SCE_IRQHandler
|
|
||||||
OTG_FS_IRQHandler
|
|
||||||
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,366 +0,0 @@
|
|||||||
;******************** (C) COPYRIGHT 2017 STMicroelectronics ********************
|
|
||||||
;* File Name : startup_stm32f107xc.s
|
|
||||||
;* Author : MCD Application Team
|
|
||||||
;* Description : STM32F107xC Devices vector table for MDK-ARM toolchain.
|
|
||||||
;* This module performs:
|
|
||||||
;* - Set the initial SP
|
|
||||||
;* - Set the initial PC == Reset_Handler
|
|
||||||
;* - Set the vector table entries with the exceptions ISR address
|
|
||||||
;* - Configure the clock system
|
|
||||||
;* - Branches to __main in the C library (which eventually
|
|
||||||
;* calls main()).
|
|
||||||
;* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
;* priority is Privileged, and the Stack is set to Main.
|
|
||||||
;******************************************************************************
|
|
||||||
;* @attention
|
|
||||||
;*
|
|
||||||
;* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
;* All rights reserved.
|
|
||||||
;*
|
|
||||||
;* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
;* in the root directory of this software component.
|
|
||||||
;* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
;*
|
|
||||||
;******************************************************************************
|
|
||||||
|
|
||||||
; Amount of memory (in bytes) allocated for Stack
|
|
||||||
; Tailor this value to your application needs
|
|
||||||
; <h> Stack Configuration
|
|
||||||
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Stack_Size EQU 0x00000400
|
|
||||||
|
|
||||||
AREA STACK, NOINIT, READWRITE, ALIGN=3
|
|
||||||
Stack_Mem SPACE Stack_Size
|
|
||||||
__initial_sp
|
|
||||||
|
|
||||||
|
|
||||||
; <h> Heap Configuration
|
|
||||||
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
|
|
||||||
; </h>
|
|
||||||
|
|
||||||
Heap_Size EQU 0x00000200
|
|
||||||
|
|
||||||
AREA HEAP, NOINIT, READWRITE, ALIGN=3
|
|
||||||
__heap_base
|
|
||||||
Heap_Mem SPACE Heap_Size
|
|
||||||
__heap_limit
|
|
||||||
|
|
||||||
PRESERVE8
|
|
||||||
THUMB
|
|
||||||
|
|
||||||
|
|
||||||
; Vector Table Mapped to Address 0 at Reset
|
|
||||||
AREA RESET, DATA, READONLY
|
|
||||||
EXPORT __Vectors
|
|
||||||
EXPORT __Vectors_End
|
|
||||||
EXPORT __Vectors_Size
|
|
||||||
|
|
||||||
__Vectors DCD __initial_sp ; Top of Stack
|
|
||||||
DCD Reset_Handler ; Reset Handler
|
|
||||||
DCD NMI_Handler ; NMI Handler
|
|
||||||
DCD HardFault_Handler ; Hard Fault Handler
|
|
||||||
DCD MemManage_Handler ; MPU Fault Handler
|
|
||||||
DCD BusFault_Handler ; Bus Fault Handler
|
|
||||||
DCD UsageFault_Handler ; Usage Fault Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD SVC_Handler ; SVCall Handler
|
|
||||||
DCD DebugMon_Handler ; Debug Monitor Handler
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD PendSV_Handler ; PendSV Handler
|
|
||||||
DCD SysTick_Handler ; SysTick Handler
|
|
||||||
|
|
||||||
; External Interrupts
|
|
||||||
DCD WWDG_IRQHandler ; Window Watchdog
|
|
||||||
DCD PVD_IRQHandler ; PVD through EXTI Line detect
|
|
||||||
DCD TAMPER_IRQHandler ; Tamper
|
|
||||||
DCD RTC_IRQHandler ; RTC
|
|
||||||
DCD FLASH_IRQHandler ; Flash
|
|
||||||
DCD RCC_IRQHandler ; RCC
|
|
||||||
DCD EXTI0_IRQHandler ; EXTI Line 0
|
|
||||||
DCD EXTI1_IRQHandler ; EXTI Line 1
|
|
||||||
DCD EXTI2_IRQHandler ; EXTI Line 2
|
|
||||||
DCD EXTI3_IRQHandler ; EXTI Line 3
|
|
||||||
DCD EXTI4_IRQHandler ; EXTI Line 4
|
|
||||||
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1
|
|
||||||
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2
|
|
||||||
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3
|
|
||||||
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4
|
|
||||||
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5
|
|
||||||
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6
|
|
||||||
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7
|
|
||||||
DCD ADC1_2_IRQHandler ; ADC1 and ADC2
|
|
||||||
DCD CAN1_TX_IRQHandler ; CAN1 TX
|
|
||||||
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
|
|
||||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
|
||||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
|
||||||
DCD EXTI9_5_IRQHandler ; EXTI Line 9..5
|
|
||||||
DCD TIM1_BRK_IRQHandler ; TIM1 Break
|
|
||||||
DCD TIM1_UP_IRQHandler ; TIM1 Update
|
|
||||||
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Commutation
|
|
||||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
|
||||||
DCD TIM2_IRQHandler ; TIM2
|
|
||||||
DCD TIM3_IRQHandler ; TIM3
|
|
||||||
DCD TIM4_IRQHandler ; TIM4
|
|
||||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
|
||||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
|
||||||
DCD I2C2_ER_IRQHandler ; I2C1 Error
|
|
||||||
DCD SPI1_IRQHandler ; SPI1
|
|
||||||
DCD SPI2_IRQHandler ; SPI2
|
|
||||||
DCD USART1_IRQHandler ; USART1
|
|
||||||
DCD USART2_IRQHandler ; USART2
|
|
||||||
DCD USART3_IRQHandler ; USART3
|
|
||||||
DCD EXTI15_10_IRQHandler ; EXTI Line 15..10
|
|
||||||
DCD RTC_Alarm_IRQHandler ; RTC alarm through EXTI line
|
|
||||||
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD 0 ; Reserved
|
|
||||||
DCD TIM5_IRQHandler ; TIM5
|
|
||||||
DCD SPI3_IRQHandler ; SPI3
|
|
||||||
DCD UART4_IRQHandler ; UART4
|
|
||||||
DCD UART5_IRQHandler ; UART5
|
|
||||||
DCD TIM6_IRQHandler ; TIM6
|
|
||||||
DCD TIM7_IRQHandler ; TIM7
|
|
||||||
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel1
|
|
||||||
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel2
|
|
||||||
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel3
|
|
||||||
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel4
|
|
||||||
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel5
|
|
||||||
DCD ETH_IRQHandler ; Ethernet
|
|
||||||
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
|
|
||||||
DCD CAN2_TX_IRQHandler ; CAN2 TX
|
|
||||||
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
|
|
||||||
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
|
|
||||||
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
|
|
||||||
DCD OTG_FS_IRQHandler ; USB OTG FS
|
|
||||||
__Vectors_End
|
|
||||||
|
|
||||||
__Vectors_Size EQU __Vectors_End - __Vectors
|
|
||||||
|
|
||||||
AREA |.text|, CODE, READONLY
|
|
||||||
|
|
||||||
; Reset handler
|
|
||||||
Reset_Handler PROC
|
|
||||||
EXPORT Reset_Handler [WEAK]
|
|
||||||
IMPORT SystemInit
|
|
||||||
IMPORT __main
|
|
||||||
LDR R0, =SystemInit
|
|
||||||
BLX R0
|
|
||||||
LDR R0, =__main
|
|
||||||
BX R0
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
; Dummy Exception Handlers (infinite loops which can be modified)
|
|
||||||
|
|
||||||
NMI_Handler PROC
|
|
||||||
EXPORT NMI_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
HardFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT HardFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
MemManage_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT MemManage_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
BusFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT BusFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
UsageFault_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT UsageFault_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SVC_Handler PROC
|
|
||||||
EXPORT SVC_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
DebugMon_Handler\
|
|
||||||
PROC
|
|
||||||
EXPORT DebugMon_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
PendSV_Handler PROC
|
|
||||||
EXPORT PendSV_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
SysTick_Handler PROC
|
|
||||||
EXPORT SysTick_Handler [WEAK]
|
|
||||||
B .
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
Default_Handler PROC
|
|
||||||
|
|
||||||
EXPORT WWDG_IRQHandler [WEAK]
|
|
||||||
EXPORT PVD_IRQHandler [WEAK]
|
|
||||||
EXPORT TAMPER_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_IRQHandler [WEAK]
|
|
||||||
EXPORT FLASH_IRQHandler [WEAK]
|
|
||||||
EXPORT RCC_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI0_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI1_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI2_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel6_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA1_Channel7_IRQHandler [WEAK]
|
|
||||||
EXPORT ADC1_2_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_TX_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_RX0_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_RX1_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN1_SCE_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI9_5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_BRK_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_UP_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM1_CC_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM2_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM3_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM4_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C1_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_EV_IRQHandler [WEAK]
|
|
||||||
EXPORT I2C2_ER_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI1_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART1_IRQHandler [WEAK]
|
|
||||||
EXPORT USART2_IRQHandler [WEAK]
|
|
||||||
EXPORT USART3_IRQHandler [WEAK]
|
|
||||||
EXPORT EXTI15_10_IRQHandler [WEAK]
|
|
||||||
EXPORT RTC_Alarm_IRQHandler [WEAK]
|
|
||||||
EXPORT OTG_FS_WKUP_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM5_IRQHandler [WEAK]
|
|
||||||
EXPORT SPI3_IRQHandler [WEAK]
|
|
||||||
EXPORT UART4_IRQHandler [WEAK]
|
|
||||||
EXPORT UART5_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM6_IRQHandler [WEAK]
|
|
||||||
EXPORT TIM7_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel1_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel2_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel3_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel4_IRQHandler [WEAK]
|
|
||||||
EXPORT DMA2_Channel5_IRQHandler [WEAK]
|
|
||||||
EXPORT ETH_IRQHandler [WEAK]
|
|
||||||
EXPORT ETH_WKUP_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN2_TX_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN2_RX0_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN2_RX1_IRQHandler [WEAK]
|
|
||||||
EXPORT CAN2_SCE_IRQHandler [WEAK]
|
|
||||||
EXPORT OTG_FS_IRQHandler [WEAK]
|
|
||||||
|
|
||||||
WWDG_IRQHandler
|
|
||||||
PVD_IRQHandler
|
|
||||||
TAMPER_IRQHandler
|
|
||||||
RTC_IRQHandler
|
|
||||||
FLASH_IRQHandler
|
|
||||||
RCC_IRQHandler
|
|
||||||
EXTI0_IRQHandler
|
|
||||||
EXTI1_IRQHandler
|
|
||||||
EXTI2_IRQHandler
|
|
||||||
EXTI3_IRQHandler
|
|
||||||
EXTI4_IRQHandler
|
|
||||||
DMA1_Channel1_IRQHandler
|
|
||||||
DMA1_Channel2_IRQHandler
|
|
||||||
DMA1_Channel3_IRQHandler
|
|
||||||
DMA1_Channel4_IRQHandler
|
|
||||||
DMA1_Channel5_IRQHandler
|
|
||||||
DMA1_Channel6_IRQHandler
|
|
||||||
DMA1_Channel7_IRQHandler
|
|
||||||
ADC1_2_IRQHandler
|
|
||||||
CAN1_TX_IRQHandler
|
|
||||||
CAN1_RX0_IRQHandler
|
|
||||||
CAN1_RX1_IRQHandler
|
|
||||||
CAN1_SCE_IRQHandler
|
|
||||||
EXTI9_5_IRQHandler
|
|
||||||
TIM1_BRK_IRQHandler
|
|
||||||
TIM1_UP_IRQHandler
|
|
||||||
TIM1_TRG_COM_IRQHandler
|
|
||||||
TIM1_CC_IRQHandler
|
|
||||||
TIM2_IRQHandler
|
|
||||||
TIM3_IRQHandler
|
|
||||||
TIM4_IRQHandler
|
|
||||||
I2C1_EV_IRQHandler
|
|
||||||
I2C1_ER_IRQHandler
|
|
||||||
I2C2_EV_IRQHandler
|
|
||||||
I2C2_ER_IRQHandler
|
|
||||||
SPI1_IRQHandler
|
|
||||||
SPI2_IRQHandler
|
|
||||||
USART1_IRQHandler
|
|
||||||
USART2_IRQHandler
|
|
||||||
USART3_IRQHandler
|
|
||||||
EXTI15_10_IRQHandler
|
|
||||||
RTC_Alarm_IRQHandler
|
|
||||||
OTG_FS_WKUP_IRQHandler
|
|
||||||
TIM5_IRQHandler
|
|
||||||
SPI3_IRQHandler
|
|
||||||
UART4_IRQHandler
|
|
||||||
UART5_IRQHandler
|
|
||||||
TIM6_IRQHandler
|
|
||||||
TIM7_IRQHandler
|
|
||||||
DMA2_Channel1_IRQHandler
|
|
||||||
DMA2_Channel2_IRQHandler
|
|
||||||
DMA2_Channel3_IRQHandler
|
|
||||||
DMA2_Channel4_IRQHandler
|
|
||||||
DMA2_Channel5_IRQHandler
|
|
||||||
ETH_IRQHandler
|
|
||||||
ETH_WKUP_IRQHandler
|
|
||||||
CAN2_TX_IRQHandler
|
|
||||||
CAN2_RX0_IRQHandler
|
|
||||||
CAN2_RX1_IRQHandler
|
|
||||||
CAN2_SCE_IRQHandler
|
|
||||||
OTG_FS_IRQHandler
|
|
||||||
|
|
||||||
B .
|
|
||||||
|
|
||||||
ENDP
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
;*******************************************************************************
|
|
||||||
; User Stack and Heap initialization
|
|
||||||
;*******************************************************************************
|
|
||||||
IF :DEF:__MICROLIB
|
|
||||||
|
|
||||||
EXPORT __initial_sp
|
|
||||||
EXPORT __heap_base
|
|
||||||
EXPORT __heap_limit
|
|
||||||
|
|
||||||
ELSE
|
|
||||||
|
|
||||||
IMPORT __use_two_region_memory
|
|
||||||
EXPORT __user_initial_stackheap
|
|
||||||
|
|
||||||
__user_initial_stackheap
|
|
||||||
|
|
||||||
LDR R0, = Heap_Mem
|
|
||||||
LDR R1, =(Stack_Mem + Stack_Size)
|
|
||||||
LDR R2, = (Heap_Mem + Heap_Size)
|
|
||||||
LDR R3, = Stack_Mem
|
|
||||||
BX LR
|
|
||||||
|
|
||||||
ALIGN
|
|
||||||
|
|
||||||
ENDIF
|
|
||||||
|
|
||||||
END
|
|
||||||
|
|
||||||
@@ -1,407 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f100xb.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F100xB Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF108F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word TIM1_BRK_TIM15_IRQHandler
|
|
||||||
.word TIM1_UP_TIM16_IRQHandler
|
|
||||||
.word TIM1_TRG_COM_TIM17_IRQHandler
|
|
||||||
.word TIM1_CC_IRQHandler
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word CEC_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word TIM6_DAC_IRQHandler
|
|
||||||
.word TIM7_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x01CC. This is for boot in RAM mode for
|
|
||||||
STM32F10xB Value Line devices. */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_IRQHandler
|
|
||||||
.thumb_set ADC1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_BRK_TIM15_IRQHandler
|
|
||||||
.thumb_set TIM1_BRK_TIM15_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_UP_TIM16_IRQHandler
|
|
||||||
.thumb_set TIM1_UP_TIM16_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_TRG_COM_TIM17_IRQHandler
|
|
||||||
.thumb_set TIM1_TRG_COM_TIM17_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_CC_IRQHandler
|
|
||||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CEC_IRQHandler
|
|
||||||
.thumb_set CEC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM6_DAC_IRQHandler
|
|
||||||
.thumb_set TIM6_DAC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM7_IRQHandler
|
|
||||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,449 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f100xe.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F100xE Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF108F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word TIM1_BRK_TIM15_IRQHandler
|
|
||||||
.word TIM1_UP_TIM16_IRQHandler
|
|
||||||
.word TIM1_TRG_COM_TIM17_IRQHandler
|
|
||||||
.word TIM1_CC_IRQHandler
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word CEC_IRQHandler
|
|
||||||
.word TIM12_IRQHandler
|
|
||||||
.word TIM13_IRQHandler
|
|
||||||
.word TIM14_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word TIM5_IRQHandler
|
|
||||||
.word SPI3_IRQHandler
|
|
||||||
.word UART4_IRQHandler
|
|
||||||
.word UART5_IRQHandler
|
|
||||||
.word TIM6_DAC_IRQHandler
|
|
||||||
.word TIM7_IRQHandler
|
|
||||||
.word DMA2_Channel1_IRQHandler
|
|
||||||
.word DMA2_Channel2_IRQHandler
|
|
||||||
.word DMA2_Channel3_IRQHandler
|
|
||||||
.word DMA2_Channel4_5_IRQHandler
|
|
||||||
.word DMA2_Channel5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x1E0. This is for boot in RAM mode for
|
|
||||||
STM32F10x High Density Value line devices. */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_IRQHandler
|
|
||||||
.thumb_set ADC1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_BRK_TIM15_IRQHandler
|
|
||||||
.thumb_set TIM1_BRK_TIM15_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_UP_TIM16_IRQHandler
|
|
||||||
.thumb_set TIM1_UP_TIM16_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_TRG_COM_TIM17_IRQHandler
|
|
||||||
.thumb_set TIM1_TRG_COM_TIM17_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_CC_IRQHandler
|
|
||||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CEC_IRQHandler
|
|
||||||
.thumb_set CEC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM12_IRQHandler
|
|
||||||
.thumb_set TIM12_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM13_IRQHandler
|
|
||||||
.thumb_set TIM13_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM14_IRQHandler
|
|
||||||
.thumb_set TIM14_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM5_IRQHandler
|
|
||||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI3_IRQHandler
|
|
||||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART4_IRQHandler
|
|
||||||
.thumb_set UART4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART5_IRQHandler
|
|
||||||
.thumb_set UART5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM6_DAC_IRQHandler
|
|
||||||
.thumb_set TIM6_DAC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM7_IRQHandler
|
|
||||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel4_5_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel4_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,322 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f101x6.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F101x6 Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF108F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x108. This is for boot in RAM mode for
|
|
||||||
STM32F10x Low Density devices.*/
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_IRQHandler
|
|
||||||
.thumb_set ADC1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
@@ -1,338 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f101xb.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F101xB Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF108F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x108. This is for boot in RAM mode for
|
|
||||||
STM32F10x Medium Density devices. */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_IRQHandler
|
|
||||||
.thumb_set ADC1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,423 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f101xe.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F101xE Value Line Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF1E0F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word FSMC_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word TIM5_IRQHandler
|
|
||||||
.word SPI3_IRQHandler
|
|
||||||
.word UART4_IRQHandler
|
|
||||||
.word UART5_IRQHandler
|
|
||||||
.word TIM6_IRQHandler
|
|
||||||
.word TIM7_IRQHandler
|
|
||||||
.word DMA2_Channel1_IRQHandler
|
|
||||||
.word DMA2_Channel2_IRQHandler
|
|
||||||
.word DMA2_Channel3_IRQHandler
|
|
||||||
.word DMA2_Channel4_5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x1E0. This is for boot in RAM mode for
|
|
||||||
STM32F10x High Density devices. */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_IRQHandler
|
|
||||||
.thumb_set ADC1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FSMC_IRQHandler
|
|
||||||
.thumb_set FSMC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM5_IRQHandler
|
|
||||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI3_IRQHandler
|
|
||||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART4_IRQHandler
|
|
||||||
.thumb_set UART4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART5_IRQHandler
|
|
||||||
.thumb_set UART5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM6_IRQHandler
|
|
||||||
.thumb_set TIM6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM7_IRQHandler
|
|
||||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel4_5_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel4_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
@@ -1,439 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f101xg.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F101xG Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF1E0F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word TIM9_IRQHandler
|
|
||||||
.word TIM10_IRQHandler
|
|
||||||
.word TIM11_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word TIM12_IRQHandler
|
|
||||||
.word TIM13_IRQHandler
|
|
||||||
.word TIM14_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word FSMC_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word TIM5_IRQHandler
|
|
||||||
.word SPI3_IRQHandler
|
|
||||||
.word UART4_IRQHandler
|
|
||||||
.word UART5_IRQHandler
|
|
||||||
.word TIM6_IRQHandler
|
|
||||||
.word TIM7_IRQHandler
|
|
||||||
.word DMA2_Channel1_IRQHandler
|
|
||||||
.word DMA2_Channel2_IRQHandler
|
|
||||||
.word DMA2_Channel3_IRQHandler
|
|
||||||
.word DMA2_Channel4_5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x1E0. This is for boot in RAM mode for
|
|
||||||
STM32F10x XL-Density devices. */
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_IRQHandler
|
|
||||||
.thumb_set ADC1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM9_IRQHandler
|
|
||||||
.thumb_set TIM9_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM10_IRQHandler
|
|
||||||
.thumb_set TIM10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM11_IRQHandler
|
|
||||||
.thumb_set TIM11_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM12_IRQHandler
|
|
||||||
.thumb_set TIM12_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM13_IRQHandler
|
|
||||||
.thumb_set TIM13_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM14_IRQHandler
|
|
||||||
.thumb_set TIM14_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FSMC_IRQHandler
|
|
||||||
.thumb_set FSMC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM5_IRQHandler
|
|
||||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI3_IRQHandler
|
|
||||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART4_IRQHandler
|
|
||||||
.thumb_set UART4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART5_IRQHandler
|
|
||||||
.thumb_set UART5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM6_IRQHandler
|
|
||||||
.thumb_set TIM6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM7_IRQHandler
|
|
||||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel4_5_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel4_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
@@ -1,330 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f102x6.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F102x6 Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF108F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_IRQHandler
|
|
||||||
.word USB_HP_IRQHandler
|
|
||||||
.word USB_LP_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word USBWakeUp_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x108. This is for boot in RAM mode for
|
|
||||||
STM32F10x Low Density devices.*/
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_IRQHandler
|
|
||||||
.thumb_set ADC1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_HP_IRQHandler
|
|
||||||
.thumb_set USB_HP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_LP_IRQHandler
|
|
||||||
.thumb_set USB_LP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USBWakeUp_IRQHandler
|
|
||||||
.thumb_set USBWakeUp_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
@@ -1,346 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f102xb.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F102xB Value Line Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF108F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_IRQHandler
|
|
||||||
.word USB_HP_IRQHandler
|
|
||||||
.word USB_LP_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word USBWakeUp_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x108. This is for boot in RAM mode for
|
|
||||||
STM32F10x Medium Density devices. */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_IRQHandler
|
|
||||||
.thumb_set ADC1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_HP_IRQHandler
|
|
||||||
.thumb_set USB_HP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_LP_IRQHandler
|
|
||||||
.thumb_set USB_LP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USBWakeUp_IRQHandler
|
|
||||||
.thumb_set USBWakeUp_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,348 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f103x6.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F103x6 Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF108F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_2_IRQHandler
|
|
||||||
.word USB_HP_CAN1_TX_IRQHandler
|
|
||||||
.word USB_LP_CAN1_RX0_IRQHandler
|
|
||||||
.word CAN1_RX1_IRQHandler
|
|
||||||
.word CAN1_SCE_IRQHandler
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word TIM1_BRK_IRQHandler
|
|
||||||
.word TIM1_UP_IRQHandler
|
|
||||||
.word TIM1_TRG_COM_IRQHandler
|
|
||||||
.word TIM1_CC_IRQHandler
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word USBWakeUp_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x108. This is for boot in RAM mode for
|
|
||||||
STM32F10x Low Density devices.*/
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_2_IRQHandler
|
|
||||||
.thumb_set ADC1_2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_HP_CAN1_TX_IRQHandler
|
|
||||||
.thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_LP_CAN1_RX0_IRQHandler
|
|
||||||
.thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_RX1_IRQHandler
|
|
||||||
.thumb_set CAN1_RX1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_SCE_IRQHandler
|
|
||||||
.thumb_set CAN1_SCE_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_BRK_IRQHandler
|
|
||||||
.thumb_set TIM1_BRK_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_UP_IRQHandler
|
|
||||||
.thumb_set TIM1_UP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_TRG_COM_IRQHandler
|
|
||||||
.thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_CC_IRQHandler
|
|
||||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USBWakeUp_IRQHandler
|
|
||||||
.thumb_set USBWakeUp_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
@@ -1,470 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f103xe.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F103xE Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Configure external SRAM mounted on STM3210E-EVAL board
|
|
||||||
* to be used as data memory (optional, to be enabled by user)
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF1E0F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_2_IRQHandler
|
|
||||||
.word USB_HP_CAN1_TX_IRQHandler
|
|
||||||
.word USB_LP_CAN1_RX0_IRQHandler
|
|
||||||
.word CAN1_RX1_IRQHandler
|
|
||||||
.word CAN1_SCE_IRQHandler
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word TIM1_BRK_IRQHandler
|
|
||||||
.word TIM1_UP_IRQHandler
|
|
||||||
.word TIM1_TRG_COM_IRQHandler
|
|
||||||
.word TIM1_CC_IRQHandler
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word USBWakeUp_IRQHandler
|
|
||||||
.word TIM8_BRK_IRQHandler
|
|
||||||
.word TIM8_UP_IRQHandler
|
|
||||||
.word TIM8_TRG_COM_IRQHandler
|
|
||||||
.word TIM8_CC_IRQHandler
|
|
||||||
.word ADC3_IRQHandler
|
|
||||||
.word FSMC_IRQHandler
|
|
||||||
.word SDIO_IRQHandler
|
|
||||||
.word TIM5_IRQHandler
|
|
||||||
.word SPI3_IRQHandler
|
|
||||||
.word UART4_IRQHandler
|
|
||||||
.word UART5_IRQHandler
|
|
||||||
.word TIM6_IRQHandler
|
|
||||||
.word TIM7_IRQHandler
|
|
||||||
.word DMA2_Channel1_IRQHandler
|
|
||||||
.word DMA2_Channel2_IRQHandler
|
|
||||||
.word DMA2_Channel3_IRQHandler
|
|
||||||
.word DMA2_Channel4_5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x1E0. This is for boot in RAM mode for
|
|
||||||
STM32F10x High Density devices. */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_2_IRQHandler
|
|
||||||
.thumb_set ADC1_2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_HP_CAN1_TX_IRQHandler
|
|
||||||
.thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_LP_CAN1_RX0_IRQHandler
|
|
||||||
.thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_RX1_IRQHandler
|
|
||||||
.thumb_set CAN1_RX1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_SCE_IRQHandler
|
|
||||||
.thumb_set CAN1_SCE_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_BRK_IRQHandler
|
|
||||||
.thumb_set TIM1_BRK_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_UP_IRQHandler
|
|
||||||
.thumb_set TIM1_UP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_TRG_COM_IRQHandler
|
|
||||||
.thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_CC_IRQHandler
|
|
||||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USBWakeUp_IRQHandler
|
|
||||||
.thumb_set USBWakeUp_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM8_BRK_IRQHandler
|
|
||||||
.thumb_set TIM8_BRK_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM8_UP_IRQHandler
|
|
||||||
.thumb_set TIM8_UP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM8_TRG_COM_IRQHandler
|
|
||||||
.thumb_set TIM8_TRG_COM_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM8_CC_IRQHandler
|
|
||||||
.thumb_set TIM8_CC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC3_IRQHandler
|
|
||||||
.thumb_set ADC3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FSMC_IRQHandler
|
|
||||||
.thumb_set FSMC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SDIO_IRQHandler
|
|
||||||
.thumb_set SDIO_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM5_IRQHandler
|
|
||||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI3_IRQHandler
|
|
||||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART4_IRQHandler
|
|
||||||
.thumb_set UART4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART5_IRQHandler
|
|
||||||
.thumb_set UART5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM6_IRQHandler
|
|
||||||
.thumb_set TIM6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM7_IRQHandler
|
|
||||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel4_5_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel4_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
@@ -1,466 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f103xb.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F103xB Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF1E0F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_2_IRQHandler
|
|
||||||
.word USB_HP_CAN1_TX_IRQHandler
|
|
||||||
.word USB_LP_CAN1_RX0_IRQHandler
|
|
||||||
.word CAN1_RX1_IRQHandler
|
|
||||||
.word CAN1_SCE_IRQHandler
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word TIM1_BRK_TIM9_IRQHandler
|
|
||||||
.word TIM1_UP_TIM10_IRQHandler
|
|
||||||
.word TIM1_TRG_COM_TIM11_IRQHandler
|
|
||||||
.word TIM1_CC_IRQHandler
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word USBWakeUp_IRQHandler
|
|
||||||
.word TIM8_BRK_TIM12_IRQHandler
|
|
||||||
.word TIM8_UP_TIM13_IRQHandler
|
|
||||||
.word TIM8_TRG_COM_TIM14_IRQHandler
|
|
||||||
.word TIM8_CC_IRQHandler
|
|
||||||
.word ADC3_IRQHandler
|
|
||||||
.word FSMC_IRQHandler
|
|
||||||
.word SDIO_IRQHandler
|
|
||||||
.word TIM5_IRQHandler
|
|
||||||
.word SPI3_IRQHandler
|
|
||||||
.word UART4_IRQHandler
|
|
||||||
.word UART5_IRQHandler
|
|
||||||
.word TIM6_IRQHandler
|
|
||||||
.word TIM7_IRQHandler
|
|
||||||
.word DMA2_Channel1_IRQHandler
|
|
||||||
.word DMA2_Channel2_IRQHandler
|
|
||||||
.word DMA2_Channel3_IRQHandler
|
|
||||||
.word DMA2_Channel4_5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x1E0. This is for boot in RAM mode for
|
|
||||||
STM32F10x XL-Density devices. */
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_2_IRQHandler
|
|
||||||
.thumb_set ADC1_2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_HP_CAN1_TX_IRQHandler
|
|
||||||
.thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USB_LP_CAN1_RX0_IRQHandler
|
|
||||||
.thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_RX1_IRQHandler
|
|
||||||
.thumb_set CAN1_RX1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_SCE_IRQHandler
|
|
||||||
.thumb_set CAN1_SCE_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_BRK_TIM9_IRQHandler
|
|
||||||
.thumb_set TIM1_BRK_TIM9_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_UP_TIM10_IRQHandler
|
|
||||||
.thumb_set TIM1_UP_TIM10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_TRG_COM_TIM11_IRQHandler
|
|
||||||
.thumb_set TIM1_TRG_COM_TIM11_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_CC_IRQHandler
|
|
||||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USBWakeUp_IRQHandler
|
|
||||||
.thumb_set USBWakeUp_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM8_BRK_TIM12_IRQHandler
|
|
||||||
.thumb_set TIM8_BRK_TIM12_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM8_UP_TIM13_IRQHandler
|
|
||||||
.thumb_set TIM8_UP_TIM13_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM8_TRG_COM_TIM14_IRQHandler
|
|
||||||
.thumb_set TIM8_TRG_COM_TIM14_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM8_CC_IRQHandler
|
|
||||||
.thumb_set TIM8_CC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC3_IRQHandler
|
|
||||||
.thumb_set ADC3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FSMC_IRQHandler
|
|
||||||
.thumb_set FSMC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SDIO_IRQHandler
|
|
||||||
.thumb_set SDIO_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM5_IRQHandler
|
|
||||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI3_IRQHandler
|
|
||||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART4_IRQHandler
|
|
||||||
.thumb_set UART4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART5_IRQHandler
|
|
||||||
.thumb_set UART5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM6_IRQHandler
|
|
||||||
.thumb_set TIM6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM7_IRQHandler
|
|
||||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel4_5_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel4_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
@@ -1,463 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f105xc.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F105xC Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF1E0F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
* @param None
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_2_IRQHandler
|
|
||||||
.word CAN1_TX_IRQHandler
|
|
||||||
.word CAN1_RX0_IRQHandler
|
|
||||||
.word CAN1_RX1_IRQHandler
|
|
||||||
.word CAN1_SCE_IRQHandler
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word TIM1_BRK_IRQHandler
|
|
||||||
.word TIM1_UP_IRQHandler
|
|
||||||
.word TIM1_TRG_COM_IRQHandler
|
|
||||||
.word TIM1_CC_IRQHandler
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word OTG_FS_WKUP_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word TIM5_IRQHandler
|
|
||||||
.word SPI3_IRQHandler
|
|
||||||
.word UART4_IRQHandler
|
|
||||||
.word UART5_IRQHandler
|
|
||||||
.word TIM6_IRQHandler
|
|
||||||
.word TIM7_IRQHandler
|
|
||||||
.word DMA2_Channel1_IRQHandler
|
|
||||||
.word DMA2_Channel2_IRQHandler
|
|
||||||
.word DMA2_Channel3_IRQHandler
|
|
||||||
.word DMA2_Channel4_IRQHandler
|
|
||||||
.word DMA2_Channel5_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word CAN2_TX_IRQHandler
|
|
||||||
.word CAN2_RX0_IRQHandler
|
|
||||||
.word CAN2_RX1_IRQHandler
|
|
||||||
.word CAN2_SCE_IRQHandler
|
|
||||||
.word OTG_FS_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x1E0. This is for boot in RAM mode for
|
|
||||||
STM32F10x Connectivity line Devices. */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_2_IRQHandler
|
|
||||||
.thumb_set ADC1_2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_TX_IRQHandler
|
|
||||||
.thumb_set CAN1_TX_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_RX0_IRQHandler
|
|
||||||
.thumb_set CAN1_RX0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_RX1_IRQHandler
|
|
||||||
.thumb_set CAN1_RX1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_SCE_IRQHandler
|
|
||||||
.thumb_set CAN1_SCE_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_BRK_IRQHandler
|
|
||||||
.thumb_set TIM1_BRK_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_UP_IRQHandler
|
|
||||||
.thumb_set TIM1_UP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_TRG_COM_IRQHandler
|
|
||||||
.thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_CC_IRQHandler
|
|
||||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak OTG_FS_WKUP_IRQHandler
|
|
||||||
.thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM5_IRQHandler
|
|
||||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI3_IRQHandler
|
|
||||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART4_IRQHandler
|
|
||||||
.thumb_set UART4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART5_IRQHandler
|
|
||||||
.thumb_set UART5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM6_IRQHandler
|
|
||||||
.thumb_set TIM6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM7_IRQHandler
|
|
||||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN2_TX_IRQHandler
|
|
||||||
.thumb_set CAN2_TX_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN2_RX0_IRQHandler
|
|
||||||
.thumb_set CAN2_RX0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN2_RX1_IRQHandler
|
|
||||||
.thumb_set CAN2_RX1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN2_SCE_IRQHandler
|
|
||||||
.thumb_set CAN2_SCE_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak OTG_FS_IRQHandler
|
|
||||||
.thumb_set OTG_FS_IRQHandler ,Default_Handler
|
|
||||||
|
|
||||||
@@ -1,472 +0,0 @@
|
|||||||
/**
|
|
||||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
|
||||||
* @file startup_stm32f107xc.s
|
|
||||||
* @author MCD Application Team
|
|
||||||
* @brief STM32F107xC Devices vector table for Atollic toolchain.
|
|
||||||
* This module performs:
|
|
||||||
* - Set the initial SP
|
|
||||||
* - Set the initial PC == Reset_Handler,
|
|
||||||
* - Set the vector table entries with the exceptions ISR address
|
|
||||||
* - Configure the clock system
|
|
||||||
* - Branches to main in the C library (which eventually
|
|
||||||
* calls main()).
|
|
||||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
|
||||||
* priority is Privileged, and the Stack is set to Main.
|
|
||||||
******************************************************************************
|
|
||||||
* @attention
|
|
||||||
*
|
|
||||||
* Copyright (c) 2017-2021 STMicroelectronics.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under terms that can be found in the LICENSE file
|
|
||||||
* in the root directory of this software component.
|
|
||||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
||||||
*
|
|
||||||
******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
.syntax unified
|
|
||||||
.cpu cortex-m3
|
|
||||||
.fpu softvfp
|
|
||||||
.thumb
|
|
||||||
|
|
||||||
.global g_pfnVectors
|
|
||||||
.global Default_Handler
|
|
||||||
|
|
||||||
/* start address for the initialization values of the .data section.
|
|
||||||
defined in linker script */
|
|
||||||
.word _sidata
|
|
||||||
/* start address for the .data section. defined in linker script */
|
|
||||||
.word _sdata
|
|
||||||
/* end address for the .data section. defined in linker script */
|
|
||||||
.word _edata
|
|
||||||
/* start address for the .bss section. defined in linker script */
|
|
||||||
.word _sbss
|
|
||||||
/* end address for the .bss section. defined in linker script */
|
|
||||||
.word _ebss
|
|
||||||
|
|
||||||
.equ BootRAM, 0xF1E0F85F
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor first
|
|
||||||
* starts execution following a reset event. Only the absolutely
|
|
||||||
* necessary set is performed, after which the application
|
|
||||||
* supplied main() routine is called.
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
|
|
||||||
.section .text.Reset_Handler
|
|
||||||
.weak Reset_Handler
|
|
||||||
.type Reset_Handler, %function
|
|
||||||
Reset_Handler:
|
|
||||||
|
|
||||||
/* Call the clock system initialization function.*/
|
|
||||||
bl SystemInit
|
|
||||||
|
|
||||||
/* Copy the data segment initializers from flash to SRAM */
|
|
||||||
ldr r0, =_sdata
|
|
||||||
ldr r1, =_edata
|
|
||||||
ldr r2, =_sidata
|
|
||||||
movs r3, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
|
|
||||||
CopyDataInit:
|
|
||||||
ldr r4, [r2, r3]
|
|
||||||
str r4, [r0, r3]
|
|
||||||
adds r3, r3, #4
|
|
||||||
|
|
||||||
LoopCopyDataInit:
|
|
||||||
adds r4, r0, r3
|
|
||||||
cmp r4, r1
|
|
||||||
bcc CopyDataInit
|
|
||||||
|
|
||||||
/* Zero fill the bss segment. */
|
|
||||||
ldr r2, =_sbss
|
|
||||||
ldr r4, =_ebss
|
|
||||||
movs r3, #0
|
|
||||||
b LoopFillZerobss
|
|
||||||
|
|
||||||
FillZerobss:
|
|
||||||
str r3, [r2]
|
|
||||||
adds r2, r2, #4
|
|
||||||
|
|
||||||
LoopFillZerobss:
|
|
||||||
cmp r2, r4
|
|
||||||
bcc FillZerobss
|
|
||||||
|
|
||||||
|
|
||||||
/* Call static constructors */
|
|
||||||
bl __libc_init_array
|
|
||||||
/* Call the application's entry point.*/
|
|
||||||
bl main
|
|
||||||
bx lr
|
|
||||||
.size Reset_Handler, .-Reset_Handler
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is the code that gets called when the processor receives an
|
|
||||||
* unexpected interrupt. This simply enters an infinite loop, preserving
|
|
||||||
* the system state for examination by a debugger.
|
|
||||||
*
|
|
||||||
* @param None
|
|
||||||
* @retval : None
|
|
||||||
*/
|
|
||||||
.section .text.Default_Handler,"ax",%progbits
|
|
||||||
Default_Handler:
|
|
||||||
Infinite_Loop:
|
|
||||||
b Infinite_Loop
|
|
||||||
.size Default_Handler, .-Default_Handler
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
*
|
|
||||||
* The minimal vector table for a Cortex M3. Note that the proper constructs
|
|
||||||
* must be placed on this to ensure that it ends up at physical address
|
|
||||||
* 0x0000.0000.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
.section .isr_vector,"a",%progbits
|
|
||||||
.type g_pfnVectors, %object
|
|
||||||
.size g_pfnVectors, .-g_pfnVectors
|
|
||||||
|
|
||||||
|
|
||||||
g_pfnVectors:
|
|
||||||
|
|
||||||
.word _estack
|
|
||||||
.word Reset_Handler
|
|
||||||
.word NMI_Handler
|
|
||||||
.word HardFault_Handler
|
|
||||||
.word MemManage_Handler
|
|
||||||
.word BusFault_Handler
|
|
||||||
.word UsageFault_Handler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word SVC_Handler
|
|
||||||
.word DebugMon_Handler
|
|
||||||
.word 0
|
|
||||||
.word PendSV_Handler
|
|
||||||
.word SysTick_Handler
|
|
||||||
.word WWDG_IRQHandler
|
|
||||||
.word PVD_IRQHandler
|
|
||||||
.word TAMPER_IRQHandler
|
|
||||||
.word RTC_IRQHandler
|
|
||||||
.word FLASH_IRQHandler
|
|
||||||
.word RCC_IRQHandler
|
|
||||||
.word EXTI0_IRQHandler
|
|
||||||
.word EXTI1_IRQHandler
|
|
||||||
.word EXTI2_IRQHandler
|
|
||||||
.word EXTI3_IRQHandler
|
|
||||||
.word EXTI4_IRQHandler
|
|
||||||
.word DMA1_Channel1_IRQHandler
|
|
||||||
.word DMA1_Channel2_IRQHandler
|
|
||||||
.word DMA1_Channel3_IRQHandler
|
|
||||||
.word DMA1_Channel4_IRQHandler
|
|
||||||
.word DMA1_Channel5_IRQHandler
|
|
||||||
.word DMA1_Channel6_IRQHandler
|
|
||||||
.word DMA1_Channel7_IRQHandler
|
|
||||||
.word ADC1_2_IRQHandler
|
|
||||||
.word CAN1_TX_IRQHandler
|
|
||||||
.word CAN1_RX0_IRQHandler
|
|
||||||
.word CAN1_RX1_IRQHandler
|
|
||||||
.word CAN1_SCE_IRQHandler
|
|
||||||
.word EXTI9_5_IRQHandler
|
|
||||||
.word TIM1_BRK_IRQHandler
|
|
||||||
.word TIM1_UP_IRQHandler
|
|
||||||
.word TIM1_TRG_COM_IRQHandler
|
|
||||||
.word TIM1_CC_IRQHandler
|
|
||||||
.word TIM2_IRQHandler
|
|
||||||
.word TIM3_IRQHandler
|
|
||||||
.word TIM4_IRQHandler
|
|
||||||
.word I2C1_EV_IRQHandler
|
|
||||||
.word I2C1_ER_IRQHandler
|
|
||||||
.word I2C2_EV_IRQHandler
|
|
||||||
.word I2C2_ER_IRQHandler
|
|
||||||
.word SPI1_IRQHandler
|
|
||||||
.word SPI2_IRQHandler
|
|
||||||
.word USART1_IRQHandler
|
|
||||||
.word USART2_IRQHandler
|
|
||||||
.word USART3_IRQHandler
|
|
||||||
.word EXTI15_10_IRQHandler
|
|
||||||
.word RTC_Alarm_IRQHandler
|
|
||||||
.word OTG_FS_WKUP_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word TIM5_IRQHandler
|
|
||||||
.word SPI3_IRQHandler
|
|
||||||
.word UART4_IRQHandler
|
|
||||||
.word UART5_IRQHandler
|
|
||||||
.word TIM6_IRQHandler
|
|
||||||
.word TIM7_IRQHandler
|
|
||||||
.word DMA2_Channel1_IRQHandler
|
|
||||||
.word DMA2_Channel2_IRQHandler
|
|
||||||
.word DMA2_Channel3_IRQHandler
|
|
||||||
.word DMA2_Channel4_IRQHandler
|
|
||||||
.word DMA2_Channel5_IRQHandler
|
|
||||||
.word ETH_IRQHandler
|
|
||||||
.word ETH_WKUP_IRQHandler
|
|
||||||
.word CAN2_TX_IRQHandler
|
|
||||||
.word CAN2_RX0_IRQHandler
|
|
||||||
.word CAN2_RX1_IRQHandler
|
|
||||||
.word CAN2_SCE_IRQHandler
|
|
||||||
.word OTG_FS_IRQHandler
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word 0
|
|
||||||
.word BootRAM /* @0x1E0. This is for boot in RAM mode for
|
|
||||||
STM32F10x Connectivity line Devices. */
|
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
*
|
|
||||||
* Provide weak aliases for each Exception handler to the Default_Handler.
|
|
||||||
* As they are weak aliases, any function with the same name will override
|
|
||||||
* this definition.
|
|
||||||
*
|
|
||||||
*******************************************************************************/
|
|
||||||
.weak NMI_Handler
|
|
||||||
.thumb_set NMI_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak HardFault_Handler
|
|
||||||
.thumb_set HardFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak MemManage_Handler
|
|
||||||
.thumb_set MemManage_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak BusFault_Handler
|
|
||||||
.thumb_set BusFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak UsageFault_Handler
|
|
||||||
.thumb_set UsageFault_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SVC_Handler
|
|
||||||
.thumb_set SVC_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak DebugMon_Handler
|
|
||||||
.thumb_set DebugMon_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak PendSV_Handler
|
|
||||||
.thumb_set PendSV_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak SysTick_Handler
|
|
||||||
.thumb_set SysTick_Handler,Default_Handler
|
|
||||||
|
|
||||||
.weak WWDG_IRQHandler
|
|
||||||
.thumb_set WWDG_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak PVD_IRQHandler
|
|
||||||
.thumb_set PVD_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TAMPER_IRQHandler
|
|
||||||
.thumb_set TAMPER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_IRQHandler
|
|
||||||
.thumb_set RTC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak FLASH_IRQHandler
|
|
||||||
.thumb_set FLASH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RCC_IRQHandler
|
|
||||||
.thumb_set RCC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI0_IRQHandler
|
|
||||||
.thumb_set EXTI0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI1_IRQHandler
|
|
||||||
.thumb_set EXTI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI2_IRQHandler
|
|
||||||
.thumb_set EXTI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI3_IRQHandler
|
|
||||||
.thumb_set EXTI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI4_IRQHandler
|
|
||||||
.thumb_set EXTI4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel6_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA1_Channel7_IRQHandler
|
|
||||||
.thumb_set DMA1_Channel7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ADC1_2_IRQHandler
|
|
||||||
.thumb_set ADC1_2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_TX_IRQHandler
|
|
||||||
.thumb_set CAN1_TX_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_RX0_IRQHandler
|
|
||||||
.thumb_set CAN1_RX0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_RX1_IRQHandler
|
|
||||||
.thumb_set CAN1_RX1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN1_SCE_IRQHandler
|
|
||||||
.thumb_set CAN1_SCE_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI9_5_IRQHandler
|
|
||||||
.thumb_set EXTI9_5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_BRK_IRQHandler
|
|
||||||
.thumb_set TIM1_BRK_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_UP_IRQHandler
|
|
||||||
.thumb_set TIM1_UP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_TRG_COM_IRQHandler
|
|
||||||
.thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM1_CC_IRQHandler
|
|
||||||
.thumb_set TIM1_CC_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM2_IRQHandler
|
|
||||||
.thumb_set TIM2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM3_IRQHandler
|
|
||||||
.thumb_set TIM3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM4_IRQHandler
|
|
||||||
.thumb_set TIM4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_EV_IRQHandler
|
|
||||||
.thumb_set I2C1_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C1_ER_IRQHandler
|
|
||||||
.thumb_set I2C1_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_EV_IRQHandler
|
|
||||||
.thumb_set I2C2_EV_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak I2C2_ER_IRQHandler
|
|
||||||
.thumb_set I2C2_ER_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI1_IRQHandler
|
|
||||||
.thumb_set SPI1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI2_IRQHandler
|
|
||||||
.thumb_set SPI2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART1_IRQHandler
|
|
||||||
.thumb_set USART1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART2_IRQHandler
|
|
||||||
.thumb_set USART2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak USART3_IRQHandler
|
|
||||||
.thumb_set USART3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak EXTI15_10_IRQHandler
|
|
||||||
.thumb_set EXTI15_10_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak RTC_Alarm_IRQHandler
|
|
||||||
.thumb_set RTC_Alarm_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak OTG_FS_WKUP_IRQHandler
|
|
||||||
.thumb_set OTG_FS_WKUP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM5_IRQHandler
|
|
||||||
.thumb_set TIM5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak SPI3_IRQHandler
|
|
||||||
.thumb_set SPI3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART4_IRQHandler
|
|
||||||
.thumb_set UART4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak UART5_IRQHandler
|
|
||||||
.thumb_set UART5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM6_IRQHandler
|
|
||||||
.thumb_set TIM6_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak TIM7_IRQHandler
|
|
||||||
.thumb_set TIM7_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel1_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel2_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel2_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel3_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel3_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel4_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel4_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak DMA2_Channel5_IRQHandler
|
|
||||||
.thumb_set DMA2_Channel5_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ETH_IRQHandler
|
|
||||||
.thumb_set ETH_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak ETH_WKUP_IRQHandler
|
|
||||||
.thumb_set ETH_WKUP_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN2_TX_IRQHandler
|
|
||||||
.thumb_set CAN2_TX_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN2_RX0_IRQHandler
|
|
||||||
.thumb_set CAN2_RX0_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN2_RX1_IRQHandler
|
|
||||||
.thumb_set CAN2_RX1_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak CAN2_SCE_IRQHandler
|
|
||||||
.thumb_set CAN2_SCE_IRQHandler,Default_Handler
|
|
||||||
|
|
||||||
.weak OTG_FS_IRQHandler
|
|
||||||
.thumb_set OTG_FS_IRQHandler ,Default_Handler
|
|
||||||
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20001FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20001FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0807FFFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x08007FFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x200017FF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x200017FF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0807FFFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000BFFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000BFFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x080FFFFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20013FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20013FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x08007FFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x200017FF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x200017FF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20003FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x08007FFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x200027FF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x200027FF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20004FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x20004FFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x08000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x08000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x0807FFFF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000FFFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*###ICF### Section handled by ICF editor, don't touch! ****/
|
|
||||||
/*-Editor annotation file-*/
|
|
||||||
/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml" */
|
|
||||||
/*-Specials-*/
|
|
||||||
define symbol __ICFEDIT_intvec_start__ = 0x20000000;
|
|
||||||
/*-Memory Regions-*/
|
|
||||||
define symbol __ICFEDIT_region_ROM_start__ = 0x20000000 ;
|
|
||||||
define symbol __ICFEDIT_region_ROM_end__ = 0x200013FF;
|
|
||||||
define symbol __ICFEDIT_region_RAM_start__ = 0x20001400;
|
|
||||||
define symbol __ICFEDIT_region_RAM_end__ = 0x2000FFFF;
|
|
||||||
/*-Sizes-*/
|
|
||||||
define symbol __ICFEDIT_size_cstack__ = 0x400;
|
|
||||||
define symbol __ICFEDIT_size_heap__ = 0x200;
|
|
||||||
/**** End of ICF editor section. ###ICF###*/
|
|
||||||
|
|
||||||
|
|
||||||
define memory mem with size = 4G;
|
|
||||||
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];
|
|
||||||
define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];
|
|
||||||
|
|
||||||
define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
|
|
||||||
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };
|
|
||||||
|
|
||||||
initialize by copy { readwrite };
|
|
||||||
do not initialize { section .noinit };
|
|
||||||
|
|
||||||
place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
|
|
||||||
|
|
||||||
place in ROM_region { readonly };
|
|
||||||
place in RAM_region { readwrite,
|
|
||||||
block CSTACK, block HEAP };
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user