Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SdFatUtil_h
00021 #define SdFatUtil_h
00022
00026 #include <WProgram.h>
00027 #include <avr/pgmspace.h>
00029 #define PgmPrint(x) SerialPrint_P(PSTR(x))
00030
00031 #define PgmPrintln(x) SerialPrintln_P(PSTR(x))
00032
00033 #define NOINLINE __attribute__((noinline))
00034
00036 static int FreeRam(void) {
00037 extern int __bss_end;
00038 extern int* __brkval;
00039 int free_memory;
00040 if (reinterpret_cast<int>(__brkval) == 0) {
00041
00042 free_memory = reinterpret_cast<int>(&free_memory)
00043 - reinterpret_cast<int>(&__bss_end);
00044 } else {
00045
00046 free_memory = reinterpret_cast<int>(&free_memory)
00047 - reinterpret_cast<int>(__brkval);
00048 }
00049 return free_memory;
00050 }
00051
00057 static NOINLINE void SerialPrint_P(PGM_P str) {
00058 for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.print(c);
00059 }
00060
00066 static NOINLINE void SerialPrintln_P(PGM_P str) {
00067 SerialPrint_P(str);
00068 Serial.println();
00069 }
00070 #endif // #define SdFatUtil_h