data/method/mavlink/pymavlink/generator/Ada/x25crc.adb

24 lines
658 B
Ada
Raw Permalink Normal View History

2024-07-24 18:30:46 +08:00
-- Package body for crc checksum
-- Copyright Fil Andrii root.fi36@gmail.com 2022
package body X25CRC is
procedure Reset (Element : in out Checksum) is
begin
Element.Low := 16#FF#;
Element.High := 16#FF#;
end Reset;
procedure Update (Element : in out Checksum; Value : Unsigned_8) is
use type Unsigned_16;
Tmp : Unsigned_16;
begin
Tmp := Unsigned_16 (Value) xor (Element.Value and 16#FF#);
Tmp := (Tmp xor Shift_Left (Tmp, 4)) and 16#FF#;
Element.Value :=
Shift_Right (Element.Value, 8) xor Shift_Left (Tmp, 8) xor Shift_Left (Tmp, 3) xor Shift_Right (Tmp, 4);
end Update;
end X25CRC;