@@ -182,12 +182,12 @@ class File : public FatFile, public Stream { | |||
} | |||
/** Opens the next file or folder in a directory. | |||
* | |||
* \param[in] mode open mode flags. | |||
* \param[in] oflag open oflag flags. | |||
* \return a File object. | |||
*/ | |||
File openNextFile(uint8_t mode = O_RDONLY) { | |||
File openNextFile(oflag_t oflag = O_RDONLY) { | |||
File tmpFile; | |||
tmpFile.openNext(this, mode); | |||
tmpFile.openNext(this, oflag); | |||
return tmpFile; | |||
} | |||
/** Read the next byte from a file. |
@@ -138,7 +138,7 @@ bool FatFile::createContiguous(FatFile* dirFile, | |||
DBG_FAIL_MACRO; | |||
goto fail; | |||
} | |||
if (!open(dirFile, path, O_CREAT | O_EXCL | O_RDWR)) { | |||
if (!open(dirFile, path, O_RDWR | O_CREAT | O_EXCL)) { | |||
DBG_FAIL_MACRO; | |||
goto fail; | |||
} | |||
@@ -311,12 +311,12 @@ bool FatFile::mkdir(FatFile* parent, fname_t* fname) { | |||
goto fail; | |||
} | |||
// create a normal file | |||
if (!open(parent, fname, O_CREAT | O_EXCL | O_RDWR)) { | |||
if (!open(parent, fname, O_RDWR | O_CREAT | O_EXCL)) { | |||
DBG_FAIL_MACRO; | |||
goto fail; | |||
} | |||
// convert file to directory | |||
m_flags = O_RDONLY; | |||
m_flags = F_READ; | |||
m_attr = FILE_ATTR_SUBDIR; | |||
// allocate and zero first cluster | |||
@@ -1387,7 +1387,7 @@ int FatFile::write(const void* buf, size_t nbyte) { | |||
goto fail; | |||
} | |||
// seek to end of file if append flag | |||
if ((m_flags & O_APPEND)) { | |||
if ((m_flags & F_APPEND)) { | |||
if (!seekSet(m_fileSize)) { | |||
DBG_FAIL_MACRO; | |||
goto fail; | |||
@@ -1505,7 +1505,7 @@ int FatFile::write(const void* buf, size_t nbyte) { | |||
m_flags |= F_FILE_DIR_DIRTY; | |||
} | |||
if (m_flags & O_SYNC) { | |||
if (m_flags & F_SYNC) { | |||
if (!sync()) { | |||
DBG_FAIL_MACRO; | |||
goto fail; |
@@ -44,9 +44,10 @@ void SdSpiAltDriver::activate() { | |||
*/ | |||
void SdSpiAltDriver::begin(uint8_t csPin) { | |||
m_csPin = csPin; | |||
m_spi->begin(m_csPin); | |||
// Next line is redundant - begin(m_csPin) sets csPin to output mode. | |||
pinMode(m_csPin, OUTPUT); | |||
digitalWrite(m_csPin, HIGH); | |||
m_spi->begin(); | |||
} | |||
//------------------------------------------------------------------------------ | |||
/** | |||
@@ -73,9 +74,9 @@ uint8_t SdSpiAltDriver::receive() { | |||
*/ | |||
uint8_t SdSpiAltDriver::receive(uint8_t* buf, size_t n) { | |||
SPI_DMA_TransferCompleted = false; | |||
m_spi->transfer(0, buf, n, SD_SPI_DMA_TransferComplete_Callback); | |||
m_spi->transfer(nullptr, buf, n, SD_SPI_DMA_TransferComplete_Callback); | |||
while (!SPI_DMA_TransferCompleted) {} | |||
return 0; | |||
return 0; | |||
} | |||
//------------------------------------------------------------------------------ | |||
/** Send a byte. | |||
@@ -94,7 +95,7 @@ void SdSpiAltDriver::send(uint8_t b) { | |||
void SdSpiAltDriver::send(const uint8_t* buf , size_t n) { | |||
SPI_DMA_TransferCompleted = false; | |||
m_spi->transfer(const_cast<uint8_t*>(buf), 0, n, | |||
m_spi->transfer(const_cast<uint8_t*>(buf), nullptr, n, | |||
SD_SPI_DMA_TransferComplete_Callback); | |||
while (!SPI_DMA_TransferCompleted) {} |
@@ -75,7 +75,7 @@ uint8_t SdSpiAltDriver::receive() { | |||
*/ | |||
uint8_t SdSpiAltDriver::receive(uint8_t* buf, size_t n) { | |||
#if USE_STM32_DMA | |||
return m_spi->dmaTransfer(0, buf, n); | |||
return m_spi->dmaTransfer(nullptr, buf, n); | |||
#else // USE_STM32_DMA | |||
m_spi->read(buf, n); | |||
return 0; | |||
@@ -97,7 +97,7 @@ void SdSpiAltDriver::send(uint8_t b) { | |||
*/ | |||
void SdSpiAltDriver::send(const uint8_t* buf , size_t n) { | |||
#if USE_STM32_DMA | |||
m_spi->dmaTransfer(const_cast<uint8*>(buf), 0, n); | |||
m_spi->dmaTransfer(const_cast<uint8*>(buf), nullptr, n); | |||
#else // USE_STM32_DMA | |||
m_spi->write(const_cast<uint8*>(buf), n); | |||
#endif // USE_STM32_DMA |