Fixed missing changes for GPIO-HAL

This commit is contained in:
Edvard Pettersen 2018-08-03 14:10:27 +02:00
parent b20f38196a
commit c53ab05aea
9 changed files with 60 additions and 62 deletions

View File

@ -57,39 +57,35 @@ gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
gpio_hal_pin_cfg_t tmp; gpio_hal_pin_cfg_t tmp;
tmp = cfg & GPIO_HAL_PIN_CFG_EDGE_BOTH; tmp = cfg & GPIO_HAL_PIN_BM_INT;
if(tmp == GPIO_HAL_PIN_CFG_EDGE_NONE) {
GPIO_DISABLE_INTERRUPT(port_base, pin_mask);
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_RISING) {
GPIO_DETECT_EDGE(port_base, pin_mask);
GPIO_TRIGGER_SINGLE_EDGE(port_base, pin_mask);
GPIO_DETECT_RISING(port_base, pin_mask);
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_FALLING) {
GPIO_DETECT_EDGE(port_base, pin_mask);
GPIO_TRIGGER_SINGLE_EDGE(port_base, pin_mask);
GPIO_DETECT_FALLING(port_base, pin_mask);
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_BOTH) {
GPIO_DETECT_EDGE(port_base, pin_mask);
GPIO_TRIGGER_BOTH_EDGES(port_base, pin_mask);
}
tmp = cfg & GPIO_HAL_PIN_CFG_PULL_MASK;
if(tmp == GPIO_HAL_PIN_CFG_PULL_NONE) {
ioc_set_over(port, pin_num, IOC_OVERRIDE_DIS);
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_DOWN) {
ioc_set_over(port, pin_num, IOC_OVERRIDE_PDE);
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_UP) {
ioc_set_over(port, pin_num, IOC_OVERRIDE_PUE);
}
tmp = cfg & GPIO_HAL_PIN_CFG_INT_MASK;
if(tmp == GPIO_HAL_PIN_CFG_INT_DISABLE) { if(tmp == GPIO_HAL_PIN_CFG_INT_DISABLE) {
GPIO_DISABLE_INTERRUPT(port_base, pin_mask); GPIO_DISABLE_INTERRUPT(port_base, pin_mask);
} else if(tmp == GPIO_HAL_PIN_CFG_INT_ENABLE) { } else {
if(tmp == GPIO_HAL_PIN_CFG_INT_RISING) {
GPIO_DETECT_EDGE(port_base, pin_mask);
GPIO_TRIGGER_SINGLE_EDGE(port_base, pin_mask);
GPIO_DETECT_RISING(port_base, pin_mask);
} else if(tmp == GPIO_HAL_PIN_CFG_INT_FALLING) {
GPIO_DETECT_EDGE(port_base, pin_mask);
GPIO_TRIGGER_SINGLE_EDGE(port_base, pin_mask);
GPIO_DETECT_FALLING(port_base, pin_mask);
} else if(tmp == GPIO_HAL_PIN_CFG_INT_BOTH) {
GPIO_DETECT_EDGE(port_base, pin_mask);
GPIO_TRIGGER_BOTH_EDGES(port_base, pin_mask);
}
GPIO_ENABLE_INTERRUPT(port_base, pin_mask); GPIO_ENABLE_INTERRUPT(port_base, pin_mask);
NVIC_EnableIRQ(port); NVIC_EnableIRQ(port);
} }
tmp = cfg & GPIO_HAL_PIN_BM_INPUT;
if(tmp == GPIO_HAL_PIN_CFG_INPUT_NOPULL) {
ioc_set_over(port, pin_num, IOC_OVERRIDE_DIS);
} else if(tmp == GPIO_HAL_PIN_CFG_INPUT_PULLDOWN) {
ioc_set_over(port, pin_num, IOC_OVERRIDE_PDE);
} else if(tmp == GPIO_HAL_PIN_CFG_INPUT_PULLUP) {
ioc_set_over(port, pin_num, IOC_OVERRIDE_PUE);
}
GPIO_SOFTWARE_CONTROL(port_base, pin_mask); GPIO_SOFTWARE_CONTROL(port_base, pin_mask);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
@ -111,11 +107,11 @@ gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
/* Pull */ /* Pull */
tmp = ioc_get_over(port, pin_num); tmp = ioc_get_over(port, pin_num);
if(tmp == IOC_OVERRIDE_PUE) { if(tmp == IOC_OVERRIDE_PUE) {
cfg |= GPIO_HAL_PIN_CFG_PULL_UP; cfg |= GPIO_HAL_PIN_CFG_INPUT_PULLUP;
} else if(tmp == IOC_OVERRIDE_PDE) { } else if(tmp == IOC_OVERRIDE_PDE) {
cfg |= GPIO_HAL_PIN_CFG_PULL_DOWN; cfg |= GPIO_HAL_PIN_CFG_INPUT_PULLDOWN;
} else { } else {
cfg |= GPIO_HAL_PIN_CFG_PULL_NONE; cfg |= GPIO_HAL_PIN_CFG_INPUT_NOPULL;
} }
/* Interrupt enable/disable */ /* Interrupt enable/disable */
@ -123,20 +119,14 @@ gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
if(tmp == 0) { if(tmp == 0) {
cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE; cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE;
} else { } else {
cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE; /* Edge detection */
}
/* Edge detection */
if(REG((port_base) + GPIO_IS) & pin_mask) {
cfg |= GPIO_HAL_PIN_CFG_EDGE_NONE;
} else {
if(REG((port_base) + GPIO_IBE) & pin_mask) { if(REG((port_base) + GPIO_IBE) & pin_mask) {
cfg |= GPIO_HAL_PIN_CFG_EDGE_BOTH; cfg |= GPIO_HAL_PIN_CFG_INT_BOTH;
} else { } else {
if(REG((port_base) + GPIO_IEV) & pin_mask) { if(REG((port_base) + GPIO_IEV) & pin_mask) {
cfg |= GPIO_HAL_PIN_CFG_EDGE_RISING; cfg |= GPIO_HAL_PIN_CFG_INT_RISING;
} else { } else {
cfg |= GPIO_HAL_PIN_CFG_EDGE_FALLING; cfg |= GPIO_HAL_PIN_CFG_INT_FALLING;
} }
} }
} }

