mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 06:40:35 +08:00
uavcan bootloader use new AppDes
This commit is contained in:
committed by
Daniel Agar
parent
bfdc6cd675
commit
760e47bbf9
@@ -132,6 +132,44 @@ uint16_t crc16_signature(uint16_t initial, size_t length, const uint8_t *bytes)
|
||||
return initial ^ CRC16_OUTPUT_XOR;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: crc32_signature
|
||||
*
|
||||
* Description:
|
||||
* Calculates a CRC-32 function
|
||||
*
|
||||
* Input Parameters:
|
||||
* acc - The accumulator value to uses as the crc's starting point
|
||||
* length - The number of bytes to add to the crc
|
||||
* bytes - A pointer to any array of length bytes
|
||||
*
|
||||
* Returned Value:
|
||||
* The crc32 of the array of bytes
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t crc32_signature(uint32_t acc, size_t length, const uint8_t *bytes)
|
||||
{
|
||||
size_t i;
|
||||
const uint32_t poly = 0xedb88320u;
|
||||
const uint8_t bits = 8u;
|
||||
uint8_t w = bits;
|
||||
|
||||
for (i = 0u; i < length; i++) {
|
||||
acc ^= bytes[i];
|
||||
w = bits;
|
||||
|
||||
while (w--) {
|
||||
const uint32_t xor = -(acc & 1);
|
||||
acc >>= 1;
|
||||
acc ^= (poly & xor);
|
||||
}
|
||||
}
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: crc64_add_word
|
||||
*
|
||||
|
||||
@@ -96,6 +96,27 @@ uint16_t crc16_add(uint16_t crc, uint8_t value);
|
||||
uint16_t crc16_signature(uint16_t initial, size_t length,
|
||||
const uint8_t *bytes);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: crc32_signature
|
||||
*
|
||||
* Description:
|
||||
* Calculates a CRC-32
|
||||
* function
|
||||
*
|
||||
* Input Parameters:
|
||||
* acc - The Initial value to uses as the crc's starting point
|
||||
* length - The number of bytes to add to the crc
|
||||
* bytes - A pointer to any array of length bytes
|
||||
*
|
||||
* Returned Value:
|
||||
* The crc16 of the array of bytes
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t crc32_signature(uint32_t acc, size_t length,
|
||||
const uint8_t *bytes);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: crc64_add_word
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user