diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 19aaedf7c65df..d2a9f395b7068 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -782,7 +782,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { * - Update the Průša MMU2 * - Handle Joystick jogging */ -void idle(bool no_stepper_sleep/*=false*/) { +void idle(const bool no_stepper_sleep/*=false*/) { #ifdef MAX7219_DEBUG_PROFILE CodeProfiler idle_profiler; #endif diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index f80405a302ee1..e9c63bb31f353 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -30,7 +30,7 @@ void stop(); // Pass true to keep steppers from timing out -void idle(bool no_stepper_sleep=false); +void idle(const bool no_stepper_sleep=false); inline void idle_no_sleep() { idle(true); } #if ENABLED(G38_PROBE_TARGET) diff --git a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp index 6508f6f02473d..43149dc60c586 100644 --- a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp +++ b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp @@ -148,7 +148,7 @@ uint32_t SPIFlashStorage::m_startAddress; #endif // HAS_SPI_FLASH_COMPRESSION -void SPIFlashStorage::beginWrite(uint32_t startAddress) { +void SPIFlashStorage::beginWrite(const uint32_t startAddress) { m_pageDataUsed = 0; m_currentPage = 0; m_startAddress = startAddress; @@ -171,7 +171,7 @@ void SPIFlashStorage::endWrite() { #endif } -void SPIFlashStorage::savePage(uint8_t *buffer) { +void SPIFlashStorage::savePage(uint8_t * const buffer) { W25QXX.SPI_FLASH_BufferWrite(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize); // Test env // char fname[256]; @@ -181,7 +181,7 @@ void SPIFlashStorage::savePage(uint8_t *buffer) { // fclose(fp); } -void SPIFlashStorage::loadPage(uint8_t *buffer) { +void SPIFlashStorage::loadPage(uint8_t * const buffer) { W25QXX.SPI_FLASH_BufferRead(buffer, m_startAddress + (SPI_FLASH_PageSize * m_currentPage), SPI_FLASH_PageSize); // Test env // char fname[256]; @@ -260,7 +260,7 @@ void SPIFlashStorage::readPage() { #endif } -uint16_t SPIFlashStorage::inData(uint8_t *data, uint16_t size) { +uint16_t SPIFlashStorage::inData(const uint8_t * const data, uint16_t size) { // Don't write more than we can NOMORE(size, pageDataFree()); memcpy(m_pageData + m_pageDataUsed, data, size); @@ -268,12 +268,12 @@ uint16_t SPIFlashStorage::inData(uint8_t *data, uint16_t size) { return size; } -void SPIFlashStorage::writeData(uint8_t *data, uint16_t size) { +void SPIFlashStorage::writeData(const uint8_t *data, uint16_t size) { // Flush a page if needed if (pageDataFree() == 0) flushPage(); while (size > 0) { - uint16_t written = inData(data, size); + const uint16_t written = inData(data, size); size -= written; // Need to write more? Flush page and continue! if (size > 0) { @@ -283,7 +283,7 @@ void SPIFlashStorage::writeData(uint8_t *data, uint16_t size) { } } -void SPIFlashStorage::beginRead(uint32_t startAddress) { +void SPIFlashStorage::beginRead(const uint32_t startAddress) { m_startAddress = startAddress; m_currentPage = 0; // Nothing in memory now @@ -293,7 +293,7 @@ void SPIFlashStorage::beginRead(uint32_t startAddress) { #endif } -uint16_t SPIFlashStorage::outData(uint8_t *data, uint16_t size) { +uint16_t SPIFlashStorage::outData(uint8_t * const data, uint16_t size) { // Don't read more than we have NOMORE(size, pageDataFree()); memcpy(data, m_pageData + m_pageDataUsed, size); @@ -306,7 +306,7 @@ void SPIFlashStorage::readData(uint8_t *data, uint16_t size) { if (pageDataFree() == 0) readPage(); while (size > 0) { - uint16_t read = outData(data, size); + const uint16_t read = outData(data, size); size -= read; // Need to write more? Flush page and continue! if (size > 0) { diff --git a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h index 72394286ac58b..bd7109b7acbd4 100644 --- a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h +++ b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.h @@ -75,23 +75,23 @@ class SPIFlashStorage { public: // Write operation - static void beginWrite(uint32_t startAddress); + static void beginWrite(const uint32_t startAddress); static void endWrite(); - static void writeData(uint8_t *data, uint16_t size); + static void writeData(const uint8_t *data, uint16_t size); // Read operation - static void beginRead(uint32_t startAddress); + static void beginRead(const uint32_t startAddress); static void readData(uint8_t *data, uint16_t size); static uint32_t getCurrentPage() { return m_currentPage; } private: static void flushPage(); - static void savePage(uint8_t *buffer); - static void loadPage(uint8_t *buffer); + static void savePage(uint8_t * const buffer); + static void loadPage(uint8_t * const buffer); static void readPage(); - static uint16_t inData(uint8_t *data, uint16_t size); - static uint16_t outData(uint8_t *data, uint16_t size); + static uint16_t inData(const uint8_t * const data, uint16_t size); + static uint16_t outData(uint8_t * const data, uint16_t size); static uint8_t m_pageData[SPI_FLASH_PageSize]; static uint32_t m_currentPage; diff --git a/Marlin/src/sd/Sd2Card.cpp b/Marlin/src/sd/Sd2Card.cpp index 2d84c95a3d195..81cc03230483a 100644 --- a/Marlin/src/sd/Sd2Card.cpp +++ b/Marlin/src/sd/Sd2Card.cpp @@ -345,7 +345,7 @@ bool DiskIODriver_SPI_SD::init(const uint8_t sckRateID, const pin_t chipSelectPi * \param[out] dst Pointer to the location that will receive the data. * \return true for success, false for failure. */ -bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t *dst) { +bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t * const dst) { #if IS_TEENSY_35_36 || IS_TEENSY_40_41 return 0 == SDHC_CardReadBlock(dst, blockNumber); #endif @@ -385,7 +385,7 @@ bool DiskIODriver_SPI_SD::readBlock(uint32_t blockNumber, uint8_t *dst) { * * \return true for success, false for failure. */ -bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { +bool DiskIODriver_SPI_SD::readData(uint8_t * const dst) { chipSelect(); return readData(dst, 512); } @@ -455,7 +455,7 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst) { #endif // SD_CHECK_AND_RETRY -bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) { +bool DiskIODriver_SPI_SD::readData(uint8_t * const dst, const uint16_t count) { bool success = false; const millis_t read_timeout = millis() + SD_READ_TIMEOUT; @@ -487,8 +487,8 @@ bool DiskIODriver_SPI_SD::readData(uint8_t *dst, const uint16_t count) { } /** read CID or CSR register */ -bool DiskIODriver_SPI_SD::readRegister(const uint8_t cmd, void *buf) { - uint8_t *dst = reinterpret_cast(buf); +bool DiskIODriver_SPI_SD::readRegister(const uint8_t cmd, void * const buf) { + uint8_t * const dst = reinterpret_cast(buf); if (cardCommand(cmd, 0)) { error(SD_CARD_ERROR_READ_REG); chipDeselect(); @@ -567,7 +567,7 @@ void DiskIODriver_SPI_SD::error(const uint8_t code) { errorCode_ = code; } * \param[in] src Pointer to the location of the data to be written. * \return true for success, false for failure. */ -bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t *src) { +bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t * const src) { if (ENABLED(SDCARD_READONLY)) return false; #if IS_TEENSY_35_36 || IS_TEENSY_40_41 @@ -598,7 +598,7 @@ bool DiskIODriver_SPI_SD::writeBlock(uint32_t blockNumber, const uint8_t *src) { * \param[in] src Pointer to the location of the data to be written. * \return true for success, false for failure. */ -bool DiskIODriver_SPI_SD::writeData(const uint8_t *src) { +bool DiskIODriver_SPI_SD::writeData(const uint8_t * const src) { if (ENABLED(SDCARD_READONLY)) return false; bool success = true; @@ -613,7 +613,7 @@ bool DiskIODriver_SPI_SD::writeData(const uint8_t *src) { } // Send one block of data for write block or write multiple blocks -bool DiskIODriver_SPI_SD::writeData(const uint8_t token, const uint8_t *src) { +bool DiskIODriver_SPI_SD::writeData(const uint8_t token, const uint8_t * const src) { if (ENABLED(SDCARD_READONLY)) return false; const uint16_t crc = TERN(SD_CHECK_AND_RETRY, CRC_CCITT(src, 512), 0xFFFF); diff --git a/Marlin/src/sd/Sd2Card.h b/Marlin/src/sd/Sd2Card.h index e0dce02a02365..23677b24fa4bd 100644 --- a/Marlin/src/sd/Sd2Card.h +++ b/Marlin/src/sd/Sd2Card.h @@ -143,7 +143,7 @@ class DiskIODriver_SPI_SD : public DiskIODriver { * * \return true for success or false for failure. */ - bool readCID(cid_t *cid) { return readRegister(CMD10, cid); } + bool readCID(cid_t * const cid) { return readRegister(CMD10, cid); } /** * Read a card's CSD register. The CSD contains Card-Specific Data that @@ -153,18 +153,18 @@ class DiskIODriver_SPI_SD : public DiskIODriver { * * \return true for success or false for failure. */ - inline bool readCSD(csd_t *csd) override { return readRegister(CMD9, csd); } + inline bool readCSD(csd_t * const csd) override { return readRegister(CMD9, csd); } - bool readData(uint8_t *dst) override; + bool readData(uint8_t * const dst) override; bool readStart(uint32_t blockNumber) override; bool readStop() override; - bool writeData(const uint8_t *src) override; - bool writeStart(const uint32_t blockNumber, const uint32_t eraseCount) override; + bool writeData(const uint8_t * const src) override; + bool writeStart(uint32_t blockNumber, const uint32_t eraseCount) override; bool writeStop() override; - bool readBlock(uint32_t block, uint8_t *dst) override; - bool writeBlock(uint32_t blockNumber, const uint8_t *src) override; + bool readBlock(uint32_t blockNumber, uint8_t * const dst) override; + bool writeBlock(uint32_t blockNumber, const uint8_t * const src) override; uint32_t cardSize() override; @@ -187,11 +187,11 @@ class DiskIODriver_SPI_SD : public DiskIODriver { } uint8_t cardCommand(const uint8_t cmd, const uint32_t arg); - bool readData(uint8_t *dst, const uint16_t count); - bool readRegister(const uint8_t cmd, void *buf); + bool readData(uint8_t * const dst, const uint16_t count); + bool readRegister(const uint8_t cmd, void * const buf); void chipDeselect(); void chipSelect(); inline void type(const uint8_t value) { type_ = value; } bool waitNotBusy(const millis_t timeout_ms); - bool writeData(const uint8_t token, const uint8_t *src); + bool writeData(const uint8_t token, const uint8_t * const src); }; diff --git a/Marlin/src/sd/SdBaseFile.cpp b/Marlin/src/sd/SdBaseFile.cpp index 818f0dcb37373..4f4a8e9fa992e 100644 --- a/Marlin/src/sd/SdBaseFile.cpp +++ b/Marlin/src/sd/SdBaseFile.cpp @@ -91,7 +91,7 @@ bool SdBaseFile::addDirCluster() { // cache a file's directory entry // cache the current "dirBlock_" and return the entry at index "dirIndex_" // return pointer to cached entry or null for failure -dir_t* SdBaseFile::cacheDirEntry(uint8_t action) { +dir_t* SdBaseFile::cacheDirEntry(const uint8_t action) { if (!vol_->cacheRawBlock(dirBlock_, action)) return nullptr; return vol_->cache()->dir + dirIndex_; } @@ -119,7 +119,7 @@ bool SdBaseFile::close() { * Reasons for failure include file is not contiguous, file has zero length * or an I/O error occurred. */ -bool SdBaseFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock) { +bool SdBaseFile::contiguousRange(uint32_t * const bgnBlock, uint32_t * const endBlock) { // error if no blocks if (firstCluster_ == 0) return false; @@ -156,7 +156,7 @@ bool SdBaseFile::contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock) { * a file is already open, the file already exists, the root * directory is full or an I/O error. */ -bool SdBaseFile::createContiguous(SdBaseFile *dirFile, const char *path, uint32_t size) { +bool SdBaseFile::createContiguous(SdBaseFile * const dirFile, const char * const path, const uint32_t size) { if (ENABLED(SDCARD_READONLY)) return false; uint32_t count; @@ -301,7 +301,7 @@ bool SdBaseFile::getDosName(char * const name) { return true; } -void SdBaseFile::getpos(filepos_t *pos) { +void SdBaseFile::getpos(filepos_t * const pos) { pos->position = curPosition_; pos->cluster = curCluster_; } @@ -337,7 +337,7 @@ void SdBaseFile::ls(uint8_t flags, uint8_t indent) { // saves 32 bytes on stack for ls recursion // return 0 - EOF, 1 - normal file, or 2 - directory -int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) { +int8_t SdBaseFile::lsPrintNext(const uint8_t flags, const uint8_t indent) { dir_t dir; uint8_t w = 0; @@ -400,7 +400,7 @@ uint8_t lfn_checksum(const uint8_t *name) { } // 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 * const name, const char **ptr) { uint8_t n = 7, // Max index until a dot is found i = 11; while (i) name[--i] = ' '; // Set whole FILENAME.EXT to spaces @@ -437,13 +437,11 @@ 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 * 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, const bool pFlag/*=true*/) { if (ENABLED(SDCARD_READONLY)) return false; - uint8_t dname[11]; - SdBaseFile dir1, dir2; - SdBaseFile *sub = &dir1; - SdBaseFile *start = parent; + SdBaseFile dir1, dir2, *sub = &dir1; + SdBaseFile * const start = parent; #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) uint8_t dlname[LONG_FILENAME_LENGTH]; @@ -459,6 +457,7 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { } } + uint8_t dname[11]; for (;;) { if (!TERN(LONG_FILENAME_WRITE_SUPPORT, parsePath(path, dname, dlname, &path), make83Name(path, dname, &path))) return false; while (*path == '/') path++; @@ -474,7 +473,7 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const char *path, bool pFlag) { return mkdir(parent, dname OPTARG(LONG_FILENAME_WRITE_SUPPORT, dlname)); } -bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11] +bool SdBaseFile::mkdir(SdBaseFile * const parent, const uint8_t dname[11] OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) ) { if (ENABLED(SDCARD_READONLY)) return false; @@ -541,7 +540,7 @@ bool SdBaseFile::mkdir(SdBaseFile *parent, const uint8_t dname[11] * * \return true for success, false for failure. */ -bool SdBaseFile::open(const char *path, uint8_t oflag) { +bool SdBaseFile::open(const char * const path, const uint8_t oflag) { return open(cwd_, path, oflag); } @@ -595,7 +594,7 @@ bool SdBaseFile::open(const char *path, uint8_t oflag) { * a directory, \a path is invalid, the file does not exist * 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 * const dirFile, const char *path, const uint8_t oflag) { uint8_t dname[11]; SdBaseFile dir1, dir2; SdBaseFile *parent = dirFile, *sub = &dir1; @@ -627,9 +626,9 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const char *path, uint8_t oflag) { } // open with filename in dname and long filename in dlname -bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11] +bool SdBaseFile::open(SdBaseFile * const dirFile, const uint8_t dname[11] OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) - , uint8_t oflag + , const uint8_t oflag ) { bool emptyFound = false, fileFound = false; uint8_t index = 0; @@ -876,7 +875,7 @@ bool SdBaseFile::open(SdBaseFile *dirFile, const uint8_t dname[11] * See open() by path for definition of flags. * \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, const uint8_t oflag) { vol_ = dirFile->vol_; // error if already open @@ -902,7 +901,7 @@ bool SdBaseFile::open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag) { } // open a cached directory entry. Assumes vol_ is initialized -bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) { +bool SdBaseFile::openCachedEntry(const uint8_t dirIndex, const uint8_t oflag) { dir_t *p; #if ENABLED(SDCARD_READONLY) @@ -962,7 +961,7 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) { * See open() by path for definition of flags. * \return true for success or false for failure. */ -bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { +bool SdBaseFile::openNext(SdBaseFile *dirFile, const uint8_t oflag) { if (!dirFile) return false; // error if already open @@ -1017,7 +1016,7 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { * \return true if the dirname is a long file name (LFN) * \return false if the dirname is a short file name 8.3 (SFN) */ - bool SdBaseFile::isDirNameLFN(const char *dirname) { + bool SdBaseFile::isDirNameLFN(const char * const dirname) { uint8_t length = strlen(dirname), idx = length; bool dotFound = false; if (idx > 12) return true; // LFN due to filename length > 12 ("filename.ext") @@ -1048,7 +1047,7 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { * The SFN is without dot ("FILENAMEEXT") * The LFN is complete ("Filename.ext") */ - bool SdBaseFile::parsePath(const char *path, uint8_t *name, uint8_t *lname, const char **ptrNextPath) { + bool SdBaseFile::parsePath(const char *path, uint8_t * const name, uint8_t * const lname, const char **ptrNextPath) { // Init randomizer for SFN generation randomSeed(millis()); // Parse the LFN @@ -1136,7 +1135,7 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { /** * Get the LFN filename block from a dir. Get the block in lname at startOffset */ - void SdBaseFile::getLFNName(vfat_t *pFatDir, char *lname, uint8_t sequenceNumber) { + void SdBaseFile::getLFNName(vfat_t *pFatDir, char *lname, const uint8_t sequenceNumber) { const uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH; LOOP_L_N(i, FILENAME_LENGTH) { const uint16_t utf16_ch = (i >= 11) ? pFatDir->name3[i - 11] : (i >= 5) ? pFatDir->name2[i - 5] : pFatDir->name1[i]; @@ -1156,7 +1155,7 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) { /** * Set the LFN filename block lname to a dir. Put the block based on sequence number */ - void SdBaseFile::setLFNName(vfat_t *pFatDir, char *lname, uint8_t sequenceNumber) { + void SdBaseFile::setLFNName(vfat_t *pFatDir, char *lname, const uint8_t sequenceNumber) { const uint8_t startOffset = (sequenceNumber - 1) * FILENAME_LENGTH, nameLength = strlen(lname); LOOP_L_N(i, FILENAME_LENGTH) { @@ -1305,7 +1304,7 @@ static void print2u(const uint8_t v) { * \param[in] pr Print stream for output. * \param[in] fatDate The date field from a directory entry. */ -void SdBaseFile::printFatDate(uint16_t fatDate) { +void SdBaseFile::printFatDate(const uint16_t fatDate) { SERIAL_ECHO(FAT_YEAR(fatDate)); SERIAL_CHAR('-'); print2u(FAT_MONTH(fatDate)); @@ -1322,7 +1321,7 @@ void SdBaseFile::printFatDate(uint16_t fatDate) { * \param[in] pr Print stream for output. * \param[in] fatTime The time field from a directory entry. */ -void SdBaseFile::printFatTime(uint16_t fatTime) { +void SdBaseFile::printFatTime(const uint16_t fatTime) { print2u(FAT_HOUR(fatTime)); SERIAL_CHAR(':'); print2u(FAT_MINUTE(fatTime)); @@ -1367,7 +1366,7 @@ int16_t SdBaseFile::read() { * read() called before a file has been opened, corrupt file system * or an I/O error occurred. */ -int16_t SdBaseFile::read(void *buf, uint16_t nbyte) { +int16_t SdBaseFile::read(void * const buf, uint16_t nbyte) { uint8_t *dst = reinterpret_cast(buf); uint16_t offset, toRead; uint32_t block; // raw device block number @@ -1429,7 +1428,7 @@ int16_t SdBaseFile::read(void *buf, uint16_t nbyte) { * readDir() called before a directory has been opened, this is not * a directory file or an I/O error occurred. */ -int8_t SdBaseFile::readDir(dir_t *dir, char * const longFilename) { +int8_t SdBaseFile::readDir(dir_t * const dir, char * const longFilename) { int16_t n; // if not a directory file or miss-positioned return an error if (!isDir() || (0x1F & curPosition_)) return -1; @@ -1676,7 +1675,7 @@ bool SdBaseFile::remove() { * \a dirFile is not a directory, \a path is not found * or an I/O error occurred. */ -bool SdBaseFile::remove(SdBaseFile *dirFile, const char *path) { +bool SdBaseFile::remove(SdBaseFile * const dirFile, const char * const path) { if (ENABLED(SDCARD_READONLY)) return false; SdBaseFile file; @@ -1715,7 +1714,7 @@ bool SdBaseFile::hide(const bool hidden) { * 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. */ -bool SdBaseFile::rename(SdBaseFile *dirFile, const char *newPath) { +bool SdBaseFile::rename(SdBaseFile * const dirFile, const char * const newPath) { if (ENABLED(SDCARD_READONLY)) return false; uint32_t dirCluster = 0; @@ -1900,7 +1899,7 @@ bool SdBaseFile::rmRfStar() { * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t). */ -SdBaseFile::SdBaseFile(const char *path, uint8_t oflag) { +SdBaseFile::SdBaseFile(const char * const path, const uint8_t oflag) { type_ = FAT_FILE_TYPE_CLOSED; writeError = false; open(path, oflag); @@ -1943,7 +1942,7 @@ bool SdBaseFile::seekSet(const uint32_t pos) { return true; } -void SdBaseFile::setpos(filepos_t *pos) { +void SdBaseFile::setpos(filepos_t * const pos) { curPosition_ = pos->position; curCluster_ = pos->cluster; } @@ -1998,7 +1997,7 @@ bool SdBaseFile::sync() { * * \return true for success, false for failure. */ -bool SdBaseFile::timestamp(SdBaseFile *file) { +bool SdBaseFile::timestamp(SdBaseFile * const file) { dir_t dir; // get timestamps @@ -2055,8 +2054,8 @@ bool SdBaseFile::timestamp(SdBaseFile *file) { * * \return true for success, false for failure. */ -bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month, - uint8_t day, uint8_t hour, uint8_t minute, uint8_t second) { +bool SdBaseFile::timestamp(const uint8_t flags, const uint16_t year, const uint8_t month, + const uint8_t day, const uint8_t hour, const uint8_t minute, const uint8_t second) { if (ENABLED(SDCARD_READONLY)) return false; uint16_t dirDate, dirTime; diff --git a/Marlin/src/sd/SdBaseFile.h b/Marlin/src/sd/SdBaseFile.h index 19225170f9ce4..046c2447cb7a6 100644 --- a/Marlin/src/sd/SdBaseFile.h +++ b/Marlin/src/sd/SdBaseFile.h @@ -89,7 +89,7 @@ uint8_t const FAT_FILE_TYPE_CLOSED = 0, // This file h * * \return Packed date for dir_t entry. */ -static inline uint16_t FAT_DATE(uint16_t year, uint8_t month, uint8_t day) { return (year - 1980) << 9 | month << 5 | day; } +static inline uint16_t FAT_DATE(const uint16_t year, const uint8_t month, const uint8_t day) { return (year - 1980) << 9 | month << 5 | day; } /** * year part of FAT directory date field @@ -97,7 +97,7 @@ static inline uint16_t FAT_DATE(uint16_t year, uint8_t month, uint8_t day) { ret * * \return Extracted year [1980,2107] */ -static inline uint16_t FAT_YEAR(uint16_t fatDate) { return 1980 + (fatDate >> 9); } +static inline uint16_t FAT_YEAR(const uint16_t fatDate) { return 1980 + (fatDate >> 9); } /** * month part of FAT directory date field @@ -105,7 +105,7 @@ static inline uint16_t FAT_YEAR(uint16_t fatDate) { return 1980 + (fatDate >> 9) * * \return Extracted month [1,12] */ -static inline uint8_t FAT_MONTH(uint16_t fatDate) { return (fatDate >> 5) & 0xF; } +static inline uint8_t FAT_MONTH(const uint16_t fatDate) { return (fatDate >> 5) & 0xF; } /** * day part of FAT directory date field @@ -113,7 +113,7 @@ static inline uint8_t FAT_MONTH(uint16_t fatDate) { return (fatDate >> 5) & 0xF; * * \return Extracted day [1,31] */ -static inline uint8_t FAT_DAY(uint16_t fatDate) { return fatDate & 0x1F; } +static inline uint8_t FAT_DAY(const uint16_t fatDate) { return fatDate & 0x1F; } /** * time field for FAT directory entry @@ -123,7 +123,7 @@ static inline uint8_t FAT_DAY(uint16_t fatDate) { return fatDate & 0x1F; } * * \return Packed time for dir_t entry. */ -static inline uint16_t FAT_TIME(uint8_t hour, uint8_t minute, uint8_t second) { return hour << 11 | minute << 5 | second >> 1; } +static inline uint16_t FAT_TIME(const uint8_t hour, const uint8_t minute, const uint8_t second) { return hour << 11 | minute << 5 | second >> 1; } /** * hour part of FAT directory time field @@ -131,7 +131,7 @@ static inline uint16_t FAT_TIME(uint8_t hour, uint8_t minute, uint8_t second) { * * \return Extracted hour [0,23] */ -static inline uint8_t FAT_HOUR(uint16_t fatTime) { return fatTime >> 11; } +static inline uint8_t FAT_HOUR(const uint16_t fatTime) { return fatTime >> 11; } /** * minute part of FAT directory time field @@ -139,7 +139,7 @@ static inline uint8_t FAT_HOUR(uint16_t fatTime) { return fatTime >> 11; } * * \return Extracted minute [0,59] */ -static inline uint8_t FAT_MINUTE(uint16_t fatTime) { return (fatTime >> 5) & 0x3F; } +static inline uint8_t FAT_MINUTE(const uint16_t fatTime) { return (fatTime >> 5) & 0x3F; } /** * second part of FAT directory time field @@ -149,7 +149,7 @@ static inline uint8_t FAT_MINUTE(uint16_t fatTime) { return (fatTime >> 5) & 0x3 * * \return Extracted second [0,58] */ -static inline uint8_t FAT_SECOND(uint16_t fatTime) { return 2 * (fatTime & 0x1F); } +static inline uint8_t FAT_SECOND(const uint16_t fatTime) { return 2 * (fatTime & 0x1F); } // Default date for file timestamps is 1 Jan 2000 uint16_t const FAT_DEFAULT_DATE = ((2000 - 1980) << 9) | (1 << 5) | 1; @@ -163,7 +163,7 @@ uint16_t const FAT_DEFAULT_TIME = (1 << 11); class SdBaseFile { public: SdBaseFile() : writeError(false), type_(FAT_FILE_TYPE_CLOSED) {} - SdBaseFile(const char *path, uint8_t oflag); + SdBaseFile(const char * const path, const uint8_t oflag); ~SdBaseFile() { if (isOpen()) close(); } /** @@ -179,18 +179,17 @@ class SdBaseFile { * get position for streams * \param[out] pos struct to receive position */ - void getpos(filepos_t *pos); + void getpos(filepos_t * const pos); /** * set position for streams * \param[out] pos struct with value for new position */ - void setpos(filepos_t *pos); + void setpos(filepos_t * const pos); bool close(); - bool contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock); - bool createContiguous(SdBaseFile *dirFile, - const char *path, uint32_t size); + bool contiguousRange(uint32_t * const bgnBlock, uint32_t * const endBlock); + bool createContiguous(SdBaseFile * const dirFile, const char * const path, const uint32_t size); /** * \return The current cluster number for a file or directory. */ @@ -235,7 +234,7 @@ class SdBaseFile { * See the timestamp() function. */ static void dateTimeCallback( - void (*dateTime)(uint16_t *date, uint16_t *time)) { + void (*dateTime)(uint16_t * const date, uint16_t * const time)) { dateTime_ = dateTime; } @@ -246,7 +245,7 @@ class SdBaseFile { bool dirEntry(dir_t *dir); static void dirName(const dir_t& dir, char *name); bool exists(const char *name); - int16_t fgets(char *str, int16_t num, char *delim = 0); + int16_t fgets(char *str, int16_t num, char *delim=0); /** * \return The total number of bytes in a file or directory. @@ -284,29 +283,29 @@ class SdBaseFile { bool isRoot() const { return type_ == FAT_FILE_TYPE_ROOT_FIXED || type_ == FAT_FILE_TYPE_ROOT32; } bool getDosName(char * const name); - void ls(uint8_t flags = 0, uint8_t indent = 0); - - bool mkdir(SdBaseFile *dir, const char *path, bool pFlag = true); - bool open(SdBaseFile *dirFile, uint16_t index, uint8_t oflag); - bool open(SdBaseFile *dirFile, const char *path, uint8_t oflag); - bool open(const char *path, uint8_t oflag = O_READ); - bool openNext(SdBaseFile *dirFile, uint8_t oflag); - bool openRoot(SdVolume *vol); + void ls(uint8_t flags=0, uint8_t indent=0); + + bool mkdir(SdBaseFile *parent, const char *path, const bool pFlag=true); + bool open(SdBaseFile * const dirFile, uint16_t index, const uint8_t oflag); + bool open(SdBaseFile * const dirFile, const char *path, const uint8_t oflag); + bool open(const char * const path, const uint8_t oflag=O_READ); + bool openNext(SdBaseFile * const dirFile, const uint8_t oflag); + bool openRoot(SdVolume * const vol); int peek(); - static void printFatDate(uint16_t fatDate); - static void printFatTime(uint16_t fatTime); + static void printFatDate(const uint16_t fatDate); + static void printFatTime(const uint16_t fatTime); bool printName(); int16_t read(); - int16_t read(void *buf, uint16_t nbyte); - int8_t readDir(dir_t *dir, char * const longFilename); - static bool remove(SdBaseFile *dirFile, const char *path); + int16_t read(void * const buf, uint16_t nbyte); + int8_t readDir(dir_t * const dir, char * const longFilename); + static bool remove(SdBaseFile * const dirFile, const char * const path); bool remove(); /** * Set the file's current position to zero. */ void rewind() { seekSet(0); } - bool rename(SdBaseFile *dirFile, const char *newPath); + bool rename(SdBaseFile * const dirFile, const char * const newPath); bool rmdir(); bool rmRfStar(); @@ -327,12 +326,12 @@ class SdBaseFile { * \param[in] offset The new position in bytes from end-of-file. * \return true for success or false for failure. */ - 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 sync(); - bool timestamp(SdBaseFile *file); - bool timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day, - uint8_t hour, uint8_t minute, uint8_t second); + bool timestamp(SdBaseFile * const file); + bool timestamp(const uint8_t flag, const uint16_t year, const uint8_t month, const uint8_t day, + const uint8_t hour, const uint8_t minute, const uint8_t second); /** * Type of file. Use isFile() or isDir() instead of type() if possible. @@ -379,17 +378,17 @@ class SdBaseFile { // private functions bool addCluster(); bool addDirCluster(); - dir_t* cacheDirEntry(uint8_t action); - int8_t lsPrintNext(uint8_t flags, uint8_t indent); - static bool make83Name(const char *str, uint8_t *name, const char **ptr); - bool mkdir(SdBaseFile *parent, const uint8_t dname[11] + dir_t* cacheDirEntry(const uint8_t action); + int8_t lsPrintNext(const uint8_t flags, const uint8_t indent); + static bool make83Name(const char *str, uint8_t * const name, const char **ptr); + bool mkdir(SdBaseFile * const parent, const uint8_t dname[11] OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) ); bool open(SdBaseFile *dirFile, const uint8_t dname[11] OPTARG(LONG_FILENAME_WRITE_SUPPORT, const uint8_t dlname[LONG_FILENAME_LENGTH]) - , uint8_t oflag + , const uint8_t oflag ); - bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags); + bool openCachedEntry(const uint8_t dirIndex, const uint8_t oflags); dir_t* readDirCache(); #if ENABLED(UTF_FILENAME_SUPPORT) @@ -399,11 +398,11 @@ class SdBaseFile { // Long Filename create/write support #if ENABLED(LONG_FILENAME_WRITE_SUPPORT) static bool isDirLFN(const dir_t* dir); - static bool isDirNameLFN(const char *dirname); - static bool parsePath(const char *str, uint8_t *name, uint8_t *lname, const char **ptr); + static bool isDirNameLFN(const char * const dirname); + static bool parsePath(const char *str, uint8_t * const name, uint8_t * const lname, const char **ptr); // Return the number of entries needed in the FAT for this LFN - static inline uint8_t getLFNEntriesNum(const char *lname) { return (strlen(lname) + 12) / 13; } - static void getLFNName(vfat_t *vFatDir, char *lname, uint8_t startOffset); - static void setLFNName(vfat_t *vFatDir, char *lname, uint8_t lfnSequenceNumber); + static uint8_t getLFNEntriesNum(const char * const lname) { return (strlen(lname) + 12) / 13; } + static void getLFNName(vfat_t *vFatDir, char *lname, const uint8_t sequenceNumber); + static void setLFNName(vfat_t *vFatDir, char *lname, const uint8_t sequenceNumber); #endif }; diff --git a/Marlin/src/sd/SdFile.cpp b/Marlin/src/sd/SdFile.cpp index bce96ef02db5e..ac5f6f923414d 100644 --- a/Marlin/src/sd/SdFile.cpp +++ b/Marlin/src/sd/SdFile.cpp @@ -43,7 +43,7 @@ * \param[in] oflag Values for \a oflag are constructed by a bitwise-inclusive * OR of open flags. see SdBaseFile::open(SdBaseFile*, const char*, uint8_t). */ -SdFile::SdFile(const char *path, uint8_t oflag) : SdBaseFile(path, oflag) { } +SdFile::SdFile(const char * const path, const uint8_t oflag) : SdBaseFile(path, oflag) { } /** * Write data to an open file. @@ -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 * 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 * const buf, const uint16_t nbyte) { return SdBaseFile::write(buf, nbyte); } /** * Write a byte to a file. Required by the Arduino Print class. @@ -68,9 +68,9 @@ int16_t SdFile::write(const void *buf, uint16_t nbyte) { return SdBaseFile::writ * Use writeError to check for errors. */ #if ARDUINO >= 100 - size_t SdFile::write(uint8_t b) { return SdBaseFile::write(&b, 1); } + size_t SdFile::write(const uint8_t b) { return SdBaseFile::write(&b, 1); } #else - void SdFile::write(uint8_t b) { SdBaseFile::write(&b, 1); } + void SdFile::write(const uint8_t b) { SdBaseFile::write(&b, 1); } #endif /** @@ -78,7 +78,7 @@ int16_t SdFile::write(const void *buf, uint16_t nbyte) { return SdBaseFile::writ * \param[in] str Pointer to the string. * Use writeError to check for errors. */ -void SdFile::write(const char *str) { SdBaseFile::write(str, strlen(str)); } +void SdFile::write(const char * const str) { SdBaseFile::write(str, strlen(str)); } /** * Write a PROGMEM string to a file. @@ -94,7 +94,7 @@ void SdFile::write_P(PGM_P str) { * \param[in] str Pointer to the PROGMEM string. * Use writeError to check for errors. */ -void SdFile::writeln_P(PGM_P str) { +void SdFile::writeln_P(PGM_P const str) { write_P(str); write_P(PSTR("\r\n")); } diff --git a/Marlin/src/sd/SdFile.h b/Marlin/src/sd/SdFile.h index 81eeadf5b5719..b075239ebba79 100644 --- a/Marlin/src/sd/SdFile.h +++ b/Marlin/src/sd/SdFile.h @@ -41,17 +41,17 @@ class SdFile : public SdBaseFile { public: SdFile() {} - SdFile(const char *name, uint8_t oflag); + SdFile(const char * const name, const uint8_t oflag); #if ARDUINO >= 100 - size_t write(uint8_t b); + size_t write(const uint8_t b); #else - void write(uint8_t b); + void write(const uint8_t b); #endif - int16_t write(const void *buf, uint16_t nbyte); - void write(const char *str); + int16_t write(const void * const buf, const uint16_t nbyte); + void write(const char * const str); void write_P(PGM_P str); - void writeln_P(PGM_P str); + void writeln_P(PGM_P const str); }; using MediaFile = SdFile; diff --git a/Marlin/src/sd/SdVolume.cpp b/Marlin/src/sd/SdVolume.cpp index 1b1fdc5a7c1e2..8c06c745371ba 100644 --- a/Marlin/src/sd/SdVolume.cpp +++ b/Marlin/src/sd/SdVolume.cpp @@ -47,7 +47,7 @@ #endif // find a contiguous group of clusters -bool SdVolume::allocContiguous(uint32_t count, uint32_t *curCluster) { +bool SdVolume::allocContiguous(const uint32_t count, uint32_t * const curCluster) { if (ENABLED(SDCARD_READONLY)) return false; // start of group @@ -138,7 +138,7 @@ bool SdVolume::cacheFlush() { return true; } -bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) { +bool SdVolume::cacheRawBlock(const uint32_t blockNumber, const bool dirty) { if (cacheBlockNumber_ != blockNumber) { if (!cacheFlush()) return false; if (!sdCard_->readBlock(blockNumber, cacheBuffer_.data)) return false; @@ -149,7 +149,7 @@ bool SdVolume::cacheRawBlock(uint32_t blockNumber, bool dirty) { } // return the size in bytes of a cluster chain -bool SdVolume::chainSize(uint32_t cluster, uint32_t *size) { +bool SdVolume::chainSize(uint32_t cluster, uint32_t * const size) { uint32_t s = 0; do { if (!fatGet(cluster, &cluster)) return false; @@ -160,7 +160,7 @@ bool SdVolume::chainSize(uint32_t cluster, uint32_t *size) { } // Fetch a FAT entry -bool SdVolume::fatGet(uint32_t cluster, uint32_t *value) { +bool SdVolume::fatGet(const uint32_t cluster, uint32_t * const value) { uint32_t lba; if (cluster > (clusterCount_ + 1)) return false; if (FAT12_SUPPORT && fatType_ == 12) { @@ -195,7 +195,7 @@ bool SdVolume::fatGet(uint32_t cluster, uint32_t *value) { } // Store a FAT entry -bool SdVolume::fatPut(uint32_t cluster, uint32_t value) { +bool SdVolume::fatPut(const uint32_t cluster, const uint32_t value) { if (ENABLED(SDCARD_READONLY)) return false; uint32_t lba; @@ -326,7 +326,7 @@ int32_t SdVolume::freeClusterCount() { * Reasons for failure include not finding a valid partition, not finding a valid * FAT file system in the specified partition or an I/O error. */ -bool SdVolume::init(DiskIODriver* dev, uint8_t part) { +bool SdVolume::init(DiskIODriver * const dev, const uint8_t part) { uint32_t totalBlocks, volumeStartBlock = 0; fat32_boot_t *fbs; diff --git a/Marlin/src/sd/SdVolume.h b/Marlin/src/sd/SdVolume.h index 3097773030927..ccf595a593d68 100644 --- a/Marlin/src/sd/SdVolume.h +++ b/Marlin/src/sd/SdVolume.h @@ -93,8 +93,8 @@ class SdVolume { * Reasons for failure include not finding a valid partition, not finding * a valid FAT file system or an I/O error. */ - bool init(DiskIODriver *dev) { return init(dev, 1) || init(dev, 0); } - bool init(DiskIODriver *dev, uint8_t part); + bool init(DiskIODriver * const dev) { return init(dev, 1) || init(dev, 0); } + bool init(DiskIODriver * const dev, const uint8_t part); // inline functions that return volume info uint8_t blocksPerCluster() const { return blocksPerCluster_; } //> \return The volume's cluster size in blocks. @@ -127,7 +127,7 @@ class SdVolume { * \param[out] v value of entry * \return true for success or false for failure */ - bool dbgFat(uint32_t n, uint32_t *v) { return fatGet(n, v); } + bool dbgFat(const uint32_t n, uint32_t * const v) { return fatGet(n, v); } private: // Allow SdBaseFile access to SdVolume private data. @@ -164,20 +164,20 @@ class SdVolume { uint16_t rootDirEntryCount_; // number of entries in FAT16 root dir uint32_t rootDirStart_; // root start block for FAT16, cluster for FAT32 - bool allocContiguous(uint32_t count, uint32_t *curCluster); - uint8_t blockOfCluster(uint32_t position) const { return (position >> 9) & (blocksPerCluster_ - 1); } - uint32_t clusterStartBlock(uint32_t cluster) const { return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_); } - uint32_t blockNumber(uint32_t cluster, uint32_t position) const { return clusterStartBlock(cluster) + blockOfCluster(position); } + bool allocContiguous(const uint32_t count, uint32_t * const curCluster); + uint8_t blockOfCluster(const uint32_t position) const { return (position >> 9) & (blocksPerCluster_ - 1); } + uint32_t clusterStartBlock(const uint32_t cluster) const { return dataStartBlock_ + ((cluster - 2) << clusterSizeShift_); } + uint32_t blockNumber(const uint32_t cluster, const uint32_t position) const { return clusterStartBlock(cluster) + blockOfCluster(position); } cache_t* cache() { return &cacheBuffer_; } uint32_t cacheBlockNumber() const { return cacheBlockNumber_; } #if USE_MULTIPLE_CARDS bool cacheFlush(); - bool cacheRawBlock(uint32_t blockNumber, bool dirty); + bool cacheRawBlock(const uint32_t blockNumber, const bool dirty); #else static bool cacheFlush(); - static bool cacheRawBlock(uint32_t blockNumber, bool dirty); + static bool cacheRawBlock(const uint32_t blockNumber, const bool dirty); #endif // used by SdBaseFile write to assign cache to SD location @@ -186,18 +186,18 @@ class SdVolume { cacheBlockNumber_ = blockNumber; } void cacheSetDirty() { cacheDirty_ |= CACHE_FOR_WRITE; } - bool chainSize(uint32_t beginCluster, uint32_t *size); - bool fatGet(uint32_t cluster, uint32_t *value); - bool fatPut(uint32_t cluster, uint32_t value); - bool fatPutEOC(uint32_t cluster) { return fatPut(cluster, 0x0FFFFFFF); } + bool chainSize(uint32_t cluster, uint32_t * const size); + bool fatGet(const uint32_t cluster, uint32_t * const value); + bool fatPut(const uint32_t cluster, const uint32_t value); + bool fatPutEOC(const uint32_t cluster) { return fatPut(cluster, 0x0FFFFFFF); } bool freeChain(uint32_t cluster); - bool isEOC(uint32_t cluster) const { - if (FAT12_SUPPORT && fatType_ == 12) return cluster >= FAT12EOC_MIN; + bool isEOC(const uint32_t cluster) const { + if (FAT12_SUPPORT && fatType_ == 12) return cluster >= FAT12EOC_MIN; if (fatType_ == 16) return cluster >= FAT16EOC_MIN; - return cluster >= FAT32EOC_MIN; + return cluster >= FAT32EOC_MIN; } - bool readBlock(uint32_t block, uint8_t *dst) { return sdCard_->readBlock(block, dst); } - bool writeBlock(uint32_t block, const uint8_t *dst) { return sdCard_->writeBlock(block, dst); } + bool readBlock(const uint32_t block, uint8_t * const dst) { return sdCard_->readBlock(block, dst); } + bool writeBlock(const uint32_t block, const uint8_t * const dst) { return sdCard_->writeBlock(block, dst); } }; using MarlinVolume = SdVolume; diff --git a/Marlin/src/sd/disk_io_driver.h b/Marlin/src/sd/disk_io_driver.h index 3e2d688aea720..f1f49cf85f463 100644 --- a/Marlin/src/sd/disk_io_driver.h +++ b/Marlin/src/sd/disk_io_driver.h @@ -47,18 +47,18 @@ class DiskIODriver { * * \return true for success or false for failure. */ - virtual bool readCSD(csd_t* csd) = 0; + virtual bool readCSD(csd_t * const csd) = 0; virtual bool readStart(const uint32_t block) = 0; - virtual bool readData(uint8_t* dst) = 0; + virtual bool readData(uint8_t * const dst) = 0; virtual bool readStop() = 0; virtual bool writeStart(const uint32_t block, const uint32_t) = 0; virtual bool writeData(const uint8_t* src) = 0; virtual bool writeStop() = 0; - virtual bool readBlock(uint32_t block, uint8_t* dst) = 0; - virtual bool writeBlock(uint32_t blockNumber, const uint8_t* src) = 0; + virtual bool readBlock(const uint32_t block, uint8_t * const dst) = 0; + virtual bool writeBlock(const uint32_t blockNumber, const uint8_t * const src) = 0; virtual uint32_t cardSize() = 0;