107 #include "stm32h7xx_hal.h"
118 #ifdef HAL_GPIO_MODULE_ENABLED
125 #define GPIO_MODE (0x00000003U)
126 #define ANALOG_MODE (0x00000008U)
127 #define EXTI_MODE (0x10000000U)
128 #define GPIO_MODE_IT (0x00010000U)
129 #define GPIO_MODE_EVT (0x00020000U)
130 #define RISING_EDGE (0x00100000U)
131 #define FALLING_EDGE (0x00200000U)
132 #define GPIO_OUTPUT_TYPE (0x00000010U)
134 #if defined(DUAL_CORE)
135 #define EXTI_CPU1 (0x01000000U)
136 #define EXTI_CPU2 (0x02000000U)
138 #define GPIO_NUMBER (16U)
175 uint32_t position = 0x00U;
180 #if defined(DUAL_CORE) && defined(CORE_CM4)
193 while (((GPIO_Init->
Pin) >> position) != 0x00U)
196 iocurrent = (GPIO_Init->
Pin) & (1UL << position);
198 if (iocurrent != 0x00U)
210 temp |= (GPIO_Init->
Speed << (position * 2U));
216 temp |= (((GPIO_Init->
Mode & GPIO_OUTPUT_TYPE) >> 4U) << position);
223 temp |= ((GPIO_Init->
Pull) << (position * 2U));
234 temp = GPIOx->
AFR[position >> 3U];
235 temp &= ~(0xFU << ((position & 0x07U) * 4U));
236 temp |= ((GPIO_Init->
Alternate) << ((position & 0x07U) * 4U));
237 GPIOx->
AFR[position >> 3U] = temp;
243 temp |= ((GPIO_Init->
Mode & GPIO_MODE) << (position * 2U));
248 if ((GPIO_Init->
Mode & EXTI_MODE) == EXTI_MODE)
253 temp =
SYSCFG->EXTICR[position >> 2U];
254 temp &= ~(0x0FUL << (4U * (position & 0x03U)));
256 SYSCFG->EXTICR[position >> 2U] = temp;
259 temp = EXTI_CurrentCPU->
IMR1;
260 temp &= ~(iocurrent);
261 if ((GPIO_Init->
Mode & GPIO_MODE_IT) == GPIO_MODE_IT)
265 EXTI_CurrentCPU->
IMR1 = temp;
267 temp = EXTI_CurrentCPU->
EMR1;
268 temp &= ~(iocurrent);
269 if ((GPIO_Init->
Mode & GPIO_MODE_EVT) == GPIO_MODE_EVT)
273 EXTI_CurrentCPU->
EMR1 = temp;
277 temp &= ~(iocurrent);
278 if ((GPIO_Init->
Mode & RISING_EDGE) == RISING_EDGE)
285 temp &= ~(iocurrent);
286 if ((GPIO_Init->
Mode & FALLING_EDGE) == FALLING_EDGE)
307 uint32_t position = 0x00U;
312 #if defined(DUAL_CORE) && defined(CORE_CM4)
323 while ((GPIO_Pin >> position) != 0x00U)
326 iocurrent = GPIO_Pin & (1UL << position) ;
328 if (iocurrent != 0x00U)
332 tmp =
SYSCFG->EXTICR[position >> 2U];
333 tmp &= (0x0FUL << (4U * (position & 0x03U)));
337 EXTI_CurrentCPU->
IMR1 &= ~(iocurrent);
338 EXTI_CurrentCPU->
EMR1 &= ~(iocurrent);
341 EXTI->RTSR1 &= ~(iocurrent);
342 EXTI->FTSR1 &= ~(iocurrent);
344 tmp = 0x0FUL << (4U * (position & 0x03U));
345 SYSCFG->EXTICR[position >> 2U] &= ~tmp;
353 GPIOx->
AFR[position >> 3U] &= ~(0xFU << ((position & 0x07U) * 4U)) ;
399 if ((GPIOx->
IDR & GPIO_Pin) != 0x00U)
434 GPIOx->
BSRR = GPIO_Pin;
438 GPIOx->
BSRR = (uint32_t)GPIO_Pin << GPIO_NUMBER;
459 GPIOx->
BSRR = ((odr & GPIO_Pin) << GPIO_NUMBER) | (~odr & GPIO_Pin);
486 GPIOx->
LCKR = GPIO_Pin;
510 #if defined(DUAL_CORE) && defined(CORE_CM4)
511 if (__HAL_GPIO_EXTID2_GET_IT(GPIO_Pin) != 0x00U)
513 __HAL_GPIO_EXTID2_CLEAR_IT(GPIO_Pin);