My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SdFatUtil.cpp 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. * Arduino SdFat Library
  24. * Copyright (C) 2008 by William Greiman
  25. *
  26. * This file is part of the Arduino Sd2Card Library
  27. */
  28. #include "MarlinConfig.h"
  29. #if ENABLED(SDSUPPORT)
  30. #include "SdFatUtil.h"
  31. #include "serial.h"
  32. /**
  33. * Amount of free RAM
  34. * \return The number of free bytes.
  35. */
  36. #ifdef __arm__
  37. extern "C" char* sbrk(int incr);
  38. int SdFatUtil::FreeRam() {
  39. char top;
  40. return &top - reinterpret_cast<char*>(sbrk(0));
  41. }
  42. #else // __arm__
  43. extern char* __brkval;
  44. extern char __bss_end;
  45. /**
  46. * Amount of free RAM
  47. * \return The number of free bytes.
  48. */
  49. int SdFatUtil::FreeRam() {
  50. char top;
  51. return __brkval ? &top - __brkval : &top - &__bss_end;
  52. }
  53. #endif // __arm
  54. /**
  55. * %Print a string in flash memory.
  56. *
  57. * \param[in] pr Print object for output.
  58. * \param[in] str Pointer to string stored in flash memory.
  59. */
  60. void SdFatUtil::print_P(PGM_P str) {
  61. for (uint8_t c; (c = pgm_read_byte(str)); str++) MYSERIAL.write(c);
  62. }
  63. /**
  64. * %Print a string in flash memory followed by a CR/LF.
  65. *
  66. * \param[in] pr Print object for output.
  67. * \param[in] str Pointer to string stored in flash memory.
  68. */
  69. void SdFatUtil::println_P(PGM_P str) { print_P(str); MYSERIAL.println(); }
  70. /**
  71. * %Print a string in flash memory to Serial.
  72. *
  73. * \param[in] str Pointer to string stored in flash memory.
  74. */
  75. void SdFatUtil::SerialPrint_P(PGM_P str) { print_P(str); }
  76. /**
  77. * %Print a string in flash memory to Serial followed by a CR/LF.
  78. *
  79. * \param[in] str Pointer to string stored in flash memory.
  80. */
  81. void SdFatUtil::SerialPrintln_P(PGM_P str) { println_P(str); }
  82. #endif // SDSUPPORT