SD file updates

This commit is contained in:
Scott Lahteine 2017-09-06 06:28:32 -05:00
parent 82fff87e16
commit 614a86a380
15 changed files with 233 additions and 226 deletions

View file

@ -26,11 +26,15 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "Sd2Card.h" #include "Sd2Card.h"
#include "../Marlin.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// send command and return error code. Return zero for OK // send command and return error code. Return zero for OK
uint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) { uint8_t Sd2Card::cardCommand(uint8_t cmd, uint32_t arg) {

View file

@ -27,17 +27,18 @@
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h" #ifndef SD2CARD_H
#if ENABLED(SDSUPPORT) #define SD2CARD_H
#ifndef Sd2Card_h
#define Sd2Card_h
/** /**
* \file * \file
* \brief Sd2Card class for V2 SD/SDHC cards * \brief Sd2Card class for V2 SD/SDHC cards
*/ */
#include "SdFatConfig.h" #include "SdFatConfig.h"
#include "SdInfo.h" #include "SdInfo.h"
#include <stdint.h>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** init timeout ms */ /** init timeout ms */
uint16_t const SD_INIT_TIMEOUT = 2000; uint16_t const SD_INIT_TIMEOUT = 2000;
@ -239,7 +240,5 @@ class Sd2Card {
bool waitNotBusy(uint16_t timeoutMillis); bool waitNotBusy(uint16_t timeoutMillis);
bool writeData(uint8_t token, const uint8_t* src); bool writeData(uint8_t token, const uint8_t* src);
}; };
#endif // Sd2Card_h
#endif // SD2CARD_H
#endif

View file

@ -27,10 +27,14 @@
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h" #include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "SdBaseFile.h" #include "SdBaseFile.h"
#include "../Marlin.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// pointer to cwd directory // pointer to cwd directory
SdBaseFile* SdBaseFile::cwd_ = 0; SdBaseFile* SdBaseFile::cwd_ = 0;
@ -1822,5 +1826,4 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
void (*SdBaseFile::oldDateTime_)(uint16_t &date, uint16_t &time) = 0; // NOLINT void (*SdBaseFile::oldDateTime_)(uint16_t &date, uint16_t &time) = 0; // NOLINT
#endif // ALLOW_DEPRECATED_FUNCTIONS #endif // ALLOW_DEPRECATED_FUNCTIONS
#endif // SDSUPPORT
#endif

View file

@ -26,18 +26,19 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#if ENABLED(SDSUPPORT)
#ifndef SdBaseFile_h #ifndef SDBASEFILE_H
#define SdBaseFile_h #define SDBASEFILE_H
/** /**
* \file * \file
* \brief SdBaseFile class * \brief SdBaseFile class
*/ */
#include "Marlin.h"
#include "SdFatConfig.h" #include "SdFatConfig.h"
#include "SdVolume.h" #include "SdVolume.h"
#include <stdint.h>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
* \struct filepos_t * \struct filepos_t
@ -488,5 +489,4 @@ class SdBaseFile {
#endif // ALLOW_DEPRECATED_FUNCTIONS #endif // ALLOW_DEPRECATED_FUNCTIONS
}; };
#endif // SdBaseFile_h #endif // SDBASEFILE_H
#endif

View file

@ -26,16 +26,14 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
/** /**
* \file * \file
* \brief configuration definitions * \brief configuration definitions
*/ */
#include "Marlin.h" #ifndef SDFATCONFIG_H
#if ENABLED(SDSUPPORT) #define SDFATCONFIG_H
#ifndef SdFatConfig_h
#define SdFatConfig_h
#include <stdint.h>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
* To use multiple SD cards set USE_MULTIPLE_CARDS nonzero. * To use multiple SD cards set USE_MULTIPLE_CARDS nonzero.
@ -128,7 +126,5 @@
#define MAX_VFAT_ENTRIES (2) #define MAX_VFAT_ENTRIES (2)
/** Total size of the buffer used to store the long filenames */ /** Total size of the buffer used to store the long filenames */
#define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1) #define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1)
#endif // SdFatConfig_h
#endif // SDFATCONFIG_H
#endif

View file

