1 |
ron |
1 |
/**
|
|
|
2 |
* Marlin 3D Printer Firmware
|
|
|
3 |
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
|
4 |
*
|
|
|
5 |
* Based on Sprinter and grbl.
|
|
|
6 |
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
7 |
*
|
|
|
8 |
* This program is free software: you can redistribute it and/or modify
|
|
|
9 |
* it under the terms of the GNU General Public License as published by
|
|
|
10 |
* the Free Software Foundation, either version 3 of the License, or
|
|
|
11 |
* (at your option) any later version.
|
|
|
12 |
*
|
|
|
13 |
* This program is distributed in the hope that it will be useful,
|
|
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
16 |
* GNU General Public License for more details.
|
|
|
17 |
*
|
|
|
18 |
* You should have received a copy of the GNU General Public License
|
|
|
19 |
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20 |
*
|
|
|
21 |
*/
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Arduino SdFat Library
|
|
|
25 |
* Copyright (C) 2008 by William Greiman
|
|
|
26 |
*
|
|
|
27 |
* This file is part of the Arduino Sd2Card Library
|
|
|
28 |
*/
|
|
|
29 |
#include "MarlinConfig.h"
|
|
|
30 |
|
|
|
31 |
#if ENABLED(SDSUPPORT)
|
|
|
32 |
|
|
|
33 |
#include "SdFatUtil.h"
|
|
|
34 |
#include "serial.h"
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Amount of free RAM
|
|
|
38 |
* \return The number of free bytes.
|
|
|
39 |
*/
|
|
|
40 |
#ifdef __arm__
|
|
|
41 |
extern "C" char* sbrk(int incr);
|
|
|
42 |
int SdFatUtil::FreeRam() {
|
|
|
43 |
char top;
|
|
|
44 |
return &top - reinterpret_cast<char*>(sbrk(0));
|
|
|
45 |
}
|
|
|
46 |
#else // __arm__
|
|
|
47 |
extern char* __brkval;
|
|
|
48 |
extern char __bss_end;
|
|
|
49 |
/**
|
|
|
50 |
* Amount of free RAM
|
|
|
51 |
* \return The number of free bytes.
|
|
|
52 |
*/
|
|
|
53 |
int SdFatUtil::FreeRam() {
|
|
|
54 |
char top;
|
|
|
55 |
return __brkval ? &top - __brkval : &top - &__bss_end;
|
|
|
56 |
}
|
|
|
57 |
#endif // __arm
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* %Print a string in flash memory.
|
|
|
61 |
*
|
|
|
62 |
* \param[in] pr Print object for output.
|
|
|
63 |
* \param[in] str Pointer to string stored in flash memory.
|
|
|
64 |
*/
|
|
|
65 |
void SdFatUtil::print_P(PGM_P str) {
|
|
|
66 |
for (uint8_t c; (c = pgm_read_byte(str)); str++) SERIAL_CHAR(c);
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
* %Print a string in flash memory followed by a CR/LF.
|
|
|
71 |
*
|
|
|
72 |
* \param[in] pr Print object for output.
|
|
|
73 |
* \param[in] str Pointer to string stored in flash memory.
|
|
|
74 |
*/
|
|
|
75 |
void SdFatUtil::println_P(PGM_P str) { print_P(str); SERIAL_EOL(); }
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* %Print a string in flash memory to Serial.
|
|
|
79 |
*
|
|
|
80 |
* \param[in] str Pointer to string stored in flash memory.
|
|
|
81 |
*/
|
|
|
82 |
void SdFatUtil::SerialPrint_P(PGM_P str) { print_P(str); }
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* %Print a string in flash memory to Serial followed by a CR/LF.
|
|
|
86 |
*
|
|
|
87 |
* \param[in] str Pointer to string stored in flash memory.
|
|
|
88 |
*/
|
|
|
89 |
void SdFatUtil::SerialPrintln_P(PGM_P str) { println_P(str); }
|
|
|
90 |
|
|
|
91 |
#endif // SDSUPPORT
|