Code cleanup (#787)

* Cleanup Core

* SAMD adjustments
This commit is contained in:
Olivier
2017-03-15 19:05:17 +01:00
committed by Henrik Ekblad
parent 481bd367f3
commit 61a415c422
44 changed files with 163 additions and 149 deletions
+10 -11
View File
@@ -6,7 +6,7 @@
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Copyright (C) 2013-2017 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
@@ -20,13 +20,14 @@
#include "MyHwESP8266.h"
#include <EEPROM.h>
void hwInit(void)
bool hwInit(void)
{
#if !defined(MY_DISABLED_SERIAL)
MY_SERIALDEVICE.begin(MY_BAUD_RATE, SERIAL_8N1, MY_ESP8266_SERIAL_MODE, 1);
MY_SERIALDEVICE.setDebugOutput(true);
#endif
EEPROM.begin(EEPROM_size);
return true;
}
void hwReadConfigBlock(void* buf, void* addr, size_t length)
@@ -109,8 +110,6 @@ ADC_MODE(ADC_VCC);
ADC_MODE(ADC_TOUT);
#endif
#if defined(MY_DEBUG) || defined(MY_SPECIAL_DEBUG)
uint16_t hwCPUVoltage()
{
#if defined(MY_SPECIAL_DEBUG)
@@ -118,7 +117,7 @@ uint16_t hwCPUVoltage()
return ESP.getVcc();
#else
// not possible
return 0;
return FUNCTION_NOT_SUPPORTED;
#endif
}
@@ -132,16 +131,19 @@ uint16_t hwFreeMem()
{
return ESP.getFreeHeap();
}
#endif
#ifdef MY_DEBUG
void hwDebugPrint(const char *fmt, ... )
{
char fmtBuffer[MY_SERIAL_OUTPUT_SIZE];
#ifdef MY_GATEWAY_FEATURE
// prepend debug message to be handled correctly by controller (C_INTERNAL, I_LOG_MESSAGE)
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;"), C_INTERNAL, I_LOG_MESSAGE);
snprintf_P(fmtBuffer, sizeof(fmtBuffer), PSTR("0;255;%d;0;%d;%lu "), C_INTERNAL, I_LOG_MESSAGE,
hwMillis());
MY_SERIALDEVICE.print(fmtBuffer);
#else
// prepend timestamp
MY_SERIALDEVICE.print(hwMillis());
MY_SERIALDEVICE.print(" ");
#endif
va_list args;
va_start (args, fmt );
@@ -156,7 +158,4 @@ void hwDebugPrint(const char *fmt, ... )
va_end (args);
MY_SERIALDEVICE.print(fmtBuffer);
MY_SERIALDEVICE.flush();
//MY_SERIALDEVICE.write(freeRam());
}
#endif