View File

@ -56,7 +56,12 @@
#define PIN_TO_NUM(pin) (pin % 8) #define PIN_TO_NUM(pin) (pin % 8)
#define PIN_TO_PORT_BASE(pin) GPIO_PORT_TO_BASE(PIN_TO_PORT(pin)) #define PIN_TO_PORT_BASE(pin) GPIO_PORT_TO_BASE(PIN_TO_PORT(pin))
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define gpio_hal_arch_interrupt_enable(p) do { \ #define gpio_hal_arch_init() do { \
/* do nothing */ \
} while(0);
#define gpio_hal_arch_interrupt_enable(p, cfg) do { \
gpio_hal_arch_pin_cfg_set((p), (cfg) & GPIO_HAL_PIN_BM_INT); \
GPIO_ENABLE_INTERRUPT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \ GPIO_ENABLE_INTERRUPT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
NVIC_EnableIRQ(PIN_TO_PORT(p)); \ NVIC_EnableIRQ(PIN_TO_PORT(p)); \
} while(0); } while(0);

View File

@ -44,22 +44,23 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "dev/button-hal.h" #include "dev/button-hal.h"
#include "dev/gpio-hal.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
BUTTON_HAL_BUTTON(key_left, "Key Left", \ BUTTON_HAL_BUTTON(key_left, "Key Left", \
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN), \ GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN), \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_ZERO, true); GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_ZERO, true);
BUTTON_HAL_BUTTON(key_right, "Key Right", \ BUTTON_HAL_BUTTON(key_right, "Key Right", \
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN), \ GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN), \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_ONE, true); GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_ONE, true);
BUTTON_HAL_BUTTON(key_up, "Key Up", \ BUTTON_HAL_BUTTON(key_up, "Key Up", \
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_UP_PORT, BUTTON_UP_PIN), \ GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_UP_PORT, BUTTON_UP_PIN), \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_TWO, true); GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_TWO, true);
BUTTON_HAL_BUTTON(key_down, "Key Down", \ BUTTON_HAL_BUTTON(key_down, "Key Down", \
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN), \ GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN), \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_THREE, true); GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_THREE, true);
BUTTON_HAL_BUTTON(key_select, "Key Select", \ BUTTON_HAL_BUTTON(key_select, "Key Select", \
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN), \ GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN), \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_FOUR, true); GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_FOUR, true);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
BUTTON_HAL_BUTTONS(&key_left, &key_right, &key_up, &key_down, &key_select); BUTTON_HAL_BUTTONS(&key_left, &key_right, &key_up, &key_down, &key_select);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -39,6 +39,7 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "dev/button-hal.h" #include "dev/button-hal.h"
#include "dev/gpio-hal.h"
#include "ti-lib.h" #include "ti-lib.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -38,23 +38,23 @@
*/ */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "dev/gpio-hal.h"
#include "dev/button-hal.h" #include "dev/button-hal.h"
#include "dev/gpio-hal.h"
#include "ti-lib.h" #include "ti-lib.h"
#include <stdbool.h> #include <stdbool.h>
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
BUTTON_HAL_BUTTON(reed_relay, "Reed Relay", BOARD_IOID_REED_RELAY, \ BUTTON_HAL_BUTTON(reed_relay, "Reed Relay", BOARD_IOID_REED_RELAY, \
GPIO_HAL_PIN_CFG_PULL_DOWN, \ GPIO_HAL_PIN_CFG_INPUT_PULLDOWN, \
BUTTON_HAL_ID_REED_RELAY, true); BUTTON_HAL_ID_REED_RELAY, true);
BUTTON_HAL_BUTTON(key_left, "Key Left", BOARD_IOID_KEY_LEFT, \ BUTTON_HAL_BUTTON(key_left, "Key Left", BOARD_IOID_KEY_LEFT, \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_KEY_LEFT, \ GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_LEFT, \
true); true);
BUTTON_HAL_BUTTON(key_right, "Key Right", BOARD_IOID_KEY_RIGHT, \ BUTTON_HAL_BUTTON(key_right, "Key Right", BOARD_IOID_KEY_RIGHT, \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_KEY_RIGHT, \ GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_RIGHT, \
true); true);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
BUTTON_HAL_BUTTONS(&reed_relay, &key_left, &key_right); BUTTON_HAL_BUTTONS(&reed_relay, &key_left, &key_right);

