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

View File

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

View File

@ -342,7 +342,7 @@ bool Sd2Card::readData(uint8_t* dst) {
bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
// wait for start block token
uint16_t t0 = millis();
while ((status_ = spiRec()) == 0XFF) {
while ((status_ = spiRec()) == 0xFF) {
if (((uint16_t)millis() - t0) > SD_READ_TIMEOUT) {
error(SD_CARD_ERROR_READ_TIMEOUT);
goto FAIL;
@ -372,12 +372,12 @@ bool Sd2Card::readData(uint8_t* dst, uint16_t count) {
#endif
chipSelectHigh();
// Send an additional dummy byte, required by Toshiba Flash Air SD Card
spiSend(0XFF);
spiSend(0xFF);
return true;
FAIL:
chipSelectHigh();
// Send an additional dummy byte, required by Toshiba Flash Air SD Card
spiSend(0XFF);
spiSend(0xFF);
return false;
}
@ -453,7 +453,7 @@ bool Sd2Card::setSckRate(uint8_t sckRateID) {
// wait for card to go not busy
bool Sd2Card::waitNotBusy(uint16_t timeoutMillis) {
uint16_t t0 = millis();
while (spiRec() != 0XFF)
while (spiRec() != 0xFF)
if (((uint16_t)millis() - t0) >= timeoutMillis) return false;
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 card errors
uint8_t const SD_CARD_ERROR_CMD0 = 0X1, // 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_CMD12 = 0X3, // 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_CMD18 = 0X5, // 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_CMD25 = 0X7, // WRITE_MULTIPLE_BLOCKS command failed
SD_CARD_ERROR_CMD58 = 0X8, // card returned an error response for CMD58 (read OCR)
SD_CARD_ERROR_ACMD23 = 0X9, // SET_WR_BLK_ERASE_COUNT failed
SD_CARD_ERROR_ACMD41 = 0XA, // ACMD41 initialization process timeout
SD_CARD_ERROR_BAD_CSD = 0XB, // card returned a bad CSR version field
SD_CARD_ERROR_ERASE = 0XC, // erase block group command failed
SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0XD, // card not capable of single block erase
SD_CARD_ERROR_ERASE_TIMEOUT = 0XE, // Erase sequence timed out
SD_CARD_ERROR_READ = 0XF, // card returned an error token instead of read data
uint8_t const SD_CARD_ERROR_CMD0 = 0x01, // timeout error for command CMD0 (initialize card in SPI mode)
SD_CARD_ERROR_CMD8 = 0x02, // CMD8 was not accepted - not a valid SD card
SD_CARD_ERROR_CMD12 = 0x03, // card returned an error response for CMD12 (write stop)
SD_CARD_ERROR_CMD17 = 0x04, // card returned an error response for CMD17 (read block)
SD_CARD_ERROR_CMD18 = 0x05, // card returned an error response for CMD18 (read multiple block)
SD_CARD_ERROR_CMD24 = 0x06, // card returned an error response for CMD24 (write block)
SD_CARD_ERROR_CMD25 = 0x07, // WRITE_MULTIPLE_BLOCKS command failed
SD_CARD_ERROR_CMD58 = 0x08, // card returned an error response for CMD58 (read OCR)
SD_CARD_ERROR_ACMD23 = 0x09, // SET_WR_BLK_ERASE_COUNT failed
SD_CARD_ERROR_ACMD41 = 0x0A, // ACMD41 initialization process timeout
SD_CARD_ERROR_BAD_CSD = 0x0B, // card returned a bad CSR version field
SD_CARD_ERROR_ERASE = 0x0C, // erase block group command failed
SD_CARD_ERROR_ERASE_SINGLE_BLOCK = 0x0D, // card not capable of single block erase
SD_CARD_ERROR_ERASE_TIMEOUT = 0x0E, // Erase sequence timed out
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_TIMEOUT = 0x11, // timeout while waiting for start of read data
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
while (dirFile->curPosition_ < dirFile->fileSize_) {
index = 0XF & (dirFile->curPosition_ >> 5);
index = 0xF & (dirFile->curPosition_ >> 5);
p = dirFile->readDirCache();
if (!p) return false;
@ -705,7 +705,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, uint16_t index, uint8_t oflag) {
return false;
}
// open cached entry
return openCachedEntry(index & 0XF, oflag);
return openCachedEntry(index & 0xF, oflag);
}
// open a cached directory entry. Assumes vol_ is initialized
@ -775,7 +775,7 @@ bool SdBaseFile::openNext(SdBaseFile* dirFile, uint8_t oflag) {
vol_ = dirFile->vol_;
while (1) {
index = 0XF & (dirFile->curPosition_ >> 5);
index = 0xF & (dirFile->curPosition_ >> 5);
// read entry into cache
p = dirFile->readDirCache();
@ -1100,7 +1100,7 @@ dir_t* SdBaseFile::readDirCache() {
if (!isDir()) return 0;
// index of entry in cache
i = (curPosition_ >> 5) & 0XF;
i = (curPosition_ >> 5) & 0xF;
// use read to locate and cache block
if (read() < 0) return 0;

View File

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