Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
宁楠萍
rt-thread
提交
5f911c6d
R
rt-thread
项目概览
宁楠萍
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f911c6d
编写于
10月 24, 2020
作者:
T
thread-liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[update] mp1 drivers and add rs485 driver.
上级
3ff0c07b
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
167 addition
and
11 deletion
+167
-11
bsp/stm32/stm32mp157a-st-discovery/board/Kconfig
bsp/stm32/stm32mp157a-st-discovery/board/Kconfig
+17
-6
bsp/stm32/stm32mp157a-st-discovery/board/SConscript
bsp/stm32/stm32mp157a-st-discovery/board/SConscript
+3
-0
bsp/stm32/stm32mp157a-st-discovery/board/ports/OpenAMP/drv_openamp.c
...tm32mp157a-st-discovery/board/ports/OpenAMP/drv_openamp.c
+7
-1
bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rcc.c
bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rcc.c
+5
-4
bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rs485.c
bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rs485.c
+110
-0
bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rs485.h
bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rs485.h
+25
-0
未找到文件。
bsp/stm32/stm32mp157a-st-discovery/board/Kconfig
浏览文件 @
5f911c6d
...
@@ -35,9 +35,24 @@ menu "Onboard Peripheral Drivers"
...
@@ -35,9 +35,24 @@ menu "Onboard Peripheral Drivers"
config BSP_USING_OPENAMP
config BSP_USING_OPENAMP
bool "Enable OpenAMP"
bool "Enable OpenAMP"
select RT_USING_OPENAMP
default n
default n
menuconfig BSP_USING_RS485
bool "Enable RS485 "
default n
if BSP_USING_RS485
comment "set rts pin number "
config BSP_RS485_RTS_PIN
int "RS485 rts pin number"
range 1 176
default 5
config RS485_UART_DEVICE_NAME
string "the uart name for rs485"
default "uart3"
endif
endmenu
endmenu
menu "On-chip Peripheral Drivers"
menu "On-chip Peripheral Drivers"
...
@@ -59,12 +74,10 @@ menu "On-chip Peripheral Drivers"
...
@@ -59,12 +74,10 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_UART3
config BSP_USING_UART3
bool "Enable UART3"
bool "Enable UART3"
default y
default y
config BSP_UART3_RX_USING_DMA
config BSP_UART3_RX_USING_DMA
bool "Enable UART3 RX DMA"
bool "Enable UART3 RX DMA"
depends on BSP_USING_UART
4
&& RT_SERIAL_USING_DMA
depends on BSP_USING_UART
3
&& RT_SERIAL_USING_DMA
default n
default n
config BSP_UART3_TX_USING_DMA
config BSP_UART3_TX_USING_DMA
bool "Enable UART3 TX DMA"
bool "Enable UART3 TX DMA"
depends on BSP_USING_UART3 && RT_SERIAL_USING_DMA
depends on BSP_USING_UART3 && RT_SERIAL_USING_DMA
...
@@ -73,12 +86,10 @@ menu "On-chip Peripheral Drivers"
...
@@ -73,12 +86,10 @@ menu "On-chip Peripheral Drivers"
config BSP_USING_UART4
config BSP_USING_UART4
bool "Enable UART4"
bool "Enable UART4"
default y
default y
config BSP_UART4_RX_USING_DMA
config BSP_UART4_RX_USING_DMA
bool "Enable UART4 RX DMA"
bool "Enable UART4 RX DMA"
depends on BSP_USING_UART4 && RT_SERIAL_USING_DMA
depends on BSP_USING_UART4 && RT_SERIAL_USING_DMA
default n
default n
config BSP_UART4_TX_USING_DMA
config BSP_UART4_TX_USING_DMA
bool "Enable UART4 TX DMA"
bool "Enable UART4 TX DMA"
depends on BSP_USING_UART4 && RT_SERIAL_USING_DMA
depends on BSP_USING_UART4 && RT_SERIAL_USING_DMA
...
...
bsp/stm32/stm32mp157a-st-discovery/board/SConscript
浏览文件 @
5f911c6d
...
@@ -37,6 +37,9 @@ if GetDepend(['BSP_USING_TIM14']):
...
@@ -37,6 +37,9 @@ if GetDepend(['BSP_USING_TIM14']):
if
GetDepend
([
'BSP_USING_PMIC'
]):
if
GetDepend
([
'BSP_USING_PMIC'
]):
src
+=
Glob
(
'ports/drv_pmic.c'
)
src
+=
Glob
(
'ports/drv_pmic.c'
)
if
GetDepend
([
'BSP_USING_RS485'
]):
src
+=
Glob
(
'ports/drv_rs485.c'
)
if
GetDepend
([
'BSP_USING_OPENAMP'
]):
if
GetDepend
([
'BSP_USING_OPENAMP'
]):
src
+=
Glob
(
'CubeMX_Config/CM4/Src/ipcc.c'
)
src
+=
Glob
(
'CubeMX_Config/CM4/Src/ipcc.c'
)
src
+=
Glob
(
'CubeMX_Config/CM4/Src/openamp.c'
)
src
+=
Glob
(
'CubeMX_Config/CM4/Src/openamp.c'
)
...
...
bsp/stm32/stm32mp157a-st-discovery/board/ports/OpenAMP/drv_openamp.c
浏览文件 @
5f911c6d
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
#ifdef BSP_USING_OPENAMP
#ifdef BSP_USING_OPENAMP
#include <finsh.h>
#include <drv_openamp.h>
#include <drv_openamp.h>
#include <openamp.h>
#include <openamp.h>
#include <virt_uart.h>
#include <virt_uart.h>
...
@@ -235,6 +236,11 @@ int rt_hw_openamp_init(void)
...
@@ -235,6 +236,11 @@ int rt_hw_openamp_init(void)
rt_hw_openamp_register
(
&
dev_openamp
,
"openamp"
,
0
,
NULL
);
rt_hw_openamp_register
(
&
dev_openamp
,
"openamp"
,
0
,
NULL
);
if
(
rt_strcmp
(
RT_CONSOLE_DEVICE_NAME
,
"openamp"
)
==
0
)
{
rt_console_set_device
(
RT_CONSOLE_DEVICE_NAME
);
}
return
RT_EOK
;
return
RT_EOK
;
}
}
INIT_PREV_EXPORT
(
rt_hw_openamp_init
);
INIT_PREV_EXPORT
(
rt_hw_openamp_init
);
...
...
bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rcc.c
浏览文件 @
5f911c6d
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
*/
*/
#include "board.h"
#include "board.h"
//#define DRV_DEBUG
//#define DRV_DEBUG
#define LOG_TAG "drv.rcc"
#define LOG_TAG "drv.rcc"
#include <drv_log.h>
#include <drv_log.h>
...
@@ -17,12 +18,12 @@
...
@@ -17,12 +18,12 @@
static
void
enable_clock
(
void
)
static
void
enable_clock
(
void
)
{
{
__HAL_RCC_GPIO
D
_CLK_ENABLE
();
__HAL_RCC_GPIO
H
_CLK_ENABLE
();
}
}
static
void
disable_clock
(
void
)
static
void
disable_clock
(
void
)
{
{
__HAL_RCC_GPIO
D
_CLK_DISABLE
();
__HAL_RCC_GPIO
H
_CLK_DISABLE
();
}
}
static
int
rcc_sample
(
int
argc
,
char
*
argv
[])
static
int
rcc_sample
(
int
argc
,
char
*
argv
[])
...
@@ -47,8 +48,8 @@ static int rcc_sample(int argc, char *argv[])
...
@@ -47,8 +48,8 @@ static int rcc_sample(int argc, char *argv[])
_exit:
_exit:
{
{
rt_kprintf
(
"Usage:
\n
"
);
rt_kprintf
(
"Usage:
\n
"
);
rt_kprintf
(
"rcc_sample enable - enable GPIO
D clock, the LD8
will blink '
\n
"
);
rt_kprintf
(
"rcc_sample enable - enable GPIO
H clock, the LD7
will blink '
\n
"
);
rt_kprintf
(
"rcc_sample disable - disable GPIO
D clock, the LD8
will stop blink'
\n
"
);
rt_kprintf
(
"rcc_sample disable - disable GPIO
H clock, the LD7
will stop blink'
\n
"
);
}
}
return
-
RT_ERROR
;
return
-
RT_ERROR
;
...
...
bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rs485.c
0 → 100644
浏览文件 @
5f911c6d
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-10-24 thread-liu first version
*/
#include <board.h>
#include "drv_rs485.h"
#ifdef BSP_USING_RS485
#define RS485_OUT rt_pin_write(BSP_RS485_RTS_PIN, PIN_HIGH)
#define RS485_IN rt_pin_write(BSP_RS485_RTS_PIN, PIN_LOW)
static
rt_device_t
serial
=
{
0
};
static
struct
rt_semaphore
rx_sem
=
{
0
};
/* rs485 send data callback function */
static
rt_err_t
rs485_output
(
rt_device_t
dev
,
void
*
buffer
)
{
RS485_IN
;
return
RT_EOK
;
}
static
rt_err_t
rs485_input
(
rt_device_t
dev
,
rt_size_t
size
)
{
rt_sem_release
(
&
rx_sem
);
return
RT_EOK
;
}
/* send string */
int
rs485_send_data
(
char
*
tbuf
,
rt_uint16_t
t_len
)
{
/* set rs485 mode */
RS485_OUT
;
/* send data */
rt_device_write
(
serial
,
0
,
tbuf
,
t_len
);
RS485_IN
;
return
RT_EOK
;
}
static
void
rs485_thread_entry
(
void
*
parameter
)
{
char
ch
;
while
(
1
)
{
/* A byte of data is read from a serial port, and if it is not read, it waits for the received semaphore */
while
(
rt_device_read
(
serial
,
-
1
,
&
ch
,
1
)
!=
1
)
{
rt_sem_take
(
&
rx_sem
,
RT_WAITING_FOREVER
);
}
/* The data read through the serial port output dislocation */
ch
=
ch
+
1
;
rs485_send_data
(
&
ch
,
1
);
}
}
/* rs485 rts pin init */
static
int
rs485_init
(
void
)
{
/* find uart device */
serial
=
rt_device_find
(
RS485_UART_DEVICE_NAME
);
if
(
!
serial
)
{
rt_kprintf
(
"find %s failed!
\n
"
,
RS485_UART_DEVICE_NAME
);
return
RT_ERROR
;
}
rt_device_open
(
serial
,
RT_DEVICE_FLAG_INT_RX
);
/* set receive data callback function */
rt_device_set_rx_indicate
(
serial
,
rs485_input
);
/* set the send completion callback function */
rt_device_set_tx_complete
(
serial
,
rs485_output
);
rt_pin_mode
(
BSP_RS485_RTS_PIN
,
PIN_MODE_OUTPUT
);
RS485_IN
;
rt_sem_init
(
&
rx_sem
,
"rx_sem"
,
0
,
RT_IPC_FLAG_FIFO
);
/* create rs485 thread */
rt_thread_t
thread
=
rt_thread_create
(
"rs485"
,
rs485_thread_entry
,
RT_NULL
,
1024
,
25
,
10
);
if
(
thread
!=
RT_NULL
)
{
rt_thread_startup
(
thread
);
}
else
{
return
RT_ERROR
;
}
return
RT_EOK
;
}
INIT_DEVICE_EXPORT
(
rs485_init
);
#endif
/* bsp_using_RS485 */
bsp/stm32/stm32mp157a-st-discovery/board/ports/drv_rs485.h
0 → 100644
浏览文件 @
5f911c6d
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-10-24 thread-liu first version
*/
#ifndef __DRV_RS485_H__
#define __DRV_RS485_H__
#ifdef __cplusplus
extern
"C"
{
#endif
#define RS485_SEND_MODE 0
#define RS485_RECV_MODE 1
#ifdef __cplusplus
}
#endif
#endif
/* drv_rs485.h */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录