Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
3abf1fd5
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,发现更多精彩内容 >>
提交
3abf1fd5
编写于
11月 29, 2014
作者:
B
Bright Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add uart driver and finsh function
上级
d50ab16e
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
278 addition
and
16 deletion
+278
-16
bsp/nuvoton_m05x/Libraries/CMSIS/Nuvoton/M051Series/Source/ARM/startup_M051Series.s
.../CMSIS/Nuvoton/M051Series/Source/ARM/startup_M051Series.s
+1
-1
bsp/nuvoton_m05x/applications/application.c
bsp/nuvoton_m05x/applications/application.c
+1
-1
bsp/nuvoton_m05x/drivers/board.c
bsp/nuvoton_m05x/drivers/board.c
+29
-3
bsp/nuvoton_m05x/drivers/board.h
bsp/nuvoton_m05x/drivers/board.h
+2
-0
bsp/nuvoton_m05x/drivers/usart.c
bsp/nuvoton_m05x/drivers/usart.c
+133
-0
bsp/nuvoton_m05x/drivers/usart.h
bsp/nuvoton_m05x/drivers/usart.h
+26
-0
bsp/nuvoton_m05x/project.uvprojx
bsp/nuvoton_m05x/project.uvprojx
+79
-4
bsp/nuvoton_m05x/rtconfig.h
bsp/nuvoton_m05x/rtconfig.h
+7
-7
未找到文件。
bsp/nuvoton_m05x/Libraries/CMSIS/Nuvoton/M051Series/Source/ARM/startup_M051Series.s
浏览文件 @
3abf1fd5
...
...
@@ -10,7 +10,7 @@
; *
; ******************************************************************************/
Stack_Size
EQU
0x00000
2
00
Stack_Size
EQU
0x00000
1
00
AREA
STACK
,
NOINIT
,
READWRITE
,
ALIGN
=
3
Stack_Mem
SPACE
Stack_Size
...
...
bsp/nuvoton_m05x/applications/application.c
浏览文件 @
3abf1fd5
...
...
@@ -56,7 +56,7 @@ static void rt_init_thread_entry(void* parameter)
/* Create led thread */
led_thread
=
rt_thread_create
(
"led"
,
led_thread_entry
,
RT_NULL
,
256
,
20
,
20
);
128
,
20
,
20
);
if
(
led_thread
!=
RT_NULL
)
rt_thread_startup
(
led_thread
);
}
...
...
bsp/nuvoton_m05x/drivers/board.c
浏览文件 @
3abf1fd5
...
...
@@ -14,9 +14,8 @@
#include <rthw.h>
#include <rtthread.h>
#include "board.h"
#include "usart.h"
/* RT_USING_COMPONENTS_INIT */
#ifdef RT_USING_COMPONENTS_INIT
#include <components.h>
...
...
@@ -44,7 +43,7 @@ void NVIC_Configuration(void)
* @param nCount: specifies the delay time length.
* @retval None
*/
static
void
D
elay
(
__IO
uint32_t
nCount
)
static
void
d
elay
(
__IO
uint32_t
nCount
)
{
/* Decrement nCount value */
while
(
nCount
!=
0
)
...
...
@@ -53,6 +52,30 @@ static void Delay(__IO uint32_t nCount)
}
}
static
void
rt_hw_system_init
(
void
)
{
/*---------------------------------------------------------------------------------------------------------*/
/* Init System Clock */
/*---------------------------------------------------------------------------------------------------------*/
SYS_UnlockReg
();
/* Enable Internal RC 22.1184MHz clock */
CLK_EnableXtalRC
(
CLK_PWRCON_OSC22M_EN_Msk
);
/* Waiting for Internal RC clock ready */
CLK_WaitClockReady
(
CLK_CLKSTATUS_OSC22M_STB_Msk
);
/* Switch HCLK clock source to Internal RC and HCLK source divide 1 */
CLK_SetHCLK
(
CLK_CLKSEL0_HCLK_S_HIRC
,
CLK_CLKDIV_HCLK
(
1
));
/* Set core clock as PLL_CLOCK from PLL */
CLK_SetCoreClock
(
BOARD_PLL_CLOCK
);
/* Set SysTick clock source to HCLK source divide 2 */
CLK_SetSysTickClockSrc
(
CLK_CLKSEL0_STCLK_S_HCLK_DIV2
);
SYS_LockReg
();
}
/**
* This is the timer interrupt service routine.
*
...
...
@@ -75,10 +98,13 @@ void rt_hw_board_init()
/* NVIC Configuration */
NVIC_Configuration
();
/* Configure the system clock */
rt_hw_system_init
();
/* Configure the SysTick */
SysTick_Config
(
SystemCoreClock
/
RT_TICK_PER_SECOND
);
/* Initial usart deriver, and set console device */
rt_hw_usart_init
();
#ifdef RT_USING_CONSOLE
rt_console_set_device
(
RT_CONSOLE_DEVICE_NAME
);
#endif
...
...
bsp/nuvoton_m05x/drivers/board.h
浏览文件 @
3abf1fd5
...
...
@@ -18,6 +18,8 @@
#include "M051Series.h"
#define BOARD_PLL_CLOCK 50000000
/* board configuration */
// <o> Internal SRAM memory size[Kbytes]
// <i>Default: 64
...
...
bsp/nuvoton_m05x/drivers/usart.c
0 → 100644
浏览文件 @
3abf1fd5
/*
* File : usart.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006-2014, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2014-11-29 Bright the first version
*/
#include "M051Series.h"
#include <rtdevice.h>
#include "usart.h"
static
rt_err_t
m05x_configure
(
struct
rt_serial_device
*
serial
,
struct
serial_configure
*
cfg
)
{
UART_T
*
uart
;
uart
=
(
UART_T
*
)
serial
->
parent
.
user_data
;
#if defined(RT_USING_UART0)
if
(
uart
==
UART0
)
{
/* Enable UART module clock */
CLK_EnableModuleClock
(
UART0_MODULE
);
/* Select UART module clock source */
CLK_SetModuleClock
(
UART0_MODULE
,
CLK_CLKSEL1_UART_S_PLL
,
CLK_CLKDIV_UART
(
1
));
/* Set P3 multi-function pins for UART0 RXD and TXD */
SYS
->
P3_MFP
&=
~
(
SYS_MFP_P30_Msk
|
SYS_MFP_P31_Msk
);
SYS
->
P3_MFP
|=
(
SYS_MFP_P30_RXD0
|
SYS_MFP_P31_TXD0
);
/* Reset IP */
SYS_ResetModule
(
UART0_RST
);
/* Configure UART0 and set UART0 Baudrate */
UART_Open
(
UART0
,
cfg
->
baud_rate
);
/* Enable Interrupt */
UART_EnableInt
(
UART0
,
UART_IER_RDA_IEN_Msk
);
}
#endif
/* RT_USING_UART0 */
#if defined(RT_USING_UART1)
#endif
/* RT_USING_UART1 */
return
RT_EOK
;
}
static
rt_err_t
m05x_control
(
struct
rt_serial_device
*
serial
,
int
cmd
,
void
*
arg
)
{
UART_T
*
uart
;
uart
=
(
UART_T
*
)
serial
->
parent
.
user_data
;
switch
(
cmd
)
{
case
RT_DEVICE_CTRL_CLR_INT
:
{
/* Disable Interrupt */
UART_DisableInt
(
uart
,
UART_IER_RDA_IEN_Msk
);
break
;
}
case
RT_DEVICE_CTRL_SET_INT
:
{
UART_EnableInt
(
uart
,
UART_IER_RDA_IEN_Msk
);
break
;
}
}
return
RT_EOK
;
}
static
int
m05x_putc
(
struct
rt_serial_device
*
serial
,
char
c
)
{
UART_T
*
uart
;
uart
=
(
UART_T
*
)
serial
->
parent
.
user_data
;
if
(
UART_IS_TX_FULL
(
uart
))
{
UART_WAIT_TX_EMPTY
(
uart
);
}
UART_WRITE
(
uart
,
c
);
return
1
;
}
static
int
m05x_getc
(
struct
rt_serial_device
*
serial
)
{
int
ch
=
-
1
;
UART_T
*
uart
;
uart
=
(
UART_T
*
)
serial
->
parent
.
user_data
;
if
(
UART_IS_RX_READY
(
uart
))
ch
=
UART_READ
(
uart
);
return
ch
;
}
static
const
struct
rt_uart_ops
m05x_uart_ops
=
{
m05x_configure
,
m05x_control
,
m05x_putc
,
m05x_getc
,
};
#if defined(RT_USING_UART0)
struct
rt_serial_device
serial0
;
void
UART0_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
if
(
UART_IS_RX_READY
(
UART0
))
{
rt_hw_serial_isr
(
&
serial0
,
RT_SERIAL_EVENT_RX_IND
);
}
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
/* RT_USING_UART0 */
void
rt_hw_usart_init
(
void
)
{
#ifdef RT_USING_UART0
struct
serial_configure
config
=
RT_SERIAL_CONFIG_DEFAULT
;
config
.
baud_rate
=
BAUD_RATE_115200
;
serial0
.
ops
=
&
m05x_uart_ops
;
serial0
.
config
=
config
;
/* register UART0 device */
rt_hw_serial_register
(
&
serial0
,
"uart0"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
,
UART0
);
#endif
/* RT_USING_UART0 */
}
bsp/nuvoton_m05x/drivers/usart.h
0 → 100644
浏览文件 @
3abf1fd5
/*
* File : usart.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006-2014, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
* Change Logs:
* Date Author Notes
* 2014-11-29 Bright the first version
*/
#ifndef __USART_H__
#define __USART_H__
#include <rthw.h>
#include <rtthread.h>
#define RT_USING_UART0
//#define RT_USING_UART1
void
rt_hw_usart_init
(
void
);
#endif
bsp/nuvoton_m05x/project.uvprojx
浏览文件 @
3abf1fd5
...
...
@@ -207,8 +207,8 @@
<AdsLsun>
1
</AdsLsun>
<AdsLven>
1
</AdsLven>
<AdsLsxf>
1
</AdsLsxf>
<RvctClst>
1
</RvctClst>
<GenPPlst>
1
</GenPPlst>
<RvctClst>
0
</RvctClst>
<GenPPlst>
0
</GenPPlst>
<AdsCpuType>
"Cortex-M0"
</AdsCpuType>
<RvctDeviceName></RvctDeviceName>
<mOS>
0
</mOS>
...
...
@@ -363,7 +363,7 @@
<MiscControls></MiscControls>
<Define>
INIT_SYSCLK_AT_BOOTING
</Define>
<Undefine></Undefine>
<IncludePath>
.;..\..\components\drivers\include;..\..\components\init;..\..\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m0;Libraries\CMSIS\Include;Libraries\CMSIS\Nuvoton\M051Series\Include;Libraries\StdDriver\inc;applications;drivers
</IncludePath>
<IncludePath>
.;..\..\components\drivers\include;..\..\components\
finsh;..\..\components\
init;..\..\include;..\..\libcpu\arm\common;..\..\libcpu\arm\cortex-m0;Libraries\CMSIS\Include;Libraries\CMSIS\Nuvoton\M051Series\Include;Libraries\StdDriver\inc;applications;drivers
</IncludePath>
</VariousControls>
</Cads>
<Aads>
...
...
@@ -396,7 +396,7 @@
<ScatterFile>
.\nuvoton_m05x.sct
</ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc>
--keep __rt_init*
</Misc>
<Misc>
--keep __
fsym_* --keep __vsym_* --keep __
rt_init*
</Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
...
...
@@ -431,6 +431,11 @@
<FileType>
1
</FileType>
<FilePath>
drivers\led.c
</FilePath>
</File>
<File>
<FileName>
usart.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
drivers\usart.c
</FilePath>
</File>
</Files>
</Group>
<Group>
...
...
@@ -648,6 +653,76 @@
</File>
</Files>
</Group>
<Group>
<GroupName>
finsh
</GroupName>
<Files>
<File>
<FileName>
shell.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\shell.c
</FilePath>
</File>
<File>
<FileName>
symbol.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\symbol.c
</FilePath>
</File>
<File>
<FileName>
cmd.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\cmd.c
</FilePath>
</File>
<File>
<FileName>
finsh_compiler.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_compiler.c
</FilePath>
</File>
<File>
<FileName>
finsh_error.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_error.c
</FilePath>
</File>
<File>
<FileName>
finsh_heap.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_heap.c
</FilePath>
</File>
<File>
<FileName>
finsh_init.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_init.c
</FilePath>
</File>
<File>
<FileName>
finsh_node.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_node.c
</FilePath>
</File>
<File>
<FileName>
finsh_ops.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_ops.c
</FilePath>
</File>
<File>
<FileName>
finsh_parser.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_parser.c
</FilePath>
</File>
<File>
<FileName>
finsh_var.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_var.c
</FilePath>
</File>
<File>
<FileName>
finsh_vm.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_vm.c
</FilePath>
</File>
<File>
<FileName>
finsh_token.c
</FileName>
<FileType>
1
</FileType>
<FilePath>
..\..\components\finsh\finsh_token.c
</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>
Components
</GroupName>
<Files>
...
...
bsp/nuvoton_m05x/rtconfig.h
浏览文件 @
3abf1fd5
...
...
@@ -10,7 +10,7 @@
/* PRIORITY_MAX */
#define RT_THREAD_PRIORITY_MAX 32
#define IDLE_THREAD_STACK_SIZE 128
/* Tick per Second */
#define RT_TICK_PER_SECOND 100
...
...
@@ -54,7 +54,6 @@
/* Using Small MM */
#define RT_USING_SMALL_MEM
#define RT_USING_TINY_SIZE
// <bool name="RT_USING_COMPONENTS_INIT" description="Using RT-Thread components initialization" default="true" />
#define RT_USING_COMPONENTS_INIT
...
...
@@ -68,19 +67,20 @@
#define RT_USING_SERIAL
/* SECTION: Console options */
//
#define RT_USING_CONSOLE
#define RT_USING_CONSOLE
/* the buffer size of console*/
#define RT_CONSOLEBUF_SIZE
128
#define RT_CONSOLEBUF_SIZE
64
// <string name="RT_CONSOLE_DEVICE_NAME" description="The device name for console" default="uart1" />
#define RT_CONSOLE_DEVICE_NAME "uart
1
"
#define RT_CONSOLE_DEVICE_NAME "uart
0
"
/* SECTION: finsh, a C-Express shell */
//
#define RT_USING_FINSH
#define RT_USING_FINSH
/* configure finsh parameters */
#define FINSH_THREAD_PRIORITY 25
#define FINSH_THREAD_STACK_SIZE 1024
#define FINSH_THREAD_STACK_SIZE 512
#define FINSH_USING_HISTORY 0
#define FINSH_HISTORY_LINES 1
/* Using symbol table */
#define FINSH_USING_SYMTAB
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录