From f8108cbf0e0ffd4ed82b22142fcea5d9174ba98f Mon Sep 17 00:00:00 2001 From: Daniel Willenson Date: Tue, 5 May 2026 15:22:34 -0400 Subject: [PATCH] add TMS570_ISO configuration * as documented in https://www.ti.com/lit/an/spna235/spna235.pdf --- fastcrc/crc64.py | 23 ++++++++++++++++++++++- src/lib.rs | 13 +++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/fastcrc/crc64.py b/fastcrc/crc64.py index 634c502..e25d9a8 100644 --- a/fastcrc/crc64.py +++ b/fastcrc/crc64.py @@ -7,8 +7,9 @@ from .fastcrc import crc_64_go_iso as _crc_64_go_iso from .fastcrc import crc_64_we as _crc_64_we from .fastcrc import crc_64_xz as _crc_64_xz +from .fastcrc import crc_64_tms570_iso as _crc_64_tms570_iso -__always_supported = ("ecma_182", "go_iso", "we", "xz") +__always_supported = ("ecma_182", "go_iso", "we", "xz", "tms570_iso") algorithms_guaranteed = set(__always_supported) algorithms_available = set(__always_supported) @@ -92,3 +93,23 @@ def xz(data: bytes, initial: Optional[int] = None) -> int: :raises TypeError: if the data is not a bytes-like object """ return _crc_64_xz(data, initial) + + +def tms570_iso(data: bytes, initial: Optional[int] = None) -> int: + """ + Compute a CRC-64 checksum of data with the `tms570_iso` algorithm. + + Algorithm parameters: + - poly: 0x000000000000001b + - init: 0x0000000000000000 + - xorout: 0x0000000000000000 + - refin: False + - refout: False + + :param bytes data: The data to be computed + :param Optional[int] initial: The optional starting value of the checksum + :return: The checksum + :rtype: int + :raises TypeError: if the data is not a bytes-like object + """ + return _crc_64_tms570_iso(data, initial) diff --git a/src/lib.rs b/src/lib.rs index f94aafc..245b836 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -65,6 +65,17 @@ const CRC_32_K_REVERSED_RECIPROCAL_REFIN: Algorithm = Algorithm { residue: 0x00000000, }; +const CRC_64_TMS570_ISO: Algorithm = Algorithm { + width: 64, + poly: 0x000000000000001b, + init: 0x0000000000000000, + refin: false, + refout: false, + xorout: 0x0000000000000000, + check: 0xe4ffbea588933790, + residue: 0x0000000000000000, +}; + define_crc_fn!(crc_8_autosar, u8, CRC_8_AUTOSAR); define_crc_fn!(crc_8_bluetooth, u8, CRC_8_BLUETOOTH); define_crc_fn!(crc_8_cdma2000, u8, CRC_8_CDMA2000); @@ -135,6 +146,7 @@ define_crc_fn!(crc_64_ecma_182, u64, CRC_64_ECMA_182); define_crc_fn!(crc_64_go_iso, u64, CRC_64_GO_ISO); define_crc_fn!(crc_64_we, u64, CRC_64_WE); define_crc_fn!(crc_64_xz, u64, CRC_64_XZ); +define_crc_fn!(crc_64_tms570_iso, u64, CRC_64_TMS570_ISO); #[pymodule(gil_used = false)] fn fastcrc(m: &Bound<'_, PyModule>) -> PyResult<()> { @@ -204,5 +216,6 @@ fn fastcrc(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(crc_64_go_iso, m)?)?; m.add_function(wrap_pyfunction!(crc_64_we, m)?)?; m.add_function(wrap_pyfunction!(crc_64_xz, m)?)?; + m.add_function(wrap_pyfunction!(crc_64_tms570_iso, m)?)?; Ok(()) }