HVcallback.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. Thruster.currentlimit = (int16_t)(_buffer[4]+(_buffer[5]<<8));
  15. }
  16. break;
  17. case 0x05:
  18. {
  19. Thruster.fault = (int16_t)_buffer[0]+( (int16_t)_buffer[1]<<8);// + (_buffer[2]<<16)+(_buffer[3]<<24);
  20. Thruster.Imax = (int16_t)_buffer[2]+( (int16_t)_buffer[3]<<8);
  21. Thruster.speedref = (int16_t)( _buffer[4] + (_buffer[5]<<8));
  22. }
  23. break;
  24. case 0x0A:
  25. {
  26. Thruster.torqueIQ = (int16_t)(_buffer[0]+(_buffer[1]<<8)) ;
  27. Thruster.temperature = (int16_t)( _buffer[2] + (_buffer[3]<<8));
  28. Thruster.motortemperature = (int16_t)( _buffer[4] + (_buffer[5]<<8));
  29. }
  30. break;
  31. default:
  32. break;
  33. }
  34. }
  35. void Haoye(uint8_t _buffer[7],HVmotor &HVmotor){
  36. uint16_t code = _buffer[1] +( _buffer[0]<<8);
  37. switch(code){
  38. case 0x5156://speed
  39. HVmotor.speed = _buffer[7] +( _buffer[6]<<8);
  40. break;
  41. case 0x5143://current
  42. HVmotor.current = _buffer[7] +( _buffer[6]<<8);// 扩大10倍
  43. break;
  44. case 0x5150://voltage
  45. HVmotor.voltage = _buffer[7] +( _buffer[6]<<8);// 扩大10倍
  46. break;
  47. case 0x5154://电机温度 motor temp
  48. HVmotor.motortemperature = _buffer[7] +( _buffer[6]<<8);// 扩大10倍
  49. break;
  50. case 0x4551://驱动器温度 driver temp
  51. HVmotor.temperature =_buffer[7] +( _buffer[6]<<8);
  52. break;
  53. case 0x4546://fault
  54. HVmotor.fault =_buffer[7] +( _buffer[6]<<8);
  55. default:
  56. break;
  57. }
  58. }