HW_UART_ATY.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifndef UART_RX_MAX_LEN
  36. #define UART_RX_MAX_LEN (254)
  37. #endif
  38. /******************************************************************************/
  39. struct HW_UART_ATY_Dev
  40. {
  41. // uint8_t* rx;
  42. uint8_t rx[UART_RX_MAX_LEN];
  43. uint8_t* tx;
  44. uint8_t rxCount;
  45. uint8_t txCount;
  46. uint32_t rcvOverTimeOutCountNum;
  47. uint32_t rcvOverTimeOutCount;
  48. uint8_t rcvOverFlag;
  49. uint8_t uartInitFlag;
  50. void (*uartInit)(uint8_t* rx);
  51. void (*uartSendByte)(uint8_t byte);
  52. /**
  53. * @brief uart receive data analysis in user define self
  54. */
  55. void (*uartReceiveProcess_User)();
  56. uint8_t lock;
  57. uint8_t debugEnable;
  58. void (*LOG)();
  59. };
  60. uint8_t UartSendByte(uint8_t byte, struct HW_UART_ATY_Dev* dev);
  61. void UartSendBytes(uint8_t* bytes, uint16_t len, struct HW_UART_ATY_Dev* dev);
  62. void UartSendStr(uint8_t* buf, struct HW_UART_ATY_Dev* dev);
  63. void UartSendFloat(float dataFloat, uint8_t endian, struct HW_UART_ATY_Dev* dev);
  64. void UartSendFloatStr(float dataFloat, uint8_t DECIMALS_NUM, struct HW_UART_ATY_Dev* dev);
  65. void UartReceiveProcess(struct HW_UART_ATY_Dev* dev);
  66. #include "stdio.h" // for printf
  67. // #include "stdlib.h"
  68. // #include "string.h"
  69. #endif /* __HW_UART_ATY_H */
  70. /******************************** End Of File *********************************/