Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SdFatUtil.h
00001 /* Arduino SdFat Library 00002 * Copyright (C) 2008 by William Greiman 00003 * 00004 * This file is part of the Arduino SdFat Library 00005 * 00006 * This Library is free software: you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation, either version 3 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This Library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 00016 * You should have received a copy of the GNU General Public License 00017 * along with the Arduino SdFat Library. If not, see 00018 * <http://www.gnu.org/licenses/>. 00019 */ 00020 #ifndef SdFatUtil_h 00021 #define SdFatUtil_h 00022 /** 00023 * \file 00024 * Useful utility functions. 00025 */ 00026 #include "mbed.h" 00027 /** Store and print a string in flash memory.*/ 00028 #define PgmPrint(x) SerialPrint_P(PSTR(x)) 00029 /** Store and print a string in flash memory followed by a CR/LF.*/ 00030 #define PgmPrintln(x) SerialPrintln_P(PSTR(x)) 00031 /** Defined so doxygen works for function definitions. */ 00032 #define NOINLINE __attribute__((noinline,unused)) 00033 #define UNUSEDOK __attribute__((unused)) 00034 //------------------------------------------------------------------------------ 00035 /** Return the number of bytes currently free in RAM. */ 00036 static UNUSEDOK int FreeRam(void) { 00037 extern int __bss_end; 00038 extern int* __brkval; 00039 int free_memory; 00040 if (reinterpret_cast<int>(__brkval) == 0) { 00041 // if no heap use from end of bss section 00042 free_memory = reinterpret_cast<int>(&free_memory) 00043 - reinterpret_cast<int>(&__bss_end); 00044 } else { 00045 // use from top of stack to heap 00046 free_memory = reinterpret_cast<int>(&free_memory) 00047 - reinterpret_cast<int>(__brkval); 00048 } 00049 return free_memory; 00050 } 00051 //------------------------------------------------------------------------------ 00052 /** 00053 * %Print a string in flash memory to the serial port. 00054 * 00055 * \param[in] str Pointer to string stored in flash memory. 00056 */ 00057 static NOINLINE void SerialPrint_P(PGM_P str) { 00058 for (uint8_t c; (c = pgm_read_byte(str)); str++) Serial.write(c); 00059 } 00060 //------------------------------------------------------------------------------ 00061 /** 00062 * %Print a string in flash memory followed by a CR/LF. 00063 * 00064 * \param[in] str Pointer to string stored in flash memory. 00065 */ 00066 static NOINLINE void SerialPrintln_P(PGM_P str) { 00067 SerialPrint_P(str); 00068 Serial.putc('/n'); 00069 } 00070 #endif // #define SdFatUtil_h
Generated on Thu Jul 14 2022 02:07:54 by
1.7.2