mciantyre / teensy4-rs

Rust support for the Teensy 4
Apache License 2.0
271 stars 31 forks source link

Enable `Trng` clock gate #137

Closed Finomnis closed 1 year ago

Finomnis commented 1 year ago

Fixes: #138

If the Trng gets initialized before its clock gate is enabled, it seems to malfunction.

The following workaround is the only way to fix it when using teensy4-bsp:

bsp::hal::ccm::clock_gate::trng().set(&mut ccm, bsp::hal::ccm::clock_gate::ON);
trng = bsp::hal::trng::Trng::new(
    trng.release_disabled(),
    Default::default(),
    Default::default(),
);

Meaning, to enable the clock gate and then re-initialize the Trng object.

This change fixes that problem by enabling the Trng clock gate in the bsp.