stm32 button: use more idiomatic GPIO read
Using GPIOA_IDR directly looks a bit arcane, and the example can benefit from introducing gpio_get() and how to use it. The stm32f0-discovery example already does it like this.
This commit is contained in:
@@ -22,8 +22,6 @@
|
||||
#include <libopencm3/stm32/rcc.h>
|
||||
#include <libopencm3/stm32/gpio.h>
|
||||
|
||||
uint16_t exti_line_state;
|
||||
|
||||
/* Set STM32 to 24 MHz. */
|
||||
static void clock_setup(void)
|
||||
{
|
||||
@@ -64,8 +62,7 @@ int main(void)
|
||||
gpio_toggle(GPIOC, GPIO9);
|
||||
|
||||
/* Upon button press, blink more slowly. */
|
||||
exti_line_state = GPIOA_IDR;
|
||||
if ((exti_line_state & (1 << 9)) == 0) {
|
||||
if (gpio_get(GPIOA, GPIO9)) {
|
||||
for (i = 0; i < 800000; i++) /* Wait a bit. */
|
||||
__asm__("nop");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user