You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
KED/bsl/csl/interfaces/usart.h

112 lines
3.0 KiB

/**
**************************************************************************************************
* @file usart.h
* @author Kerem Yollu & Edwin Koch
* @date 02.11.2021
* @version 1.0
**************************************************************************************************
* @brief USART functionalities description and implementation template
*
* **Detailed Description :**
*
* This header file for pin control is based on the most common configuation options
* curenty awailable for modern hardware.
* Depending of the used Chip, some function may vary or be unawailable.
* Please take a minute to go and explore the according Chips pin.c file to see woh each function
* is implmented.
*
* @todo
* - 03.11.2021 : MAybe find a way to link the awalabe uart channnels with the awailable pins for that USART channel
**************************************************************************************************
*/
#ifndef _USART_H_
#define _USART_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "pin.h"
#include "../stm32f042/Drivers/CMSIS/Device/ST/STM32F0xx/Include/stm32f042x6.h"
/*! Enum of USART Word Lenght Options */
typedef enum
{
seven, /*!< 7 bits word Lenght */
eight, /*!< 8 bits word Lenght */
nine /*!< 9 bits word Lenght */
}usartWordLength_t;
/*! Enum of USART Word Lenght Options */
typedef enum
{
usart1 = USART1_BASE , /*!< USART Channel 1 */
usart2 = USART2_BASE /*!< USART Channel 2 */
}usartNo_t;
typedef enum
{
even,
odd
}usartParity_t;
/**
* \brief Enable the USART with the most commment settings
* \param usartNo_t channel Uart **Channel** to be used
* \param pinNo_t pinTx Pin to be used for **Transmit**
* \param pinNo_t pinRx Pin to be used for **Recieve**
* \retval none
*/
void usartInit( usartNo_t channel,
pinNo_t pinTx,
pinNo_t pinRx,
uint32_t baud,
usartWordLength_t lenght,
uint8_t parity,
uint8_t hwFlowControl);
/**
* \brief Enable the USART Transmission pin, be carefull this function will not link the right pin to the right UART channel.
* \param pinNo_t pinTx Pin to be used for **Transmit**
* \retval none
*/
void usartInitTx(pinNo_t pinTx);
/**
* \brief Enable the USART Recieve pin, be carefull this function will not link the right pin to the right UART channel.
* \param pinNo_t pinRx Pin to be used for **Transmit**
* \retval none
*/
void usartInitRx(pinNo_t pinRx);
/**
* \brief Sets the word lenght of the Usart channel.
* \param usartNo_t channel,
* \param usartWordLength_t lenght
* \retval none
*/
void usartSetWordLenght(usartNo_t channel, usartWordLength_t lenght);
/**
* \brief Sets the Baud Rate of the Usart channel.
* \param uint32_t baud
* \retval none
*/
void usartSetBaudRate(usartNo_t channel, uint32_t baud);
/**
* \brief Sets the word lenght of the Usart channel.
* \param * USART_TypeDef usart
* \retval none
*/
void usartSendChar(int ch);
void print_Usart(char *ptr);
#ifdef __cplusplus
}
#endif
#endif // _USART_H_