AP_Camera: move crc8_dvb_s2 to AP_Math

This commit is contained in:
Andy Piper 2020-04-30 20:35:59 +01:00 committed by Andrew Tridgell
parent d4c5b945b3
commit ac5a7275bf
2 changed files with 2 additions and 16 deletions

View File

@ -26,6 +26,7 @@
#if HAL_RUNCAM_ENABLED
#include <AP_Math/AP_Math.h>
#include <AP_Math/crc.h>
#include <GCS_MAVLink/GCS.h>
#include <AP_Logger/AP_Logger.h>
@ -900,20 +901,6 @@ void AP_RunCam::send_packet(Command command, uint8_t param)
uart->flush();
}
// crc functions
uint8_t AP_RunCam::crc8_dvb_s2(uint8_t crc, uint8_t a)
{
crc ^= a;
for (uint8_t i = 0; i < 8; ++i) {
if (crc & 0x80) {
crc = (crc << 1) ^ 0xD5;
} else {
crc = crc << 1;
}
}
return crc;
}
uint8_t AP_RunCam::crc8_high_first(uint8_t *ptr, uint8_t len)
{
uint8_t crc = 0x00;
@ -1027,7 +1014,7 @@ uint8_t AP_RunCam::Request::get_crc() const
{
uint8_t crc = 0;
for (int i = 0; i < _recv_response_length; i++) {
crc = AP_RunCam::crc8_dvb_s2(crc, _recv_buf[i]);
crc = crc8_dvb_s2(crc, _recv_buf[i]);
}
return crc;
}

View File

@ -401,7 +401,6 @@ private:
void send_packet(Command command, uint8_t param);
// crc functions
static uint8_t crc8_high_first(uint8_t *ptr, uint8_t len);
static uint8_t crc8_dvb_s2(uint8_t crc, uint8_t a);
// handle a device info response
void parse_device_info(const Request& request);
// wait for the RunCam device to be fully ready