From 491062cac6dcbfcddfdd5e8d3ba7348cb03ceda8 Mon Sep 17 00:00:00 2001 From: Attila BODY Date: Tue, 19 Nov 2019 12:47:07 +0100 Subject: [PATCH] Checkpoint --- .cproject | 4 -- .mxproject | 2 +- Inc/main.h | 16 ++--- Inc/spi.h | 1 - Inc/stm32f4xx_it.h | 3 - Src/gpio.c | 4 +- Src/spi.c | 82 ----------------------- Src/stm32f4xx_it.c | 41 ------------ components/f4ll_c/inc/crc_handler.h | 10 +-- components/f4ll_c/src/crc_handler.c | 34 +++++++++- components/f4ll_c/src/usart_handler.c | 4 ++ f407ve_hs_uart Release.launch | 21 ++++-- f407ve_hs_uart.ioc | 94 ++++++++------------------- 13 files changed, 95 insertions(+), 221 deletions(-) diff --git a/.cproject b/.cproject index 1c9221e..53724ca 100644 --- a/.cproject +++ b/.cproject @@ -40,7 +40,6 @@ - diff --git a/.mxproject b/.mxproject index f528bd6..c7f69c8 100644 --- a/.mxproject +++ b/.mxproject @@ -10,7 +10,7 @@ LibFiles=Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h;Drivers/STM32F4xx_ [PreviousUsedCubeIDEFiles] SourceFiles=Src/main.c;Src/gpio.c;Src/crc.c;Src/dma.c;Src/bsp_driver_sd.c;Src/sd_diskio.c;Src/fatfs.c;Src/fsmc.c;Src/sdio.c;Src/spi.c;Src/sys.c;Src/usart.c;Src/usb_otg.c;Src/stm32f4xx_it.c;Src/stm32f4xx_hal_msp.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_crc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_utils.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_spi.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usart.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/Third_Party/FatFs/src/option/ccsbcs.c;Src/system_stm32f4xx.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_crc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_utils.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_spi.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usart.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/Third_Party/FatFs/src/option/ccsbcs.c;Src/system_stm32f4xx.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/Third_Party/FatFs/src/option/ccsbcs.c; HeaderPath=Drivers/STM32F4xx_HAL_Driver/Inc;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;Middlewares/Third_Party/FatFs/src;Drivers/CMSIS/Device/ST/STM32F4xx/Include;Drivers/CMSIS/Include;Inc; -CDefines=USE_FULL_LL_DRIVER;USE_HAL_DRIVER;STM32F407xx;USE_HAL_DRIVER;USE_HAL_DRIVER; +CDefines=USE_FULL_LL_DRIVER;USE_HAL_DRIVER;STM32F407xx;USE_FULL_LL_DRIVER;USE_HAL_DRIVER;USE_HAL_DRIVER; [PreviousUsedMakefileFiles] SourceFiles=Src/main.c;Src/gpio.c;Src/crc.c;Src/dma.c;Src/bsp_driver_sd.c;Src/sd_diskio.c;Src/fatfs.c;Src/fsmc.c;Src/sdio.c;Src/spi.c;Src/usart.c;Src/usb_otg.c;Src/stm32f4xx_it.c;Src/stm32f4xx_hal_msp.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_crc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_spi.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usart.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_utils.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_exti.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/Third_Party/FatFs/src/option/ccsbcs.c;Src/system_stm32f4xx.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_crc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_fsmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sram.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_sdmmc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_sd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_spi.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usart.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pcd_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_utils.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_exti.c;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/Third_Party/FatFs/src/option/ccsbcs.c;Src/system_stm32f4xx.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;null;Middlewares/Third_Party/FatFs/src/diskio.c;Middlewares/Third_Party/FatFs/src/ff.c;Middlewares/Third_Party/FatFs/src/ff_gen_drv.c;Middlewares/Third_Party/FatFs/src/option/syscall.c;Middlewares/Third_Party/FatFs/src/option/ccsbcs.c; diff --git a/Inc/main.h b/Inc/main.h index 8a3a06d..e903533 100644 --- a/Inc/main.h +++ b/Inc/main.h @@ -76,14 +76,14 @@ void Error_Handler(void); #define KEY1_GPIO_Port GPIOE #define KEY0_Pin LL_GPIO_PIN_4 #define KEY0_GPIO_Port GPIOE -#define DEBUG0_Pin LL_GPIO_PIN_0 -#define DEBUG0_GPIO_Port GPIOC -#define DEBUG1_Pin LL_GPIO_PIN_1 -#define DEBUG1_GPIO_Port GPIOC -#define DEBUG2_Pin LL_GPIO_PIN_2 -#define DEBUG2_GPIO_Port GPIOC -#define DEBUG3_Pin LL_GPIO_PIN_3 -#define DEBUG3_GPIO_Port GPIOC +#define DBG0_Pin LL_GPIO_PIN_0 +#define DBG0_GPIO_Port GPIOC +#define DBG1_Pin LL_GPIO_PIN_1 +#define DBG1_GPIO_Port GPIOC +#define DBG2_Pin LL_GPIO_PIN_2 +#define DBG2_GPIO_Port GPIOC +#define DBG3_Pin LL_GPIO_PIN_3 +#define DBG3_GPIO_Port GPIOC #define LED0_Pin LL_GPIO_PIN_6 #define LED0_GPIO_Port GPIOA #define LED1_Pin LL_GPIO_PIN_7 diff --git a/Inc/spi.h b/Inc/spi.h index f967914..23e20ec 100644 --- a/Inc/spi.h +++ b/Inc/spi.h @@ -34,7 +34,6 @@ /* USER CODE END Private defines */ -void MX_SPI1_Init(void); void MX_SPI2_Init(void); /* USER CODE BEGIN Prototypes */ diff --git a/Inc/stm32f4xx_it.h b/Inc/stm32f4xx_it.h index 837a10f..b7931fe 100644 --- a/Inc/stm32f4xx_it.h +++ b/Inc/stm32f4xx_it.h @@ -62,18 +62,15 @@ void DMA1_Stream3_IRQHandler(void); void DMA1_Stream4_IRQHandler(void); void DMA1_Stream5_IRQHandler(void); void DMA1_Stream6_IRQHandler(void); -void SPI1_IRQHandler(void); void SPI2_IRQHandler(void); void USART1_IRQHandler(void); void USART2_IRQHandler(void); void USART3_IRQHandler(void); void UART4_IRQHandler(void); -void DMA2_Stream0_IRQHandler(void); void DMA2_Stream1_IRQHandler(void); void DMA2_Stream2_IRQHandler(void); void DMA2_Stream3_IRQHandler(void); void DMA2_Stream4_IRQHandler(void); -void DMA2_Stream5_IRQHandler(void); void DMA2_Stream6_IRQHandler(void); void DMA2_Stream7_IRQHandler(void); void USART6_IRQHandler(void); diff --git a/Src/gpio.c b/Src/gpio.c index 9df4d24..5c7b265 100644 --- a/Src/gpio.c +++ b/Src/gpio.c @@ -51,7 +51,7 @@ void MX_GPIO_Init(void) LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOD); /**/ - LL_GPIO_ResetOutputPin(GPIOC, DEBUG0_Pin|DEBUG1_Pin|DEBUG2_Pin|DEBUG3_Pin); + LL_GPIO_ResetOutputPin(GPIOC, DBG0_Pin|DBG1_Pin|DBG2_Pin|DBG3_Pin); /**/ LL_GPIO_ResetOutputPin(GPIOA, LED0_Pin|LED1_Pin); @@ -66,7 +66,7 @@ void MX_GPIO_Init(void) LL_GPIO_Init(GPIOE, &GPIO_InitStruct); /**/ - GPIO_InitStruct.Pin = DEBUG0_Pin|DEBUG1_Pin|DEBUG2_Pin|DEBUG3_Pin; + GPIO_InitStruct.Pin = DBG0_Pin|DBG1_Pin|DBG2_Pin|DBG3_Pin; GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; diff --git a/Src/spi.c b/Src/spi.c index 7ba49eb..0ff817c 100644 --- a/Src/spi.c +++ b/Src/spi.c @@ -24,88 +24,6 @@ /* USER CODE END 0 */ -/* SPI1 init function */ -void MX_SPI1_Init(void) -{ - LL_SPI_InitTypeDef SPI_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* Peripheral clock enable */ - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SPI1); - - LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB); - /**SPI1 GPIO Configuration - PB3 ------> SPI1_SCK - PB4 ------> SPI1_MISO - PB5 ------> SPI1_MOSI - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_5; - LL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* SPI1 DMA Init */ - - /* SPI1_RX Init */ - LL_DMA_SetChannelSelection(DMA2, LL_DMA_STREAM_0, LL_DMA_CHANNEL_3); - - LL_DMA_SetDataTransferDirection(DMA2, LL_DMA_STREAM_0, LL_DMA_DIRECTION_PERIPH_TO_MEMORY); - - LL_DMA_SetStreamPriorityLevel(DMA2, LL_DMA_STREAM_0, LL_DMA_PRIORITY_LOW); - - LL_DMA_SetMode(DMA2, LL_DMA_STREAM_0, LL_DMA_MODE_NORMAL); - - LL_DMA_SetPeriphIncMode(DMA2, LL_DMA_STREAM_0, LL_DMA_PERIPH_NOINCREMENT); - - LL_DMA_SetMemoryIncMode(DMA2, LL_DMA_STREAM_0, LL_DMA_MEMORY_INCREMENT); - - LL_DMA_SetPeriphSize(DMA2, LL_DMA_STREAM_0, LL_DMA_PDATAALIGN_BYTE); - - LL_DMA_SetMemorySize(DMA2, LL_DMA_STREAM_0, LL_DMA_MDATAALIGN_BYTE); - - LL_DMA_DisableFifoMode(DMA2, LL_DMA_STREAM_0); - - /* SPI1_TX Init */ - LL_DMA_SetChannelSelection(DMA2, LL_DMA_STREAM_5, LL_DMA_CHANNEL_3); - - LL_DMA_SetDataTransferDirection(DMA2, LL_DMA_STREAM_5, LL_DMA_DIRECTION_MEMORY_TO_PERIPH); - - LL_DMA_SetStreamPriorityLevel(DMA2, LL_DMA_STREAM_5, LL_DMA_PRIORITY_LOW); - - LL_DMA_SetMode(DMA2, LL_DMA_STREAM_5, LL_DMA_MODE_NORMAL); - - LL_DMA_SetPeriphIncMode(DMA2, LL_DMA_STREAM_5, LL_DMA_PERIPH_NOINCREMENT); - - LL_DMA_SetMemoryIncMode(DMA2, LL_DMA_STREAM_5, LL_DMA_MEMORY_INCREMENT); - - LL_DMA_SetPeriphSize(DMA2, LL_DMA_STREAM_5, LL_DMA_PDATAALIGN_BYTE); - - LL_DMA_SetMemorySize(DMA2, LL_DMA_STREAM_5, LL_DMA_MDATAALIGN_BYTE); - - LL_DMA_DisableFifoMode(DMA2, LL_DMA_STREAM_5); - - /* SPI1 interrupt Init */ - NVIC_SetPriority(SPI1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); - NVIC_EnableIRQ(SPI1_IRQn); - - SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX; - SPI_InitStruct.Mode = LL_SPI_MODE_MASTER; - SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT; - SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW; - SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE; - SPI_InitStruct.NSS = LL_SPI_NSS_SOFT; - SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV2; - SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST; - SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE; - SPI_InitStruct.CRCPoly = 10; - LL_SPI_Init(SPI1, &SPI_InitStruct); - LL_SPI_SetStandard(SPI1, LL_SPI_PROTOCOL_MOTOROLA); - -} /* SPI2 init function */ void MX_SPI2_Init(void) { diff --git a/Src/stm32f4xx_it.c b/Src/stm32f4xx_it.c index 94014ea..c010cad 100644 --- a/Src/stm32f4xx_it.c +++ b/Src/stm32f4xx_it.c @@ -326,19 +326,6 @@ void DMA1_Stream6_IRQHandler(void) /* USER CODE END DMA1_Stream6_IRQn 1 */ } -/** - * @brief This function handles SPI1 global interrupt. - */ -void SPI1_IRQHandler(void) -{ - /* USER CODE BEGIN SPI1_IRQn 0 */ - - /* USER CODE END SPI1_IRQn 0 */ - /* USER CODE BEGIN SPI1_IRQn 1 */ - - /* USER CODE END SPI1_IRQn 1 */ -} - /** * @brief This function handles SPI2 global interrupt. */ @@ -420,20 +407,6 @@ void UART4_IRQHandler(void) /* USER CODE END UART4_IRQn 1 */ } -/** - * @brief This function handles DMA2 stream0 global interrupt. - */ -void DMA2_Stream0_IRQHandler(void) -{ - /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ - - /* USER CODE END DMA2_Stream0_IRQn 0 */ - - /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ - - /* USER CODE END DMA2_Stream0_IRQn 1 */ -} - /** * @brief This function handles DMA2 stream1 global interrupt. */ @@ -506,20 +479,6 @@ void DMA2_Stream4_IRQHandler(void) /* USER CODE END DMA2_Stream4_IRQn 1 */ } -/** - * @brief This function handles DMA2 stream5 global interrupt. - */ -void DMA2_Stream5_IRQHandler(void) -{ - /* USER CODE BEGIN DMA2_Stream5_IRQn 0 */ - - /* USER CODE END DMA2_Stream5_IRQn 0 */ - - /* USER CODE BEGIN DMA2_Stream5_IRQn 1 */ - - /* USER CODE END DMA2_Stream5_IRQn 1 */ -} - /** * @brief This function handles DMA2 stream6 global interrupt. */ diff --git a/components/f4ll_c/inc/crc_handler.h b/components/f4ll_c/inc/crc_handler.h index 4777e8f..a24e4c0 100644 --- a/components/f4ll_c/inc/crc_handler.h +++ b/components/f4ll_c/inc/crc_handler.h @@ -21,10 +21,10 @@ #endif struct crcslottask_t { - void *address; + void * volatile address; uint16_t wordCount; - void (*callback)(void*, uint32_t, uint8_t); - void *callbackParam; + void (* volatile callback)(void*, uint32_t, uint8_t); + void * volatile callbackParam; }; struct crcslotlistitem_t { @@ -35,8 +35,8 @@ struct crcslotlistitem_t { struct crcstatus_t { DMAINFO dmaInfo; - volatile struct crcslotlistitem_t *activeSlot; - volatile uint8_t activeTask; + struct crcslotlistitem_t * volatile activeSlot; + uint8_t volatile activeTask; struct crcslotlistitem_t *first; }; diff --git a/components/f4ll_c/src/crc_handler.c b/components/f4ll_c/src/crc_handler.c index 33639fe..5d0e5f0 100644 --- a/components/f4ll_c/src/crc_handler.c +++ b/components/f4ll_c/src/crc_handler.c @@ -4,6 +4,7 @@ * Created on: Aug 29, 2019 * Author: abody */ +#include "main.h" #include #include #include "diag.h" @@ -26,6 +27,17 @@ # define DIAG_INTERRUPT_OUT() #endif +#define SLOTHITORYSIZE 8192 + +typedef struct crcstatus_t * CRCSTATUSPTR; +typedef struct crcslotlistitem_t * CRCSLOTPTR; + +CRCSLOTPTR slot0History[SLOTHITORYSIZE]; +CRCSLOTPTR slot1History[SLOTHITORYSIZE]; +CRCSLOTPTR *slotHistoryPtrs[2] = { slot0History, slot1History }; +uint32_t slotIndexes[2] = {0, 0}; + +uint32_t volatile spuriousCount = 0; void InitCrcStatus(struct crcstatus_t *st, DMA_TypeDef *dma, uint32_t stream) { @@ -71,15 +83,19 @@ uint8_t EnqueueCrcTask(struct crcstatus_t *status, struct crcslotlistitem_t *slo uint32_t prim = __get_PRIMASK(); uint16_t need_start; - while(status->activeSlot == slot); + LL_GPIO_SetOutputPin(DBG0_GPIO_Port, task ? DBG1_Pin : DBG0_Pin); + + while(status->activeSlot == slot && status->activeTask == task); __disable_irq(); need_start = (status->activeSlot == NULL); slot->tasks[task].address = need_start ? NULL : address; slot->tasks[task].wordCount = (len+3)/4; slot->tasks[task].callback = callback; slot->tasks[task].callbackParam = callbackParam; - if(need_start) + if(need_start) { status->activeSlot = slot; + status->activeTask = task; + } __set_PRIMASK(prim); if(need_start) { @@ -89,6 +105,7 @@ uint8_t EnqueueCrcTask(struct crcstatus_t *status, struct crcslotlistitem_t *slo DIAG_CRC_CALC_START(); LL_DMA_EnableStream(status->dmaInfo.dma, status->dmaInfo.stream); } + LL_GPIO_ResetOutputPin(DBG0_GPIO_Port, task ? DBG1_Pin : DBG0_Pin); return need_start; } @@ -142,11 +159,17 @@ static void StartNextCrcTask(struct crcstatus_t *status) void HandleCrcDmaIrq(struct crcstatus_t *status) { + LL_GPIO_SetOutputPin(DBG0_GPIO_Port, DBG2_Pin); + DIAG_INTERRUPT_IN(); if(*status->dmaInfo.isReg & status->dmaInfo.tcMask) { // DMA transfer complete *status->dmaInfo.ifcReg = status->dmaInfo.tcMask; LL_DMA_DisableStream(status->dmaInfo.dma, status->dmaInfo.stream); if(status->activeSlot) { + +// (slotHistoryPtrs[status->activeTask][slotIndexes[status->activeTask]++]) = status->activeSlot; +// while(slotIndexes[status->activeTask] >= SLOTHITORYSIZE); + struct crcslottask_t *tsk = &status->activeSlot->tasks[status->activeTask]; if(tsk->callback) tsk->callback(tsk->callbackParam, CRC->DR, 1); @@ -171,6 +194,13 @@ void HandleCrcDmaIrq(struct crcstatus_t *status) StartNextCrcTask(status); } } + else + { + ++spuriousCount; + } + DIAG_INTERRUPT_OUT(); + + LL_GPIO_ResetOutputPin(DBG0_GPIO_Port, DBG2_Pin); } diff --git a/components/f4ll_c/src/usart_handler.c b/components/f4ll_c/src/usart_handler.c index 6336553..8c6f113 100644 --- a/components/f4ll_c/src/usart_handler.c +++ b/components/f4ll_c/src/usart_handler.c @@ -105,9 +105,13 @@ static inline uint8_t CheckHeader(USARTPACKET *packet) uint8_t PostPacket(USARTSTATUS *status, uint8_t const *payload, uint16_t length, struct crcstatus_t *crcStatus, uint8_t waitForCrcQueue) { +// static uint32_t count = 0; +// ITM->PORT[1].u32 = count++; + if(length > 256) return 1; + BuildHeader(&status->txBuffer, status->txSerial++, length); uint16_t payloadLength = RoundUpTo4(length); if(payload) diff --git a/f407ve_hs_uart Release.launch b/f407ve_hs_uart Release.launch index 624f9d8..013f8ac 100644 --- a/f407ve_hs_uart Release.launch +++ b/f407ve_hs_uart Release.launch @@ -2,7 +2,7 @@ - + @@ -13,9 +13,9 @@ - - - + + + @@ -29,6 +29,15 @@ + + + + + + + + + @@ -39,7 +48,7 @@ - + @@ -47,7 +56,7 @@ - + diff --git a/f407ve_hs_uart.ioc b/f407ve_hs_uart.ioc index 978d846..2c405d8 100644 --- a/f407ve_hs_uart.ioc +++ b/f407ve_hs_uart.ioc @@ -29,8 +29,6 @@ Dma.Request0=USART3_RX Dma.Request1=USART3_TX Dma.Request10=UART4_RX Dma.Request11=UART4_TX -Dma.Request12=SPI1_RX -Dma.Request13=SPI1_TX Dma.Request2=USART2_RX Dma.Request3=USART2_TX Dma.Request4=USART1_RX @@ -39,27 +37,7 @@ Dma.Request6=USART6_RX Dma.Request7=USART6_TX Dma.Request8=MEMTOMEM Dma.Request9=MEMTOMEM -Dma.RequestsNb=14 -Dma.SPI1_RX.12.Direction=DMA_PERIPH_TO_MEMORY -Dma.SPI1_RX.12.FIFOMode=DMA_FIFOMODE_DISABLE -Dma.SPI1_RX.12.Instance=DMA2_Stream0 -Dma.SPI1_RX.12.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.SPI1_RX.12.MemInc=DMA_MINC_ENABLE -Dma.SPI1_RX.12.Mode=DMA_NORMAL -Dma.SPI1_RX.12.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.SPI1_RX.12.PeriphInc=DMA_PINC_DISABLE -Dma.SPI1_RX.12.Priority=DMA_PRIORITY_LOW -Dma.SPI1_RX.12.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode -Dma.SPI1_TX.13.Direction=DMA_MEMORY_TO_PERIPH -Dma.SPI1_TX.13.FIFOMode=DMA_FIFOMODE_DISABLE -Dma.SPI1_TX.13.Instance=DMA2_Stream5 -Dma.SPI1_TX.13.MemDataAlignment=DMA_MDATAALIGN_BYTE -Dma.SPI1_TX.13.MemInc=DMA_MINC_ENABLE -Dma.SPI1_TX.13.Mode=DMA_NORMAL -Dma.SPI1_TX.13.PeriphDataAlignment=DMA_PDATAALIGN_BYTE -Dma.SPI1_TX.13.PeriphInc=DMA_PINC_DISABLE -Dma.SPI1_TX.13.Priority=DMA_PRIORITY_LOW -Dma.SPI1_TX.13.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode +Dma.RequestsNb=12 Dma.UART4_RX.10.Direction=DMA_PERIPH_TO_MEMORY Dma.UART4_RX.10.FIFOMode=DMA_FIFOMODE_DISABLE Dma.UART4_RX.10.Instance=DMA1_Stream2 @@ -172,21 +150,20 @@ KeepUserPlacement=false Mcu.Family=STM32F4 Mcu.IP0=CRC Mcu.IP1=DMA -Mcu.IP10=UART4 -Mcu.IP11=USART1 -Mcu.IP12=USART2 -Mcu.IP13=USART3 -Mcu.IP14=USART6 -Mcu.IP15=USB_OTG_FS +Mcu.IP10=USART1 +Mcu.IP11=USART2 +Mcu.IP12=USART3 +Mcu.IP13=USART6 +Mcu.IP14=USB_OTG_FS Mcu.IP2=FATFS Mcu.IP3=FSMC Mcu.IP4=NVIC Mcu.IP5=RCC Mcu.IP6=SDIO -Mcu.IP7=SPI1 -Mcu.IP8=SPI2 -Mcu.IP9=SYS -Mcu.IPNb=16 +Mcu.IP7=SPI2 +Mcu.IP8=SYS +Mcu.IP9=UART4 +Mcu.IPNb=15 Mcu.Name=STM32F407V(E-G)Tx Mcu.Package=LQFP100 Mcu.Pin0=PE3 @@ -243,19 +220,17 @@ Mcu.Pin54=PD4 Mcu.Pin55=PD5 Mcu.Pin56=PD7 Mcu.Pin57=PB3 -Mcu.Pin58=PB4 -Mcu.Pin59=PB5 +Mcu.Pin58=PB6 +Mcu.Pin59=PB7 Mcu.Pin6=PC0 -Mcu.Pin60=PB6 -Mcu.Pin61=PB7 -Mcu.Pin62=PB8 -Mcu.Pin63=VP_CRC_VS_CRC -Mcu.Pin64=VP_FATFS_VS_SDIO -Mcu.Pin65=VP_SYS_VS_Systick +Mcu.Pin60=PB8 +Mcu.Pin61=VP_CRC_VS_CRC +Mcu.Pin62=VP_FATFS_VS_SDIO +Mcu.Pin63=VP_SYS_VS_Systick Mcu.Pin7=PC1 Mcu.Pin8=PC2 Mcu.Pin9=PC3 -Mcu.PinsNb=66 +Mcu.PinsNb=64 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F407VETx @@ -268,14 +243,12 @@ NVIC.DMA1_Stream3_IRQn=true\:1\:0\:true\:false\:true\:false\:true NVIC.DMA1_Stream4_IRQn=true\:1\:0\:true\:false\:true\:false\:true NVIC.DMA1_Stream5_IRQn=true\:1\:0\:true\:false\:true\:false\:true NVIC.DMA1_Stream6_IRQn=true\:1\:0\:true\:false\:true\:false\:true -NVIC.DMA2_Stream0_IRQn=true\:1\:0\:true\:false\:true\:true\:true NVIC.DMA2_Stream1_IRQn=true\:1\:0\:true\:false\:true\:false\:true NVIC.DMA2_Stream2_IRQn=true\:1\:0\:true\:false\:true\:false\:true NVIC.DMA2_Stream3_IRQn=true\:0\:0\:false\:false\:true\:true\:true NVIC.DMA2_Stream4_IRQn=true\:0\:0\:false\:false\:true\:true\:true -NVIC.DMA2_Stream5_IRQn=true\:0\:0\:false\:false\:true\:false\:true -NVIC.DMA2_Stream6_IRQn=true\:0\:0\:false\:false\:true\:false\:true -NVIC.DMA2_Stream7_IRQn=true\:0\:0\:false\:false\:true\:false\:true +NVIC.DMA2_Stream6_IRQn=true\:1\:0\:true\:false\:true\:false\:true +NVIC.DMA2_Stream7_IRQn=true\:1\:0\:true\:false\:true\:false\:true NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.ForceEnableDMAVector=true NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false @@ -283,7 +256,6 @@ NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SPI1_IRQn=true\:0\:0\:false\:false\:true\:true\:true NVIC.SPI2_IRQn=true\:0\:0\:false\:false\:true\:true\:true NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true @@ -303,9 +275,9 @@ PA11.Mode=Device_Only PA11.Signal=USB_OTG_FS_DM PA12.Mode=Device_Only PA12.Signal=USB_OTG_FS_DP -PA13.Mode=Serial_Wire +PA13.Mode=Trace_Asynchronous_SW PA13.Signal=SYS_JTMS-SWDIO -PA14.Mode=Serial_Wire +PA14.Mode=Trace_Asynchronous_SW PA14.Signal=SYS_JTCK-SWCLK PA2.Mode=Asynchronous PA2.Signal=USART2_TX @@ -342,13 +314,8 @@ PB14.Signal=SPI2_MISO PB15.Locked=true PB15.Mode=Full_Duplex_Master PB15.Signal=SPI2_MOSI -PB3.Locked=true -PB3.Mode=Full_Duplex_Master -PB3.Signal=SPI1_SCK -PB4.Mode=Full_Duplex_Master -PB4.Signal=SPI1_MISO -PB5.Mode=Full_Duplex_Master -PB5.Signal=SPI1_MOSI +PB3.Mode=Trace_Asynchronous_SW +PB3.Signal=SYS_JTDO-SWO PB6.GPIOParameters=GPIO_Label PB6.GPIO_Label=NRF_CE PB6.Locked=true @@ -362,11 +329,11 @@ PB8.GPIO_Label=NRF_IRQ PB8.Locked=true PB8.Signal=GPIO_Input PC0.GPIOParameters=GPIO_Label -PC0.GPIO_Label=DEBUG0 +PC0.GPIO_Label=DBG0 PC0.Locked=true PC0.Signal=GPIO_Output PC1.GPIOParameters=GPIO_Label -PC1.GPIO_Label=DEBUG1 +PC1.GPIO_Label=DBG1 PC1.Locked=true PC1.Signal=GPIO_Output PC10.Mode=SD_4_bits_Wide_bus @@ -380,11 +347,11 @@ PC14-OSC32_IN.Signal=RCC_OSC32_IN PC15-OSC32_OUT.Mode=LSE-External-Oscillator PC15-OSC32_OUT.Signal=RCC_OSC32_OUT PC2.GPIOParameters=GPIO_Label -PC2.GPIO_Label=DEBUG2 +PC2.GPIO_Label=DBG2 PC2.Locked=true PC2.Signal=GPIO_Output PC3.GPIOParameters=GPIO_Label -PC3.GPIO_Label=DEBUG3 +PC3.GPIO_Label=DBG3 PC3.Locked=true PC3.Signal=GPIO_Output PC6.Mode=Asynchronous @@ -486,7 +453,7 @@ ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=true -ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-LL-true,2-MX_DMA_Init-DMA-false-LL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_UART4_Init-UART4-false-LL-true,5-MX_USART1_UART_Init-USART1-false-LL-true,6-MX_USART2_UART_Init-USART2-false-LL-true,7-MX_USART3_UART_Init-USART3-false-LL-true,8-MX_USART6_UART_Init-USART6-false-LL-true,9-MX_CRC_Init-CRC-false-LL-true,10-MX_FSMC_Init-FSMC-true-HAL-true,11-MX_SDIO_SD_Init-SDIO-true-HAL-true,12-MX_SPI1_Init-SPI1-true-LL-true,13-MX_SPI2_Init-SPI2-true-LL-true,14-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-true-HAL-true,15-MX_FATFS_Init-FATFS-true-HAL-false +ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-LL-true,2-MX_DMA_Init-DMA-false-LL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_UART4_Init-UART4-false-LL-true,5-MX_USART1_UART_Init-USART1-false-LL-true,6-MX_USART2_UART_Init-USART2-false-LL-true,7-MX_USART3_UART_Init-USART3-false-LL-true,8-MX_USART6_UART_Init-USART6-false-LL-true,9-MX_CRC_Init-CRC-false-LL-true,10-MX_FSMC_Init-FSMC-true-HAL-true,11-MX_SDIO_SD_Init-SDIO-true-HAL-true,12-MX_SPI2_Init-SPI2-true-LL-true,13-MX_USB_OTG_FS_PCD_Init-USB_OTG_FS-true-HAL-true,14-MX_FATFS_Init-FATFS-true-HAL-false RCC.48MHZClocksFreq_Value=48000000 RCC.AHBFreq_Value=168000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 @@ -520,11 +487,6 @@ RCC.VCOI2SOutputFreq_Value=384000000 RCC.VCOInputFreq_Value=2000000 RCC.VCOOutputFreq_Value=336000000 RCC.VcooutputI2S=192000000 -SPI1.CalculateBaudRate=42.0 MBits/s -SPI1.Direction=SPI_DIRECTION_2LINES -SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate -SPI1.Mode=SPI_MODE_MASTER -SPI1.VirtualType=VM_MASTER SPI2.CalculateBaudRate=21.0 MBits/s SPI2.Direction=SPI_DIRECTION_2LINES SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate