hal_uart.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __hal_uart_H__
  2. #define __hal_uart_H__
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <string.h>
  6. #include "sdk_common.h"
  7. #include "SEGGER_RTT.h"
  8. #include "usr_config.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #ifdef __cplusplus
  13. }
  14. #endif
  15. typedef enum {
  16. UART0_T_HEART = 0,
  17. UART0_T_MOTION, //动作
  18. UART0_T_UPDATA, //数据更新
  19. UART0_T_PLAY, //比率设置
  20. UART0_T_SPEED, //速度设置
  21. UART0_T_RULE_ASK, //规则设置申请
  22. UART0_T_VOL_ASK, //声音设置申请
  23. UART0_T_PLAY_ASK, //比率设置申请
  24. UART0_T_SPEED_ASK, //速度设置申请
  25. UART0_T_BILL_ALL_ASK, //总帐申请
  26. UART0_T_BILL_PLAYER_ASK, //玩家帐目申请
  27. UART0_T_BILL_CLEAR, //清除所有玩家帐目
  28. UART0_T_RECOVER, //恢复出厂设置
  29. UART0_NUM_OF_T,
  30. }UART0_T_n;
  31. typedef enum {
  32. UART0_R_HEART = 0,
  33. UART0_R_RULE, //规则设置
  34. UART0_R_VOL, //声音设置
  35. UART0_R_PLAY, //比率设置
  36. UART0_R_SPEED, //速度设置
  37. UART0_R_BILL_ALL, //总帐
  38. UART0_R_BILL_PLAYER, //玩家帐目
  39. UART0_NUM_OF_R,
  40. }UART0_R_n;
  41. typedef void (*UART0_Callback)(void*);
  42. typedef struct _UART0_Rx{
  43. uint8_t cmd;
  44. uint8_t* pDat;
  45. uint8_t datLen;
  46. UART0_Callback cb;
  47. }UART0_Rx_t;
  48. typedef struct _UART0_Tx{
  49. uint8_t cmd;
  50. uint8_t* pDat;
  51. uint8_t datLen;
  52. uint8_t nTimes;
  53. uint32_t periodTime;
  54. uint32_t periodTimecnt;
  55. uint32_t waitTime;
  56. UART0_Callback cb;
  57. }UART0_Tx_t;
  58. void UART0_Initialize(void);
  59. void UART0_Send(unsigned char cmd,unsigned char *pDat,unsigned char datLen);
  60. int UART0_Tx_Send(unsigned char cmd,unsigned char *pDat,unsigned char datLen,uint8_t nTimes,uint32_t periodTime,uint32_t afterTime,uint32_t waitTime);
  61. int UART0_Rx_Regist(unsigned char cmd,UART0_Callback cb);
  62. int UART0_Tx_Regist(unsigned char cmd,UART0_Callback timeout_cb);
  63. void UART0_Tx_Clear(unsigned char cmd);
  64. #endif /* __DF_H */