Macro embedded_crc_macros::crc8_lookup_table[][src]

macro_rules! crc8_lookup_table {
    (fn $function_name:ident, $initial_value:expr, $lookup_table:ident, $doc:expr) => { ... };
}
Expand description

Define public function implementing the CRC-8 algorithm for the given polynomial and initial value using a lookup table.

This implementation is much faster at the cost of some space. A function name and some documentation for it must be provided.

The lookup table must be stored in a constant defined in the same environment and can be generated in the build.rs file with the build_rs_lookup_table_file_generation macro and then included like in the following example.

You can also find an example using this in the smbus-pec crate.

use embedded_crc_macros::crc8_lookup_table;
// include!(concat!(env!("OUT_DIR"), "/lookup_table.rs"));
crc8_lookup_table!(fn pec, 0, LOOKUP_TABLE, "SMBus Packet Error Code");