@@ -93,6 +93,11 @@ static void test_gpio_read(void)
9393
9494 value = readl (addr_idr );
9595 g_assert_cmpint (value , = = , 0x81 );
96+
97+ set_irq_in ("/machine/stm32/gpio[a]" , 0 , 0 );
98+
99+ value = readl (addr_idr );
100+ g_assert_cmpint (value , = = , 0x80 );
96101}
97102
98103static void test_gpio_write (void )
@@ -123,6 +128,17 @@ static void test_gpio_write(void)
123128
124129 writel (addr_bsrr , 0x0000ffef );
125130
131+ // Make sure pin can be toggled between input and output
132+ writel (addr_odr , 0x00000000 );
133+ config_gpio (GPIOA_BASE_ADDR , 0x33333333 , 0x33333330 ); // Pin 0 is input
134+ g_assert_cmpint (get_irq_for_gpio (gpio_a_out_id , 0x0 ), = = , 0 );
135+ writel (addr_odr , 0x00000001 );
136+ g_assert_cmpint (get_irq_for_gpio (gpio_a_out_id , 0x0 ), = = , 0 );
137+ writel (addr_odr , 0x00000000 );
138+ config_gpio (GPIOA_BASE_ADDR , 0x33333333 , 0x33333333 ); // Pin 0 is output
139+ g_assert_cmpint (get_irq_for_gpio (gpio_a_out_id , 0x0 ), = = , 0 );
140+ writel (addr_odr , 0x00000001 );
141+ g_assert_cmpint (get_irq_for_gpio (gpio_a_out_id , 0x0 ), = = , 1 );
126142
127143 //config_gpio(GPIOB_BASE_ADDR, 0x33333333, 0x33333333); // All outputs
128144
0 commit comments