GaIA BIOS Library
Loading...
Searching...
No Matches
gpio.h File Reference

The GPIO driver. More...

#include <stdint.h>
#include <stdbool.h>
#include "board.h"

Macros

#define GPIO_PORT_A   (0x00)
#define GPIO_PORT_B   (0x01)
#define GPIO_PORT_C   (0x02)
#define GPIO_PORT_D   (0x03)
#define GPIO_PORT_E   (0x04)
#define GPIO_PORT_F   (0x05)
#define GPIO_PORT_G   (0x06)
#define GPIO_PORT_H   (0x07)
#define GPIO_PIN_MODE_INPUT   0x00000000U
#define GPIO_PIN_MODE_GPOUT   0x00000001U
#define GPIO_PIN_MODE_GPOUT_PP   0x00000001U
#define GPIO_PIN_MODE_GPOUT_OD   0x00000011U
#define GPIO_PIN_MODE_AF   0x00000002U
#define GPIO_PIN_MODE_ANALOG   0x00000003U
#define GPIO_PIN_SPEED_2MHZ   (0x00ul)
#define GPIO_PIN_SPEED_LOW   0x00000000U
#define GPIO_PIN_SPEED_25MHZ   (0x01ul)
#define GPIO_PIN_SPEED_MEDIUM   0x00000001U
#define GPIO_PIN_SPEED_50MHZ   (0x02ul)
#define GPIO_PIN_SPEED_HIGH   0x00000002U
#define GPIO_PIN_SPEED_100MHZ   (0x03ul)
#define GPIO_PIN_SPEED_VERY_HIGH   0x00000003U
#define gpio_pin_init   gpio_set_pin
 Configure a microcontroller pin.

Functions

void gpio_enable_clock (uint8_t port)
 Enable clock for the specified GPIO port.
void gpio_set_pin (GPIO_TypeDef *port, uint32_t pin_number, uint32_t mode, uint32_t speed, uint32_t alternate_function)
 Configure a microcontroller pin.
void gpio_enable_pullup (GPIO_TypeDef *gpio, uint8_t pin_number)
 If a pin is configured in input with pull-up / pull-down mode, this function enable pull-up.
void gpio_set (GPIO_TypeDef *gpio, uint8_t pin_number)
 Set a microcontroller gpio pin.
void gpio_clr (GPIO_TypeDef *gpio, uint8_t pin_number)
 Clear a microcontroller gpio pin.
bool gpio_get_status (GPIO_TypeDef *gpio, uint8_t pin_number)
 Get gpio status.

Detailed Description

The GPIO driver.

Provides functions to initialize the GPIOs and to set/get their values.

Author
Tecnologix, 2014

Macro Definition Documentation

◆ gpio_pin_init

#define gpio_pin_init   gpio_set_pin

Configure a microcontroller pin.

Parameters
portA pointer to GPIO description structure.
pinThe pin number.
modePin mode. It can be one of the following:
  • #GPIO_PIN_MODE_INPUT
  • #GPIO_PIN_MODE_GPOUT
  • #GPIO_PIN_MODE_AF
  • #GPIO_PIN_MODE_ANALOG
speedPin speed. It can be one of the following:
  • #GPIO_PIN_SPEED_LOW
  • #GPIO_PIN_SPEED_MEDIUM
  • #GPIO_PIN_SPEED_HIGH
  • #GPIO_PIN_SPEED_VERY_HIGH
alt_funcPin alternate function selection.

Function Documentation

◆ gpio_clr()

void gpio_clr ( GPIO_TypeDef * gpio,
uint8_t pin_number )

Clear a microcontroller gpio pin.

Parameters
gpioA pointer to GPIO description structure.
pin_numberThe pin number.

◆ gpio_enable_clock()

void gpio_enable_clock ( uint8_t port)

Enable clock for the specified GPIO port.

Parameters
portThe GPIO port.

◆ gpio_enable_pullup()

void gpio_enable_pullup ( GPIO_TypeDef * gpio,
uint8_t pin_number )

If a pin is configured in input with pull-up / pull-down mode, this function enable pull-up.

Parameters
gpioA pointer to GPIO description structure.
pin_numberThe pin number.

◆ gpio_get_status()

bool gpio_get_status ( GPIO_TypeDef * gpio,
uint8_t pin_number )

Get gpio status.

Parameters
gpioA pointer to GPIO description structure.
pin_numberThe pin number.
Returns
true if pin is set to high voltage level, false otherwise.

◆ gpio_set()

void gpio_set ( GPIO_TypeDef * gpio,
uint8_t pin_number )

Set a microcontroller gpio pin.

Parameters
gpioA pointer to GPIO description structure.
pin_numberThe pin number.

◆ gpio_set_pin()

void gpio_set_pin ( GPIO_TypeDef * port,
uint32_t pin_number,
uint32_t mode,
uint32_t speed,
uint32_t alternate_function )

Configure a microcontroller pin.

Parameters
portA pointer to GPIO description structure.
pin_numberThe pin number.
modePin mode. It can be one of the following:
  • GPIO_MODE_INPUT
  • GPIO_MODE_GPOUT
  • GPIO_MODE_AF
  • GPIO_MODE_ANALOG
speedPin speed. It can be one of the following:
  • GPIO_SPEED_2MHZ
  • GPIO_SPEED_25MHZ
  • GPIO_SPEED_50MHZ
  • GPIO_SPEED_100MHZ
alternate_functionPin alternate function selection.