Reverting API change to GPIO HAL
This commit is contained in:
parent
aa5b5bce6d
commit
d0124e3de7
@ -57,35 +57,39 @@ gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
|
||||
gpio_hal_pin_cfg_t tmp;
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_BM_INT;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_INT_DISABLE) {
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_EDGE_NONE) {
|
||||
GPIO_DISABLE_INTERRUPT(port_base, pin_mask);
|
||||
} 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);
|
||||
NVIC_EnableIRQ(port);
|
||||
} 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_BM_INPUT;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_INPUT_NOPULL) {
|
||||
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_INPUT_PULLDOWN) {
|
||||
} 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_INPUT_PULLUP) {
|
||||
} 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) {
|
||||
GPIO_DISABLE_INTERRUPT(port_base, pin_mask);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INT_ENABLE) {
|
||||
GPIO_ENABLE_INTERRUPT(port_base, pin_mask);
|
||||
NVIC_EnableIRQ(port);
|
||||
}
|
||||
|
||||
GPIO_SOFTWARE_CONTROL(port_base, pin_mask);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -107,11 +111,11 @@ gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
|
||||
/* Pull */
|
||||
tmp = ioc_get_over(port, pin_num);
|
||||
if(tmp == IOC_OVERRIDE_PUE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INPUT_PULLUP;
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_UP;
|
||||
} else if(tmp == IOC_OVERRIDE_PDE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INPUT_PULLDOWN;
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_DOWN;
|
||||
} else {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INPUT_NOPULL;
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_NONE;
|
||||
}
|
||||
|
||||
/* Interrupt enable/disable */
|
||||
@ -119,14 +123,20 @@ gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
|
||||
if(tmp == 0) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE;
|
||||
} else {
|
||||
/* Edge detection */
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_BOTH;
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
} else {
|
||||
if(REG((port_base) + GPIO_IEV) & pin_mask) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_RISING;
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_RISING;
|
||||
} else {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_FALLING;
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_FALLING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,12 +56,9 @@
|
||||
#define PIN_TO_NUM(pin) (pin % 8)
|
||||
#define PIN_TO_PORT_BASE(pin) GPIO_PORT_TO_BASE(PIN_TO_PORT(pin))
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_hal_arch_init() do { \
|
||||
/* do nothing */ \
|
||||
} while(0);
|
||||
#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); \
|
||||
#define gpio_hal_arch_interrupt_enable(p) do { \
|
||||
GPIO_ENABLE_INTERRUPT(PIN_TO_PORT_BASE(p), GPIO_PIN_MASK((p) % 8)); \
|
||||
NVIC_EnableIRQ(PIN_TO_PORT(p)); \
|
||||
} while(0);
|
||||
|
@ -47,18 +47,6 @@
|
||||
#define CONFIG_MASK (IOC_IOPULL_M | IOC_INT_M | IOC_IOMODE_OPEN_SRC_INV)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
{
|
||||
gpio_hal_pin_cfg_t config = gpio_hal_arch_pin_cfg_get(pin);
|
||||
config &= ~GPIO_HAL_PIN_BM_INT;
|
||||
config |= cfg;
|
||||
gpio_hal_arch_pin_cfg_set(pin, cfg);
|
||||
|
||||
ti_lib_gpio_clear_event_dio(pin);
|
||||
ti_lib_rom_ioc_int_enable(pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
{
|
||||
uint32_t config;
|
||||
@ -68,26 +56,33 @@ gpio_hal_arch_pin_cfg_set(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
config = ti_lib_rom_ioc_port_configure_get(pin);
|
||||
config &= ~CONFIG_MASK;
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_BM_INT;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_INT_DISABLE) {
|
||||
config |= (IOC_NO_EDGE | IOC_INT_DISABLE);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INT_RISING) {
|
||||
config |= (IOC_RISING_EDGE | IOC_INT_ENABLE);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INT_FALLING) {
|
||||
config |= (IOC_FALLING_EDGE | IOC_INT_ENABLE);
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INT_BOTH) {
|
||||
config |= (IOC_BOTH_EDGES | IOC_INT_ENABLE);
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_EDGE_NONE) {
|
||||
config |= IOC_NO_EDGE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_RISING) {
|
||||
config |= IOC_RISING_EDGE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_FALLING) {
|
||||
config |= IOC_FALLING_EDGE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_EDGE_BOTH) {
|
||||
config |= IOC_BOTH_EDGES;
|
||||
}
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_BM_INPUT;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_INPUT_NOPULL) {
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_PULL_MASK;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_PULL_NONE) {
|
||||
config |= IOC_NO_IOPULL;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INPUT_PULLDOWN) {
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_DOWN) {
|
||||
config |= IOC_IOPULL_DOWN;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INPUT_PULLUP) {
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_PULL_UP) {
|
||||
config |= IOC_IOPULL_UP;
|
||||
}
|
||||
|
||||
tmp = cfg & GPIO_HAL_PIN_CFG_INT_MASK;
|
||||
if(tmp == GPIO_HAL_PIN_CFG_INT_DISABLE) {
|
||||
config |= IOC_INT_DISABLE;
|
||||
} else if(tmp == GPIO_HAL_PIN_CFG_INT_ENABLE) {
|
||||
config |= IOC_INT_ENABLE;
|
||||
}
|
||||
|
||||
ti_lib_rom_ioc_port_configure_set(pin, IOC_PORT_GPIO, config);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -104,27 +99,31 @@ gpio_hal_arch_pin_cfg_get(gpio_hal_pin_t pin)
|
||||
/* Pull */
|
||||
tmp = config & IOC_IOPULL_M;
|
||||
if(tmp == IOC_IOPULL_UP) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INPUT_PULLUP;
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_UP;
|
||||
} else if(tmp == IOC_IOPULL_DOWN) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INPUT_PULLDOWN;
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_DOWN;
|
||||
} else if(tmp == IOC_NO_IOPULL) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INPUT_NOPULL;
|
||||
cfg |= GPIO_HAL_PIN_CFG_PULL_NONE;
|
||||
}
|
||||
|
||||
/* Interrupt enable/disable */
|
||||
tmp = config & IOC_INT_ENABLE;
|
||||
if(tmp == IOC_INT_DISABLE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE;
|
||||
} else {
|
||||
/* Edge detection */
|
||||
tmp = config & IOC_BOTH_EDGES;
|
||||
if(tmp == IOC_FALLING_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_FALLING;
|
||||
} else if(tmp == IOC_RISING_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_RISING;
|
||||
} else if(tmp == IOC_BOTH_EDGES) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_BOTH;
|
||||
}
|
||||
} else if(tmp == IOC_INT_ENABLE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
}
|
||||
|
||||
/* Edge detection */
|
||||
tmp = config & IOC_BOTH_EDGES;
|
||||
if(tmp == IOC_NO_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_NONE;
|
||||
} else if(tmp == IOC_FALLING_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_FALLING;
|
||||
} else if(tmp == IOC_RISING_EDGE) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_RISING;
|
||||
} else if(tmp == IOC_BOTH_EDGES) {
|
||||
cfg |= GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
}
|
||||
|
||||
return cfg;
|
||||
|
@ -53,7 +53,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define gpio_hal_arch_init() do { /* do nothing */ } while (0)
|
||||
#define gpio_hal_arch_init() do { /* Do nothing */ } while(0)
|
||||
|
||||
#define gpio_hal_arch_interrupt_enable(p) interrupt_enable(p)
|
||||
#define gpio_hal_arch_interrupt_disable(p) ti_lib_rom_ioc_int_disable(p)
|
||||
|
||||
#define gpio_hal_arch_pin_set_input(p) ti_lib_rom_ioc_pin_type_gpio_input(p)
|
||||
@ -69,6 +71,13 @@
|
||||
#define gpio_hal_arch_toggle_pins(p) ti_lib_gpio_toggle_multi_dio(p)
|
||||
#define gpio_hal_arch_write_pins(p, v) ti_lib_gpio_write_multi_dio(p, v)
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static inline void
|
||||
interrupt_enable(gpio_hal_pin_t pin)
|
||||
{
|
||||
ti_lib_gpio_clear_event_dio(pin);
|
||||
ti_lib_rom_ioc_int_enable(pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#endif /* GPIO_HAL_ARCH_H_ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -45,20 +45,18 @@ static uint8_t pin_state[GPIO_HAL_PIN_COUNT];
|
||||
void
|
||||
gpio_hal_arch_init(void)
|
||||
{
|
||||
LOG_DBG("Initialized\n");
|
||||
/* Do nothing */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin)
|
||||
{
|
||||
if(pin >= GPIO_HAL_PIN_COUNT) {
|
||||
LOG_ERR("Pin %u out of bounds\n", pin);
|
||||
return;
|
||||
}
|
||||
|
||||
pin_cfg[pin] &= ~(gpio_hal_pin_cfg_t)GPIO_HAL_PIN_BM_INT;
|
||||
pin_cfg[pin] |= cfg;
|
||||
LOG_DBG("Pin %u: Enabled interrupt, config=0x%02x\n", pin, pin_cfg[pin]);
|
||||
LOG_DBG("Pin %u: Enabled interrupt\n", pin);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -57,60 +57,36 @@ static PIN_Handle pin_handle;
|
||||
static void
|
||||
from_hal_cfg(gpio_hal_pin_cfg_t cfg, PIN_Config *pin_cfg, PIN_Config *pin_mask)
|
||||
{
|
||||
cfg &= GPIO_HAL_PIN_BM_ALL;
|
||||
/* Pulling config */
|
||||
*pin_mask |= PIN_BM_PULLING;
|
||||
|
||||
/* Input config */
|
||||
if(cfg & GPIO_HAL_PIN_BM_INPUT) {
|
||||
*pin_mask |= PIN_BM_INPUT_MODE;
|
||||
|
||||
/* Hysteresis config */
|
||||
if((cfg & GPIO_HAL_PIN_BM_INPUT_HYSTERESIS) == GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS) {
|
||||
*pin_cfg |= PIN_HYSTERESIS;
|
||||
}
|
||||
|
||||
/* Pulling config */
|
||||
switch(cfg & GPIO_HAL_PIN_BM_INPUT_PULLING) {
|
||||
case GPIO_HAL_PIN_CFG_INPUT_NOPULL: *pin_cfg |= PIN_NOPULL; break;
|
||||
case GPIO_HAL_PIN_CFG_INPUT_PULLUP: *pin_cfg |= PIN_PULLUP; break;
|
||||
case GPIO_HAL_PIN_CFG_INPUT_PULLDOWN: *pin_cfg |= PIN_PULLDOWN; break;
|
||||
}
|
||||
switch(cfg & GPIO_HAL_PIN_CFG_PULL_MASK) {
|
||||
default: /* Default to no pullup/pulldown */
|
||||
case GPIO_HAL_PIN_CFG_PULL_NONE: *pin_cfg |= PIN_NOPULL; break;
|
||||
case GPIO_HAL_PIN_CFG_PULL_UP: *pin_cfg |= PIN_PULLUP; break;
|
||||
case GPIO_HAL_PIN_CFG_PULL_DOWN: *pin_cfg |= PIN_PULLDOWN; break;
|
||||
}
|
||||
|
||||
/* Output config */
|
||||
if(cfg & GPIO_HAL_PIN_BM_OUTPUT) {
|
||||
*pin_mask |= PIN_BM_OUTPUT_MODE;
|
||||
/* Hysteresis config */
|
||||
*pin_mask |= PIN_BM_HYSTERESIS;
|
||||
|
||||
/* Output buffer type config */
|
||||
switch(cfg & GPIO_HAL_PIN_BM_OUTPUT_BUF) {
|
||||
case GPIO_HAL_PIN_CFG_OUTPUT_PUSHPULL: *pin_cfg |= PIN_PUSHPULL; break;
|
||||
case GPIO_HAL_PIN_CFG_OUTPUT_OPENDRAIN: *pin_cfg |= PIN_OPENDRAIN; break;
|
||||
case GPIO_HAL_PIN_CFG_OUTPUT_OPENSOURCE: *pin_cfg |= PIN_OPENSOURCE; break;
|
||||
}
|
||||
|
||||
/* Slew control config */
|
||||
if((cfg & GPIO_HAL_PIN_BM_OUTPUT_SLEWCTRL) == GPIO_HAL_PIN_CFG_OUTPUT_SLEWCTRL) {
|
||||
*pin_cfg |= PIN_SLEWCTRL;
|
||||
}
|
||||
|
||||
/* Drive strength config */
|
||||
switch(cfg & GPIO_HAL_PIN_BM_OUTPUT_DRVSTR) {
|
||||
case GPIO_HAL_PIN_CFG_OUTPUT_DRVSTR_MIN: *pin_cfg |= PIN_DRVSTR_MIN; break;
|
||||
case GPIO_HAL_PIN_CFG_OUTPUT_DRVSTR_MED: *pin_cfg |= PIN_DRVSTR_MED; break;
|
||||
case GPIO_HAL_PIN_CFG_OUTPUT_DRVSTR_MAX: *pin_cfg |= PIN_DRVSTR_MAX; break;
|
||||
}
|
||||
if(cfg & GPIO_HAL_PIN_CFG_HYSTERESIS) {
|
||||
*pin_cfg |= PIN_HYSTERESIS;
|
||||
}
|
||||
|
||||
/* Interrupt config */
|
||||
if(cfg & GPIO_HAL_PIN_BM_INT) {
|
||||
*pin_mask |= PIN_BM_IRQ;
|
||||
*pin_mask |= PIN_BM_IRQ;
|
||||
|
||||
if((cfg & GPIO_HAL_PIN_CFG_INT_MASK) == GPIO_HAL_PIN_CFG_INT_ENABLE) {
|
||||
/* Interrupt edge config */
|
||||
switch(cfg & GPIO_HAL_PIN_BM_INT) {
|
||||
case GPIO_HAL_PIN_CFG_INT_DISABLE: *pin_cfg |= PIN_IRQ_DIS; break;
|
||||
case GPIO_HAL_PIN_CFG_INT_FALLING: *pin_cfg |= PIN_IRQ_NEGEDGE; break;
|
||||
case GPIO_HAL_PIN_CFG_INT_RISING: *pin_cfg |= PIN_IRQ_POSEDGE; break;
|
||||
case GPIO_HAL_PIN_CFG_INT_BOTH: *pin_cfg |= PIN_IRQ_BOTHEDGES; break;
|
||||
switch(cfg & GPIO_HAL_PIN_CFG_EDGE_BOTH) {
|
||||
case GPIO_HAL_PIN_CFG_EDGE_NONE: *pin_cfg |= PIN_IRQ_DIS; break;
|
||||
case GPIO_HAL_PIN_CFG_EDGE_FALLING: *pin_cfg |= PIN_IRQ_NEGEDGE; break;
|
||||
case GPIO_HAL_PIN_CFG_EDGE_RISING: *pin_cfg |= PIN_IRQ_POSEDGE; break;
|
||||
case GPIO_HAL_PIN_CFG_EDGE_BOTH: *pin_cfg |= PIN_IRQ_BOTHEDGES; break;
|
||||
}
|
||||
} else {
|
||||
*pin_cfg |= PIN_IRQ_DIS;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -121,36 +97,14 @@ to_hal_cfg(PIN_Config pin_cfg, gpio_hal_pin_cfg_t *cfg)
|
||||
if(pin_cfg & PIN_BM_INPUT_MODE) {
|
||||
/* Hysteresis config */
|
||||
if((pin_cfg & PIN_BM_HYSTERESIS) == PIN_HYSTERESIS) {
|
||||
*cfg |= GPIO_HAL_PIN_BM_INPUT_HYSTERESIS;
|
||||
*cfg |= GPIO_HAL_PIN_CFG_HYSTERESIS;
|
||||
}
|
||||
|
||||
/* Pulling config */
|
||||
switch(pin_cfg & PIN_BM_PULLING) {
|
||||
case PIN_NOPULL: *cfg |= GPIO_HAL_PIN_CFG_INPUT_NOPULL; break;
|
||||
case PIN_PULLUP: *cfg |= GPIO_HAL_PIN_CFG_INPUT_PULLUP; break;
|
||||
case PIN_PULLDOWN: *cfg |= GPIO_HAL_PIN_CFG_INPUT_PULLDOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Output config */
|
||||
if(pin_cfg & PIN_BM_OUTPUT_MODE) {
|
||||
/* Output buffer type config */
|
||||
switch(pin_cfg & PIN_BM_OUTPUT_BUF) {
|
||||
case PIN_PUSHPULL: *cfg |= GPIO_HAL_PIN_CFG_OUTPUT_PUSHPULL; break;
|
||||
case PIN_OPENDRAIN: *cfg |= GPIO_HAL_PIN_CFG_OUTPUT_OPENDRAIN; break;
|
||||
case PIN_OPENSOURCE: *cfg |= GPIO_HAL_PIN_CFG_OUTPUT_OPENSOURCE; break;
|
||||
}
|
||||
|
||||
/* Slew control config */
|
||||
if((pin_cfg & PIN_BM_SLEWCTRL) == PIN_SLEWCTRL) {
|
||||
*cfg |= GPIO_HAL_PIN_CFG_OUTPUT_SLEWCTRL;
|
||||
}
|
||||
|
||||
/* Drive strength config */
|
||||
switch(pin_cfg & PIN_BM_DRVSTR) {
|
||||
case PIN_DRVSTR_MIN: *cfg |= GPIO_HAL_PIN_CFG_OUTPUT_DRVSTR_MIN; break;
|
||||
case PIN_DRVSTR_MED: *cfg |= GPIO_HAL_PIN_CFG_OUTPUT_DRVSTR_MED; break;
|
||||
case PIN_DRVSTR_MAX: *cfg |= GPIO_HAL_PIN_CFG_OUTPUT_DRVSTR_MAX; break;
|
||||
case PIN_NOPULL: *cfg |= GPIO_HAL_PIN_CFG_PULL_NONE; break;
|
||||
case PIN_PULLUP: *cfg |= GPIO_HAL_PIN_CFG_PULL_UP; break;
|
||||
case PIN_PULLDOWN: *cfg |= GPIO_HAL_PIN_CFG_PULL_DOWN; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,10 +112,18 @@ to_hal_cfg(PIN_Config pin_cfg, gpio_hal_pin_cfg_t *cfg)
|
||||
if(pin_cfg & PIN_BM_IRQ) {
|
||||
/* Interrupt edge config */
|
||||
switch(pin_cfg & PIN_BM_IRQ) {
|
||||
case PIN_IRQ_DIS: *cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE; break;
|
||||
case PIN_IRQ_NEGEDGE: *cfg |= GPIO_HAL_PIN_CFG_INT_FALLING; break;
|
||||
case PIN_IRQ_POSEDGE: *cfg |= GPIO_HAL_PIN_CFG_INT_RISING; break;
|
||||
case PIN_IRQ_BOTHEDGES: *cfg |= GPIO_HAL_PIN_CFG_INT_BOTH; break;
|
||||
case PIN_IRQ_DIS: *cfg |= GPIO_HAL_PIN_CFG_EDGE_NONE;
|
||||
*cfg |= GPIO_HAL_PIN_CFG_INT_DISABLE;
|
||||
break;
|
||||
case PIN_IRQ_NEGEDGE: *cfg |= GPIO_HAL_PIN_CFG_EDGE_FALLING;
|
||||
*cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
break;
|
||||
case PIN_IRQ_POSEDGE: *cfg |= GPIO_HAL_PIN_CFG_EDGE_RISING;
|
||||
*cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
break;
|
||||
case PIN_IRQ_BOTHEDGES: *cfg |= GPIO_HAL_PIN_CFG_EDGE_BOTH;
|
||||
*cfg |= GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,20 +147,16 @@ gpio_hal_arch_init(void)
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
|
||||
gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin)
|
||||
{
|
||||
PIN_add(pin_handle, PIN_getConfig(pin));
|
||||
PIN_Config pin_cfg;
|
||||
PIN_Config irq_cfg;
|
||||
|
||||
cfg &= GPIO_HAL_PIN_BM_INT;
|
||||
pin_cfg = PIN_getConfig(pin);
|
||||
PIN_add(pin_handle, pin_cfg);
|
||||
|
||||
PIN_Config int_cfg = PIN_IRQ_DIS;
|
||||
switch(cfg) {
|
||||
case GPIO_HAL_PIN_CFG_INT_FALLING: int_cfg |= PIN_IRQ_NEGEDGE; break;
|
||||
case GPIO_HAL_PIN_CFG_INT_RISING: int_cfg |= PIN_IRQ_POSEDGE; break;
|
||||
case GPIO_HAL_PIN_CFG_INT_BOTH: int_cfg |= PIN_IRQ_BOTHEDGES; break;
|
||||
}
|
||||
|
||||
PIN_setInterrupt(pin_handle, pin | int_cfg);
|
||||
irq_cfg = pin_cfg & PIN_BM_IRQ;
|
||||
PIN_setInterrupt(pin_handle, pin | irq_cfg);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -44,23 +44,22 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/button-hal.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTON(key_left, "Key Left", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_LEFT_PORT, BUTTON_LEFT_PIN), \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_ZERO, true);
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_ZERO, true);
|
||||
BUTTON_HAL_BUTTON(key_right, "Key Right", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_RIGHT_PORT, BUTTON_RIGHT_PIN), \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_ONE, true);
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_ONE, true);
|
||||
BUTTON_HAL_BUTTON(key_up, "Key Up", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_UP_PORT, BUTTON_UP_PIN), \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_TWO, true);
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_TWO, true);
|
||||
BUTTON_HAL_BUTTON(key_down, "Key Down", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_DOWN_PORT, BUTTON_DOWN_PIN), \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_THREE, true);
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_THREE, true);
|
||||
BUTTON_HAL_BUTTON(key_select, "Key Select", \
|
||||
GPIO_PORT_PIN_TO_GPIO_HAL_PIN(BUTTON_SELECT_PORT, BUTTON_SELECT_PIN), \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_BUTTON_FOUR, true);
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BUTTON_HAL_ID_BUTTON_FOUR, true);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&key_left, &key_right, &key_up, &key_down, &key_select);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -45,23 +45,23 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Key left button, AKA BTN-1. */
|
||||
BUTTON_HAL_BUTTON(
|
||||
key_left, /**< Name */
|
||||
"Key Left", /**< Description */
|
||||
Board_PIN_BTN1, /**< Board PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_LEFT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
key_left, /**< Name */
|
||||
"Key Left", /**< Description */
|
||||
Board_PIN_BTN1, /**< Board PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_UP |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_LEFT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
|
||||
/* Key right button, AKA BTN-2. */
|
||||
BUTTON_HAL_BUTTON(
|
||||
key_right, /**< Name */
|
||||
"Key Right", /**< Description */
|
||||
Board_PIN_BTN2, /**< Board PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_RIGHT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
key_right, /**< Name */
|
||||
"Key Right", /**< Description */
|
||||
Board_PIN_BTN2, /**< Board PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_UP |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_RIGHT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&key_left, &key_right);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -45,33 +45,33 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Key left button, AKA BTN-1 */
|
||||
BUTTON_HAL_BUTTON(
|
||||
key_left, /**< Name */
|
||||
"Key Left", /**< Description */
|
||||
Board_KEY_LEFT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_LEFT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
key_left, /**< Name */
|
||||
"Key Left", /**< Description */
|
||||
Board_KEY_LEFT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_UP |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_LEFT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
|
||||
/* Key right button, AKA BTN-2 */
|
||||
BUTTON_HAL_BUTTON(
|
||||
key_right, /**< Name */
|
||||
"Key Right", /**< Description */
|
||||
Board_KEY_RIGHT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_RIGHT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
key_right, /**< Name */
|
||||
"Key Right", /**< Description */
|
||||
Board_KEY_RIGHT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_UP |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_RIGHT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
|
||||
/* Reed Relay button */
|
||||
BUTTON_HAL_BUTTON(
|
||||
reed_relay, /**< Name */
|
||||
"Reed Relay", /**< Description */
|
||||
Board_RELAY, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLDOWN |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_REED_RELAY, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
reed_relay, /**< Name */
|
||||
"Reed Relay", /**< Description */
|
||||
Board_RELAY, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_DOWN |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_REED_RELAY, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&key_left, &key_right, &reed_relay);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -45,53 +45,53 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Key select button */
|
||||
BUTTON_HAL_BUTTON(
|
||||
key_select, /**< Name */
|
||||
"Key Select", /**< Description */
|
||||
Board_KEY_SELECT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_SELECT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
key_select, /**< Name */
|
||||
"Key Select", /**< Description */
|
||||
Board_KEY_SELECT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_UP |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_SELECT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
|
||||
/* Key up button */
|
||||
BUTTON_HAL_BUTTON(
|
||||
key_up, /**< Name */
|
||||
"Key Up", /**< Description */
|
||||
Board_KEY_UP, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_UP, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
key_up, /**< Name */
|
||||
"Key Up", /**< Description */
|
||||
Board_KEY_UP, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_UP |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_UP, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
|
||||
/* Key down button */
|
||||
BUTTON_HAL_BUTTON(
|
||||
key_down, /**< Name */
|
||||
"Key Down", /**< Description */
|
||||
Board_KEY_DOWN, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_DOWN, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
key_down, /**< Name */
|
||||
"Key Down", /**< Description */
|
||||
Board_KEY_DOWN, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_UP |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_DOWN, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
|
||||
/* Key left button */
|
||||
BUTTON_HAL_BUTTON(
|
||||
key_left, /**< Name */
|
||||
"Key Left", /**< Description */
|
||||
Board_KEY_LEFT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_LEFT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
key_left, /**< Name */
|
||||
"Key Left", /**< Description */
|
||||
Board_KEY_LEFT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_UP |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_LEFT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
|
||||
/* Key right button */
|
||||
BUTTON_HAL_BUTTON(
|
||||
key_right, /**< Name */
|
||||
"Key Right", /**< Description */
|
||||
Board_KEY_RIGHT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP |
|
||||
GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_RIGHT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
key_right, /**< Name */
|
||||
"Key Right", /**< Description */
|
||||
Board_KEY_RIGHT, /**< PIN */
|
||||
GPIO_HAL_PIN_CFG_PULL_UP |
|
||||
GPIO_HAL_PIN_CFG_HYSTERESIS, /**< Pull configuration */
|
||||
BUTTON_HAL_ID_KEY_RIGHT, /**< Unique ID */
|
||||
true); /**< Negative logic */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&key_select, &key_up, &key_down, &key_left, &key_right);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -39,16 +39,15 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/button-hal.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include "ti-lib.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTON(key_left, "Key Left", BOARD_IOID_KEY_LEFT, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_LEFT, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_LEFT, \
|
||||
true);
|
||||
|
||||
BUTTON_HAL_BUTTON(key_right, "Key Right", BOARD_IOID_KEY_RIGHT, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_RIGHT, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_RIGHT, \
|
||||
true);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&key_left, &key_right);
|
||||
|
@ -198,8 +198,8 @@
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define BUTTON_HAL_ID_KEY_LEFT 0x00
|
||||
#define BUTTON_HAL_ID_KEY_RIGHT 0x01
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_LEFT 0x00
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_RIGHT 0x01
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -214,8 +214,8 @@
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define BUTTON_HAL_ID_KEY_LEFT 0x00
|
||||
#define BUTTON_HAL_ID_KEY_RIGHT 0x01
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_LEFT 0x00
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_RIGHT 0x01
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -199,8 +199,8 @@
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define BUTTON_HAL_ID_KEY_LEFT 0x00
|
||||
#define BUTTON_HAL_ID_KEY_RIGHT 0x01
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_LEFT 0x00
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_RIGHT 0x01
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -38,23 +38,23 @@
|
||||
*/
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/button-hal.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
#include "dev/button-hal.h"
|
||||
|
||||
#include "ti-lib.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTON(reed_relay, "Reed Relay", BOARD_IOID_REED_RELAY, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLDOWN, \
|
||||
BUTTON_HAL_ID_REED_RELAY, true);
|
||||
GPIO_HAL_PIN_CFG_PULL_DOWN, \
|
||||
BOARD_BUTTON_HAL_INDEX_REED_RELAY, true);
|
||||
|
||||
BUTTON_HAL_BUTTON(key_left, "Key Left", BOARD_IOID_KEY_LEFT, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_LEFT, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_LEFT, \
|
||||
true);
|
||||
|
||||
BUTTON_HAL_BUTTON(key_right, "Key Right", BOARD_IOID_KEY_RIGHT, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_RIGHT, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_RIGHT, \
|
||||
true);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&reed_relay, &key_left, &key_right);
|
||||
|
@ -248,9 +248,9 @@
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define BUTTON_HAL_ID_KEY_LEFT 0x00
|
||||
#define BUTTON_HAL_ID_KEY_RIGHT 0x01
|
||||
#define BUTTON_HAL_ID_REED_RELAY 0xFF
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_LEFT 0x00
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_RIGHT 0x01
|
||||
#define BOARD_BUTTON_HAL_INDEX_REED_RELAY 0xFF
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -229,9 +229,9 @@
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define BUTTON_HAL_ID_KEY_LEFT 0x00
|
||||
#define BUTTON_HAL_ID_KEY_RIGHT 0x01
|
||||
#define BUTTON_HAL_ID_REED_RELAY 0xFF
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_LEFT 0x00
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_RIGHT 0x01
|
||||
#define BOARD_BUTTON_HAL_INDEX_REED_RELAY 0xFF
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -39,25 +39,24 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#include "contiki.h"
|
||||
#include "dev/button-hal.h"
|
||||
#include "dev/gpio-hal.h"
|
||||
|
||||
#include "ti-lib.h"
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTON(key_left, "Key Left", BOARD_IOID_KEY_LEFT, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_LEFT, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_LEFT, \
|
||||
true);
|
||||
BUTTON_HAL_BUTTON(key_right, "Key Right", BOARD_IOID_KEY_RIGHT, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_RIGHT, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_RIGHT, \
|
||||
true);
|
||||
BUTTON_HAL_BUTTON(key_up, "Key Up", BOARD_IOID_KEY_UP, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_UP, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_UP, \
|
||||
true);
|
||||
BUTTON_HAL_BUTTON(key_down, "Key Down", BOARD_IOID_KEY_DOWN, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, BUTTON_HAL_ID_KEY_DOWN, \
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, BOARD_BUTTON_HAL_INDEX_KEY_DOWN, \
|
||||
true);
|
||||
BUTTON_HAL_BUTTON(key_select, "Key Select", BOARD_IOID_KEY_SELECT, \
|
||||
GPIO_HAL_PIN_CFG_INPUT_PULLUP, \
|
||||
BUTTON_HAL_ID_KEY_SELECT, true);
|
||||
GPIO_HAL_PIN_CFG_PULL_UP, \
|
||||
BOARD_BUTTON_HAL_INDEX_KEY_SELECT, true);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
BUTTON_HAL_BUTTONS(&key_left, &key_right, &key_up, &key_down, &key_select);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -238,11 +238,11 @@
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define BUTTON_HAL_ID_KEY_LEFT 0x00
|
||||
#define BUTTON_HAL_ID_KEY_RIGHT 0x01
|
||||
#define BUTTON_HAL_ID_KEY_UP 0x02
|
||||
#define BUTTON_HAL_ID_KEY_DOWN 0x03
|
||||
#define BUTTON_HAL_ID_KEY_SELECT 0x04
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_LEFT 0x00
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_RIGHT 0x01
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_UP 0x02
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_DOWN 0x03
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_SELECT 0x04
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -238,11 +238,11 @@
|
||||
* Those values are not meant to be modified by the user
|
||||
* @{
|
||||
*/
|
||||
#define BUTTON_HAL_ID_KEY_LEFT 0x00
|
||||
#define BUTTON_HAL_ID_KEY_RIGHT 0x01
|
||||
#define BUTTON_HAL_ID_KEY_UP 0x02
|
||||
#define BUTTON_HAL_ID_KEY_DOWN 0x03
|
||||
#define BUTTON_HAL_ID_KEY_SELECT 0x04
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_LEFT 0x00
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_RIGHT 0x01
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_UP 0x02
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_DOWN 0x03
|
||||
#define BOARD_BUTTON_HAL_INDEX_KEY_SELECT 0x04
|
||||
/** @} */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
|
@ -115,11 +115,11 @@ PROCESS_THREAD(gpio_hal_example, ev, data)
|
||||
gpio_hal_pin_cfg_t interrupt;
|
||||
|
||||
interrupt = gpio_hal_arch_pin_cfg_get(btn_pin) &
|
||||
GPIO_HAL_PIN_BM_INT;
|
||||
GPIO_HAL_PIN_CFG_INT_ENABLE;
|
||||
|
||||
if(interrupt != GPIO_HAL_PIN_CFG_INT_DISABLE) {
|
||||
if(interrupt == 0) {
|
||||
printf("Enabling button interrupt\n");
|
||||
gpio_hal_arch_interrupt_enable(btn_pin, GPIO_HAL_PIN_CFG_INT_BOTH);
|
||||
gpio_hal_arch_interrupt_enable(btn_pin);
|
||||
} else {
|
||||
printf("Disabling button interrupt\n");
|
||||
gpio_hal_arch_interrupt_disable(btn_pin);
|
||||
|
@ -98,11 +98,11 @@
|
||||
#define CC26XX_DEMO_LEDS_BUTTON LEDS_RED
|
||||
#define CC26XX_DEMO_LEDS_REBOOT LEDS_ALL
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define CC26XX_DEMO_TRIGGER_1 BUTTON_HAL_ID_KEY_LEFT
|
||||
#define CC26XX_DEMO_TRIGGER_2 BUTTON_HAL_ID_KEY_RIGHT
|
||||
#define CC26XX_DEMO_TRIGGER_1 BOARD_BUTTON_HAL_INDEX_KEY_LEFT
|
||||
#define CC26XX_DEMO_TRIGGER_2 BOARD_BUTTON_HAL_INDEX_KEY_RIGHT
|
||||
|
||||
#if BOARD_SENSORTAG
|
||||
#define CC26XX_DEMO_TRIGGER_3 BUTTON_HAL_ID_REED_RELAY
|
||||
#define CC26XX_DEMO_TRIGGER_3 BOARD_BUTTON_HAL_INDEX_REED_RELAY
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct etimer et;
|
||||
|
@ -98,18 +98,18 @@
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* User configuration */
|
||||
/* Take a sensor reading on button press */
|
||||
#define CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER BUTTON_HAL_ID_KEY_LEFT
|
||||
#define CC26XX_WEB_DEMO_SENSOR_READING_TRIGGER BOARD_BUTTON_HAL_INDEX_KEY_LEFT
|
||||
|
||||
/* Payload length of ICMPv6 echo requests used to measure RSSI with def rt */
|
||||
#define CC26XX_WEB_DEMO_ECHO_REQ_PAYLOAD_LEN 20
|
||||
|
||||
#if BOARD_SENSORTAG
|
||||
/* Force an MQTT publish on sensor event */
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BUTTON_HAL_ID_REED_RELAY
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BOARD_BUTTON_HAL_INDEX_REED_RELAY
|
||||
#elif BOARD_LAUNCHPAD
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BUTTON_HAL_ID_KEY_LEFT
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BOARD_BUTTON_HAL_INDEX_KEY_LEFT
|
||||
#else
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BUTTON_HAL_ID_KEY_DOWN
|
||||
#define CC26XX_WEB_DEMO_MQTT_PUBLISH_TRIGGER BOARD_BUTTON_HAL_INDEX_KEY_DOWN
|
||||
#endif
|
||||
|
||||
#define CC26XX_WEB_DEMO_STATUS_LED LEDS_GREEN
|
||||
|
@ -63,7 +63,7 @@
|
||||
#define VERY_SLEEPY_MODE_OFF 0
|
||||
#define VERY_SLEEPY_MODE_ON 1
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define BUTTON_TRIGGER BUTTON_HAL_ID_KEY_LEFT
|
||||
#define BUTTON_TRIGGER BOARD_BUTTON_HAL_INDEX_KEY_LEFT
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define MAC_CAN_BE_TURNED_OFF 0
|
||||
#define MAC_MUST_STAY_ON 1
|
||||
|
@ -178,10 +178,11 @@ button_hal_init()
|
||||
button_event_handler.handler = press_release_handler;
|
||||
|
||||
for(button = button_hal_buttons; *button != NULL; button++) {
|
||||
cfg = (*button)->pull;
|
||||
cfg = GPIO_HAL_PIN_CFG_EDGE_BOTH | GPIO_HAL_PIN_CFG_INT_ENABLE |
|
||||
(*button)->pull;
|
||||
gpio_hal_arch_pin_set_input((*button)->pin);
|
||||
gpio_hal_arch_pin_cfg_set((*button)->pin, cfg);
|
||||
gpio_hal_arch_interrupt_enable((*button)->pin, GPIO_HAL_PIN_CFG_INT_BOTH);
|
||||
gpio_hal_arch_interrupt_enable((*button)->pin);
|
||||
button_event_handler.pin_mask |= gpio_hal_pin_to_mask((*button)->pin);
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@
|
||||
/**
|
||||
* \brief GPIO pin number representation
|
||||
*/
|
||||
typedef uint_fast8_t gpio_hal_pin_t;
|
||||
typedef uint8_t gpio_hal_pin_t;
|
||||
|
||||
/**
|
||||
* \brief GPIO pin configuration
|
||||
@ -82,7 +82,7 @@ typedef uint_fast8_t gpio_hal_pin_t;
|
||||
* A logical representation of a pin's configuration. It is an OR combination
|
||||
* of GPIO_HAL_PIN_CFG_xyz macros.
|
||||
*/
|
||||
typedef uint_least32_t gpio_hal_pin_cfg_t;
|
||||
typedef uint32_t gpio_hal_pin_cfg_t;
|
||||
|
||||
#ifdef GPIO_HAL_CONF_PIN_COUNT
|
||||
#define GPIO_HAL_PIN_COUNT GPIO_HAL_CONF_PIN_COUNT
|
||||
@ -90,73 +90,34 @@ typedef uint_least32_t gpio_hal_pin_cfg_t;
|
||||
#define GPIO_HAL_PIN_COUNT 32
|
||||
#endif
|
||||
|
||||
#if GPIO_HAL_PIN_COUNT > 32
|
||||
typedef uint64_t gpio_hal_pin_mask_t;
|
||||
#else
|
||||
/**
|
||||
* \brief GPIO pin mask representation
|
||||
*/
|
||||
#if GPIO_HAL_PIN_COUNT > 32
|
||||
typedef uint_least64_t gpio_hal_pin_mask_t;
|
||||
#else
|
||||
typedef uint_least32_t gpio_hal_pin_mask_t;
|
||||
typedef uint32_t gpio_hal_pin_mask_t;
|
||||
#endif
|
||||
|
||||
typedef void (*gpio_hal_callback_t)(gpio_hal_pin_mask_t pin_mask);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Configuration bits
|
||||
* bit 8 -> bit 0 ->
|
||||
* xxxxxxff eedccbba
|
||||
*
|
||||
* Input config:
|
||||
* a - 1 bit - hystersis
|
||||
* b - 2 bits - pulling
|
||||
*
|
||||
* Output config:
|
||||
* c - 2 bits - output buffer
|
||||
* d - 1 bit - slew control
|
||||
* e - 2 bits - drive strength
|
||||
*
|
||||
* Interrupt config:
|
||||
* f - 2 bits - interrupt mode
|
||||
*
|
||||
* Unused config:
|
||||
* x: unused
|
||||
*/
|
||||
#define GPIO_HAL_PIN_CFG_PULL_NONE 0x00
|
||||
#define GPIO_HAL_PIN_CFG_PULL_UP 0x01
|
||||
#define GPIO_HAL_PIN_CFG_PULL_DOWN 0x02
|
||||
#define GPIO_HAL_PIN_CFG_PULL_MASK (GPIO_HAL_PIN_CFG_PULL_UP | \
|
||||
GPIO_HAL_PIN_CFG_PULL_DOWN)
|
||||
|
||||
#define GPIO_HAL_PIN_CFG_INPUT_HYSTERESIS (1 << 0)
|
||||
#define GPIO_HAL_PIN_CFG_INPUT_NOPULL (0 << 1)
|
||||
#define GPIO_HAL_PIN_CFG_INPUT_PULLUP (1 << 1)
|
||||
#define GPIO_HAL_PIN_CFG_INPUT_PULLDOWN (2 << 1)
|
||||
#define GPIO_HAL_PIN_CFG_HYSTERESIS 0x10
|
||||
|
||||
#define GPIO_HAL_PIN_BM_INPUT_HYSTERESIS (0x01 << 0) /**< 0b00000001 */
|
||||
#define GPIO_HAL_PIN_BM_INPUT_PULLING (0x06 << 0) /**< 0b00000110 */
|
||||
#define GPIO_HAL_PIN_BM_INPUT ( GPIO_HAL_PIN_BM_INPUT_HYSTERESIS \
|
||||
| GPIO_HAL_PIN_BM_INPUT_PULLING)
|
||||
#define GPIO_HAL_PIN_CFG_EDGE_NONE 0x00
|
||||
#define GPIO_HAL_PIN_CFG_EDGE_RISING 0x04
|
||||
#define GPIO_HAL_PIN_CFG_EDGE_FALLING 0x08
|
||||
#define GPIO_HAL_PIN_CFG_EDGE_BOTH (GPIO_HAL_PIN_CFG_EDGE_RISING | \
|
||||
GPIO_HAL_PIN_CFG_EDGE_FALLING)
|
||||
|
||||
#define GPIO_HAL_PIN_CFG_OUTPUT_PUSHPULL (0 << 3)
|
||||
#define GPIO_HAL_PIN_CFG_OUTPUT_OPENDRAIN (1 << 3)
|
||||
#define GPIO_HAL_PIN_CFG_OUTPUT_OPENSOURCE (2 << 3)
|
||||
#define GPIO_HAL_PIN_CFG_OUTPUT_SLEWCTRL (1 << 5)
|
||||
#define GPIO_HAL_PIN_CFG_OUTPUT_DRVSTR_MIN (0 << 6)
|
||||
#define GPIO_HAL_PIN_CFG_OUTPUT_DRVSTR_MED (1 << 6)
|
||||
#define GPIO_HAL_PIN_CFG_OUTPUT_DRVSTR_MAX (2 << 6)
|
||||
|
||||
#define GPIO_HAL_PIN_BM_OUTPUT_BUF (0x18 << 0) /**< 0b00011000 */
|
||||
#define GPIO_HAL_PIN_BM_OUTPUT_SLEWCTRL (0x20 << 0) /**< 0b00100000 */
|
||||
#define GPIO_HAL_PIN_BM_OUTPUT_DRVSTR (0xC0 << 0) /**< 0b11000000 */
|
||||
#define GPIO_HAL_PIN_BM_OUTPUT ( GPIO_HAL_PIN_BM_OUTPUT_BUF \
|
||||
| GPIO_HAL_PIN_BM_OUTPUT_SLEWCTRL \
|
||||
| GPIO_HAL_PIN_BM_OUTPUT_DRVSTR)
|
||||
|
||||
#define GPIO_HAL_PIN_CFG_INT_DISABLE (0 << 8)
|
||||
#define GPIO_HAL_PIN_CFG_INT_FALLING (1 << 8)
|
||||
#define GPIO_HAL_PIN_CFG_INT_RISING (2 << 8)
|
||||
#define GPIO_HAL_PIN_CFG_INT_BOTH (3 << 8)
|
||||
|
||||
#define GPIO_HAL_PIN_BM_INT (0x03 << 8) /**< 0b00000011 */
|
||||
|
||||
#define GPIO_HAL_PIN_BM_ALL ( GPIO_HAL_PIN_BM_INPUT \
|
||||
| GPIO_HAL_PIN_BM_OUTPUT \
|
||||
| GPIO_HAL_PIN_BM_INT)
|
||||
#define GPIO_HAL_PIN_CFG_INT_DISABLE 0x00
|
||||
#define GPIO_HAL_PIN_CFG_INT_ENABLE 0x80
|
||||
#define GPIO_HAL_PIN_CFG_INT_MASK 0x80
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/**
|
||||
* \brief Datatype for GPIO event handlers
|
||||
@ -296,7 +257,7 @@ void gpio_hal_arch_init(void);
|
||||
* The implementation can be provided as a global symbol, an inline function
|
||||
* or a function-like macro, as described above.
|
||||
*/
|
||||
void gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg);
|
||||
void gpio_hal_arch_interrupt_enable(gpio_hal_pin_t pin);
|
||||
#endif
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#ifndef gpio_hal_arch_interrupt_disable
|
||||
|
Loading…
Reference in New Issue
Block a user