From 5b7dac8c8e47b12561edbbf0ea8b3b437befa115 Mon Sep 17 00:00:00 2001 From: wanghaijing Date: Fri, 23 Apr 2021 09:52:17 +0800 Subject: [PATCH] [add] spi config increases irq_type --- bsp/stm32/libraries/HAL_Drivers/config/f0/spi_config.h | 2 ++ bsp/stm32/libraries/HAL_Drivers/config/f1/spi_config.h | 3 +++ bsp/stm32/libraries/HAL_Drivers/config/f2/spi_config.h | 3 +++ bsp/stm32/libraries/HAL_Drivers/config/f4/spi_config.h | 5 +++++ bsp/stm32/libraries/HAL_Drivers/config/f7/spi_config.h | 5 +++++ bsp/stm32/libraries/HAL_Drivers/config/g0/spi_config.h | 2 ++ bsp/stm32/libraries/HAL_Drivers/config/g4/spi_config.h | 5 +++++ bsp/stm32/libraries/HAL_Drivers/config/h7/spi_config.h | 5 +++++ bsp/stm32/libraries/HAL_Drivers/config/l1/spi_config.h | 3 +++ bsp/stm32/libraries/HAL_Drivers/config/l4/spi_config.h | 3 +++ bsp/stm32/libraries/HAL_Drivers/config/mp1/spi_config.h | 5 +++++ bsp/stm32/libraries/HAL_Drivers/config/wb/spi_config.h | 3 +++ bsp/stm32/libraries/HAL_Drivers/config/wl/spi_config.h | 3 +++ bsp/stm32/libraries/HAL_Drivers/drv_spi.c | 6 ++++++ bsp/stm32/libraries/HAL_Drivers/drv_spi.h | 1 + 15 files changed, 54 insertions(+) diff --git a/bsp/stm32/libraries/HAL_Drivers/config/f0/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/f0/spi_config.h index 79523e704d..39cda3c5dd 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/f0/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/f0/spi_config.h @@ -24,6 +24,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -56,6 +57,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/f1/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/f1/spi_config.h index bf28c2fc72..fb44c6145c 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/f1/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/f1/spi_config.h @@ -24,6 +24,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -56,6 +57,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -88,6 +90,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/f2/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/f2/spi_config.h index b3e9507b19..cfe1e252eb 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/f2/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/f2/spi_config.h @@ -24,6 +24,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -58,6 +59,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -92,6 +94,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/f4/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/f4/spi_config.h index d03b31ce8a..da3e05d8bd 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/f4/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/f4/spi_config.h @@ -24,6 +24,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -58,6 +59,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -92,6 +94,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ @@ -126,6 +129,7 @@ extern "C" { { \ .Instance = SPI4, \ .bus_name = "spi4", \ + .irq_type = SPI4_IRQn, \ } #endif /* SPI4_BUS_CONFIG */ #endif /* BSP_USING_SPI4 */ @@ -160,6 +164,7 @@ extern "C" { { \ .Instance = SPI5, \ .bus_name = "spi5", \ + .irq_type = SPI5_IRQn, \ } #endif /* SPI5_BUS_CONFIG */ #endif /* BSP_USING_SPI5 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/f7/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/f7/spi_config.h index 26f230d9b1..aab36015b9 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/f7/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/f7/spi_config.h @@ -23,6 +23,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -57,6 +58,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -91,6 +93,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ @@ -125,6 +128,7 @@ extern "C" { { \ .Instance = SPI4, \ .bus_name = "spi4", \ + .irq_type = SPI4_IRQn, \ } #endif /* SPI4_BUS_CONFIG */ #endif /* BSP_USING_SPI4 */ @@ -159,6 +163,7 @@ extern "C" { { \ .Instance = SPI5, \ .bus_name = "spi5", \ + .irq_type = SPI5_IRQn, \ } #endif /* SPI5_BUS_CONFIG */ #endif /* BSP_USING_SPI5 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/g0/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/g0/spi_config.h index a33777977a..a8f60fddbf 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/g0/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/g0/spi_config.h @@ -24,6 +24,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -58,6 +59,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/g4/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/g4/spi_config.h index d03b31ce8a..da3e05d8bd 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/g4/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/g4/spi_config.h @@ -24,6 +24,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -58,6 +59,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -92,6 +94,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ @@ -126,6 +129,7 @@ extern "C" { { \ .Instance = SPI4, \ .bus_name = "spi4", \ + .irq_type = SPI4_IRQn, \ } #endif /* SPI4_BUS_CONFIG */ #endif /* BSP_USING_SPI4 */ @@ -160,6 +164,7 @@ extern "C" { { \ .Instance = SPI5, \ .bus_name = "spi5", \ + .irq_type = SPI5_IRQn, \ } #endif /* SPI5_BUS_CONFIG */ #endif /* BSP_USING_SPI5 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/h7/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/h7/spi_config.h index 26f230d9b1..aab36015b9 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/h7/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/h7/spi_config.h @@ -23,6 +23,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -57,6 +58,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -91,6 +93,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ @@ -125,6 +128,7 @@ extern "C" { { \ .Instance = SPI4, \ .bus_name = "spi4", \ + .irq_type = SPI4_IRQn, \ } #endif /* SPI4_BUS_CONFIG */ #endif /* BSP_USING_SPI4 */ @@ -159,6 +163,7 @@ extern "C" { { \ .Instance = SPI5, \ .bus_name = "spi5", \ + .irq_type = SPI5_IRQn, \ } #endif /* SPI5_BUS_CONFIG */ #endif /* BSP_USING_SPI5 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/l1/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/l1/spi_config.h index bf28c2fc72..fb44c6145c 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/l1/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/l1/spi_config.h @@ -24,6 +24,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -56,6 +57,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -88,6 +90,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/l4/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/l4/spi_config.h index d510ca379d..16fab826d0 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/l4/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/l4/spi_config.h @@ -23,6 +23,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -57,6 +58,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -91,6 +93,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/mp1/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/mp1/spi_config.h index 3236751624..d1c6c44cc3 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/mp1/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/mp1/spi_config.h @@ -23,6 +23,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -57,6 +58,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -91,6 +93,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ @@ -125,6 +128,7 @@ extern "C" { { \ .Instance = SPI4, \ .bus_name = "spi4", \ + .irq_type = SPI4_IRQn, \ } #endif /* SPI4_BUS_CONFIG */ #endif /* BSP_USING_SPI4 */ @@ -159,6 +163,7 @@ extern "C" { { \ .Instance = SPI5, \ .bus_name = "spi5", \ + .irq_type = SPI5_IRQn, \ } #endif /* SPI5_BUS_CONFIG */ #endif /* BSP_USING_SPI5 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/wb/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/wb/spi_config.h index 0f37cfe2af..1704fcdfe1 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/wb/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/wb/spi_config.h @@ -23,6 +23,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -57,6 +58,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -91,6 +93,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/config/wl/spi_config.h b/bsp/stm32/libraries/HAL_Drivers/config/wl/spi_config.h index d510ca379d..64c8e23f07 100644 --- a/bsp/stm32/libraries/HAL_Drivers/config/wl/spi_config.h +++ b/bsp/stm32/libraries/HAL_Drivers/config/wl/spi_config.h @@ -23,6 +23,7 @@ extern "C" { { \ .Instance = SPI1, \ .bus_name = "spi1", \ + .irq_type = SPI1_IRQn, \ } #endif /* SPI1_BUS_CONFIG */ #endif /* BSP_USING_SPI1 */ @@ -57,6 +58,7 @@ extern "C" { { \ .Instance = SPI2, \ .bus_name = "spi2", \ + .irq_type = SPI2_IRQn, \ } #endif /* SPI2_BUS_CONFIG */ #endif /* BSP_USING_SPI2 */ @@ -91,6 +93,7 @@ extern "C" { { \ .Instance = SPI3, \ .bus_name = "spi3", \ + .irq_type = SPI3_IRQn, \ } #endif /* SPI3_BUS_CONFIG */ #endif /* BSP_USING_SPI3 */ diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_spi.c b/bsp/stm32/libraries/HAL_Drivers/drv_spi.c index a521e4bb83..44d2d0e418 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_spi.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_spi.c @@ -263,6 +263,12 @@ static rt_err_t stm32_spi_init(struct stm32_spi *spi_drv, struct rt_spi_configur HAL_NVIC_SetPriority(spi_drv->config->dma_tx->dma_irq, 0, 1); HAL_NVIC_EnableIRQ(spi_drv->config->dma_tx->dma_irq); } + + if(spi_drv->spi_dma_flag & SPI_USING_TX_DMA_FLAG || spi_drv->spi_dma_flag & SPI_USING_RX_DMA_FLAG) + { + HAL_NVIC_SetPriority(spi_drv->config->irq_type, 2, 0); + HAL_NVIC_EnableIRQ(spi_drv->config->irq_type); + } LOG_D("%s init done", spi_drv->config->bus_name); return RT_EOK; diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_spi.h b/bsp/stm32/libraries/HAL_Drivers/drv_spi.h index f30d97f777..65f752fc8a 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_spi.h +++ b/bsp/stm32/libraries/HAL_Drivers/drv_spi.h @@ -37,6 +37,7 @@ struct stm32_spi_config { SPI_TypeDef *Instance; char *bus_name; + IRQn_Type irq_type; struct dma_config *dma_rx, *dma_tx; };