galileo: Add board-level abstraction layer for GPIO

This patch adds a HAL for GPIOs so that users of the API can specify
board-level IO pin numbers rather than CPU-level pin numbers.
This commit is contained in:
Michael LeMay 2016-08-22 16:28:58 -07:00
parent 2912559061
commit b17a936bf7
7 changed files with 132 additions and 18 deletions

View file

@ -33,10 +33,11 @@
#include "contiki.h"
#include "sys/ctimer.h"
#include "galileo-gpio.h"
#include "gpio.h"
#define PIN_OUTPUT 5
#define PIN_INPUT 6
#define PIN_OUTPUT 2
#define PIN_INPUT 3
static uint32_t value;
static struct ctimer timer;
@ -51,9 +52,9 @@ timeout(void *data)
/* toggle pin state */
value = !value;
quarkX1000_gpio_write(PIN_OUTPUT, value);
galileo_gpio_write(PIN_OUTPUT, value);
quarkX1000_gpio_read(PIN_INPUT, &value_in);
galileo_gpio_read(PIN_INPUT, &value_in);
if (value == value_in)
printf("GPIO pin value match!\n");

View file

@ -33,10 +33,11 @@
#include "contiki.h"
#include "sys/ctimer.h"
#include "galileo-gpio.h"
#include "gpio.h"
#define PIN_OUTPUT 5
#define PIN_INTR 6
#define PIN_OUTPUT 2
#define PIN_INTR 3
static struct ctimer timer;
@ -47,8 +48,8 @@ static void
timeout(void *data)
{
/* emulate an interrupt */
quarkX1000_gpio_write(PIN_OUTPUT, 0);
quarkX1000_gpio_write(PIN_OUTPUT, 1);
galileo_gpio_write(PIN_OUTPUT, 0);
galileo_gpio_write(PIN_OUTPUT, 1);
ctimer_reset(&timer);
}
@ -63,7 +64,7 @@ PROCESS_THREAD(gpio_interrupt_process, ev, data)
{
PROCESS_BEGIN();
quarkX1000_gpio_config(PIN_INTR, QUARKX1000_GPIO_INT | QUARKX1000_GPIO_ACTIVE_HIGH | QUARKX1000_GPIO_EDGE);
galileo_gpio_config(PIN_INTR, QUARKX1000_GPIO_INT | QUARKX1000_GPIO_ACTIVE_HIGH | QUARKX1000_GPIO_EDGE);
quarkX1000_gpio_set_callback(callback);

View file

@ -33,9 +33,10 @@
#include "contiki.h"
#include "sys/ctimer.h"
#include "galileo-gpio.h"
#include "gpio.h"
#define PIN 5 /* IO2 */
#define PIN 2
static uint32_t value;
static struct ctimer timer;
@ -48,7 +49,7 @@ timeout(void *data)
{
/* toggle pin state */
value = !value;
quarkX1000_gpio_write(PIN, value);
galileo_gpio_write(PIN, value);
ctimer_reset(&timer);
}