View File

@ -39,23 +39,24 @@
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#include "contiki.h" #include "contiki.h"
#include "dev/button-hal.h" #include "dev/button-hal.h"
#include "dev/gpio-hal.h"
#include "ti-lib.h" #include "ti-lib.h"
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
BUTTON_HAL_BUTTON(key_left, "Key Left", BOARD_IOID_KEY_LEFT, \ BUTTON_HAL_BUTTON(key_left, "Key Left", BOARD_IOID_KEY_LEFT, \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_KEY_LEFT, \ GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_LEFT, \
true); true);
BUTTON_HAL_BUTTON(key_right, "Key Right", BOARD_IOID_KEY_RIGHT, \ BUTTON_HAL_BUTTON(key_right, "Key Right", BOARD_IOID_KEY_RIGHT, \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_KEY_RIGHT, \ GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_RIGHT, \
true); true);
BUTTON_HAL_BUTTON(key_up, "Key Up", BOARD_IOID_KEY_UP, \ BUTTON_HAL_BUTTON(key_up, "Key Up", BOARD_IOID_KEY_UP, \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_KEY_UP, \ GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_UP, \
true); true);
BUTTON_HAL_BUTTON(key_down, "Key Down", BOARD_IOID_KEY_DOWN, \ BUTTON_HAL_BUTTON(key_down, "Key Down", BOARD_IOID_KEY_DOWN, \
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_KEY_DOWN, \ GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_DOWN, \
true); true);
BUTTON_HAL_BUTTON(key_select, "Key Select", BOARD_IOID_KEY_SELECT, \ BUTTON_HAL_BUTTON(key_select, "Key Select", BOARD_IOID_KEY_SELECT, \
GPIO_HAL_PIN_CFG_PULL_UP, \ GPIO_HAL_PIN_CFG_INPUT_PULLUP, \
BUTTON_HAL_ID_KEY_SELECT, true); BUTTON_HAL_ID_KEY_SELECT, true);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
BUTTON_HAL_BUTTONS(&key_left, &key_right, &key_up, &key_down, &key_select); BUTTON_HAL_BUTTONS(&key_left, &key_right, &key_up, &key_down, &key_select);

