Skip to content

Commit d204929

Browse files
tekka007henrikekblad
authored andcommitted
Use RNG for randomSeed(), ADC_MODE() switch (#696)
1 parent 38013ce commit d204929

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

core/MyHwESP8266.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,25 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo
9090
return MY_SLEEP_NOT_POSSIBLE;
9191
}
9292

93-
#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG)
93+
#if defined(MY_SPECIAL_DEBUG)
94+
// settings for getVcc()
9495
ADC_MODE(ADC_VCC);
96+
#else
97+
// [default] settings for analogRead(A0)
98+
ADC_MODE(ADC_TOUT);
99+
#endif
100+
101+
#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG)
95102

96103
uint16_t hwCPUVoltage()
97104
{
98-
// in mV
105+
#if defined(MY_SPECIAL_DEBUG)
106+
// in mV, requires ADC_VCC set
99107
return ESP.getVcc();
108+
#else
109+
// not possible
110+
return 0;
111+
#endif
100112
}
101113

102114
uint16_t hwCPUFrequency()

core/MyHwESP8266.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@
3232

3333
#define EEPROM_size (1024)
3434

35-
3635
// Define these as macros to save valuable space
3736
#define hwDigitalWrite(__pin, __value) digitalWrite(__pin, __value)
3837
#define hwDigitalRead(__pin) digitalRead(__pin)
3938
#define hwPinMode(__pin, __value) pinMode(__pin, __value)
4039
#define hwWatchdogReset() wdt_reset()
4140
#define hwReboot() ESP.restart()
4241
#define hwMillis() millis()
43-
#define hwRandomNumberInit() randomSeed(analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN))
42+
#define hwRandomNumberInit() randomSeed(RANDOM_REG32)
4443

4544
void hwInit(void);
4645
void hwReadConfigBlock(void* buf, void* adr, size_t length);

0 commit comments

Comments
 (0)