HVcallback.cpp 975 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. }