|
-
- #ifndef SdFatUtil_h
- #define SdFatUtil_h
-
- #include <Arduino.h>
- #include <avr/pgmspace.h>
-
- #define PgmPrint(x) SerialPrint_P(PSTR(x))
-
- #define PgmPrintln(x) SerialPrintln_P(PSTR(x))
-
- #define NOINLINE __attribute__((noinline,unused))
- #define UNUSEDOK __attribute__((unused))
-
-
- static UNUSEDOK int FreeRam(void) {
- extern int __bss_end;
- extern int* __brkval;
- int free_memory;
- if (reinterpret_cast<int>(__brkval) == 0) {
-
- free_memory = reinterpret_cast<int>(&free_memory)
- - reinterpret_cast<int>(&__bss_end);
- } else {
-
- free_memory = reinterpret_cast<int>(&free_memory)
- - reinterpret_cast<int>(__brkval);
- }
- return free_memory;
- }
-
-
- static NOINLINE void SerialPrint_P(PGM_P str) {
- for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.write(c);
- }
-
-
- static NOINLINE void SerialPrintln_P(PGM_P str) {
- SerialPrint_P(str);
- Serial.println();
- }
- #endif
|