bsp_interface.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /********************** 头文件 *************************/
  2. #include "bsp_interface.h"
  3. /********************** 变量区 *************************/
  4. extern IMU_DAT_t m_IMU_DAT_t;
  5. /********************** 函数声明区 *************************/
  6. void sen_data_buf_to_host(void)
  7. {
  8. static uint16_t ts = 0;
  9. uint8_t buf[256];
  10. uint8_t L=0;
  11. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.press>>8);
  12. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.press>>0);
  13. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.press>>8);
  14. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.press>>0);
  15. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.press>>8);
  16. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.press>>0);
  17. ts++;
  18. send_protocol(DEX_NUM,CMD_HEART,buf,L);
  19. }
  20. void sen_data_to_host(void)
  21. {
  22. static uint16_t ts = 0;
  23. uint8_t buf[256];
  24. uint8_t L=0;
  25. buf[L++] = (uint8_t)(m_IMU_DAT_t.h.press>>8);
  26. buf[L++] = (uint8_t)(m_IMU_DAT_t.h.press>>0);
  27. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.pos[0]>>8);
  28. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.pos[0]>>0);
  29. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.pos[1]>>8);
  30. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.pos[1]>>0);
  31. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.pos[2]>>8);
  32. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.pos[2]>>0);
  33. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.att[0]>>8);
  34. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.att[0]>>0);
  35. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.att[1]>>8);
  36. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.att[1]>>0);
  37. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.att[2]>>8);
  38. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.att[2]>>0);
  39. buf[L++] = (uint8_t)(m_IMU_DAT_t.s.zupt>>0);
  40. ts++;
  41. send_protocol(DEX_NUM,CMD_HEART,buf,L);
  42. }
  43. static uint8_t send_motion = 0;
  44. static uint8_t send_ts = 0;
  45. static uint8_t send_times = 0;
  46. void send_motion_to_phone(uint8_t motion,uint16_t ts)
  47. {
  48. send_motion = motion;
  49. send_ts = ts;
  50. send_times = 10;
  51. // uint8_t buf[16];
  52. // uint8_t L=0;
  53. // buf[L++] = motion;
  54. //
  55. // buf[L++] = (uint8_t)(ts>>8);
  56. // buf[L++] = (uint8_t)(ts>>0);
  57. //
  58. // for(int i = 0; i <5; i++)
  59. // send_protocol(DEX_NUM,CMD_MOTION,buf,L);
  60. }
  61. void send_to_phone_process(void)
  62. {
  63. uint8_t buf[16];
  64. uint8_t L=0;
  65. if(send_times>0){
  66. send_times--;
  67. buf[L++] = send_motion;
  68. buf[L++] = (uint8_t)(send_ts>>8);
  69. buf[L++] = (uint8_t)(send_ts>>0);
  70. send_protocol(DEX_NUM,CMD_MOTION,buf,L);
  71. }
  72. }