pub fn update(&mut self, data: &[u8]) {
        // write 4 bytes at once, then 2, then 1, as appropriate
        // in the case of a single large slice this improves speed by >3x
        let mut words = data.chunks_exact(4);
        for word in words.by_ref() {
            let word = u32::from_be_bytes(word.try_into().unwrap());
            self.reg.dr().write(|w| w.dr().bits(word));
        }

        // there will be at most 3 bytes remaining, so 1 half-word and 1 byte
        let mut half_word = words.remainder().chunks_exact(2);
        if let Some(half_word) = half_word.next() {
            let half_word = u16::from_be_bytes(half_word.try_into().unwrap());
            self.reg.dr16().write(|w| w.dr16().bits(half_word));
        }

        if let Some(byte) = half_word.remainder().first() {
            self.reg.dr8().write(|w| w.dr8().bits(*byte));
        }
    }
/// Write data to the CRC unit. Note that CRC calculation works
/// faster if more data is given at once.
Write data to the CRC unit. Note that CRC calculation works
faster if more data is given at once.
Write data to the CRC unit . Note that CRC calculation works faster if more data is given at once .
pub fn update(&mut self, data: &[u8]) {
        // write 4 bytes at once, then 2, then 1, as appropriate
        // in the case of a single large slice this improves speed by >3x
        let mut words = data.chunks_exact(4);
        for word in words.by_ref() {
            let word = u32::from_be_bytes(word.try_into().unwrap());
            self.reg.dr().write(|w| w.dr().bits(word));
        }
        // there will be at most 3 bytes remaining, so 1 half-word and 1 byte
        let mut half_word = words.remainder().chunks_exact(2);
        if let Some(half_word) = half_word.next() {
            let half_word = u16::from_be_bytes(half_word.try_into().unwrap());
            self.reg.dr16().write(|w| w.dr16().bits(half_word));
        }
        if let Some(byte) = half_word.remainder().first() {
            self.reg.dr8().write(|w| w.dr8().bits(*byte));
        }
    }
pub fn update ( & mut self , data : & [ u8 ] ) { // write 4 bytes at once, then 2, then 1, as appropriate // in the case of a single large slice this improves speed by >3x let mut words = data . chunks_exact ( 4 ) ; for word in words . by_ref ( ) { let word = u32 :: from_be_bytes ( word . try_into ( ) . unwrap ( ) ) ; self . reg . dr ( ) . write ( | w | w . dr ( ) . bits ( word ) ) ; } // there will be at most 3 bytes remaining, so 1 half-word and 1 byte let mut half_word = words . remainder ( ) . chunks_exact ( 2 ) ; if let Some ( half_word ) = half_word . next ( ) { let half_word = u16 :: from_be_bytes ( half_word . try_into ( ) . unwrap ( ) ) ; self . reg . dr16 ( ) . write ( | w | w . dr16 ( ) . bits ( half_word ) ) ; } if let Some ( byte ) = half_word . remainder ( ) . first ( ) { self . reg . dr8 ( ) . write ( | w | w . dr8 ( ) . bits ( * byte ) ) ; } }
Write data to the CRC unit.
Write data to the CRC unit .
&mut self
data
&[u8]
&mut self
data
&[u8]