Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
SummerGao.
rt-thread
提交
fc871227
R
rt-thread
项目概览
SummerGao.
/
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,发现更多精彩内容 >>
提交
fc871227
编写于
12月 23, 2021
作者:
mysterywolf
提交者:
Bernard Xiong
12月 27, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[mini4020] format code
上级
923fb0c1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
77 addition
and
77 deletion
+77
-77
bsp/mini4020/drivers/board.c
bsp/mini4020/drivers/board.c
+77
-77
未找到文件。
bsp/mini4020/drivers/board.c
浏览文件 @
fc871227
...
...
@@ -21,14 +21,14 @@
void
rt_hw_serial_putc
(
const
char
c
);
#define UART0
((struct uartport *)UART0_BASE)
#define UART0
((struct uartport *)UART0_BASE)
struct
rt_device
uart0_device
;
struct
serial_int_rx
uart0_int_rx
;
struct
serial_device
uart0
=
{
UART0
,
&
uart0_int_rx
,
RT_NULL
UART0
,
&
uart0_int_rx
,
RT_NULL
};
/**
...
...
@@ -36,12 +36,12 @@ struct serial_device uart0 =
*/
void
rt_timer_handler
(
int
vector
,
void
*
param
)
{
rt_uint32_t
clear_int
;
rt_tick_increase
();
rt_uint32_t
clear_int
;
rt_tick_increase
();
/*Clear timer interrupt*/
clear_int
=
*
(
RP
)
TIMER_T1ISCR
;
*
(
RP
)
TIMER_T1ISCR
=
clear_int
;
/*Clear timer interrupt*/
clear_int
=
*
(
RP
)
TIMER_T1ISCR
;
*
(
RP
)
TIMER_T1ISCR
=
clear_int
;
}
/**
...
...
@@ -49,33 +49,33 @@ void rt_timer_handler(int vector, void *param)
*/
void
rt_serial_handler
(
int
vector
,
void
*
param
)
{
//rt_kprintf("in rt_serial_handler\n");
rt_int32_t
stat
=
*
(
RP
)
UART0_IIR
;
char
c
;
RT_UNUSED
(
c
);
/*Received data*/
if
(((
stat
&
0x0E
)
>>
1
)
==
0x02
)
{
rt_hw_serial_isr
(
&
uart0_device
);
}
else
{
/*clear the timeout interrupt*/
while
(
uart0
.
uart_device
->
lsr
&
USTAT_RCV_READY
)
c
=
uart0
.
uart_device
->
dlbl_fifo
.
rxfifo
;
}
//rt_kprintf("in rt_serial_handler\n");
rt_int32_t
stat
=
*
(
RP
)
UART0_IIR
;
char
c
;
RT_UNUSED
(
c
);
/*Received data*/
if
(((
stat
&
0x0E
)
>>
1
)
==
0x02
)
{
rt_hw_serial_isr
(
&
uart0_device
);
}
else
{
/*clear the timeout interrupt*/
while
(
uart0
.
uart_device
->
lsr
&
USTAT_RCV_READY
)
c
=
uart0
.
uart_device
->
dlbl_fifo
.
rxfifo
;
}
}
/**
/**
* This function will init led on the board
*/
static
void
rt_hw_board_led_init
(
void
)
{
/* PE3 PE4 PE5 for led */
*
(
RP
)
GPIO_PORTE_SEL
|=
0x38
;
/* GPIO */
*
(
RP
)
GPIO_PORTE_DIR
&=
~
0x38
;
/* output*/
*
(
RP
)
GPIO_PORTE_DATA
&=
~
0x38
;
/* low */
...
...
@@ -86,15 +86,15 @@ static void rt_hw_board_led_init(void)
*/
void
rt_hw_timer_init
(
void
)
{
/*Set timer1*/
*
(
RP
)
TIMER_T1LCR
=
880000
;
*
(
RP
)
TIMER_T1CR
=
0x06
;
/*Set timer1*/
*
(
RP
)
TIMER_T1LCR
=
880000
;
*
(
RP
)
TIMER_T1CR
=
0x06
;
rt_hw_interrupt_install
(
INTSRC_TIMER1
,
rt_timer_handler
,
RT_NULL
,
"tick"
);
rt_hw_interrupt_umask
(
INTSRC_TIMER1
);
rt_hw_interrupt_install
(
INTSRC_TIMER1
,
rt_timer_handler
,
RT_NULL
,
"tick"
);
rt_hw_interrupt_umask
(
INTSRC_TIMER1
);
/*Enable timer1*/
*
(
RP
)
TIMER_T1CR
|=
0x01
;
/*Enable timer1*/
*
(
RP
)
TIMER_T1CR
|=
0x01
;
}
/**
...
...
@@ -102,55 +102,55 @@ void rt_hw_timer_init(void)
*/
void
rt_hw_uart_init
(
void
)
{
const
rt_int32_t
sysclk
=
72000000
;
/*Set data bit:8*/
*
(
RP
)(
UART0_LCR
)
=
0x83
;
/*Set baud rate high*/
*
(
RP
)(
UART0_DLBH
)
=
(
sysclk
/
16
/
115200
)
>>
8
;
/*Set baud rate low*/
*
(
RP
)(
UART0_DLBL
)
=
(
sysclk
/
16
/
115200
)
&
0xff
;
*
(
RP
)(
UART0_LCR
)
=
0x83
&
(
~
(
0x1
<<
7
));
/*Set trigger level*/
*
(
RP
)(
UART0_FCR
)
=
0x0
;
*
(
RP
)(
UART0_IER
)
=
0x0
;
/*Enable rx interrupt*/
*
(
RP
)(
UART0_IER
)
|=
0x01
;
/*Disable tx interrupt*/
*
(
RP
)(
UART0_IER
)
&=
~
(
0x1
<<
1
);
rt_hw_interrupt_install
(
INTSRC_UART0
,
rt_serial_handler
,
RT_NULL
,
"UART0"
);
rt_hw_interrupt_umask
(
INTSRC_UART0
);
/* register uart0 */
rt_hw_serial_register
(
&
uart0_device
,
"uart0"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_STREAM
,
&
uart0
);
const
rt_int32_t
sysclk
=
72000000
;
/*Set data bit:8*/
*
(
RP
)(
UART0_LCR
)
=
0x83
;
/*Set baud rate high*/
*
(
RP
)(
UART0_DLBH
)
=
(
sysclk
/
16
/
115200
)
>>
8
;
/*Set baud rate low*/
*
(
RP
)(
UART0_DLBL
)
=
(
sysclk
/
16
/
115200
)
&
0xff
;
*
(
RP
)(
UART0_LCR
)
=
0x83
&
(
~
(
0x1
<<
7
));
/*Set trigger level*/
*
(
RP
)(
UART0_FCR
)
=
0x0
;
*
(
RP
)(
UART0_IER
)
=
0x0
;
/*Enable rx interrupt*/
*
(
RP
)(
UART0_IER
)
|=
0x01
;
/*Disable tx interrupt*/
*
(
RP
)(
UART0_IER
)
&=
~
(
0x1
<<
1
);
rt_hw_interrupt_install
(
INTSRC_UART0
,
rt_serial_handler
,
RT_NULL
,
"UART0"
);
rt_hw_interrupt_umask
(
INTSRC_UART0
);
/* register uart0 */
rt_hw_serial_register
(
&
uart0_device
,
"uart0"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_STREAM
,
&
uart0
);
}
void
rt_hw_board_init
(
void
)
{
/* initialize uart */
rt_hw_uart_init
();
//
rt_hw_board_led_init();
rt_hw_timer_init
();
/* initialize uart */
rt_hw_uart_init
();
//
rt_hw_board_led_init();
rt_hw_timer_init
();
}
/* write one character to serial, must not trigger interrupt */
void
rt_hw_serial_putc
(
const
char
c
)
{
/*
to be polite with serial console add a line feed
to the carriage return character
*/
if
(
c
==
'\n'
)
rt_hw_serial_putc
(
'\r'
);
/*
to be polite with serial console add a line feed
to the carriage return character
*/
if
(
c
==
'\n'
)
rt_hw_serial_putc
(
'\r'
);
while
(
!
((
*
(
RP
)
UART0_LSR
)
&
0x40
));
while
(
!
((
*
(
RP
)
UART0_LSR
)
&
0x40
));
*
(
RP
)(
UART0_BASE
)
=
c
;
*
(
RP
)(
UART0_BASE
)
=
c
;
}
/**
...
...
@@ -160,8 +160,8 @@ void rt_hw_serial_putc(const char c)
*/
void
rt_hw_console_output
(
const
char
*
str
)
{
while
(
*
str
)
{
rt_hw_serial_putc
(
*
str
++
);
}
while
(
*
str
)
{
rt_hw_serial_putc
(
*
str
++
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录