View File

@ -115,11 +115,11 @@ PROCESS_THREAD(gpio_hal_example, ev, data)
gpio_hal_pin_cfg_t interrupt; gpio_hal_pin_cfg_t interrupt;
interrupt = gpio_hal_arch_pin_cfg_get(btn_pin) & interrupt = gpio_hal_arch_pin_cfg_get(btn_pin) &
GPIO_HAL_PIN_CFG_INT_ENABLE; GPIO_HAL_PIN_BM_INT;
if(interrupt == 0) { if(interrupt != GPIO_HAL_PIN_CFG_INT_DISABLE) {
printf("Enabling button interrupt\n"); printf("Enabling button interrupt\n");
gpio_hal_arch_interrupt_enable(btn_pin); gpio_hal_arch_interrupt_enable(btn_pin, GPIO_HAL_PIN_CFG_INT_BOTH);
} else { } else {
printf("Disabling button interrupt\n"); printf("Disabling button interrupt\n");
gpio_hal_arch_interrupt_disable(btn_pin); gpio_hal_arch_interrupt_disable(btn_pin);

View File

@ -98,11 +98,11 @@
#define CC26XX_DEMO_LEDS_BUTTON LEDS_RED #define CC26XX_DEMO_LEDS_BUTTON LEDS_RED
#define CC26XX_DEMO_LEDS_REBOOT LEDS_ALL #define CC26XX_DEMO_LEDS_REBOOT LEDS_ALL
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define CC26XX_DEMO_TRIGGER_1 BOARD_BUTTON_HAL_INDEX_KEY_LEFT #define CC26XX_DEMO_TRIGGER_1 BUTTON_HAL_ID_KEY_LEFT
#define CC26XX_DEMO_TRIGGER_2 BOARD_BUTTON_HAL_INDEX_KEY_RIGHT #define CC26XX_DEMO_TRIGGER_2 BUTTON_HAL_ID_KEY_RIGHT
#if BOARD_SENSORTAG #if BOARD_SENSORTAG
#define CC26XX_DEMO_TRIGGER_3 BOARD_BUTTON_HAL_INDEX_REED_RELAY #define CC26XX_DEMO_TRIGGER_3 BUTTON_HAL_ID_REED_RELAY
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static struct etimer et; static struct etimer et;

View File

@ -63,7 +63,7 @@
#define VERY_SLEEPY_MODE_OFF 0 #define VERY_SLEEPY_MODE_OFF 0
#define VERY_SLEEPY_MODE_ON 1 #define VERY_SLEEPY_MODE_ON 1
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define BUTTON_TRIGGER BOARD_BUTTON_HAL_INDEX_KEY_LEFT #define BUTTON_TRIGGER BUTTON_HAL_ID_KEY_LEFT
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#define MAC_CAN_BE_TURNED_OFF 0 #define MAC_CAN_BE_TURNED_OFF 0
#define MAC_MUST_STAY_ON 1 #define MAC_MUST_STAY_ON 1