Skip to content

Commit b209534

Browse files
committed
Scale and unify frequency measurement results
1 parent 4a403f6 commit b209534

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

libraries/MySensors/core/MyHw.h

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ uint8_t hwReadConfig(int adr);
4545
int8_t hwSleep(unsigned long ms);
4646
int8_t hwSleep(uint8_t interrupt, uint8_t mode, unsigned long ms);
4747
int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms);
48-
4948
#ifdef MY_DEBUG
5049
void hwDebugPrint(const char *fmt, ... );
5150
#endif

libraries/MySensors/core/MyHwATMega328.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ uint16_t hwCPUVoltage() {
148148
// Do conversion
149149
ADCSRA |= _BV(ADSC);
150150
while (bit_is_set(ADCSRA,ADSC));
151-
// return value in mV
151+
// return Vcc in mV
152152
return (1125300UL) / ADC;
153153
}
154154

@@ -176,8 +176,8 @@ uint8_t hwCPUFrequency() {
176176
WDTCSR |= (1 << WDCE) | (1 << WDE);
177177
WDTCSR = WDTsave;
178178
interrupts();
179-
// return frequency in MHz (accuracy +- 10%)
180-
return TCNT1 * 2048UL / 1000000UL;
179+
// return frequency in 1/10MHz (accuracy +- 10%)
180+
return TCNT1 * 2048UL / 100000UL;
181181
}
182182

183183

libraries/MySensors/core/MyHwESP8266.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,13 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo
110110
ADC_MODE(ADC_VCC);
111111

112112
uint16_t hwCPUVoltage() {
113+
// in mV
113114
return ESP.getVcc();
114115
}
115116

116-
uint8_t hwCPUFrequency() {
117-
return ESP.getCpuFreqMHz();
117+
uint16_t hwCPUFrequency() {
118+
// in 1/10Mhz
119+
return ESP.getCpuFreqMHz()*10;
118120
}
119121

120122
#ifdef MY_DEBUG

0 commit comments

Comments
 (0)