capsules_extra

Module crc

Source
Expand description

Provides userspace access to a Crc unit.

§Instantiation

Instantiate the capsule for use as a system call driver with a hardware implementation and a Grant for the App type, and set the result as a client of the hardware implementation. For example, using the SAM4L’s CrcU driver:


let crc_buffer = static_init!([u8; 64], [0; 64]);

let crc = static_init!(
    capsules::crc::CrcDriver<'static, sam4l::crccu::Crccu<'static>>,
    capsules::crc::CrcDriver::new(
        &mut sam4l::crccu::CRCCU,
        crc_buffer,
        board_kernel.create_grant(&grant_cap)
     )
);
sam4l::crccu::CRCCU.set_client(crc);

§Crc Algorithms

The capsule supports two general purpose Crc algorithms, as well as a few hardware specific algorithms implemented on the Atmel SAM4L.

In the values used to identify polynomials below, more-significant bits correspond to higher-order terms, and the most significant bit is omitted because it always equals one. All algorithms listed here consume each input byte from most-significant bit to least-significant.

§Crc-32

Polynomial: 0x04C11DB7

This algorithm is used in Ethernet and many other applications. It bit- reverses and then bit-inverts the output.

§Crc-32C

Polynomial: 0x1EDC6F41

Bit-reverses and then bit-inverts the output. It may be equivalent to various Crc functions using the same name.

§SAM4L-16

Polynomial: 0x1021

This algorithm does no post-processing on the output value. The sixteen-bit Crc result is placed in the low-order bits of the returned result value, and the high-order bits will all be set. That is, result values will always be of the form 0xFFFFxxxx for this algorithm. It can be performed purely in hardware on the SAM4L.

§SAM4L-32

Polynomial: 0x04C11DB7

This algorithm uses the same polynomial as Crc-32, but does no post- processing on the output value. It can be performed purely in hardware on the SAM4L.

§SAM4L-32C

Polynomial: 0x1EDC6F41

This algorithm uses the same polynomial as Crc-32C, but does no post- processing on the output value. It can be performed purely in hardware on the SAM4L.

Structs§

  • An opaque value maintaining state for one application’s request
  • Struct that holds the state of the Crc driver and implements the Driver trait for use by processes through the system call interface.

Constants§