[RF69] Added TRNG support
This commit is contained in:
parent
b40ad5c2f7
commit
ff8d9d672d
2 changed files with 26 additions and 0 deletions
|
@ -764,6 +764,25 @@ void RF69::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
|
||||||
_mod->setRfSwitchPins(rxEn, txEn);
|
_mod->setRfSwitchPins(rxEn, txEn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t RF69::random() {
|
||||||
|
// set mode to Rx
|
||||||
|
setMode(RF69_RX);
|
||||||
|
|
||||||
|
// 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++) {
|
||||||
|
randByte |= ((_mod->SPIreadRegister(RF69_REG_RSSI_VALUE) & 0x01) << i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set mode to standby
|
||||||
|
setMode(RF69_STANDBY);
|
||||||
|
|
||||||
|
return(randByte);
|
||||||
|
}
|
||||||
|
|
||||||
int16_t RF69::config() {
|
int16_t RF69::config() {
|
||||||
int16_t state = ERR_NONE;
|
int16_t state = ERR_NONE;
|
||||||
|
|
||||||
|
|
|
@ -820,6 +820,13 @@ class RF69: public PhysicalLayer {
|
||||||
*/
|
*/
|
||||||
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
void setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Get one truly random byte from RSSI noise.
|
||||||
|
|
||||||
|
\returns TRNG byte.
|
||||||
|
*/
|
||||||
|
uint8_t random();
|
||||||
|
|
||||||
#ifndef RADIOLIB_GODMODE
|
#ifndef RADIOLIB_GODMODE
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue