Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
5f81f8e7
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
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,发现更多精彩内容 >>
未验证
提交
5f81f8e7
编写于
3月 30, 2018
作者:
T
Tanek
提交者:
GitHub
3月 30, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1330 from balanceTWK/master
[BSP][i.mxrt1052] fix uart
上级
75a2fe4d
144bfdbd
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
46 addition
and
60 deletion
+46
-60
bsp/imxrt1052-evk/drivers/board.c
bsp/imxrt1052-evk/drivers/board.c
+29
-30
bsp/imxrt1052-evk/drivers/drv_uart.c
bsp/imxrt1052-evk/drivers/drv_uart.c
+15
-27
bsp/imxrt1052-evk/drivers/drv_uart.h
bsp/imxrt1052-evk/drivers/drv_uart.h
+2
-3
未找到文件。
bsp/imxrt1052-evk/drivers/board.c
浏览文件 @
5f81f8e7
...
...
@@ -78,9 +78,8 @@ static void BOARD_BootClockRUN(void)
CLOCK_DeinitEnetPll
();
CLOCK_DeinitUsb2Pll
();
/* Configure UART divider to default */
CLOCK_SetMux
(
kCLOCK_UartMux
,
0
);
/* Set UART source to PLL3 80M */
CLOCK_SetDiv
(
kCLOCK_UartDiv
,
0
);
/* Set UART divider to 1 */
/* iomuxc clock (iomuxc_clk_enable): 0x03u */
CLOCK_EnableClock
(
kCLOCK_Iomuxc
);
/* Update core clock */
SystemCoreClockUpdate
();
...
...
@@ -191,13 +190,13 @@ void rt_hw_board_init()
#if defined(RT_USING_SDRAM) && defined(RT_USING_MEMHEAP_AS_HEAP)
rt_kprintf
(
"sdram heap, begin: 0x%p, end: 0x%p
\n
"
,
SDRAM_BEGIN
,
SDRAM_END
);
rt_system_heap_init
((
void
*
)
SDRAM_BEGIN
,
(
void
*
)
SDRAM_END
);
rt_system_heap_init
((
void
*
)
SDRAM_BEGIN
,
(
void
*
)
SDRAM_END
);
rt_kprintf
(
"sram heap, begin: 0x%p, end: 0x%p
\n
"
,
HEAP_BEGIN
,
HEAP_END
);
rt_memheap_init
(
&
system_heap
,
"sram"
,
(
void
*
)
HEAP_BEGIN
,
HEAP_SIZE
);
#else
rt_kprintf
(
"sram heap, begin: 0x%p, end: 0x%p
\n
"
,
HEAP_BEGIN
,
HEAP_END
);
rt_system_heap_init
((
void
*
)
HEAP_BEGIN
,
(
void
*
)
HEAP_END
);
rt_system_heap_init
((
void
*
)
HEAP_BEGIN
,
(
void
*
)
HEAP_END
);
#endif
#endif
...
...
bsp/imxrt1052-evk/drivers/drv_uart.c
浏览文件 @
5f81f8e7
...
...
@@ -21,7 +21,6 @@
#ifdef RT_USING_SERIAL
/* GPIO外设时钟会在LPUART_Init中自动配置, 如果定义了以下宏则不会自动配置 */
#if defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL
#error "Please don't define 'FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL'!"
#endif
...
...
@@ -41,10 +40,10 @@
/* imxrt uart driver */
struct
imxrt_uart
{
LPUART_Type
*
uart_base
;
LPUART_Type
*
uart_base
;
IRQn_Type
irqn
;
struct
rt_serial_device
*
serial
;
struct
rt_serial_device
*
serial
;
char
*
device_name
;
};
...
...
@@ -129,7 +128,8 @@ void LPUART8_IRQHandler(void)
#endif
/* RT_USING_UART8 */
static
const
struct
imxrt_uart
uarts
[]
=
{
static
const
struct
imxrt_uart
uarts
[]
=
{
#ifdef RT_USING_UART1
{
LPUART1
,
...
...
@@ -198,7 +198,7 @@ static const struct imxrt_uart uarts[] = {
};
/* Get debug console frequency. */
uint32_t
BOARD_DebugConsole
SrcFreq
(
void
)
uint32_t
GetUart
SrcFreq
(
void
)
{
uint32_t
freq
;
...
...
@@ -231,7 +231,6 @@ void imxrt_uart_gpio_init(struct imxrt_uart *uart)
if
(
uart
->
uart_base
!=
RT_NULL
)
{
#ifdef RT_USING_UART1
CLOCK_EnableClock
(
kCLOCK_Iomuxc
);
/* iomuxc clock (iomuxc_clk_enable): 0x03u */
IOMUXC_SetPinMux
(
IOMUXC_GPIO_AD_B0_12_LPUART1_TX
,
/* GPIO_AD_B0_12 is configured as LPUART1_TX */
...
...
@@ -261,7 +260,6 @@ void imxrt_uart_gpio_init(struct imxrt_uart *uart)
Hyst. Enable Field: Hysteresis Disabled */
#endif
#ifdef RT_USING_UART2
CLOCK_EnableClock
(
kCLOCK_Iomuxc
);
IOMUXC_SetPinMux
(
IOMUXC_GPIO_AD_B1_02_LPUART2_TX
,
...
...
@@ -272,15 +270,12 @@ void imxrt_uart_gpio_init(struct imxrt_uart *uart)
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_AD_B1_02_LPUART2_TX
,
0x10B0u
);
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_AD_B1_03_LPUART2_RX
,
0x10B0u
);
#endif
#ifdef RT_USING_UART3
CLOCK_EnableClock
(
kCLOCK_Iomuxc
);
IOMUXC_SetPinMux
(
IOMUXC_GPIO_AD_B1_06_LPUART3_TX
,
...
...
@@ -291,13 +286,11 @@ void imxrt_uart_gpio_init(struct imxrt_uart *uart)
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_AD_B1_06_LPUART3_TX
,
0x10B0u
);
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_AD_B1_07_LPUART3_RX
,
0x10B0u
);
#endif
#ifdef RT_USING_UART4
CLOCK_EnableClock
(
kCLOCK_Iomuxc
);
IOMUXC_SetPinMux
(
IOMUXC_GPIO_B1_00_LPUART4_TX
,
...
...
@@ -308,13 +301,11 @@ void imxrt_uart_gpio_init(struct imxrt_uart *uart)
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_B1_00_LPUART4_TX
,
0x10B0u
);
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_B1_01_LPUART4_RX
,
0x10B0u
);
#endif
#ifdef RT_USING_UART5
CLOCK_EnableClock
(
kCLOCK_Iomuxc
);
IOMUXC_SetPinMux
(
IOMUXC_GPIO_B1_12_LPUART5_TX
,
...
...
@@ -325,13 +316,11 @@ void imxrt_uart_gpio_init(struct imxrt_uart *uart)
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_B1_12_LPUART5_TX
,
0x10B0u
);
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_B1_13_LPUART5_RX
,
0x10B0u
);
#endif
#ifdef RT_USING_UART6
CLOCK_EnableClock
(
kCLOCK_Iomuxc
);
IOMUXC_SetPinMux
(
IOMUXC_GPIO_AD_B0_02_LPUART6_TX
,
...
...
@@ -342,13 +331,11 @@ void imxrt_uart_gpio_init(struct imxrt_uart *uart)
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_AD_B0_02_LPUART6_TX
,
0x10B0u
);
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_AD_B0_03_LPUART6_RX
,
0x10B0u
);
#endif
#ifdef RT_USING_UART7
CLOCK_EnableClock
(
kCLOCK_Iomuxc
);
IOMUXC_SetPinMux
(
IOMUXC_GPIO_EMC_31_LPUART7_TX
,
...
...
@@ -359,13 +346,11 @@ void imxrt_uart_gpio_init(struct imxrt_uart *uart)
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_EMC_31_LPUART7_TX
,
0x10B0u
);
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_EMC_32_LPUART7_RX
,
0x10B0u
);
#endif
#ifdef RT_USING_UART8
CLOCK_EnableClock
(
kCLOCK_Iomuxc
);
IOMUXC_SetPinMux
(
IOMUXC_GPIO_AD_B1_10_LPUART8_TX
,
...
...
@@ -376,7 +361,6 @@ void imxrt_uart_gpio_init(struct imxrt_uart *uart)
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_AD_B1_10_LPUART8_TX
,
0x10B0u
);
IOMUXC_SetPinConfig
(
IOMUXC_GPIO_AD_B1_11_LPUART8_RX
,
0x10B0u
);
...
...
@@ -440,8 +424,7 @@ static rt_err_t imxrt_configure(struct rt_serial_device *serial, struct serial_c
config
.
enableTx
=
true
;
config
.
enableRx
=
true
;
LPUART_Init
(
uart
->
uart_base
,
&
config
,
BOARD_DebugConsoleSrcFreq
());
LPUART_Init
(
uart
->
uart_base
,
&
config
,
GetUartSrcFreq
());
return
RT_EOK
;
}
...
...
@@ -481,7 +464,7 @@ static int imxrt_putc(struct rt_serial_device *serial, char ch)
uart
=
(
struct
imxrt_uart
*
)
serial
->
parent
.
user_data
;
LPUART_WriteByte
(
uart
->
uart_base
,
ch
);
while
(
!
(
LPUART_GetStatusFlags
(
uart
->
uart_base
)
&
kLPUART_TxDataRegEmptyFlag
));
while
(
!
(
LPUART_GetStatusFlags
(
uart
->
uart_base
)
&
kLPUART_TxDataRegEmptyFlag
));
return
1
;
}
...
...
@@ -546,16 +529,21 @@ static const struct rt_uart_ops imxrt_uart_ops =
imxrt_getc
,
};
int
imxrt_hw_u
s
art_init
(
void
)
int
imxrt_hw_uart_init
(
void
)
{
struct
serial_configure
config
=
RT_SERIAL_CONFIG_DEFAULT
;
int
i
;
/* Configure UART divider to default */
CLOCK_SetMux
(
kCLOCK_UartMux
,
0
);
/* Set UART source to PLL3 80M */
CLOCK_SetDiv
(
kCLOCK_UartDiv
,
0
);
/* Set UART divider to 1 */
for
(
i
=
0
;
i
<
sizeof
(
uarts
)
/
sizeof
(
uarts
[
0
]);
i
++
)
{
uarts
[
i
].
serial
->
ops
=
&
imxrt_uart_ops
;
uarts
[
i
].
serial
->
config
=
config
;
/* register UART
1
device */
/* register UART device */
rt_hw_serial_register
(
uarts
[
i
].
serial
,
uarts
[
i
].
device_name
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
...
...
@@ -564,6 +552,6 @@ int imxrt_hw_usart_init(void)
return
0
;
}
INIT_BOARD_EXPORT
(
imxrt_hw_u
s
art_init
);
INIT_BOARD_EXPORT
(
imxrt_hw_uart_init
);
#endif
/*RT_USING_SERIAL */
bsp/imxrt1052-evk/drivers/drv_uart.h
浏览文件 @
5f81f8e7
...
...
@@ -12,12 +12,11 @@
* 2017-10-10 Tanek the first version
*/
#ifndef __DRV_U
S
ART_H__
#define __DRV_U
S
ART_H__
#ifndef __DRV_UART_H__
#define __DRV_UART_H__
#include <rthw.h>
#include <rtthread.h>
int
rt_hw_usart_init
(
void
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录