/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2024 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. * ****************************************************************************** */ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "Main.h" #include /* Private includes ----------------------------------------------------------*/ #include "daq_usbd_core.h" /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN PTD */ /* USER CODE END PTD */ /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ /* USER CODE END PM */ /* Private variables ---------------------------------------------------------*/ #if defined ( __ICCARM__ ) /*!< IAR Compiler */ #pragma location=0x30000000 ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */ #pragma location=0x30000200 ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */ #elif defined ( __CC_ARM ) /* MDK ARM Compiler */ __attribute__((at(0x30000000))) ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */ __attribute__((at(0x30000200))) ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */ #elif defined ( __GNUC__ ) /* GNU Compiler */ ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */ ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecripSection"))); /* Ethernet Tx DMA Descriptors */ #endif ETH_TxPacketConfig TxConfig; ADC_HandleTypeDef hadc1; DFSDM_Channel_HandleTypeDef hdfsdm1_channel1; ETH_HandleTypeDef heth; I2C_HandleTypeDef hi2c1; LTDC_HandleTypeDef hltdc; QSPI_HandleTypeDef hqspi; SAI_HandleTypeDef hsai_BlockA1; SAI_HandleTypeDef hsai_BlockB1; UART_HandleTypeDef huart1; PCD_HandleTypeDef hpcd_USB_OTG_FS; PCD_HandleTypeDef hpcd_USB_OTG_HS; NOR_HandleTypeDef hnor1; SRAM_HandleTypeDef hsram2; SDRAM_HandleTypeDef hsdram1; /* USER CODE BEGIN PV */ extern USBD_ClassTypeDef USBD_CDC; USBD_HandleTypeDef USBD_Device; extern USBD_CDC_ItfTypeDef USBD_CDC_fops; extern USBD_DescriptorsTypeDef VCP_Desc; USBD_StatusTypeDef result; #define USE_USB_FS /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); void PeriphCommonClock_Config(void); static void MX_GPIO_Init(void); static void MX_ADC1_Init(void); static void MX_DFSDM1_Init(void); static void MX_ETH_Init(void); static void MX_FMC_Init(void); static void MX_I2C1_Init(void); static void MX_LTDC_Init(void); static void MX_QUADSPI_Init(void); static void MX_SAI1_Init(void); static void MX_USART1_UART_Init(void); static void MX_USB_OTG_FS_PCD_Init(void); static void MX_USB_OTG_HS_PCD_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ /** * @brief The application entry point. * @retval int */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* Configure the peripherals common clocks */ PeriphCommonClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); // MX_ADC1_Init(); //MX_DFSDM1_Init(); //MX_ETH_Init(); MX_FMC_Init(); MX_I2C1_Init(); MX_LTDC_Init(); MX_QUADSPI_Init(); //MX_SAI1_Init(); MX_USART1_UART_Init(); MX_USB_OTG_FS_PCD_Init(); // MX_USB_OTG_HS_PCD_Init(); /* USER CODE BEGIN 2 */ // char buffer[10] = "Hello_World"; // USBD_Init(&USBD_Device,&VCP_Desc,0); USBD_Init(&USBD_Device, &VCP_Desc,0); /* Add Supported Class */ USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS); /* Add CDC Interface Class */ USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops); /* Start Device Process */ // USBD_Start(&USBD_Device); // USBD_LL_Start(&USBD_Device); char toggle = 1; // unsigned long int delay = 50000; // const uint8_t data[] = "Hello_world"; while(1) { // HAL_UART_Transmit(&huart1,data,sizeof(data)-1,HAL_MAX_DELAY); // /* USER CODE END WHILE */ // USBD_CDC_SetTxBuffer(&USBD_Device,buffer,sizeof(buffer)); // result = USBD_CDC_TransmitPacket(&USBD_Device); // HAL_Delay(5000); // while(delay--); // HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_10); // HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_11); // if(toggle) { // HAL_GPIO_WritePin(LED1_RGB_GPIO_Port,LED1_RGB_Pin,GPIO_PIN_SET); HAL_GPIO_WritePin(LED3_RGB_GPIO_Port,LED3_RGB_Pin,GPIO_PIN_RESET); // while(--delay); toggle = 0; } else { // HAL_GPIO_WritePin(LED1_RGB_GPIO_Port,LED1_RGB_Pin,GPIO_PIN_RESET); HAL_GPIO_WritePin(LED3_RGB_GPIO_Port,LED3_RGB_Pin,GPIO_PIN_SET); // while(--delay); toggle = 1; } USBD_LL_Delay(500); // delay = 50000; //HAL_UART_Transmit(&huart1,"Hello_UART",9,HAL_MAX_DELAY); /* USER CODE BEGIN 3 */ } /* Add Supported Class */ USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS); /* Add CDC Interface Class */ USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops); /* Start Device Process */ USBD_Start(&USBD_Device); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* Add Supported Class */ USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS); /* Add CDC Interface Class */ USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops); /* Start Device Process */ USBD_Start(&USBD_Device); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* Add Supported Class */ USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS); /* Add CDC Interface Class */ USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops); /* Start Device Process */ USBD_Start(&USBD_Device); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* Add Supported Class */ USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS); /* Add CDC Interface Class */ USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops); /* Start Device Process */ USBD_Start(&USBD_Device); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ /* USER CODE END 3 */ } /** * @brief System Clock Configuration * @retval None */ void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Supply configuration update enable */ HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY); /** Configure the main internal regulator output voltage */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE0); while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.HSIState = RCC_HSI_DIV1; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 2; RCC_OscInitStruct.PLL.PLLN = 65; RCC_OscInitStruct.PLL.PLLP = 2; RCC_OscInitStruct.PLL.PLLQ = 20; RCC_OscInitStruct.PLL.PLLR = 2; RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3; RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; RCC_OscInitStruct.PLL.PLLFRACN = 0; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != 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_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2; RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2; RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV4; RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { Error_Handler(); } HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); } /** * @brief Peripherals Common Clock Configuration * @retval None */ void PeriphCommonClock_Config(void) { RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; /** Initializes the peripherals clock */ PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_USB|RCC_PERIPHCLK_LTDC; PeriphClkInitStruct.PLL3.PLL3M = 2; PeriphClkInitStruct.PLL3.PLL3N = 20; PeriphClkInitStruct.PLL3.PLL3P = 5; PeriphClkInitStruct.PLL3.PLL3Q = 5; PeriphClkInitStruct.PLL3.PLL3R = 5; PeriphClkInitStruct.PLL3.PLL3RGE = RCC_PLL3VCIRANGE_3; PeriphClkInitStruct.PLL3.PLL3VCOSEL = RCC_PLL3VCOWIDE; PeriphClkInitStruct.PLL3.PLL3FRACN = 0; PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL3; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { Error_Handler(); } } /** * @brief ADC1 Initialization Function * @param None * @retval None */ static void MX_ADC1_Init(void) { /* USER CODE BEGIN ADC1_Init 0 */ /* USER CODE END ADC1_Init 0 */ ADC_MultiModeTypeDef multimode = {0}; ADC_ChannelConfTypeDef sConfig = {0}; /* USER CODE BEGIN ADC1_Init 1 */ /* USER CODE END ADC1_Init 1 */ /** Common config */ hadc1.Instance = ADC1; hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; hadc1.Init.Resolution = ADC_RESOLUTION_16B; hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE; hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV; hadc1.Init.LowPowerAutoWait = DISABLE; hadc1.Init.ContinuousConvMode = DISABLE; hadc1.Init.NbrOfConversion = 1; hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; hadc1.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR; hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED; hadc1.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE; hadc1.Init.OversamplingMode = DISABLE; if (HAL_ADC_Init(&hadc1) != HAL_OK) { Error_Handler(); } /** Configure the ADC multi-mode */ multimode.Mode = ADC_MODE_INDEPENDENT; if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK) { Error_Handler(); } /** Configure Regular Channel */ sConfig.Channel = ADC_CHANNEL_1; sConfig.Rank = ADC_REGULAR_RANK_1; sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5; sConfig.SingleDiff = ADC_DIFFERENTIAL_ENDED; sConfig.OffsetNumber = ADC_OFFSET_NONE; sConfig.Offset = 0; sConfig.OffsetSignedSaturation = DISABLE; if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN ADC1_Init 2 */ /* USER CODE END ADC1_Init 2 */ } /** * @brief DFSDM1 Initialization Function * @param None * @retval None */ static void MX_DFSDM1_Init(void) { /* USER CODE BEGIN DFSDM1_Init 0 */ /* USER CODE END DFSDM1_Init 0 */ /* USER CODE BEGIN DFSDM1_Init 1 */ /* USER CODE END DFSDM1_Init 1 */ hdfsdm1_channel1.Instance = DFSDM1_Channel1; hdfsdm1_channel1.Init.OutputClock.Activation = ENABLE; hdfsdm1_channel1.Init.OutputClock.Selection = DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM; hdfsdm1_channel1.Init.OutputClock.Divider = 2; hdfsdm1_channel1.Init.Input.Multiplexer = DFSDM_CHANNEL_EXTERNAL_INPUTS; hdfsdm1_channel1.Init.Input.DataPacking = DFSDM_CHANNEL_STANDARD_MODE; hdfsdm1_channel1.Init.Input.Pins = DFSDM_CHANNEL_SAME_CHANNEL_PINS; hdfsdm1_channel1.Init.SerialInterface.Type = DFSDM_CHANNEL_SPI_RISING; hdfsdm1_channel1.Init.SerialInterface.SpiClock = DFSDM_CHANNEL_SPI_CLOCK_INTERNAL; hdfsdm1_channel1.Init.Awd.FilterOrder = DFSDM_CHANNEL_FASTSINC_ORDER; hdfsdm1_channel1.Init.Awd.Oversampling = 1; hdfsdm1_channel1.Init.Offset = 0; hdfsdm1_channel1.Init.RightBitShift = 0x00; if (HAL_DFSDM_ChannelInit(&hdfsdm1_channel1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN DFSDM1_Init 2 */ /* USER CODE END DFSDM1_Init 2 */ } /** * @brief ETH Initialization Function * @param None * @retval None */ static void MX_ETH_Init(void) { /* USER CODE BEGIN ETH_Init 0 */ /* USER CODE END ETH_Init 0 */ static uint8_t MACAddr[6]; /* USER CODE BEGIN ETH_Init 1 */ /* USER CODE END ETH_Init 1 */ heth.Instance = ETH; MACAddr[0] = 0x00; MACAddr[1] = 0x80; MACAddr[2] = 0xE1; MACAddr[3] = 0x00; MACAddr[4] = 0x00; MACAddr[5] = 0x00; heth.Init.MACAddr = &MACAddr[0]; heth.Init.MediaInterface = HAL_ETH_RMII_MODE; heth.Init.TxDesc = DMATxDscrTab; heth.Init.RxDesc = DMARxDscrTab; heth.Init.RxBuffLen = 1524; /* USER CODE BEGIN MACADDRESS */ /* USER CODE END MACADDRESS */ if (HAL_ETH_Init(&heth) != HAL_OK) { Error_Handler(); } memset(&TxConfig, 0 , sizeof(ETH_TxPacketConfig)); TxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CSUM | ETH_TX_PACKETS_FEATURES_CRCPAD; TxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC; TxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT; /* USER CODE BEGIN ETH_Init 2 */ /* USER CODE END ETH_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 = 0x307075B1; 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(); } /* USER CODE BEGIN I2C1_Init 2 */ /* USER CODE END I2C1_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}; LTDC_LayerCfgTypeDef pLayerCfg1 = {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_AL; hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL; hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC; hltdc.Init.HorizontalSync = 7; hltdc.Init.VerticalSync = 3; hltdc.Init.AccumulatedHBP = 14; hltdc.Init.AccumulatedVBP = 5; hltdc.Init.AccumulatedActiveW = 654; hltdc.Init.AccumulatedActiveH = 485; hltdc.Init.TotalWidth = 660; hltdc.Init.TotalHeigh = 487; 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 = 0; pLayerCfg.WindowY0 = 0; pLayerCfg.WindowY1 = 0; pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; pLayerCfg.Alpha = 0; pLayerCfg.Alpha0 = 0; pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA; pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA; pLayerCfg.FBStartAdress = 0; pLayerCfg.ImageWidth = 0; pLayerCfg.ImageHeight = 0; pLayerCfg.Backcolor.Blue = 0; pLayerCfg.Backcolor.Green = 0; pLayerCfg.Backcolor.Red = 0; if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) { Error_Handler(); } pLayerCfg1.WindowX0 = 0; pLayerCfg1.WindowX1 = 0; pLayerCfg1.WindowY0 = 0; pLayerCfg1.WindowY1 = 0; pLayerCfg1.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888; pLayerCfg1.Alpha = 0; pLayerCfg1.Alpha0 = 0; pLayerCfg1.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA; pLayerCfg1.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA; pLayerCfg1.FBStartAdress = 0; pLayerCfg1.ImageWidth = 0; pLayerCfg1.ImageHeight = 0; pLayerCfg1.Backcolor.Blue = 0; pLayerCfg1.Backcolor.Green = 0; pLayerCfg1.Backcolor.Red = 0; if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg1, 1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN LTDC_Init 2 */ /* 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 = 255; hqspi.Init.FifoThreshold = 1; hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE; hqspi.Init.FlashSize = 1; hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE; hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0; hqspi.Init.DualFlash = QSPI_DUALFLASH_ENABLE; if (HAL_QSPI_Init(&hqspi) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN QUADSPI_Init 2 */ /* USER CODE END QUADSPI_Init 2 */ } /** * @brief SAI1 Initialization Function * @param None * @retval None */ static void MX_SAI1_Init(void) { /* USER CODE BEGIN SAI1_Init 0 */ /* USER CODE END SAI1_Init 0 */ /* USER CODE BEGIN SAI1_Init 1 */ /* USER CODE END SAI1_Init 1 */ hsai_BlockA1.Instance = SAI1_Block_A; hsai_BlockA1.Init.Protocol = SAI_FREE_PROTOCOL; hsai_BlockA1.Init.AudioMode = SAI_MODEMASTER_TX; hsai_BlockA1.Init.DataSize = SAI_DATASIZE_8; hsai_BlockA1.Init.FirstBit = SAI_FIRSTBIT_MSB; hsai_BlockA1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS; hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; hsai_BlockA1.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE; hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; hsai_BlockA1.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_192K; hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE; hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING; hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED; hsai_BlockA1.Init.PdmInit.Activation = DISABLE; hsai_BlockA1.Init.PdmInit.MicPairsNbr = 1; hsai_BlockA1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; hsai_BlockA1.FrameInit.FrameLength = 8; hsai_BlockA1.FrameInit.ActiveFrameLength = 1; hsai_BlockA1.FrameInit.FSDefinition = SAI_FS_STARTFRAME; hsai_BlockA1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; hsai_BlockA1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; hsai_BlockA1.SlotInit.FirstBitOffset = 0; hsai_BlockA1.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE; hsai_BlockA1.SlotInit.SlotNumber = 1; hsai_BlockA1.SlotInit.SlotActive = 0x00000000; if (HAL_SAI_Init(&hsai_BlockA1) != HAL_OK) { Error_Handler(); } hsai_BlockB1.Instance = SAI1_Block_B; hsai_BlockB1.Init.Protocol = SAI_FREE_PROTOCOL; hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX; hsai_BlockB1.Init.DataSize = SAI_DATASIZE_8; hsai_BlockB1.Init.FirstBit = SAI_FIRSTBIT_MSB; hsai_BlockB1.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE; hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS; hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE; hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY; hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE; hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE; hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING; hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED; hsai_BlockB1.Init.PdmInit.Activation = DISABLE; hsai_BlockB1.Init.PdmInit.MicPairsNbr = 1; hsai_BlockB1.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE; hsai_BlockB1.FrameInit.FrameLength = 8; hsai_BlockB1.FrameInit.ActiveFrameLength = 1; hsai_BlockB1.FrameInit.FSDefinition = SAI_FS_STARTFRAME; hsai_BlockB1.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW; hsai_BlockB1.FrameInit.FSOffset = SAI_FS_FIRSTBIT; hsai_BlockB1.SlotInit.FirstBitOffset = 0; hsai_BlockB1.SlotInit.SlotSize = SAI_SLOTSIZE_DATASIZE; hsai_BlockB1.SlotInit.SlotNumber = 1; hsai_BlockB1.SlotInit.SlotActive = 0x00000000; if (HAL_SAI_Init(&hsai_BlockB1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN SAI1_Init 2 */ /* USER CODE END SAI1_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.Init.ClockPrescaler = UART_PRESCALER_DIV1; huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT; if (HAL_UART_Init(&huart1) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_SetTxFifoThreshold(&huart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_SetRxFifoThreshold(&huart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK) { Error_Handler(); } if (HAL_UARTEx_DisableFifoMode(&huart1) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USART1_Init 2 */ HAL_UART_MspInit(&huart1); /* USER CODE END USART1_Init 2 */ } /** * @brief USB_OTG_FS Initialization Function * @param None * @retval None */ static void MX_USB_OTG_FS_PCD_Init(void) { /* USER CODE BEGIN USB_OTG_FS_Init 0 */ /* USER CODE END USB_OTG_FS_Init 0 */ /* USER CODE BEGIN USB_OTG_FS_Init 1 */ /* USER CODE END USB_OTG_FS_Init 1 */ hpcd_USB_OTG_FS.Instance = USB_OTG_FS; hpcd_USB_OTG_FS.Init.dev_endpoints = 9; hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_FS.Init.battery_charging_enable = DISABLE; hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE; hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USB_OTG_FS_Init 2 */ /* USER CODE END USB_OTG_FS_Init 2 */ } /** * @brief USB_OTG_HS Initialization Function * @param None * @retval None */ static void MX_USB_OTG_HS_PCD_Init(void) { /* USER CODE BEGIN USB_OTG_HS_Init 0 */ /* USER CODE END USB_OTG_HS_Init 0 */ /* USER CODE BEGIN USB_OTG_HS_Init 1 */ /* USER CODE END USB_OTG_HS_Init 1 */ hpcd_USB_OTG_HS.Instance = USB_OTG_HS; hpcd_USB_OTG_HS.Init.dev_endpoints = 9; hpcd_USB_OTG_HS.Init.speed = PCD_SPEED_HIGH; hpcd_USB_OTG_HS.Init.dma_enable = DISABLE; hpcd_USB_OTG_HS.Init.phy_itface = USB_OTG_ULPI_PHY; hpcd_USB_OTG_HS.Init.Sof_enable = DISABLE; hpcd_USB_OTG_HS.Init.low_power_enable = DISABLE; hpcd_USB_OTG_HS.Init.lpm_enable = DISABLE; hpcd_USB_OTG_HS.Init.vbus_sensing_enable = DISABLE; hpcd_USB_OTG_HS.Init.use_dedicated_ep1 = DISABLE; hpcd_USB_OTG_HS.Init.use_external_vbus = DISABLE; if (HAL_PCD_Init(&hpcd_USB_OTG_HS) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN USB_OTG_HS_Init 2 */ /* USER CODE END USB_OTG_HS_Init 2 */ } /* FMC initialization function */ static void MX_FMC_Init(void) { /* USER CODE BEGIN FMC_Init 0 */ /* USER CODE END FMC_Init 0 */ FMC_NORSRAM_TimingTypeDef Timing = {0}; FMC_SDRAM_TimingTypeDef SdramTiming = {0}; /* USER CODE BEGIN FMC_Init 1 */ /* USER CODE END FMC_Init 1 */ /** Perform the NOR1 memory initialization sequence */ hnor1.Instance = FMC_NORSRAM_DEVICE; hnor1.Extended = FMC_NORSRAM_EXTENDED_DEVICE; /* hnor1.Init */ hnor1.Init.NSBank = FMC_NORSRAM_BANK1; hnor1.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; hnor1.Init.MemoryType = FMC_MEMORY_TYPE_NOR; hnor1.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16; hnor1.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE; hnor1.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; hnor1.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; hnor1.Init.WriteOperation = FMC_WRITE_OPERATION_DISABLE; hnor1.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; hnor1.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; hnor1.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_ENABLE; hnor1.Init.WriteBurst = FMC_WRITE_BURST_DISABLE; hnor1.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY; hnor1.Init.WriteFifo = FMC_WRITE_FIFO_ENABLE; hnor1.Init.PageSize = FMC_PAGE_SIZE_NONE; /* Timing */ Timing.AddressSetupTime = 15; Timing.AddressHoldTime = 15; Timing.DataSetupTime = 255; Timing.BusTurnAroundDuration = 15; Timing.CLKDivision = 16; Timing.DataLatency = 17; Timing.AccessMode = FMC_ACCESS_MODE_A; /* ExtTiming */ if (HAL_NOR_Init(&hnor1, &Timing, NULL) != HAL_OK) { Error_Handler( ); } /** Perform the SRAM2 memory initialization sequence */ hsram2.Instance = FMC_NORSRAM_DEVICE; hsram2.Extended = FMC_NORSRAM_EXTENDED_DEVICE; /* hsram2.Init */ hsram2.Init.NSBank = FMC_NORSRAM_BANK3; hsram2.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE; hsram2.Init.MemoryType = FMC_MEMORY_TYPE_SRAM; hsram2.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_16; hsram2.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE; hsram2.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW; hsram2.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS; hsram2.Init.WriteOperation = FMC_WRITE_OPERATION_DISABLE; hsram2.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE; hsram2.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE; hsram2.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_ENABLE; hsram2.Init.WriteBurst = FMC_WRITE_BURST_DISABLE; hsram2.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY; hsram2.Init.WriteFifo = FMC_WRITE_FIFO_ENABLE; hsram2.Init.PageSize = FMC_PAGE_SIZE_NONE; /* Timing */ Timing.AddressSetupTime = 15; Timing.AddressHoldTime = 15; Timing.DataSetupTime = 255; Timing.BusTurnAroundDuration = 15; Timing.CLKDivision = 16; Timing.DataLatency = 17; Timing.AccessMode = FMC_ACCESS_MODE_A; /* ExtTiming */ if (HAL_SRAM_Init(&hsram2, &Timing, NULL) != HAL_OK) { Error_Handler( ); } /** Perform the SDRAM1 memory initialization sequence */ hsdram1.Instance = FMC_SDRAM_DEVICE; /* hsdram1.Init */ hsdram1.Init.SDBank = FMC_SDRAM_BANK2; hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_11; hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_1; hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_DISABLE; hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_DISABLE; hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; /* SdramTiming */ SdramTiming.LoadToActiveDelay = 16; SdramTiming.ExitSelfRefreshDelay = 16; SdramTiming.SelfRefreshTime = 16; SdramTiming.RowCycleDelay = 16; SdramTiming.WriteRecoveryTime = 16; SdramTiming.RPDelay = 16; SdramTiming.RCDDelay = 16; if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) { Error_Handler( ); } /* USER CODE BEGIN FMC_Init 2 */ /* 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_GPIOI_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOK_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE(); __HAL_RCC_GPIOD_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOJ_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); __HAL_RCC_GPIOF_CLK_ENABLE(); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(FDCAN1_STBY_GPIO_Port, FDCAN1_STBY_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(LED1_RGB_GPIO_Port, LED1_RGB_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOA, LCD_BL_CTRL_Pin|LED3_RGB_Pin, GPIO_PIN_RESET); /*Configure GPIO pins : SDIO1_D2_Pin SDIO1_D3_Pin SDIO1_CLK_Pin SDIO1_D0_Pin SDIO1_D1_Pin */ GPIO_InitStruct.Pin = SDIO1_D2_Pin|SDIO1_D3_Pin|SDIO1_CLK_Pin|SDIO1_D0_Pin |SDIO1_D1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_SDIO1; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : FDCAN1_STBY_Pin */ GPIO_InitStruct.Pin = FDCAN1_STBY_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(FDCAN1_STBY_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PDM1_CLK_Pin */ GPIO_InitStruct.Pin = PDM1_CLK_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF10_SAI4; HAL_GPIO_Init(PDM1_CLK_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : SDIO1_CDIR_Pin SDIO1_CKIN_Pin */ GPIO_InitStruct.Pin = SDIO1_CDIR_Pin|SDIO1_CKIN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF7_SDIO1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pin : SDIO1_CMD_Pin */ GPIO_InitStruct.Pin = SDIO1_CMD_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_SDIO1; HAL_GPIO_Init(SDIO1_CMD_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : MFX_IRQOUT_Pin */ GPIO_InitStruct.Pin = MFX_IRQOUT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(MFX_IRQOUT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : MCO_Pin */ GPIO_InitStruct.Pin = MCO_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF0_MCO; HAL_GPIO_Init(MCO_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : SDIO1_D123DIR_Pin SDIO1_D0DIR_Pin */ GPIO_InitStruct.Pin = SDIO1_D123DIR_Pin|SDIO1_D0DIR_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Alternate = GPIO_AF8_SDIO1; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : LED1_RGB_Pin */ GPIO_InitStruct.Pin = LED1_RGB_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(LED1_RGB_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : LCD_BL_CTRL_Pin LED3_RGB_Pin */ GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin|LED3_RGB_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ } /* USER CODE BEGIN 4 */ /* USER CODE END 4 */ /** * @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 */ __disable_irq(); while (1) { } /* 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, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */