使用指南
Luban-Lite 中对 UART 的配置需要在多个地方完成
SoC 设置
在 bsp/artinchip/sys/soc name/Kconfig.chip 中完成该 SoC 中 UART 的相关信息设置,SDK 默认已经完成设置,一般不需要调整
config AIC_UART_DRV
bool
default n
config AIC_UART_DRV_V10
bool
default y if AIC_UART_DRV
config AIC_UART_DRV_VER
string
default "10" if AIC_UART_DRV_V10
config AIC_UART_DEV_NUM
int
default 8 if AIC_UART_DRV
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Board 设置
在 target/soc name/board name/ 目录可以设置要用到的 UART 端口和相应端口的 Pinmux
端口设置
在 target/soc name/board name/Kconfig.board 中完成该开发板中 UART 的相关信息设置, 一般会配置需要的 UART 端口,SDK 默认已经完成设置,一般不需要调整
config AIC_USING_UART0
bool "Using UART0"
default n
select AIC_UART_DRV
config AIC_USING_UART1
bool "Using UART1"
default n
select AIC_UART_DRV
2
3
4
5
6
7
8
9
Pinmux
在 target/soc name/board name/pinmux.c 中设置 UART 端口的 pinmux,需要根据开发板板的不同进行不同的设置
struct aic_pinmux aic_pinmux_config[] = {
...
#ifdef AIC_USING_UART0
/* UART0 */
{5, PIN_PULL_DIS, 3, "PA.0"},
{5, PIN_PULL_DIS, 3, "PA.1"},
#endif
2
3
4
5
6
7
驱动设置
在 bsp/artinchip/drv/UART/Kconfig.dev 中设置设备驱动的工作参数,需要根据使用的不同进行不同的参数设置
baudrate
data bites
stop bits
parity
flow control
config AIC_DEV_UART0_BAUDRATE
int "UART0 baudrate"
default 115200
config AIC_DEV_UART0_DATABITS
int "UART0 data bits"
range 0 15
default 8
config AIC_DEV_UART0_STOPBITS
int "UART0 stop bits"
range 0 3
default 1
2
3
4
5
6
7
8
9
10
11
12
13
使用配置
在如上设置成功后,在 Luban-Lite 根目录下执行 scons --menuconfig,可以进入功能配置界面配置相关参数
Board options -->
[*] Using UART0
[*] Using UART1
[*] Using UART2
[*] Using UART3
UART0 parameter --->
(48000000) UART0 clk frequence
(115200) UART0 baudrate
(8) UART0 data bits
(1) UART0 stop bits
(0) UART0 parity (0=none, 1=odd, 2=even)
UART0 protocol (RS232) --->
UART0 mode (RS232 normal) --->
[ ] Enable UART0 dma mode
2
3
4
5
6
7
8
9
10
11
12
13
14
修改波特率时最好参考cmu手册的模块时钟章节去修改不同波特率对应的clk frequence,以免出现误码的情况。
模式配置
在UART mode中可选择不同的模式:
Board options -->
[*] Using UART0
UART0 parameter --->
(48000000) UART0 clk frequence
(115200) UART0 baudrate
(8) UART0 data bits
(1) UART0 stop bits
(0) UART0 parity (0=none, 1=odd, 2=even)
UART0 protocol (RS232) --->
UART0 mode (RS232 normal) --->
(X) RS232 normal
( ) RS232 auto flow control
( ) RS232 unauto flow control
( ) RS232 software flow control
( ) RS232 software and hardware flow control
2
3
4
5
6
7
8
9
10
11
12
13
14
15
RS232协议可选模式:
RS232 normal: 普通RS232模式
RS232 software flow control: RS232软件流控模式
RS232 auto flow control: RS232硬件自动流控模式,流控管脚固定
RS232 unauto flow control: RS232硬件非自动流控模式,流控管脚自选
RS232 sw and hw flow control: RS232软件流控模式与硬件非自动流控模式,流控管脚自选
RS485协议可选模式:
RS485 normal: RS485三线模式(TX、RX、RTS),RTS管脚固定
RS485 simulation: 模拟RS485三线模式(TX、RX、RTS),RTS管脚自选
RS485 compact io: RS485二线模式(TX/RX、RTS)
管脚配置
若选择RS232 unauto flow control或是RS232 sw and hw flow control需要根据需求自行使能并选择RTS管脚和CTS管脚:
Board options -->
[*] Using UART0
[ ] Using UART1
[ ] Using UART2
[ ] Using UART3
UART0 parameter --->
(48000000) UART0 clk frequence
(115200) UART0 baudrate
(8) UART0 data bits
(1) UART0 stop bits
(0) UART0 parity (0=none, 1=odd, 2=even)
UART0 protocol (RS232) --->
UART0 mode (RS232 unauto flow control) --->
[*] Enable RTS --->
(PA.3) UART0 RTS pin
[*] Enable CTS --->
(PA.2) UART0 CTS pin
[ ] Enable UART0 dma mode
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18