misc. pointer formatting
This commit is contained in:
parent
98b2b45264
commit
8b6718c632
@ -135,7 +135,7 @@ static uint8_t buffer[256] = {0}, // The RAM buffer to accumulate writes
|
|||||||
#define DEBUG_OUT ENABLED(EE_EMU_DEBUG)
|
#define DEBUG_OUT ENABLED(EE_EMU_DEBUG)
|
||||||
#include "../../core/debug_out.h"
|
#include "../../core/debug_out.h"
|
||||||
|
|
||||||
static void ee_Dump(const int page, const void* data) {
|
static void ee_Dump(const int page, const void *data) {
|
||||||
|
|
||||||
#ifdef EE_EMU_DEBUG
|
#ifdef EE_EMU_DEBUG
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ static void ee_Dump(const int page, const void* data) {
|
|||||||
* @param data (pointer to the data buffer)
|
* @param data (pointer to the data buffer)
|
||||||
*/
|
*/
|
||||||
__attribute__ ((long_call, section (".ramfunc")))
|
__attribute__ ((long_call, section (".ramfunc")))
|
||||||
static bool ee_PageWrite(uint16_t page, const void* data) {
|
static bool ee_PageWrite(uint16_t page, const void *data) {
|
||||||
|
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
uint32_t addrflash = uint32_t(getFlashStorage(page));
|
uint32_t addrflash = uint32_t(getFlashStorage(page));
|
||||||
|
@ -139,7 +139,7 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg) {
|
|||||||
I2S0.int_clr.val = I2S0.int_st.val; //clear pending interrupt
|
I2S0.int_clr.val = I2S0.int_st.val; //clear pending interrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
void stepperTask(void* parameter) {
|
void stepperTask(void *parameter) {
|
||||||
uint32_t remaining = 0;
|
uint32_t remaining = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
typedef void (*usart_rx_callback_t)(serial_t * obj);
|
typedef void (*usart_rx_callback_t)(serial_t * obj);
|
||||||
|
|
||||||
struct MarlinSerial : public HardwareSerial {
|
struct MarlinSerial : public HardwareSerial {
|
||||||
MarlinSerial(void* peripheral, usart_rx_callback_t rx_callback) :
|
MarlinSerial(void *peripheral, usart_rx_callback_t rx_callback) :
|
||||||
HardwareSerial(peripheral), _rx_callback(rx_callback)
|
HardwareSerial(peripheral), _rx_callback(rx_callback)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ DRESULT disk_read(BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
|
|||||||
DRESULT disk_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
|
DRESULT disk_write(BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
|
||||||
#endif
|
#endif
|
||||||
#if _DISKIO_IOCTL
|
#if _DISKIO_IOCTL
|
||||||
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void* buff);
|
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Disk Status Bits (DSTATUS) */
|
/* Disk Status Bits (DSTATUS) */
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
// Dump a backtrace entry
|
// Dump a backtrace entry
|
||||||
static bool UnwReportOut(void* ctx, const UnwReport* bte) {
|
static bool UnwReportOut(void *ctx, const UnwReport *bte) {
|
||||||
int *p = (int*)ctx;
|
int *p = (int*)ctx;
|
||||||
|
|
||||||
(*p)++;
|
(*p)++;
|
||||||
|
@ -114,7 +114,7 @@ typedef struct {
|
|||||||
* report function maybe called again in future. If false is returned,
|
* report function maybe called again in future. If false is returned,
|
||||||
* unwinding will stop with UnwindStart() returning UNWIND_TRUNCATED.
|
* unwinding will stop with UnwindStart() returning UNWIND_TRUNCATED.
|
||||||
*/
|
*/
|
||||||
typedef bool (*UnwindReportFunc)(void* data, const UnwReport* bte);
|
typedef bool (*UnwindReportFunc)(void *data, const UnwReport *bte);
|
||||||
|
|
||||||
/** Structure that holds memory callback function pointers.
|
/** Structure that holds memory callback function pointers.
|
||||||
*/
|
*/
|
||||||
|
@ -70,7 +70,7 @@ void DGUSDisplay::InitDisplay() {
|
|||||||
RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN));
|
RequestScreen(TERN(SHOW_BOOTSCREEN, DGUSLCD_SCREEN_BOOT, DGUSLCD_SCREEN_MAIN));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DGUSDisplay::WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) {
|
void DGUSDisplay::WriteVariable(uint16_t adr, const void *values, uint8_t valueslen, bool isstr) {
|
||||||
const char* myvalues = static_cast<const char*>(values);
|
const char* myvalues = static_cast<const char*>(values);
|
||||||
bool strend = !myvalues;
|
bool strend = !myvalues;
|
||||||
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
|
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
|
||||||
@ -120,7 +120,7 @@ void DGUSDisplay::WriteVariable(uint16_t adr, long value) {
|
|||||||
WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(long));
|
WriteVariable(adr, static_cast<const void*>(&tmp), sizeof(long));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr) {
|
void DGUSDisplay::WriteVariablePGM(uint16_t adr, const void *values, uint8_t valueslen, bool isstr) {
|
||||||
const char* myvalues = static_cast<const char*>(values);
|
const char* myvalues = static_cast<const char*>(values);
|
||||||
bool strend = !myvalues;
|
bool strend = !myvalues;
|
||||||
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
|
WriteHeader(adr, DGUS_CMD_WRITEVAR, valueslen);
|
||||||
|
@ -56,8 +56,8 @@ public:
|
|||||||
static void InitDisplay();
|
static void InitDisplay();
|
||||||
|
|
||||||
// Variable access.
|
// Variable access.
|
||||||
static void WriteVariable(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false);
|
static void WriteVariable(uint16_t adr, const void *values, uint8_t valueslen, bool isstr=false);
|
||||||
static void WriteVariablePGM(uint16_t adr, const void* values, uint8_t valueslen, bool isstr=false);
|
static void WriteVariablePGM(uint16_t adr, const void *values, uint8_t valueslen, bool isstr=false);
|
||||||
static void WriteVariable(uint16_t adr, int16_t value);
|
static void WriteVariable(uint16_t adr, int16_t value);
|
||||||
static void WriteVariable(uint16_t adr, uint16_t value);
|
static void WriteVariable(uint16_t adr, uint16_t value);
|
||||||
static void WriteVariable(uint16_t adr, uint8_t value);
|
static void WriteVariable(uint16_t adr, uint8_t value);
|
||||||
|
@ -75,7 +75,7 @@ void DGUSScreenHandler::sendinfoscreen_en_mks(const char *line1, const char *lin
|
|||||||
dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true);
|
dgusdisplay.WriteVariable(VP_MSGSTR4, line4, 32, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DGUSScreenHandler::sendinfoscreen_mks(const void* line1, const void* line2, const void* line3, const void* line4, uint16_t language) {
|
void DGUSScreenHandler::sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language) {
|
||||||
if (language == MKS_English)
|
if (language == MKS_English)
|
||||||
DGUSScreenHandler::sendinfoscreen_en_mks((char *)line1, (char *)line2, (char *)line3, (char *)line4);
|
DGUSScreenHandler::sendinfoscreen_en_mks((char *)line1, (char *)line2, (char *)line3, (char *)line4);
|
||||||
else if (language == MKS_SimpleChinese)
|
else if (language == MKS_SimpleChinese)
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
#if 0
|
#if 0
|
||||||
static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4);
|
static void sendinfoscreen_ch_mks(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4);
|
||||||
static void sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) ;
|
static void sendinfoscreen_en_mks(const char *line1, const char *line2, const char *line3, const char *line4) ;
|
||||||
static void sendinfoscreen_mks(const void* line1, const void* line2, const void* line3, const void* line4,uint16_t language);
|
static void sendinfoscreen_mks(const void *line1, const void *line2, const void *line3, const void *line4, uint16_t language);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// "M117" Message -- msg is a RAM ptr.
|
// "M117" Message -- msg is a RAM ptr.
|
||||||
|
@ -229,7 +229,7 @@ void CLCD::CommandFifo::cmd(uint32_t cmd32) {
|
|||||||
write((void*)&cmd32, sizeof(uint32_t));
|
write((void*)&cmd32, sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLCD::CommandFifo::cmd(void* data, uint16_t len) {
|
void CLCD::CommandFifo::cmd(void *data, uint16_t len) {
|
||||||
write(data, len);
|
write(data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ class CLCD::CommandFifo {
|
|||||||
void execute();
|
void execute();
|
||||||
|
|
||||||
void cmd(uint32_t cmd32);
|
void cmd(uint32_t cmd32);
|
||||||
void cmd(void* data, uint16_t len);
|
void cmd(void *data, uint16_t len);
|
||||||
|
|
||||||
void dlstart() {cmd(FTDI::CMD_DLSTART);}
|
void dlstart() {cmd(FTDI::CMD_DLSTART);}
|
||||||
void swap() {cmd(FTDI::CMD_SWAP);}
|
void swap() {cmd(FTDI::CMD_SWAP);}
|
||||||
|
@ -149,7 +149,7 @@ class CommandProcessor : public CLCD::CommandFifo {
|
|||||||
// Wrap all the CommandFifo routines to allow method chaining
|
// Wrap all the CommandFifo routines to allow method chaining
|
||||||
|
|
||||||
inline CommandProcessor& cmd (uint32_t cmd32) {CLCD::CommandFifo::cmd(cmd32); return *this;}
|
inline CommandProcessor& cmd (uint32_t cmd32) {CLCD::CommandFifo::cmd(cmd32); return *this;}
|
||||||
inline CommandProcessor& cmd (void* data, uint16_t len) {CLCD::CommandFifo::cmd(data, len); return *this;}
|
inline CommandProcessor& cmd (void *data, uint16_t len) {CLCD::CommandFifo::cmd(data, len); return *this;}
|
||||||
inline CommandProcessor& execute() {CLCD::CommandFifo::execute(); return *this;}
|
inline CommandProcessor& execute() {CLCD::CommandFifo::execute(); return *this;}
|
||||||
|
|
||||||
inline CommandProcessor& fgcolor (uint32_t rgb) {CLCD::CommandFifo::fgcolor(rgb); return *this;}
|
inline CommandProcessor& fgcolor (uint32_t rgb) {CLCD::CommandFifo::fgcolor(rgb); return *this;}
|
||||||
|
@ -477,7 +477,7 @@ bool Sd2Card::readData(uint8_t *dst, const uint16_t count) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** read CID or CSR register */
|
/** read CID or CSR register */
|
||||||
bool Sd2Card::readRegister(const uint8_t cmd, void* buf) {
|
bool Sd2Card::readRegister(const uint8_t cmd, void *buf) {
|
||||||
uint8_t *dst = reinterpret_cast<uint8_t*>(buf);
|
uint8_t *dst = reinterpret_cast<uint8_t*>(buf);
|
||||||
if (cardCommand(cmd, 0)) {
|
if (cardCommand(cmd, 0)) {
|
||||||
error(SD_CARD_ERROR_READ_REG);
|
error(SD_CARD_ERROR_READ_REG);
|
||||||
|
@ -177,7 +177,7 @@ private:
|
|||||||
uint8_t cardCommand(const uint8_t cmd, const uint32_t arg);
|
uint8_t cardCommand(const uint8_t cmd, const uint32_t arg);
|
||||||
|
|
||||||
bool readData(uint8_t *dst, const uint16_t count);
|
bool readData(uint8_t *dst, const uint16_t count);
|
||||||
bool readRegister(const uint8_t cmd, void* buf);
|
bool readRegister(const uint8_t cmd, void *buf);
|
||||||
void chipDeselect();
|
void chipDeselect();
|
||||||
void chipSelect();
|
void chipSelect();
|
||||||
inline void type(const uint8_t value) { type_ = value; }
|
inline void type(const uint8_t value) { type_ = value; }
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#include "SdBaseFile.h"
|
#include "SdBaseFile.h"
|
||||||
|
|
||||||
#include "../MarlinCore.h"
|
#include "../MarlinCore.h"
|
||||||
SdBaseFile* SdBaseFile::cwd_ = 0; // Pointer to Current Working Directory
|
SdBaseFile *SdBaseFile::cwd_ = 0; // Pointer to Current Working Directory
|
||||||
|
|
||||||
// callback function for date/time
|
// callback function for date/time
|
||||||
void (*SdBaseFile::dateTime_)(uint16_t *date, uint16_t *time) = 0;
|
void (*SdBaseFile::dateTime_)(uint16_t *date, uint16_t *time) = 0;
|
||||||
@ -155,7 +155,7 @@ bool SdBaseFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock) {
|
|||||||
* a file is already open, the file already exists, the root
|
* a file is already open, the file already exists, the root
|
||||||
* directory is full or an I/O error.
|
* directory is full or an I/O error.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char *path, uint32_t size) {
|
bool SdBaseFile::createContiguous(SdBaseFile *dirFile, const char *path, uint32_t size) {
|
||||||
if (ENABLED(SDCARD_READONLY)) return false;
|
if (ENABLED(SDCARD_READONLY)) return false;
|
||||||
|
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
@ -187,12 +187,11 @@ bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char *path, uint32_
|
|||||||
* \return true for success, false for failure.
|
* \return true for success, false for failure.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::dirEntry(dir_t *dir) {
|
bool SdBaseFile::dirEntry(dir_t *dir) {
|
||||||
dir_t *p;
|
|
||||||
// make sure fields on SD are correct
|
// make sure fields on SD are correct
|
||||||
if (!sync()) return false;
|
if (!sync()) return false;
|
||||||
|
|
||||||
// read entry
|
// read entry
|
||||||
p = cacheDirEntry(SdVolume::CACHE_FOR_READ);
|
dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_READ);
|
||||||
if (!p) return false;
|
if (!p) return false;
|
||||||
|
|
||||||
// copy to caller's struct
|
// copy to caller's struct
|
||||||
@ -207,7 +206,7 @@ bool SdBaseFile::dirEntry(dir_t *dir) {
|
|||||||
* \param[in] dir The directory structure containing the name.
|
* \param[in] dir The directory structure containing the name.
|
||||||
* \param[out] name A 13 byte char array for the formatted name.
|
* \param[out] name A 13 byte char array for the formatted name.
|
||||||
*/
|
*/
|
||||||
void SdBaseFile::dirName(const dir_t& dir, char *name) {
|
void SdBaseFile::dirName(const dir_t &dir, char *name) {
|
||||||
uint8_t j = 0;
|
uint8_t j = 0;
|
||||||
LOOP_L_N(i, 11) {
|
LOOP_L_N(i, 11) {
|
||||||
if (dir.name[i] == ' ')continue;
|
if (dir.name[i] == ' ')continue;
|
||||||
@ -386,7 +385,7 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format directory name field from a 8.3 name string
|
// Format directory name field from a 8.3 name string
|
||||||
bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char** ptr) {
|
bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char **ptr) {
|
||||||
uint8_t n = 7, // Max index until a dot is found
|
uint8_t n = 7, // Max index until a dot is found
|
||||||
i = 11;
|
i = 11;
|
||||||
while (i) name[--i] = ' '; // Set whole FILENAME.EXT to spaces
|
while (i) name[--i] = ' '; // Set whole FILENAME.EXT to spaces
|
||||||
@ -423,13 +422,13 @@ bool SdBaseFile::make83Name(const char *str, uint8_t *name, const char** ptr) {
|
|||||||
* Reasons for failure include this file is already open, \a parent is not a
|
* Reasons for failure include this file is already open, \a parent is not a
|
||||||
* directory, \a path is invalid or already exists in \a parent.
|
* directory, \a path is invalid or already exists in \a parent.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::mkdir(SdBaseFile* parent, const char *path, bool pFlag) {
|
bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) {
|
||||||
if (ENABLED(SDCARD_READONLY)) return false;
|
if (ENABLED(SDCARD_READONLY)) return false;
|
||||||
|
|
||||||
uint8_t dname[11];
|
uint8_t dname[11];
|
||||||
SdBaseFile dir1, dir2;
|
SdBaseFile dir1, dir2;
|
||||||
SdBaseFile* sub = &dir1;
|
SdBaseFile *sub = &dir1;
|
||||||
SdBaseFile* start = parent;
|
SdBaseFile *start = parent;
|
||||||
|
|
||||||
if (!parent || isOpen()) return false;
|
if (!parent || isOpen()) return false;
|
||||||
|
|
||||||
@ -455,13 +454,9 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const char *path, bool pFlag) {
|
|||||||
return mkdir(parent, dname);
|
return mkdir(parent, dname);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) {
|
bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11]) {
|
||||||
if (ENABLED(SDCARD_READONLY)) return false;
|
if (ENABLED(SDCARD_READONLY)) return false;
|
||||||
|
|
||||||
uint32_t block;
|
|
||||||
dir_t d;
|
|
||||||
dir_t *p;
|
|
||||||
|
|
||||||
if (!parent->isDir()) return false;
|
if (!parent->isDir()) return false;
|
||||||
|
|
||||||
// create a normal file
|
// create a normal file
|
||||||
@ -478,19 +473,20 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) {
|
|||||||
if (!sync()) return false;
|
if (!sync()) return false;
|
||||||
|
|
||||||
// cache entry - should already be in cache due to sync() call
|
// cache entry - should already be in cache due to sync() call
|
||||||
p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
||||||
if (!p) return false;
|
if (!p) return false;
|
||||||
|
|
||||||
// change directory entry attribute
|
// change directory entry attribute
|
||||||
p->attributes = DIR_ATT_DIRECTORY;
|
p->attributes = DIR_ATT_DIRECTORY;
|
||||||
|
|
||||||
// make entry for '.'
|
// make entry for '.'
|
||||||
|
dir_t d;
|
||||||
memcpy(&d, p, sizeof(d));
|
memcpy(&d, p, sizeof(d));
|
||||||
d.name[0] = '.';
|
d.name[0] = '.';
|
||||||
LOOP_S_L_N(i, 1, 11) d.name[i] = ' ';
|
LOOP_S_L_N(i, 1, 11) d.name[i] = ' ';
|
||||||
|
|
||||||
// cache block for '.' and '..'
|
// cache block for '.' and '..'
|
||||||
block = vol_->clusterStartBlock(firstCluster_);
|
uint32_t block = vol_->clusterStartBlock(firstCluster_);
|
||||||
if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) return false;
|
if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) return false;
|
||||||
|
|
||||||
// copy '.' to block
|
// copy '.' to block
|
||||||
@ -577,7 +573,7 @@ bool SdBaseFile::open(const char *path, uint8_t oflag) {
|
|||||||
* a directory, \a path is invalid, the file does not exist
|
* a directory, \a path is invalid, the file does not exist
|
||||||
* or can't be opened in the access mode specified by oflag.
|
* or can't be opened in the access mode specified by oflag.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::open(SdBaseFile* dirFile, const char *path, uint8_t oflag) {
|
bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) {
|
||||||
uint8_t dname[11];
|
uint8_t dname[11];
|
||||||
SdBaseFile dir1, dir2;
|
SdBaseFile dir1, dir2;
|
||||||
SdBaseFile *parent = dirFile, *sub = &dir1;
|
SdBaseFile *parent = dirFile, *sub = &dir1;
|
||||||
@ -605,7 +601,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const char *path, uint8_t oflag) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// open with filename in dname
|
// open with filename in dname
|
||||||
bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag) {
|
bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag) {
|
||||||
bool emptyFound = false, fileFound = false;
|
bool emptyFound = false, fileFound = false;
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
dir_t *p;
|
dir_t *p;
|
||||||
@ -696,9 +692,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t ofla
|
|||||||
* See open() by path for definition of flags.
|
* See open() by path for definition of flags.
|
||||||
* \return true for success or false for failure.
|
* \return true for success or false for failure.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
|
bool SdBaseFile::open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag) {
|
||||||
dir_t *p;
|
|
||||||
|
|
||||||
vol_ = dirFile->vol_;
|
vol_ = dirFile->vol_;
|
||||||
|
|
||||||
// error if already open
|
// error if already open
|
||||||
@ -711,7 +705,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
|
|||||||
if (!dirFile->seekSet(32 * index)) return false;
|
if (!dirFile->seekSet(32 * index)) return false;
|
||||||
|
|
||||||
// read entry into cache
|
// read entry into cache
|
||||||
p = dirFile->readDirCache();
|
dir_t *p = dirFile->readDirCache();
|
||||||
if (!p) return false;
|
if (!p) return false;
|
||||||
|
|
||||||
// error if empty slot or '.' or '..'
|
// error if empty slot or '.' or '..'
|
||||||
@ -784,10 +778,7 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) {
|
|||||||
* See open() by path for definition of flags.
|
* See open() by path for definition of flags.
|
||||||
* \return true for success or false for failure.
|
* \return true for success or false for failure.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
|
bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) {
|
||||||
dir_t *p;
|
|
||||||
uint8_t index;
|
|
||||||
|
|
||||||
if (!dirFile) return false;
|
if (!dirFile) return false;
|
||||||
|
|
||||||
// error if already open
|
// error if already open
|
||||||
@ -796,10 +787,10 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
|
|||||||
vol_ = dirFile->vol_;
|
vol_ = dirFile->vol_;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
index = 0xF & (dirFile->curPosition_ >> 5);
|
uint8_t index = 0xF & (dirFile->curPosition_ >> 5);
|
||||||
|
|
||||||
// read entry into cache
|
// read entry into cache
|
||||||
p = dirFile->readDirCache();
|
dir_t *p = dirFile->readDirCache();
|
||||||
if (!p) return false;
|
if (!p) return false;
|
||||||
|
|
||||||
// done if last entry
|
// done if last entry
|
||||||
@ -825,9 +816,8 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
|
|||||||
*
|
*
|
||||||
* \return true for success, false for failure.
|
* \return true for success, false for failure.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::openParent(SdBaseFile* dir) {
|
bool SdBaseFile::openParent(SdBaseFile *dir) {
|
||||||
dir_t entry;
|
dir_t entry;
|
||||||
dir_t *p;
|
|
||||||
SdBaseFile file;
|
SdBaseFile file;
|
||||||
uint32_t c;
|
uint32_t c;
|
||||||
uint32_t cluster;
|
uint32_t cluster;
|
||||||
@ -850,7 +840,7 @@ bool SdBaseFile::openParent(SdBaseFile* dir) {
|
|||||||
// first block of parent dir
|
// first block of parent dir
|
||||||
if (!vol_->cacheRawBlock(lbn, SdVolume::CACHE_FOR_READ)) return false;
|
if (!vol_->cacheRawBlock(lbn, SdVolume::CACHE_FOR_READ)) return false;
|
||||||
|
|
||||||
p = &vol_->cacheBuffer_.dir[1];
|
dir_t *p = &vol_->cacheBuffer_.dir[1];
|
||||||
// verify name for '../..'
|
// verify name for '../..'
|
||||||
if (p->name[0] != '.' || p->name[1] != '.') return false;
|
if (p->name[0] != '.' || p->name[1] != '.') return false;
|
||||||
// '..' is pointer to first cluster of parent. open '../..' to find parent
|
// '..' is pointer to first cluster of parent. open '../..' to find parent
|
||||||
@ -881,7 +871,7 @@ bool SdBaseFile::openParent(SdBaseFile* dir) {
|
|||||||
* Reasons for failure include the file is already open, the FAT volume has
|
* Reasons for failure include the file is already open, the FAT volume has
|
||||||
* not been initialized or it a FAT12 volume.
|
* not been initialized or it a FAT12 volume.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::openRoot(SdVolume* vol) {
|
bool SdBaseFile::openRoot(SdVolume *vol) {
|
||||||
// error if file is already open
|
// error if file is already open
|
||||||
if (isOpen()) return false;
|
if (isOpen()) return false;
|
||||||
|
|
||||||
@ -1008,7 +998,7 @@ int16_t SdBaseFile::read() {
|
|||||||
* read() called before a file has been opened, corrupt file system
|
* read() called before a file has been opened, corrupt file system
|
||||||
* or an I/O error occurred.
|
* or an I/O error occurred.
|
||||||
*/
|
*/
|
||||||
int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
|
int16_t SdBaseFile::read(void *buf, uint16_t nbyte) {
|
||||||
uint8_t *dst = reinterpret_cast<uint8_t*>(buf);
|
uint8_t *dst = reinterpret_cast<uint8_t*>(buf);
|
||||||
uint16_t offset, toRead;
|
uint16_t offset, toRead;
|
||||||
uint32_t block; // raw device block number
|
uint32_t block; // raw device block number
|
||||||
@ -1136,7 +1126,7 @@ int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) {
|
|||||||
// Reset n to the start of the long name
|
// Reset n to the start of the long name
|
||||||
n = 0;
|
n = 0;
|
||||||
for (uint16_t idx = 0; idx < (LONG_FILENAME_LENGTH) / 2; idx += 2) { // idx is fixed since FAT LFN always contains UTF-16LE encoding
|
for (uint16_t idx = 0; idx < (LONG_FILENAME_LENGTH) / 2; idx += 2) { // idx is fixed since FAT LFN always contains UTF-16LE encoding
|
||||||
uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1] << 8);
|
const uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1] << 8);
|
||||||
if (0xD800 == (utf16_ch & 0xF800)) // Surrogate pair - encode as '_'
|
if (0xD800 == (utf16_ch & 0xF800)) // Surrogate pair - encode as '_'
|
||||||
longFilename[n++] = '_';
|
longFilename[n++] = '_';
|
||||||
else if (0 == (utf16_ch & 0xFF80)) // Encode as 1-byte UTF-8 char
|
else if (0 == (utf16_ch & 0xFF80)) // Encode as 1-byte UTF-8 char
|
||||||
@ -1199,12 +1189,11 @@ dir_t* SdBaseFile::readDirCache() {
|
|||||||
bool SdBaseFile::remove() {
|
bool SdBaseFile::remove() {
|
||||||
if (ENABLED(SDCARD_READONLY)) return false;
|
if (ENABLED(SDCARD_READONLY)) return false;
|
||||||
|
|
||||||
dir_t *d;
|
|
||||||
// free any clusters - will fail if read-only or directory
|
// free any clusters - will fail if read-only or directory
|
||||||
if (!truncate(0)) return false;
|
if (!truncate(0)) return false;
|
||||||
|
|
||||||
// cache directory entry
|
// cache directory entry
|
||||||
d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
||||||
if (!d) return false;
|
if (!d) return false;
|
||||||
|
|
||||||
// mark entry deleted
|
// mark entry deleted
|
||||||
@ -1235,7 +1224,7 @@ bool SdBaseFile::remove() {
|
|||||||
* \a dirFile is not a directory, \a path is not found
|
* \a dirFile is not a directory, \a path is not found
|
||||||
* or an I/O error occurred.
|
* or an I/O error occurred.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::remove(SdBaseFile* dirFile, const char *path) {
|
bool SdBaseFile::remove(SdBaseFile *dirFile, const char *path) {
|
||||||
if (ENABLED(SDCARD_READONLY)) return false;
|
if (ENABLED(SDCARD_READONLY)) return false;
|
||||||
|
|
||||||
SdBaseFile file;
|
SdBaseFile file;
|
||||||
@ -1252,13 +1241,10 @@ bool SdBaseFile::remove(SdBaseFile* dirFile, const char *path) {
|
|||||||
* Reasons for failure include \a dirFile is not open or is not a directory
|
* Reasons for failure include \a dirFile is not open or is not a directory
|
||||||
* file, newPath is invalid or already exists, or an I/O error occurs.
|
* file, newPath is invalid or already exists, or an I/O error occurs.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::rename(SdBaseFile* dirFile, const char *newPath) {
|
bool SdBaseFile::rename(SdBaseFile *dirFile, const char *newPath) {
|
||||||
if (ENABLED(SDCARD_READONLY)) return false;
|
if (ENABLED(SDCARD_READONLY)) return false;
|
||||||
|
|
||||||
dir_t entry;
|
|
||||||
uint32_t dirCluster = 0;
|
uint32_t dirCluster = 0;
|
||||||
SdBaseFile file;
|
|
||||||
dir_t *d;
|
|
||||||
|
|
||||||
// must be an open file or subdirectory
|
// must be an open file or subdirectory
|
||||||
if (!(isFile() || isSubDir())) return false;
|
if (!(isFile() || isSubDir())) return false;
|
||||||
@ -1268,16 +1254,18 @@ bool SdBaseFile::rename(SdBaseFile* dirFile, const char *newPath) {
|
|||||||
|
|
||||||
// sync() and cache directory entry
|
// sync() and cache directory entry
|
||||||
sync();
|
sync();
|
||||||
d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
||||||
if (!d) return false;
|
if (!d) return false;
|
||||||
|
|
||||||
// save directory entry
|
// save directory entry
|
||||||
|
dir_t entry;
|
||||||
memcpy(&entry, d, sizeof(entry));
|
memcpy(&entry, d, sizeof(entry));
|
||||||
|
|
||||||
// mark entry deleted
|
// mark entry deleted
|
||||||
d->name[0] = DIR_NAME_DELETED;
|
d->name[0] = DIR_NAME_DELETED;
|
||||||
|
|
||||||
// make directory entry for new path
|
// make directory entry for new path
|
||||||
|
SdBaseFile file;
|
||||||
if (isFile()) {
|
if (isFile()) {
|
||||||
if (!file.open(dirFile, newPath, O_CREAT | O_EXCL | O_WRITE)) {
|
if (!file.open(dirFile, newPath, O_CREAT | O_EXCL | O_WRITE)) {
|
||||||
goto restore;
|
goto restore;
|
||||||
@ -1536,8 +1524,7 @@ bool SdBaseFile::sync() {
|
|||||||
*
|
*
|
||||||
* \return true for success, false for failure.
|
* \return true for success, false for failure.
|
||||||
*/
|
*/
|
||||||
bool SdBaseFile::timestamp(SdBaseFile* file) {
|
bool SdBaseFile::timestamp(SdBaseFile *file) {
|
||||||
dir_t *d;
|
|
||||||
dir_t dir;
|
dir_t dir;
|
||||||
|
|
||||||
// get timestamps
|
// get timestamps
|
||||||
@ -1546,7 +1533,7 @@ bool SdBaseFile::timestamp(SdBaseFile* file) {
|
|||||||
// update directory fields
|
// update directory fields
|
||||||
if (!sync()) return false;
|
if (!sync()) return false;
|
||||||
|
|
||||||
d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
||||||
if (!d) return false;
|
if (!d) return false;
|
||||||
|
|
||||||
// copy timestamps
|
// copy timestamps
|
||||||
@ -1599,7 +1586,6 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month,
|
|||||||
if (ENABLED(SDCARD_READONLY)) return false;
|
if (ENABLED(SDCARD_READONLY)) return false;
|
||||||
|
|
||||||
uint16_t dirDate, dirTime;
|
uint16_t dirDate, dirTime;
|
||||||
dir_t *d;
|
|
||||||
|
|
||||||
if (!isOpen()
|
if (!isOpen()
|
||||||
|| year < 1980
|
|| year < 1980
|
||||||
@ -1616,7 +1602,7 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month,
|
|||||||
// update directory entry
|
// update directory entry
|
||||||
if (!sync()) return false;
|
if (!sync()) return false;
|
||||||
|
|
||||||
d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
||||||
if (!d) return false;
|
if (!d) return false;
|
||||||
|
|
||||||
dirDate = FAT_DATE(year, month, day);
|
dirDate = FAT_DATE(year, month, day);
|
||||||
@ -1710,7 +1696,7 @@ bool SdBaseFile::truncate(uint32_t length) {
|
|||||||
* include write() is called before a file has been opened, write is called
|
* include write() is called before a file has been opened, write is called
|
||||||
* for a read-only file, device is full, a corrupt file system or an I/O error.
|
* for a read-only file, device is full, a corrupt file system or an I/O error.
|
||||||
*/
|
*/
|
||||||
int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
|
int16_t SdBaseFile::write(const void *buf, uint16_t nbyte) {
|
||||||
#if ENABLED(SDCARD_READONLY)
|
#if ENABLED(SDCARD_READONLY)
|
||||||
writeError = true; return -1;
|
writeError = true; return -1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -189,7 +189,7 @@ class SdBaseFile {
|
|||||||
|
|
||||||
bool close();
|
bool close();
|
||||||
bool contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock);
|
bool contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock);
|
||||||
bool createContiguous(SdBaseFile* dirFile,
|
bool createContiguous(SdBaseFile *dirFile,
|
||||||
const char *path, uint32_t size);
|
const char *path, uint32_t size);
|
||||||
/**
|
/**
|
||||||
* \return The current cluster number for a file or directory.
|
* \return The current cluster number for a file or directory.
|
||||||
@ -204,7 +204,7 @@ class SdBaseFile {
|
|||||||
/**
|
/**
|
||||||
* \return Current working directory
|
* \return Current working directory
|
||||||
*/
|
*/
|
||||||
static SdBaseFile* cwd() { return cwd_; }
|
static SdBaseFile *cwd() { return cwd_; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the date/time callback function
|
* Set the date/time callback function
|
||||||
@ -286,27 +286,27 @@ class SdBaseFile {
|
|||||||
bool getDosName(char * const name);
|
bool getDosName(char * const name);
|
||||||
void ls(uint8_t flags = 0, uint8_t indent = 0);
|
void ls(uint8_t flags = 0, uint8_t indent = 0);
|
||||||
|
|
||||||
bool mkdir(SdBaseFile* dir, const char *path, bool pFlag = true);
|
bool mkdir(SdBaseFile *dir, const char *path, bool pFlag = true);
|
||||||
bool open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag);
|
bool open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag);
|
||||||
bool open(SdBaseFile* dirFile, const char *path, uint8_t oflag);
|
bool open(SdBaseFile *dirFile, const char *path, uint8_t oflag);
|
||||||
bool open(const char *path, uint8_t oflag = O_READ);
|
bool open(const char *path, uint8_t oflag = O_READ);
|
||||||
bool openNext(SdBaseFile* dirFile, uint8_t oflag);
|
bool openNext(SdBaseFile *dirFile, uint8_t oflag);
|
||||||
bool openRoot(SdVolume* vol);
|
bool openRoot(SdVolume *vol);
|
||||||
int peek();
|
int peek();
|
||||||
static void printFatDate(uint16_t fatDate);
|
static void printFatDate(uint16_t fatDate);
|
||||||
static void printFatTime(uint16_t fatTime);
|
static void printFatTime(uint16_t fatTime);
|
||||||
bool printName();
|
bool printName();
|
||||||
int16_t read();
|
int16_t read();
|
||||||
int16_t read(void* buf, uint16_t nbyte);
|
int16_t read(void *buf, uint16_t nbyte);
|
||||||
int8_t readDir(dir_t *dir, char *longFilename);
|
int8_t readDir(dir_t *dir, char *longFilename);
|
||||||
static bool remove(SdBaseFile* dirFile, const char *path);
|
static bool remove(SdBaseFile *dirFile, const char *path);
|
||||||
bool remove();
|
bool remove();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the file's current position to zero.
|
* Set the file's current position to zero.
|
||||||
*/
|
*/
|
||||||
void rewind() { seekSet(0); }
|
void rewind() { seekSet(0); }
|
||||||
bool rename(SdBaseFile* dirFile, const char *newPath);
|
bool rename(SdBaseFile *dirFile, const char *newPath);
|
||||||
bool rmdir();
|
bool rmdir();
|
||||||
bool rmRfStar();
|
bool rmRfStar();
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ class SdBaseFile {
|
|||||||
bool seekEnd(const int32_t offset = 0) { return seekSet(fileSize_ + offset); }
|
bool seekEnd(const int32_t offset = 0) { return seekSet(fileSize_ + offset); }
|
||||||
bool seekSet(const uint32_t pos);
|
bool seekSet(const uint32_t pos);
|
||||||
bool sync();
|
bool sync();
|
||||||
bool timestamp(SdBaseFile* file);
|
bool timestamp(SdBaseFile *file);
|
||||||
bool timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day,
|
bool timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day,
|
||||||
uint8_t hour, uint8_t minute, uint8_t second);
|
uint8_t hour, uint8_t minute, uint8_t second);
|
||||||
|
|
||||||
@ -341,11 +341,11 @@ class SdBaseFile {
|
|||||||
* \return SdVolume that contains this file.
|
* \return SdVolume that contains this file.
|
||||||
*/
|
*/
|
||||||
SdVolume* volume() const { return vol_; }
|
SdVolume* volume() const { return vol_; }
|
||||||
int16_t write(const void* buf, uint16_t nbyte);
|
int16_t write(const void *buf, uint16_t nbyte);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SdFat; // allow SdFat to set cwd_
|
friend class SdFat; // allow SdFat to set cwd_
|
||||||
static SdBaseFile* cwd_; // global pointer to cwd dir
|
static SdBaseFile *cwd_; // global pointer to cwd dir
|
||||||
|
|
||||||
// data time callback function
|
// data time callback function
|
||||||
static void (*dateTime_)(uint16_t *date, uint16_t *time);
|
static void (*dateTime_)(uint16_t *date, uint16_t *time);
|
||||||
@ -364,21 +364,21 @@ class SdBaseFile {
|
|||||||
uint8_t dirIndex_; // index of directory entry in dirBlock
|
uint8_t dirIndex_; // index of directory entry in dirBlock
|
||||||
uint32_t fileSize_; // file size in bytes
|
uint32_t fileSize_; // file size in bytes
|
||||||
uint32_t firstCluster_; // first cluster of file
|
uint32_t firstCluster_; // first cluster of file
|
||||||
SdVolume* vol_; // volume where file is located
|
SdVolume *vol_; // volume where file is located
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EXPERIMENTAL - Don't use!
|
* EXPERIMENTAL - Don't use!
|
||||||
*/
|
*/
|
||||||
//bool openParent(SdBaseFile* dir);
|
//bool openParent(SdBaseFile *dir);
|
||||||
|
|
||||||
// private functions
|
// private functions
|
||||||
bool addCluster();
|
bool addCluster();
|
||||||
bool addDirCluster();
|
bool addDirCluster();
|
||||||
dir_t* cacheDirEntry(uint8_t action);
|
dir_t* cacheDirEntry(uint8_t action);
|
||||||
int8_t lsPrintNext(uint8_t flags, uint8_t indent);
|
int8_t lsPrintNext(uint8_t flags, uint8_t indent);
|
||||||
static bool make83Name(const char *str, uint8_t *name, const char** ptr);
|
static bool make83Name(const char *str, uint8_t *name, const char **ptr);
|
||||||
bool mkdir(SdBaseFile* parent, const uint8_t dname[11]);
|
bool mkdir(SdBaseFile *parent, const uint8_t dname[11]);
|
||||||
bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag);
|
bool open(SdBaseFile *dirFile, const uint8_t dname[11], uint8_t oflag);
|
||||||
bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags);
|
bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags);
|
||||||
dir_t* readDirCache();
|
dir_t* readDirCache();
|
||||||
};
|
};
|
||||||
|
@ -60,7 +60,7 @@ SdFile::SdFile(const char *path, uint8_t oflag) : SdBaseFile(path, oflag) { }
|
|||||||
* include write() is called before a file has been opened, write is called
|
* include write() is called before a file has been opened, write is called
|
||||||
* for a read-only file, device is full, a corrupt file system or an I/O error.
|
* for a read-only file, device is full, a corrupt file system or an I/O error.
|
||||||
*/
|
*/
|
||||||
int16_t SdFile::write(const void* buf, uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); }
|
int16_t SdFile::write(const void *buf, uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a byte to a file. Required by the Arduino Print class.
|
* Write a byte to a file. Required by the Arduino Print class.
|
||||||
|
@ -49,7 +49,7 @@ class SdFile : public SdBaseFile {
|
|||||||
void write(uint8_t b);
|
void write(uint8_t b);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t write(const void* buf, uint16_t nbyte);
|
int16_t write(const void *buf, uint16_t nbyte);
|
||||||
void write(const char *str);
|
void write(const char *str);
|
||||||
void write_P(PGM_P str);
|
void write_P(PGM_P str);
|
||||||
void writeln_P(PGM_P str);
|
void writeln_P(PGM_P str);
|
||||||
|
@ -90,8 +90,8 @@ class SdVolume {
|
|||||||
* Reasons for failure include not finding a valid partition, not finding
|
* Reasons for failure include not finding a valid partition, not finding
|
||||||
* a valid FAT file system or an I/O error.
|
* a valid FAT file system or an I/O error.
|
||||||
*/
|
*/
|
||||||
bool init(Sd2Card* dev) { return init(dev, 1) ? true : init(dev, 0); }
|
bool init(Sd2Card *dev) { return init(dev, 1) ? true : init(dev, 0); }
|
||||||
bool init(Sd2Card* dev, uint8_t part);
|
bool init(Sd2Card *dev, uint8_t part);
|
||||||
|
|
||||||
// inline functions that return volume info
|
// inline functions that return volume info
|
||||||
uint8_t blocksPerCluster() const { return blocksPerCluster_; } //> \return The volume's cluster size in blocks.
|
uint8_t blocksPerCluster() const { return blocksPerCluster_; } //> \return The volume's cluster size in blocks.
|
||||||
@ -138,13 +138,13 @@ class SdVolume {
|
|||||||
#if USE_MULTIPLE_CARDS
|
#if USE_MULTIPLE_CARDS
|
||||||
cache_t cacheBuffer_; // 512 byte cache for device blocks
|
cache_t cacheBuffer_; // 512 byte cache for device blocks
|
||||||
uint32_t cacheBlockNumber_; // Logical number of block in the cache
|
uint32_t cacheBlockNumber_; // Logical number of block in the cache
|
||||||
Sd2Card* sdCard_; // Sd2Card object for cache
|
Sd2Card *sdCard_; // Sd2Card object for cache
|
||||||
bool cacheDirty_; // cacheFlush() will write block if true
|
bool cacheDirty_; // cacheFlush() will write block if true
|
||||||
uint32_t cacheMirrorBlock_; // block number for mirror FAT
|
uint32_t cacheMirrorBlock_; // block number for mirror FAT
|
||||||
#else
|
#else
|
||||||
static cache_t cacheBuffer_; // 512 byte cache for device blocks
|
static cache_t cacheBuffer_; // 512 byte cache for device blocks
|
||||||
static uint32_t cacheBlockNumber_; // Logical number of block in the cache
|
static uint32_t cacheBlockNumber_; // Logical number of block in the cache
|
||||||
static Sd2Card* sdCard_; // Sd2Card object for cache
|
static Sd2Card *sdCard_; // Sd2Card object for cache
|
||||||
static bool cacheDirty_; // cacheFlush() will write block if true
|
static bool cacheDirty_; // cacheFlush() will write block if true
|
||||||
static uint32_t cacheMirrorBlock_; // block number for mirror FAT
|
static uint32_t cacheMirrorBlock_; // block number for mirror FAT
|
||||||
#endif
|
#endif
|
||||||
|
@ -723,9 +723,9 @@ void CardReader::report_status() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CardReader::write_command(char * const buf) {
|
void CardReader::write_command(char * const buf) {
|
||||||
char* begin = buf;
|
char *begin = buf;
|
||||||
char* npos = nullptr;
|
char *npos = nullptr;
|
||||||
char* end = buf + strlen(buf) - 1;
|
char *end = buf + strlen(buf) - 1;
|
||||||
|
|
||||||
file.writeError = false;
|
file.writeError = false;
|
||||||
if ((npos = strchr(buf, 'N'))) {
|
if ((npos = strchr(buf, 'N'))) {
|
||||||
@ -845,7 +845,7 @@ uint16_t CardReader::countFilesInWorkDir() {
|
|||||||
*
|
*
|
||||||
* A nullptr result indicates an unrecoverable error.
|
* A nullptr result indicates an unrecoverable error.
|
||||||
*/
|
*/
|
||||||
const char* CardReader::diveToFile(const bool update_cwd, SdFile*& diveDir, const char * const path, const bool echo/*=false*/) {
|
const char* CardReader::diveToFile(const bool update_cwd, SdFile* &diveDir, const char * const path, const bool echo/*=false*/) {
|
||||||
// Track both parent and subfolder
|
// Track both parent and subfolder
|
||||||
static SdFile newDir1, newDir2;
|
static SdFile newDir1, newDir2;
|
||||||
SdFile *sub = &newDir1, *startDir;
|
SdFile *sub = &newDir1, *startDir;
|
||||||
|
@ -141,7 +141,7 @@ public:
|
|||||||
static inline uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
|
static inline uint8_t percentDone() { return (isFileOpen() && filesize) ? sdpos / ((filesize + 99) / 100) : 0; }
|
||||||
|
|
||||||
// Helper for open and remove
|
// Helper for open and remove
|
||||||
static const char* diveToFile(const bool update_cwd, SdFile*& curDir, const char * const path, const bool echo=false);
|
static const char* diveToFile(const bool update_cwd, SdFile* &curDir, const char * const path, const bool echo=false);
|
||||||
|
|
||||||
#if ENABLED(SDCARD_SORT_ALPHA)
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
||||||
static void presort();
|
static void presort();
|
||||||
@ -168,8 +168,8 @@ public:
|
|||||||
static inline void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); }
|
static inline void setIndex(const uint32_t index) { file.seekSet((sdpos = index)); }
|
||||||
static inline char* getWorkDirName() { workDir.getDosName(filename); return filename; }
|
static inline char* getWorkDirName() { workDir.getDosName(filename); return filename; }
|
||||||
static inline int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; }
|
static inline int16_t get() { int16_t out = (int16_t)file.read(); sdpos = file.curPosition(); return out; }
|
||||||
static inline int16_t read(void* buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
|
static inline int16_t read(void *buf, uint16_t nbyte) { return file.isOpen() ? file.read(buf, nbyte) : -1; }
|
||||||
static inline int16_t write(void* buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
|
static inline int16_t write(void *buf, uint16_t nbyte) { return file.isOpen() ? file.write(buf, nbyte) : -1; }
|
||||||
|
|
||||||
static Sd2Card& getSd2Card() { return sd2card; }
|
static Sd2Card& getSd2Card() { return sd2card; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user