hal_ble_uart0.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __hal_ble_uart0__
  2. #define __hal_ble_uart0__
  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. /*************** 发送命令 ********************/
  16. typedef enum {
  17. UART0_T_HEART = 0,
  18. UART0_T_CONFIG_ASK, //配对申请
  19. UART0_T_CONFIG_ACK, //配对成功
  20. UART0_T_CHAR_VOL, //充电电量
  21. UART0_NUM_OF_T, //命令连续用此值
  22. }UART0_T_n;
  23. //#define UART0_NUM_OF_T 9 //注意:::此值根据命令的数量改变
  24. /*************** 发送子命令 ********************/
  25. //enum { //UART0_T_UPDATE
  26. // UART0_T_UPDATE_BASEINFO = 0, //设备基本信息
  27. // UART0_T_UPDATE_DATA , //设备数据
  28. // UART0_T_UPDATE_STEPNUM , //回复存储步数
  29. // UART0_T_UPDATE_STEPNUM_CLERA, //删除存储步数
  30. //};
  31. //enum { //UART0_T_CHARGE
  32. // UART0_T_CHARGE_NONE = 0,
  33. // UART0_T_CHARGE_PULLOUT,
  34. // UART0_T_CHARGE_INSERT,
  35. // UART0_T_CHARGE_DONE,
  36. // UART0_T_CHARGE_ERROR,
  37. //};
  38. /*************** 接收命令 ********************/
  39. typedef enum {
  40. UART0_R_HEART = 0,
  41. UART0_R_CONFIG_ASK, //配对申请
  42. UART0_R_CONFIG_ACK, //配对成功
  43. UART0_R_CHAR_VOL, //充电电量
  44. UART0_NUM_OF_R, //命令连续用此值
  45. }UART0_R_n;
  46. //#define UART0_NUM_OF_R 11 //注意:::此值根据命令的数量改变
  47. /*************** 接收子命令 ********************/
  48. //enum { //UART0_R_UPDATE
  49. // UART0_R_UPDATE_BASEINFO = 0,
  50. // UART0_R_UPDATE_DATA ,
  51. // UART0_R_UPDATE_STEPNUM,
  52. // UART0_R_UPDATE_STEPNUM_CLERA,
  53. //};
  54. typedef void (*UART0_Callback)(void*);
  55. typedef struct _UART0_Rx{
  56. uint8_t cmd;
  57. uint8_t* pDat;
  58. uint8_t datLen;
  59. UART0_Callback cb;
  60. }UART0_Rx_t;
  61. typedef struct _UART0_Tx{
  62. uint8_t n;
  63. uint32_t t;
  64. uint8_t ncnt;
  65. uint32_t tcnt;
  66. uint8_t cmd;
  67. uint8_t* pDat;
  68. uint8_t datLen;
  69. uint8_t holdon;
  70. UART0_Callback cb;
  71. struct _UART0_Tx *next; //单向链表
  72. }UART0_Tx_t;
  73. void UART0_Initialize(void);
  74. void UART0_unInit(void);
  75. void UART0_Send(unsigned char cmd,unsigned char *pDat,unsigned char datLen);
  76. int UART0_Rx_Regist(unsigned char cmd,UART0_Callback cb);
  77. void UART0_Tx_Send(UART0_Tx_t* handle,unsigned char cmd,unsigned char *pDat,unsigned char datLen);
  78. void UART0_Tx_Clear(UART0_Tx_t* handle);
  79. void UART0_Push(unsigned char* p,int len);
  80. #endif