[SX126x] Added TRNG support
This commit is contained in:
parent
04195ee0d2
commit
b40ad5c2f7
2 changed files with 29 additions and 1 deletions
|
@ -1173,6 +1173,27 @@ int16_t SX126x::autoLDRO() {
|
|||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
uint8_t SX126x::random() {
|
||||
// set mode to Rx
|
||||
setRx(SX126X_RX_TIMEOUT_INF);
|
||||
|
||||
// wait a bit for the RSSI reading to stabilise
|
||||
Module::delay(10);
|
||||
|
||||
// read RSSI value 8 times, always keep just the least significant bit
|
||||
uint8_t randByte = 0x00;
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
uint8_t val = 0x00;
|
||||
readRegister(SX126X_REG_RANDOM_NUMBER_0, &val, sizeof(uint8_t));
|
||||
randByte |= ((val & 0x01) << i);
|
||||
}
|
||||
|
||||
// set mode to standby
|
||||
standby();
|
||||
|
||||
return(randByte);
|
||||
}
|
||||
|
||||
int16_t SX126x::setTCXO(float voltage, uint32_t delay) {
|
||||
// set mode to standby
|
||||
standby();
|
||||
|
|
|
@ -854,7 +854,7 @@ class SX126x: public PhysicalLayer {
|
|||
|
||||
/*!
|
||||
\brief Forces LoRa low data rate optimization. Only available in LoRa mode. After calling this method, LDRO will always be set to
|
||||
the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call SX1278::autoLDRO()
|
||||
the provided value, regardless of symbol length. To re-enable automatic LDRO configuration, call SX126x::autoLDRO()
|
||||
|
||||
\param enable Force LDRO to be always enabled (true) or disabled (false).
|
||||
|
||||
|
@ -870,6 +870,13 @@ class SX126x: public PhysicalLayer {
|
|||
*/
|
||||
int16_t autoLDRO();
|
||||
|
||||
/*!
|
||||
\brief Get one truly random byte from RSSI noise.
|
||||
|
||||
\returns TRNG byte.
|
||||
*/
|
||||
uint8_t random();
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
protected:
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue