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

GPIO CPU definitions for the STM32 family. More...

Detailed Description

GPIO CPU definitions for the STM32 family.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de
Vincent Dupont vince.nosp@m.nt@o.nosp@m.takey.nosp@m.s.co.nosp@m.m

Definition in file cpu_gpio.h.

#include <stdint.h>
#include "cpu.h"
+ Include dependency graph for cpu_gpio.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define GPIO_UNDEF   (0xffffffff)
 Definition of a fitting UNDEF value.
 
#define GPIO_PIN(x, y)   ((GPIOA_BASE + (x << 10)) | y)
 Define a CPU specific GPIO pin generator macro.
 
#define GPIO_MODE(io, pr, ot)   ((io << 0) | (pr << 2) | (ot << 4))
 Generate GPIO mode bitfields.
 
enum  
 Available GPIO ports. More...
 
enum  gpio_af_t {
  GPIO_AF0 = 0 , GPIO_AF1 , GPIO_AF2 , GPIO_AF3 ,
  GPIO_AF4 , GPIO_AF5 , GPIO_AF6 , GPIO_AF7 ,
  GPIO_AF8 , GPIO_AF9 , GPIO_AF10 , GPIO_AF11 ,
  GPIO_AF12 , GPIO_AF13 , GPIO_AF14 , GPIO_AF15 ,
  GPIO_AF_UNDEF
}
 Available MUX values for configuring a pin's alternate function. More...
 
void gpio_init_af (gpio_t pin, gpio_af_t af)
 Configure the alternate function for the given pin.
 
void gpio_init_analog (gpio_t pin)
 Configure the given pin to be used as ADC input.
 

Macro Definition Documentation

◆ GPIO_MODE

#define GPIO_MODE (   io,
  pr,
  ot 
)    ((io << 0) | (pr << 2) | (ot << 4))

Generate GPIO mode bitfields.

We use 5 bit to encode the mode:

  • bit 0+1: pin mode (input / output)
  • bit 2+3: pull resistor configuration
  • bit 4: output type (0: push-pull, 1: open-drain)

Definition at line 176 of file cpu_gpio.h.

◆ GPIO_PIN

#define GPIO_PIN (   x,
 
)    ((GPIOA_BASE + (x << 10)) | y)

Define a CPU specific GPIO pin generator macro.

Definition at line 52 of file cpu_gpio.h.

◆ GPIO_UNDEF

#define GPIO_UNDEF   (0xffffffff)

Definition of a fitting UNDEF value.

Definition at line 44 of file cpu_gpio.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Available GPIO ports.

Definition at line 58 of file cpu_gpio.h.

◆ gpio_af_t

enum gpio_af_t

Available MUX values for configuring a pin's alternate function.

Enumerator
GPIO_AF0 

use alternate function 0

GPIO_AF1 

use alternate function 1

GPIO_AF2 

use alternate function 2

GPIO_AF3 

use alternate function 3

GPIO_AF4 

use alternate function 4

GPIO_AF5 

use alternate function 5

GPIO_AF6 

use alternate function 6

GPIO_AF7 

use alternate function 7

GPIO_AF8 

use alternate function 8

GPIO_AF9 

use alternate function 9

GPIO_AF10 

use alternate function 10

GPIO_AF11 

use alternate function 11

GPIO_AF12 

use alternate function 12

GPIO_AF13 

use alternate function 13

GPIO_AF14 

use alternate function 14

GPIO_AF15 

use alternate function 15

GPIO_AF_UNDEF 

an UNDEF value definition, e.g.

for register based spi

Definition at line 97 of file cpu_gpio.h.

Function Documentation

◆ gpio_init_af()

void gpio_init_af ( gpio_t  pin,
gpio_af_t  af 
)

Configure the alternate function for the given pin.

Parameters
[in]pinpin to configure
[in]afalternate function to use

◆ gpio_init_analog()

void gpio_init_analog ( gpio_t  pin)

Configure the given pin to be used as ADC input.

Parameters
[in]pinpin to configure