microHAL
An abstraction layer for your future F4xx projects
Loading...
Searching...
No Matches
gpio.h File Reference

Function prototypes for the GPIO driver. More...

#include <stdint.h>
#include "stm32f4xx.h"
#include "defines.h"

Go to the source code of this file.

Data Structures

struct  GPIORegs
 Contains GPIO registers. More...
 

Macros

#define GPIO(bank)
 

Typedefs

typedef enum gp_bank gp_bank_t
 Available GPIO peripherals.
 
typedef enum gp_dir gp_dir_t
 Available GPIO modes.
 
typedef enum gp_otype gp_otype_t
 Available GPIO output types.
 
typedef enum gp_speed gp_speed_t
 Available GPIO output speeds.
 
typedef enum gp_pupd gp_pupd_t
 Available GPIO pull states.
 

Enumerations

enum  gp_bank { GP_BANK_LEN }
 Available GPIO peripherals.
 
enum  gp_dir { GP_DIR_IN = 0x00 , GP_DIR_OU = 0x01 , GP_DIR_AL = 0x02 , GP_DIR_AN = 0x03 }
 Available GPIO modes.
 
enum  gp_otype { GP_OTYPE_PP = 0x00 , GP_OTYPE_OD = 0x01 }
 Available GPIO output types.
 
enum  gp_speed { GP_SPEED_LOW = 0x00 , GP_SPEED_MED = 0x01 , GP_SPEED_FAS = 0x02 , GP_SPEED_HIG = 0x03 }
 Available GPIO output speeds.
 
enum  gp_pupd { GP_PUPD_NONE = 0x00 , GP_PUPD_PLUP = 0x01 , GP_PUPD_PLDO = 0x02 }
 Available GPIO pull states.
 

Functions

void gp_set_direction (const gp_bank_t bank, const uint8_t pin, const gp_dir_t dir)
 Sets the GPIO pin to the desired mode.
 
void gp_set_output_type (const gp_bank_t bank, const uint8_t pin, const gp_otype_t type)
 Sets the GPIO output pin to the desired type.
 
void gp_set_speed (const gp_bank_t bank, const uint8_t pin, const gp_speed_t speed)
 Sets the GPIO output pin to the desired speed.
 
void gp_set_pupd (const gp_bank_t bank, const uint8_t pin, const gp_pupd_t poopdr)
 Sets the GPIO input pin to the desired state.
 
void gp_set_val (const gp_bank_t bank, const uint8_t pin, const _Bool value)
 Sets the GPIO output pin to the desired value.
 
uint8_t gp_read_val (const gp_bank_t bank, const uint8_t pin)
 Reads the GPIO input pin value.
 
void gp_set_af (const gp_bank_t bank, const uint8_t pin, const uint8_t af)
 Sets the alternate function of the GPIO pin.
 

Detailed Description

Function prototypes for the GPIO driver.

This file contains all of the enums, macros, and function prototypes required for a functional GPIO driver.

Author
Vasileios Ch. (BillisC)
Bug
None, yet.

Macro Definition Documentation

◆ GPIO

#define GPIO ( bank)
Value:
(struct GPIORegs *)(GPIOA_BASE + (0x400U * ((uint8_t)bank - (uint8_t)'A')))
Contains GPIO registers.
Definition gpio.h:24

Function Documentation

◆ gp_read_val()

uint8_t gp_read_val ( const gp_bank_t bank,
const uint8_t pin )

Reads the GPIO input pin value.

Parameters
bankThe GPIO bank
pinThe GPIO pin
Returns
The current state of the pin

◆ gp_set_af()

void gp_set_af ( const gp_bank_t bank,
const uint8_t pin,
const uint8_t af )

Sets the alternate function of the GPIO pin.

Parameters
bankThe GPIO bank
pinThe GPIO pin
Thealternate function number
Returns
None

◆ gp_set_direction()

void gp_set_direction ( const gp_bank_t bank,
const uint8_t pin,
const gp_dir_t dir )

Sets the GPIO pin to the desired mode.

The available directions for the GPIO pins are specified in the gp_dir_t enum. Any other value will be ignored.

Parameters
bankThe GPIO bank
pinThe GPIO pin
dirThe pin mode
Returns
None

◆ gp_set_output_type()

void gp_set_output_type ( const gp_bank_t bank,
const uint8_t pin,
const gp_otype_t type )

Sets the GPIO output pin to the desired type.

The available output types for the GPIO pins are specified in the gp_otype_t enum. Any other value will be ignored.

Parameters
bankThe GPIO bank
pinThe GPIO pin
typeThe pin type
Returns
None

◆ gp_set_pupd()

void gp_set_pupd ( const gp_bank_t bank,
const uint8_t pin,
const gp_pupd_t poopdr )

Sets the GPIO input pin to the desired state.

The available pull-up/pull-down states for the GPIO pins are specified in the gp_pupdr_t enum. Any other value will be ignored.

Parameters
bankThe GPIO bank
pinThe GPIO pin
poopdrThe pin state
Returns
None

◆ gp_set_speed()

void gp_set_speed ( const gp_bank_t bank,
const uint8_t pin,
const gp_speed_t speed )

Sets the GPIO output pin to the desired speed.

The available speeds for the GPIO output pins are specified in the gp_speed_t enum. Any other value will be ignored.

Parameters
bankThe GPIO bank
pinThe GPIO pin
speedThe pin speed
Returns
None

◆ gp_set_val()

void gp_set_val ( const gp_bank_t bank,
const uint8_t pin,
const _Bool value )

Sets the GPIO output pin to the desired value.

Allowed values are either TRUE(1) or FALSE(0). Any other value will be ignored.

Parameters
bankThe GPIO bank
pinThe GPIO pin
valueThe pin value
Returns
None