Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
人间散章
rt-thread
提交
6ca82399
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,发现更多精彩内容 >>
提交
6ca82399
编写于
3月 22, 2021
作者:
mysterywolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[mb9bf568r] 手动-自动格式整理
上级
06118227
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
77 addition
and
162 deletion
+77
-162
bsp/mb9bf568r/applications/application.c
bsp/mb9bf568r/applications/application.c
+4
-8
bsp/mb9bf568r/applications/demo.c
bsp/mb9bf568r/applications/demo.c
+0
-69
bsp/mb9bf568r/applications/startup.c
bsp/mb9bf568r/applications/startup.c
+3
-7
bsp/mb9bf568r/drivers/board.c
bsp/mb9bf568r/drivers/board.c
+3
-7
bsp/mb9bf568r/drivers/board.h
bsp/mb9bf568r/drivers/board.h
+2
-6
bsp/mb9bf568r/drivers/led.c
bsp/mb9bf568r/drivers/led.c
+17
-9
bsp/mb9bf568r/drivers/mcu.h
bsp/mb9bf568r/drivers/mcu.h
+4
-4
bsp/mb9bf568r/drivers/serial.c
bsp/mb9bf568r/drivers/serial.c
+25
-29
bsp/mb9bf568r/drivers/serial.h
bsp/mb9bf568r/drivers/serial.h
+19
-23
未找到文件。
bsp/mb9bf568r/applications/application.c
浏览文件 @
6ca82399
/*
* File : application.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2011, RT-Thread Development Team
* Copyright (c) 2006-2021, 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
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
...
...
@@ -28,7 +24,7 @@ void rt_init_thread_entry(void *parameter)
#endif
//finsh_system_init();
//finsh_system_init();
finsh_set_device
(
RT_CONSOLE_DEVICE_NAME
);
...
...
@@ -37,7 +33,7 @@ void rt_init_thread_entry(void *parameter)
extern
void
rt_led_hw_init
(
void
);
rt_led_hw_init
();
}
{
{
extern
int
demo_init
(
void
);
demo_init
();
}
...
...
bsp/mb9bf568r/applications/demo.c
已删除
100644 → 0
浏览文件 @
06118227
/*
此demo用于演示动态线程创建
*/
#include <rtthread.h>
#include "board.h"
#ifdef RT_USING_FINSH
#include <finsh.h>
#include <shell.h>
#endif
static
rt_thread_t
tid1
=
RT_NULL
;
static
rt_thread_t
tid2
=
RT_NULL
;
static
void
thread1_entry
(
void
*
parameter
)
{
rt_uint32_t
count
=
0
;
rt_kprintf
(
"thread1 dynamicly created ok
\n
"
);
while
(
1
)
{
rt_kprintf
(
"thread1 count: %d
\n
"
,
count
++
);
rt_thread_delay
(
RT_TICK_PER_SECOND
);
}
}
static
void
thread2_entry
(
void
*
parameter
)
{
rt_uint32_t
count
=
0
;
rt_kprintf
(
"thread2 dynamicly created ok
\n
"
);
while
(
1
)
{
if
(
count
==
3
)
break
;
rt_kprintf
(
"thread2 count: %d
\n
"
,
count
++
);
rt_thread_delay
(
RT_TICK_PER_SECOND
);
}
rt_thread_delay
(
RT_TICK_PER_SECOND
*
4
);
rt_thread_delete
(
tid1
);
rt_kprintf
(
"thread1 deleted ok
\n
"
);
}
int
demo_init
(
void
)
{
tid1
=
rt_thread_create
(
"thread1"
,
thread1_entry
,
RT_NULL
,
512
,
6
,
10
);
if
(
tid1
!=
RT_NULL
)
rt_thread_startup
(
tid1
);
tid2
=
rt_thread_create
(
"thread2"
,
thread2_entry
,
RT_NULL
,
512
,
6
,
10
);
if
(
tid2
!=
RT_NULL
)
rt_thread_startup
(
tid2
);
return
0
;
}
bsp/mb9bf568r/applications/startup.c
浏览文件 @
6ca82399
/*
* File : startup.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2011, RT-Thread Development Team
* Copyright (c) 2006-2021, 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
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
...
...
@@ -43,7 +39,7 @@ void rtthread_startup(void)
/* show version */
rt_show_version
();
/* init timer system */
rt_system_timer_init
();
...
...
bsp/mb9bf568r/drivers/board.c
浏览文件 @
6ca82399
/*
* File : board.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009 - 2011 RT-Thread Develop Team
* Copyright (c) 2006-2021, 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
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
...
...
@@ -64,7 +60,7 @@ rt_uint32_t rt_hw_tick_get_microsecond(void)
rt_tick_t
tick
;
rt_uint32_t
value
;
#define TICK_US
(1000000/RT_TICK_PER_SECOND)
#define TICK_US
(1000000/RT_TICK_PER_SECOND)
tick
=
rt_tick_get
();
value
=
tick
*
TICK_US
+
(
SysTick
->
LOAD
-
SysTick
->
VAL
)
*
TICK_US
/
SysTick
->
LOAD
;
...
...
bsp/mb9bf568r/drivers/board.h
浏览文件 @
6ca82399
/*
* File : board.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2009, RT-Thread Development Team
* Copyright (c) 2006-2021, 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
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
...
...
bsp/mb9bf568r/drivers/led.c
浏览文件 @
6ca82399
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
*/
#include <rtthread.h>
#include "board.h"
...
...
@@ -28,9 +36,9 @@ static rt_err_t rt_led_init (rt_device_t dev)
/* led0-1-2 : P27-P38-PE0 */
FM4_GPIO
->
PFR2
&=
~
((
1
<<
7
)
);
/* set P27 fuction is GPIO. */
FM4_GPIO
->
DDR2
|=
(
1
<<
7
)
;
/* set P27 output. */
FM4_GPIO
->
PFR3
&=
~
((
1
<<
8
)
);
/* set P38 fuction is GPIO. */
FM4_GPIO
->
PFR3
&=
~
((
1
<<
8
)
);
/* set P38 fuction is GPIO. */
FM4_GPIO
->
DDR3
|=
(
1
<<
8
)
;
/* set P38 output. */
FM4_GPIO
->
PFRE
&=
~
((
1
<<
0
)
);
/* set PE0 fuction is GPIO. */
FM4_GPIO
->
PFRE
&=
~
((
1
<<
0
)
);
/* set PE0 fuction is GPIO. */
FM4_GPIO
->
DDRE
|=
(
1
<<
0
)
;
/* set PE0 output. */
/* LED0 */
...
...
@@ -127,16 +135,16 @@ static rt_err_t rt_led_control (rt_device_t dev, int cmd, void *args)
void
rt_led_hw_init
(
void
)
{
fm4_led
.
parent
.
type
=
RT_Device_Class_Char
;
fm4_led
.
parent
.
type
=
RT_Device_Class_Char
;
fm4_led
.
parent
.
rx_indicate
=
RT_NULL
;
fm4_led
.
parent
.
tx_complete
=
RT_NULL
;
fm4_led
.
parent
.
init
=
rt_led_init
;
fm4_led
.
parent
.
open
=
rt_led_open
;
fm4_led
.
parent
.
close
=
rt_led_close
;
fm4_led
.
parent
.
init
=
rt_led_init
;
fm4_led
.
parent
.
open
=
rt_led_open
;
fm4_led
.
parent
.
close
=
rt_led_close
;
fm4_led
.
parent
.
read
=
rt_led_read
;
fm4_led
.
parent
.
write
=
rt_led_write
;
fm4_led
.
parent
.
control
=
rt_led_control
;
fm4_led
.
parent
.
user_data
=
RT_NULL
;
fm4_led
.
parent
.
write
=
rt_led_write
;
fm4_led
.
parent
.
control
=
rt_led_control
;
fm4_led
.
parent
.
user_data
=
RT_NULL
;
/* register a character device */
rt_device_register
(
&
fm4_led
.
parent
,
"led"
,
RT_DEVICE_FLAG_RDWR
);
...
...
bsp/mb9bf568r/drivers/mcu.h
浏览文件 @
6ca82399
...
...
@@ -41,8 +41,8 @@
**
******************************************************************************/
#define PDL_INT_TYPE_C
1
#define PDL_INT_TYPE_A
2
#define PDL_INT_TYPE_C
1
#define PDL_INT_TYPE_A
2
#define PDL_MCU_INT_TYPE PDL_INT_TYPE_A
...
...
@@ -50,7 +50,7 @@
******************************************************************************
** \brief MCU header file include
**
******************************************************************************/
******************************************************************************/
#ifndef _MB9B560R_H_
#include "mb9b560r.h"
#endif
...
...
@@ -59,7 +59,7 @@
******************************************************************************
** \brief MCU system start-up header file include
**
******************************************************************************/
******************************************************************************/
#ifndef _SYSTEM_MB9ABXXX_H_
#include "system_mb9bf56xr.h"
#endif
bsp/mb9bf568r/drivers/serial.c
浏览文件 @
6ca82399
/*
* File : serial.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
* Copyright (c) 2006-2021, 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
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
...
...
@@ -258,16 +254,16 @@ rt_err_t rt_hw_serial_register(rt_device_t device, const char* name,
{
RT_ASSERT
(
device
!=
RT_NULL
);
device
->
type
=
RT_Device_Class_Char
;
device
->
type
=
RT_Device_Class_Char
;
device
->
rx_indicate
=
RT_NULL
;
device
->
tx_complete
=
RT_NULL
;
device
->
init
=
rt_serial_init
;
device
->
open
=
rt_serial_open
;
device
->
close
=
rt_serial_close
;
device
->
read
=
rt_serial_read
;
device
->
write
=
rt_serial_write
;
device
->
control
=
rt_serial_control
;
device
->
user_data
=
serial
;
device
->
init
=
rt_serial_init
;
device
->
open
=
rt_serial_open
;
device
->
close
=
rt_serial_close
;
device
->
read
=
rt_serial_read
;
device
->
write
=
rt_serial_write
;
device
->
control
=
rt_serial_control
;
device
->
user_data
=
serial
;
/* register a character device */
return
rt_device_register
(
device
,
name
,
RT_DEVICE_FLAG_RDWR
|
flag
);
...
...
@@ -303,7 +299,7 @@ void rt_hw_serial_isr(rt_device_t device)
#ifdef RT_USING_UART0
/* UART0 device driver structure */
#define UART0
FM4_MFS0
#define UART0
FM4_MFS0
struct
serial_int_rx
uart0_int_rx
;
struct
serial_device
uart0
=
{
...
...
@@ -316,8 +312,8 @@ struct serial_device uart0 =
struct
rt_device
uart0_device
;
void
MFS0_RX_IRQHandler
(
void
)
{
/* enter interrupt */
{
/* enter interrupt */
rt_interrupt_enter
();
rt_hw_serial_isr
(
&
uart0_device
);
/* leave interrupt */
...
...
@@ -330,28 +326,28 @@ void MFS0_RX_IRQHandler(void)
void
rt_hw_serial_init
(
void
)
{
uint32_t
APB2_clock
=
(
SystemCoreClock
>>
(
APBC2_PSR_Val
&
0x03
));
uint32_t
APB2_clock
=
(
SystemCoreClock
>>
(
APBC2_PSR_Val
&
0x03
));
#ifdef RT_USING_UART0
// Initialize ports for MFS0
FM4_GPIO
->
PFR2
=
0x06u
;
// P21>SIN0_0, P22>SOT0_0
FM4_GPIO
->
EPFR07
&=
0xFFFFFF0Ful
;
FM4_GPIO
->
EPFR07
|=
0x00000040ul
;
// Initialize MFS to UART asynchronous mode
uart0
.
uart_device
->
SMR
=
SMR_MD_UART
|
SMR_SOE
;;
FM4_GPIO
->
PFR2
=
0x06u
;
// P21>SIN0_0, P22>SOT0_0
FM4_GPIO
->
EPFR07
&=
0xFFFFFF0Ful
;
FM4_GPIO
->
EPFR07
|=
0x00000040ul
;
// Initialize MFS to UART asynchronous mode
uart0
.
uart_device
->
SMR
=
SMR_MD_UART
|
SMR_SOE
;;
uart0
.
uart_device
->
BGR
=
(
APB2_clock
+
(
BPS
/
2
))
/
BPS
-
1
;
/* round */
uart0
.
uart_device
->
ESCR
=
ESCR_DATABITS_8
;
uart0
.
uart_device
->
SCR
=
SCR_RXE
|
SCR_TXE
|
SCR_RIE
;
/* register UART0 device */
rt_hw_serial_register
(
&
uart0_device
,
"uart0"
,
RT_DEVICE_FLAG_RDWR
|
RT_DEVICE_FLAG_INT_RX
|
RT_DEVICE_FLAG_STREAM
,
&
uart0
);
#endif
/**< #ifdef RT_USING_UART0 */
}
...
...
bsp/mb9bf568r/drivers/serial.h
浏览文件 @
6ca82399
/*
* File : serial.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
* Copyright (c) 2006-2021, 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
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2006-03-13 Bernard first version
* 2011-05-15 lgnq modified according bernard's implementaion.
* 2011-05-15 lgnq modified according bernard's implementaion.
*/
#ifndef __RT_HW_SERIAL_H__
...
...
@@ -57,21 +53,21 @@
#define ESCR_DATABITS_7 0x03U
#define ESCR_DATABITS_9 0x04U
#define BPS
115200
/* serial baudrate */
#define BPS
115200
/* serial baudrate */
#define UART_RX_BUFFER_SIZE
128
#define UART_TX_BUFFER_SIZE
128
#define UART_RX_BUFFER_SIZE
128
#define UART_TX_BUFFER_SIZE
128
struct
serial_int_rx
{
rt_uint8_t
rx_buffer
[
UART_RX_BUFFER_SIZE
];
rt_uint32_t
read_index
,
save_index
;
rt_uint8_t
rx_buffer
[
UART_RX_BUFFER_SIZE
];
rt_uint32_t
read_index
,
save_index
;
};
struct
serial_int_tx
{
rt_uint8_t
tx_buffer
[
UART_TX_BUFFER_SIZE
];
rt_uint32_t
write_index
,
save_index
;
rt_uint8_t
tx_buffer
[
UART_TX_BUFFER_SIZE
];
rt_uint32_t
write_index
,
save_index
;
};
/*
...
...
@@ -83,15 +79,15 @@ struct serial_int_tx
struct
serial_device
{
FM4_MFS_TypeDef
*
uart_device
;
/* irq number */
IRQn_Type
rx_irq
;
IRQn_Type
tx_irq
;
/* rx structure */
struct
serial_int_rx
*
int_rx
;
/* tx structure */
struct
serial_int_tx
*
int_tx
;
FM4_MFS_TypeDef
*
uart_device
;
/* irq number */
IRQn_Type
rx_irq
;
IRQn_Type
tx_irq
;
/* rx structure */
struct
serial_int_rx
*
int_rx
;
/* tx structure */
struct
serial_int_tx
*
int_tx
;
};
void
rt_hw_serial_isr
(
rt_device_t
device
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录