/**
* @file HW_UART_ATY.h
*
* @param Project DEVICE_GENERAL_ATY_LIB
*
* @author ATY
*
* @copyright
* - Copyright 2017 - 2023 MZ-ATY
* - This code follows:
* - MZ-ATY Various Contents Joint Statement -
*
* https://mengze.top/MZ-ATY_VCJS
* - CC 4.0 BY-NC-SA -
*
* https://creativecommons.org/licenses/by-nc-sa/4.0/
* - Your use will be deemed to have accepted the terms of this statement.
*
* @brief Familiar functions of uart for STC51
*
* @version
* - 1_01_221231 > ATY
* -# Preliminary version, first Release
* - 1_02_240410 > ATY
* -# add multy addr and channel
* -# add lock
* -# 1ms with 2 channel at the same time tested good(OK?)
********************************************************************************
*/
#ifndef __HW_UART_ATY_H
#define __HW_UART_ATY_H
#include "INCLUDE_ATY.h"
/******************************* For user *************************************/
// #define UART_RX_MAX_LEN (9 + (15 * 4))
// #define UART_RX_MAX_LEN (16)
#ifndef UART_RX_MAX_LEN
#define UART_RX_MAX_LEN (254)
#endif
/******************************************************************************/
struct HW_UART_ATY_Dev
{
// uint8_t* rx;
uint8_t rx[UART_RX_MAX_LEN];
uint8_t* tx;
uint8_t rxCount;
uint8_t txCount;
uint32_t rcvOverTimeOutCountNum;
uint32_t rcvOverTimeOutCount;
uint8_t rcvOverFlag;
uint8_t uartInitFlag;
void (*uartInit)(uint8_t* rx);
void (*uartSendByte)(uint8_t byte);
/**
* @brief uart receive data analysis in user define self
*/
void (*uartReceiveProcess_User)();
uint8_t lock;
uint8_t debugEnable;
void (*LOG)(const char*, ...);
};
uint8_t UartSendByte(uint8_t byte, struct HW_UART_ATY_Dev* dev);
void UartRxClear(struct HW_UART_ATY_Dev* dev);
void UartSendBytes(uint8_t* bytes, uint16_t len, struct HW_UART_ATY_Dev* dev);
void UartSendStr(uint8_t* buf, struct HW_UART_ATY_Dev* dev);
void UartSendFloat(float dataFloat, uint8_t endian, struct HW_UART_ATY_Dev* dev);
void UartSendFloatStr(float dataFloat, uint8_t DECIMALS_NUM, struct HW_UART_ATY_Dev* dev);
void UartReceiveProcess(struct HW_UART_ATY_Dev* dev);
#include "stdio.h" // for printf
// #include "stdlib.h"
// #include "string.h"
#endif /* __HW_UART_ATY_H */
/******************************** End Of File *********************************/