|
47 | 47 | #define HEAP_AVAILABLE() ESP.getFreeHeap() |
48 | 48 | #define YAML_DEFAULT_LOG_LEVEL (LogLevel_t)ARDUHAL_LOG_LEVEL |
49 | 49 | #define YAML_PATHNAME pathToFileName |
50 | | -#else |
51 | | - #include <stdio.h> |
52 | | - #include <stdint.h> |
| 50 | +#elif defined ESP8266 |
| 51 | + #include "Esp.h" // bring esp8266-arduino specifics to scope |
| 52 | + #define HEAP_AVAILABLE() ESP.getFreeHeap() |
| 53 | + #define LOG_PRINTF Serial.printf |
| 54 | +#elif defined ARDUINO_ARCH_RP2040 |
| 55 | + #include <Arduino.h> |
| 56 | + #define LOG_PRINTF Serial.printf |
| 57 | + #define HEAP_AVAILABLE() rp2040.getFreeHeap() |
| 58 | +#elif defined ARDUINO_ARCH_SAMD |
53 | 59 | #include <stdarg.h> |
54 | | - // declare macros and functions needed by the logger |
55 | | - #define LOG_PRINTF printf |
56 | | - #ifdef ESP8266 |
57 | | - #include "Esp.h" // bring esp8266-arduino specifics to scope |
58 | | - #define HEAP_AVAILABLE() ESP.getFreeHeap() |
59 | | - #else |
60 | | - #define HEAP_AVAILABLE() getFreeRam() |
61 | | - static int getFreeRam() |
62 | | - { |
63 | | - // implement your own |
64 | | - return 0; |
65 | | - } |
66 | | - #endif |
67 | | - #define YAML_DEFAULT_LOG_LEVEL LogLevelWarning |
68 | | - #define YAML_PATHNAME _pathToFileName |
| 60 | + #include <Arduino.h> |
| 61 | + #define LOG_PRINTF Serial.printf |
| 62 | + #ifdef __arm__ |
| 63 | + // should use uinstd.h to define sbrk but Due causes a conflict |
| 64 | + extern "C" char* sbrk(int incr); |
| 65 | + #else // __ARM__ |
| 66 | + extern char *__brkval; |
| 67 | + #endif // __arm__ |
| 68 | + static int getFreeRam() |
| 69 | + { |
| 70 | + char top; |
| 71 | + #ifdef __arm__ |
| 72 | + return &top - reinterpret_cast<char*>(sbrk(0)); |
| 73 | + #elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151) |
| 74 | + return &top - __brkval; |
| 75 | + #else // __arm__ |
| 76 | + return __brkval ? &top - __brkval : &top - __malloc_heap_start; |
| 77 | + #endif // __arm__ |
| 78 | + } |
| 79 | + #define HEAP_AVAILABLE() getFreeRam() |
| 80 | +#else |
| 81 | + static int getFreeRam() |
| 82 | + { |
| 83 | + // implement your own |
| 84 | + return 0; |
| 85 | + } |
| 86 | + #define HEAP_AVAILABLE() getFreeRam() |
69 | 87 |
|
| 88 | +#endif |
| 89 | + |
| 90 | +#if !defined YAML_PATHNAME |
| 91 | + #define YAML_PATHNAME _pathToFileName |
70 | 92 | static const char * _pathToFileName(const char * path) |
71 | 93 | { |
72 | 94 | size_t i = 0, pos = 0; |
|
82 | 104 | } |
83 | 105 | #endif |
84 | 106 |
|
| 107 | +#if !defined LOG_PRINTF |
| 108 | + #define LOG_PRINTF printf |
| 109 | +#endif |
| 110 | + |
| 111 | +#if !defined YAML_DEFAULT_LOG_LEVEL |
| 112 | + #define YAML_DEFAULT_LOG_LEVEL LogLevelWarning |
| 113 | +#endif |
| 114 | + |
| 115 | + |
85 | 116 |
|
86 | 117 | namespace YAML |
87 | 118 | { |
|
0 commit comments