hal_protocol.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "hal_protocol.h"
  2. #include "hal_esb.h"
  3. #include "hal_uart.h"
  4. /********************** Íⲿº¯ÊýÉùÃ÷Çø *************************/
  5. void Send_IMU_Data(IMU_DAT_t* p)
  6. {
  7. static uint8_t buf[64];
  8. int L = 0;
  9. buf[L++] = (uint8_t)(p->h.press>>8);
  10. buf[L++] = (uint8_t)(p->h.press>>0);
  11. buf[L++] = (uint8_t)(p->h.acc[0]>>8);
  12. buf[L++] = (uint8_t)(p->h.acc[0]>>0);
  13. buf[L++] = (uint8_t)(p->h.acc[1]>>8);
  14. buf[L++] = (uint8_t)(p->h.acc[1]>>0);
  15. buf[L++] = (uint8_t)(p->h.acc[2]>>8);
  16. buf[L++] = (uint8_t)(p->h.acc[2]>>0);
  17. buf[L++] = (uint8_t)(p->h.gyr[0]>>8);
  18. buf[L++] = (uint8_t)(p->h.gyr[0]>>0);
  19. buf[L++] = (uint8_t)(p->h.gyr[1]>>8);
  20. buf[L++] = (uint8_t)(p->h.gyr[1]>>0);
  21. buf[L++] = (uint8_t)(p->h.gyr[2]>>8);
  22. buf[L++] = (uint8_t)(p->h.gyr[2]>>0);
  23. buf[L++] = (uint8_t)(p->h.mag[0]>>8);
  24. buf[L++] = (uint8_t)(p->h.mag[0]>>0);
  25. buf[L++] = (uint8_t)(p->h.mag[1]>>8);
  26. buf[L++] = (uint8_t)(p->h.mag[1]>>0);
  27. buf[L++] = (uint8_t)(p->h.mag[2]>>8);
  28. buf[L++] = (uint8_t)(p->h.mag[2]>>0);
  29. ESB_Tx_Send(0,buf,L,1,0,0,0);
  30. }
  31. void send_protocol(uint8_t dex,uint8_t cmd,uint8_t* dat,uint8_t len)
  32. {
  33. if(IS_HOST){
  34. UART0_Send(cmd,dat,len);
  35. }else{
  36. ESB_Send(cmd,dat,len);
  37. }
  38. }