Initialize the GPIOx peripheral according to the specified parameters in the GPIO_Init.
174 uint32_t position = 0x00u;
185 while (((GPIO_Init->Pin) >> position) != 0x00u)
188 iocurrent = (GPIO_Init->Pin) & (1uL << position);
190 if (iocurrent != 0x00u)
194 if((GPIO_Init->Mode == GPIO_MODE_AF_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
201 temp = GPIOx->AFR[position >> 3u];
202 temp &= ~(0xFu << ((position & 0x07u) * 4u));
203 temp |= ((GPIO_Init->Alternate) << ((position & 0x07u) * 4u));
204 GPIOx->AFR[position >> 3u] = temp;
209 temp &= ~(GPIO_MODER_MODE0 << (position * 2u));
210 temp |= ((GPIO_Init->Mode & GPIO_MODE) << (position * 2u));
214 if((GPIO_Init->Mode == GPIO_MODE_OUTPUT_PP) || (GPIO_Init->Mode == GPIO_MODE_AF_PP) ||
215 (GPIO_Init->Mode == GPIO_MODE_OUTPUT_OD) || (GPIO_Init->Mode == GPIO_MODE_AF_OD))
220 temp = GPIOx->OSPEEDR;
221 temp &= ~(GPIO_OSPEEDR_OSPEED0 << (position * 2u));
222 temp |= (GPIO_Init->Speed << (position * 2u));
223 GPIOx->OSPEEDR = temp;
226 temp = GPIOx->OTYPER;
227 temp &= ~(GPIO_OTYPER_OT0 << position) ;
228 temp |= (((GPIO_Init->Mode & GPIO_OUTPUT_TYPE) >> 4u) << position);
229 GPIOx->OTYPER = temp;
232 #if defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) 235 if((GPIO_Init->Mode & GPIO_MODE_ANALOG) == GPIO_MODE_ANALOG)
239 temp &= ~(GPIO_ASCR_ASC0 << position) ;
240 temp |= (((GPIO_Init->Mode & ANALOG_MODE) >> 3) << position);
248 temp &= ~(GPIO_PUPDR_PUPD0 << (position * 2u));
249 temp |= ((GPIO_Init->Pull) << (position * 2u));
254 if((GPIO_Init->Mode & EXTI_MODE) == EXTI_MODE)
257 __HAL_RCC_SYSCFG_CLK_ENABLE();
259 temp = SYSCFG->EXTICR[position >> 2u];
260 temp &= ~(0x0FuL << (4u * (position & 0x03u)));
261 temp |= (GPIO_GET_INDEX(GPIOx) << (4u * (position & 0x03u)));
262 SYSCFG->EXTICR[position >> 2u] = temp;
266 temp &= ~(iocurrent);
267 if((GPIO_Init->Mode & GPIO_MODE_IT) == GPIO_MODE_IT)
274 temp &= ~(iocurrent);
275 if((GPIO_Init->Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)
283 temp &= ~(iocurrent);
284 if((GPIO_Init->Mode & RISING_EDGE) == RISING_EDGE)
291 temp &= ~(iocurrent);
292 if((GPIO_Init->Mode & FALLING_EDGE) == FALLING_EDGE)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))