ACDC Senior Project v1.0.0
Senior Project for Textron Aviation
Loading...
Searching...
No Matches
ACDC_GPIO.c File Reference

Implementation of GPIO configuration and manipulation functions. More...

#include "ACDC_GPIO.h"

Macros

#define GPIO_CNF_INPUT_PULLUP_PULLDOWN   0b10u
 
#define GPIO_MODE_CNF   0b1111
 
#define GPIO_MODE_OFFSET   0
 
#define GPIO_CNF_OFFSET   2
 

Functions

void GPIO_PinDirection (GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN, uint8_t GPIO_MODE, uint8_t GPIO_CNF)
 Sets the Direction of the Pin to Input/Output (MODE) and the sets its Configuration (CNF) [CAN ONLY SET ONE PIN AT A TIME].
 
void GPIO_Deinit (GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN)
 Deinitializes GPIO_PIN on GPIOx back to its reset value.
 
void GPIO_Write (GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN, uint16_t GPIO_VALUE)
 Sets the pins output to the value passed into GPIO_VALUE.
 
void GPIO_Set (GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN)
 Sets the pins output to HIGH or 1.
 
void GPIO_Clear (GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN)
 Sets the pins output to LOW or 0.
 
void GPIO_Toggle (GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN)
 Toggles the pins output. From 0 -> 1 or 1 -> 0.
 
uint8_t GPIO_Read (const GPIO_TypeDef *GPIOx, uint16_t GPIO_PIN)
 Returns the current value of GPIO_PIN on GPIOx.
 
uint8_t GPIO_GetPinNumber (uint16_t GPIO_PIN)
 Returns the Pin number of the GPIO_PIN_#.
 

Detailed Description

Implementation of GPIO configuration and manipulation functions.

Author
Devin Marx

This file provides functions for initializing and controlling GPIO pins, including setting pin directions, writing values, and reading pin states.

Version
0.1
Date
2023-10-11

Macro Definition Documentation

◆ GPIO_CNF_INPUT_PULLUP_PULLDOWN

#define GPIO_CNF_INPUT_PULLUP_PULLDOWN   0b10u

Check if the INPUT CNF bit is a pullup or pulldown

◆ GPIO_CNF_OFFSET

#define GPIO_CNF_OFFSET   2

CNF bit offset

◆ GPIO_MODE_CNF

#define GPIO_MODE_CNF   0b1111

Bitmask for the MODE & CNF bits

◆ GPIO_MODE_OFFSET

#define GPIO_MODE_OFFSET   0

MODE bit offset

Function Documentation

◆ GPIO_Clear()

void GPIO_Clear ( GPIO_TypeDef * GPIOx,
uint16_t GPIO_PIN )

Sets the pins output to LOW or 0.

Parameters
GPIOxPort of the GPIO (Ex. GPIOA, GPIOB, ...)
GPIO_PINDesired pin on port GPIOx (Ex. GPIO_PIN_0, GPIO_PIN_1, ...)

◆ GPIO_Deinit()

void GPIO_Deinit ( GPIO_TypeDef * GPIOx,
uint16_t GPIO_PIN )

Deinitializes GPIO_PIN on GPIOx back to its reset value.

Parameters
GPIOxPort of the GPIO (Ex. GPIOA, GPIOB, ...)
GPIO_PINDesired pin on port GPIOx (Ex. GPIO_PIN_0, GPIO_PIN_1, ...)

◆ GPIO_GetPinNumber()

uint8_t GPIO_GetPinNumber ( uint16_t GPIO_PIN)

Returns the Pin number of the GPIO_PIN_#.

Parameters
GPIO_PINDesired pin (Ex. GPIO_PIN_0, GPIO_PIN_1, ...)
Returns
Number of the pin (Ex. GPIO_PIN = GPIO_PIN_13, then 13 is retured)

◆ GPIO_PinDirection()

void GPIO_PinDirection ( GPIO_TypeDef * GPIOx,
uint16_t GPIO_PIN,
uint8_t GPIO_MODE,
uint8_t GPIO_CNF )

Sets the Direction of the Pin to Input/Output (MODE) and the sets its Configuration (CNF) [CAN ONLY SET ONE PIN AT A TIME].

Parameters
GPIOxPort of the GPIO (Ex. GPIOA, GPIOB, ...)
GPIO_PINDesired pin on port GPIOx (Ex. GPIO_PIN_0, GPIO_PIN_1, ...)
GPIO_MODEDesired mode like output 2Mhz, output 10Mhz, output 50Mhz or Input
GPIO_CNFDesired configuration, if output then Push-Pull or Open-Drain, else if input then Analog, Floating, or Pullup/Pulldown

◆ GPIO_Read()

uint8_t GPIO_Read ( const GPIO_TypeDef * GPIOx,
uint16_t GPIO_PIN )

Returns the current value of GPIO_PIN on GPIOx.

Parameters
GPIOxPort of the GPIO (Ex. GPIOA, GPIOB, ...)
GPIO_PINDesired pin on port GPIOx (Ex. GPIO_PIN_0, GPIO_PIN_1, ...)
Returns
>= 1 if Pin is High, else 0

◆ GPIO_Set()

void GPIO_Set ( GPIO_TypeDef * GPIOx,
uint16_t GPIO_PIN )

Sets the pins output to HIGH or 1.

Parameters
GPIOxPort of the GPIO (Ex. GPIOA, GPIOB, ...)
GPIO_PINDesired pin on port GPIOx (Ex. GPIO_PIN_0, GPIO_PIN_1, ...)

◆ GPIO_Toggle()

void GPIO_Toggle ( GPIO_TypeDef * GPIOx,
uint16_t GPIO_PIN )

Toggles the pins output. From 0 -> 1 or 1 -> 0.

Parameters
GPIOxPort of the GPIO (Ex. GPIOA, GPIOB, ...)
GPIO_PINDesired pin on port GPIOx (Ex. GPIO_PIN_0, GPIO_PIN_1, ...)

◆ GPIO_Write()

void GPIO_Write ( GPIO_TypeDef * GPIOx,
uint16_t GPIO_PIN,
uint16_t GPIO_VALUE )

Sets the pins output to the value passed into GPIO_VALUE.

Parameters
GPIOxPort of the GPIO (Ex. GPIOA, GPIOB, ...)
GPIO_PINDesired pin on port GPIOx (Ex. GPIO_PIN_0, GPIO_PIN_1, ...)
GPIO_VALUEValue to set pin to. If >= 1 then 1, else 0