Loading...
Searching...
No Matches
gpio_mux.h File Reference

Common Pin MUX functions. More...

Detailed Description

Common Pin MUX functions.

The pins in this CPU are multiplexed to several different function. This module allows to configure the pin multiplexer (MUX) from peripheral drivers.

Author
iosabi iosab.nosp@m.i@pr.nosp@m.otonm.nosp@m.ail..nosp@m.com

Definition in file gpio_mux.h.

#include <stdint.h>
#include "periph_cpu.h"
+ Include dependency graph for gpio_mux.h:

Go to the source code of this file.

#define GPIO_T_ADDR_BASE(pin)   (GPIOA_BASE + ((pin) & 0xf000u))
 Obtain the GPIO_BASE address from a GPIO_PIN(x, y) value.
 
#define GPIO_T_ADDR(pin)   ((GPIO_Type *)(GPIO_T_ADDR_BASE(pin)))
 Obtain the GPIO_BASE GPIO_Type* pointer from a GPIO_PIN(x, y) value.
 
#define GPIO_T_PORT(pin)   ((gpio_t)(pin) >> 12u)
 Obtain the "x" port number (0 based) from a GPIO_PIN(x, y) value.
 
#define GPIO_T_PIN(pin)   ((pin) & 0x00ffu)
 Obtain the pin number "y" from a GPIO_PIN(x, y) value.
 
#define GPIO_T_IS_HWCS(pin)   (((pin) & 0xff00u) == 0x8000)
 Return whether the given pin is a CSHW pin.
 
#define GPIO_T_HWCS(pin)   ((pin) & 0x0003u)
 Return the given CSHW number from the gpio_t pin.
 
void gpio_init_mux (gpio_t pin, uint32_t func)
 Configure the pin mux to the given function.
 

Macro Definition Documentation

◆ GPIO_T_ADDR

#define GPIO_T_ADDR (   pin)    ((GPIO_Type *)(GPIO_T_ADDR_BASE(pin)))

Obtain the GPIO_BASE GPIO_Type* pointer from a GPIO_PIN(x, y) value.

Definition at line 41 of file gpio_mux.h.

◆ GPIO_T_ADDR_BASE

#define GPIO_T_ADDR_BASE (   pin)    (GPIOA_BASE + ((pin) & 0xf000u))

Obtain the GPIO_BASE address from a GPIO_PIN(x, y) value.

Definition at line 36 of file gpio_mux.h.

◆ GPIO_T_HWCS

#define GPIO_T_HWCS (   pin)    ((pin) & 0x0003u)

Return the given CSHW number from the gpio_t pin.

Definition at line 67 of file gpio_mux.h.

◆ GPIO_T_IS_HWCS

#define GPIO_T_IS_HWCS (   pin)    (((pin) & 0xff00u) == 0x8000)

Return whether the given pin is a CSHW pin.

Definition at line 62 of file gpio_mux.h.

◆ GPIO_T_PIN

#define GPIO_T_PIN (   pin)    ((pin) & 0x00ffu)

Obtain the pin number "y" from a GPIO_PIN(x, y) value.

Definition at line 53 of file gpio_mux.h.

◆ GPIO_T_PORT

#define GPIO_T_PORT (   pin)    ((gpio_t)(pin) >> 12u)

Obtain the "x" port number (0 based) from a GPIO_PIN(x, y) value.

This macro needs to be kept in sync with the definition of GPIO_PIN.

Definition at line 48 of file gpio_mux.h.

Function Documentation

◆ gpio_init_mux()

void gpio_init_mux ( gpio_t  pin,
uint32_t  func 
)

Configure the pin mux to the given function.

The meaning of the function value will depend on the gpio pin.