Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lfmiao0
rt-thread
提交
9a9a7b35
R
rt-thread
项目概览
lfmiao0
/
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,发现更多精彩内容 >>
提交
9a9a7b35
编写于
2月 15, 2019
作者:
G
guanwenliang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
STM32G071 BSP对SPI和UART DMA读写的支持
上级
7b532187
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
22 deletion
+76
-22
bsp/stm32/libraries/HAL_Drivers/config/g0/dma_config.h
bsp/stm32/libraries/HAL_Drivers/config/g0/dma_config.h
+36
-6
bsp/stm32/libraries/HAL_Drivers/config/g0/spi_config.h
bsp/stm32/libraries/HAL_Drivers/config/g0/spi_config.h
+2
-2
bsp/stm32/libraries/HAL_Drivers/config/g0/uart_config.h
bsp/stm32/libraries/HAL_Drivers/config/g0/uart_config.h
+9
-3
bsp/stm32/libraries/HAL_Drivers/drv_spi.c
bsp/stm32/libraries/HAL_Drivers/drv_spi.c
+7
-6
bsp/stm32/libraries/HAL_Drivers/drv_usart.c
bsp/stm32/libraries/HAL_Drivers/drv_usart.c
+22
-5
未找到文件。
bsp/stm32/libraries/HAL_Drivers/config/g0/dma_config.h
浏览文件 @
9a9a7b35
...
...
@@ -20,32 +20,62 @@ extern "C" {
/* DMA1 channel1 */
#if defined(BSP_SPI1_RX_USING_DMA) && !defined(SPI1_RX_DMA_INSTANCE)
#define SPI1_
RX_DMA
_IRQHandler DMA1_Channel1_IRQHandler
#define SPI1_
DMA_RX
_IRQHandler DMA1_Channel1_IRQHandler
#define SPI1_RX_DMA_RCC RCC_AHBENR_DMA1EN
#define SPI1_RX_DMA_INSTANCE DMA1_Channel1
#define SPI1_RX_DMA_REQUEST DMA_REQUEST_SPI1_RX
#define SPI1_RX_DMA_IRQ DMA1_Channel1_IRQn
#ifdef BSP_UART1_RX_USING_DMA
#undef BSP_UART1_RX_USING_DMA
#endif
#ifdef BSP_SPI2_RX_USING_DMA
#undef BSP_SPI2_RX_USING_DMA
#endif
#elif defined(BSP_UART1_RX_USING_DMA) && !defined(UART1_RX_DMA_INSTANCE)
#define UART1_DMA_RX_IRQHandler DMA1_Channel1_IRQHandler
#define UART1_RX_DMA_RCC RCC_AHBENR_DMA1EN
#define UART1_RX_DMA_INSTANCE DMA1_Channel1
#define UART1_RX_DMA_REQUEST DMA_REQUEST_USART1_RX
#define UART1_RX_DMA_IRQ DMA1_Channel1_IRQn
#ifdef BSP_SPI2_RX_USING_DMA
#undef BSP_SPI2_RX_USING_DMA
#endif
#elif defined(BSP_SPI2_RX_USING_DMA) && !defined(SPI2_RX_DMA_INSTANCE)
#define SPI2_DMA_RX_IRQHandler DMA1_Channel1_IRQHandler
#define SPI2_RX_DMA_RCC RCC_AHBENR_DMA1EN
#define SPI2_RX_DMA_INSTANCE DMA1_Channel1
#define SPI2_RX_DMA_REQUEST DMA_REQUEST_SPI2_RX
#define SPI2_RX_DMA_IRQ DMA1_Channel1_IRQn
#endif
/* DMA1 channle2-3 */
#if defined(BSP_SPI1_TX_USING_DMA) && !defined(SPI1_TX_DMA_INSTANCE)
#define SPI1_TX_DMA_IRQHandler DMA1_Channel2_3_IRQHandler
#define SPI1_TX_DMA_RCC RCC_AHBENR_DMA1EN
#define SPI1_TX_DMA_INSTANCE DMA1_Channel2
#define SPI1_TX_DMA_REQUEST DMA_REQUEST_SPI1_TX
#define SPI1_TX_DMA_IRQ DMA1_Channel2_3_IRQn
#define SPI1_DMA_TX_IRQHandler DMA1_Channel2_3_IRQHandler
#define SPI1_TX_DMA_RCC RCC_AHBENR_DMA1EN
#define SPI1_TX_DMA_INSTANCE DMA1_Channel2
#define SPI1_TX_DMA_REQUEST DMA_REQUEST_SPI1_TX
#define SPI1_TX_DMA_IRQ DMA1_Channel2_3_IRQn
#ifdef BSP_UART2_RX_USING_DMA
#undef BSP_UART2_RX_USING_DMA
#endif
#ifdef BSP_SPI2_TX_USING_DMA
#undef BSP_SPI2_TX_USING_DMA
#endif
#elif defined(BSP_UART2_RX_USING_DMA) && !defined(UART2_RX_DMA_INSTANCE)
#define UART2_DMA_RX_IRQHandler DMA1_Channel2_3_IRQHandler
#define UART2_RX_DMA_RCC RCC_AHBENR_DMA1EN
#define UART2_RX_DMA_INSTANCE DMA1_Channel2
#define UART2_RX_DMA_REQUEST DMA_REQUEST_USART2_RX
#define UART2_RX_DMA_IRQ DMA1_Channel2_3_IRQn
#ifdef BSP_SPI2_TX_USING_DMA
#undef BSP_SPI2_TX_USING_DMA
#endif
#elif defined(BSP_SPI2_TX_USING_DMA) && !defined(SPI2_TX_DMA_INSTANCE)
#define SPI2_DMA_TX_IRQHandler DMA1_Channel2_3_IRQHandler
#define SPI2_TX_DMA_RCC RCC_AHBENR_DMA1EN
#define SPI2_TX_DMA_INSTANCE DMA1_Channel2
#define SPI2_TX_DMA_REQUEST DMA_REQUEST_SPI2_TX
#define SPI2_TX_DMA_IRQ DMA1_Channel2_3_IRQn
#endif
#if defined(BSP_LPUART1_RX_USING_DMA) && !defined(LPUART1_RX_DMA_INSTANCE)
...
...
bsp/stm32/libraries/HAL_Drivers/config/g0/spi_config.h
浏览文件 @
9a9a7b35
...
...
@@ -68,7 +68,7 @@ extern "C" {
{ \
.dma_rcc = SPI2_TX_DMA_RCC, \
.Instance = SPI2_TX_DMA_INSTANCE, \
.
channel = SPI2_TX_DMA_CHANNEL
, \
.
request = SPI2_TX_DMA_REQUEST
, \
.dma_irq = SPI2_TX_DMA_IRQ, \
}
#endif
/* SPI2_TX_DMA_CONFIG */
...
...
@@ -80,7 +80,7 @@ extern "C" {
{ \
.dma_rcc = SPI2_RX_DMA_RCC, \
.Instance = SPI2_RX_DMA_INSTANCE, \
.
channel = SPI2_RX_DMA_CHANNEL
, \
.
request = SPI2_RX_DMA_REQUEST
, \
.dma_irq = SPI2_RX_DMA_IRQ, \
}
#endif
/* SPI2_RX_DMA_CONFIG */
...
...
bsp/stm32/libraries/HAL_Drivers/config/g0/uart_config.h
浏览文件 @
9a9a7b35
...
...
@@ -21,14 +21,16 @@
.Instance = LPUART1, \
.irq_type = USART3_4_LPUART1_IRQn, \
}
#define LPUART1_IRQHandler USART3_4_LPUART1_IRQHandler
#endif
/* LPUART1_CONFIG */
#if defined(BSP_LPUART1_RX_USING_DMA)
#ifndef LPUART1_DMA_CONFIG
#define LPUART1_DMA_CONFIG \
{ \
.Instance = DMA1_Channel1, \
.dma_rcc = RCC_AHBENR_DMA1EN, \
.dma_irq = DMA1_Channel1_IRQn, \
.Instance = LPUART1_RX_DMA_INSTANCE, \
.request = LPUART1_RX_DMA_REQUEST, \
.dma_rcc = LPUART1_RX_DMA_RCC, \
.dma_irq = LPUART1_RX_DMA_IRQ, \
}
#endif
/* LPUART1_DMA_CONFIG */
#endif
/* BSP_LPUART1_RX_USING_DMA */
...
...
@@ -50,6 +52,7 @@
#define UART1_DMA_CONFIG \
{ \
.Instance = UART1_RX_DMA_INSTANCE, \
.request = UART1_RX_DMA_REQUEST, \
.dma_rcc = UART1_RX_DMA_RCC, \
.dma_irq = UART1_RX_DMA_IRQ, \
}
...
...
@@ -72,6 +75,7 @@
#define UART2_DMA_CONFIG \
{ \
.Instance = UART2_RX_DMA_INSTANCE, \
.request = UART2_RX_DMA_REQUEST, \
.dma_rcc = UART2_RX_DMA_RCC, \
.dma_irq = UART2_RX_DMA_IRQ, \
}
...
...
@@ -103,6 +107,7 @@
#define UART3_DMA_CONFIG \
{ \
.Instance = UART3_RX_DMA_INSTANCE, \
.request = UART3_RX_DMA_REQUEST, \
.dma_rcc = UART3_RX_DMA_RCC, \
.dma_irq = UART3_RX_DMA_IRQ, \
}
...
...
@@ -134,6 +139,7 @@
#define UART4_DMA_CONFIG \
{ \
.Instance = UART4_RX_DMA_INSTANCE, \
.request = UART4_RX_DMA_REQUEST, \
.dma_rcc = UART4_RX_DMA_RCC, \
.dma_irq = UART4_RX_DMA_IRQ, \
}
...
...
bsp/stm32/libraries/HAL_Drivers/drv_spi.c
浏览文件 @
9a9a7b35
...
...
@@ -203,7 +203,7 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
spi_handle
->
Init
.
TIMode
=
SPI_TIMODE_DISABLE
;
spi_handle
->
Init
.
CRCCalculation
=
SPI_CRCCALCULATION_DISABLE
;
spi_handle
->
State
=
HAL_SPI_STATE_RESET
;
#if
def SOC_SERIES_STM32L4
#if
defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32G0)
spi_handle
->
Init
.
NSSPMode
=
SPI_NSS_PULSE_DISABLE
;
#endif
...
...
@@ -212,7 +212,8 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur
return
RT_EIO
;
}
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F0)|| defined(SOC_SERIES_STM32F7)
#if defined(SOC_SERIES_STM32L4) || defined(SOC_SERIES_STM32F0) \
|| defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32G0)
SET_BIT
(
spi_handle
->
Instance
->
CR2
,
SPI_RXFIFO_THRESHOLD_HF
);
#endif
...
...
@@ -389,7 +390,7 @@ static int rt_hw_spi_bus_init(void)
spi_bus_obj
[
i
].
dma
.
handle_rx
.
Instance
=
spi_config
[
i
].
dma_rx
->
Instance
;
#if defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
spi_bus_obj
[
i
].
dma
.
handle_rx
.
Init
.
Channel
=
spi_config
[
i
].
dma_rx
->
channel
;
#elif defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32L4)
|| defined(SOC_SERIES_STM32G0)
spi_bus_obj
[
i
].
dma
.
handle_rx
.
Init
.
Request
=
spi_config
[
i
].
dma_rx
->
request
;
#endif
spi_bus_obj
[
i
].
dma
.
handle_rx
.
Init
.
Direction
=
DMA_PERIPH_TO_MEMORY
;
...
...
@@ -408,7 +409,7 @@ static int rt_hw_spi_bus_init(void)
{
rt_uint32_t
tmpreg
=
0x00U
;
#if defined(SOC_SERIES_STM32F1)
#if defined(SOC_SERIES_STM32F1)
|| defined(SOC_SERIES_STM32G0)
/* enable DMA clock && Delay after an RCC peripheral clock enabling*/
SET_BIT
(
RCC
->
AHBENR
,
spi_config
[
i
].
dma_rx
->
dma_rcc
);
tmpreg
=
READ_BIT
(
RCC
->
AHBENR
,
spi_config
[
i
].
dma_rx
->
dma_rcc
);
...
...
@@ -427,7 +428,7 @@ static int rt_hw_spi_bus_init(void)
spi_bus_obj
[
i
].
dma
.
handle_tx
.
Instance
=
spi_config
[
i
].
dma_tx
->
Instance
;
#if defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
spi_bus_obj
[
i
].
dma
.
handle_tx
.
Init
.
Channel
=
spi_config
[
i
].
dma_tx
->
channel
;
#elif defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32L4)
|| defined(SOC_SERIES_STM32G0)
spi_bus_obj
[
i
].
dma
.
handle_tx
.
Init
.
Request
=
spi_config
[
i
].
dma_tx
->
request
;
#endif
spi_bus_obj
[
i
].
dma
.
handle_tx
.
Init
.
Direction
=
DMA_MEMORY_TO_PERIPH
;
...
...
@@ -446,7 +447,7 @@ static int rt_hw_spi_bus_init(void)
{
rt_uint32_t
tmpreg
=
0x00U
;
#if defined(SOC_SERIES_STM32F1)
#if defined(SOC_SERIES_STM32F1)
|| defined(SOC_SERIES_STM32G0)
/* enable DMA clock && Delay after an RCC peripheral clock enabling*/
SET_BIT
(
RCC
->
AHBENR
,
spi_config
[
i
].
dma_rx
->
dma_rcc
);
tmpreg
=
READ_BIT
(
RCC
->
AHBENR
,
spi_config
[
i
].
dma_rx
->
dma_rcc
);
...
...
bsp/stm32/libraries/HAL_Drivers/drv_usart.c
浏览文件 @
9a9a7b35
...
...
@@ -432,7 +432,7 @@ void UART5_DMA_RX_IRQHandler(void)
#endif
/* BSP_USING_UART5*/
#if defined(BSP_USING_LPUART1)
void
USART3_4_
LPUART1_IRQHandler
(
void
)
void
LPUART1_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
...
...
@@ -442,7 +442,20 @@ void USART3_4_LPUART1_IRQHandler(void)
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
#if defined(RT_SERIAL_USING_DMA) && defined(BSP_LPUART1_RX_USING_DMA)
void
LPUART1_DMA_RX_IRQHandler
(
void
)
{
/* enter interrupt */
rt_interrupt_enter
();
HAL_DMA_IRQHandler
(
&
uart_obj
[
LPUART1_INDEX
].
dma
.
handle
);
/* leave interrupt */
rt_interrupt_leave
();
}
#endif
/* defined(RT_SERIAL_USING_DMA) && defined(BSP_UART5_RX_USING_DMA) */
#endif
/* BSP_USING_LPUART1 */
#ifdef RT_SERIAL_USING_DMA
static
void
stm32_dma_config
(
struct
rt_serial_device
*
serial
)
...
...
@@ -471,13 +484,12 @@ static void stm32_dma_config(struct rt_serial_device *serial)
__HAL_LINKDMA
(
&
(
uart
->
handle
),
hdmarx
,
uart
->
dma
.
handle
);
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32G0) \
|| defined(SOC_SERIES_STM32L0)
#if defined(SOC_SERIES_STM32F1) || defined(SOC_SERIES_STM32F0) || defined(SOC_SERIES_STM32L0)
uart
->
dma
.
handle
.
Instance
=
uart
->
config
->
dma_rx
->
Instance
;
#elif defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
uart
->
dma
.
handle
.
Instance
=
uart
->
config
->
dma_rx
->
Instance
;
uart
->
dma
.
handle
.
Init
.
Channel
=
uart
->
config
->
dma_rx
->
channel
;
#elif defined(SOC_SERIES_STM32L4)
#elif defined(SOC_SERIES_STM32L4)
|| defined(SOC_SERIES_STM32G0)
uart
->
dma
.
handle
.
Instance
=
uart
->
config
->
dma_rx
->
Instance
;
uart
->
dma
.
handle
.
Init
.
Request
=
uart
->
config
->
dma_rx
->
request
;
#endif
...
...
@@ -597,6 +609,11 @@ static void stm32_uart_get_dma_config(void)
static
struct
dma_config
uart5_dma_rx
=
UART5_DMA_CONFIG
;
uart_config
[
UART5_INDEX
].
dma_rx
=
&
uart5_dma_rx
;
#endif
#ifdef BSP_LPUART1_RX_USING_DMA
uart_obj
[
LPUART1_INDEX
].
uart_dma_flag
=
1
;
static
struct
dma_config
uart5_dma_rx
=
LPUART1_DMA_CONFIG
;
uart_config
[
LPUART1_INDEX
].
dma_rx
=
&
uart5_dma_rx
;
#endif
}
int
rt_hw_usart_init
(
void
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录