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

Header file containing various functions for sending, receiving, and initilizing the UART/USART prehiperal. More...

#include "stm32f1xx.h"
#include "ACDC_CLOCK.h"

Go to the source code of this file.

Enumerations

enum  SerialSpeed {
  Serial_1200 = 1200 , Serial_2400 = 2400 , Serial_4800 = 4800 , Serial_9600 = 9600 ,
  Serial_19200 = 19200 , Serial_38400 = 38400 , Serial_57600 = 57600 , Serial_115200 = 115200 ,
  Serial_230400 = 230400
}
 

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

Header file containing various functions for sending, receiving, and initilizing the UART/USART prehiperal.

Author
Devin Marx
Version
0.1
Date
2023-11-8

Enumeration Type Documentation

◆ SerialSpeed

Enumerator
Serial_1200 

Baud rate: 1200 bps

Serial_2400 

Baud rate: 2400 bps

Serial_4800 

Baud rate: 4800 bps

Serial_9600 

Baud rate: 9600 bps

Serial_19200 

Baud rate: 19200 bps

Serial_38400 

Baud rate: 38400 bps

Serial_57600 

Baud rate: 57600 bps

Serial_115200 

Baud rate: 115200 bps

Serial_230400 

Baud rate: 230400 bps

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