hal_esb.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef __hal_esb_H__
  2. #define __hal_esb_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. ESB_T_HEART = 0,
  17. ESB_T_MOTION, //动作
  18. ESB_T_UPDATA, //数据更新
  19. ESB_T_A2 = 0xa2, //数据更新
  20. ESB_NUM_OF_T,
  21. }ESB_T_n;
  22. typedef enum {
  23. ESB_R_HEART = 0,
  24. ESB_R_MOTION, //动作
  25. ESB_R_UPDATA, //数据更新
  26. ESB_R_A1 = 0xa1, //数据更新
  27. ESB_R_A2 = 0xa2, //数据更新
  28. ESB_NUM_OF_R,
  29. }ESB_R_n;
  30. typedef void (*ESB_Callback)(void*);
  31. typedef struct _ESB_Rx{
  32. uint8_t cmd;
  33. uint8_t* pDat;
  34. uint8_t datLen;
  35. ESB_Callback cb;
  36. }ESB_Rx_t;
  37. typedef struct _ESB_Tx{
  38. uint8_t cmd;
  39. uint8_t* pDat;
  40. uint8_t datLen;
  41. uint8_t nTimes;
  42. uint32_t periodTime;
  43. uint32_t periodTimecnt;
  44. uint32_t waitTime;
  45. ESB_Callback cb;
  46. }ESB_Tx_t;
  47. void ESB_Initialize(void);
  48. void ESB_Send(unsigned char cmd,unsigned char *pDat,unsigned char datLen);
  49. int ESB_Tx_Send(unsigned char cmd,unsigned char *pDat,unsigned char datLen,uint8_t nTimes,uint32_t periodTime,uint32_t afterTime,uint32_t waitTime);
  50. int ESB_Rx_Regist(unsigned char cmd,ESB_Callback cb);
  51. int ESB_Tx_Regist(unsigned char cmd,ESB_Callback timeout_cb);
  52. void ESB_Tx_Clear(unsigned char cmd);
  53. #endif /* __DF_H */