diff --git a/boards/remote-pa/board.c b/boards/remote-pa/board.c index cf9e638676..382172a921 100644 --- a/boards/remote-pa/board.c +++ b/boards/remote-pa/board.c @@ -60,7 +60,7 @@ static void rf_switch_init(void) RF_SWITCH_PORT->DIR |= (1 << RF_SWITCH_PIN); /* configure io-mux for used pins */ - IOC->OVER[RF_SWITCH_PIN] = IOC_OVERRIDE_OE; + IOC_PXX_OVER[RF_SWITCH_PIN] = IOC_OVERRIDE_OE; /* Set to default */ RF_SWITCH_INTERNAL; diff --git a/cpu/cc2538/include/periph_cpu.h b/cpu/cc2538/include/periph_cpu.h index 83d7877c17..3307fcbe97 100644 --- a/cpu/cc2538/include/periph_cpu.h +++ b/cpu/cc2538/include/periph_cpu.h @@ -127,24 +127,13 @@ static inline uint8_t gpio_pp_num(gpio_t pin) } /** - * @brief Helper function to enable gpio hardware control + * @brief Configure an alternate function for the given pin * * @param[in] pin gpio pin + * @param[in] sel Setting for IOC select register, (-1) to ignore + * @param[in] over Setting for IOC override register, (-1) to ignore */ -static inline void gpio_hw_ctrl(gpio_t pin) -{ - gpio(pin)->AFSEL |= gpio_pin_mask(pin); -} - -/** - * @brief Helper function to enable gpio software control - * - * @param[in] pin gpio pin - */ -static inline void gpio_sw_ctrl(gpio_t pin) -{ - gpio(pin)->AFSEL &= ~gpio_pin_mask(pin); -} +void gpio_init_af(gpio_t pin, int sel, int over); /** * @brief Define a custom GPIO_UNDEF value diff --git a/cpu/cc2538/periph/gpio.c b/cpu/cc2538/periph/gpio.c index ab05014d5c..d3bb64440c 100644 --- a/cpu/cc2538/periph/gpio.c +++ b/cpu/cc2538/periph/gpio.c @@ -46,7 +46,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) gpio(pin)->IE &= ~gpio_pin_mask(pin); gpio(pin)->AFSEL &= ~gpio_pin_mask(pin); /* configure pull configuration */ - IOC->OVER[gpio_pp_num(pin)] = mode; + IOC_PXX_OVER[gpio_pp_num(pin)] = mode; /* set pin direction */ if (mode == IOC_OVERRIDE_OE) { @@ -184,3 +184,19 @@ void isr_gpiod(void) { handle_isr(GPIO_D, 3); } + +/* CC2538 specific add-on GPIO functions */ + +void gpio_init_af(gpio_t pin, int sel, int over) +{ + assert(pin != GPIO_UNDEF); + + if (over >= 0) { + IOC_PXX_OVER[gpio_pp_num(pin)] = over; + } + if(sel >= 0) { + IOC_PXX_SEL[gpio_pp_num(pin)] = sel; + } + /* enable alternative function mode */ + gpio(pin)->AFSEL |= gpio_pin_mask(pin); +}