Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
天中雨水
rt-thread
提交
827b772f
R
rt-thread
项目概览
天中雨水
/
rt-thread
该项目与 Fork 源项目分叉
Fork自
RT-Thread / rt-thread
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
827b772f
编写于
12月 11, 2020
作者:
B
Bernard Xiong
提交者:
GitHub
12月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4146 from thread-liu/main
[add] dma test case for stm32mp157a-ev1.
上级
42088b01
3ab2d4fb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
184 addition
and
0 deletion
+184
-0
bsp/stm32/stm32mp157a-st-ev1/board/Kconfig
bsp/stm32/stm32mp157a-st-ev1/board/Kconfig
+4
-0
bsp/stm32/stm32mp157a-st-ev1/board/SConscript
bsp/stm32/stm32mp157a-st-ev1/board/SConscript
+3
-0
bsp/stm32/stm32mp157a-st-ev1/board/ports/dma_sample.c
bsp/stm32/stm32mp157a-st-ev1/board/ports/dma_sample.c
+177
-0
未找到文件。
bsp/stm32/stm32mp157a-st-ev1/board/Kconfig
浏览文件 @
827b772f
...
...
@@ -134,6 +134,10 @@ menu "On-chip Peripheral Drivers"
select RT_USING_WDT
default n
config BSP_USING_DMA
bool "Enable DMA Test"
default name
config BSP_USING_QSPI
bool "Enable QSPI BUS"
select RT_USING_QSPI
...
...
bsp/stm32/stm32mp157a-st-ev1/board/SConscript
浏览文件 @
827b772f
...
...
@@ -76,6 +76,9 @@ if GetDepend(['BSP_USING_RS485']):
if
GetDepend
([
'BSP_USING_TIM14'
]):
src
+=
Glob
(
'ports/timer_sample.c'
)
if
GetDepend
([
'BSP_USING_DMA'
]):
src
+=
Glob
(
'ports/dma_sample.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/dma_sample.c
0 → 100644
浏览文件 @
827b772f
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-12-10 thread-liu first version
*/
#include <board.h>
#if defined(BSP_USING_DMA)
#define BUFFER_SIZE 32
/* DMA max buffer size */
static
DMA_HandleTypeDef
hdma_memtomem_dma1_stream5
=
{
0
};
/* Using dma1 stream5 to test */
static
const
rt_uint32_t
DMA_Src_Buffer
[
BUFFER_SIZE
]
=
{
0x01020304
,
0x05060708
,
0x090A0B0C
,
0x0D0E0F10
,
0x11121314
,
0x15161718
,
0x191A1B1C
,
0x1D1E1F20
,
0x21222324
,
0x25262728
,
0x292A2B2C
,
0x2D2E2F30
,
0x31323334
,
0x35363738
,
0x393A3B3C
,
0x3D3E3F40
,
0x41424344
,
0x45464748
,
0x494A4B4C
,
0x4D4E4F50
,
0x51525354
,
0x55565758
,
0x595A5B5C
,
0x5D5E5F60
,
0x61626364
,
0x65666768
,
0x696A6B6C
,
0x6D6E6F70
,
0x71727374
,
0x75767778
,
0x797A7B7C
,
0x7D7E7F80
};
static
rt_uint32_t
DMA_Dst_Buffer
[
BUFFER_SIZE
];
#define __is_print(ch) ((unsigned int)((ch) - ' ') < 127u - ' ')
static
void
dump_hex
(
const
rt_uint8_t
*
ptr
,
rt_size_t
buflen
)
{
unsigned
char
*
buf
=
(
unsigned
char
*
)
ptr
;
int
i
,
j
;
for
(
i
=
0
;
i
<
buflen
;
i
+=
16
)
{
rt_kprintf
(
"%08X: "
,
i
);
for
(
j
=
0
;
j
<
16
;
j
++
)
{
if
(
i
+
j
<
buflen
)
{
rt_kprintf
(
"%02X "
,
buf
[
i
+
j
]);
}
else
{
rt_kprintf
(
" "
);
}
}
rt_kprintf
(
" "
);
for
(
j
=
0
;
j
<
16
;
j
++
)
{
if
(
i
+
j
<
buflen
)
{
rt_kprintf
(
"%c"
,
__is_print
(
buf
[
i
+
j
])
?
buf
[
i
+
j
]
:
'.'
);
}
}
rt_kprintf
(
"
\n
"
);
}
}
void
DMA1_Stream5_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
HAL_DMA_IRQHandler
(
&
hdma_memtomem_dma1_stream5
);
/* leave interrupt */
rt_interrupt_leave
();
}
static
void
MX_DMA_Init
(
void
)
{
/* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE
();
__HAL_RCC_DMAMUX_CLK_ENABLE
();
/* Configure DMA request hdma_memtomem_dma1_stream5 on DMA1_Stream5 */
hdma_memtomem_dma1_stream5
.
Instance
=
DMA1_Stream5
;
hdma_memtomem_dma1_stream5
.
Init
.
Request
=
DMA_REQUEST_MEM2MEM
;
hdma_memtomem_dma1_stream5
.
Init
.
Direction
=
DMA_MEMORY_TO_MEMORY
;
hdma_memtomem_dma1_stream5
.
Init
.
PeriphInc
=
DMA_PINC_ENABLE
;
hdma_memtomem_dma1_stream5
.
Init
.
MemInc
=
DMA_MINC_ENABLE
;
hdma_memtomem_dma1_stream5
.
Init
.
PeriphDataAlignment
=
DMA_PDATAALIGN_WORD
;
hdma_memtomem_dma1_stream5
.
Init
.
MemDataAlignment
=
DMA_MDATAALIGN_WORD
;
hdma_memtomem_dma1_stream5
.
Init
.
Mode
=
DMA_NORMAL
;
hdma_memtomem_dma1_stream5
.
Init
.
Priority
=
DMA_PRIORITY_LOW
;
hdma_memtomem_dma1_stream5
.
Init
.
FIFOMode
=
DMA_FIFOMODE_ENABLE
;
hdma_memtomem_dma1_stream5
.
Init
.
FIFOThreshold
=
DMA_FIFO_THRESHOLD_FULL
;
hdma_memtomem_dma1_stream5
.
Init
.
MemBurst
=
DMA_MBURST_INC4
;
hdma_memtomem_dma1_stream5
.
Init
.
PeriphBurst
=
DMA_PBURST_INC4
;
if
(
HAL_DMA_Init
(
&
hdma_memtomem_dma1_stream5
)
!=
HAL_OK
)
{
Error_Handler
();
}
/* DMA interrupt init */
/* DMA1_Stream5_IRQn interrupt configuration */
HAL_NVIC_SetPriority
(
DMA1_Stream5_IRQn
,
0
,
0
);
HAL_NVIC_EnableIRQ
(
DMA1_Stream5_IRQn
);
}
static
void
TransferComplete
(
DMA_HandleTypeDef
*
DmaHandle
)
{
rt_kprintf
(
"dma dst buffer :
\n
"
);
dump_hex
((
rt_uint8_t
*
)
DMA_Dst_Buffer
,
sizeof
(
DMA_Dst_Buffer
));
rt_kprintf
(
"============ dma transfer success ============
\n
"
);
rt_memset
(
DMA_Dst_Buffer
,
0x00
,
sizeof
(
DMA_Dst_Buffer
));
}
static
void
TransferError
(
DMA_HandleTypeDef
*
DmaHandle
)
{
rt_kprintf
(
"============ dma transfer error ============
\n
"
);
}
static
int
rt_hw_dma_init
(
void
)
{
rt_err_t
result
=
RT_EOK
;
MX_DMA_Init
();
/* Select Callbacks functions called after Transfer complete and Transfer error */
HAL_DMA_RegisterCallback
(
&
hdma_memtomem_dma1_stream5
,
HAL_DMA_XFER_CPLT_CB_ID
,
TransferComplete
);
HAL_DMA_RegisterCallback
(
&
hdma_memtomem_dma1_stream5
,
HAL_DMA_XFER_ERROR_CB_ID
,
TransferError
);
return
result
;
}
INIT_APP_EXPORT
(
rt_hw_dma_init
);
static
int
dma_transfer_test
()
{
rt_kprintf
(
"============ dma travsfer start ============
\n
"
);
rt_kprintf
(
"dma src buffer :
\n
"
);
dump_hex
((
rt_uint8_t
*
)
DMA_Src_Buffer
,
sizeof
(
DMA_Src_Buffer
));
if
(
HAL_DMA_Start_IT
(
&
hdma_memtomem_dma1_stream5
,
(
rt_uint32_t
)
&
DMA_Src_Buffer
,
(
rt_uint32_t
)
&
DMA_Dst_Buffer
,
BUFFER_SIZE
)
!=
HAL_OK
)
{
/* Transfer Error */
return
-
RT_ERROR
;
}
return
RT_EOK
;
}
int
dma_sample
(
int
argc
,
char
**
argv
)
{
if
(
argc
>
1
)
{
if
(
!
rt_strcmp
(
argv
[
1
],
"start"
))
{
rt_kprintf
(
"dma test start
\n
"
);
dma_transfer_test
();
return
RT_EOK
;
}
else
{
goto
_exit
;
}
}
_exit:
{
rt_kprintf
(
"Usage:
\n
"
);
rt_kprintf
(
"dma_sample start - start dma
\n
"
);
}
return
RT_EOK
;
}
MSH_CMD_EXPORT
(
dma_sample
,
dma
test
);
#endif
/* USE_DMA_SAMPLE */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录