HVcallback.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <AP_Common/AP_Common.h>
  2. #include <AP_HAL/AP_HAL.h>
  3. #include "AP_UAVCAN.h"
  4. #include "HVcallback.h"
  5. //hight volt HighVoltThrusterSetRegs.hpp
  6. void HVcycle(uint8_t _code,uint8_t _buffer[6],HVmes &Thruster){
  7. uint8_t code = (_code&0xF0)>>4;//bfd
  8. switch (code)
  9. {
  10. case 0x03:
  11. {
  12. Thruster.voltage = _buffer[0]+(_buffer[1]<<8);
  13. Thruster.speed = (int16_t)(_buffer[2]+(_buffer[3]<<8) + (_buffer[4]<<16) + (_buffer[5]<<24));
  14. }
  15. break;
  16. case 0x05:
  17. {
  18. Thruster.fault = _buffer[0]+(_buffer[1]<<8) + (_buffer[2]<<16)+(_buffer[3]<<24);
  19. Thruster.speedref = (int16_t)( _buffer[4] + (_buffer[5]<<8));
  20. }
  21. break;
  22. case 0x0A:
  23. {
  24. Thruster.torqueIQ = (int16_t)(_buffer[0]+(_buffer[1]<<8)) ;
  25. Thruster.temperature = (int16_t)( _buffer[2] + (_buffer[3]<<8));
  26. Thruster.motortemperature = (int16_t)( _buffer[4] + (_buffer[5]<<8));
  27. }
  28. break;
  29. default:
  30. break;
  31. }
  32. }
  33. void Haoye(uint8_t _buffer[7],HVmotor &HVmotor){
  34. uint16_t code = _buffer[1] +( _buffer[0]<<8);
  35. switch(code){
  36. case 0x5156://speed
  37. HVmotor.speed = _buffer[7] +( _buffer[6]<<8);
  38. break;
  39. case 0x5143://current
  40. HVmotor.current = _buffer[7] +( _buffer[6]<<8);// 扩大10倍
  41. break;
  42. case 0x5150://voltage
  43. HVmotor.voltage = _buffer[7] +( _buffer[6]<<8);// 扩大10倍
  44. break;
  45. case 0x5154://电机温度 motor temp
  46. HVmotor.motortemperature = _buffer[7] +( _buffer[6]<<8);// 扩大10倍
  47. break;
  48. case 0x4551://驱动器温度 driver temp
  49. HVmotor.temperature =_buffer[7] +( _buffer[6]<<8);
  50. break;
  51. case 0x4546://fault
  52. HVmotor.fault =_buffer[7] +( _buffer[6]<<8);
  53. default:
  54. break;
  55. }
  56. }