/*
 * uart.h
 *
 *  Created on: 2020. 8. 3.
 *      Author: parkyj
 */

#ifndef UART_H_
#define UART_H_

#include <stdbool.h>
#include "main.h"
#define hTerminal    huart3
#define hMain    huart1


#define ANSI_COLOR_RED     "\x1b[31m"
#define ANSI_COLOR_GREEN   "\x1b[32m"
#define ANSI_COLOR_YELLOW  "\x1b[33m"
#define ANSI_COLOR_BLUE    "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN    "\x1b[36m"
#define ANSI_COLOR_RESET   "\x1b[0m" "\r\n"    



#define QUEUE_BUFFER_LENGTH 128

typedef struct
{
    int head, tail, data;
    uint8_t Buffer[QUEUE_BUFFER_LENGTH];
}UARTQUEUE, *pUARTQUEUE;
typedef struct  {
   uint8_t buffer[QUEUE_BUFFER_LENGTH];
   volatile uint16_t input_p;
   volatile uint16_t output_p;
} uart_hal_tx_type;

extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart3;


extern UARTQUEUE TerminalQueue;
extern UARTQUEUE MainQueue;

void PutDataToUartQueue(UART_HandleTypeDef *huart, uint8_t data);
void InitUartQueue(pUARTQUEUE pQueue);
void GetDataFromUartQueue(UART_HandleTypeDef *huart);
bool Get_UartRcv(void);
void Set_UartRcv(bool);
void Uart1_Data_Send(uint8_t* data,uint16_t size);
void Uart_Check(void);

#endif /* UART_H_ */
