123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #include "Marlin.h"
- #ifdef SDSUPPORT
- #include "SdFatUtil.h"
- #ifdef __arm__
- extern "C" char* sbrk(int incr);
- int SdFatUtil::FreeRam() {
- char top;
- return &top - reinterpret_cast<char*>(sbrk(0));
- }
- #else
- extern char *__brkval;
- extern char __bss_end;
- int SdFatUtil::FreeRam() {
- char top;
- return __brkval ? &top - __brkval : &top - &__bss_end;
- }
- #endif
- void SdFatUtil::set_stack_guard()
- {
- char i = 0;
- uint32_t *stack_guard;
- stack_guard = (uint32_t*)&__bss_end;
-
- *stack_guard = STACK_GUARD_TEST_VALUE;
-
- }
- bool SdFatUtil::test_stack_integrity()
- {
- uint32_t* stack_guard = (uint32_t*)&__bss_end;
- return (*stack_guard == STACK_GUARD_TEST_VALUE);
- }
- uint32_t SdFatUtil::get_stack_guard_test_value()
- {
-
- uint32_t* stack_guard;
- uint32_t output;
- stack_guard = (uint32_t*)&__bss_end;
-
-
- output = *stack_guard;
- return(output);
- }
- void SdFatUtil::print_P( PGM_P str) {
- for (uint8_t c; (c = pgm_read_byte(str)); str++) MYSERIAL.write(c);
- }
- void SdFatUtil::println_P( PGM_P str) {
- print_P( str);
- MYSERIAL.println();
- }
- void SdFatUtil::SerialPrint_P(PGM_P str) {
- print_P(str);
- }
- void SdFatUtil::SerialPrintln_P(PGM_P str) {
- println_P( str);
- }
- #endif
|