HomeAut
usart.h
1 /*
2  * usart.h
3  *
4  * Author: Vizi Gábor
5  * E-mail: vizi.gabor90@gmail.com
6  * Function: usart communication
7  * Target: STM32Fx
8  * Version: v4
9  * Last modified: 2016.09.28
10  */
11 
12 #ifndef USART_H_
13 #define USART_H_
14 
15 
16 /*------------------------------------------------------------------------------
17  * Includes
18  *----------------------------------------------------------------------------*/
19 
20 #include "include.h"
21 
22 
23 /*------------------------------------------------------------------------------
24  * Macros & definitions
25  *----------------------------------------------------------------------------*/
26 
27 // Size of Transmission buffer
28 #define TXBUFFERSIZE 256UL
29 // Size of Reception buffer
30 #define RXBUFFERSIZE 256UL
31 #define RXBUFFER_WAIT_LENGTH 1
32 
33 
34 
35 /*------------------------------------------------------------------------------
36  * Type definitions
37  *----------------------------------------------------------------------------*/
38 
39 
40 
41 /*------------------------------------------------------------------------------
42  * Global variables
43  *----------------------------------------------------------------------------*/
44 
45 #ifdef CONFIG_MODULE_DEBUGUSART_ENABLE
46 extern UART_HandleTypeDef Debug_UartHandle;
47 #endif
48 #ifdef CONFIG_MODULE_ESP8266_ENABLE
49 extern UART_HandleTypeDef ESP8266_UartHandle;
50 #endif
51 
52 extern volatile char USART_RxBuffer[RXBUFFERSIZE];
53 extern volatile char USART_TxBuffer[TXBUFFERSIZE];
54 
55 extern volatile uint8_t USART_RxBufferWriteCounter;
56 
57 
58 
59 /*------------------------------------------------------------------------------
60  * Global function declarations
61  *----------------------------------------------------------------------------*/
62 void USART_Init(UART_HandleTypeDef *UartHandle);
63 
64 void USART_StartReceiveMessage(void);
65 
66 bool USART_SendChar(char c);
67 uint8_t USART_SendMessage(const char *aTxBuffer);
68 bool USART_SendNewLine(void);
69 bool USART_SendLine(const char *message);
70 void USART_SendFloat(float value);
71 
72 
73 
74 #endif /* USART_H_ */