Skip to content

Commit debfce2

Browse files
committed
Merge pull request arduino#453 from tekka007/HWabstractions
Add hwFreeMem() function
2 parents 9d6a25d + c0e1173 commit debfce2

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

libraries/MySensors/core/MyHwATMega328.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ uint16_t hwCPUVoltage() {
152152
return (1125300UL) / ADC;
153153
}
154154

155-
uint8_t hwCPUFrequency() {
155+
uint16_t hwCPUFrequency() {
156156
noInterrupts();
157157
// setup timer1
158158
TIFR1 = 0xFF;
@@ -180,6 +180,12 @@ uint8_t hwCPUFrequency() {
180180
return TCNT1 * 2048UL / 100000UL;
181181
}
182182

183+
uint16_t hwFreeMem() {
184+
extern int __heap_start, *__brkval;
185+
int v;
186+
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
187+
}
188+
183189

184190

185191
#ifdef MY_DEBUG

libraries/MySensors/core/MyHwESP8266.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ uint16_t hwCPUFrequency() {
126126
return ESP.getCpuFreqMHz()*10;
127127
}
128128

129+
uint16_t hwFreeMem() {
130+
return ESP.getFreeHeap();
131+
}
132+
129133
#ifdef MY_DEBUG
130134
void hwDebugPrint(const char *fmt, ... ) {
131135
char fmtBuffer[300];

libraries/MySensors/core/MyHwSAMD.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,21 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo
138138
return -2;
139139
}
140140

141+
uint16_t hwCPUVoltage() {
142+
// TODO: Not supported!
143+
return 0;
144+
}
145+
146+
uint16_t hwCPUFrequency() {
147+
// TODO: Not supported!
148+
return 0;
149+
}
150+
151+
uint16_t hwFreeMem() {
152+
// TODO: Not supported!
153+
return 0;
154+
}
155+
141156
#ifdef MY_DEBUG
142157
void hwDebugPrint(const char *fmt, ... ) {
143158
if (MY_SERIALDEVICE) {

0 commit comments

Comments
 (0)