Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
b9c66058
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看板
提交
b9c66058
编写于
1月 11, 2014
作者:
R
RTsien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add operating definitions of UART0 to UART5
上级
05e9233d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
203 addition
and
30 deletion
+203
-30
bsp/beaglebone/drivers/serial.c
bsp/beaglebone/drivers/serial.c
+203
-30
未找到文件。
bsp/beaglebone/drivers/serial.c
浏览文件 @
b9c66058
...
...
@@ -10,6 +10,7 @@
* Change Logs:
* Date Author Notes
* 2013-07-06 Bernard the first version
* 2014-01-11 RTsien add definitions of UART0 to UART5
*/
#include <rthw.h>
...
...
@@ -162,14 +163,18 @@ static const struct rt_uart_ops am33xx_uart_ops =
am33xx_getc
,
};
/* UART
1
device driver structure */
struct
serial_ringbuffer
uart
1_int_rx
;
struct
am33xx_uart
uart
1
=
/* UART device driver structure */
struct
serial_ringbuffer
uart
_int_rx
[
6
]
;
struct
am33xx_uart
uart
[
6
]
=
{
UART0_BASE
,
UART0_INT
,
{
UART0_BASE
,
UART0_INT
},
{
UART1_BASE
,
UART1_INT
},
{
UART2_BASE
,
UART2_INT
},
{
UART3_BASE
,
UART3_INT
},
{
UART4_BASE
,
UART4_INT
},
{
UART5_BASE
,
UART5_INT
}
};
struct
rt_serial_device
serial
1
;
struct
rt_serial_device
serial
[
6
]
;
#define write_reg(base, value) *(int*)(base) = value
#define read_reg(base) *(int*)(base)
...
...
@@ -219,11 +224,46 @@ static void start_uart_clk(void)
;
/* enable uart1 */
#ifdef RT_USING_UART1
CM_PER_UART1_CLKCTRL_REG
(
prcm_base
)
|=
0x2
;
/* wait for uart1 clk */
while
((
CM_PER_UART1_CLKCTRL_REG
(
prcm_base
)
&
(
0x3
<<
16
))
!=
0
)
;
#endif
#ifdef RT_USING_UART2
CM_PER_UART2_CLKCTRL_REG
(
prcm_base
)
|=
0x2
;
/* wait for uart2 clk */
while
((
CM_PER_UART2_CLKCTRL_REG
(
prcm_base
)
&
(
0x3
<<
16
))
!=
0
)
;
#endif
#ifdef RT_USING_UART3
CM_PER_UART3_CLKCTRL_REG
(
prcm_base
)
|=
0x2
;
/* wait for uart3 clk */
while
((
CM_PER_UART3_CLKCTRL_REG
(
prcm_base
)
&
(
0x3
<<
16
))
!=
0
)
;
#endif
#ifdef RT_USING_UART4
CM_PER_UART4_CLKCTRL_REG
(
prcm_base
)
|=
0x2
;
/* wait for uart4 clk */
while
((
CM_PER_UART4_CLKCTRL_REG
(
prcm_base
)
&
(
0x3
<<
16
))
!=
0
)
;
#endif
#ifdef RT_USING_UART5
CM_PER_UART5_CLKCTRL_REG
(
prcm_base
)
|=
0x2
;
/* wait for uart5 clk */
while
((
CM_PER_UART5_CLKCTRL_REG
(
prcm_base
)
&
(
0x3
<<
16
))
!=
0
)
;
#endif
/* Waiting for the L4LS UART clock */
while
(
!
(
CM_PER_L4LS_CLKSTCTRL_REG
(
prcm_base
)
&
(
1
<<
10
)))
;
...
...
@@ -236,44 +276,177 @@ static void config_pinmux(void)
ctlm_base
=
AM33XX_CTLM_REGS
;
/* make sure the pin mux is OK for uart */
#ifdef RT_USING_UART1
REG32
(
ctlm_base
+
0x800
+
0x180
)
=
0x20
;
REG32
(
ctlm_base
+
0x800
+
0x184
)
=
0x00
;
#endif
#ifdef RT_USING_UART2
REG32
(
ctlm_base
+
0x800
+
0x150
)
=
0x20
;
REG32
(
ctlm_base
+
0x800
+
0x154
)
=
0x00
;
#endif
#ifdef RT_USING_UART3
REG32
(
ctlm_base
+
0x800
+
0x164
)
=
0x01
;
#endif
#ifdef RT_USING_UART4
REG32
(
ctlm_base
+
0x800
+
0x070
)
=
0x26
;
REG32
(
ctlm_base
+
0x800
+
0x074
)
=
0x06
;
#endif
#ifdef RT_USING_UART5
REG32
(
ctlm_base
+
0x800
+
0x0C4
)
=
0x24
;
REG32
(
ctlm_base
+
0x800
+
0x0C0
)
=
0x04
;
#endif
}
int
rt_hw_serial_init
(
void
)
{
struct
am33xx_uart
*
uart
;
struct
serial_configure
config
;
uart
=
&
uart1
;
uart
->
base
=
UART1_BASE
;
struct
serial_configure
config
[
6
];
poweron_per_domain
();
start_uart_clk
();
config_pinmux
();
config
.
baud_rate
=
BAUD_RATE_115200
;
config
.
bit_order
=
BIT_ORDER_LSB
;
config
.
data_bits
=
DATA_BITS_8
;
config
.
parity
=
PARITY_NONE
;
config
.
stop_bits
=
STOP_BITS_1
;
config
.
invert
=
NRZ_NORMAL
;
serial1
.
ops
=
&
am33xx_uart_ops
;
serial
1
.
int_rx
=
&
uart1_int_rx
;
serial
1
.
config
=
config
;
#ifdef RT_USING_UART0
config
[
0
].
baud_rate
=
BAUD_RATE_115200
;
config
[
0
].
bit_order
=
BIT_ORDER_LSB
;
config
[
0
].
data_bits
=
DATA_BITS_8
;
config
[
0
].
parity
=
PARITY_NONE
;
config
[
0
].
stop_bits
=
STOP_BITS_1
;
config
[
0
].
invert
=
NRZ_NORMAL
;
serial
[
0
].
ops
=
&
am33xx_uart_ops
;
serial
[
0
].
int_rx
=
&
uart_int_rx
[
0
]
;
serial
[
0
].
config
=
config
[
0
];
/* enable RX interrupt */
UART_IER_REG
(
uart
->
base
)
=
0x01
;
UART_IER_REG
(
uart
[
0
].
base
)
=
0x01
;
/* install ISR */
rt_hw_interrupt_install
(
uart
->
irq
,
am33xx_uart_isr
,
&
serial1
,
"uart1"
);
rt_hw_interrupt_control
(
uart
->
irq
,
0
,
0
);
rt_hw_interrupt_mask
(
uart
->
irq
);
/* register UART1 device */
rt_hw_serial_register
(
&
serial1
,
"uart1"
,
rt_hw_interrupt_install
(
uart
[
0
].
irq
,
am33xx_uart_isr
,
&
serial
[
0
],
"uart0"
);
rt_hw_interrupt_control
(
uart
[
0
].
irq
,
0
,
0
);
rt_hw_interrupt_mask
(
uart
[
0
].
irq
);
/* register UART0 device */
rt_hw_serial_register
(
&
serial
[
0
],
"uart0"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_STREAM
,
&
uart
[
0
]);
#endif
#ifdef RT_USING_UART1
config
[
1
].
baud_rate
=
BAUD_RATE_115200
;
config
[
1
].
bit_order
=
BIT_ORDER_LSB
;
config
[
1
].
data_bits
=
DATA_BITS_8
;
config
[
1
].
parity
=
PARITY_NONE
;
config
[
1
].
stop_bits
=
STOP_BITS_1
;
config
[
1
].
invert
=
NRZ_NORMAL
;
serial
[
1
].
ops
=
&
am33xx_uart_ops
;
serial
[
1
].
int_rx
=
&
uart_int_rx
[
1
];
serial
[
1
].
config
=
config
[
1
];
/* enable RX interrupt */
UART_IER_REG
(
uart
[
1
].
base
)
=
0x01
;
/* install ISR */
rt_hw_interrupt_install
(
uart
[
1
].
irq
,
am33xx_uart_isr
,
&
serial
[
1
],
"uart1"
);
rt_hw_interrupt_control
(
uart
[
1
].
irq
,
0
,
0
);
rt_hw_interrupt_mask
(
uart
[
1
].
irq
);
/* register UART0 device */
rt_hw_serial_register
(
&
serial
[
1
],
"uart1"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_STREAM
,
&
uart
[
1
]);
#endif
#ifdef RT_USING_UART2
config
[
2
].
baud_rate
=
BAUD_RATE_115200
;
config
[
2
].
bit_order
=
BIT_ORDER_LSB
;
config
[
2
].
data_bits
=
DATA_BITS_8
;
config
[
2
].
parity
=
PARITY_NONE
;
config
[
2
].
stop_bits
=
STOP_BITS_1
;
config
[
2
].
invert
=
NRZ_NORMAL
;
serial
[
2
].
ops
=
&
am33xx_uart_ops
;
serial
[
2
].
int_rx
=
&
uart_int_rx
[
2
];
serial
[
2
].
config
=
config
[
2
];
/* enable RX interrupt */
UART_IER_REG
(
uart
[
2
].
base
)
=
0x01
;
/* install ISR */
rt_hw_interrupt_install
(
uart
[
2
].
irq
,
am33xx_uart_isr
,
&
serial
[
2
],
"uart2"
);
rt_hw_interrupt_control
(
uart
[
2
].
irq
,
0
,
0
);
rt_hw_interrupt_mask
(
uart
[
2
].
irq
);
/* register UART2 device */
rt_hw_serial_register
(
&
serial
[
2
],
"uart2"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_STREAM
,
&
uart
[
2
]);
#endif
#ifdef RT_USING_UART3
config
[
3
].
baud_rate
=
BAUD_RATE_115200
;
config
[
3
].
bit_order
=
BIT_ORDER_LSB
;
config
[
3
].
data_bits
=
DATA_BITS_8
;
config
[
3
].
parity
=
PARITY_NONE
;
config
[
3
].
stop_bits
=
STOP_BITS_1
;
config
[
3
].
invert
=
NRZ_NORMAL
;
serial
[
3
].
ops
=
&
am33xx_uart_ops
;
serial
[
3
].
int_rx
=
&
uart_int_rx
[
3
];
serial
[
3
].
config
=
config
[
3
];
/* enable RX interrupt */
UART_IER_REG
(
uart
[
3
].
base
)
=
0x01
;
/* install ISR */
rt_hw_interrupt_install
(
uart
[
3
].
irq
,
am33xx_uart_isr
,
&
serial
[
3
],
"uart3"
);
rt_hw_interrupt_control
(
uart
[
3
].
irq
,
0
,
0
);
rt_hw_interrupt_mask
(
uart
[
3
].
irq
);
/* register UART3 device */
rt_hw_serial_register
(
&
serial
[
3
],
"uart3"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_STREAM
,
&
uart
[
3
]);
#endif
#ifdef RT_USING_UART4
config
[
4
].
baud_rate
=
BAUD_RATE_115200
;
config
[
4
].
bit_order
=
BIT_ORDER_LSB
;
config
[
4
].
data_bits
=
DATA_BITS_8
;
config
[
4
].
parity
=
PARITY_NONE
;
config
[
4
].
stop_bits
=
STOP_BITS_1
;
config
[
4
].
invert
=
NRZ_NORMAL
;
serial
[
4
].
ops
=
&
am33xx_uart_ops
;
serial
[
4
].
int_rx
=
&
uart_int_rx
[
4
];
serial
[
4
].
config
=
config
[
4
];
/* enable RX interrupt */
UART_IER_REG
(
uart
[
4
].
base
)
=
0x01
;
/* install ISR */
rt_hw_interrupt_install
(
uart
[
4
].
irq
,
am33xx_uart_isr
,
&
serial
[
4
],
"uart4"
);
rt_hw_interrupt_control
(
uart
[
4
].
irq
,
0
,
0
);
rt_hw_interrupt_mask
(
uart
[
4
].
irq
);
/* register UART4 device */
rt_hw_serial_register
(
&
serial
[
4
],
"uart4"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_STREAM
,
&
uart
[
4
]);
#endif
#ifdef RT_USING_UART5
config
[
5
].
baud_rate
=
BAUD_RATE_115200
;
config
[
5
].
bit_order
=
BIT_ORDER_LSB
;
config
[
5
].
data_bits
=
DATA_BITS_8
;
config
[
5
].
parity
=
PARITY_NONE
;
config
[
5
].
stop_bits
=
STOP_BITS_1
;
config
[
5
].
invert
=
NRZ_NORMAL
;
serial
[
5
].
ops
=
&
am33xx_uart_ops
;
serial
[
5
].
int_rx
=
&
uart_int_rx
[
5
];
serial
[
5
].
config
=
config
[
5
];
/* enable RX interrupt */
UART_IER_REG
(
uart
[
5
].
base
)
=
0x01
;
/* install ISR */
rt_hw_interrupt_install
(
uart
[
5
].
irq
,
am33xx_uart_isr
,
&
serial
[
5
],
"uart5"
);
rt_hw_interrupt_control
(
uart
[
5
].
irq
,
0
,
0
);
rt_hw_interrupt_mask
(
uart
[
5
].
irq
);
/* register UART4 device */
rt_hw_serial_register
(
&
serial
[
5
],
"uart5"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_STREAM
,
uart
);
&
uart
[
5
]);
#endif
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录