annotate TRNG erratum, address review comment
This commit is contained in:
@@ -110,18 +110,18 @@ int getentropy(void *buf, size_t buflen) {
|
||||
}
|
||||
}
|
||||
|
||||
watch_disable_TRNG(TRNG);
|
||||
watch_disable_TRNG();
|
||||
hri_mclk_clear_APBCMASK_TRNG_bit(MCLK);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void watch_disable_TRNG(Trng *hw) {
|
||||
hri_trng_clear_CTRLA_ENABLE_bit(hw);
|
||||
// silicon erratum: the TRNG may leave internal components powered after disable.
|
||||
// the workaround is to clear the register twice.
|
||||
hri_trng_write_CTRLA_reg(hw, 0);
|
||||
hri_trng_write_CTRLA_reg(hw, 0);
|
||||
void watch_disable_TRNG() {
|
||||
// per Microchip datasheet clarification DS80000782,
|
||||
// silicon erratum 1.16.1 indicates that the TRNG may leave internal components powered after being disabled.
|
||||
// the workaround is to disable the TRNG by clearing the control register, twice.
|
||||
hri_trng_write_CTRLA_reg(TRNG, 0);
|
||||
hri_trng_write_CTRLA_reg(TRNG, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -96,12 +96,8 @@ void watch_reset_to_bootloader(void);
|
||||
*/
|
||||
int read(int file, char *ptr, int len);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
typedef void* Trng;
|
||||
#endif
|
||||
|
||||
/** @brief Disables the TRNG, working around a silicon erratum.
|
||||
/** @brief Disables the TRNG twice in order to work around silicon erratum 1.16.1.
|
||||
*/
|
||||
void watch_disable_TRNG(Trng* hw);
|
||||
void watch_disable_TRNG();
|
||||
|
||||
#endif /* WATCH_H_ */
|
||||
|
||||
@@ -57,7 +57,7 @@ void _watch_disable_tcc(void) {}
|
||||
|
||||
void _watch_enable_usb(void) {}
|
||||
|
||||
void watch_disable_TRNG(Trng* hw) {}
|
||||
void watch_disable_TRNG() {}
|
||||
|
||||
// this function ends up getting called by printf to log stuff to the USB console.
|
||||
int _write(int file, char *ptr, int len) {
|
||||
|
||||
Reference in New Issue
Block a user