1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu, cc2538: add gpio alternative functions

This commit is contained in:
smlng 2017-07-17 14:10:19 +02:00
parent 7ea8c7f768
commit 46facf4ff7
3 changed files with 22 additions and 17 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);
}