@ -26,11 +26,11 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#if ENABLED(SDSUPPORT)
#ifndef SdFatStructs_h #ifndef SDFATSTRUCTS_H
#define SdFatStructs_h #define SDFATSTRUCTS_H
#include <stdint.h>
#define PACKED __attribute__((__packed__)) #define PACKED __attribute__((__packed__))
/** /**
@ -649,7 +649,5 @@ static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) {
static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) { static inline uint8_t DIR_IS_FILE_OR_SUBDIR(const dir_t* dir) {
return (dir->attributes & DIR_ATT_VOLUME_ID) == 0; return (dir->attributes & DIR_ATT_VOLUME_ID) == 0;
} }
#endif // SdFatStructs_h
#endif // SDFATSTRUCTS_H
#endif

View file

@ -26,9 +26,11 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "SdFatUtil.h" #include "SdFatUtil.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -88,4 +90,5 @@ void SdFatUtil::SerialPrint_P(PGM_P str) {
void SdFatUtil::SerialPrintln_P(PGM_P str) { void SdFatUtil::SerialPrintln_P(PGM_P str) {
println_P(str); println_P(str);
} }
#endif
#endif // SDSUPPORT

View file

@ -26,11 +26,10 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#ifndef SdFatUtil_h #ifndef SDFATUTIL_H
#define SdFatUtil_h #define SDFATUTIL_H
#include "Marlin.h" #include <string.h>
#if ENABLED(SDSUPPORT)
/** /**
* \file * \file
@ -51,6 +50,4 @@ namespace SdFatUtil {
using namespace SdFatUtil; // NOLINT using namespace SdFatUtil; // NOLINT
#endif // SDSUPPORT #endif // SDFATUTIL_H
#endif // SdFatUtil_h

View file

@ -26,10 +26,13 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "SdFile.h" #include "SdFile.h"
/** Create a file object and open it in the current working directory. /** Create a file object and open it in the current working directory.
* *
* \param[in] path A path with a valid 8.3 DOS name for a file to be opened. * \param[in] path A path with a valid 8.3 DOS name for a file to be opened.

View file

@ -26,18 +26,20 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
/** /**
* \file * \file
* \brief SdFile class * \brief SdFile class
*/ */
#include "Marlin.h"
#if ENABLED(SDSUPPORT) #ifndef SDFILE_H
#define SDFILE_H
#include "SdBaseFile.h" #include "SdBaseFile.h"
//todo: HAL: create wrapper for Print?
//#include <Print.h> #include <stdint.h>
#ifndef SdFile_h #include <string.h>
#define SdFile_h
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** /**
* \class SdFile * \class SdFile
@ -58,7 +60,5 @@ class SdFile : public SdBaseFile/*, public Print*/ {
void write_P(PGM_P str); void write_P(PGM_P str);
void writeln_P(PGM_P str); void writeln_P(PGM_P str);
}; };
#endif // SdFile_h
#endif // SDFILE_H
#endif

View file

@ -26,12 +26,11 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h" #ifndef SDINFO_H
#if ENABLED(SDSUPPORT) #define SDINFO_H
#ifndef SdInfo_h
#define SdInfo_h
#include <stdint.h> #include <stdint.h>
// Based on the document: // Based on the document:
// //
// SD Specifications // SD Specifications
@ -284,6 +283,5 @@ union csd_t {
csd1_t v1; csd1_t v1;
csd2_t v2; csd2_t v2;
}; };
#endif // SdInfo_h
#endif #endif // SDINFO_H

View file

@ -26,10 +26,15 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "SdVolume.h" #include "SdVolume.h"
#include "../Marlin.h"
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#if !USE_MULTIPLE_CARDS #if !USE_MULTIPLE_CARDS
// raw block cache // raw block cache
@ -417,4 +422,5 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
FAIL: FAIL:
return false; return false;
} }
#endif
#endif // SDSUPPORT

View file

