119 #ifdef HAL_GPIO_MODULE_ENABLED
126 #define GPIO_MODE ((uint32_t)0x00000003U)
127 #define EXTI_MODE ((uint32_t)0x10000000U)
128 #define GPIO_MODE_IT ((uint32_t)0x00010000U)
129 #define GPIO_MODE_EVT ((uint32_t)0x00020000U)
130 #define RISING_EDGE ((uint32_t)0x00100000U)
131 #define FALLING_EDGE ((uint32_t)0x00200000U)
132 #define GPIO_OUTPUT_TYPE ((uint32_t)0x00000010U)
134 #define GPIO_NUMBER ((uint32_t)16U)
171 uint32_t position = 0x00;
172 uint32_t ioposition = 0x00;
173 uint32_t iocurrent = 0x00;
174 uint32_t temp = 0x00;
183 for(position = 0; position < GPIO_NUMBER; position++)
186 ioposition = ((uint32_t)0x01) << position;
188 iocurrent = (uint32_t)(GPIO_Init->
Pin) & ioposition;
190 if(iocurrent == ioposition)
202 temp |= (GPIO_Init->
Speed << (position * 2));
208 temp |= (((GPIO_Init->
Mode & GPIO_OUTPUT_TYPE) >> 4) << position);
215 temp |= ((GPIO_Init->
Pull) << (position * 2));
225 temp = GPIOx->
AFR[position >> 3];
226 temp &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ;
227 temp |= ((uint32_t)(GPIO_Init->
Alternate) << (((uint32_t)position & (uint32_t)0x07) * 4));
228 GPIOx->
AFR[position >> 3] = temp;
234 temp |= ((GPIO_Init->
Mode & GPIO_MODE) << (position * 2));
239 if((GPIO_Init->
Mode & EXTI_MODE) == EXTI_MODE)
244 temp =
SYSCFG->EXTICR[position >> 2];
245 temp &= ~(((uint32_t)0x0F) << (4 * (position & 0x03)));
246 temp |= ((uint32_t)(
GPIO_GET_INDEX(GPIOx)) << (4 * (position & 0x03)));
247 SYSCFG->EXTICR[position >> 2] = temp;
251 temp &= ~((uint32_t)iocurrent);
252 if((GPIO_Init->
Mode & GPIO_MODE_IT) == GPIO_MODE_IT)
259 temp &= ~((uint32_t)iocurrent);
260 if((GPIO_Init->
Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)
268 temp &= ~((uint32_t)iocurrent);
269 if((GPIO_Init->
Mode & RISING_EDGE) == RISING_EDGE)
276 temp &= ~((uint32_t)iocurrent);
277 if((GPIO_Init->
Mode & FALLING_EDGE) == FALLING_EDGE)
297 uint32_t ioposition = 0x00;
298 uint32_t iocurrent = 0x00;
305 for(position = 0; position < GPIO_NUMBER; position++)
308 ioposition = ((uint32_t)0x01) << position;
310 iocurrent = (GPIO_Pin) & ioposition;
312 if(iocurrent == ioposition)
315 tmp =
SYSCFG->EXTICR[position >> 2];
316 tmp &= (((uint32_t)0x0F) << (4 * (position & 0x03)));
317 if(tmp == ((uint32_t)(
GPIO_GET_INDEX(GPIOx)) << (4 * (position & 0x03))))
320 EXTI->IMR &= ~((uint32_t)iocurrent);
321 EXTI->EMR &= ~((uint32_t)iocurrent);
324 EXTI->RTSR &= ~((uint32_t)iocurrent);
325 EXTI->FTSR &= ~((uint32_t)iocurrent);
328 tmp = ((uint32_t)0x0F) << (4 * (position & 0x03));
329 SYSCFG->EXTICR[position >> 2] &= ~tmp;
336 GPIOx->
AFR[position >> 3] &= ~((uint32_t)0xF << ((uint32_t)(position & (uint32_t)0x07) * 4)) ;
415 GPIOx->
BSRR = GPIO_Pin;
419 GPIOx->
BSRR = (uint32_t)GPIO_Pin << 16;
434 if ((GPIOx->
ODR & GPIO_Pin) != 0X00u)
436 GPIOx->
BSRR = (uint32_t)GPIO_Pin << GPIO_NUMBER;
440 GPIOx->
BSRR = (uint32_t)GPIO_Pin;
467 GPIOx->
LCKR = GPIO_Pin;