Skip to content
Snippets Groups Projects
Commit cfed0e33 authored by Hauke Petersen's avatar Hauke Petersen
Browse files

cpu/cc2538: adapted to GPIO inerface changes

parent c36efa0f
No related branches found
No related tags found
No related merge requests found
...@@ -343,13 +343,7 @@ static const uint8_t reverse_pin_lut[] = { ...@@ -343,13 +343,7 @@ static const uint8_t reverse_pin_lut[] = {
#endif #endif
}; };
static const uint32_t ioc_mask_lut[] = { int gpio_init(gpio_t dev, gpio_mode_t mode)
[GPIO_NOPULL ] = IOC_OVERRIDE_DIS,
[GPIO_PULLUP ] = IOC_OVERRIDE_PUE,
[GPIO_PULLDOWN] = IOC_OVERRIDE_PDE,
};
int gpio_init(gpio_t dev, gpio_dir_t dir, gpio_pp_t pushpull)
{ {
int pin; int pin;
...@@ -360,28 +354,42 @@ int gpio_init(gpio_t dev, gpio_dir_t dir, gpio_pp_t pushpull) ...@@ -360,28 +354,42 @@ int gpio_init(gpio_t dev, gpio_dir_t dir, gpio_pp_t pushpull)
pin = pin_lut[dev]; pin = pin_lut[dev];
gpio_software_control(pin); gpio_software_control(pin);
if (dir == GPIO_DIR_OUT) { switch (mode) {
gpio_dir_output(pin); case GPIO_IN:
/* configure the pin's pull resistor state */ gpio_dir_input(pin);
IOC_PXX_OVER[pin] = IOC_OVERRIDE_OE | ioc_mask_lut[pushpull]; /* configure the pin's pull resistor state */
} IOC_PXX_OVER[pin] = (IOC_OVERRIDE_DIS);
else { break;
gpio_dir_input(pin); case GPIO_IN_PD:
/* configure the pin's pull resistor state */ gpio_dir_input(pin);
IOC_PXX_OVER[pin] = ioc_mask_lut[pushpull]; /* configure the pin's pull resistor state */
IOC_PXX_OVER[pin] = (IOC_OVERRIDE_PDE);
break;
case GPIO_IN_PU:
gpio_dir_input(pin);
/* configure the pin's pull resistor state */
IOC_PXX_OVER[pin] = (IOC_OVERRIDE_PUE);
case GPIO_OUT:
gpio_dir_output(pin);
/* configure the pin's pull resistor state */
IOC_PXX_OVER[pin] = (IOC_OVERRIDE_OE | IOC_OVERRIDE_DIS);
break;
default:
return -1;
} }
return 0; return 0;
} }
int gpio_init_int(gpio_t dev, gpio_pp_t pullup, gpio_flank_t flank, gpio_cb_t cb, void *arg) int gpio_init_int(gpio_t dev, gpio_mode_t mode, gpio_flank_t flank,
gpio_cb_t cb, void *arg)
{ {
int res, pin, irq_num; int res, pin, irq_num;
uint32_t mask; uint32_t mask;
cc2538_gpio_t* instance; cc2538_gpio_t* instance;
/* Note: gpio_init() also checks if the gpio is enabled. */ /* Note: gpio_init() also checks if the gpio is enabled. */
res = gpio_init(dev, GPIO_DIR_IN, pullup); res = gpio_init(dev, mode);
if (res < 0) { if (res < 0) {
return res; return res;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment