Skip to content

Commit a871b60

Browse files
authored
Fix: STM32H747 only supports detection of rising edges, falling edges or rising/falling. (#2)
However, interrupt on active high or intterupt on active low levels is not supported.
1 parent cde0032 commit a871b60

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/gpio.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ static void MX_GPIO_Init(void) {
115115

116116
#define GPIO_MODE_IN_RE 0x01 /*!< Input interrupt rising edge */
117117
#define GPIO_MODE_IN_FE 0x02 /*!< Input interrupt falling edge */
118-
#define GPIO_MODE_IN_AH 0x04 /*!< Input interrupt active high */
119-
#define GPIO_MODE_IN_AL 0x08 /*!< Input interrupt active low */
120118

121119
static void handle_irq() {
122120
uint32_t pr = EXTI->PR1;
@@ -225,7 +223,11 @@ void gpio_handler(uint8_t opcode, uint8_t *pdata, uint16_t size) {
225223
break;
226224
case IRQ_TYPE:
227225
GPIO_InitStruct.Pin = GPIO_pinmap[index].pin;
228-
GPIO_InitStruct.Mode = ((value == GPIO_MODE_IN_RE) || (value == GPIO_MODE_IN_AH)) ? GPIO_MODE_IT_RISING : GPIO_MODE_IT_FALLING;
226+
227+
if (value == GPIO_MODE_IN_RE) GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
228+
else if (value == GPIO_MODE_IN_FE) GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
229+
else return;
230+
229231
GPIO_InitStruct.Pull = GPIO_PULLUP;
230232
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
231233
HAL_GPIO_Init(GPIO_pinmap[index].port, &GPIO_InitStruct);

0 commit comments

Comments
 (0)