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

Implentation of UART/USART Tx/Rx functions. More...

#include "ACDC_USART.h"
#include "ACDC_GPIO.h"

Functions

void USART_Init (USART_TypeDef *USARTx, SerialSpeed Serial_x, bool useUART)
 Initilizes the USARTx peripheral at the serial speed Serial_x, and the default.
 
void USART_ChangeSerialSpeed (USART_TypeDef *USARTx, SerialSpeed Serial_x)
 Changes the Serial speed of the USART.
 
void USART_SendChar (USART_TypeDef *USARTx, char chr)
 Sends a single character over UART/USART (BLOCKING)
 
void USART_SendString (USART_TypeDef *USARTx, const char *str)
 Sends the string str over UART/USART. (Will automatically append "\r\n" to the transmision (BLOCKING))
 
char USART_RecieveChar (const USART_TypeDef *USARTx)
 Recieves a single character from UART/USART (BLOCKING)
 
void USART_RecieveString (const USART_TypeDef *USARTx, char *buffer, uint16_t bufferLen)
 Recieves a string from UART/USART and stops when "\n\r" is recieved or the buffer is full. (BLOCKING)
 
bool USART_HasDataToRecieve (const USART_TypeDef *USARTx)
 Checks if there is data available in the USART recieve buffer.
 

Detailed Description

Implentation of UART/USART Tx/Rx functions.

Author
Devin Marx
Version
0.2
Date
2024-01-21

Function Documentation

◆ USART_ChangeSerialSpeed()

void USART_ChangeSerialSpeed ( USART_TypeDef * USARTx,
SerialSpeed Serial_x )

Changes the Serial speed of the USART.

Parameters
USARTxUSART Peripheral (Ex. USART1, USART2, ...)
Serial_xTx/Rx speed of the USART peripheral (Ex. Serial_115200, Serial_9600, ...)

◆ USART_HasDataToRecieve()

bool USART_HasDataToRecieve ( const USART_TypeDef * USARTx)

Checks if there is data available in the USART recieve buffer.

Parameters
USARTxUSART Peripheral (Ex. USART1, USART2, ...)
Returns
True if there is data available to recieve, false otherwise.

◆ USART_Init()

void USART_Init ( USART_TypeDef * USARTx,
SerialSpeed Serial_x,
bool useUART )

Initilizes the USARTx peripheral at the serial speed Serial_x, and the default.

Parameters
USARTxUSART Peripheral (Ex. USART1, USART2, ...)
Serial_xTx/Rx speed of the USART peripheral (Ex. Serial_115200, Serial_9600, ...)
SystemClockSpeedtrue if you want UART, false if you want USART

◆ USART_RecieveChar()

char USART_RecieveChar ( const USART_TypeDef * USARTx)

Recieves a single character from UART/USART (BLOCKING)

Parameters
USARTxUSART Peripheral (Ex. USART1, USART2, ...)
Returns
Character recieved over UART/USART

◆ USART_RecieveString()

void USART_RecieveString ( const USART_TypeDef * USARTx,
char * buffer,
uint16_t bufferLen )

Recieves a string from UART/USART and stops when "\n\r" is recieved or the buffer is full. (BLOCKING)

Parameters
USARTxUSART Peripheral (Ex. USART1, USART2, ...)
bufferBuffer to store the recieved string
bufferLenMaximum length of the buffer

◆ USART_SendChar()

void USART_SendChar ( USART_TypeDef * USARTx,
char chr )

Sends a single character over UART/USART (BLOCKING)

Parameters
USARTxUSART Peripheral (Ex. USART1, USART2, ...)
chrSignular character to send over UART/USART

◆ USART_SendString()

void USART_SendString ( USART_TypeDef * USARTx,
const char * str )

Sends the string str over UART/USART. (Will automatically append "\r\n" to the transmision (BLOCKING))

Parameters
USARTxUSART Peripheral (Ex. USART1, USART2, ...)
strString to send over UART/USART