/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOF_CLK_ENABLE() ; __GPIOH_CLK_ENABLE() ; __GPIOA_CLK_ENABLE() ; __GPIOB_CLK_ENABLE() ; __GPIOI_CLK_ENABLE() ; __GPIOC_CLK_ENABLE() ; /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(GPIOF, LED1_Pin | LED2_Pin | LED3_Pin | LED4_Pin, GPIO_PIN_RESET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET); /*Configure GPIO pin Output Level */ HAL_GPIO_WritePin(DS3234_CS_GPIO_Port, DS3234_CS_Pin, GPIO_PIN_SET); /*Configure GPIO pins : LED1_Pin LED2_Pin LED3_Pin LED4_Pin */ GPIO_InitStruct.Pin = LED1_Pin | LED2_Pin | LED3_Pin | LED4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pin : SPI_CS_Pin */ GPIO_InitStruct.Pin = SPI_CS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(SPI_CS_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : ONEHZ_EXTI_Pin */ GPIO_InitStruct.Pin = ONEHZ_EXTI_Pin; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(ONEHZ_EXTI_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : DS3234_CS_Pin */ GPIO_InitStruct.Pin = DS3234_CS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(DS3234_CS_GPIO_Port, &GPIO_InitStruct); /* EXTI interrupt init*/ HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0); HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); }
static void LED_Thread1(void const *argument) { GPIO_InitTypeDef GPIO_InitStruct_LED, GPIO_InitStruct_BUTTON; /* GPIO Ports Clock Enable */ __GPIOI_CLK_ENABLE(); /*Configure GPIO pin : PI1 */ GPIO_InitStruct_LED.Pin = GPIO_PIN_1; GPIO_InitStruct_LED.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct_LED.Pull = GPIO_NOPULL; GPIO_InitStruct_LED.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct_LED); GPIO_InitStruct_BUTTON.Pin = GPIO_PIN_11; GPIO_InitStruct_BUTTON.Mode = GPIO_MODE_INPUT; GPIO_InitStruct_BUTTON.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct_BUTTON); while(1) { if(HAL_GPIO_ReadPin(GPIOI, GPIO_PIN_11)){ HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_1); HAL_Delay(500); printf("Pintando \n"); } HAL_GPIO_WritePin(GPIOI, GPIO_PIN_1, 0); } }
void Raw32OSInit(void) { /* Enable the CPU Cache's */ SCB_EnableICache(); // Enable I-Cache SCB_EnableDCache(); // Enable D-Cache /* STM32F7xx HAL library initialization: - Configure the Flash ART accelerator on ITCM interface - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock to 216 MHz */ SystemClock_Config(); #if !GFX_USE_OS_CHIBIOS // LED - for testing GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = GPIO_PIN_1; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; __GPIOI_CLK_ENABLE(); HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); #endif }
/************************************************************************************************************** * Function Name : bsp_GPIOxClockEnable * Description : Enable specific GPIO Port clock * Input Variable : GPIO Port * Return Variable : None * Author : Bryant * Create Date : Sep-29-2015 * Call : Outside ****************************************************************************************************************/ void bsp_GPIOxClockEnable(GPIO_TypeDef* gpioPort) { if(gpioPort==GPIOA) __GPIOA_CLK_ENABLE(); if(gpioPort==GPIOB) __GPIOB_CLK_ENABLE(); if(gpioPort==GPIOC) __GPIOC_CLK_ENABLE(); if(gpioPort==GPIOD) __GPIOD_CLK_ENABLE(); if(gpioPort==GPIOE) __GPIOE_CLK_ENABLE(); if(gpioPort==GPIOF) __GPIOF_CLK_ENABLE(); if(gpioPort==GPIOG) __GPIOG_CLK_ENABLE(); if(gpioPort==GPIOH) __GPIOH_CLK_ENABLE(); if(gpioPort==GPIOI) __GPIOI_CLK_ENABLE(); if(gpioPort==GPIOJ) __GPIOJ_CLK_ENABLE(); if(gpioPort==GPIOK) __GPIOK_CLK_ENABLE(); }
void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio) { if (0) { #ifdef __GPIOA_CLK_ENABLE } else if (gpio == GPIOA) { __GPIOA_CLK_ENABLE(); #endif #ifdef __GPIOB_CLK_ENABLE } else if (gpio == GPIOB) { __GPIOB_CLK_ENABLE(); #endif #ifdef __GPIOC_CLK_ENABLE } else if (gpio == GPIOC) { __GPIOC_CLK_ENABLE(); #endif #ifdef __GPIOD_CLK_ENABLE } else if (gpio == GPIOD) { __GPIOD_CLK_ENABLE(); #endif #ifdef __GPIOE_CLK_ENABLE } else if (gpio == GPIOE) { __GPIOE_CLK_ENABLE(); #endif #ifdef __GPIOF_CLK_ENABLE } else if (gpio == GPIOF) { __GPIOF_CLK_ENABLE(); #endif #ifdef __GPIOG_CLK_ENABLE } else if (gpio == GPIOG) { __GPIOG_CLK_ENABLE(); #endif #ifdef __GPIOH_CLK_ENABLE } else if (gpio == GPIOH) { __GPIOH_CLK_ENABLE(); #endif #ifdef __GPIOI_CLK_ENABLE } else if (gpio == GPIOI) { __GPIOI_CLK_ENABLE(); #endif #ifdef __GPIOJ_CLK_ENABLE } else if (gpio == GPIOJ) { __GPIOJ_CLK_ENABLE(); #endif #ifdef __GPIOK_CLK_ENABLE } else if (gpio == GPIOK) { __GPIOK_CLK_ENABLE(); #endif } }
F7GPIO::F7GPIO(GPIO_TypeDef* GPIOx,uint32_t GPIO_Pin) { __GPIOE_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOJ_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); __GPIOK_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); this->GPIOx = GPIOx; this->GPIO_Pin = GPIO_Pin; }
// Enable GPIO clock and return GPIO base address uint32_t Set_GPIO_Clock(uint32_t port_idx) { uint32_t gpio_add = 0; switch (port_idx) { case PortA: gpio_add = GPIOA_BASE; __GPIOA_CLK_ENABLE(); break; case PortB: gpio_add = GPIOB_BASE; __GPIOB_CLK_ENABLE(); break; case PortC: gpio_add = GPIOC_BASE; __GPIOC_CLK_ENABLE(); break; case PortD: gpio_add = GPIOD_BASE; __GPIOD_CLK_ENABLE(); break; case PortE: gpio_add = GPIOE_BASE; __GPIOE_CLK_ENABLE(); break; case PortF: gpio_add = GPIOF_BASE; __GPIOF_CLK_ENABLE(); break; case PortG: gpio_add = GPIOG_BASE; __GPIOG_CLK_ENABLE(); break; case PortH: gpio_add = GPIOH_BASE; __GPIOH_CLK_ENABLE(); break; case PortI: gpio_add = GPIOI_BASE; __GPIOI_CLK_ENABLE(); break; default: error("Pinmap error: wrong port number."); break; } return gpio_add; }
void vFreeRTOSInitAll() { /* This sample code shows how to use STM32F2xx GPIO HAL API to toggle PG6, PG7, PG10, and PG12 IOs (connected to LED1, LED2, LED3 and LED4 on STM322xG-EVAL board) in an infinite loop. To proceed, 3 steps are required: */ /* STM32F2xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* -1- Enable GPIOG, GPIOC and GPIOI Clock (to be able to program the configuration registers) */ __GPIOG_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); /* -2- Configure PG.6, PG.8, PI.9 and PC.7 IOs in output push-pull mode to drive external LEDs */ GPIO_InitStruct.Pin = (GPIO_PIN_6 | GPIO_PIN_8); GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); }
/** * @brief LTDC MSP Initialization * This function configures the hardware resources used in this example: * - Peripheral's clock enable * - Peripheral's GPIO Configuration * @param hltdc: LTDC handle pointer * @retval None */ void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc) { GPIO_InitTypeDef GPIO_Init_Structure; /*##-1- Enable peripherals and GPIO Clocks #################################*/ /* Enable the LTDC Clock */ __LTDC_CLK_ENABLE(); /* Enable GPIO Clock */ __GPIOI_CLK_ENABLE(); __GPIOJ_CLK_ENABLE(); __GPIOK_CLK_ENABLE(); /*##-2- Configure peripheral GPIO ##########################################*/ /******************** LTDC Pins configuration *************************/ /* LTDC pins configuraiton: PI12 -- 15 */ GPIO_Init_Structure.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOI, &GPIO_Init_Structure); /* LTDC pins configuraiton: PJ0 -- 15 */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \ GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \ GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOJ, &GPIO_Init_Structure); /* LTDC pins configuraiton: PK0 -- 7 */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOK, &GPIO_Init_Structure); }
/** * @brief Initializes the LTDC MSP. * @param None * @retval None */ static void MspInit(void) { GPIO_InitTypeDef GPIO_Init_Structure; /* Enable the LTDC and DMA2D clocks */ __LTDC_CLK_ENABLE(); __DMA2D_CLK_ENABLE(); /* Enable GPIOs clock */ __GPIOI_CLK_ENABLE(); __GPIOJ_CLK_ENABLE(); __GPIOK_CLK_ENABLE(); /*** LTDC Pins configuration ***/ /* GPIOI configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOI, &GPIO_Init_Structure); /* GPIOJ configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \ GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \ GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOJ, &GPIO_Init_Structure); /* GPIOK configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOK, &GPIO_Init_Structure); }
GPIOPins::GPIOPins(GPIO_TypeDef *peripheral, std::initializer_list<Pin> pins, Mode mode, Pull pull, Speed speed, AlternateFunction alternate /*= AlternateFunction::None*/) { this->peripheral = peripheral; for (const auto &pin : pins) { pins_bitmask |= std::bitset<16>(static_cast<uint16_t>(pin)); } //if (std::find(initialized_peripherals.begin(), initialized_peripherals.end(), peripheral) == initialized_peripherals.end()) { if (peripheral == GPIOA) __GPIOA_CLK_ENABLE(); else if (peripheral == GPIOB) __GPIOB_CLK_ENABLE(); else if (peripheral == GPIOC) __GPIOC_CLK_ENABLE(); else if (peripheral == GPIOD) __GPIOD_CLK_ENABLE(); else if (peripheral == GPIOE) __GPIOE_CLK_ENABLE(); else if (peripheral == GPIOF) __GPIOF_CLK_ENABLE(); else if (peripheral == GPIOG) __GPIOG_CLK_ENABLE(); else if (peripheral == GPIOH) __GPIOH_CLK_ENABLE(); else if (peripheral == GPIOI) __GPIOI_CLK_ENABLE(); //} //initialized_peripherals.push_back(peripheral); auto init_configuration = GPIO_InitTypeDef(); init_configuration.Pin = pins_bitmask.to_ulong(); init_configuration.Mode = static_cast<uint32_t>(mode); init_configuration.Pull = static_cast<uint32_t>(pull); init_configuration.Speed = static_cast<uint32_t>(speed); if (alternate != AlternateFunction::None) init_configuration.Alternate = static_cast<uint8_t>(alternate); HAL_GPIO_Init(peripheral, &init_configuration); }
/** * @brief Configure all GPIO's to AN to reduce the power consumption * @param None * @retval None */ static void GPIO_ConfigAN(void) { GPIO_InitTypeDef GPIO_InitStruct; /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Enable GPIOs clock */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pin = GPIO_PIN_All; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* Disable GPIOs clock */ __GPIOA_CLK_DISABLE(); __GPIOB_CLK_DISABLE(); __GPIOC_CLK_DISABLE(); __GPIOD_CLK_DISABLE(); __GPIOE_CLK_DISABLE(); __GPIOF_CLK_DISABLE(); __GPIOG_CLK_DISABLE(); __GPIOH_CLK_DISABLE(); __GPIOI_CLK_DISABLE(); }
/** * @brief Configures I2C Interrupt. * @param None * @retval None */ static void I2Cx_ITConfig(void) { static uint8_t I2C_IT_Enabled = 0; GPIO_InitTypeDef GPIO_InitStruct; if(I2C_IT_Enabled == 0) { I2C_IT_Enabled = 1; /* Enable the GPIO EXTI clock */ __GPIOI_CLK_ENABLE(); __SYSCFG_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_2; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FAST; GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /* Set priority and Enable GPIO EXTI Interrupt */ HAL_NVIC_SetPriority((IRQn_Type)(EXTI2_IRQn), 5, 0); HAL_NVIC_EnableIRQ((IRQn_Type)(EXTI2_IRQn)); } }
/** * @brief Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) { GPIO_InitTypeDef GPIO_InitStruct; if(hpcd->Instance == USB_OTG_FS) { /* Configure USB FS GPIOs */ __GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Configure VBUS Pin */ #if defined(MICROPY_HW_USB_VBUS_DETECT_PIN) // USB VBUS detect pin is always A9 GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); #endif #if defined(MICROPY_HW_USB_OTG_ID_PIN) // USB ID pin is always A10 GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); #endif /* Enable USB FS Clocks */ __USB_OTG_FS_CLK_ENABLE(); /* Set USBFS Interrupt priority */ HAL_NVIC_SetPriority(OTG_FS_IRQn, 6, 0); /* Enable USBFS Interrupt */ HAL_NVIC_EnableIRQ(OTG_FS_IRQn); } #if defined(USE_USB_HS) else if(hpcd->Instance == USB_OTG_HS) { /* Configure USB FS GPIOs */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); /* CLK */ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D0 */ GPIO_InitStruct.Pin = GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D1 D2 D3 D4 D5 D6 D7 */ GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 |\ GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* STP */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* NXT */ GPIO_InitStruct.Pin = GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /* DIR */ GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /* Enable USB HS Clocks */ __USB_OTG_HS_CLK_ENABLE(); __USB_OTG_HS_ULPI_CLK_ENABLE(); /* Set USBHS Interrupt to the lowest priority */ HAL_NVIC_SetPriority(OTG_HS_IRQn, 6, 0); /* Enable USBHS Interrupt */ HAL_NVIC_EnableIRQ(OTG_HS_IRQn); } #endif }
/** * @brief Initializes the DCMI MSP. * @param None * @retval None */ static void DCMI_MspInit(void) { static DMA_HandleTypeDef hdma; GPIO_InitTypeDef GPIO_Init_Structure; DCMI_HandleTypeDef *hdcmi = &hdcmi_eval; /*** Enable peripherals and GPIO clocks ***/ /* Enable DCMI clock */ __DCMI_CLK_ENABLE(); /* Enable DMA2 clock */ __DMA2_CLK_ENABLE(); /* Enable GPIO clocks */ __GPIOA_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); /*** Configure the GPIO ***/ /* Configure DCMI GPIO as alternate function */ GPIO_Init_Structure.Pin = GPIO_PIN_6; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_PULLUP; GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOA, &GPIO_Init_Structure); GPIO_Init_Structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 |\ GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_PULLUP; GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOH, &GPIO_Init_Structure); GPIO_Init_Structure.Pin = GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |\ GPIO_PIN_7; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_PULLUP; GPIO_Init_Structure.Speed = GPIO_SPEED_HIGH; GPIO_Init_Structure.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOI, &GPIO_Init_Structure); /*** Configure the DMA streams ***/ /* Configure the DMA handler for Transmission process */ hdma.Init.Channel = DMA_CHANNEL_1; hdma.Init.Direction = DMA_PERIPH_TO_MEMORY; hdma.Init.PeriphInc = DMA_PINC_DISABLE; hdma.Init.MemInc = DMA_MINC_ENABLE; hdma.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; hdma.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; hdma.Init.Mode = DMA_CIRCULAR; hdma.Init.Priority = DMA_PRIORITY_HIGH; hdma.Init.FIFOMode = DMA_FIFOMODE_DISABLE; hdma.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; hdma.Init.MemBurst = DMA_MBURST_SINGLE; hdma.Init.PeriphBurst = DMA_PBURST_SINGLE; hdma.Instance = DMA2_Stream1; /* Associate the initialized DMA handle to the DCMI handle */ __HAL_LINKDMA(hdcmi, DMA_Handle, hdma); /*** Configure the NVIC for DCMI and DMA ***/ /* NVIC configuration for DCMI transfer complete interrupt */ HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0); HAL_NVIC_EnableIRQ(DCMI_IRQn); /* NVIC configuration for DMA2 transfer complete interrupt */ HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); /* Configure the DMA stream */ HAL_DMA_Init(hdcmi->DMA_Handle); }
/** * @brief Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) { GPIO_InitTypeDef GPIO_InitStruct; if(hpcd->Instance == USB_OTG_FS) { /* Configure USB FS GPIOs */ __GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Configure VBUS Pin */ #if defined(MICROPY_HW_USB_VBUS_DETECT_PIN) // USB VBUS detect pin is always A9 GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); #endif #if defined(MICROPY_HW_USB_OTG_ID_PIN) // USB ID pin is always A10 GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); #endif /* Enable USB FS Clocks */ __USB_OTG_FS_CLK_ENABLE(); #if defined (MCU_SERIES_L4) /* Enable VDDUSB */ if(__HAL_RCC_PWR_IS_CLK_DISABLED()) { __HAL_RCC_PWR_CLK_ENABLE(); HAL_PWREx_EnableVddUSB(); __HAL_RCC_PWR_CLK_DISABLE(); } else { HAL_PWREx_EnableVddUSB(); } #endif /* Set USBFS Interrupt priority */ HAL_NVIC_SetPriority(OTG_FS_IRQn, IRQ_PRI_OTG_FS, IRQ_SUBPRI_OTG_FS); /* Enable USBFS Interrupt */ HAL_NVIC_EnableIRQ(OTG_FS_IRQn); } #if defined(USE_USB_HS) else if(hpcd->Instance == USB_OTG_HS) { #if defined(USE_USB_HS_IN_FS) /* Configure USB FS GPIOs */ __GPIOB_CLK_ENABLE(); /* Configure DM DP Pins */ GPIO_InitStruct.Pin = (GPIO_PIN_14 | GPIO_PIN_15); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); #if defined(MICROPY_HW_USB_VBUS_DETECT_PIN) /* Configure VBUS Pin */ GPIO_InitStruct.Pin = GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); #endif #if defined(MICROPY_HW_USB_OTG_ID_PIN) /* Configure ID pin */ GPIO_InitStruct.Pin = GPIO_PIN_12; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); #endif /* * Enable calling WFI and correct * function of the embedded USB_FS_IN_HS phy */ __OTGHSULPI_CLK_SLEEP_DISABLE(); __OTGHS_CLK_SLEEP_ENABLE(); /* Enable USB HS Clocks */ __USB_OTG_HS_CLK_ENABLE(); #else // !USE_USB_HS_IN_FS /* Configure USB HS GPIOs */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); /* CLK */ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D0 */ GPIO_InitStruct.Pin = GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D1 D2 D3 D4 D5 D6 D7 */ GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 |\ GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* STP */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* NXT */ GPIO_InitStruct.Pin = GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /* DIR */ GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /* Enable USB HS Clocks */ __USB_OTG_HS_CLK_ENABLE(); __USB_OTG_HS_ULPI_CLK_ENABLE(); #endif // !USE_USB_HS_IN_FS /* Set USBHS Interrupt to the lowest priority */ HAL_NVIC_SetPriority(OTG_HS_IRQn, IRQ_PRI_OTG_HS, IRQ_SUBPRI_OTG_HS); /* Enable USBHS Interrupt */ HAL_NVIC_EnableIRQ(OTG_HS_IRQn); } #endif // USE_USB_HS }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI PB5 ------> USB_OTG_HS_ULPI_D7 PB4 ------> S_TIM3_CH1 PA15 ------> S_TIM2_CH1_ETR PA12 ------> USB_OTG_FS_DP PI4 ------> SAI2_MCLK_A PG10 ------> SAI2_SD_B PA11 ------> USB_OTG_FS_DM PI5 ------> SAI2_SCK_A PI7 ------> SAI2_FS_A PI6 ------> SAI2_SD_A PI1 ------> SPI2_SCK PA10 ------> USB_OTG_FS_ID PI0 ------> S_TIM5_CH4 PA8 ------> S_TIM1_CH1 PC7 ------> USART6_RX PH4 ------> USB_OTG_HS_ULPI_NXT PC6 ------> USART6_TX PF7 ------> ADC3_IN5 PF6 ------> ADC3_IN4 PB13 ------> USB_OTG_HS_ULPI_D6 PF10 ------> ADC3_IN8 PF9 ------> ADC3_IN7 PF8 ------> ADC3_IN6 PB12 ------> USB_OTG_HS_ULPI_D5 PC0 ------> USB_OTG_HS_ULPI_STP PC2 ------> USB_OTG_HS_ULPI_DIR PA0/WKUP ------> ADCx_IN0 PH7 ------> I2C3_SCL PA5 ------> USB_OTG_HS_ULPI_CK PB10 ------> USB_OTG_HS_ULPI_D3 PH6 ------> S_TIM12_CH1 PH8 ------> I2C3_SDA PA3 ------> USB_OTG_HS_ULPI_D0 PB1 ------> USB_OTG_HS_ULPI_D2 PB0 ------> USB_OTG_HS_ULPI_D1 PB11 ------> USB_OTG_HS_ULPI_D4 PB14 ------> SPI2_MISO PB15 ------> SPI2_MOSI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOE_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOJ_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); __GPIOK_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); /*Configure GPIO pin : OTG_HS_OverCurrent_Pin */ GPIO_InitStruct.Pin = OTG_HS_OverCurrent_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_HS_OverCurrent_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : ULPI_D7_Pin ULPI_D6_Pin ULPI_D5_Pin ULPI_D3_Pin ULPI_D2_Pin ULPI_D1_Pin ULPI_D4_Pin */ GPIO_InitStruct.Pin = ULPI_D7_Pin|ULPI_D6_Pin|ULPI_D5_Pin|ULPI_D3_Pin |ULPI_D2_Pin|ULPI_D1_Pin|ULPI_D4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_D3_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; HAL_GPIO_Init(ARDUINO_PWM_D3_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_D9_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D9_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; HAL_GPIO_Init(ARDUINO_PWM_D9_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : OTG_FS_VBUS_Pin */ GPIO_InitStruct.Pin = OTG_FS_VBUS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_FS_VBUS_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : Audio_INT_Pin */ GPIO_InitStruct.Pin = Audio_INT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : OTG_FS_P_Pin OTG_FS_N_Pin OTG_FS_ID_Pin */ GPIO_InitStruct.Pin = OTG_FS_P_Pin|OTG_FS_N_Pin|OTG_FS_ID_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pins : SAI2_MCLKA_Pin SAI2_SCKA_Pin SAI2_FSA_Pin SAI2_SDA_Pin */ GPIO_InitStruct.Pin = SAI2_MCLKA_Pin|SAI2_SCKA_Pin|SAI2_FSA_Pin|SAI2_SDA_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF10_SAI2; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /*Configure GPIO pin : SAI2_SDB_Pin */ GPIO_InitStruct.Pin = SAI2_SDB_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF10_SAI2; HAL_GPIO_Init(SAI2_SDB_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : OTG_FS_PowerSwitchOn_Pin */ GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_D7_Pin ARDUINO_D8_Pin LCD_DISP_Pin */ GPIO_InitStruct.Pin = ARDUINO_D7_Pin|ARDUINO_D8_Pin|LCD_DISP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /*Configure GPIO pin : uSD_Detect_Pin */ GPIO_InitStruct.Pin = uSD_Detect_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(uSD_Detect_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_LOW; HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : OTG_FS_OverCurrent_Pin */ GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : TP3_Pin NC2_Pin */ GPIO_InitStruct.Pin = TP3_Pin|NC2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_SCK_D13_Pin */ GPIO_InitStruct.Pin = ARDUINO_SCK_D13_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(ARDUINO_SCK_D13_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : DCMI_PWR_EN_Pin */ GPIO_InitStruct.Pin = DCMI_PWR_EN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(DCMI_PWR_EN_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_CS_D10_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_CS_D10_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; HAL_GPIO_Init(ARDUINO_PWM_CS_D10_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_D5_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D5_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; HAL_GPIO_Init(ARDUINO_PWM_D5_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : LCD_INT_Pin */ GPIO_InitStruct.Pin = LCD_INT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_RX_D0_Pin ARDUINO_TX_D1_Pin */ GPIO_InitStruct.Pin = ARDUINO_RX_D0_Pin|ARDUINO_TX_D1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF8_USART6; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : ULPI_NXT_Pin */ GPIO_InitStruct.Pin = ULPI_NXT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(ULPI_NXT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_D4_Pin ARDUINO_D2_Pin EXT_RST_Pin */ GPIO_InitStruct.Pin = ARDUINO_D4_Pin|ARDUINO_D2_Pin|EXT_RST_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_A4_Pin ARDUINO_A5_Pin ARDUINO_A1_Pin ARDUINO_A2_Pin ARDUINO_A3_Pin */ GPIO_InitStruct.Pin = ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A2_Pin |ARDUINO_A3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pins : ULPI_STP_Pin ULPI_DIR_Pin */ GPIO_InitStruct.Pin = ULPI_STP_Pin|ULPI_DIR_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : RMII_RXER_Pin */ GPIO_InitStruct.Pin = RMII_RXER_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(RMII_RXER_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_A0_Pin */ GPIO_InitStruct.Pin = ARDUINO_A0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(ARDUINO_A0_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : LCD_SCL_Pin LCD_SDA_Pin */ GPIO_InitStruct.Pin = LCD_SCL_Pin|LCD_SDA_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF4_I2C3; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /*Configure GPIO pins : ULPI_CLK_Pin ULPI_D0_Pin */ GPIO_InitStruct.Pin = ULPI_CLK_Pin|ULPI_D0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_D6_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D6_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF9_TIM12; HAL_GPIO_Init(ARDUINO_PWM_D6_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_MISO_D12_Pin ARDUINO_MOSI_PWM_D11_Pin */ GPIO_InitStruct.Pin = ARDUINO_MISO_D12_Pin|ARDUINO_MOSI_PWM_D11_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); }
/** Configure pins PE4 ------> LTDC_B0 PG14 ------> ETH_TXD1 PE1 ------> FMC_NBL1 PE0 ------> FMC_NBL0 PB8 ------> I2C1_SCL PB5 ------> USB_OTG_HS_ULPI_D7 PB4 ------> S_TIM3_CH1 PC12 ------> SDMMC1_CK PA15 ------> S_TIM2_CH1_ETR PG13 ------> ETH_TXD0 PB9 ------> I2C1_SDA PB7 ------> USART1_RX PG15 ------> FMC_SDNCAS PG11 ------> ETH_TX_EN PJ13 ------> LTDC_B1 PD0 ------> FMC_D2_DA2 PC11 ------> SDMMC1_D3 PC10 ------> SDMMC1_D2 PA12 ------> USB_OTG_FS_DP PI4 ------> SAI2_MCLK_A PK7 ------> LTDC_DE PK6 ------> LTDC_B7 PK5 ------> LTDC_B6 PG12 ------> LTDC_B4 PG10 ------> SAI2_SD_B PJ14 ------> LTDC_B2 PD1 ------> FMC_D3_DA3 PA11 ------> USB_OTG_FS_DM PF0 ------> FMC_A0 PI5 ------> SAI2_SCK_A PI7 ------> SAI2_FS_A PI10 ------> LTDC_HSYNC PI6 ------> SAI2_SD_A PK4 ------> LTDC_B5 PJ15 ------> LTDC_B3 PD2 ------> SDMMC1_CMD PI1 ------> SPI2_SCK PA10 ------> USB_OTG_FS_ID PF1 ------> FMC_A1 PI9 ------> LTDC_VSYNC PI0 ------> S_TIM5_CH4 PA9 ------> USART1_TX PK1 ------> LTDC_G6 PK2 ------> LTDC_G7 PC9 ------> SDMMC1_D1 PA8 ------> S_TIM1_CH1 PF2 ------> FMC_A2 PI15 ------> LTDC_R0 PJ11 ------> LTDC_G4 PK0 ------> LTDC_G5 PC8 ------> SDMMC1_D0 PC7 ------> USART6_RX PF3 ------> FMC_A3 PI14 ------> LTDC_CLK PH4 ------> USB_OTG_HS_ULPI_NXT PJ8 ------> LTDC_G1 PJ10 ------> LTDC_G3 PG8 ------> FMC_SDCLK PC6 ------> USART6_TX PF4 ------> FMC_A4 PH5 ------> FMC_SDNWE PH3 ------> FMC_SDNE0 PJ7 ------> LTDC_G0 PJ9 ------> LTDC_G2 PF7 ------> ADC3_IN5 PF6 ------> ADC3_IN4 PF5 ------> FMC_A5 PJ6 ------> LTDC_R7 PD15 ------> FMC_D1_DA1 PB13 ------> USB_OTG_HS_ULPI_D6 PD10 ------> FMC_D15_DA15 PF10 ------> ADC3_IN8 PF9 ------> ADC3_IN7 PF8 ------> ADC3_IN6 PC3 ------> FMC_SDCKE0 PD14 ------> FMC_D0_DA0 PB12 ------> USB_OTG_HS_ULPI_D5 PD9 ------> FMC_D14_DA14 PD8 ------> FMC_D13_DA13 PC0 ------> USB_OTG_HS_ULPI_STP PC1 ------> ETH_MDC PC2 ------> USB_OTG_HS_ULPI_DIR PF12 ------> FMC_A6 PG1 ------> FMC_A11 PF15 ------> FMC_A9 PJ4 ------> LTDC_R5 PJ5 ------> LTDC_R6 PA1 ------> ETH_REF_CLK PA0/WKUP ------> ADCx_IN0 PC4 ------> ETH_RXD0 PF13 ------> FMC_A7 PG0 ------> FMC_A10 PJ3 ------> LTDC_R4 PE8 ------> FMC_D5_DA5 PG5 ------> FMC_A15_BA1 PG4 ------> FMC_A14_BA0 PH7 ------> I2C3_SCL PA2 ------> ETH_MDIO PA5 ------> USB_OTG_HS_ULPI_CK PC5 ------> ETH_RXD1 PF14 ------> FMC_A8 PJ2 ------> LTDC_R3 PF11 ------> FMC_SDNRAS PE9 ------> FMC_D6_DA6 PE11 ------> FMC_D8_DA8 PE14 ------> FMC_D11_DA11 PB10 ------> USB_OTG_HS_ULPI_D3 PH6 ------> S_TIM12_CH1 PH8 ------> I2C3_SDA PA3 ------> USB_OTG_HS_ULPI_D0 PA7 ------> ETH_CRS_DV PB1 ------> USB_OTG_HS_ULPI_D2 PB0 ------> USB_OTG_HS_ULPI_D1 PJ0 ------> LTDC_R1 PJ1 ------> LTDC_R2 PE7 ------> FMC_D4_DA4 PE10 ------> FMC_D7_DA7 PE12 ------> FMC_D9_DA9 PE15 ------> FMC_D12_DA12 PE13 ------> FMC_D10_DA10 PB11 ------> USB_OTG_HS_ULPI_D4 PB14 ------> SPI2_MISO PB15 ------> SPI2_MOSI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOE_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOJ_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); __GPIOK_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); /*Configure GPIO pin : LCD_B0_Pin */ GPIO_InitStruct.Pin = LCD_B0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(LCD_B0_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : OTG_HS_OverCurrent_Pin */ GPIO_InitStruct.Pin = OTG_HS_OverCurrent_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_HS_OverCurrent_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : RMII_TXD1_Pin RMII_TXD0_Pin RMII_TX_EN_Pin */ GPIO_InitStruct.Pin = RMII_TXD1_Pin|RMII_TXD0_Pin|RMII_TX_EN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF11_ETH; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); /*Configure GPIO pins : PE1 PE0 FMC_D5_Pin FMC_D6_Pin FMC_D8_Pin FMC_D11_Pin FMC_D4_Pin FMC_D7_Pin FMC_D9_Pin FMC_D12_Pin FMC_D10_Pin */ GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_0|FMC_D5_Pin|FMC_D6_Pin |FMC_D8_Pin|FMC_D11_Pin|FMC_D4_Pin|FMC_D7_Pin |FMC_D9_Pin|FMC_D12_Pin|FMC_D10_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_SCL_D15_Pin ARDUINO_SDA_D14_Pin */ GPIO_InitStruct.Pin = ARDUINO_SCL_D15_Pin|ARDUINO_SDA_D14_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pins : ULPI_D7_Pin ULPI_D6_Pin ULPI_D5_Pin ULPI_D3_Pin ULPI_D2_Pin ULPI_D1_Pin ULPI_D4_Pin */ GPIO_InitStruct.Pin = ULPI_D7_Pin|ULPI_D6_Pin|ULPI_D5_Pin|ULPI_D3_Pin |ULPI_D2_Pin|ULPI_D1_Pin|ULPI_D4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_D3_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; HAL_GPIO_Init(ARDUINO_PWM_D3_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : SDMMC_CK_Pin SDMMC_D3_Pin SDMMC_D2_Pin PC9 PC8 */ GPIO_InitStruct.Pin = SDMMC_CK_Pin|SDMMC_D3_Pin|SDMMC_D2_Pin|GPIO_PIN_9 |GPIO_PIN_8; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_D9_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D9_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; HAL_GPIO_Init(ARDUINO_PWM_D9_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : VCP_RX_Pin */ GPIO_InitStruct.Pin = VCP_RX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF7_USART1; HAL_GPIO_Init(VCP_RX_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PG15 PG8 PG1 PG0 FMC_BA1_Pin FMC_BA0_Pin */ GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_8|GPIO_PIN_1|GPIO_PIN_0 |FMC_BA1_Pin|FMC_BA0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); /*Configure GPIO pins : LCD_B1_Pin LCD_B2_Pin LCD_B3_Pin LCD_G4_Pin LCD_G1_Pin LCD_G3_Pin LCD_G0_Pin LCD_G2_Pin LCD_R7_Pin LCD_R5_Pin LCD_R6_Pin LCD_R4_Pin LCD_R3_Pin LCD_R1_Pin LCD_R2_Pin */ GPIO_InitStruct.Pin = LCD_B1_Pin|LCD_B2_Pin|LCD_B3_Pin|LCD_G4_Pin |LCD_G1_Pin|LCD_G3_Pin|LCD_G0_Pin|LCD_G2_Pin |LCD_R7_Pin|LCD_R5_Pin|LCD_R6_Pin|LCD_R4_Pin |LCD_R3_Pin|LCD_R1_Pin|LCD_R2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct); /*Configure GPIO pin : OTG_FS_VBUS_Pin */ GPIO_InitStruct.Pin = OTG_FS_VBUS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_FS_VBUS_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : Audio_INT_Pin */ GPIO_InitStruct.Pin = Audio_INT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : FMC_D2_Pin FMC_D3_Pin FMC_D1_Pin FMC_D15_Pin FMC_D0_Pin FMC_D14_Pin FMC_D13_Pin */ GPIO_InitStruct.Pin = FMC_D2_Pin|FMC_D3_Pin|FMC_D1_Pin|FMC_D15_Pin |FMC_D0_Pin|FMC_D14_Pin|FMC_D13_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); /*Configure GPIO pins : OTG_FS_P_Pin OTG_FS_N_Pin OTG_FS_ID_Pin */ GPIO_InitStruct.Pin = OTG_FS_P_Pin|OTG_FS_N_Pin|OTG_FS_ID_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pins : SAI2_MCLKA_Pin SAI2_SCKA_Pin SAI2_FSA_Pin SAI2_SDA_Pin */ GPIO_InitStruct.Pin = SAI2_MCLKA_Pin|SAI2_SCKA_Pin|SAI2_FSA_Pin|SAI2_SDA_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF10_SAI2; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /*Configure GPIO pins : LCD_DE_Pin LCD_B7_Pin LCD_B6_Pin LCD_B5_Pin LCD_G6_Pin LCD_G7_Pin LCD_G5_Pin */ GPIO_InitStruct.Pin = LCD_DE_Pin|LCD_B7_Pin|LCD_B6_Pin|LCD_B5_Pin |LCD_G6_Pin|LCD_G7_Pin|LCD_G5_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOK, &GPIO_InitStruct); /*Configure GPIO pin : LCD_B4_Pin */ GPIO_InitStruct.Pin = LCD_B4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF9_LTDC; HAL_GPIO_Init(LCD_B4_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : SAI2_SDB_Pin */ GPIO_InitStruct.Pin = SAI2_SDB_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF10_SAI2; HAL_GPIO_Init(SAI2_SDB_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : OTG_FS_PowerSwitchOn_Pin */ GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_D7_Pin ARDUINO_D8_Pin LCD_DISP_Pin */ GPIO_InitStruct.Pin = ARDUINO_D7_Pin|ARDUINO_D8_Pin|LCD_DISP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /*Configure GPIO pin : uSD_Detect_Pin */ GPIO_InitStruct.Pin = uSD_Detect_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(uSD_Detect_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PF0 PF1 PF2 PF3 PF4 PF5 PF12 PF15 PF13 PF14 PF11 */ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_12|GPIO_PIN_15 |GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pins : LCD_HSYNC_Pin LCD_VSYNC_Pin LCD_R0_Pin LCD_CLK_Pin */ GPIO_InitStruct.Pin = LCD_HSYNC_Pin|LCD_VSYNC_Pin|LCD_R0_Pin|LCD_CLK_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOI, &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_LOW; HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : OTG_FS_OverCurrent_Pin */ GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : SDMMC_D0_Pin */ GPIO_InitStruct.Pin = SDMMC_D0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC; HAL_GPIO_Init(SDMMC_D0_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : TP3_Pin NC2_Pin */ GPIO_InitStruct.Pin = TP3_Pin|NC2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_SCK_D13_Pin */ GPIO_InitStruct.Pin = ARDUINO_SCK_D13_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(ARDUINO_SCK_D13_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : DCMI_PWR_EN_Pin */ GPIO_InitStruct.Pin = DCMI_PWR_EN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(DCMI_PWR_EN_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_CS_D10_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_CS_D10_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; HAL_GPIO_Init(ARDUINO_PWM_CS_D10_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : VCP_TX_Pin */ GPIO_InitStruct.Pin = VCP_TX_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF7_USART1; HAL_GPIO_Init(VCP_TX_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_D5_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D5_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF1_TIM1; HAL_GPIO_Init(ARDUINO_PWM_D5_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : LCD_INT_Pin */ GPIO_InitStruct.Pin = LCD_INT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_RX_D0_Pin ARDUINO_TX_D1_Pin */ GPIO_InitStruct.Pin = ARDUINO_RX_D0_Pin|ARDUINO_TX_D1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF8_USART6; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : ULPI_NXT_Pin */ GPIO_InitStruct.Pin = ULPI_NXT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(ULPI_NXT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : FMC_SDNME_Pin PH3 */ GPIO_InitStruct.Pin = FMC_SDNME_Pin|GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_D4_Pin ARDUINO_D2_Pin EXT_RST_Pin */ GPIO_InitStruct.Pin = ARDUINO_D4_Pin|ARDUINO_D2_Pin|EXT_RST_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_A4_Pin ARDUINO_A5_Pin ARDUINO_A1_Pin ARDUINO_A2_Pin ARDUINO_A3_Pin */ GPIO_InitStruct.Pin = ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A2_Pin |ARDUINO_A3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); /*Configure GPIO pin : PC3 */ GPIO_InitStruct.Pin = GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_FMC; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pins : ULPI_STP_Pin ULPI_DIR_Pin */ GPIO_InitStruct.Pin = ULPI_STP_Pin|ULPI_DIR_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pins : RMII_MDC_Pin RMII_RXD0_Pin RMII_RXD1_Pin */ GPIO_InitStruct.Pin = RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF11_ETH; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : RMII_RXER_Pin */ GPIO_InitStruct.Pin = RMII_RXER_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(RMII_RXER_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : RMII_REF_CLK_Pin RMII_MDIO_Pin RMII_CRS_DV_Pin */ GPIO_InitStruct.Pin = RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF11_ETH; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_A0_Pin */ GPIO_InitStruct.Pin = ARDUINO_A0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(ARDUINO_A0_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : LCD_SCL_Pin LCD_SDA_Pin */ GPIO_InitStruct.Pin = LCD_SCL_Pin|LCD_SDA_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF4_I2C3; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /*Configure GPIO pins : ULPI_CLK_Pin ULPI_D0_Pin */ GPIO_InitStruct.Pin = ULPI_CLK_Pin|ULPI_D0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : ARDUINO_PWM_D6_Pin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D6_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF9_TIM12; HAL_GPIO_Init(ARDUINO_PWM_D6_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : ARDUINO_MISO_D12_Pin ARDUINO_MOSI_PWM_D11_Pin */ GPIO_InitStruct.Pin = ARDUINO_MISO_D12_Pin|ARDUINO_MOSI_PWM_D11_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); }
/** Configure pins as * Analog * Input * Output * EVENT_OUT * EXTI PB8 ------> I2C1_SCL PB5 ------> USB_OTG_HS_ULPI_D7 PB4 ------> S_TIM3_CH1 PA15 ------> S_TIM2_CH1_ETR PB9 ------> I2C1_SDA PA12 ------> USB_OTG_FS_DP PA11 ------> USB_OTG_FS_DM PH15 ------> TIM8_CH3N PI1 ------> SPI2_SCK PA10 ------> USB_OTG_FS_ID PI0 ------> S_TIM5_CH4 PH4 ------> USB_OTG_HS_ULPI_NXT PB13 ------> USB_OTG_HS_ULPI_D6 PB12 ------> USB_OTG_HS_ULPI_D5 PC0 ------> USB_OTG_HS_ULPI_STP PC2 ------> USB_OTG_HS_ULPI_DIR PA5 ------> USB_OTG_HS_ULPI_CK PB10 ------> USB_OTG_HS_ULPI_D3 PH6 ------> S_TIM12_CH1 PA3 ------> USB_OTG_HS_ULPI_D0 PB1 ------> USB_OTG_HS_ULPI_D2 PB0 ------> USB_OTG_HS_ULPI_D1 PB11 ------> USB_OTG_HS_ULPI_D4 PB14 ------> SPI2_MISO PB15 ------> SPI2_MOSI */ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; /* GPIO Ports Clock Enable */ __GPIOE_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOA_CLK_ENABLE(); __GPIOJ_CLK_ENABLE(); __GPIOD_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); __GPIOK_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = OTG_HS_OverCurrent_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_HS_OverCurrent_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PBPin PBPin */ GPIO_InitStruct.Pin = ARDUINO_SCL_D15_Pin|ARDUINO_SDA_D14_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF4_I2C1; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pins : PBPin PBPin PBPin PBPin PBPin PBPin PBPin */ GPIO_InitStruct.Pin = ULPI_D7_Pin|ULPI_D6_Pin|ULPI_D5_Pin|ULPI_D3_Pin |ULPI_D2_Pin|ULPI_D1_Pin|ULPI_D4_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D3_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM3; HAL_GPIO_Init(ARDUINO_PWM_D3_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D9_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF1_TIM2; HAL_GPIO_Init(ARDUINO_PWM_D9_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = OTG_FS_VBUS_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_FS_VBUS_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = Audio_INT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PAPin PAPin PAPin */ GPIO_InitStruct.Pin = OTG_FS_P_Pin|OTG_FS_N_Pin|OTG_FS_ID_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PIPin PIPin PIPin */ GPIO_InitStruct.Pin = ARDUINO_D7_Pin|ARDUINO_D8_Pin|LCD_DISP_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = uSD_Detect_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(uSD_Detect_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = TP_PH15_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF3_TIM8; HAL_GPIO_Init(TP_PH15_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = ARDUINO_SCK_D13_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(ARDUINO_SCK_D13_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = DCMI_PWR_EN_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(DCMI_PWR_EN_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = ARDUINO_PWM_CS_D10_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF2_TIM5; HAL_GPIO_Init(ARDUINO_PWM_CS_D10_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = LCD_INT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = ULPI_NXT_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(ULPI_NXT_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PGPin PGPin PGPin */ GPIO_InitStruct.Pin = ARDUINO_D4_Pin|ARDUINO_D2_Pin|EXT_RST_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = NC2_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(NC2_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PCPin PCPin */ GPIO_InitStruct.Pin = ULPI_STP_Pin|ULPI_DIR_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = RMII_RXER_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(RMII_RXER_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PAPin PAPin */ GPIO_InitStruct.Pin = ULPI_CLK_Pin|ULPI_D0_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /*Configure GPIO pin : PtPin */ GPIO_InitStruct.Pin = ARDUINO_PWM_D6_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF9_TIM12; HAL_GPIO_Init(ARDUINO_PWM_D6_GPIO_Port, &GPIO_InitStruct); /*Configure GPIO pins : PBPin PBPin */ GPIO_InitStruct.Pin = ARDUINO_MISO_D12_Pin|ARDUINO_MOSI_PWM_D11_Pin; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); }
/** * @brief Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) { GPIO_InitTypeDef GPIO_InitStruct; if(hpcd->Instance == USB_OTG_FS) { /* Configure USB FS GPIOs */ __GPIOA_CLK_ENABLE(); /* Configure DM DP Pins */ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Configure VBUS Pin */ GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Configure ID pin */ GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Enable USB FS Clocks */ __USB_OTG_FS_CLK_ENABLE(); /* Set USBFS Interrupt to the lowest priority */ HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); /* Enable USBFS Interrupt */ HAL_NVIC_EnableIRQ(OTG_FS_IRQn); } else if(hpcd->Instance == USB_OTG_HS) { #ifdef USE_USB_HS_IN_FS /* Configure USB FS GPIOs */ __GPIOB_CLK_ENABLE(); /*Configure GPIO for HS on FS mode*/ GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_14 |GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* Configure VBUS Pin */ GPIO_InitStruct.Pin = GPIO_PIN_13 ; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); GPIO_InitStruct.Pull = GPIO_NOPULL; #else /* Configure USB HS GPIOs */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); /* CLK */ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D0 */ GPIO_InitStruct.Pin = GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D1 D2 D3 D4 D5 D6 D7 */ GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 |\ GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* STP */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* NXT */ GPIO_InitStruct.Pin = GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /* DIR */ GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /* Enable embedded ULPI */ __USB_OTG_HS_ULPI_CLK_ENABLE(); #endif /* USE_USB_HS_IN_FS */ /* Enable USB HS Clocks */ __USB_OTG_HS_CLK_ENABLE(); /* Set USBHS Interrupt to the lowest priority */ HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); /* Enable USBHS Interrupt */ HAL_NVIC_EnableIRQ(OTG_HS_IRQn); } }
/** * @brief Initializes the HCD MSP. * @param hhcd: HCD handle * @retval None */ void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd) { GPIO_InitTypeDef GPIO_InitStruct; BSP_IO_Init(); if(hhcd->Instance == USB_OTG_FS) { /* Configure USB FS GPIOs */ __GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Enable USB FS Clocks */ __USB_OTG_FS_CLK_ENABLE(); /* Set USBFS Interrupt to the lowest priority */ HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); /* Enable USBFS Interrupt */ HAL_NVIC_EnableIRQ(OTG_FS_IRQn); /* Configure USB FS Power Switch IO pin in Output mode */ BSP_IO_ConfigPin(OTG_FS1_POWER_SWITCH_PIN, IO_MODE_OUTPUT); } else if(hhcd->Instance == USB_OTG_HS) { #ifdef USE_USB_HS_IN_FS /* Configure POWER_SWITCH IO pin */ BSP_IO_ConfigPin(OTG_FS2_POWER_SWITCH_PIN, IO_MODE_OUTPUT); __GPIOB_CLK_ENABLE(); /*Configure GPIO for HS on FS mode*/ GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |GPIO_PIN_15; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF12_OTG_HS_FS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); #else /* Configure USB FS GPIOs */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); /* CLK */ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D0 */ GPIO_InitStruct.Pin = GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D1 D2 D3 D4 D5 D6 D7 */ GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 |\ GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* STP */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* NXT */ GPIO_InitStruct.Pin = GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /* DIR */ GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); __USB_OTG_HS_ULPI_CLK_ENABLE(); #endif /* Enable USB HS Clocks */ __USB_OTG_HS_CLK_ENABLE(); /* Set USBHS Interrupt to the lowest priority */ HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); /* Enable USBHS Interrupt */ HAL_NVIC_EnableIRQ(OTG_HS_IRQn); } }
/** * @brief Initializes SDRAM MSP. */ static void SDRAM_MspInit(void) { static DMA_HandleTypeDef dmaHandle; GPIO_InitTypeDef GPIO_Init_Structure; SDRAM_HandleTypeDef *hsdram = &sdramHandle; /* Enable FMC clock */ __FMC_CLK_ENABLE(); /* Enable chosen DMAx clock */ __DMAx_CLK_ENABLE(); /* Enable GPIOs clock */ __GPIOD_CLK_ENABLE(); __GPIOE_CLK_ENABLE(); __GPIOF_CLK_ENABLE(); __GPIOG_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); /* Common GPIO configuration */ GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_PULLUP; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; GPIO_Init_Structure.Alternate = GPIO_AF12_FMC; /* GPIOD configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_8| GPIO_PIN_9 | GPIO_PIN_10 |\ GPIO_PIN_14 | GPIO_PIN_15; HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure); /* GPIOE configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_7| GPIO_PIN_8 | GPIO_PIN_9 |\ GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ GPIO_PIN_15; HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure); /* GPIOF configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2| GPIO_PIN_3 | GPIO_PIN_4 |\ GPIO_PIN_5 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ GPIO_PIN_15; HAL_GPIO_Init(GPIOF, &GPIO_Init_Structure); /* GPIOG configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4| GPIO_PIN_5 | GPIO_PIN_8 |\ GPIO_PIN_15; HAL_GPIO_Init(GPIOG, &GPIO_Init_Structure); /* GPIOH configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5 | GPIO_PIN_8 | GPIO_PIN_9 |\ GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 |\ GPIO_PIN_15; HAL_GPIO_Init(GPIOH, &GPIO_Init_Structure); /* GPIOI configuration */ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 |\ GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | GPIO_PIN_9 | GPIO_PIN_10; HAL_GPIO_Init(GPIOI, &GPIO_Init_Structure); /* Configure common DMA parameters */ dmaHandle.Init.Channel = SDRAM_DMAx_CHANNEL; dmaHandle.Init.Direction = DMA_MEMORY_TO_MEMORY; dmaHandle.Init.PeriphInc = DMA_PINC_ENABLE; dmaHandle.Init.MemInc = DMA_MINC_ENABLE; dmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; dmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; dmaHandle.Init.Mode = DMA_NORMAL; dmaHandle.Init.Priority = DMA_PRIORITY_HIGH; dmaHandle.Init.FIFOMode = DMA_FIFOMODE_DISABLE; dmaHandle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; dmaHandle.Init.MemBurst = DMA_MBURST_SINGLE; dmaHandle.Init.PeriphBurst = DMA_PBURST_SINGLE; dmaHandle.Instance = SDRAM_DMAx_STREAM; /* Associate the DMA handle */ __HAL_LINKDMA(hsdram, hdma, dmaHandle); /* Deinitialize the stream for new transfer */ HAL_DMA_DeInit(&dmaHandle); /* Configure the DMA stream */ HAL_DMA_Init(&dmaHandle); /* NVIC configuration for DMA transfer complete interrupt */ HAL_NVIC_SetPriority(SDRAM_DMAx_IRQn, 5, 0); HAL_NVIC_EnableIRQ(SDRAM_DMAx_IRQn); }
// Enable GPIO clock and return GPIO base address GPIO_TypeDef *Set_GPIO_Clock(uint32_t port_idx) { uint32_t gpio_add = 0; switch (port_idx) { case PortA: gpio_add = GPIOA_BASE; __GPIOA_CLK_ENABLE(); break; case PortB: gpio_add = GPIOB_BASE; __GPIOB_CLK_ENABLE(); break; #if defined(GPIOC_BASE) case PortC: gpio_add = GPIOC_BASE; __GPIOC_CLK_ENABLE(); break; #endif #if defined GPIOD_BASE case PortD: gpio_add = GPIOD_BASE; __GPIOD_CLK_ENABLE(); break; #endif #if defined GPIOE_BASE case PortE: gpio_add = GPIOE_BASE; __GPIOE_CLK_ENABLE(); break; #endif #if defined GPIOF_BASE case PortF: gpio_add = GPIOF_BASE; __GPIOF_CLK_ENABLE(); break; #endif #if defined GPIOG_BASE case PortG: #if defined TARGET_STM32L4 __HAL_RCC_PWR_CLK_ENABLE(); HAL_PWREx_EnableVddIO2(); #endif gpio_add = GPIOG_BASE; __GPIOG_CLK_ENABLE(); break; #endif #if defined GPIOH_BASE case PortH: gpio_add = GPIOH_BASE; __GPIOH_CLK_ENABLE(); break; #endif #if defined GPIOI_BASE case PortI: gpio_add = GPIOI_BASE; __GPIOI_CLK_ENABLE(); break; #endif #if defined GPIOJ_BASE case PortJ: gpio_add = GPIOJ_BASE; __GPIOJ_CLK_ENABLE(); break; #endif #if defined GPIOK_BASE case PortK: gpio_add = GPIOK_BASE; __GPIOK_CLK_ENABLE(); break; #endif default: error("Pinmap error: wrong port number."); break; } return (GPIO_TypeDef *) gpio_add; }
/** * @brief Initializes the PCD MSP. * @param hpcd: PCD handle * @retval None */ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) { GPIO_InitTypeDef GPIO_InitStruct; if(hpcd->Instance == USB_OTG_FS) { /* Configure USB FS GPIOs */ __GPIOA_CLK_ENABLE(); /* Configure DM DP Pins */ GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Configure VBUS Pin */ GPIO_InitStruct.Pin = GPIO_PIN_9; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Configure ID pin */ GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* Enable USB FS Clock */ __USB_OTG_FS_CLK_ENABLE(); /* Set USBFS Interrupt priority */ HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); /* Enable USBFS Interrupt */ HAL_NVIC_EnableIRQ(OTG_FS_IRQn); if(hpcd->Init.low_power_enable == 1) { /* Enable EXTI Line 18 for USB wakeup*/ __HAL_USB_FS_EXTI_CLEAR_FLAG(); __HAL_USB_FS_EXTI_SET_RISING_EGDE_TRIGGER(); __HAL_USB_FS_EXTI_ENABLE_IT(); /* Set EXTI Wakeup Interrupt priority*/ HAL_NVIC_SetPriority(OTG_FS_WKUP_IRQn, 0, 0); /* Enable EXTI Interrupt */ HAL_NVIC_EnableIRQ(OTG_FS_WKUP_IRQn); } } else if(hpcd->Instance == USB_OTG_HS) { /* Configure USB FS GPIOs */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); /* CLK */ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D0 */ GPIO_InitStruct.Pin = GPIO_PIN_3; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D1 D2 D3 D4 D5 D6 D7 */ GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 |\ GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* STP */ GPIO_InitStruct.Pin = GPIO_PIN_0; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* NXT */ GPIO_InitStruct.Pin = GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /* DIR */ GPIO_InitStruct.Pin = GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /* Enable USB HS Clocks */ __USB_OTG_HS_CLK_ENABLE(); __USB_OTG_HS_ULPI_CLK_ENABLE(); /* Set USBHS Interrupt priority */ HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); /* Enable USBHS Interrupt */ HAL_NVIC_EnableIRQ(OTG_HS_IRQn); if(hpcd->Init.low_power_enable == 1) { /* Enable EXTI Line 20 for USB wakeup*/ __HAL_USB_HS_EXTI_CLEAR_FLAG(); __HAL_USB_HS_EXTI_SET_RISING_EGDE_TRIGGER(); __HAL_USB_HS_EXTI_ENABLE_IT(); /* Set EXTI Wakeup Interrupt priority*/ HAL_NVIC_SetPriority(OTG_HS_WKUP_IRQn, 0, 0); /* Enable EXTI Interrupt */ HAL_NVIC_EnableIRQ(OTG_HS_WKUP_IRQn); } } }
/** * @brief Initializes the HCD MSP. * @param hhcd: HCD handle * @retval None */ void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd) { GPIO_InitTypeDef GPIO_InitStruct; if(hhcd->Instance == USB_OTG_FS) { /* Configure USB FS GPIOs */ __GPIOA_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12); GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_10; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /* Enable USB FS Clocks */ __USB_OTG_FS_CLK_ENABLE(); /* Set USBFS Interrupt to the lowest priority */ HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0); /* Enable USBFS Interrupt */ HAL_NVIC_EnableIRQ(OTG_FS_IRQn); } else if(hhcd->Instance == USB_OTG_HS) { /* Configure USB HS GPIOs */ __GPIOA_CLK_ENABLE(); __GPIOB_CLK_ENABLE(); __GPIOC_CLK_ENABLE(); __GPIOH_CLK_ENABLE(); __GPIOI_CLK_ENABLE(); /* CLK */ GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_InitStruct.Alternate = GPIO_AF10_OTG_HS; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D0 */ GPIO_InitStruct.Pin = GPIO_PIN_3; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* D1 D2 D3 D4 D5 D6 D7 */ GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_5 |\ GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* STP */ GPIO_InitStruct.Pin = GPIO_PIN_0; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* NXT */ GPIO_InitStruct.Pin = GPIO_PIN_4; HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /* DIR */ GPIO_InitStruct.Pin = GPIO_PIN_11; HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); /* Enable USB HS Clocks */ __USB_OTG_HS_CLK_ENABLE(); __USB_OTG_HS_ULPI_CLK_ENABLE(); /* Set USBHS Interrupt to the lowest priority */ HAL_NVIC_SetPriority(OTG_HS_IRQn, 5, 0); /* Enable USBHS Interrupt */ HAL_NVIC_EnableIRQ(OTG_HS_IRQn); } }
STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { // parse args mp_arg_val_t vals[PIN_INIT_NUM_ARGS]; mp_arg_parse_all(n_args, args, kw_args, PIN_INIT_NUM_ARGS, pin_init_args, vals); // get io mode uint mode = vals[0].u_int; if (!IS_GPIO_MODE(mode)) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid pin mode: %d", mode)); } // get pull mode uint pull = vals[1].u_int; if (!IS_GPIO_PULL(pull)) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid pin pull: %d", pull)); } // get af (alternate function) mp_int_t af = vals[2].u_int; if ((mode == GPIO_MODE_AF_PP || mode == GPIO_MODE_AF_OD) && !IS_GPIO_AF(af)) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid pin af: %d", af)); } // enable the peripheral clock for the port of this pin switch (self->port) { #ifdef __GPIOA_CLK_ENABLE case PORT_A: __GPIOA_CLK_ENABLE(); break; #endif #ifdef __GPIOB_CLK_ENABLE case PORT_B: __GPIOB_CLK_ENABLE(); break; #endif #ifdef __GPIOC_CLK_ENABLE case PORT_C: __GPIOC_CLK_ENABLE(); break; #endif #ifdef __GPIOD_CLK_ENABLE case PORT_D: __GPIOD_CLK_ENABLE(); break; #endif #ifdef __GPIOE_CLK_ENABLE case PORT_E: __GPIOE_CLK_ENABLE(); break; #endif #ifdef __GPIOF_CLK_ENABLE case PORT_F: __GPIOF_CLK_ENABLE(); break; #endif #ifdef __GPIOG_CLK_ENABLE case PORT_G: __GPIOG_CLK_ENABLE(); break; #endif #ifdef __GPIOH_CLK_ENABLE case PORT_H: __GPIOH_CLK_ENABLE(); break; #endif #ifdef __GPIOI_CLK_ENABLE case PORT_I: __GPIOI_CLK_ENABLE(); break; #endif #ifdef __GPIOJ_CLK_ENABLE case PORT_J: __GPIOJ_CLK_ENABLE(); break; #endif } // configure the GPIO as requested GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.Pin = self->pin_mask; GPIO_InitStructure.Mode = mode; GPIO_InitStructure.Pull = pull; GPIO_InitStructure.Speed = GPIO_SPEED_FAST; GPIO_InitStructure.Alternate = af; HAL_GPIO_Init(self->gpio, &GPIO_InitStructure); return mp_const_none; }