Apply pointer formatting
This commit is contained in:
@ -63,7 +63,7 @@
|
||||
0x0E,0x07,0x1C,0x15,0x2A,0x23,0x38,0x31,0x46,0x4F,0x54,0x5D,0x62,0x6B,0x70,0x79
|
||||
};
|
||||
|
||||
static uint8_t CRC7(const uint8_t* data, uint8_t n) {
|
||||
static uint8_t CRC7(const uint8_t *data, uint8_t n) {
|
||||
uint8_t crc = 0;
|
||||
while (n > 0) {
|
||||
crc = pgm_read_byte(&crctab7[ (crc << 1) ^ *data++ ]);
|
||||
@ -72,7 +72,7 @@
|
||||
return (crc << 1) | 1;
|
||||
}
|
||||
#else
|
||||
static uint8_t CRC7(const uint8_t* data, uint8_t n) {
|
||||
static uint8_t CRC7(const uint8_t *data, uint8_t n) {
|
||||
uint8_t crc = 0;
|
||||
LOOP_L_N(i, n) {
|
||||
uint8_t d = data[i];
|
||||
@ -338,7 +338,7 @@ bool Sd2Card::init(const uint8_t sckRateID, const pin_t chipSelectPin) {
|
||||
* \param[out] dst Pointer to the location that will receive the data.
|
||||
* \return true for success, false for failure.
|
||||
*/
|
||||
bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t* dst) {
|
||||
bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t *dst) {
|
||||
#if IS_TEENSY_35_36 || IS_TEENSY_40_41
|
||||
return 0 == SDHC_CardReadBlock(dst, blockNumber);
|
||||
#endif
|
||||
@ -378,7 +378,7 @@ bool Sd2Card::readBlock(uint32_t blockNumber, uint8_t* dst) {
|
||||
*
|
||||
* \return true for success, false for failure.
|
||||
*/
|
||||
bool Sd2Card::readData(uint8_t* dst) {
|
||||
bool Sd2Card::readData(uint8_t *dst) {
|
||||
chipSelect();
|
||||
return readData(dst, 512);
|
||||
}
|
||||
@ -421,7 +421,7 @@ bool Sd2Card::readData(uint8_t* dst) {
|
||||
};
|
||||
// faster CRC-CCITT
|
||||
// uses the x^16,x^12,x^5,x^1 polynomial.
|
||||
static uint16_t CRC_CCITT(const uint8_t* data, size_t n) {
|
||||
static uint16_t CRC_CCITT(const uint8_t *data, size_t n) {
|
||||
uint16_t crc = 0;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
crc = pgm_read_word(&crctab16[(crc >> 8 ^ data[i]) & 0xFF]) ^ (crc << 8);
|
||||
@ -431,7 +431,7 @@ bool Sd2Card::readData(uint8_t* dst) {
|
||||
#else
|
||||
// slower CRC-CCITT
|
||||
// uses the x^16,x^12,x^5,x^1 polynomial.
|
||||
static uint16_t CRC_CCITT(const uint8_t* data, size_t n) {
|
||||
static uint16_t CRC_CCITT(const uint8_t *data, size_t n) {
|
||||
uint16_t crc = 0;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
crc = (uint8_t)(crc >> 8) | (crc << 8);
|
||||
@ -445,7 +445,7 @@ bool Sd2Card::readData(uint8_t* dst) {
|
||||
#endif
|
||||
#endif // SD_CHECK_AND_RETRY
|
||||
|
||||
bool Sd2Card::readData(uint8_t* dst, const uint16_t count) {
|
||||
bool Sd2Card::readData(uint8_t *dst, const uint16_t count) {
|
||||
bool success = false;
|
||||
|
||||
const millis_t read_timeout = millis() + SD_READ_TIMEOUT;
|
||||
@ -478,7 +478,7 @@ bool Sd2Card::readData(uint8_t* dst, const uint16_t count) {
|
||||
|
||||
/** read CID or CSR register */
|
||||
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)) {
|
||||
error(SD_CARD_ERROR_READ_REG);
|
||||
chipDeselect();
|
||||
@ -555,7 +555,7 @@ bool Sd2Card::waitNotBusy(const millis_t timeout_ms) {
|
||||
* \param[in] src Pointer to the location of the data to be written.
|
||||
* \return true for success, false for failure.
|
||||
*/
|
||||
bool Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t* src) {
|
||||
bool Sd2Card::writeBlock(uint32_t blockNumber, const uint8_t *src) {
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
#if IS_TEENSY_35_36 || IS_TEENSY_40_41
|
||||
@ -586,7 +586,7 @@ bool Sd2Card::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 Sd2Card::writeData(const uint8_t* src) {
|
||||
bool Sd2Card::writeData(const uint8_t *src) {
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
bool success = true;
|
||||
@ -601,7 +601,7 @@ bool Sd2Card::writeData(const uint8_t* src) {
|
||||
}
|
||||
|
||||
// Send one block of data for write block or write multiple blocks
|
||||
bool Sd2Card::writeData(const uint8_t token, const uint8_t* src) {
|
||||
bool Sd2Card::writeData(const uint8_t token, const uint8_t *src) {
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
const uint16_t crc = TERN(SD_CHECK_AND_RETRY, CRC_CCITT(src, 512), 0xFFFF);
|
||||
|
@ -124,7 +124,7 @@ public:
|
||||
*/
|
||||
bool init(const uint8_t sckRateID, const pin_t chipSelectPin);
|
||||
|
||||
bool readBlock(uint32_t block, uint8_t* dst);
|
||||
bool readBlock(uint32_t block, uint8_t *dst);
|
||||
|
||||
/**
|
||||
* Read a card's CID register. The CID contains card identification
|
||||
@ -135,7 +135,7 @@ public:
|
||||
*
|
||||
* \return true for success or false for failure.
|
||||
*/
|
||||
bool readCID(cid_t* cid) { return readRegister(CMD10, cid); }
|
||||
bool readCID(cid_t *cid) { return readRegister(CMD10, cid); }
|
||||
|
||||
/**
|
||||
* Read a card's CSD register. The CSD contains Card-Specific Data that
|
||||
@ -145,9 +145,9 @@ public:
|
||||
*
|
||||
* \return true for success or false for failure.
|
||||
*/
|
||||
inline bool readCSD(csd_t* csd) { return readRegister(CMD9, csd); }
|
||||
inline bool readCSD(csd_t *csd) { return readRegister(CMD9, csd); }
|
||||
|
||||
bool readData(uint8_t* dst);
|
||||
bool readData(uint8_t *dst);
|
||||
bool readStart(uint32_t blockNumber);
|
||||
bool readStop();
|
||||
bool setSckRate(const uint8_t sckRateID);
|
||||
@ -157,8 +157,8 @@ public:
|
||||
* \return 0 - SD V1, 1 - SD V2, or 3 - SDHC.
|
||||
*/
|
||||
int type() const {return type_;}
|
||||
bool writeBlock(uint32_t blockNumber, const uint8_t* src);
|
||||
bool writeData(const uint8_t* src);
|
||||
bool writeBlock(uint32_t blockNumber, const uint8_t *src);
|
||||
bool writeData(const uint8_t *src);
|
||||
bool writeStart(uint32_t blockNumber, const uint32_t eraseCount);
|
||||
bool writeStop();
|
||||
|
||||
@ -176,11 +176,11 @@ private:
|
||||
}
|
||||
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);
|
||||
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 *src);
|
||||
};
|
||||
|
@ -43,7 +43,7 @@
|
||||
SdBaseFile* SdBaseFile::cwd_ = 0; // Pointer to Current Working Directory
|
||||
|
||||
// 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;
|
||||
|
||||
// add a cluster to a file
|
||||
bool SdBaseFile::addCluster() {
|
||||
@ -118,7 +118,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 *bgnBlock, uint32_t *endBlock) {
|
||||
// error if no blocks
|
||||
if (firstCluster_ == 0) return false;
|
||||
|
||||
@ -155,7 +155,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* dirFile, const char *path, uint32_t size) {
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
uint32_t count;
|
||||
@ -186,8 +186,8 @@ bool SdBaseFile::createContiguous(SdBaseFile* dirFile, const char* path, uint32_
|
||||
*
|
||||
* \return true for success, false for failure.
|
||||
*/
|
||||
bool SdBaseFile::dirEntry(dir_t* dir) {
|
||||
dir_t* p;
|
||||
bool SdBaseFile::dirEntry(dir_t *dir) {
|
||||
dir_t *p;
|
||||
// make sure fields on SD are correct
|
||||
if (!sync()) return false;
|
||||
|
||||
@ -207,7 +207,7 @@ bool SdBaseFile::dirEntry(dir_t* dir) {
|
||||
* \param[in] dir The directory structure containing the 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;
|
||||
LOOP_L_N(i, 11) {
|
||||
if (dir.name[i] == ' ')continue;
|
||||
@ -229,7 +229,7 @@ void SdBaseFile::dirName(const dir_t& dir, char* name) {
|
||||
*
|
||||
* \return true if the file exists else false.
|
||||
*/
|
||||
bool SdBaseFile::exists(const char* name) {
|
||||
bool SdBaseFile::exists(const char *name) {
|
||||
SdBaseFile file;
|
||||
return file.open(this, name, O_READ);
|
||||
}
|
||||
@ -254,7 +254,7 @@ bool SdBaseFile::exists(const char* name) {
|
||||
* \return For success fgets() returns the length of the string in \a str.
|
||||
* If no data is read, fgets() returns zero for EOF or -1 if an error occurred.
|
||||
**/
|
||||
int16_t SdBaseFile::fgets(char* str, int16_t num, char* delim) {
|
||||
int16_t SdBaseFile::fgets(char *str, int16_t num, char *delim) {
|
||||
char ch;
|
||||
int16_t n = 0;
|
||||
int16_t r = -1;
|
||||
@ -293,7 +293,7 @@ bool SdBaseFile::getDosName(char * const name) {
|
||||
return true;
|
||||
}
|
||||
// cache entry
|
||||
dir_t* p = cacheDirEntry(SdVolume::CACHE_FOR_READ);
|
||||
dir_t *p = cacheDirEntry(SdVolume::CACHE_FOR_READ);
|
||||
if (!p) return false;
|
||||
|
||||
// format name
|
||||
@ -301,7 +301,7 @@ bool SdBaseFile::getDosName(char * const name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void SdBaseFile::getpos(filepos_t* pos) {
|
||||
void SdBaseFile::getpos(filepos_t *pos) {
|
||||
pos->position = curPosition_;
|
||||
pos->cluster = curCluster_;
|
||||
}
|
||||
@ -386,7 +386,7 @@ int8_t SdBaseFile::lsPrintNext(uint8_t flags, uint8_t indent) {
|
||||
}
|
||||
|
||||
// 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
|
||||
i = 11;
|
||||
while (i) name[--i] = ' '; // Set whole FILENAME.EXT to spaces
|
||||
@ -423,7 +423,7 @@ 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, bool pFlag) {
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
uint8_t dname[11];
|
||||
@ -460,7 +460,7 @@ bool SdBaseFile::mkdir(SdBaseFile* parent, const uint8_t dname[11]) {
|
||||
|
||||
uint32_t block;
|
||||
dir_t d;
|
||||
dir_t* p;
|
||||
dir_t *p;
|
||||
|
||||
if (!parent->isDir()) return false;
|
||||
|
||||
@ -523,7 +523,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 *path, uint8_t oflag) {
|
||||
return open(cwd_, path, oflag);
|
||||
}
|
||||
|
||||
@ -577,7 +577,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* dirFile, const char *path, uint8_t oflag) {
|
||||
uint8_t dname[11];
|
||||
SdBaseFile dir1, dir2;
|
||||
SdBaseFile *parent = dirFile, *sub = &dir1;
|
||||
@ -608,7 +608,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const char* path, uint8_t oflag) {
|
||||
bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag) {
|
||||
bool emptyFound = false, fileFound = false;
|
||||
uint8_t index;
|
||||
dir_t* p;
|
||||
dir_t *p;
|
||||
|
||||
vol_ = dirFile->vol_;
|
||||
|
||||
@ -697,7 +697,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t ofla
|
||||
* \return true for success or false for failure.
|
||||
*/
|
||||
bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
|
||||
dir_t* p;
|
||||
dir_t *p;
|
||||
|
||||
vol_ = dirFile->vol_;
|
||||
|
||||
@ -725,7 +725,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) {
|
||||
dir_t* p;
|
||||
dir_t *p;
|
||||
|
||||
#if ENABLED(SDCARD_READONLY)
|
||||
if (oflag & (O_WRITE | O_CREAT | O_TRUNC)) goto FAIL;
|
||||
@ -785,7 +785,7 @@ bool SdBaseFile::openCachedEntry(uint8_t dirIndex, uint8_t oflag) {
|
||||
* \return true for success or false for failure.
|
||||
*/
|
||||
bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
|
||||
dir_t* p;
|
||||
dir_t *p;
|
||||
uint8_t index;
|
||||
|
||||
if (!dirFile) return false;
|
||||
@ -827,7 +827,7 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
|
||||
*/
|
||||
bool SdBaseFile::openParent(SdBaseFile* dir) {
|
||||
dir_t entry;
|
||||
dir_t* p;
|
||||
dir_t *p;
|
||||
SdBaseFile file;
|
||||
uint32_t c;
|
||||
uint32_t cluster;
|
||||
@ -1009,7 +1009,7 @@ int16_t SdBaseFile::read() {
|
||||
* or an I/O error occurred.
|
||||
*/
|
||||
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;
|
||||
uint32_t block; // raw device block number
|
||||
|
||||
@ -1049,7 +1049,7 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
|
||||
else {
|
||||
// read block to cache and copy data to caller
|
||||
if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_READ)) return -1;
|
||||
uint8_t* src = vol_->cache()->data + offset;
|
||||
uint8_t *src = vol_->cache()->data + offset;
|
||||
memcpy(dst, src, n);
|
||||
}
|
||||
dst += n;
|
||||
@ -1070,7 +1070,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* longFilename) {
|
||||
int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) {
|
||||
int16_t n;
|
||||
// if not a directory file or miss-positioned return an error
|
||||
if (!isDir() || (0x1F & curPosition_)) return -1;
|
||||
@ -1096,7 +1096,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
|
||||
// Fill the long filename if we have a long filename entry.
|
||||
// Long filename entries are stored before the short filename.
|
||||
if (longFilename && DIR_IS_LONG_NAME(dir)) {
|
||||
vfat_t* VFAT = (vfat_t*)dir;
|
||||
vfat_t *VFAT = (vfat_t*)dir;
|
||||
// Sanity-check the VFAT entry. The first cluster is always set to zero. And the sequence number should be higher than 0
|
||||
if (VFAT->firstClusterLow == 0) {
|
||||
const uint8_t seq = VFAT->sequenceNumber & 0x1F;
|
||||
@ -1199,7 +1199,7 @@ dir_t* SdBaseFile::readDirCache() {
|
||||
bool SdBaseFile::remove() {
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
dir_t* d;
|
||||
dir_t *d;
|
||||
// free any clusters - will fail if read-only or directory
|
||||
if (!truncate(0)) return false;
|
||||
|
||||
@ -1235,7 +1235,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* dirFile, const char *path) {
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
SdBaseFile file;
|
||||
@ -1252,13 +1252,13 @@ bool SdBaseFile::remove(SdBaseFile* dirFile, const char* path) {
|
||||
* 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* dirFile, const char *newPath) {
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
dir_t entry;
|
||||
uint32_t dirCluster = 0;
|
||||
SdBaseFile file;
|
||||
dir_t* d;
|
||||
dir_t *d;
|
||||
|
||||
// must be an open file or subdirectory
|
||||
if (!(isFile() || isSubDir())) return false;
|
||||
@ -1356,7 +1356,7 @@ bool SdBaseFile::rmdir() {
|
||||
|
||||
// make sure directory is empty
|
||||
while (curPosition_ < fileSize_) {
|
||||
dir_t* p = readDirCache();
|
||||
dir_t *p = readDirCache();
|
||||
if (!p) return false;
|
||||
// done if past last used entry
|
||||
if (p->name[0] == DIR_NAME_FREE) break;
|
||||
@ -1396,7 +1396,7 @@ bool SdBaseFile::rmRfStar() {
|
||||
// remember position
|
||||
index = curPosition_ / 32;
|
||||
|
||||
dir_t* p = readDirCache();
|
||||
dir_t *p = readDirCache();
|
||||
if (!p) return false;
|
||||
|
||||
// done if past last entry
|
||||
@ -1438,7 +1438,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 *path, uint8_t oflag) {
|
||||
type_ = FAT_FILE_TYPE_CLOSED;
|
||||
writeError = false;
|
||||
open(path, oflag);
|
||||
@ -1481,7 +1481,7 @@ bool SdBaseFile::seekSet(const uint32_t pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void SdBaseFile::setpos(filepos_t* pos) {
|
||||
void SdBaseFile::setpos(filepos_t *pos) {
|
||||
curPosition_ = pos->position;
|
||||
curCluster_ = pos->cluster;
|
||||
}
|
||||
@ -1499,7 +1499,7 @@ bool SdBaseFile::sync() {
|
||||
if (ENABLED(SDCARD_READONLY) || !isOpen()) goto FAIL;
|
||||
|
||||
if (flags_ & F_FILE_DIR_DIRTY) {
|
||||
dir_t* d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
||||
dir_t *d = cacheDirEntry(SdVolume::CACHE_FOR_WRITE);
|
||||
// check for deleted by another open file object
|
||||
if (!d || d->name[0] == DIR_NAME_DELETED) goto FAIL;
|
||||
|
||||
@ -1537,7 +1537,7 @@ bool SdBaseFile::sync() {
|
||||
* \return true for success, false for failure.
|
||||
*/
|
||||
bool SdBaseFile::timestamp(SdBaseFile* file) {
|
||||
dir_t* d;
|
||||
dir_t *d;
|
||||
dir_t dir;
|
||||
|
||||
// get timestamps
|
||||
@ -1599,7 +1599,7 @@ bool SdBaseFile::timestamp(uint8_t flags, uint16_t year, uint8_t month,
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
uint16_t dirDate, dirTime;
|
||||
dir_t* d;
|
||||
dir_t *d;
|
||||
|
||||
if (!isOpen()
|
||||
|| year < 1980
|
||||
@ -1716,7 +1716,7 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
|
||||
#endif
|
||||
|
||||
// convert void* to uint8_t* - must be before goto statements
|
||||
const uint8_t* src = reinterpret_cast<const uint8_t*>(buf);
|
||||
const uint8_t *src = reinterpret_cast<const uint8_t*>(buf);
|
||||
|
||||
// number of bytes left to write - must be before goto statements
|
||||
uint16_t nToWrite = nbyte;
|
||||
@ -1782,7 +1782,7 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
|
||||
// rewrite part of block
|
||||
if (!vol_->cacheRawBlock(block, SdVolume::CACHE_FOR_WRITE)) goto FAIL;
|
||||
}
|
||||
uint8_t* dst = vol_->cache()->data + blockOffset;
|
||||
uint8_t *dst = vol_->cache()->data + blockOffset;
|
||||
memcpy(dst, src, n);
|
||||
}
|
||||
curPosition_ += n;
|
||||
|
@ -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 *path, uint8_t oflag);
|
||||
~SdBaseFile() { if (isOpen()) close(); }
|
||||
|
||||
/**
|
||||
@ -179,18 +179,18 @@ class SdBaseFile {
|
||||
* get position for streams
|
||||
* \param[out] pos struct to receive position
|
||||
*/
|
||||
void getpos(filepos_t* pos);
|
||||
void getpos(filepos_t *pos);
|
||||
|
||||
/**
|
||||
* set position for streams
|
||||
* \param[out] pos struct with value for new position
|
||||
*/
|
||||
void setpos(filepos_t* pos);
|
||||
void setpos(filepos_t *pos);
|
||||
|
||||
bool close();
|
||||
bool contiguousRange(uint32_t* bgnBlock, uint32_t* endBlock);
|
||||
bool contiguousRange(uint32_t *bgnBlock, uint32_t *endBlock);
|
||||
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.
|
||||
*/
|
||||
@ -213,7 +213,7 @@ class SdBaseFile {
|
||||
* function is of the form:
|
||||
*
|
||||
* \code
|
||||
* void dateTime(uint16_t* date, uint16_t* time) {
|
||||
* void dateTime(uint16_t *date, uint16_t *time) {
|
||||
* uint16_t year;
|
||||
* uint8_t month, day, hour, minute, second;
|
||||
*
|
||||
@ -235,7 +235,7 @@ class SdBaseFile {
|
||||
* See the timestamp() function.
|
||||
*/
|
||||
static void dateTimeCallback(
|
||||
void (*dateTime)(uint16_t* date, uint16_t* time)) {
|
||||
void (*dateTime)(uint16_t *date, uint16_t *time)) {
|
||||
dateTime_ = dateTime;
|
||||
}
|
||||
|
||||
@ -243,10 +243,10 @@ class SdBaseFile {
|
||||
* Cancel the date/time callback function.
|
||||
*/
|
||||
static void dateTimeCallbackCancel() { dateTime_ = 0; }
|
||||
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);
|
||||
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);
|
||||
|
||||
/**
|
||||
* \return The total number of bytes in a file or directory.
|
||||
@ -286,10 +286,10 @@ class SdBaseFile {
|
||||
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 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 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);
|
||||
int peek();
|
||||
@ -298,15 +298,15 @@ class SdBaseFile {
|
||||
bool printName();
|
||||
int16_t read();
|
||||
int16_t read(void* buf, uint16_t nbyte);
|
||||
int8_t readDir(dir_t* dir, char* longFilename);
|
||||
static bool remove(SdBaseFile* dirFile, const char* path);
|
||||
int8_t readDir(dir_t *dir, char *longFilename);
|
||||
static bool remove(SdBaseFile* dirFile, const char *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* dirFile, const char *newPath);
|
||||
bool rmdir();
|
||||
bool rmRfStar();
|
||||
|
||||
@ -348,7 +348,7 @@ class SdBaseFile {
|
||||
static SdBaseFile* cwd_; // global pointer to cwd dir
|
||||
|
||||
// data time callback function
|
||||
static void (*dateTime_)(uint16_t* date, uint16_t* time);
|
||||
static void (*dateTime_)(uint16_t *date, uint16_t *time);
|
||||
|
||||
// bits defined in flags_
|
||||
static uint8_t const F_OFLAG = (O_ACCMODE | O_APPEND | O_SYNC), // should be 0x0F
|
||||
@ -376,7 +376,7 @@ class SdBaseFile {
|
||||
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);
|
||||
static bool make83Name(const char *str, uint8_t *name, const char** ptr);
|
||||
bool mkdir(SdBaseFile* parent, const uint8_t dname[11]);
|
||||
bool open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t oflag);
|
||||
bool openCachedEntry(uint8_t cacheIndex, uint8_t oflags);
|
||||
|
@ -571,7 +571,7 @@ uint8_t const DIR_NAME_0xE5 = 0x05, // escape for name[0] = 0xE5
|
||||
*
|
||||
* \return true if the entry is for part of a long name else false.
|
||||
*/
|
||||
static inline uint8_t DIR_IS_LONG_NAME(const dir_t* dir) {
|
||||
static inline uint8_t DIR_IS_LONG_NAME(const dir_t *dir) {
|
||||
return (dir->attributes & DIR_ATT_LONG_NAME_MASK) == DIR_ATT_LONG_NAME;
|
||||
}
|
||||
|
||||
@ -584,7 +584,7 @@ uint8_t const DIR_ATT_FILE_TYPE_MASK = (DIR_ATT_VOLUME_ID | DIR_ATT_DIRECTORY);
|
||||
*
|
||||
* \return true if the entry is for a normal file else false.
|
||||
*/
|
||||
static inline uint8_t DIR_IS_FILE(const dir_t* dir) {
|
||||
static inline uint8_t DIR_IS_FILE(const dir_t *dir) {
|
||||
return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == 0;
|
||||
}
|
||||
|
||||
@ -594,7 +594,7 @@ static inline uint8_t DIR_IS_FILE(const dir_t* dir) {
|
||||
*
|
||||
* \return true if the entry is for a subdirectory else false.
|
||||
*/
|
||||
static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) {
|
||||
static inline uint8_t DIR_IS_SUBDIR(const dir_t *dir) {
|
||||
return (dir->attributes & DIR_ATT_FILE_TYPE_MASK) == DIR_ATT_DIRECTORY;
|
||||
}
|
||||
|
||||
@ -604,6 +604,6 @@ static inline uint8_t DIR_IS_SUBDIR(const dir_t* dir) {
|
||||
*
|
||||
* \return true if the entry is for a normal file or subdirectory else false.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
@ -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 *path, uint8_t oflag) : SdBaseFile(path, oflag) { }
|
||||
|
||||
/**
|
||||
* Write data to an open file.
|
||||
@ -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 *str) { SdBaseFile::write(str, strlen(str)); }
|
||||
|
||||
/**
|
||||
* Write a PROGMEM string to a file.
|
||||
|
@ -42,7 +42,7 @@
|
||||
class SdFile : public SdBaseFile {
|
||||
public:
|
||||
SdFile() {}
|
||||
SdFile(const char* name, uint8_t oflag);
|
||||
SdFile(const char *name, uint8_t oflag);
|
||||
#if ARDUINO >= 100
|
||||
size_t write(uint8_t b);
|
||||
#else
|
||||
@ -50,7 +50,7 @@ class SdFile : public SdBaseFile {
|
||||
#endif
|
||||
|
||||
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 writeln_P(PGM_P str);
|
||||
};
|
||||
|
@ -47,7 +47,7 @@
|
||||
#endif // USE_MULTIPLE_CARDS
|
||||
|
||||
// find a contiguous group of clusters
|
||||
bool SdVolume::allocContiguous(uint32_t count, uint32_t* curCluster) {
|
||||
bool SdVolume::allocContiguous(uint32_t count, uint32_t *curCluster) {
|
||||
if (ENABLED(SDCARD_READONLY)) return false;
|
||||
|
||||
// start of group
|
||||
@ -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 *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(uint32_t cluster, uint32_t *value) {
|
||||
uint32_t lba;
|
||||
if (cluster > (clusterCount_ + 1)) return false;
|
||||
if (FAT12_SUPPORT && fatType_ == 12) {
|
||||
@ -328,7 +328,7 @@ int32_t SdVolume::freeClusterCount() {
|
||||
*/
|
||||
bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||
uint32_t totalBlocks, volumeStartBlock = 0;
|
||||
fat32_boot_t* fbs;
|
||||
fat32_boot_t *fbs;
|
||||
|
||||
sdCard_ = dev;
|
||||
fatType_ = 0;
|
||||
@ -342,7 +342,7 @@ bool SdVolume::init(Sd2Card* dev, uint8_t part) {
|
||||
if (part) {
|
||||
if (part > 4) return false;
|
||||
if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ)) return false;
|
||||
part_t* p = &cacheBuffer_.mbr.part[part - 1];
|
||||
part_t *p = &cacheBuffer_.mbr.part[part - 1];
|
||||
if ((p->boot & 0x7F) != 0 || p->totalSectors < 100 || p->firstSector == 0)
|
||||
return false; // not a valid partition
|
||||
volumeStartBlock = p->firstSector;
|
||||
|
@ -124,7 +124,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(uint32_t n, uint32_t *v) { return fatGet(n, v); }
|
||||
|
||||
private:
|
||||
// Allow SdBaseFile access to SdVolume private data.
|
||||
@ -161,7 +161,7 @@ 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);
|
||||
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); }
|
||||
@ -183,8 +183,8 @@ 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 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 freeChain(uint32_t cluster);
|
||||
@ -193,6 +193,6 @@ class SdVolume {
|
||||
if (fatType_ == 16) return cluster >= FAT16EOC_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(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); }
|
||||
};
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
|
||||
// Select a file
|
||||
static void selectFileByIndex(const uint16_t nr);
|
||||
static void selectFileByName(const char* const match);
|
||||
static void selectFileByName(const char * const match);
|
||||
|
||||
// Print job
|
||||
static void openAndPrintFile(const char *name); // (working directory)
|
||||
|
@ -295,7 +295,7 @@ uint32_t Sd2Card::cardSize() {
|
||||
return lun0_capacity;
|
||||
}
|
||||
|
||||
bool Sd2Card::readBlock(uint32_t block, uint8_t* dst) {
|
||||
bool Sd2Card::readBlock(uint32_t block, uint8_t *dst) {
|
||||
if (!isInserted()) return false;
|
||||
#if USB_DEBUG >= 3
|
||||
if (block >= lun0_capacity) {
|
||||
@ -309,7 +309,7 @@ bool Sd2Card::readBlock(uint32_t block, uint8_t* dst) {
|
||||
return bulk.Read(0, block, 512, 1, dst) == 0;
|
||||
}
|
||||
|
||||
bool Sd2Card::writeBlock(uint32_t block, const uint8_t* src) {
|
||||
bool Sd2Card::writeBlock(uint32_t block, const uint8_t *src) {
|
||||
if (!isInserted()) return false;
|
||||
#if USB_DEBUG >= 3
|
||||
if (block >= lun0_capacity) {
|
||||
|
@ -60,15 +60,15 @@ class Sd2Card {
|
||||
static void idle();
|
||||
|
||||
inline bool readStart(const uint32_t block) { pos = block; return isReady(); }
|
||||
inline bool readData(uint8_t* dst) { return readBlock(pos++, dst); }
|
||||
inline bool readData(uint8_t *dst) { return readBlock(pos++, dst); }
|
||||
inline bool readStop() const { return true; }
|
||||
|
||||
inline bool writeStart(const uint32_t block, const uint32_t) { pos = block; return isReady(); }
|
||||
inline bool writeData(uint8_t* src) { return writeBlock(pos++, src); }
|
||||
inline bool writeData(uint8_t *src) { return writeBlock(pos++, src); }
|
||||
inline bool writeStop() const { return true; }
|
||||
|
||||
bool readBlock(uint32_t block, uint8_t* dst);
|
||||
bool writeBlock(uint32_t blockNumber, const uint8_t* src);
|
||||
bool readBlock(uint32_t block, uint8_t *dst);
|
||||
bool writeBlock(uint32_t blockNumber, const uint8_t *src);
|
||||
|
||||
bool readCSD(csd_t*) { return true; }
|
||||
|
||||
|
@ -133,7 +133,7 @@ uint8_t USB::SetAddress(uint8_t addr, uint8_t ep, EpInfo **ppep, uint16_t *nak_l
|
||||
/* 00 = success */
|
||||
/* 01-0f = non-zero HRSLT */
|
||||
uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
|
||||
uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p) {
|
||||
uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t *dataptr, USBReadParser *p) {
|
||||
bool direction = false; // Request direction, IN or OUT
|
||||
uint8_t rcode;
|
||||
SETUP_PKT setup_pkt;
|
||||
@ -201,7 +201,7 @@ uint8_t USB::ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bReque
|
||||
* Keep sending INs and writes data to memory area pointed by 'data'
|
||||
* rcode 0 if no errors. rcode 01-0f is relayed from dispatchPkt(). Rcode f0 means RCVDAVIRQ error, fe = USB xfer timeout
|
||||
*/
|
||||
uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) {
|
||||
uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval /*= 0*/) {
|
||||
EpInfo *pep = nullptr;
|
||||
uint16_t nak_limit = 0;
|
||||
|
||||
@ -215,7 +215,7 @@ uint8_t USB::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t*
|
||||
return InTransfer(pep, nak_limit, nbytesptr, data, bInterval);
|
||||
}
|
||||
|
||||
uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval /*= 0*/) {
|
||||
uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval /*= 0*/) {
|
||||
uint8_t rcode = 0;
|
||||
uint8_t pktsize;
|
||||
|
||||
@ -286,7 +286,7 @@ uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, ui
|
||||
* Handles NAK bug per Maxim Application Note 4000 for single buffer transfer
|
||||
* rcode 0 if no errors. rcode 01-0f is relayed from HRSL
|
||||
*/
|
||||
uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) {
|
||||
uint8_t USB::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data) {
|
||||
EpInfo *pep = nullptr;
|
||||
uint16_t nak_limit = 0;
|
||||
|
||||
@ -743,12 +743,12 @@ uint8_t USB::ReleaseDevice(uint8_t addr) {
|
||||
}
|
||||
|
||||
// Get device descriptor
|
||||
uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) {
|
||||
uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr) {
|
||||
return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, nbytes, dataptr, nullptr);
|
||||
}
|
||||
|
||||
// Get configuration descriptor
|
||||
uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) {
|
||||
uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr) {
|
||||
return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, nbytes, dataptr, nullptr);
|
||||
}
|
||||
|
||||
@ -774,7 +774,7 @@ uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser
|
||||
}
|
||||
|
||||
// Get string descriptor
|
||||
uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) {
|
||||
uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t ns, uint8_t index, uint16_t langid, uint8_t *dataptr) {
|
||||
return ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns, ns, dataptr, nullptr);
|
||||
}
|
||||
|
||||
|
@ -250,19 +250,19 @@ public:
|
||||
uint8_t setEpInfoEntry(uint8_t addr, uint8_t epcount, EpInfo* eprecord_ptr);
|
||||
|
||||
/* Control requests */
|
||||
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr);
|
||||
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr);
|
||||
uint8_t getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr);
|
||||
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr);
|
||||
|
||||
uint8_t getConfDescr(uint8_t addr, uint8_t ep, uint8_t conf, USBReadParser *p);
|
||||
|
||||
uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t* dataptr);
|
||||
uint8_t getStrDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr);
|
||||
uint8_t setAddr(uint8_t oldaddr, uint8_t ep, uint8_t newaddr);
|
||||
uint8_t setConf(uint8_t addr, uint8_t ep, uint8_t conf_value);
|
||||
/**/
|
||||
uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr, bool direction);
|
||||
uint8_t ctrlData(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr, bool direction);
|
||||
uint8_t ctrlStatus(uint8_t ep, bool direction, uint16_t nak_limit);
|
||||
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data, uint8_t bInterval = 0);
|
||||
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data);
|
||||
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data, uint8_t bInterval = 0);
|
||||
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data);
|
||||
uint8_t dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit);
|
||||
|
||||
void Task();
|
||||
@ -272,7 +272,7 @@ public:
|
||||
uint8_t ReleaseDevice(uint8_t addr);
|
||||
|
||||
uint8_t ctrlReq(uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
|
||||
uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t* dataptr, USBReadParser *p);
|
||||
uint16_t wInd, uint16_t total, uint16_t nbytes, uint8_t *dataptr, USBReadParser *p);
|
||||
|
||||
private:
|
||||
void init();
|
||||
@ -285,17 +285,17 @@ private:
|
||||
#if 0 //defined(USB_METHODS_INLINE)
|
||||
//get device descriptor
|
||||
|
||||
inline uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* dataptr) {
|
||||
inline uint8_t USB::getDevDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *dataptr) {
|
||||
return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes, dataptr));
|
||||
}
|
||||
//get configuration descriptor
|
||||
|
||||
inline uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) {
|
||||
inline uint8_t USB::getConfDescr(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t conf, uint8_t *dataptr) {
|
||||
return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes, dataptr));
|
||||
}
|
||||
//get string descriptor
|
||||
|
||||
inline uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t* dataptr) {
|
||||
inline uint8_t USB::getStrDescr(uint8_t addr, uint8_t ep, uint16_t nuint8_ts, uint8_t index, uint16_t langid, uint8_t *dataptr) {
|
||||
return ( ctrlReq(addr, ep, bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, nuint8_ts, dataptr));
|
||||
}
|
||||
//set address
|
||||
|
@ -51,7 +51,7 @@ void MAX3421e::regWr(uint8_t reg, uint8_t data) {
|
||||
|
||||
// multiple-byte write
|
||||
// return a pointer to memory position after last written
|
||||
uint8_t* MAX3421e::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
|
||||
uint8_t* MAX3421e::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p) {
|
||||
cs();
|
||||
spiSend(reg | 0x02);
|
||||
while (nbytes--) spiSend(*data_p++);
|
||||
@ -79,7 +79,7 @@ uint8_t MAX3421e::regRd(uint8_t reg) {
|
||||
// multiple-byte register read
|
||||
|
||||
// return a pointer to a memory position after last read
|
||||
uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
|
||||
uint8_t* MAX3421e::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) {
|
||||
cs();
|
||||
spiSend(reg);
|
||||
while (nbytes--) *data_p++ = spiRec();
|
||||
|
@ -37,10 +37,10 @@ class MAX3421e {
|
||||
bool start();
|
||||
|
||||
void regWr(uint8_t reg, uint8_t data);
|
||||
uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
|
||||
uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p);
|
||||
void gpioWr(uint8_t data);
|
||||
uint8_t regRd(uint8_t reg);
|
||||
uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
|
||||
uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p);
|
||||
uint8_t gpioRd();
|
||||
bool reset();
|
||||
|
||||
|
@ -594,7 +594,7 @@ void UHS_USB_HOST_BASE::ReleaseDevice(uint8_t addr) {
|
||||
* @param dataptr pointer to the data to return
|
||||
* @return status of the request, zero is success.
|
||||
*/
|
||||
uint8_t UHS_USB_HOST_BASE::getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t* dataptr) {
|
||||
uint8_t UHS_USB_HOST_BASE::getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t *dataptr) {
|
||||
return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, 0x00, USB_DESCRIPTOR_DEVICE, 0x0000, nbytes), nbytes, dataptr));
|
||||
}
|
||||
|
||||
@ -607,7 +607,7 @@ uint8_t UHS_USB_HOST_BASE::getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t* d
|
||||
* @param dataptr ointer to the data to return
|
||||
* @return status of the request, zero is success.
|
||||
*/
|
||||
uint8_t UHS_USB_HOST_BASE::getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t* dataptr) {
|
||||
uint8_t UHS_USB_HOST_BASE::getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t *dataptr) {
|
||||
return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, conf, USB_DESCRIPTOR_CONFIGURATION, 0x0000, nbytes), nbytes, dataptr));
|
||||
}
|
||||
|
||||
@ -621,7 +621,7 @@ uint8_t UHS_USB_HOST_BASE::getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t c
|
||||
* @param dataptr pointer to the data to return
|
||||
* @return status of the request, zero is success.
|
||||
*/
|
||||
uint8_t UHS_USB_HOST_BASE::getStrDescr(uint8_t addr, uint16_t ns, uint8_t index, uint16_t langid, uint8_t* dataptr) {
|
||||
uint8_t UHS_USB_HOST_BASE::getStrDescr(uint8_t addr, uint16_t ns, uint8_t index, uint16_t langid, uint8_t *dataptr) {
|
||||
return ( ctrlReq(addr, mkSETUP_PKT8(UHS_bmREQ_GET_DESCR, USB_REQUEST_GET_DESCRIPTOR, index, USB_DESCRIPTOR_STRING, langid, ns), ns, dataptr));
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ uint8_t UHS_USB_HOST_BASE::setConf(uint8_t addr, uint8_t conf_value) {
|
||||
* @param data pointer to buffer to hold transfer
|
||||
* @return zero for success or error code
|
||||
*/
|
||||
uint8_t UHS_USB_HOST_BASE::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data) {
|
||||
uint8_t UHS_USB_HOST_BASE::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data) {
|
||||
UHS_EpInfo *pep = NULL;
|
||||
uint16_t nak_limit = 0;
|
||||
HOST_DEBUG("outTransfer: addr: 0x%2.2x ep: 0x%2.2x nbytes: 0x%4.4x data: 0x%p\r\n", addr, ep, nbytes, data);
|
||||
@ -689,7 +689,7 @@ uint8_t UHS_USB_HOST_BASE::outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes
|
||||
* @param data pointer to buffer to hold transfer
|
||||
* @return zero for success or error code
|
||||
*/
|
||||
uint8_t UHS_USB_HOST_BASE::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data) {
|
||||
uint8_t UHS_USB_HOST_BASE::inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data) {
|
||||
UHS_EpInfo *pep = NULL;
|
||||
uint16_t nak_limit = 0;
|
||||
|
||||
@ -980,7 +980,7 @@ uint8_t UHS_USB_HOST_BASE::eat(UHS_EpInfo *pep, uint16_t *left, uint16_t *read,
|
||||
return rcode;
|
||||
}
|
||||
|
||||
uint8_t UHS_USB_HOST_BASE::ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t* dataptr) {
|
||||
uint8_t UHS_USB_HOST_BASE::ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t *dataptr) {
|
||||
//bool direction = bmReqType & 0x80; //request direction, IN or OUT
|
||||
uint8_t rcode = 0;
|
||||
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
return (current_state == usb_task_state);
|
||||
};
|
||||
|
||||
virtual UHS_EpInfo * UHS_NI ctrlReqOpen(NOTUSED(uint8_t addr), NOTUSED(uint64_t Request), NOTUSED(uint8_t* dataptr)) {
|
||||
virtual UHS_EpInfo * UHS_NI ctrlReqOpen(NOTUSED(uint8_t addr), NOTUSED(uint64_t Request), NOTUSED(uint8_t *dataptr)) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
@ -213,17 +213,17 @@ public:
|
||||
|
||||
uint8_t UHS_NI EPClearHalt(uint8_t addr, uint8_t ep);
|
||||
|
||||
uint8_t UHS_NI ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t* dataptr);
|
||||
uint8_t UHS_NI ctrlReq(uint8_t addr, uint64_t Request, uint16_t nbytes, uint8_t *dataptr);
|
||||
|
||||
uint8_t UHS_NI getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t* dataptr);
|
||||
uint8_t UHS_NI getDevDescr(uint8_t addr, uint16_t nbytes, uint8_t *dataptr);
|
||||
|
||||
uint8_t UHS_NI getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t* dataptr);
|
||||
uint8_t UHS_NI getConfDescr(uint8_t addr, uint16_t nbytes, uint8_t conf, uint8_t *dataptr);
|
||||
|
||||
uint8_t UHS_NI setAddr(uint8_t oldaddr, uint8_t newaddr);
|
||||
|
||||
uint8_t UHS_NI setConf(uint8_t addr, uint8_t conf_value);
|
||||
|
||||
uint8_t UHS_NI getStrDescr(uint8_t addr, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t* dataptr);
|
||||
uint8_t UHS_NI getStrDescr(uint8_t addr, uint16_t nbytes, uint8_t index, uint16_t langid, uint8_t *dataptr);
|
||||
|
||||
void UHS_NI ReleaseDevice(uint8_t addr);
|
||||
|
||||
@ -262,8 +262,8 @@ public:
|
||||
uint8_t enumerateInterface(ENUMERATION_INFO *ei);
|
||||
uint8_t getNextInterface(ENUMERATION_INFO *ei, UHS_EpInfo *pep, uint8_t data[], uint16_t *left, uint16_t *read, uint8_t *offset);
|
||||
uint8_t initDescrStream(ENUMERATION_INFO *ei, USB_FD_CONFIGURATION_DESCRIPTOR *ucd, UHS_EpInfo *pep, uint8_t *data, uint16_t *left, uint16_t *read, uint8_t *offset);
|
||||
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t* data);
|
||||
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t* data);
|
||||
uint8_t outTransfer(uint8_t addr, uint8_t ep, uint16_t nbytes, uint8_t *data);
|
||||
uint8_t inTransfer(uint8_t addr, uint8_t ep, uint16_t *nbytesptr, uint8_t *data);
|
||||
uint8_t doSoftReset(uint8_t parent, uint8_t port, uint8_t address);
|
||||
uint8_t getone(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset);
|
||||
uint8_t eat(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint8_t *dataptr, uint8_t *offset, uint16_t *yum);
|
||||
|
@ -388,7 +388,7 @@ public:
|
||||
return (!condet);
|
||||
};
|
||||
|
||||
virtual UHS_EpInfo *ctrlReqOpen(uint8_t addr, uint64_t Request, uint8_t* dataptr);
|
||||
virtual UHS_EpInfo *ctrlReqOpen(uint8_t addr, uint64_t Request, uint8_t *dataptr);
|
||||
|
||||
virtual void UHS_NI vbusPower(VBUS_t state) {
|
||||
regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE) | (uint8_t)(state));
|
||||
@ -483,8 +483,8 @@ public:
|
||||
void gpioWr(uint8_t data);
|
||||
uint8_t regRd(uint8_t reg);
|
||||
uint8_t gpioRd();
|
||||
uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
|
||||
uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p);
|
||||
uint8_t* bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p);
|
||||
uint8_t* bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p);
|
||||
|
||||
// ARM/NVIC specific, used to emulate reentrant ISR.
|
||||
#ifdef SWI_IRQ_NUM
|
||||
|
@ -76,7 +76,7 @@ void UHS_NI MAX3421E_HOST::regWr(uint8_t reg, uint8_t data) {
|
||||
/* multiple-byte write */
|
||||
|
||||
/* returns a pointer to memory position after last written */
|
||||
uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
|
||||
uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p) {
|
||||
SPIclass.beginTransaction(MAX3421E_SPI_Settings);
|
||||
MARLIN_UHS_WRITE_SS(LOW);
|
||||
SPIclass.transfer(reg | 0x02);
|
||||
@ -117,7 +117,7 @@ uint8_t UHS_NI MAX3421E_HOST::regRd(uint8_t reg) {
|
||||
/* multiple-byte register read */
|
||||
|
||||
/* returns a pointer to a memory position after last read */
|
||||
uint8_t* UHS_NI MAX3421E_HOST::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t* data_p) {
|
||||
uint8_t* UHS_NI MAX3421E_HOST::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) {
|
||||
SPIclass.beginTransaction(MAX3421E_SPI_Settings);
|
||||
MARLIN_UHS_WRITE_SS(LOW);
|
||||
SPIclass.transfer(reg);
|
||||
@ -472,7 +472,7 @@ uint8_t UHS_NI MAX3421E_HOST::SetAddress(uint8_t addr, uint8_t ep, UHS_EpInfo **
|
||||
* @param data pointer to data buffer
|
||||
* @return 0 on success
|
||||
*/
|
||||
uint8_t UHS_NI MAX3421E_HOST::InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t* data) {
|
||||
uint8_t UHS_NI MAX3421E_HOST::InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data) {
|
||||
uint8_t rcode = 0;
|
||||
uint8_t pktsize;
|
||||
|
||||
|
Reference in New Issue
Block a user