Change some hex case

This commit is contained in:
Scott Lahteine 2017-12-15 15:17:52 -06:00
parent 4782acf60e
commit 8b12371e45
6 changed files with 32 additions and 32 deletions

View File

@ -97,7 +97,7 @@ void spiBegin (void) {
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** SPI receive a byte */ /** SPI receive a byte */
uint8_t spiRec(void) { uint8_t spiRec(void) {
SPDR = 0XFF; SPDR = 0xFF;
while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
return SPDR; return SPDR;
} }
@ -105,11 +105,11 @@ void spiBegin (void) {
/** SPI read data */ /** SPI read data */
void spiRead(uint8_t* buf, uint16_t nbyte) { void spiRead(uint8_t* buf, uint16_t nbyte) {
if (nbyte-- == 0) return; if (nbyte-- == 0) return;
SPDR = 0XFF; SPDR = 0xFF;
for (uint16_t i = 0; i < nbyte; i++) { for (uint16_t i = 0; i < nbyte; i++) {
while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
buf[i] = SPDR; buf[i] = SPDR;
SPDR = 0XFF; SPDR = 0xFF;
} }
while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
buf[nbyte] = SPDR; buf[nbyte] = SPDR;
@ -150,7 +150,7 @@ void spiBegin (void) {
uint8_t data = 0; uint8_t data = 0;
// no interrupts during byte receive - about 8 us // no interrupts during byte receive - about 8 us
cli(); cli();
// output pin high - like sending 0XFF // output pin high - like sending 0xFF
WRITE(MOSI_PIN, HIGH); WRITE(MOSI_PIN, HIGH);
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
@ -184,7 +184,7 @@ void spiBegin (void) {
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
WRITE(SCK_PIN, LOW); WRITE(SCK_PIN, LOW);
WRITE(MOSI_PIN, data & 0X80); WRITE(MOSI_PIN, data & 0x80);
data <<= 1; data <<= 1;

View File

@ -56,7 +56,7 @@ uint8_t spiRec(void) {
uint8_t returnByte = SPI.transfer(0xFF); uint8_t returnByte = SPI.transfer(0xFF);
SPI.endTransaction(); SPI.endTransaction();
return returnByte; return returnByte;
// SPDR = 0XFF; // SPDR = 0xFF;
// while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } // while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
// return SPDR; // return SPDR;
} }
@ -67,11 +67,11 @@ void spiRead(uint8_t* buf, uint16_t nbyte) {
SPI.transfer(buf, nbyte); SPI.transfer(buf, nbyte);
SPI.endTransaction(); SPI.endTransaction();
//if (nbyte-- == 0) return; //if (nbyte-- == 0) return;
// SPDR = 0XFF; // SPDR = 0xFF;
//for (uint16_t i = 0; i < nbyte; i++) { //for (uint16_t i = 0; i < nbyte; i++) {
// while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } // while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
// buf[i] = SPDR; // buf[i] = SPDR;
// SPDR = 0XFF; // SPDR = 0xFF;
//} //}
//while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ } //while (!TEST(SPSR, SPIF)) { /* Intentionally left empty */ }
//buf[nbyte] = SPDR; //buf[nbyte] = SPDR;

View File

@ -342,7 +342,7 @@ bool Sd2Card::readData(uint8_t* dst) {
bool Sd2Card::readData(uint8_t* dst, uint16_t count) { bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
// wait for start block token // wait for start block token
uint16_t t0 = millis(); uint16_t t0 = millis();
while ((status_ = spiRec()) == 0XFF) { while ((status_ = spiRec()) == 0xFF) {
if (((uint16_t)millis() - t0) > SD_READ_TIMEOUT) { if (((uint16_t)millis() - t0) > SD_READ_TIMEOUT) {
error(SD_CARD_ERROR_READ_TIMEOUT); error(SD_CARD_ERROR_READ_TIMEOUT);
goto FAIL; goto FAIL;
@ -372,12 +372,12 @@ bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
#endif #endif
chipSelectHigh(); chipSelectHigh();
// Send an additional dummy byte, required by Toshiba Flash Air SD Card // Send an additional dummy byte, required by Toshiba Flash Air SD Card
spiSend(0XFF); spiSend(0xFF);
return true; return true;
FAIL: FAIL:
chipSelectHigh(); chipSelectHigh();
// Send an additional dummy byte, required by Toshiba Flash Air SD Card // Send an additional dummy byte, required by Toshiba Flash Air SD Card
spiSend(0XFF); spiSend(0xFF);
return false; return false;
} }
@ -453,7 +453,7 @@ bool Sd2Card::setSckRate(uint8_t sckRateID) {
// wait for card to go not busy // wait for card to go not busy
bool Sd2Card::waitNotBusy(uint16_t timeoutMillis) { bool Sd2Card::waitNotBusy(uint16_t timeoutMillis) {
uint16_t t0 = millis(); uint16_t t0 = millis();
while (spiRec() != 0XFF) while (spiRec() != 0xFF)
if (((uint16_t)millis() - t0) >= timeoutMillis) return false; if (((uint16_t)millis() - t0) >= timeoutMillis) return false;
return true; return true;

View File

@ -46,21 +46,21 @@ uint16_t const SD_INIT_TIMEOUT = 2000, // init timeout ms
SD_WRITE_TIMEOUT = 600; // write time out ms SD_WRITE_TIMEOUT = 600; // write time out ms
// SD card errors // SD card errors
uint8_t const SD_CARD_ERROR_CMD0 = 0X1, // timeout error for command CMD0 (initialize card in SPI mode) uint8_t const SD_CARD_ERROR_CMD0 = 0x01, // timeout error for command CMD0 (initialize card in SPI mode)
SD_CARD_ERROR_CMD8 = 0X2, // CMD8 was not accepted - not a valid SD card SD_CARD_ERROR_CMD8 = 0x02, // CMD8 was not accepted - not a valid SD card
SD_CARD_ERROR_CMD12 = 0X3, // card returned an error response for CMD12 (write stop) SD_CARD_ERROR_CMD12 = 0x03, // card returned an error response for CMD12 (write stop)
SD_CARD_ERROR_CMD17 = 0X4, // card returned an error response for CMD17 (read block) SD_CARD_ERROR_CMD17 = 0x04, // card returned an error response for CMD17 (read block)
SD_CARD_ERROR_CMD18 = 0X5, // card returned an error response for CMD18 (read multiple block) SD_CARD_ERROR_CMD18 = 0x05, // card returned an error response for CMD18 (read multiple block)
SD_CARD_ERROR_CMD24 = 0X6, // card returned an error response for CMD24 (write block) SD_CARD_ERROR_CMD24 = 0x06, // card returned an error response for CMD24 (write block)
SD_CARD_ERROR_CMD25 = 0X7, // WRITE_MULTIPLE_BLOCKS command failed SD_CARD_ERROR_CMD25 = 0x07, // WRITE_MULTIPLE_BLOCKS command failed
SD_CARD_ERROR_CMD58 = 0X8, // card returned an error response for CMD58 (read OCR) SD_CARD_ERROR_CMD58 = 0x08, // card returned an error response for CMD58 (read OCR)
SD_CARD_ERROR_ACMD23 = 0X9, // SET_WR_BLK_ERASE_COUNT failed SD_CARD_ERROR_ACMD23 = 0x09, // SET_WR_BLK_ERASE_COUNT failed
SD_CARD_ERROR_ACMD41 = 0XA, // ACMD41 initialization process timeout SD_CARD_ERROR_ACMD41 = 0x0A, // ACMD41 initialization process timeout
SD_CARD_ERROR_BAD_CSD = 0XB, // card returned a bad CSR version field SD_CARD_ERROR_BAD_CSD = 0x0B, // card returned a bad CSR version field
SD_CARD_ERROR_ERASE = 0XC, // erase block group command failed SD_CARD_ERROR_ERASE = 0x0C, // erase block group command failed
SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0XD, // card not capable of single block erase SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0x0D, // card not capable of single block erase
SD_CARD_ERROR_ERASE_TIMEOUT = 0XE, // Erase sequence timed out SD_CARD_ERROR_ERASE_TIMEOUT = 0x0E, // Erase sequence timed out
SD_CARD_ERROR_READ = 0XF, // card returned an error token instead of read data SD_CARD_ERROR_READ = 0x0F, // card returned an error token instead of read data
SD_CARD_ERROR_READ_REG = 0x10, // read CID or CSD failed SD_CARD_ERROR_READ_REG = 0x10, // read CID or CSD failed
SD_CARD_ERROR_READ_TIMEOUT = 0x11, // timeout while waiting for start of read data SD_CARD_ERROR_READ_TIMEOUT = 0x11, // timeout while waiting for start of read data
SD_CARD_ERROR_STOP_TRAN = 0x12, // card did not accept STOP_TRAN_TOKEN SD_CARD_ERROR_STOP_TRAN = 0x12, // card did not accept STOP_TRAN_TOKEN

View File

@ -601,7 +601,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t ofla
// search for file // search for file
while (dirFile->curPosition_ < dirFile->fileSize_) { while (dirFile->curPosition_ < dirFile->fileSize_) {
index = 0XF & (dirFile->curPosition_ >> 5); index = 0xF & (dirFile->curPosition_ >> 5);
p = dirFile->readDirCache(); p = dirFile->readDirCache();
if (!p) return false; if (!p) return false;
@ -705,7 +705,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
return false; return false;
} }
// open cached entry // open cached entry
return openCachedEntry(index & 0XF, oflag); return openCachedEntry(index & 0xF, oflag);
} }
// open a cached directory entry. Assumes vol_ is initialized // open a cached directory entry. Assumes vol_ is initialized
@ -775,7 +775,7 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
vol_ = dirFile->vol_; vol_ = dirFile->vol_;
while (1) { while (1) {
index = 0XF & (dirFile->curPosition_ >> 5); index = 0xF & (dirFile->curPosition_ >> 5);
// read entry into cache // read entry into cache
p = dirFile->readDirCache(); p = dirFile->readDirCache();
@ -1100,7 +1100,7 @@ dir_t* SdBaseFile::readDirCache() {
if (!isDir()) return 0; if (!isDir()) return 0;
// index of entry in cache // index of entry in cache
i = (curPosition_ >> 5) & 0XF; i = (curPosition_ >> 5) & 0xF;
// use read to locate and cache block // use read to locate and cache block
if (read() < 0) return 0; if (read() < 0) return 0;

View File

@ -207,7 +207,7 @@ bool SdVolume::fatPut(uint32_t cluster, uint32_t value) {
index &= 0x1FF; index &= 0x1FF;
uint8_t tmp = value; uint8_t tmp = value;
if (cluster & 1) { if (cluster & 1) {
tmp = (cacheBuffer_.data[index] & 0XF) | tmp << 4; tmp = (cacheBuffer_.data[index] & 0xF) | tmp << 4;
} }
cacheBuffer_.data[index] = tmp; cacheBuffer_.data[index] = tmp;
index++; index++;