Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
混口饭吃,
rt-thread
提交
ba7865d3
R
rt-thread
项目概览
混口饭吃,
/
rt-thread
与 Fork 源项目一致
Fork自
Mr_Pangza / 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,发现更多精彩内容 >>
提交
ba7865d3
编写于
12月 05, 2020
作者:
T
thread-liu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[add] spi loopback test case.
上级
edd3fd21
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
105 addition
and
13 deletion
+105
-13
bsp/stm32/stm32mp157a-st-ev1/board/CubeMX_Config/CM4/Src/stm32mp1xx_hal_msp.c
...a-st-ev1/board/CubeMX_Config/CM4/Src/stm32mp1xx_hal_msp.c
+14
-13
bsp/stm32/stm32mp157a-st-ev1/board/SConscript
bsp/stm32/stm32mp157a-st-ev1/board/SConscript
+6
-0
bsp/stm32/stm32mp157a-st-ev1/board/ports/spi_sample.c
bsp/stm32/stm32mp157a-st-ev1/board/ports/spi_sample.c
+85
-0
未找到文件。
bsp/stm32/stm32mp157a-st-ev1/board/CubeMX_Config/CM4/Src/stm32mp1xx_hal_msp.c
浏览文件 @
ba7865d3
...
...
@@ -517,17 +517,17 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{
GPIO_InitTypeDef
GPIO_InitStruct
=
{
0
};
RCC_PeriphCLKInitTypeDef
PeriphClkInit
=
{
0
};
if
(
hspi
->
Instance
==
SPI
5
)
if
(
hspi
->
Instance
==
SPI
1
)
{
/* USER CODE BEGIN SPI
5
_MspInit 0 */
/* USER CODE BEGIN SPI
1
_MspInit 0 */
/* USER CODE END SPI
5
_MspInit 0 */
/* USER CODE END SPI
1
_MspInit 0 */
if
(
IS_ENGINEERING_BOOT_MODE
())
{
/** Initializes the peripherals clock
*/
PeriphClkInit
.
PeriphClockSelection
=
RCC_PERIPHCLK_SPI
45
;
PeriphClkInit
.
Spi
45ClockSelection
=
RCC_SPI45CLKSOURCE_PCLK2
;
PeriphClkInit
.
PeriphClockSelection
=
RCC_PERIPHCLK_SPI
1
;
PeriphClkInit
.
Spi
1ClockSelection
=
RCC_SPI1CLKSOURCE_PLL4
;
if
(
HAL_RCCEx_PeriphCLKConfig
(
&
PeriphClkInit
)
!=
HAL_OK
)
{
Error_Handler
();
...
...
@@ -536,19 +536,20 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
}
/* Peripheral clock enable */
__HAL_RCC_SPI
5
_CLK_ENABLE
();
__HAL_RCC_SPI
1
_CLK_ENABLE
();
__HAL_RCC_GPIOF_CLK_ENABLE
();
/**SPI5 GPIO Configuration
PF9 ------> SPI5_MOSI
PF7 ------> SPI5_SCK
__HAL_RCC_GPIOZ_CLK_ENABLE
();
/**SPI1 GPIO Configuration
PZ2 ------> SPI1_MOSI
PZ1 ------> SPI1_MISO
PZ0 ------> SPI1_SCK
*/
GPIO_InitStruct
.
Pin
=
GPIO_PIN_
9
|
GPIO_PIN_7
;
GPIO_InitStruct
.
Pin
=
GPIO_PIN_
0
|
GPIO_PIN_1
|
GPIO_PIN_2
;
GPIO_InitStruct
.
Mode
=
GPIO_MODE_AF_PP
;
GPIO_InitStruct
.
Pull
=
GPIO_NOPULL
;
GPIO_InitStruct
.
Speed
=
GPIO_SPEED_FREQ_MEDIUM
;
GPIO_InitStruct
.
Alternate
=
GPIO_AF5_SPI
5
;
HAL_GPIO_Init
(
GPIO
F
,
&
GPIO_InitStruct
);
GPIO_InitStruct
.
Alternate
=
GPIO_AF5_SPI
1
;
HAL_GPIO_Init
(
GPIO
Z
,
&
GPIO_InitStruct
);
/* USER CODE BEGIN SPI5_MspInit 1 */
...
...
bsp/stm32/stm32mp157a-st-ev1/board/SConscript
浏览文件 @
ba7865d3
...
...
@@ -13,6 +13,9 @@ CubeMX_Config/Common/System/system_stm32mp1xx.c
CubeMX_Config/CM4/Src/stm32mp1xx_hal_msp.c
'''
)
if
GetDepend
([
'BSP_USING_SPI1'
]):
src
+=
Glob
(
'ports/spi_sample.c'
)
if
GetDepend
([
'BSP_USING_PMIC'
]):
src
+=
Glob
(
'ports/drv_pmic.c'
)
...
...
@@ -55,6 +58,9 @@ if GetDepend(['BSP_USING_DFSDM']):
if
GetDepend
([
'BSP_USING_WWDG'
]):
src
+=
Glob
(
'ports/drv_wwdg.c'
)
if
GetDepend
([
'BSP_USING_EXTI'
]):
src
+=
Glob
(
'ports/drv_exti.c'
)
if
GetDepend
([
'BSP_USING_OPENAMP'
]):
src
+=
Glob
(
'CubeMX_Config/CM4/Src/ipcc.c'
)
src
+=
Glob
(
'CubeMX_Config/CM4/Src/openamp.c'
)
...
...
bsp/stm32/stm32mp157a-st-ev1/board/ports/spi_sample.c
0 → 100644
浏览文件 @
ba7865d3
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-09-15 thread-liu first version
*/
#include "board.h"
#if defined(BSP_USING_SPI1)
#include <drv_spi.h>
#define SPI_NAME "spi1"
#define SPI_DEVICE_NAME "spi10"
static
struct
rt_spi_device
*
spi_dev
=
RT_NULL
;
/* attach spi1 device */
static
int
rt_spi_device_init
(
void
)
{
struct
rt_spi_configuration
cfg
;
rt_hw_spi_device_attach
(
SPI_NAME
,
SPI_DEVICE_NAME
,
NULL
,
NULL
);
cfg
.
data_width
=
8
;
cfg
.
mode
=
RT_SPI_MASTER
|
RT_SPI_MODE_0
|
RT_SPI_MSB
|
RT_SPI_NO_CS
;
cfg
.
max_hz
=
1
*
1000
*
1000
;
spi_dev
=
(
struct
rt_spi_device
*
)
rt_device_find
(
SPI_DEVICE_NAME
);
if
(
RT_NULL
==
spi_dev
)
{
rt_kprintf
(
"spi sample run failed! can't find %s device!
\n
"
,
SPI_NAME
);
return
RT_ERROR
;
}
rt_spi_configure
(
spi_dev
,
&
cfg
);
return
RT_EOK
;
}
INIT_APP_EXPORT
(
rt_spi_device_init
);
/* spi5 loopback mode test case */
static
int
spi_sample
(
int
argc
,
char
**
argv
)
{
rt_uint8_t
t_buf
[
8
],
r_buf
[
8
];
int
i
=
0
;
static
struct
rt_spi_message
msg1
;
if
(
argc
!=
9
)
{
rt_kprintf
(
"Usage:
\n
"
);
rt_kprintf
(
"spi_sample 1 2 3 4 5 6 7 8
\n
"
);
return
-
RT_ERROR
;
}
for
(
i
=
0
;
i
<
8
;
i
++
)
{
t_buf
[
i
]
=
atoi
(
argv
[
i
+
1
]);
}
msg1
.
send_buf
=
&
t_buf
;
msg1
.
recv_buf
=
&
r_buf
;
msg1
.
length
=
sizeof
(
t_buf
);
msg1
.
cs_take
=
1
;
msg1
.
cs_release
=
0
;
msg1
.
next
=
RT_NULL
;
rt_spi_transfer_message
(
spi_dev
,
&
msg1
);
rt_kprintf
(
"spi rbuf : "
);
for
(
i
=
0
;
i
<
sizeof
(
t_buf
);
i
++
)
{
rt_kprintf
(
"%x "
,
r_buf
[
i
]);
}
rt_kprintf
(
"
\n
spi loopback mode test over!
\n
"
);
return
RT_EOK
;
}
MSH_CMD_EXPORT
(
spi_sample
,
spi
loopback
test
);
#endif
/* BSP_USING_SPI5 */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录