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:
Roland Hieber
2016-10-08 23:30:32 +02:00
parent 4dfa31f9f8
commit bb8f4699da
6 changed files with 6 additions and 24 deletions

View File

@@ -24,8 +24,6 @@
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
uint16_t exti_line_state;
/* Set STM32 to 64 MHz. */
static void clock_setup(void)
{
@@ -64,8 +62,7 @@ int main(void)
gpio_toggle(GPIOE, GPIO11);
/* Upon button press, blink more slowly. */
exti_line_state = GPIOA_IDR;
if ((exti_line_state & (1 << 0)) != 0) {
if (gpio_get(GPIOA, GPIO0)) {
for (i = 0; i < 3000000; i++) /* Wait a bit. */
__asm__("nop");
}