cpu/sam3: add gpio_init_mux() function
This commit is contained in:
parent
9b312a8aae
commit
38c7d11f8c
@ -149,6 +149,14 @@ typedef struct {
|
|||||||
uint8_t irqn; /**< interrupt number of the device */
|
uint8_t irqn; /**< interrupt number of the device */
|
||||||
} uart_conf_t;
|
} uart_conf_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure the given GPIO pin to be used with the given MUX setting
|
||||||
|
*
|
||||||
|
* @param[in] pin GPIO pin to configure
|
||||||
|
* @param[in] mux MUX setting to use
|
||||||
|
*/
|
||||||
|
void gpio_init_mux(gpio_t pin, gpio_mux_t mux);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -242,6 +242,17 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gpio_init_mux(gpio_t pin, gpio_mux_t mux)
|
||||||
|
{
|
||||||
|
/* power on the corresponding port */
|
||||||
|
PMC->PMC_PCER0 = (1 << (_port_num(pin) + 11));
|
||||||
|
/* give peripheral control over the pin */
|
||||||
|
_port(pin)->PIO_PDR = (1 << _pin_num(pin));
|
||||||
|
/* and configure the MUX */
|
||||||
|
_port(pin)->PIO_ABSR &= ~(1 << _pin_num(pin));
|
||||||
|
_port(pin)->PIO_ABSR |= (mux << _pin_num(pin));
|
||||||
|
}
|
||||||
|
|
||||||
void gpio_irq_enable(gpio_t pin)
|
void gpio_irq_enable(gpio_t pin)
|
||||||
{
|
{
|
||||||
NVIC_EnableIRQ((1 << (_port_num(pin) + PIOA_IRQn)));
|
NVIC_EnableIRQ((1 << (_port_num(pin) + PIOA_IRQn)));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user