@ -26,10 +26,9 @@
* *
* This file is part of the Arduino Sd2Card Library * This file is part of the Arduino Sd2Card Library
*/ */
#include "Marlin.h" #ifndef SDVOLUME_H
#if ENABLED(SDSUPPORT) #define SDVOLUME_H
#ifndef SdVolume_h
#define SdVolume_h
/** /**
* \file * \file
* \brief SdVolume class * \brief SdVolume class
@ -38,6 +37,8 @@
#include "Sd2Card.h" #include "Sd2Card.h"
#include "SdFatStructs.h" #include "SdFatStructs.h"
#include <stdint.h>
//============================================================================== //==============================================================================
// SdVolume class // SdVolume class
/** /**
@ -223,5 +224,5 @@ class SdVolume {
} }
#endif // ALLOW_DEPRECATED_FUNCTIONS #endif // ALLOW_DEPRECATED_FUNCTIONS
}; };
#endif // SdVolume
#endif #endif // SDVOLUME_H

View file

@ -20,17 +20,20 @@
* *
*/ */
#include <ctype.h> #include "../inc/MarlinConfig.h"
#include "cardreader.h"
#include "ultralcd.h"
#include "stepper.h"
#include "language.h"
#include "Marlin.h"
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#include "cardreader.h"
#include "../Marlin.h"
#include "../lcd/ultralcd.h"
#include "../module/stepper.h"
#include "../module/printcounter.h"
#include "../core/language.h"
#include <ctype.h>
#define LONGEST_FILENAME (longFilename[0] ? longFilename : filename) #define LONGEST_FILENAME (longFilename[0] ? longFilename : filename)
CardReader::CardReader() { CardReader::CardReader() {
@ -864,12 +867,15 @@ void CardReader::updir() {
#endif // SDCARD_SORT_ALPHA #endif // SDCARD_SORT_ALPHA
#if (ENABLED(SDCARD_SORT_ALPHA) && SDSORT_USES_RAM && SDSORT_CACHE_NAMES) uint16_t CardReader::get_num_Files() {
// if true - don't need to access the SD card for file names return
uint16_t CardReader::get_num_Files() {return nrFiles;} #if ENABLED(SDCARD_SORT_ALPHA) && SDSORT_USES_RAM && SDSORT_CACHE_NAMES
nrFiles // no need to access the SD card for filenames
#else #else
uint16_t CardReader::get_num_Files() {return getnrfilenames(); } getnrfilenames()
#endif #endif
;
}
void CardReader::printingHasFinished() { void CardReader::printingHasFinished() {
stepper.synchronize(); stepper.synchronize();

View file

@ -23,16 +23,11 @@
#ifndef CARDREADER_H #ifndef CARDREADER_H
#define CARDREADER_H #define CARDREADER_H
#include "MarlinConfig.h"
#if ENABLED(SDSUPPORT)
#define MAX_DIR_DEPTH 10 // Maximum folder depth #define MAX_DIR_DEPTH 10 // Maximum folder depth
#include "SdFile.h" #include "SdFile.h"
#include "types.h" #include "../inc/MarlinConfig.h"
#include "enum.h"
class CardReader { class CardReader {
public: public:
@ -166,27 +161,25 @@ private:
#endif #endif
}; };
extern CardReader card;
#define IS_SD_PRINTING (card.sdprinting)
#define IS_SD_FILE_OPEN (card.isFileOpen())
#if PIN_EXISTS(SD_DETECT) #if PIN_EXISTS(SD_DETECT)
#if ENABLED(SD_DETECT_INVERTED) #if ENABLED(SD_DETECT_INVERTED)
#define IS_SD_INSERTED (READ(SD_DETECT_PIN) != 0) #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == HIGH)
#else #else
#define IS_SD_INSERTED (READ(SD_DETECT_PIN) == 0) #define IS_SD_INSERTED (READ(SD_DETECT_PIN) == LOW)
#endif #endif
#else #else
//No card detect line? Assume the card is inserted. //No card detect line? Assume the card is inserted.
#define IS_SD_INSERTED true #define IS_SD_INSERTED true
#endif #endif
#if ENABLED(SDSUPPORT)
#define IS_SD_PRINTING (card.sdprinting)
#define IS_SD_FILE_OPEN (card.isFileOpen())
#else #else
#define IS_SD_PRINTING (false) #define IS_SD_PRINTING (false)
#define IS_SD_FILE_OPEN (false) #define IS_SD_FILE_OPEN (false)
#endif
#endif // SDSUPPORT extern CardReader card;
#endif // __CARDREADER_H #endif // CARDREADER_H