/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * *

© Copyright (c) 2020 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "cmsis_os.h" #include "stm32f7xx_hal_pcd.h" #include "stm32f7xx_hal_pcd.c" #include "app_touchgfx.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include #include /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ typedef StaticSemaphore_t osStaticMutexDef_t; /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ #define REFRESH_COUNT 1835 #define HAL_PCD_MODULE_ENABLED #define SDRAM_TIMEOUT ((uint32_t)0xFFFF) #define SDRAM_MODEREG_BURST_LENGTH_1 ((uint16_t)0x0000) #define SDRAM_MODEREG_BURST_LENGTH_2 ((uint16_t)0x0001) #define SDRAM_MODEREG_BURST_LENGTH_4 ((uint16_t)0x0002) #define SDRAM_MODEREG_BURST_LENGTH_8 ((uint16_t)0x0004) #define SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL ((uint16_t)0x0000) #define SDRAM_MODEREG_BURST_TYPE_INTERLEAVED ((uint16_t)0x0008) #define SDRAM_MODEREG_CAS_LATENCY_2 ((uint16_t)0x0020) #define SDRAM_MODEREG_CAS_LATENCY_3 ((uint16_t)0x0030) #define SDRAM_MODEREG_OPERATING_MODE_STANDARD ((uint16_t)0x0000) #define SDRAM_MODEREG_WRITEBURST_MODE_PROGRAMMED ((uint16_t)0x0000) #define SDRAM_MODEREG_WRITEBURST_MODE_SINGLE ((uint16_t)0x0200) #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #define STATIC_HEAP_SIZE (1024) #define ALIGN_FLOOR(addr, type) (((uint32_t)(addr)) & ~(uint32_t)(sizeof(type)-1)) #define ALIGN_CEIL(addr, type) ALIGN_FLOOR((uint32_t)(addr) + sizeof(type) - 1, type) /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ CRC_HandleTypeDef hcrc; DCMI_HandleTypeDef hdcmi; DMA_HandleTypeDef hdma_dcmi; DMA2D_HandleTypeDef hdma2d; I2C_HandleTypeDef hi2c1; I2C_HandleTypeDef hi2c3; LTDC_HandleTypeDef hltdc; QSPI_HandleTypeDef hqspi; TIM_HandleTypeDef htim1; TIM_HandleTypeDef htim2; UART_HandleTypeDef huart1; DMA_HandleTypeDef hdma_memtomem_dma2_stream0; SDRAM_HandleTypeDef hsdram1; PCD_HandleTypeDef hpcd; /* Definitions for ESP_LPW */ osThreadId_t ESP_LPWHandle; const osThreadAttr_t ESP_LPW_attributes = { .name = "ESP_LPW", .stack_size = 256 * 4, .priority = (osPriority_t) osPriorityNormal, }; /* Definitions for TouchGFXTask */ osThreadId_t TouchGFXTaskHandle; const osThreadAttr_t TouchGFXTask_attributes = { .name = "TouchGFXTask", .stack_size = 4096 * 4, .priority = (osPriority_t) osPriorityNormal2, }; /* Definitions for Update_Fb */ osThreadId_t Update_FbHandle; const osThreadAttr_t Update_Fb_attributes = { .name = "Update_Fb", .stack_size = 512 * 4, .priority = (osPriority_t) osPriorityAboveNormal, }; /* Definitions for Event_Decoding */ osThreadId_t Event_DecodingHandle; const osThreadAttr_t Event_Decoding_attributes = { .name = "Event_Decoding", .stack_size = 256 * 4, .priority = (osPriority_t) osPriorityNormal3, }; /* Definitions for Activity_Map */ osThreadId_t Activity_MapHandle; const osThreadAttr_t Activity_Map_attributes = { .name = "Activity_Map", .stack_size = 256 * 4, .priority = (osPriority_t) osPriorityNormal1, }; /* Definitions for Statistics */ osThreadId_t StatisticsHandle; const osThreadAttr_t Statistics_attributes = { .name = "Statistics", .stack_size = 256 * 4, .priority = (osPriority_t) osPriorityNormal1, }; /* Definitions for Led_Tracking */ osThreadId_t Led_TrackingHandle; const osThreadAttr_t Led_Tracking_attributes = { .name = "Led_Tracking", .stack_size = 256 * 4, .priority = (osPriority_t) osPriorityNormal1, }; /* Definitions for tskCtlUpdateFb */ osMutexId_t tskCtlUpdateFbHandle; osStaticMutexDef_t TskCtlUpdateFbControlBlock; const osMutexAttr_t tskCtlUpdateFb_attributes = { .name = "tskCtlUpdateFb", .cb_mem = &TskCtlUpdateFbControlBlock, .cb_size = sizeof(TskCtlUpdateFbControlBlock), }; /* Definitions for Vsync_Semaphore */ osSemaphoreId_t Vsync_SemaphoreHandle; const osSemaphoreAttr_t Vsync_Semaphore_attributes = { .name = "Vsync_Semaphore" }; /* Definitions for ESP_LPW_Semph */ osSemaphoreId_t ESP_LPW_SemphHandle; const osSemaphoreAttr_t ESP_LPW_Semph_attributes = { .name = "ESP_LPW_Semph" }; /* Definitions for Activity_Map_Semph */ osSemaphoreId_t Activity_Map_SemphHandle; const osSemaphoreAttr_t Activity_Map_Semph_attributes = { .name = "Activity_Map_Semph" }; /* Definitions for Statistics_Semph */ osSemaphoreId_t Statistics_SemphHandle; const osSemaphoreAttr_t Statistics_Semph_attributes = { .name = "Statistics_Semph" }; /* Definitions for Led_Tracking_Semph */ osSemaphoreId_t Led_Tracking_SemphHandle; const osSemaphoreAttr_t Led_Tracking_Semph_attributes = { .name = "Led_Tracking_Semph" }; /* USER CODE BEGIN PV */ static FMC_SDRAM_CommandTypeDef Command; /* I2C driver */ DrvI2cHandle_t drv_i2c; /* Dma driver */ DrvDmaHandle_t drv_dma; /* GenX320 driver */ DrvGenx320Handle_t drv_genx320; /* Thread arguments. */ static void* pvStaticAllocate(size_t ulSize); const args_update_fb_t args_update_fb = { .hltdc = &hltdc, .drv_dma = &drv_dma, }; const args_evt_decoder_t args_evt_decoder = { .hdcmi = &hdcmi, .hdma_dcmi = &hdma_dcmi, .drv_genx320 = &drv_genx320, }; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MPU_Config(void); static void MX_GPIO_Init(void); static void MX_DMA_Init(void); static void MX_FMC_Init(void); static void MX_I2C3_Init(void); static void MX_QUADSPI_Init(void); static void MX_I2C1_Init(void); static void MX_DCMI_Init(void); static void MX_CRC_Init(void); static void MX_LTDC_Init(void); static void MX_USART1_UART_Init(void); static void MX_DMA2D_Init(void); static void MX_TIM1_Init(void); static void MX_TIM2_Init(void); void ESP_LPW_Task(void *argument); extern void TouchGFX_Task(void *argument); void Task_Update_Fb(void *argument); void Event_Decoding_Task(void *argument); void Activity_Map_Task(void *argument); void Statistics_Task(void *argument); void Led_Tracking_Task(void *argument); /* USER CODE BEGIN PFP */ /* * @brief Call back function for transmission transfer complete */ void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c) { assert(hi2c == &hi2c1); ucDrvI2cCallback(drv_i2c); } /* * @brief Call back function for reception transfer complete */ void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) { assert(hi2c == &hi2c1); ucDrvI2cCallback(drv_i2c); } /* * @brief Call back function for DMA transfer complete */ void HAL_DMA_MasterCpltCallback(DMA_HandleTypeDef *hdma) { assert(hdma == &hdma_memtomem_dma2_stream0); ucDrvDmaCallback(drv_dma); } /* * @brief For Debug Communication */ PUTCHAR_PROTOTYPE { HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, HAL_MAX_DELAY); return ch; } /* * @brief Call back function for register reload */ void HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef *hltdc) { update_fb_callback(); } /** * @brief Function to reset the frame buffers which do not belong to the .bss section. */ void reset_buffers() { /* Reset the TouchGFX Frame Buffer */ memset((void *)GUI_BUF_ADD_1 , 0x0 , 0x3fc00); memset((void *)GUI_BUF_ADD_2 , 0x0 , 0xff000); } /** * @brief Function to execute the power down sequence for ULP passive mode. */ void ULP_standby_sequence() { /* Toggle OFF the RSTN */ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_15, GPIO_PIN_RESET); psee_sleep_us_imp(tclk_stop); /* Stop the 10MHz PWM signal */ HAL_TIM_PWM_Stop(&htim1,TIM_CHANNEL_1); psee_sleep_us_imp(Tana_stop); /* Switch ON PSU_EN_2V5*/ if(HAL_GPIO_ReadPin(GPIOH, GPIO_PIN_6) != GPIO_PIN_SET) { HAL_GPIO_WritePin(GPIOH, GPIO_PIN_6, GPIO_PIN_SET); psee_sleep_us_imp(TIO_stop); } else { psee_sleep_us_imp(TIO_stop); } /* Switch OFF PSU_EN_1V8*/ HAL_GPIO_WritePin(GPIOI, GPIO_PIN_0, GPIO_PIN_RESET); psee_sleep_us_imp(Tdig_stop); /* Switch OFF PSU_EN_1V1*/ HAL_GPIO_WritePin(GPIOG, GPIO_PIN_7, GPIO_PIN_RESET); psee_sleep_us_imp(Tulp_set); /* Toggle OFF ULP_ENB*/ HAL_GPIO_WritePin(GPIOF, GPIO_PIN_8, GPIO_PIN_RESET); } /** * @brief Function to execute the power up sequence for waking up from ULP passive mode. */ void ULP_wakeup_sequence() { /* Initialize the sensor */ const struct issd *current_issd = psee_open_evt(); /* Set Standard biases */ psee_sensor_set_biases(&genx320_default_biases); /* Start the sensor */ psee_sensor_start(current_issd); /* Set Flip */ psee_sensor_set_flip(0,0); /* Configure the activity map */ psee_configure_activity_map(); /* Toggle ON ULP_ENB*/ HAL_GPIO_WritePin(GPIOF, GPIO_PIN_8, GPIO_PIN_SET); } /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ static uint8_t pxStaticHeap[STATIC_HEAP_SIZE] __ALIGNED(32) = {0}; /** * @brief Function for Static heap allocation. */ static void* pvStaticAllocate(size_t ulSize) { static size_t ulAllocated = 0; /* Align requested size on long boundaries. */ unsigned ulAlign = (unsigned) ALIGN_CEIL(ulSize, long); /* Check the requested size do not exceed max size. */ size_t ulRequested = ulAllocated + ulAlign; if (STATIC_HEAP_SIZE < ulRequested) return NULL; /* Return the current buffer position and update the position. */ void *pVoid = (void *) (pxStaticHeap + ulAllocated); ulAllocated = ulRequested; return pVoid; } /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* PUT THIS FIRST, WON'T WORK OTHERWISE */ MX_DMA_Init(); /* USER CODE END 1 */ /* MPU Configuration--------------------------------------------------------*/ MPU_Config(); /* Enable the CPU Cache */ /* Enable I-Cache---------------------------------------------------------*/ SCB_EnableICache(); /* Enable D-Cache---------------------------------------------------------*/ SCB_EnableDCache(); /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ hpcd.Instance = USB_OTG_FS; // or USB_OTG_HS depending on your STM32 model hpcd.Init.dev_endpoints = 6; // Number of endpoints used hpcd.Init.speed = PCD_SPEED_FULL; // Full-speed or high-speed depending on your setup hpcd.Init.dma_enable = DISABLE; // DMA enable/disable hpcd.Init.phy_itface = PCD_PHY_EMBEDDED; // PHY interface (Embedded or External) hpcd.Init.Sof_enable = ENABLE; // Enable Start of Frame hpcd.Init.low_power_enable = DISABLE; // Low power mode hpcd.Init.lpm_enable = DISABLE; // Link Power Management hpcd.Init.vbus_sensing_enable = ENABLE; // VBUS sensing hpcd.Init.use_dedicated_ep1 = DISABLE; // Dedicated endpoint 1 if (HAL_PCD_Init(&hpcd) != HAL_OK) { // Initialization Error Error_Handler(); // Implement this function to handle errors } /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_FMC_Init(); MX_I2C3_Init(); MX_QUADSPI_Init(); MX_I2C1_Init(); MX_DCMI_Init(); MX_CRC_Init(); MX_LTDC_Init(); MX_USART1_UART_Init(); MX_DMA2D_Init(); MX_TIM1_Init(); MX_TIM2_Init(); MX_TouchGFX_Init(); /* Call PreOsInit function */ MX_TouchGFX_PreOSInit(); /* USER CODE BEGIN 2 */ /* Change Systick priority to 4 to use HAL_DELAY() */ HAL_InitTick(4); /* Reset the display frame buffers */ reset_buffers(); reset_frame_buffers(); /* Initialize drivers */ BaseType_t i2c_status = xDrvI2cCreate(&hi2c1, pvStaticAllocate, &drv_i2c); assert(i2c_status == pdTRUE); BaseType_t dma_status = xDrvDmaCreate(&hdma_memtomem_dma2_stream0, pvStaticAllocate, &drv_dma); assert(dma_status == pdTRUE); HAL_DMA_RegisterCallback(&hdma_memtomem_dma2_stream0, HAL_DMA_XFER_CPLT_CB_ID, HAL_DMA_MasterCpltCallback); BaseType_t genx320_status = xDrvGenx320Create(pvStaticAllocate, &drv_genx320); assert(genx320_status == pdTRUE); /* Change Systick priority back to 15 */ HAL_InitTick(15); /* USER CODE END 2 */ /* Init scheduler */ osKernelInitialize(); /* Create the mutex(es) */ /* creation of tskCtlUpdateFb */ tskCtlUpdateFbHandle = osMutexNew(&tskCtlUpdateFb_attributes); /* USER CODE BEGIN RTOS_MUTEX */ /* add mutexes, ... */ /* USER CODE END RTOS_MUTEX */ /* Create the semaphores(s) */ /* creation of Vsync_Semaphore */ Vsync_SemaphoreHandle = osSemaphoreNew(1, 0, &Vsync_Semaphore_attributes); /* creation of ESP_LPW_Semph */ ESP_LPW_SemphHandle = osSemaphoreNew(1, 0, &ESP_LPW_Semph_attributes); /* creation of Activity_Map_Semph */ Activity_Map_SemphHandle = osSemaphoreNew(1, 0, &Activity_Map_Semph_attributes); /* creation of Statistics_Semph */ Statistics_SemphHandle = osSemaphoreNew(1, 0, &Statistics_Semph_attributes); /* creation of Led_Tracking_Semph */ Led_Tracking_SemphHandle = osSemaphoreNew(1, 0, &Led_Tracking_Semph_attributes); /* USER CODE BEGIN RTOS_SEMAPHORES */ /* add semaphores, ... */ /* USER CODE END RTOS_SEMAPHORES */ /* USER CODE BEGIN RTOS_TIMERS */ /* start timers, add new ones, ... */ /* USER CODE END RTOS_TIMERS */ /* USER CODE BEGIN RTOS_QUEUES */ /* add queues, ... */ /* USER CODE END RTOS_QUEUES */ /* Create the thread(s) */ /* creation of ESP_LPW */ ESP_LPWHandle = osThreadNew(ESP_LPW_Task, NULL, &ESP_LPW_attributes); /* creation of TouchGFXTask */ TouchGFXTaskHandle = osThreadNew(TouchGFX_Task, NULL, &TouchGFXTask_attributes); /* creation of Update_Fb */ Update_FbHandle = osThreadNew(Task_Update_Fb, (void*) &args_update_fb, &Update_Fb_attributes); /* creation of Event_Decoding */ Event_DecodingHandle = osThreadNew(Event_Decoding_Task, (void*) &args_evt_decoder, &Event_Decoding_attributes); /* creation of Activity_Map */ Activity_MapHandle = osThreadNew(Activity_Map_Task, NULL, &Activity_Map_attributes); /* creation of Statistics */ StatisticsHandle = osThreadNew(Statistics_Task, NULL, &Statistics_attributes); /* creation of Led_Tracking */ Led_TrackingHandle = osThreadNew(Led_Tracking_Task, NULL, &Led_Tracking_attributes); /* USER CODE BEGIN RTOS_THREADS */ /* add threads, ... */ /* USER CODE END RTOS_THREADS */ /* USER CODE BEGIN RTOS_EVENTS */ /* add events, ... */ /* USER CODE END RTOS_EVENTS */ /* Start scheduler */ osKernelStart(); /* We should never get here as control is now taken by the scheduler */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 12; RCC_OscInitStruct.PLL.PLLN = 192; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 2; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Activate the Over-Drive mode */ if (HAL_PWREx_EnableOverDrive() != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK) { Error_Handler(); } } /** * @brief CRC Initialization Function * @param None * @retval None */ static void MX_CRC_Init(void) { /* USER CODE BEGIN CRC_Init 0 */ /* USER CODE END CRC_Init 0 */ /* USER CODE BEGIN CRC_Init 1 */ /* USER CODE END CRC_Init 1 */ hcrc.Instance = CRC; hcrc.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_ENABLE; hcrc.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_ENABLE; hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE; hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE; hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; if (HAL_CRC_Init(&hcrc) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN CRC_Init 2 */ /* USER CODE END CRC_Init 2 */ } /** * @brief DCMI Initialization Function * @param None * @retval None */ static void MX_DCMI_Init(void) { /* USER CODE BEGIN DCMI_Init 0 */ /* USER CODE END DCMI_Init 0 */ /* USER CODE BEGIN DCMI_Init 1 */ /* USER CODE END DCMI_Init 1 */ hdcmi.Instance = DCMI; hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_FALLING; hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_HIGH; hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_HIGH; hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME; hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; hdcmi.Init.JPEGMode = DCMI_JPEG_ENABLE; hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL; hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD; hdcmi.Init.LineSelectMode = DCMI_LSM_ALL; hdcmi.Init.LineSelectStart = DCMI_OELS_ODD; if (HAL_DCMI_Init(&hdcmi) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN DCMI_Init 2 */ /* USER CODE END DCMI_Init 2 */ } /** * @brief DMA2D Initialization Function * @param None * @retval None */ static void MX_DMA2D_Init(void) { /* USER CODE BEGIN DMA2D_Init 0 */ /* USER CODE END DMA2D_Init 0 */ /* USER CODE BEGIN DMA2D_Init 1 */ /* USER CODE END DMA2D_Init 1 */ hdma2d.Instance = DMA2D; hdma2d.Init.Mode = DMA2D_M2M; hdma2d.Init.ColorMode = DMA2D_OUTPUT_ARGB8888; hdma2d.Init.OutputOffset = 0; hdma2d.LayerCfg[1].InputOffset = 0; hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_ARGB8888; hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; hdma2d.LayerCfg[1].InputAlpha = 0; if (HAL_DMA2D_Init(&hdma2d) != HAL_OK) { Error_Handler(); } if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN DMA2D_Init 2 */ /* USER CODE END DMA2D_Init 2 */ } /** * @brief I2C1 Initialization Function * @param None * @retval None */ static void MX_I2C1_Init(void) { /* USER CODE BEGIN I2C1_Init 0 */ /* USER CODE END I2C1_Init 0 */ /* USER CODE BEGIN I2C1_Init 1 */ /* USER CODE END I2C1_Init 1 */ hi2c1.Instance = I2C1; hi2c1.Init.Timing = 0x0020081F; hi2c1.Init.OwnAddress1 = 0; hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; hi2c1.Init.OwnAddress2 = 0; hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK; hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; if (HAL_I2C_Init(&hi2c1) != HAL_OK) { Error_Handler(); } /** Configure Analogue filter */ if (HAL_I2CEx_ConfigAnalogFilter(&hi2c1, I2C_ANALOGFILTER_ENABLE) != HAL_OK) { Error_Handler(); } /** Configure Digital filter */ if (HAL_I2CEx_ConfigDigitalFilter(&hi2c1, 0) != HAL_OK) { Error_Handler(); } /** I2C Enable Fast Mode Plus */ HAL_I2CEx_EnableFastModePlus(I2C_FASTMODEPLUS_I2C1); /* USER CODE BEGIN I2C1_Init 2 */ /* USER CODE END I2C1_Init 2 */ } /** * @brief I2C3 Initialization Function * @param None * @retval None */ static void MX_I2C3_Init(void) { /* USER CODE BEGIN I2C3_Init 0 */ HAL_Delay(100); //Delay to fix initialization issue on some boards /* USER CODE END I2C3_Init 0 */ /* USER CODE BEGIN I2C3_Init 1 */ /* USER CODE END I2C3_Init 1 */ hi2c3.Instance = I2C3; hi2c3.Init.Timing = 0x00C0EAFF; hi2c3.Init.OwnAddress1 = 0; hi2c3.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT; hi2c3.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE; hi2c3.Init.OwnAddress2 = 0; hi2c3.Init.OwnAddress2Masks = I2C_OA2_NOMASK; hi2c3.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; hi2c3.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; if (HAL_I2C_Init(&hi2c3) != HAL_OK) { Error_Handler(); } /** Configure Analogue filter */ if (HAL_I2CEx_ConfigAnalogFilter(&hi2c3, I2C_ANALOGFILTER_ENABLE) != HAL_OK) { Error_Handler(); } /** Configure Digital filter */ if (HAL_I2CEx_ConfigDigitalFilter(&hi2c3, 0) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN I2C3_Init 2 */ /* USER CODE END I2C3_Init 2 */ } /** * @brief LTDC Initialization Function * @param None * @retval None */ static void MX_LTDC_Init(void) { /* USER CODE BEGIN LTDC_Init 0 */ /* USER CODE END LTDC_Init 0 */ LTDC_LayerCfgTypeDef pLayerCfg = {0}; /* USER CODE BEGIN LTDC_Init 1 */ /* USER CODE END LTDC_Init 1 */ hltdc.Instance = LTDC; hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL; hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AH; hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AH; hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC; hltdc.Init.HorizontalSync = 3; hltdc.Init.VerticalSync = 1; hltdc.Init.AccumulatedHBP = 46; hltdc.Init.AccumulatedVBP = 13; hltdc.Init.AccumulatedActiveW = 526; hltdc.Init.AccumulatedActiveH = 285; hltdc.Init.TotalWidth = 534; hltdc.Init.TotalHeigh = 297; hltdc.Init.Backcolor.Blue = 0; hltdc.Init.Backcolor.Green = 0; hltdc.Init.Backcolor.Red = 0; if (HAL_LTDC_Init(&hltdc) != HAL_OK) { Error_Handler(); } pLayerCfg.WindowX0 = 0; pLayerCfg.WindowX1 = 480; pLayerCfg.WindowY0 = 0; pLayerCfg.WindowY1 = 272; pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; pLayerCfg.Alpha = 255; pLayerCfg.Alpha0 = 0; pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA; pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA; pLayerCfg.FBStartAdress = 0xC0000000; pLayerCfg.ImageWidth = 480; pLayerCfg.ImageHeight = 272; pLayerCfg.Backcolor.Blue = 0; pLayerCfg.Backcolor.Green = 0; pLayerCfg.Backcolor.Red = 0; if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN LTDC_Init 2 */ __HAL_LTDC_DISABLE_IT(&hltdc, LTDC_IT_TE | LTDC_IT_FU); /* USER CODE END LTDC_Init 2 */ } /** * @brief QUADSPI Initialization Function * @param None * @retval None */ static void MX_QUADSPI_Init(void) { /* USER CODE BEGIN QUADSPI_Init 0 */ /* USER CODE END QUADSPI_Init 0 */ /* USER CODE BEGIN QUADSPI_Init 1 */ /* USER CODE END QUADSPI_Init 1 */ /* QUADSPI parameter configuration*/ hqspi.Instance = QUADSPI; hqspi.Init.ClockPrescaler = 1; hqspi.Init.FifoThreshold = 4; hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_HALFCYCLE; hqspi.Init.FlashSize = 24; hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_6_CYCLE; hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; hqspi.Init.FlashID = QSPI_FLASH_ID_1; hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE; if (HAL_QSPI_Init(&hqspi) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN QUADSPI_Init 2 */ BSP_QSPI_Init(); BSP_QSPI_MemoryMappedMode(); HAL_NVIC_DisableIRQ(QUADSPI_IRQn); /* USER CODE END QUADSPI_Init 2 */ } /** * @brief TIM1 Initialization Function * @param None * @retval None */ static void MX_TIM1_Init(void) { /* USER CODE BEGIN TIM1_Init 0 */ /* USER CODE END TIM1_Init 0 */ TIM_ClockConfigTypeDef sClockSourceConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; TIM_OC_InitTypeDef sConfigOC = {0}; TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0}; /* USER CODE BEGIN TIM1_Init 1 */ /* USER CODE END TIM1_Init 1 */ htim1.Instance = TIM1; htim1.Init.Prescaler = 1; htim1.Init.CounterMode = TIM_COUNTERMODE_UP; htim1.Init.Period = 9; htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim1.Init.RepetitionCounter = 0; htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim1) != HAL_OK) { Error_Handler(); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK) { Error_Handler(); } if (HAL_TIM_PWM_Init(&htim1) != HAL_OK) { Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK) { Error_Handler(); } sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.Pulse = 5; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH; sConfigOC.OCFastMode = TIM_OCFAST_ENABLE; sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) { Error_Handler(); } sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE; sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF; sBreakDeadTimeConfig.DeadTime = 0; sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE; sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH; sBreakDeadTimeConfig.BreakFilter = 0; sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE; sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH; sBreakDeadTimeConfig.Break2Filter = 0; sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM1_Init 2 */ /* USER CODE END TIM1_Init 2 */ HAL_TIM_MspPostInit(&htim1); } /** * @brief TIM2 Initialization Function * @param None * @retval None */ static void MX_TIM2_Init(void) { /* USER CODE BEGIN TIM2_Init 0 */ /* USER CODE END TIM2_Init 0 */ TIM_ClockConfigTypeDef sClockSourceConfig = {0}; TIM_MasterConfigTypeDef sMasterConfig = {0}; /* USER CODE BEGIN TIM2_Init 1 */ /* USER CODE END TIM2_Init 1 */ htim2.Instance = TIM2; htim2.Init.Prescaler = 99; htim2.Init.CounterMode = TIM_COUNTERMODE_UP; htim2.Init.Period = 4294967295; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; if (HAL_TIM_Base_Init(&htim2) != HAL_OK) { Error_Handler(); } sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) { Error_Handler(); } sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN TIM2_Init 2 */ /* Start the Timer 2 for us delay function */ HAL_TIM_Base_Start(&htim2); /* USER CODE END TIM2_Init 2 */ } /** * @brief USART1 Initialization Function * @param None * @retval None */ static void MX_USART1_UART_Init(void) { /* USER CODE BEGIN USART1_Init 0 */ /* USER CODE END USART1_Init 0 */ /* USER CODE BEGIN USART1_Init 1 */ /* USER CODE END USART1_Init 1 */ huart1.Instance = USART1; huart1.Init.BaudRate = 115200; huart1.Init.WordLength = UART_WORDLENGTH_8B; huart1.Init.StopBits = UART_STOPBITS_1; huart1.Init.Parity = UART_PARITY_NONE; huart1.Init.Mode = UART_MODE_TX_RX; huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; huart1.Init.OverSampling = UART_OVERSAMPLING_16; huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE; huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; if (HAL_UART_Init(&huart1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USART1_Init 2 */ /* USER CODE END USART1_Init 2 */ } /** * Enable DMA controller clock * Configure DMA for memory to memory transfers * hdma_memtomem_dma2_stream0 */ static void MX_DMA_Init(void) { /* DMA controller clock enable */ __HAL_RCC_DMA2_CLK_ENABLE(); /* Configure DMA request hdma_memtomem_dma2_stream0 on DMA2_Stream0 */ hdma_memtomem_dma2_stream0.Instance = DMA2_Stream0; hdma_memtomem_dma2_stream0.Init.Channel = DMA_CHANNEL_0; hdma_memtomem_dma2_stream0.Init.Direction = DMA_MEMORY_TO_MEMORY; hdma_memtomem_dma2_stream0.Init.PeriphInc = DMA_PINC_DISABLE; hdma_memtomem_dma2_stream0.Init.MemInc = DMA_MINC_ENABLE; hdma_memtomem_dma2_stream0.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma_memtomem_dma2_stream0.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; hdma_memtomem_dma2_stream0.Init.Mode = DMA_NORMAL; hdma_memtomem_dma2_stream0.Init.Priority = DMA_PRIORITY_LOW; hdma_memtomem_dma2_stream0.Init.FIFOMode = DMA_FIFOMODE_ENABLE; hdma_memtomem_dma2_stream0.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; hdma_memtomem_dma2_stream0.Init.MemBurst = DMA_MBURST_INC4; hdma_memtomem_dma2_stream0.Init.PeriphBurst = DMA_PBURST_INC4; if (HAL_DMA_Init(&hdma_memtomem_dma2_stream0) != HAL_OK) { Error_Handler( ); } /* DMA interrupt init */ /* DMA2_Stream0_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 5, 0); HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); /* DMA2_Stream1_IRQn interrupt configuration */ HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); } /* FMC initialization function */ static void MX_FMC_Init(void) { /* USER CODE BEGIN FMC_Init 0 */ /* USER CODE END FMC_Init 0 */ FMC_SDRAM_TimingTypeDef SdramTiming = {0}; /* USER CODE BEGIN FMC_Init 1 */ /* USER CODE END FMC_Init 1 */ /** Perform the SDRAM1 memory initialization sequence */ hsdram1.Instance = FMC_SDRAM_DEVICE; /* hsdram1.Init */ hsdram1.Init.SDBank = FMC_SDRAM_BANK1; hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16; hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; /* SdramTiming */ SdramTiming.LoadToActiveDelay = 2; SdramTiming.ExitSelfRefreshDelay = 7; SdramTiming.SelfRefreshTime = 4; SdramTiming.RowCycleDelay = 7; SdramTiming.WriteRecoveryTime = 3; SdramTiming.RPDelay = 2; SdramTiming.RCDDelay = 2; if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) { Error_Handler( ); } /* USER CODE BEGIN FMC_Init 2 */ __IO uint32_t tmpmrd = 0; /* Step 1: Configure a clock configuration enable command */ Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; Command.AutoRefreshNumber = 1; Command.ModeRegisterDefinition = 0; /* Send the command */ HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT); /* Step 2: Insert 100 us minimum delay */ /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */ HAL_Delay(1); /* Step 3: Configure a PALL (precharge all) command */ Command.CommandMode = FMC_SDRAM_CMD_PALL; Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; Command.AutoRefreshNumber = 1; Command.ModeRegisterDefinition = 0; /* Send the command */ HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT); /* Step 4: Configure an Auto Refresh command */ Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; Command.AutoRefreshNumber = 8; Command.ModeRegisterDefinition = 0; /* Send the command */ HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT); /* Step 5: Program the external memory mode register */ tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 | \ SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL | \ SDRAM_MODEREG_CAS_LATENCY_3 | \ SDRAM_MODEREG_OPERATING_MODE_STANDARD | \ SDRAM_MODEREG_WRITEBURST_MODE_SINGLE; Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE; Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; Command.AutoRefreshNumber = 1; Command.ModeRegisterDefinition = tmpmrd; /* Send the command */ HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT); /* Step 6: Set the refresh rate counter */ /* Set the device refresh rate */ HAL_SDRAM_ProgramRefreshRate(&hsdram1, REFRESH_COUNT); //Deactivate speculative/cache access to first FMC Bank to save FMC bandwidth FMC_Bank1->BTCR[0] = 0x000030D2; /* USER CODE END FMC_Init 2 */ } /** * @brief GPIO Initialization Function * @param None * @retval None */ static void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; /* USER CODE BEGIN MX_GPIO_Init_1 */ /* USER CODE END MX_GPIO_Init_1 */ /* GPIO Ports Clock Enable */ __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE(); __HAL_RCC_GPIOJ_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOK_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); __HAL_RCC_GPIOI_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOB, VSYNC_FREQ_Pin|GPIO_PIN_15, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_Port, LCD_BL_CTRL_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOH, DCMI_PWR_EN_Pin|PSU_EN_2V5____D6_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(PSU_EN_1V8____D5_GPIO_Port, PSU_EN_1V8____D5_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOC, FRAME_RATE_Pin|RENDER_TIME_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOG, PSU_EN_1V1____D4_Pin|MCU_ACTIVE_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOF, ULP_TH_Pin|ULP_RSTn_Pin|ULP_ENb_Pin, GPIO_PIN_SET); /*Configure GPIO pin : VSYNC_FREQ_Pin */ GPIO_InitStruct.Pin = VSYNC_FREQ_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; HAL_GPIO_Init(VSYNC_FREQ_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : LCD_BL_CTRL_Pin */ GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : LCD_DISP_Pin PSU_EN_1V8____D5_Pin */ GPIO_InitStruct.Pin = LCD_DISP_Pin|PSU_EN_1V8____D5_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /*Configure GPIO pins : DCMI_PWR_EN_Pin PSU_EN_2V5____D6_Pin */ GPIO_InitStruct.Pin = DCMI_PWR_EN_Pin|PSU_EN_2V5____D6_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /*Configure GPIO pins : FRAME_RATE_Pin RENDER_TIME_Pin */ GPIO_InitStruct.Pin = FRAME_RATE_Pin|RENDER_TIME_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : PSU_EN_1V1____D4_Pin */ GPIO_InitStruct.Pin = PSU_EN_1V1____D4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(PSU_EN_1V1____D4_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : MCU_ACTIVE_Pin */ GPIO_InitStruct.Pin = MCU_ACTIVE_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; HAL_GPIO_Init(MCU_ACTIVE_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : ULP_TH_Pin ULP_RSTn_Pin ULP_ENb_Pin */ GPIO_InitStruct.Pin = ULP_TH_Pin|ULP_RSTn_Pin|ULP_ENb_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pin : WAKEUP_Pin */ GPIO_InitStruct.Pin = WAKEUP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(WAKEUP_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PB15 */ GPIO_InitStruct.Pin = GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ } /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ /* USER CODE BEGIN Header_ESP_LPW_Task */ /** * @brief Function implementing the ESP_LPW thread. * @param argument: Not used * @retval None */ /* USER CODE END Header_ESP_LPW_Task */ void ESP_LPW_Task(void *argument) { /* USER CODE BEGIN 5 */ psee_esp_lpw_task(); /* USER CODE END 5 */ } /* USER CODE BEGIN Header_Task_Update_Fb */ /** * @brief Function implementing the Update_Fb thread. * @param argument: Not used * @retval None */ /* USER CODE END Header_Task_Update_Fb */ void Task_Update_Fb(void *argument) { /* USER CODE BEGIN Task_Update_Fb */ const args_update_fb_t *args = (args_update_fb_t *) argument; task_update_fb(args); /* USER CODE END Task_Update_Fb */ } /* USER CODE BEGIN Header_Event_Decoding_Task */ /** * @brief Function implementing the Event_Decoding thread. * @param argument: Not used * @retval None */ /* USER CODE END Header_Event_Decoding_Task */ void Event_Decoding_Task(void *argument) { /* USER CODE BEGIN Event_Decoding_Task */ task_evt_decoder((args_evt_decoder_t *) argument); /* USER CODE END Event_Decoding_Task */ } /* USER CODE BEGIN Header_Activity_Map_Task */ /** * @brief Function implementing the Activity_Map thread. * @param argument: Not used * @retval None */ /* USER CODE END Header_Activity_Map_Task */ void Activity_Map_Task(void *argument) { /* USER CODE BEGIN Activity_Map_Task */ psee_activity_map_task(); /* USER CODE END Activity_Map_Task */ } /* USER CODE BEGIN Header_Statistics_Task */ /** * @brief Function implementing the Statistics thread. * @param argument: Not used * @retval None */ /* USER CODE END Header_Statistics_Task */ void Statistics_Task(void *argument) { /* USER CODE BEGIN Statistics_Task */ psee_statistics_task(); /* USER CODE END Statistics_Task */ } /* USER CODE BEGIN Header_Led_Tracking_Task */ /** * @brief Function implementing the Led_Tracking thread. * @param argument: Not used * @retval None */ /* USER CODE END Header_Led_Tracking_Task */ void Led_Tracking_Task(void *argument) { /* USER CODE BEGIN Led_Tracking_Task */ psee_led_tracking_task(); /* USER CODE END Led_Tracking_Task */ } /* MPU Configuration */ void MPU_Config(void) { MPU_Region_InitTypeDef MPU_InitStruct = {0}; /* Disables the MPU */ HAL_MPU_Disable(); /** Initializes and configures the Region and the memory to be protected */ MPU_InitStruct.Enable = MPU_REGION_ENABLE; MPU_InitStruct.Number = MPU_REGION_NUMBER0; MPU_InitStruct.BaseAddress = 0x90000000; MPU_InitStruct.Size = MPU_REGION_SIZE_256MB; MPU_InitStruct.SubRegionDisable = 0x0; MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0; MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS; MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE; MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE; MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; HAL_MPU_ConfigRegion(&MPU_InitStruct); /** Initializes and configures the Region and the memory to be protected */ MPU_InitStruct.Number = MPU_REGION_NUMBER1; MPU_InitStruct.Size = MPU_REGION_SIZE_16MB; MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE; HAL_MPU_ConfigRegion(&MPU_InitStruct); /* Enables the MPU */ HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); } /** * @brief Period elapsed callback in non blocking mode * @note This function is called when TIM6 interrupt took place, inside * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment * a global variable "uwTick" used as application time base. * @param htim : TIM handle * @retval None */ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { /* USER CODE BEGIN Callback 0 */ /* USER CODE END Callback 0 */ if (htim->Instance == TIM6) { HAL_IncTick(); } /* USER CODE BEGIN Callback 1 */ /* USER CODE END Callback 1 */ } /** * @brief This function is executed in case of error occurrence. * @retval None */ void Error_Handler(void) { /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */ void assert_failed(uint8_t *file, uint32_t line) { /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, tex: // printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */