C
Qt Quick Ultralite imagedecoder Example
/** ****************************************************************************** * @file JPEG/JPEG_DecodingFromFLASH_DMA/Src/stm32h7xx_hal_msp.c * @author MCD Application Team * @brief HAL MSP module for Cortex-M7. ****************************************************************************** * @attention * * Copyright (c) 2019 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" /** @addtogroup STM32H7xx_HAL_Examples * @{ */ /** @addtogroup JPEG_DecodingFromFLASH_DMA * @{ */ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ extern JPEG_HandleTypeDef JPEG_Handle; /** @defgroup HAL_MSP_Private_Functions * @{ */ /** * @brief JPEG MSP Initialization * This function configures the hardware resources used in this example: * - Peripheral's clock enable * - NVIC configuration for JPEG interrupt request enable * - DMA configuration for transmission request by peripheral * - NVIC configuration for DMA interrupt request enable * @param hjpeg: JPEG handle pointer * @retval None */ void HAL_JPEG_MspInit(JPEG_HandleTypeDef *hjpeg) { #ifdef USE_DMA_BASED_JPEG_DECODING static MDMA_HandleTypeDef hmdmaIn; static MDMA_HandleTypeDef hmdmaOut; /* Enable JPEG clock */ __HAL_RCC_JPGDECEN_CLK_ENABLE(); /* Enable MDMA clock */ __HAL_RCC_MDMA_CLK_ENABLE(); HAL_NVIC_SetPriority(JPEG_IRQn, 0x07, 0x0F); HAL_NVIC_EnableIRQ(JPEG_IRQn); /* Input MDMA */ /* Set the parameters to be configured */ hmdmaIn.Init.Priority = MDMA_PRIORITY_HIGH; hmdmaIn.Init.Endianness = MDMA_LITTLE_ENDIANNESS_PRESERVE; hmdmaIn.Init.SourceInc = MDMA_SRC_INC_BYTE; hmdmaIn.Init.DestinationInc = MDMA_DEST_INC_DISABLE; hmdmaIn.Init.SourceDataSize = MDMA_SRC_DATASIZE_BYTE; hmdmaIn.Init.DestDataSize = MDMA_DEST_DATASIZE_WORD; hmdmaIn.Init.DataAlignment = MDMA_DATAALIGN_PACKENABLE; hmdmaIn.Init.SourceBurst = MDMA_SOURCE_BURST_32BEATS; hmdmaIn.Init.DestBurst = MDMA_DEST_BURST_16BEATS; hmdmaIn.Init.SourceBlockAddressOffset = 0; hmdmaIn.Init.DestBlockAddressOffset = 0; /*Using JPEG Input FIFO Threshold as a trigger for the MDMA*/ hmdmaIn.Init.Request = MDMA_REQUEST_JPEG_INFIFO_TH; /* Set the MDMA HW trigger to JPEG Input FIFO Threshold flag*/ hmdmaIn.Init.TransferTriggerMode = MDMA_BUFFER_TRANSFER; hmdmaIn.Init.BufferTransferLength = 32; /*Set the MDMA buffer size to the JPEG FIFO threshold size i.e 32 bytes (8 words)*/ hmdmaIn.Instance = MDMA_Channel7; /* Associate the DMA handle */ __HAL_LINKDMA(hjpeg, hdmain, hmdmaIn); /* DeInitialize the DMA Stream */ HAL_MDMA_DeInit(&hmdmaIn); /* Initialize the DMA stream */ HAL_MDMA_Init(&hmdmaIn); /* Output MDMA */ /* Set the parameters to be configured */ hmdmaOut.Init.Priority = MDMA_PRIORITY_VERY_HIGH; hmdmaOut.Init.Endianness = MDMA_LITTLE_ENDIANNESS_PRESERVE; hmdmaOut.Init.SourceInc = MDMA_SRC_INC_DISABLE; hmdmaOut.Init.DestinationInc = MDMA_DEST_INC_BYTE; hmdmaOut.Init.SourceDataSize = MDMA_SRC_DATASIZE_WORD; hmdmaOut.Init.DestDataSize = MDMA_DEST_DATASIZE_BYTE; hmdmaOut.Init.DataAlignment = MDMA_DATAALIGN_PACKENABLE; hmdmaOut.Init.SourceBurst = MDMA_SOURCE_BURST_32BEATS; hmdmaOut.Init.DestBurst = MDMA_DEST_BURST_32BEATS; hmdmaOut.Init.SourceBlockAddressOffset = 0; hmdmaOut.Init.DestBlockAddressOffset = 0; /*Using JPEG Output FIFO Threshold as a trigger for the MDMA*/ hmdmaOut.Init.Request = MDMA_REQUEST_JPEG_OUTFIFO_TH; /* Set the MDMA HW trigger to JPEG Output FIFO Threshold flag*/ hmdmaOut.Init.TransferTriggerMode = MDMA_BUFFER_TRANSFER; hmdmaOut.Init.BufferTransferLength = 32; /*Set the MDMA buffer size to the JPEG FIFO threshold size i.e 32 bytes (8 words)*/ hmdmaOut.Instance = MDMA_Channel6; /* DeInitialize the DMA Stream */ HAL_MDMA_DeInit(&hmdmaOut); /* Initialize the DMA stream */ HAL_MDMA_Init(&hmdmaOut); /* Associate the DMA handle */ __HAL_LINKDMA(hjpeg, hdmaout, hmdmaOut); HAL_NVIC_SetPriority(MDMA_IRQn, 0x08, 0x0F); HAL_NVIC_EnableIRQ(MDMA_IRQn); #else /* Enable JPEG clock */ __HAL_RCC_JPGDECEN_CLK_ENABLE(); HAL_NVIC_SetPriority(JPEG_IRQn, 0x07, 0x0F); HAL_NVIC_EnableIRQ(JPEG_IRQn); #endif } void HAL_JPEG_MspDeInit(JPEG_HandleTypeDef *hjpeg) { #ifdef USE_DMA_BASED_JPEG_DECODING HAL_NVIC_DisableIRQ(MDMA_IRQn); /* DeInitialize the MDMA Stream */ HAL_MDMA_DeInit(hjpeg->hdmain); /* DeInitialize the MDMA Stream */ HAL_MDMA_DeInit(hjpeg->hdmaout); #endif } #ifdef USE_DMA_BASED_JPEG_DECODING void MDMA_IRQHandler() { /* Check the interrupt and clear flag */ HAL_MDMA_IRQHandler(JPEG_Handle.hdmain); HAL_MDMA_IRQHandler(JPEG_Handle.hdmaout); } #endif /** * @} */ void JPEG_IRQHandler(void) { HAL_JPEG_IRQHandler(&JPEG_Handle); }