Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
人间散章
rt-thread
提交
a0580191
R
rt-thread
项目概览
人间散章
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a0580191
编写于
3月 18, 2021
作者:
I
iysheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[bsp][ab32vg1] Add support with uart2 and optimize serial port configuration with env tool
上级
6de81af0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
123 addition
and
17 deletion
+123
-17
bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig
bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig
+16
-11
bsp/bluetrum/ab32vg1-ab-prougen/board/ab32vg1_hal_msp.c
bsp/bluetrum/ab32vg1-ab-prougen/board/ab32vg1_hal_msp.c
+16
-0
bsp/bluetrum/libraries/hal_drivers/drv_usart.c
bsp/bluetrum/libraries/hal_drivers/drv_usart.c
+35
-5
bsp/bluetrum/libraries/hal_drivers/drv_usart.h
bsp/bluetrum/libraries/hal_drivers/drv_usart.h
+2
-0
bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_gpio_ex.h
...s/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_gpio_ex.h
+7
-0
bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_uart.h
...ries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_uart.h
+1
-0
bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/source/ab32vg1_hal_uart.c
...aries/hal_libraries/ab32vg1_hal/source/ab32vg1_hal_uart.c
+46
-1
未找到文件。
bsp/bluetrum/ab32vg1-ab-prougen/board/Kconfig
浏览文件 @
a0580191
...
...
@@ -2,12 +2,6 @@ menu "Hardware Drivers Config"
menu "Onboard Peripheral Drivers"
config BSP_USING_USB_TO_USART
bool "Enable USB TO USART (uart0)"
select BSP_USING_UART
select BSP_USING_UART0
default y
menuconfig BSP_USING_AUDIO
bool "Enable Audio Device"
select RT_USING_AUDIO
...
...
@@ -34,11 +28,22 @@ menu "Onboard Peripheral Drivers"
endmenu
menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_UART0
bool "Enable UART0"
select RT_USING_SERIAL
default y
menuconfig BSP_USING_UART
bool "Enable UART"
if BSP_USING_UART
config BSP_USING_UART0
bool "Enable UART0"
select RT_USING_SERIAL
default y
config BSP_USING_UART1
bool "Enable UART1"
select RT_USING_SERIAL
default n
config BSP_USING_UART2
bool "Enable UART2"
select RT_USING_SERIAL
default n
endif
config BSP_USING_SDIO
bool "Enable SDIO"
...
...
bsp/bluetrum/ab32vg1-ab-prougen/board/ab32vg1_hal_msp.c
浏览文件 @
a0580191
...
...
@@ -35,6 +35,22 @@ void hal_uart_mspinit(struct uart_handle *huart)
gpio_init
.
af_con
=
GPIO_AFEN
|
GPIO_AFCON0
|
UT1RXMAP_AF
;
hal_gpio_init
(
GPIOA_BASE
,
&
gpio_init
);
/* Interrupt */
}
else
if
(
huart
->
instance
==
UART2_BASE
)
{
gpio_init
.
pin
=
GPIO_PIN_2
;
gpio_init
.
dir
=
GPIO_DIR_OUTPUT
;
gpio_init
.
de
=
GPIO_DIGITAL
;
gpio_init
.
alternate
=
GPIO_AF_MAP_Gx
(
UT2TXMAP_AF
,
GPIO_AF_G2
);
gpio_init
.
af_con
=
GPIO_AFEN
|
GPIO_AFCON1
|
UT2TXMAP_AF
;
hal_gpio_init
(
GPIOB_BASE
,
&
gpio_init
);
gpio_init
.
pin
=
GPIO_PIN_1
;
gpio_init
.
pull
=
GPIO_PULLUP
;
gpio_init
.
dir
=
GPIO_DIR_INPUT
;
gpio_init
.
de
=
GPIO_DIGITAL
;
gpio_init
.
alternate
=
GPIO_AF_MAP_Gx
(
UT2RXMAP_AF
,
GPIO_AF_G2
);
gpio_init
.
af_con
=
GPIO_AFEN
|
GPIO_AFCON1
|
UT2RXMAP_AF
;
hal_gpio_init
(
GPIOB_BASE
,
&
gpio_init
);
/* Interrupt */
}
}
...
...
bsp/bluetrum/libraries/hal_drivers/drv_usart.c
浏览文件 @
a0580191
...
...
@@ -21,20 +21,40 @@
enum
{
#ifdef BSP_USING_UART0
UART0_INDEX
,
#endif
#ifdef BSP_USING_UART1
UART1_INDEX
,
#endif
#ifdef BSP_USING_UART2
UART2_INDEX
,
#endif
};
static
struct
ab32_uart_config
uart_config
[]
=
{
#ifdef BSP_USING_UART0
{
.
name
=
"uart0"
,
.
instance
=
UART0_BASE
,
.
mode
=
UART_MODE_TX_RX
|
UART_MODE_1LINE
,
},
#endif
#ifdef BSP_USING_UART1
{
.
name
=
"uart1"
,
.
instance
=
UART1_BASE
,
.
mode
=
UART_MODE_TX_RX
,
},
#endif
#ifdef BSP_USING_UART2
{
.
name
=
"uart2"
,
.
instance
=
UART2_BASE
,
.
mode
=
UART_MODE_TX_RX
,
}
#endif
};
static
struct
ab32_uart
uart_obj
[
sizeof
(
uart_config
)
/
sizeof
(
uart_config
[
0
])]
=
{
0
};
...
...
@@ -48,7 +68,7 @@ static rt_err_t ab32_configure(struct rt_serial_device *serial, struct serial_co
uart
=
rt_container_of
(
serial
,
struct
ab32_uart
,
serial
);
uart
->
handle
.
instance
=
uart
->
config
->
instance
;
uart
->
handle
.
init
.
baud
=
cfg
->
baud_rate
;
uart
->
handle
.
init
.
mode
=
UART_MODE_TX_RX
;
uart
->
handle
.
init
.
mode
=
uart
->
config
->
mode
;
switch
(
cfg
->
data_bits
)
{
...
...
@@ -152,14 +172,24 @@ static void uart_isr(int vector, void *param)
{
rt_interrupt_enter
();
#ifdef BSP_USING_UART0
if
(
hal_uart_getflag
(
UART0_BASE
,
UART_FLAG_RXPND
))
//RX one byte finish
{
rt_hw_serial_isr
(
&
(
uart_obj
[
UART0_INDEX
].
serial
),
RT_SERIAL_EVENT_RX_IND
);
}
// if(hal_uart_getflag(UART1_BASE, UART_FLAG_RXPND)) //RX one byte finish
// {
// rt_hw_serial_isr(&(uart_obj[UART1_INDEX].serial), RT_SERIAL_EVENT_RX_IND);
// }
#endif
#ifdef BSP_USING_UART1
if
(
hal_uart_getflag
(
UART1_BASE
,
UART_FLAG_RXPND
))
//RX one byte finish
{
rt_hw_serial_isr
(
&
(
uart_obj
[
UART1_INDEX
].
serial
),
RT_SERIAL_EVENT_RX_IND
);
}
#endif
#ifdef BSP_USING_UART2
if
(
hal_uart_getflag
(
UART2_BASE
,
UART_FLAG_RXPND
))
//RX one byte finish
{
rt_hw_serial_isr
(
&
(
uart_obj
[
UART2_INDEX
].
serial
),
RT_SERIAL_EVENT_RX_IND
);
}
#endif
rt_interrupt_leave
();
}
...
...
bsp/bluetrum/libraries/hal_drivers/drv_usart.h
浏览文件 @
a0580191
...
...
@@ -20,6 +20,8 @@ struct ab32_uart_config
{
const
char
*
name
;
hal_sfr_t
instance
;
uint8_t
mode
;
uint8_t
reserve
[
3
];
// struct dma_config *dma_rx;
// struct dma_config *dma_tx;
};
...
...
bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_gpio_ex.h
浏览文件 @
a0580191
...
...
@@ -33,8 +33,15 @@
* G1: tx:PA7 rx:PA6
* G2: tx:PA4 rx:PA3
* G3: tx:PF2 rx:map to tx
*
* UART2:
* G1: tx:PE3 rx:PE2
* G2: tx:PB2 rx:PB1
*/
#define UT2RXMAP_AF (8u)
#define UT2TXMAP_AF (4u)
#define UT1RXMAP_AF (28u)
#define UT1TXMAP_AF (24u)
#define HSUTRXMAP_AF (20u)
...
...
bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/include/ab32vg1_hal_uart.h
浏览文件 @
a0580191
...
...
@@ -78,6 +78,7 @@ struct uart_handle
*/
#define UART_MODE_TX (0x00u)
/*!< TX mode */
#define UART_MODE_TX_RX (0x01u)
/*!< RX and TX mode */
#define UART_MODE_1LINE (0x02u)
/*!< oneline mode */
/**
* @}
...
...
bsp/bluetrum/libraries/hal_libraries/ab32vg1_hal/source/ab32vg1_hal_uart.c
浏览文件 @
a0580191
...
...
@@ -27,10 +27,51 @@ void hal_uart_setbaud(hal_sfr_t uartx, uint32_t baud)
uint32_t
baud_cfg
;
uartx
[
UARTxCON
]
|=
UART_CLK_SRC1
;
baud_cfg
=
(
26000000
/
2
)
/
baud
;
//1.5M
baud_cfg
=
(
26000000
/
2
)
/
baud
;
uartx
[
UARTxBAUD
]
=
(
baud_cfg
<<
16
)
|
baud_cfg
;
}
/**
* @brief Set the UART misc paramter.
*
* @param uartx This parameter can be UARTxN where x can be (0.2).
* @param param uart config paramter pointer.
*/
void
hal_uart_setparam
(
hal_sfr_t
uartx
,
struct
uart_init
*
param
)
{
switch
(
param
->
word_len
)
{
case
UART_WORDLENGTH_8B
:
uartx
[
UARTxCON
]
&=
~
UART_BIT9_ENABLE
;
break
;
case
UART_WORDLENGTH_9B
:
uartx
[
UARTxCON
]
|=
UART_BIT9_ENABLE
;
break
;
default:
break
;
}
switch
(
param
->
stop_bits
)
{
case
UART_STOPBITS_1
:
uartx
[
UARTxCON
]
&=
~
UART_SB2_ENABLE
;
break
;
case
UART_STOPBITS_2
:
uartx
[
UARTxCON
]
|=
UART_SB2_ENABLE
;
break
;
default:
break
;
}
if
(
param
->
mode
&
UART_MODE_1LINE
)
{
uartx
[
UARTxCON
]
|=
UART_1LINE_ENABLE
;
}
else
{
uartx
[
UARTxCON
]
&=
~
UART_1LINE_ENABLE
;
}
}
/**
* @brief Initialize the UART mode.
*
...
...
@@ -157,11 +198,15 @@ void uart_config_all(struct uart_handle *huart)
hal_rcu_periph_clk_enable
(
RCU_UART0
);
}
else
if
(
huart
->
instance
==
UART1_BASE
)
{
hal_rcu_periph_clk_enable
(
RCU_UART1
);
}
else
if
(
huart
->
instance
==
UART2_BASE
)
{
hal_rcu_periph_clk_enable
(
RCU_UART2
);
}
else
{
return
;
/* Not support! */
}
hal_uart_deinit
(
huart
->
instance
);
hal_uart_setbaud
(
huart
->
instance
,
huart
->
init
.
baud
);
hal_uart_setparam
(
huart
->
instance
,
&
huart
->
init
);
if
(
huart
->
init
.
mode
!=
UART_MODE_TX
)
{
hal_uart_control
(
huart
->
instance
,
UART_RX_ENABLE
,
HAL_ENABLE
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录