Skip to content

Commit

Permalink
Merge pull request mysensors#453 from tekka007/HWabstractions
Browse files Browse the repository at this point in the history
Add hwFreeMem() function
  • Loading branch information
henrikekblad committed May 30, 2016
2 parents 9d6a25d + c0e1173 commit debfce2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libraries/MySensors/core/MyHwATMega328.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ uint16_t hwCPUVoltage() {
return (1125300UL) / ADC;
}

uint8_t hwCPUFrequency() {
uint16_t hwCPUFrequency() {
noInterrupts();
// setup timer1
TIFR1 = 0xFF;
Expand Down Expand Up @@ -180,6 +180,12 @@ uint8_t hwCPUFrequency() {
return TCNT1 * 2048UL / 100000UL;
}

uint16_t hwFreeMem() {
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}



#ifdef MY_DEBUG
Expand Down
4 changes: 4 additions & 0 deletions libraries/MySensors/core/MyHwESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ uint16_t hwCPUFrequency() {
return ESP.getCpuFreqMHz()*10;
}

uint16_t hwFreeMem() {
return ESP.getFreeHeap();
}

#ifdef MY_DEBUG
void hwDebugPrint(const char *fmt, ... ) {
char fmtBuffer[300];
Expand Down
15 changes: 15 additions & 0 deletions libraries/MySensors/core/MyHwSAMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ int8_t hwSleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mo
return -2;
}

uint16_t hwCPUVoltage() {
// TODO: Not supported!
return 0;
}

uint16_t hwCPUFrequency() {
// TODO: Not supported!
return 0;
}

uint16_t hwFreeMem() {
// TODO: Not supported!
return 0;
}

#ifdef MY_DEBUG
void hwDebugPrint(const char *fmt, ... ) {
if (MY_SERIALDEVICE) {
Expand Down

0 comments on commit debfce2

Please sign in to comment.