GCS_MAVLink: use AVR assembler CRC function if available

This commit is contained in:
Andrew Tridgell 2013-01-11 16:01:38 +11:00
parent 82b036282b
commit d6ac02139f
2 changed files with 11 additions and 0 deletions

View File

@ -125,6 +125,15 @@ static inline uint16_t comm_get_txspace(mavlink_channel_t chan)
return (uint16_t)ret;
}
#ifdef HAVE_CRC_ACCUMULATE
// use the AVR C library implementation. This is a bit over twice as
// fast as the C version
static inline void crc_accumulate(uint8_t data, uint16_t *crcAccum)
{
*crcAccum = _crc_ccitt_update(*crcAccum, data);
}
#endif
#define MAVLINK_USE_CONVENIENCE_FUNCTIONS
#include "include/mavlink/v1.0/ardupilotmega/mavlink.h"

View File

@ -24,6 +24,7 @@ extern "C" {
* @param data new char to hash
* @param crcAccum the already accumulated checksum
**/
#ifndef HAVE_CRC_ACCUMULATE
static inline void crc_accumulate(uint8_t data, uint16_t *crcAccum)
{
/*Accumulate one byte of data into the CRC*/
@ -33,6 +34,7 @@ static inline void crc_accumulate(uint8_t data, uint16_t *crcAccum)
tmp ^= (tmp<<4);
*crcAccum = (*crcAccum>>8) ^ (tmp<<8) ^ (tmp <<3) ^ (tmp>>4);
}
#endif
/**
* @brief Initiliaze the buffer for the X.25 CRC