HW_UART_ATY.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * @file HW_UART_ATY.h
  3. *
  4. * @param Project DEVICE_GENERAL_ATY_LIB
  5. *
  6. * @author ATY
  7. *
  8. * @copyright
  9. * - Copyright 2017 - 2023 MZ-ATY
  10. * - This code follows:
  11. * - MZ-ATY Various Contents Joint Statement -
  12. * <a href="https://mengze.top/MZ-ATY_VCJS">
  13. * https://mengze.top/MZ-ATY_VCJS</a>
  14. * - CC 4.0 BY-NC-SA -
  15. * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  16. * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
  17. * - Your use will be deemed to have accepted the terms of this statement.
  18. *
  19. * @brief Familiar functions of uart for STC51
  20. *
  21. * @version
  22. * - 1_01_221231 > ATY
  23. * -# Preliminary version, first Release
  24. * - 1_02_240410 > ATY
  25. * -# add multy addr and channel
  26. * -# add lock
  27. * -# 1ms with 2 channel at the same time tested good(OK?)
  28. ********************************************************************************
  29. */
  30. #ifndef __HW_UART_ATY_H
  31. #define __HW_UART_ATY_H
  32. #include "INCLUDE_ATY.h"
  33. /******************************* For user *************************************/
  34. // #define UART_RX_MAX_LEN (9 + (15 * 4))
  35. // #define UART_RX_MAX_LEN (16)
  36. #ifndef UART_RX_MAX_LEN
  37. #define UART_RX_MAX_LEN (254)
  38. #endif
  39. /******************************************************************************/
  40. struct HW_UART_ATY_Dev
  41. {
  42. // uint8_t* rx;
  43. uint8_t rx[UART_RX_MAX_LEN];
  44. uint8_t* tx;
  45. uint8_t rxCount;
  46. uint8_t txCount;
  47. uint32_t rcvOverTimeOutCountNum;
  48. uint32_t rcvOverTimeOutCount;
  49. uint8_t rcvOverFlag;
  50. uint8_t uartInitFlag;
  51. void (*uartInit)(uint8_t* rx);
  52. void (*uartSendByte)(uint8_t byte);
  53. /**
  54. * @brief uart receive data analysis in user define self
  55. */
  56. void (*uartReceiveProcess_User)();
  57. uint8_t lock;
  58. uint8_t debugEnable;
  59. void (*LOG)(const char*, ...);
  60. };
  61. uint8_t UartSendByte(uint8_t byte, struct HW_UART_ATY_Dev* dev);
  62. void UartRxClear(struct HW_UART_ATY_Dev* dev);
  63. void UartSendBytes(uint8_t* bytes, uint16_t len, struct HW_UART_ATY_Dev* dev);
  64. void UartSendStr(uint8_t* buf, struct HW_UART_ATY_Dev* dev);
  65. void UartSendFloat(float dataFloat, uint8_t endian, struct HW_UART_ATY_Dev* dev);
  66. void UartSendFloatStr(float dataFloat, uint8_t DECIMALS_NUM, struct HW_UART_ATY_Dev* dev);
  67. void UartReceiveProcess(struct HW_UART_ATY_Dev* dev);
  68. #include "stdio.h" // for printf
  69. // #include "stdlib.h"
  70. // #include "string.h"
  71. #endif /* __HW_UART_ATY_H */
  72. /******************************** End Of File *********************************/