stm32: avoid useless endian conversion in rng

This commit is contained in:
Loïc Damien 2023-10-02 17:20:58 +02:00 committed by GitHub
parent 5f6a915a32
commit bf6e06060b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -164,7 +164,7 @@ impl<'d, T: Instance> Rng<'d, T> {
return Err(Error::SeedError); return Err(Error::SeedError);
} }
// write bytes to chunk // write bytes to chunk
for (dest, src) in chunk.iter_mut().zip(random_word.to_be_bytes().iter()) { for (dest, src) in chunk.iter_mut().zip(random_word.to_ne_bytes().iter()) {
*dest = *src *dest = *src
} }
} }
@ -195,7 +195,7 @@ impl<'d, T: Instance> RngCore for Rng<'d, T> {
fn fill_bytes(&mut self, dest: &mut [u8]) { fn fill_bytes(&mut self, dest: &mut [u8]) {
for chunk in dest.chunks_mut(4) { for chunk in dest.chunks_mut(4) {
let rand = self.next_u32(); let rand = self.next_u32();
for (slot, num) in chunk.iter_mut().zip(rand.to_be_bytes().iter()) { for (slot, num) in chunk.iter_mut().zip(rand.to_ne_bytes().iter()) {
*slot = *num *slot = *num
} }
} }