generated from hulk/gd32e23x_template
Compare commits
11 Commits
feature-pr
...
dev
Author | SHA1 | Date | |
---|---|---|---|
73caf651ef | |||
da00f1d758 | |||
1f64a500f9 | |||
385b6fda17 | |||
5714a10061 | |||
af629a6bc4 | |||
b0b2966efc | |||
6e0ec2b64e | |||
b5b9d538a1 | |||
81182cbafa | |||
7e9aefdd5f |
@@ -12,7 +12,7 @@ set(VERSION "V${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
|
|||||||
string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
|
string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
|
||||||
|
|
||||||
# Options 1
|
# Options 1
|
||||||
set(OPT1 "_[12V]")
|
set(OPT1 "_[24V]")
|
||||||
#set(OPT1 "_[SW_IIC]")
|
#set(OPT1 "_[SW_IIC]")
|
||||||
|
|
||||||
# Options 2
|
# Options 2
|
||||||
|
61
CommunicationProtocol.md
Normal file
61
CommunicationProtocol.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# US&IR传感器模块通信协议
|
||||||
|
|
||||||
|
## US&IR传感器模块通信协议
|
||||||
|
|
||||||
|
| **序号** | **修改内容** | **版本** | **日期** | **修改人** |
|
||||||
|
|:------:|:--------:|:------:|:----------:|:-------:|
|
||||||
|
| 1 | 初版 | V0.1 | 2025-01-20 | Hulk |
|
||||||
|
| | | | | |
|
||||||
|
| | | | | |
|
||||||
|
| | | | | |
|
||||||
|
|
||||||
|
### 发包格式
|
||||||
|
|
||||||
|
| **包头** | **类型** | **数据长度** | **数据** | **校验** |
|
||||||
|
|:------:|:------:|:-----------:|:------:|:------:|
|
||||||
|
| D5 | 0x04 | Data Length | Data | CRC |
|
||||||
|
|
||||||
|
- 数据长度只包含数据部分,不包含包头、类型、数据长度、校验
|
||||||
|
- CRC求和校验,包含类型、数据长度、数据
|
||||||
|
- 数据部分为ascii码
|
||||||
|
|
||||||
|
### 回包格式
|
||||||
|
|
||||||
|
| **包头** | **状态码** | **数据长度** | **数据** | **校验** |
|
||||||
|
|:------:|:----------:|:-----------:|:------:|:------:|
|
||||||
|
| B5 | 0xF0 正常包 | Data Length | Data | CRC |
|
||||||
|
| B5 | 0xF1 CRC错误 | Data Length | Data | CRC |
|
||||||
|
| B5 | 0xF2 包头错误 | Data Length | Data | CRC |
|
||||||
|
| B5 | 0xF3 类型错误 | Data Length | Data | CRC |
|
||||||
|
| B5 | 0xF4 包长度错误 | Data Length | Data | CRC |
|
||||||
|
|
||||||
|
- 数据长度只包含数据部分,不包含包头、类型、数据长度、校验
|
||||||
|
- CRC求和校验,包含状态码、数据长度、数据
|
||||||
|
- 有效数据部分为uint32_t,高字节在前
|
||||||
|
- 包错误和指令错误时,数据部分为ascii码 `err`
|
||||||
|
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
## US&IR传感器模块功能
|
||||||
|
|
||||||
|
### 1. 读取液面的超声距离
|
||||||
|
|
||||||
|
- 发送M1指令,读取距离液面的超声距离。
|
||||||
|
- `D5 04 02 4D 31 84`
|
||||||
|
- 电涡流传感器模块涡流回复数据
|
||||||
|
- `B5 F0 02 1D C0 CF`, 有效数据为 `0x1DC0`,转换为`7616`,距离为76.16mm
|
||||||
|
- `B5 F0 02 16 A5 AD`, 有效数据为 `0x16A5`,转换为`5797`,距离为57.97mm
|
||||||
|
- 错误命令(M3指令)回包
|
||||||
|
- `B5 F0 03 65 72 72 3C`,有效数据为 `err`
|
||||||
|
- CRC错误回包
|
||||||
|
- `B5 F1 03 65 72 72 3D`, 有效数据为 `err`
|
||||||
|
- 包头错误回包
|
||||||
|
- `B5 F2 03 65 72 72 3E`, 有效数据为 `err`
|
||||||
|
- 类型错误回包
|
||||||
|
- `B5 F3 03 65 72 72 3F`, 有效数据为 `err`
|
||||||
|
- 数据长度错误回包
|
||||||
|
- `B5 F4 03 65 72 72 40`, 有效数据为 `err`
|
||||||
|
|
||||||
|
### 2. 读取数据时间间隔
|
||||||
|
|
||||||
|
- 推荐数据时间间隔至少为50ms
|
93
README.md
93
README.md
@@ -1,80 +1,31 @@
|
|||||||
# gd32e23x_template
|
# XLSW-3DP-Sensor-UltraSonic&IR
|
||||||
本项目为`GD32E230Fx`系列的基于Clion的CMake开发的工程模板。本人暂未入门,强行上强度,放弃keil,拥抱开源。遂尝试使用arm-none-eabi-gcc进行开发。
|
|
||||||
有幸寻得[@mo10 ](https://github.com/mo10)大佬的帮助,本项目的基础目录架构与CMakeLists.txt与toolchain.cmake均为大佬提供。
|
|
||||||
|
|
||||||
## 关于本项目
|
| **版本号** | **修改内容** | **日期** | **修改人** |
|
||||||
本项目默认的芯片型号为`GD32E230F4`,但是可以根据需要修改为其他型号,具体修改方法请参考下方`关于链接脚本`的说明。
|
|:-------:|:--------:|:----------:|:-------:|
|
||||||
### 版本号
|
| v0.0.1 | 非稳定版本 | 2025-01-20 | Hulk |
|
||||||
默认版本号为`0.0.1`,在`CMakeLists.txt`中修改`PROJECT_VERSION`即可。
|
| v0.2.0 | 硬件修改RS485接口芯片为SP3485(非自动换向) | 2025-06-03 | Hulk |
|
||||||
### 项目名称
|
|
||||||
默认项目名称为`gd32e23x_template`,在`CMakeLists.txt`中修改`PROJECT_NAME`即可。请先修改项目名称再配置编译环境。
|
|
||||||
### 软件IIC与硬件IIC
|
|
||||||
本项目中提供了软件IIC与硬件IIC的驱动,但是默认使用硬件IIC,如果需要使用软件IIC,请在`board_config.h`中取消注释`// #define SOFTWARE_IIC`(line 8)。
|
|
||||||
### 编译选项
|
|
||||||
本项目预留了两个编译选项,`OPT1`与`OPT2`,默认均为空,请根据需要自行修改,例如`OPT1`为`_[HW_IIC]`,`OPT2`为`_[NO_LED]`。
|
|
||||||
`OPT1`与`OPT2`均在`CMakeLists.txt`中可修改。
|
|
||||||
### 关于编译日期
|
|
||||||
本项目在`CMakeLists.txt`中添加了编译日期。
|
|
||||||
|
|
||||||
### 关于led
|
## US&IR传感器模块通信协议
|
||||||
本项目默认开启了LED闪烁,并使用TIMER16进行定时。
|
|
||||||
|
|
||||||
|
通信协议:[US&IR通信协议](CommunicationProtocol.md)
|
||||||
|
|
||||||
## 关于C标准库的printf的重写
|
---
|
||||||
在Keil开发中,ARMClang有自己的microLIB,所以直接调用,然后重写fputc函数即可,但在gcc中需要重写`_write`函数,本项目模板中已经在`main.c`中完成重写。
|
|
||||||
同时需要添加`--spaces=nano.spaces`编译参数。
|
|
||||||
但是printf本身占用flash比较大,建议谨慎使用,尤其是本项目搭建时候采用的型号为`GD32E230F4V6`内存非常有限,重写后加上spaces设置,目前能用。
|
|
||||||
|
|
||||||
## 添加源文件与头文件
|
## 300K超声换能头工作流程
|
||||||
在`ProjectDir/CMakeLists.txt`中21行左右,添加对应源文件即可。
|
### **1. 超声波发送**
|
||||||
|
通过TIMER13定时器,配置为输出300KHz的PWM信号,驱动超声换能头发射超声波。TIMER13的输出模式为PWM1模式,同时用TIMER13的更新中断触发次数进行计数。
|
||||||
|
最终使驱动引脚发送300KHz 50%占空比 5个周期的PWM信号。同时开启计时。
|
||||||
|
|
||||||
```cmake
|
### **2. 超声波计时**
|
||||||
set(TARGET_C_SRC
|
通过TIMER15定时器,配置为us计时器,并传入预先测得的超声消隐延时值(例如:230us)。该定时器用于在发送超声波后延时一段时间,确保接收通道不会受到发射信号的干扰。但是暂不开启该定时器。
|
||||||
${CMAKE_SOURCE_DIR}/src/main.c
|
同时在TIMER15的更新中断中断服务函数中,开启外部输入中断,用以检测超声回波,并开启TIMER16定时器。
|
||||||
${CMAKE_SOURCE_DIR}/src/gd32e23x_it.c
|
TIMER16定时器输入捕获,用于计算超声回波的时间。
|
||||||
${CMAKE_SOURCE_DIR}/src/systick.c
|
通过前面的消隐时间与回波时间的和值,计算出实际的距离值。
|
||||||
)
|
|
||||||
```
|
|
||||||
## 关于链接脚本
|
|
||||||
注意芯片选型, 不同型号的芯片 FLASH 和 RAM 大小不同。需要修改链接脚本`ld/gd32e23x_gcc.ld`
|
|
||||||
|
|
||||||
| 芯片型号 | FLASH | RAM |
|
### **3. 距离值输出**
|
||||||
|------------|-------|-----|
|
|
||||||
| GD32E230F4 | 16K | 4K |
|
|
||||||
| GD32E230F8 | 64K | 8K |
|
|
||||||
|
|
||||||
```linkerscript
|
\[
|
||||||
/* memory map */
|
\frac{\frac{(\verb|TIME_CORRECTION_US| + \verb|us_value|)\times 340\,\text{m/s}}{10^{3} \ast 10^{3}} }{2}
|
||||||
MEMORY
|
\]
|
||||||
{
|
|
||||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 16K
|
|
||||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 4K
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## 关于Startup文件
|
其中,`TIME_CORRECTION_US`为超声消隐延时定时器的初始值,`us_value`为外部输入中断计数值。
|
||||||
|
|
||||||
[@mo10 ](https://github.com/mo10)大佬提供的一些想法,具体如下。但是我目前还没测试到实际的影响和作用范围,所以暂未同步进来,仅作为备忘内容
|
|
||||||
```asm
|
|
||||||
Reset_Handler:
|
|
||||||
ldr r0, =_sp
|
|
||||||
mov sp, r0
|
|
||||||
ldr r0, =_end
|
|
||||||
msr msplim, r0
|
|
||||||
/* copy the data segment into ram */
|
|
||||||
movs r1, #0
|
|
||||||
b LoopCopyDataInit
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Ref
|
|
||||||
|
|
||||||
1. 参考LD/Startup
|
|
||||||
|
|
||||||
[https://github.com/Noveren/gd32e23x-template/blob/main/gd32e23x/template/linker.ld](https://github.com/Noveren/gd32e23x-template/blob/main/gd32e23x/template/linker.ld)
|
|
||||||
|
|
||||||
[https://github.com/Noveren/gd32e23x-template/blob/main/gd32e23x/template/startup.s](https://github.com/Noveren/gd32e23x-template/blob/main/gd32e23x/template/startup.s)
|
|
||||||
|
|
||||||
2. 官方LD/Startup
|
|
||||||
|
|
||||||
使用Embedded Builder工具生成的C标准库生成的模板
|
|
@@ -9,8 +9,10 @@
|
|||||||
|
|
||||||
// #define DEBUG_VERBOES
|
// #define DEBUG_VERBOES
|
||||||
|
|
||||||
#define POWER_SUPPLY_12V
|
// #define POWER_SUPPLY_12V
|
||||||
// #define POWER_SUPPLY_24V
|
#define POWER_SUPPLY_24V
|
||||||
|
|
||||||
|
// #define DEBUG_VOFA_TOOL
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@
|
|||||||
#define USART_PHY USART0
|
#define USART_PHY USART0
|
||||||
#define USART_PHY_BAUDRATE 115200U
|
#define USART_PHY_BAUDRATE 115200U
|
||||||
#define RS485_EN_PORT GPIOA
|
#define RS485_EN_PORT GPIOA
|
||||||
#define RS485_EN_PIN GPIO_PIN_4
|
#define RS485_EN_PIN GPIO_PIN_1
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@@ -8,8 +8,6 @@
|
|||||||
#include "gd32e23x.h"
|
#include "gd32e23x.h"
|
||||||
#include "board_config.h"
|
#include "board_config.h"
|
||||||
|
|
||||||
void usart_config(void);
|
|
||||||
|
|
||||||
void rs485_config(void);
|
void rs485_config(void);
|
||||||
|
|
||||||
#endif //USART_H
|
#endif //USART_H
|
||||||
|
@@ -35,5 +35,5 @@ void led_blink_config(void)
|
|||||||
|
|
||||||
timer_enable(LED_BLINK_TIMER);
|
timer_enable(LED_BLINK_TIMER);
|
||||||
|
|
||||||
nvic_irq_enable(LED_BLINK_IRQ, 2);
|
nvic_irq_enable(LED_BLINK_IRQ, 3U);
|
||||||
}
|
}
|
17
src/main.c
17
src/main.c
@@ -25,26 +25,25 @@ int main(void)
|
|||||||
/* configure LED */
|
/* configure LED */
|
||||||
led_blink_config();
|
led_blink_config();
|
||||||
/* configure FWDGT */
|
/* configure FWDGT */
|
||||||
watchdog_init();
|
// watchdog_init();
|
||||||
|
|
||||||
#ifdef SOFTWARE_IIC
|
// #ifdef SOFTWARE_IIC
|
||||||
soft_i2c_config();
|
// soft_i2c_config();
|
||||||
#else
|
// #else
|
||||||
i2c_config();
|
// i2c_config();
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
printf("system start!\r\n");
|
printf("system start!\r\n");
|
||||||
|
|
||||||
ultrasonic_config();
|
ultrasonic_config();
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
gd60914_get_object_tempture();
|
// gd60914_get_object_tempture();
|
||||||
|
|
||||||
delay_ms(50);
|
delay_ms(50);
|
||||||
|
|
||||||
ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES);
|
ultrasonic_pwm_out_cycles(ULTRASONIC_TX_CYCLES);
|
||||||
|
|
||||||
watchdog_reload();
|
// watchdog_reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,12 +21,12 @@ void process_command(uint8_t *cmd, size_t length) {
|
|||||||
sprintf(combined_str, "%c%c", cmd[3], cmd[4]);
|
sprintf(combined_str, "%c%c", cmd[3], cmd[4]);
|
||||||
if (strcmp(combined_str, "M1") == 0) {
|
if (strcmp(combined_str, "M1") == 0) {
|
||||||
ultrasonic_distance_report();
|
ultrasonic_distance_report();
|
||||||
} else if (strcmp(combined_str, "M2") == 0) {
|
// } else if (strcmp(combined_str, "M2") == 0) {
|
||||||
gd60914_tempture_report();
|
// gd60914_tempture_report();
|
||||||
} else if (strcmp(combined_str, "M3") == 0)
|
// } else if (strcmp(combined_str, "M3") == 0)
|
||||||
{
|
// {
|
||||||
printf("%c%c%c%c%c%c", 0xB5, 0xF1, 0x02, 0x6F, 0x6B, 0xCC);
|
// printf("%c%c%c%c%c%c", 0xB5, 0xF1, 0x02, 0x6F, 0x6B, 0xCC);
|
||||||
fwdgt_reset_mcu();
|
// fwdgt_reset_mcu();
|
||||||
} else {
|
} else {
|
||||||
printf("%c%c%c%c%c%c%c", 0xB5, 0xF0, 0x03, 0x65, 0x72, 0x72, 0x3C);
|
printf("%c%c%c%c%c%c%c", 0xB5, 0xF0, 0x03, 0x65, 0x72, 0x72, 0x3C);
|
||||||
return;
|
return;
|
||||||
@@ -110,6 +110,9 @@ void ultrasonic_distance_report(void) {
|
|||||||
|
|
||||||
distance_uint16 = ultrasonic_calc_distance();
|
distance_uint16 = ultrasonic_calc_distance();
|
||||||
|
|
||||||
|
#ifdef DEBUG_VOFA_TOOL
|
||||||
|
printf("%d\n", distance_uint16);
|
||||||
|
#else
|
||||||
package_data[0] = (distance_uint16 >> 8) & 0xFF;
|
package_data[0] = (distance_uint16 >> 8) & 0xFF;
|
||||||
package_data[1] = distance_uint16 & 0xFF;
|
package_data[1] = distance_uint16 & 0xFF;
|
||||||
|
|
||||||
@@ -120,4 +123,5 @@ void ultrasonic_distance_report(void) {
|
|||||||
printf("%c%c%c", package_header[0], package_header[1], package_header[2]);
|
printf("%c%c%c", package_header[0], package_header[1], package_header[2]);
|
||||||
printf("%c%c", package_data[0], package_data[1]);
|
printf("%c%c", package_data[0], package_data[1]);
|
||||||
printf("%c", calculate_crc(combined_data, 6));
|
printf("%c", calculate_crc(combined_data, 6));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -140,7 +140,7 @@ void ultrasonic_config(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t ultrasonic_calc_distance(void) {
|
uint16_t ultrasonic_calc_distance(void) {
|
||||||
while (!ultrasonicMeasurementDone);
|
// while (!ultrasonicMeasurementDone);
|
||||||
// uint32_t us_value = timer_channel_capture_value_register_read(US_ECHO_TIMER, US_ECHO_CH);
|
// uint32_t us_value = timer_channel_capture_value_register_read(US_ECHO_TIMER, US_ECHO_CH);
|
||||||
uint16_t distance = (TIME_CORRECTION_US + g_capture_value) * 17;
|
uint16_t distance = (TIME_CORRECTION_US + g_capture_value) * 17;
|
||||||
/*
|
/*
|
||||||
|
67
src/usart.c
67
src/usart.c
@@ -4,36 +4,6 @@
|
|||||||
|
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief configure the USART
|
|
||||||
* @param none
|
|
||||||
* @retval none
|
|
||||||
*/
|
|
||||||
void usart_config(void)
|
|
||||||
{
|
|
||||||
rcu_periph_clock_enable(USART_GPIO_RCU);
|
|
||||||
rcu_periph_clock_enable(USART_RCU);
|
|
||||||
|
|
||||||
gpio_af_set(USART_GPIO_PORT, USART_GPIO_AF, USART_RX_PIN);
|
|
||||||
gpio_af_set(USART_GPIO_PORT, USART_GPIO_AF, USART_TX_PIN);
|
|
||||||
|
|
||||||
gpio_mode_set(USART_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP, USART_RX_PIN);
|
|
||||||
gpio_output_options_set(USART_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, USART_RX_PIN);
|
|
||||||
gpio_mode_set(USART_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP, USART_TX_PIN);
|
|
||||||
gpio_output_options_set(USART_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, USART_TX_PIN);
|
|
||||||
|
|
||||||
usart_deinit(USART_PHY);
|
|
||||||
usart_baudrate_set(USART_PHY, USART_PHY_BAUDRATE);
|
|
||||||
usart_receive_config(USART_PHY, USART_RECEIVE_ENABLE);
|
|
||||||
usart_transmit_config(USART_PHY, USART_TRANSMIT_ENABLE);
|
|
||||||
|
|
||||||
usart_enable(USART_PHY);
|
|
||||||
|
|
||||||
nvic_irq_enable(USART0_IRQn, 0);
|
|
||||||
usart_interrupt_enable(USART_PHY, USART_INT_RBNE);
|
|
||||||
usart_interrupt_enable(USART_PHY, USART_INT_IDLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief configure the RS485(MAX13487) driver
|
* @brief configure the RS485(MAX13487) driver
|
||||||
* @param none
|
* @param none
|
||||||
@@ -41,10 +11,39 @@ void usart_config(void)
|
|||||||
*/
|
*/
|
||||||
void rs485_config(void)
|
void rs485_config(void)
|
||||||
{
|
{
|
||||||
usart_config();
|
rcu_periph_clock_enable(USART_GPIO_RCU);
|
||||||
|
rcu_periph_clock_enable(USART_RCU);
|
||||||
|
|
||||||
gpio_mode_set(RS485_EN_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, RS485_EN_PIN);
|
gpio_af_set(USART_GPIO_PORT, GPIO_AF_1, USART_TX_PIN | USART_RX_PIN | RS485_EN_PIN);
|
||||||
gpio_output_options_set(RS485_EN_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RS485_EN_PIN);
|
|
||||||
|
|
||||||
gpio_bit_write(RS485_EN_PORT, RS485_EN_PIN, SET); //auto dircetion control
|
/* configure USART Tx&Rx as alternate function push-pull */
|
||||||
|
gpio_mode_set(USART_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_PULLUP, USART_TX_PIN | USART_RX_PIN);
|
||||||
|
gpio_output_options_set(USART_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_10MHZ, USART_TX_PIN | USART_RX_PIN);
|
||||||
|
|
||||||
|
/* configure RS485 EN Pin */
|
||||||
|
gpio_mode_set(USART_GPIO_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, RS485_EN_PIN);
|
||||||
|
gpio_output_options_set(USART_GPIO_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, RS485_EN_PIN);
|
||||||
|
// gpio_bit_write(RS485_GPIO_PORT, RS485_EN_PIN, SET);
|
||||||
|
|
||||||
|
/* USART configure */
|
||||||
|
usart_deinit(USART_PHY);
|
||||||
|
usart_baudrate_set(USART_PHY, USART_PHY_BAUDRATE);
|
||||||
|
// usart_parity_config(RS485_PHY, USART_PM_NONE);
|
||||||
|
// usart_word_length_set(RS485_PHY, USART_WL_8BIT);
|
||||||
|
// usart_stop_bit_set(RS485_PHY, USART_STB_1BIT);
|
||||||
|
usart_receive_config(USART_PHY, USART_RECEIVE_ENABLE);
|
||||||
|
usart_transmit_config(USART_PHY, USART_TRANSMIT_ENABLE);
|
||||||
|
|
||||||
|
usart_driver_assertime_config(USART_PHY, 0x01);
|
||||||
|
usart_driver_deassertime_config(USART_PHY, 0x01);
|
||||||
|
|
||||||
|
// usart_depolarity_config(USART0, USART_DEP_HIGH);
|
||||||
|
// usart_depolarity_config(USART0, USART_DEP_LOW);
|
||||||
|
|
||||||
|
usart_rs485_driver_enable(USART_PHY);
|
||||||
|
usart_enable(USART_PHY);
|
||||||
|
|
||||||
|
nvic_irq_enable(USART0_IRQn, 0);
|
||||||
|
usart_interrupt_enable(USART_PHY, USART_INT_RBNE);
|
||||||
|
usart_interrupt_enable(USART_PHY, USART_INT_IDLE);
|
||||||
}
|
}
|
Reference in New Issue
Block a user