@@ -1,62 +1,27 @@ | |||
### Warning: This beta version is now out of date. Use standard version of SdFat. | |||
### Warning: This beta is for testing with Particle IoT mesh devices. | |||
Teensy 3.5/3.6 SDIO support has been added. Try the TeensySdioDemo example. | |||
Many other example will work with Teensy SDIO if you use the SdFatSdio classes | |||
and call begin with no parameters. | |||
This version of SdFat has been modified to use standard POSIX/Linux | |||
definitions of open flags from fcntl.h. | |||
``` | |||
SdFatSdio sd; | |||
.... | |||
if (!sd.begin()) { | |||
// Handle failure. | |||
} | |||
``` | |||
Recent versions of the Arduino IDE have bugs that may cause SdFat-beta to crash. | |||
https://forum.arduino.cc/index.php?topic=419264.0 | |||
SdFat-beta was tested using Arduino AVR boards 1.6.11. | |||
If you are using IDE 1.6.11 you must also install AVR boards 1.6.11, not | |||
1.6.12 or 1.6.13. | |||
If you are using Arduino IDE 1.6.11, do Tools > Board > Boards Manager > Arduino AVR Boards > 1.6.11 > Install > Close. | |||
Key changes: | |||
Open flags are include access modes, O_RDONLY, O_RDWR, O_WRONLY, and modifiers | |||
O_APPEND, O_CREAT, O_EXCL, O_SYNC, O_TRUNC. | |||
The SPI divisor has been replaced by SPISettings. | |||
Rename this folder SdFat and place it in the standard place for libraries. | |||
There are two new classes, SdFatEX and SdFatSoftSpiEX. | |||
I tested with a particle CLI project with a SdFat in a lib | |||
Please read changes.txt and the html documentation for more information. | |||
Please report problems as issues. | |||
The Arduino SdFat library provides read/write access to FAT16/FAT32 | |||
file systems on SD/SDHC flash cards. | |||
SdFat requires Arduino 1.6x or greater. | |||
To use SdFat, unzip the download file and place the SdFat folder | |||
into the libraries sub-folder in your main sketch folder. | |||
For more information see the Manual installation section of this guide: | |||
``` | |||
\Users\bill\Documents\Particle\projects\SdFatMod>ls * | |||
README.md argon_firmware_1545324931631.bin project.properties | |||
http://arduino.cc/en/Guide/Libraries | |||
lib: | |||
SdFat | |||
A number of configuration options can be set by editing SdFatConfig.h | |||
define macros. See the html documentation for details | |||
src: | |||
SdFatMod.ino | |||
``` | |||
Read changes.txt if you have used previous releases of this library. | |||
The mods required changing the type for open flags from uint8_t to int so | |||
bugs are likely if any uint8_t local variables were missed. | |||
Please read the html documentation for this library. Start with | |||
html/index.html and read the Main Page. Next go to the Classes tab and | |||
read the documentation for the classes SdFat, SdFatEX, SdBaseFile, | |||
SdFile, File, StdioStream, ifstream, ofstream, and others. | |||
Please continue by reading the html documentation. | |||
Updated 5 Sep 2016 |
@@ -1,9 +0,0 @@ | |||
name=SdFat | |||
version=2016.7.24 | |||
author= | |||
maintainer= | |||
sentence=FAT16/FAT32 file system for SD cards. | |||
paragraph= | |||
category=Uncategorized | |||
url= | |||
architectures=* |
@@ -1,35 +0,0 @@ | |||
/* Arduino SdFat Library | |||
* Copyright (C) 2016 by William Greiman | |||
* | |||
* This file is part of the Arduino SdFat Library | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with the Arduino SdFat Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
*/ | |||
/** | |||
* \file | |||
* \brief Define block driver. | |||
*/ | |||
#ifndef BlockDriver_h | |||
#define BlockDriver_h | |||
#include "FatLib/BaseBlockDriver.h" | |||
#include "SdCard/SdSpiCard.h" | |||
//----------------------------------------------------------------------------- | |||
/** typedef for BlockDriver */ | |||
#if ENABLE_EXTENDED_TRANSFER_CLASS || ENABLE_SDIO_CLASS | |||
typedef BaseBlockDriver BlockDriver; | |||
#else // ENABLE_EXTENDED_TRANSFER_CLASS || ENABLE_SDIO_CLASS | |||
typedef SdSpiCard BlockDriver; | |||
#endif // ENABLE_EXTENDED_TRANSFER_CLASS || ENABLE_SDIO_CLASS | |||
#endif // BlockDriver_h |
@@ -1,67 +0,0 @@ | |||
/* FatLib Library | |||
* Copyright (C) 2013 by William Greiman | |||
* | |||
* This file is part of the FatLib Library | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with the FatLib Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef FatApiConstants_h | |||
#define FatApiConstants_h | |||
//------------------------------------------------------------------------------ | |||
// use the gnu style oflag in open() | |||
/** open() oflag for reading */ | |||
const uint8_t O_READ = 0X01; | |||
/** open() oflag - same as O_IN */ | |||
const uint8_t O_RDONLY = O_READ; | |||
/** open() oflag for write */ | |||
const uint8_t O_WRITE = 0X02; | |||
/** open() oflag - same as O_WRITE */ | |||
const uint8_t O_WRONLY = O_WRITE; | |||
/** open() oflag for reading and writing */ | |||
const uint8_t O_RDWR = (O_READ | O_WRITE); | |||
/** open() oflag mask for access modes */ | |||
const uint8_t O_ACCMODE = (O_READ | O_WRITE); | |||
/** The file offset shall be set to the end of the file prior to each write. */ | |||
const uint8_t O_APPEND = 0X04; | |||
/** synchronous writes - call sync() after each write */ | |||
const uint8_t O_SYNC = 0X08; | |||
/** truncate the file to zero length */ | |||
const uint8_t O_TRUNC = 0X10; | |||
/** set the initial position at the end of the file */ | |||
const uint8_t O_AT_END = 0X20; | |||
/** create the file if nonexistent */ | |||
const uint8_t O_CREAT = 0X40; | |||
/** If O_CREAT and O_EXCL are set, open() shall fail if the file exists */ | |||
const uint8_t O_EXCL = 0X80; | |||
// FatFile class static and const definitions | |||
// flags for ls() | |||
/** ls() flag for list all files including hidden. */ | |||
const uint8_t LS_A = 1; | |||
/** ls() flag to print modify. date */ | |||
const uint8_t LS_DATE = 2; | |||
/** ls() flag to print file size. */ | |||
const uint8_t LS_SIZE = 4; | |||
/** ls() flag for recursive list of subdirectories */ | |||
const uint8_t LS_R = 8; | |||
// flags for timestamp | |||
/** set the file's last access date */ | |||
const uint8_t T_ACCESS = 1; | |||
/** set the file's creation date and time */ | |||
const uint8_t T_CREATE = 2; | |||
/** Set the file's write date and time */ | |||
const uint8_t T_WRITE = 4; | |||
#endif // FatApiConstants_h |
@@ -1,33 +0,0 @@ | |||
/* FatLib Library | |||
* Copyright (C) 2013 by William Greiman | |||
* | |||
* This file is part of the FatLib Library | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with the FatLib Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef FatLib_h | |||
#define FatLib_h | |||
#include "ArduinoFiles.h" | |||
#include "ArduinoStream.h" | |||
#include "FatFileSystem.h" | |||
#include "FatLibConfig.h" | |||
#include "FatVolume.h" | |||
#include "FatFile.h" | |||
#include "StdioStream.h" | |||
#include "fstream.h" | |||
//------------------------------------------------------------------------------ | |||
/** FatFileSystem version YYYYMMDD */ | |||
#define FAT_LIB_VERSION 20150131 | |||
#endif // FatLib_h |
@@ -1,38 +0,0 @@ | |||
/* FatLib Library | |||
* Copyright (C) 2013 by William Greiman | |||
* | |||
* This file is part of the FatLib Library | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with the FatLib Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef FmtNumber_h | |||
#define FmtNumber_h | |||
// #include <ctype.h> | |||
inline bool isDigit(char c) { | |||
return '0' <= c && c <= '9'; | |||
} | |||
inline bool isSpace(char c) { | |||
return c == ' ' || (0X9 <= c && c <= 0XD); | |||
} | |||
#include <math.h> | |||
#include <stdint.h> | |||
char* fmtDec(uint16_t n, char* p); | |||
char* fmtDec(uint32_t n, char* p); | |||
char* fmtFloat(float value, char* p, uint8_t prec); | |||
char* fmtFloat(float value, char* ptr, uint8_t prec, char expChar); | |||
char* fmtHex(uint32_t n, char* p); | |||
float scale10(float v, int8_t n); | |||
float scanFloat(const char* str, char** ptr); | |||
#endif // FmtNumber_h |
@@ -1,56 +0,0 @@ | |||
/* Arduino SdFat Library | |||
* Copyright (C) 2015 by William Greiman | |||
* | |||
* This file is part of the Arduino SdFat Library | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* You should have received a copy of the GNU General Public License | |||
* along with the Arduino SdFat Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef FreeStack_h | |||
#define FreeStack_h | |||
/** | |||
* \file | |||
* \brief FreeStack() function. | |||
*/ | |||
#if defined(__AVR__) || defined(DOXYGEN) | |||
/** boundary between stack and heap. */ | |||
extern char *__brkval; | |||
/** End of bss section.*/ | |||
extern char __bss_end; | |||
/** Amount of free stack space. | |||
* \return The number of free bytes. | |||
*/ | |||
static int FreeStack() { | |||
char* sp = reinterpret_cast<char*>(SP); | |||
return __brkval ? sp - __brkval : sp - &__bss_end; | |||
// char top; | |||
// return __brkval ? &top - __brkval : &top - &__bss_end; | |||
} | |||
#elif defined(PLATFORM_ID) // Particle board | |||
static int FreeStack() { | |||
return System.freeMemory(); | |||
} | |||
#elif defined(__arm__) | |||
extern "C" char* sbrk(int incr); | |||
static int FreeStack() { | |||
char top = 't'; | |||
return &top - reinterpret_cast<char*>(sbrk(0)); | |||
} | |||
#else | |||
#warning FreeStack is not defined for this system. | |||
static int FreeStack() { | |||
return 0; | |||
} | |||
#endif | |||
#endif // FreeStack_h |
@@ -1,62 +0,0 @@ | |||
/* Arduino SdFat Library | |||
* Copyright (C) 2012 by William Greiman | |||
* | |||
* This file is part of the Arduino SdFat Library | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with the Arduino SdFat Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
*/ | |||
/** | |||
* \file | |||
* \brief Minimal AVR Serial driver. | |||
*/ | |||
#ifndef MinimumSerial_h | |||
#define MinimumSerial_h | |||
#include "SysCall.h" | |||
//============================================================================== | |||
/** | |||
* \class MinimumSerial | |||
* \brief mini serial class for the %SdFat library. | |||
*/ | |||
class MinimumSerial : public Print { | |||
public: | |||
/** \return true for hardware serial */ | |||
operator bool() { return true; } | |||
/** | |||
* \return one if data is available. | |||
*/ | |||
int available(); | |||
/** | |||
* Set baud rate for serial port zero and enable in non interrupt mode. | |||
* Do not call this function if you use another serial library. | |||
* \param[in] baud rate | |||
*/ | |||
void begin(uint32_t baud); | |||
/** Wait for write done. */ | |||
void flush(); | |||
/** | |||
* Unbuffered read | |||
* \return -1 if no character is available or an available character. | |||
*/ | |||
int read(); | |||
/** | |||
* Unbuffered write | |||
* | |||
* \param[in] b byte to write. | |||
* \return 1 | |||
*/ | |||
size_t write(uint8_t b); | |||
using Print::write; | |||
}; | |||
#endif // MinimumSerial_h |
@@ -1,121 +0,0 @@ | |||
/* Arduino SdSpiAltDriver Library | |||
* Copyright (C) 2013 by William Greiman | |||
* | |||
* This file is part of the Arduino SdSpiAltDriver Library | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with the Arduino SdSpiAltDriver Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
*/ | |||
#if defined(__STM32F1__) | |||
#include "SdSpiDriver.h" | |||
#define USE_STM32F1_DMAC 1 | |||
//------------------------------------------------------------------------------ | |||
static SPIClass m_SPI1(1); | |||
#if BOARD_NR_SPI > 1 | |||
static SPIClass m_SPI2(2); | |||
#endif // BOARD_NR_SPI > 1 | |||
#if BOARD_NR_SPI > 2 | |||
static SPIClass m_SPI3(3); | |||
#endif // BOARD_NR_SPI > 2 | |||
// | |||
static SPIClass* pSpi[] = | |||
#if BOARD_NR_SPI == 1 | |||
{&m_SPI1}; | |||
#elif BOARD_NR_SPI == 2 | |||
{&m_SPI1, &m_SPI2}; | |||
#elif BOARD_NR_SPI == 3 | |||
{&m_SPI1, &m_SPI2, &m_SPI3}; | |||
#else // BOARD_NR_SPI | |||
#error "BOARD_NR_SPI too large" | |||
#endif // BOARD_NR_SPI | |||
//------------------------------------------------------------------------------ | |||
/** Set SPI options for access to SD/SDHC cards. | |||
* | |||
* \param[in] divisor SCK clock divider relative to the APB1 or APB2 clock. | |||
*/ | |||
void SdSpiAltDriver::activate() { | |||
pSpi[m_spiPort]->beginTransaction(m_spiSettings); | |||
} | |||
//------------------------------------------------------------------------------ | |||
/** Initialize the SPI bus. | |||
* | |||
* \param[in] chipSelectPin SD card chip select pin. | |||
*/ | |||
void SdSpiAltDriver::begin(uint8_t csPin) { | |||
m_csPin = csPin; | |||
pinMode(m_csPin, OUTPUT); | |||
digitalWrite(m_csPin, HIGH); | |||
pSpi[m_spiPort]->begin(); | |||
} | |||
//------------------------------------------------------------------------------ | |||
/** | |||
* End SPI transaction. | |||
*/ | |||
void SdSpiAltDriver::deactivate() { | |||
pSpi[m_spiPort]->endTransaction(); | |||
} | |||
//------------------------------------------------------------------------------ | |||
/** Receive a byte. | |||
* | |||
* \return The byte. | |||
*/ | |||
uint8_t SdSpiAltDriver::receive() { | |||
return pSpi[m_spiPort]->transfer(0XFF); | |||
} | |||
//------------------------------------------------------------------------------ | |||
/** Receive multiple bytes. | |||
* | |||
* \param[out] buf Buffer to receive the data. | |||
* \param[in] n Number of bytes to receive. | |||
* | |||
* \return Zero for no error or nonzero error code. | |||
*/ | |||
uint8_t SdSpiAltDriver::receive(uint8_t* buf, size_t n) { | |||
int rtn = 0; | |||
#if USE_STM32F1_DMAC | |||
rtn = pSpi[m_spiPort]->dmaTransfer(0, const_cast<uint8*>(buf), n); | |||
#else // USE_STM32F1_DMAC | |||
// pSpi[m_spiPort]->read(buf, n); fails ?? use byte transfer | |||
for (size_t i = 0; i < n; i++) { | |||
buf[i] = pSpi[m_spiPort]->transfer(0XFF); | |||
} | |||
#endif // USE_STM32F1_DMAC | |||
return rtn; | |||
} | |||
//------------------------------------------------------------------------------ | |||
/** Send a byte. | |||
* | |||
* \param[in] b Byte to send | |||
*/ | |||
void SdSpiAltDriver::send(uint8_t b) { | |||
pSpi[m_spiPort]->transfer(b); | |||
} | |||
//------------------------------------------------------------------------------ | |||
/** Send multiple bytes. | |||
* | |||
* \param[in] buf Buffer for data to be sent. | |||
* \param[in] n Number of bytes to send. | |||
*/ | |||
void SdSpiAltDriver::send(const uint8_t* buf , size_t n) { | |||
#if USE_STM32F1_DMAC | |||
pSpi[m_spiPort]->dmaSend(const_cast<uint8*>(buf), n); | |||
#else // #if USE_STM32F1_DMAC | |||
pSpi[m_spiPort]->write(buf, n); | |||
#endif // USE_STM32F1_DMAC | |||
} | |||
//----------------------------------------------------------------------------- | |||
void SdSpiAltDriver::setPort(uint8_t portNumber) { | |||
m_spiPort = portNumber < 1 || portNumber > BOARD_NR_SPI ? 0 : portNumber -1; | |||
} | |||
#endif // defined(__STM32F1__) |
@@ -1,45 +0,0 @@ | |||
/* Arduino SdFat Library | |||
* Copyright (C) 2011 by William Greiman | |||
* | |||
* This file is part of the Arduino SdFat Library | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with the Arduino SdFat Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
*/ | |||
#ifndef SdFatTestSuite_h | |||
#define SdFatTestSuite_h | |||
#include <SdFat.h> | |||
#include <SdFatUtil.h> | |||
#if defined(__arm__) && !defined(strcmp_P) | |||
#define strcmp_P(a, b) strcmp((a), (b)) | |||
#endif // strcmp_P | |||
#if defined(__arm__) && !defined(strncpy_P) | |||
#define strncpy_P(s, t, n) strncpy(s, t, n) | |||
#endif // strncpy_P | |||
#if defined(__arm__) && !defined(strlen_P) | |||
#define strlen_P(str) strlen(str) | |||
#endif // strlen_P | |||
#define testVerifyBool(result) testVerify_P(result, PSTR(#result)) | |||
#define testVerifyMsg(result, msg) testVerify_P(result, PSTR(msg)) | |||
#define testVerifyStr(result, expect) testVerify_P(result, PSTR(expect)) | |||
void testBegin(); | |||
void testEnd(); | |||
void testVerify_P(bool b, PGM_P msg); | |||
void testVerify_P(char* result, PGM_P expect); | |||
#endif // SdFatTestSuite_h |
@@ -2,6 +2,7 @@ | |||
// uses RTClib from https://github.com/adafruit/RTClib | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
#include "FreeStack.h" | |||
#define SD_CHIP_SELECT SS // SD chip select pin |
@@ -1,5 +1,6 @@ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// create a serial output stream | |||
ArduinoOutStream cout(Serial); |
@@ -7,6 +7,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD chip select pin | |||
const uint8_t chipSelect = SS; |
@@ -3,6 +3,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD chip select pin | |||
const uint8_t chipSelect = SS; |
@@ -3,6 +3,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// create a serial output stream | |||
ArduinoOutStream cout(Serial); |
@@ -3,6 +3,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// create serial output stream | |||
ArduinoOutStream cout(Serial); |
@@ -3,7 +3,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD chip select pin | |||
const uint8_t chipSelect = SS; | |||
@@ -1,6 +1,7 @@ | |||
// Demo of rewriting a line read by fgets | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD card chip select pin | |||
const uint8_t chipSelect = SS; | |||
@@ -65,7 +66,7 @@ void demoFgets() { | |||
//------------------------------------------------------------------------------ | |||
void makeTestFile() { | |||
// create or open test file | |||
SdFile wrfile("fgets.txt", O_WRITE | O_CREAT | O_TRUNC); | |||
SdFile wrfile("fgets.txt", O_WRONLY | O_CREAT | O_TRUNC); | |||
// check for open error | |||
if (!wrfile.isOpen()) { |
@@ -4,6 +4,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD chip select pin | |||
const uint8_t chipSelect = SS; |
@@ -436,7 +436,7 @@ void binaryToCsv() { | |||
return; | |||
} | |||
binFile.rewind(); | |||
if (!binFile.read(&buf , 512) == 512) { | |||
if (binFile.read(&buf , 512) != 512) { | |||
error("Read metadata failed"); | |||
} | |||
// Create a new csv file. | |||
@@ -517,7 +517,7 @@ void checkOverrun() { | |||
binFile.rewind(); | |||
Serial.println(); | |||
Serial.println(F("Checking overrun errors - type any character to stop")); | |||
if (!binFile.read(&buf , 512) == 512) { | |||
if (binFile.read(&buf , 512) != 512) { | |||
error("Read metadata failed"); | |||
} | |||
bn++; |
@@ -3,7 +3,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD card chip select pin. | |||
const uint8_t chipSelect = SS; | |||
//------------------------------------------------------------------------------ | |||
@@ -53,7 +53,7 @@ void setup() { | |||
int rootFileCount = 0; | |||
sd.vwd()->rewind(); | |||
while (file.openNext(sd.vwd(), O_READ)) { | |||
while (file.openNext(sd.vwd(), O_RDONLY)) { | |||
if (!file.isHidden()) { | |||
rootFileCount++; | |||
} | |||
@@ -73,7 +73,7 @@ void setup() { | |||
cout << F("Created Folder1\n"); | |||
// Create a file in Folder1 using a path. | |||
if (!file.open("Folder1/file1.txt", O_CREAT | O_WRITE)) { | |||
if (!file.open("Folder1/file1.txt", O_WRONLY | O_CREAT)) { | |||
error("create Folder1/file1.txt failed"); | |||
} | |||
file.close(); | |||
@@ -86,7 +86,7 @@ void setup() { | |||
cout << F("chdir to Folder1\n"); | |||
// Create File2.txt in current directory. | |||
if (!file.open("File2.txt", O_CREAT | O_WRITE)) { | |||
if (!file.open("File2.txt", O_WRONLY | O_CREAT)) { | |||
error("create File2.txt failed"); | |||
} | |||
file.close(); |
@@ -41,10 +41,10 @@ void setup() { | |||
Serial.println(); | |||
// List files in root directory. | |||
if (!dirFile.open("/", O_READ)) { | |||
if (!dirFile.open("/", O_RDONLY)) { | |||
sd.errorHalt("open root failed"); | |||
} | |||
while (n < nMax && file.openNext(&dirFile, O_READ)) { | |||
while (n < nMax && file.openNext(&dirFile, O_RDONLY)) { | |||
// Skip directories and hidden files. | |||
if (!file.isSubDir() && !file.isHidden()) { | |||
@@ -81,7 +81,7 @@ void loop() { | |||
return; | |||
} | |||
Serial.println(i); | |||
if (!file.open(&dirFile, dirIndex[i], O_READ)) { | |||
if (!file.open(&dirFile, dirIndex[i], O_RDONLY)) { | |||
sd.errorHalt(F("open")); | |||
} | |||
Serial.println(); |
@@ -197,7 +197,7 @@ void binaryToCsv() { | |||
strcpy(csvName, binName); | |||
strcpy(&csvName[BASE_NAME_SIZE + 3], "csv"); | |||
if (!csvFile.open(csvName, O_WRITE | O_CREAT | O_TRUNC)) { | |||
if (!csvFile.open(csvName, O_WRONLY | O_CREAT | O_TRUNC)) { | |||
error("open csvFile failed"); | |||
} | |||
binFile.rewind(); | |||
@@ -338,7 +338,7 @@ void openBinFile() { | |||
} | |||
binFile.close(); | |||
strcpy(binName, name); | |||
if (!binFile.open(binName, O_READ)) { | |||
if (!binFile.open(binName, O_RDONLY)) { | |||
Serial.println(F("open failed")); | |||
return; | |||
} |
@@ -197,7 +197,7 @@ void binaryToCsv() { | |||
strcpy(csvName, binName); | |||
strcpy(&csvName[BASE_NAME_SIZE + 3], "csv"); | |||
if (!csvFile.open(csvName, O_WRITE | O_CREAT | O_TRUNC)) { | |||
if (!csvFile.open(csvName, O_WRONLY | O_CREAT | O_TRUNC)) { | |||
error("open csvFile failed"); | |||
} | |||
binFile.rewind(); | |||
@@ -338,7 +338,7 @@ void openBinFile() { | |||
} | |||
binFile.close(); | |||
strcpy(binName, name); | |||
if (!binFile.open(binName, O_READ)) { | |||
if (!binFile.open(binName, O_RDONLY)) { | |||
Serial.println(F("open failed")); | |||
return; | |||
} |
@@ -197,7 +197,7 @@ void binaryToCsv() { | |||
strcpy(csvName, binName); | |||
strcpy(&csvName[BASE_NAME_SIZE + 3], "csv"); | |||
if (!csvFile.open(csvName, O_WRITE | O_CREAT | O_TRUNC)) { | |||
if (!csvFile.open(csvName, O_WRONLY | O_CREAT | O_TRUNC)) { | |||
error("open csvFile failed"); | |||
} | |||
binFile.rewind(); | |||
@@ -338,7 +338,7 @@ void openBinFile() { | |||
} | |||
binFile.close(); | |||
strcpy(binName, name); | |||
if (!binFile.open(binName, O_READ)) { | |||
if (!binFile.open(binName, O_RDONLY)) { | |||
Serial.println(F("open failed")); | |||
return; | |||
} |
@@ -35,7 +35,7 @@ void setup() { | |||
// Warning, openNext starts at the current position of sd.vwd() so a | |||
// rewind may be neccessary in your application. | |||
sd.vwd()->rewind(); | |||
while (file.openNext(sd.vwd(), O_READ)) { | |||
while (file.openNext(sd.vwd(), O_RDONLY)) { | |||
file.printFileSize(&Serial); | |||
Serial.write(' '); | |||
file.printModifyDateTime(&Serial); |
@@ -3,6 +3,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
#include "FreeStack.h" | |||
// SD chip select pin | |||
@@ -64,7 +65,7 @@ void loop() { | |||
char fileName[13] = "bench0.txt"; | |||
fileName[5] = '0' + test; | |||
// open or create file - truncate existing file. | |||
if (!file.open(fileName, O_CREAT | O_TRUNC | O_RDWR)) { | |||
if (!file.open(fileName, O_RDWR | O_CREAT | O_TRUNC)) { | |||
error("open failed"); | |||
} | |||
maxLatency = 0; |
@@ -2,6 +2,7 @@ | |||
// | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// | |||
// Set DISABLE_CHIP_SELECT to disable a second SPI device. | |||
// For example, with the Ethernet shield, set DISABLE_CHIP_SELECT |
@@ -12,6 +12,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
#include "FreeStack.h" | |||
// SD chip select pin |
@@ -55,7 +55,7 @@ int csvReadText(File* file, char* str, size_t size, char delim) { | |||
rtn = ch; | |||
break; | |||
} | |||
if ((n+1) >= size) { | |||
if ((n + 1) >= size) { | |||
// string too long | |||
rtn = -2; | |||
n--; |
@@ -4,6 +4,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD chip select pin | |||
const uint8_t chipSelect = SS; |
@@ -33,11 +33,7 @@ void setup() { | |||
Serial.begin(9600); | |||
// Wait for USB Serial | |||
while (!Serial) { | |||
SysCall::yield(); | |||
} | |||
Serial.print(F("FreeStack: ")); | |||
Serial.println(FreeStack()); | |||
// fill buffer with known data | |||
for (size_t i = 0; i < sizeof(buf); i++) { | |||
@@ -46,8 +42,9 @@ void setup() { | |||
Serial.println(F("type any character to start")); | |||
while (!Serial.available()) { | |||
SysCall::yield(); | |||
} | |||
Serial.print(F("FreeStack: ")); | |||
Serial.println(FreeStack()); | |||
// initialize the first card | |||
if (!sd1.begin(SD1_CS, SD_SCK_MHZ(18))) { | |||
@@ -123,7 +120,7 @@ void setup() { | |||
// create or open /Dir2/copy.bin and truncate it to zero length | |||
SdFile file2; | |||
if (!file2.open("copy.bin", O_WRITE | O_CREAT | O_TRUNC)) { | |||
if (!file2.open("copy.bin", O_WRONLY | O_CREAT | O_TRUNC)) { | |||
sd2.errorExit("file2"); | |||
} | |||
Serial.println(F("Copying test.bin to copy.bin")); |
@@ -30,6 +30,7 @@ const uint8_t chipSelect = SS; | |||
#define DEBUG_PRINT 0 | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
#if DEBUG_PRINT | |||
#include "FreeStack.h" | |||
#endif // DEBUG_PRINT |
@@ -3,6 +3,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// Set USE_SDIO to zero for SPI card access. | |||
#define USE_SDIO 0 |
@@ -36,7 +36,7 @@ void setup() { | |||
sd.initErrorHalt(); | |||
} | |||
if (!file.open("SoftSPI.txt", O_CREAT | O_RDWR)) { | |||
if (!file.open("SoftSPI.txt", O_RDWR O _CREAT)) { | |||
sd.errorHalt(F("open failed")); | |||
} | |||
file.println(F("This line was printed using software SPI.")); |
@@ -53,7 +53,7 @@ void setup() { | |||
for (uint8_t dataType = 0; dataType < 5; dataType++) { | |||
for (uint8_t fileType = 0; fileType < 2; fileType++) { | |||
if (!fileType) { | |||
if (!printFile.open("print.txt", O_CREAT | O_RDWR | O_TRUNC)) { | |||
if (!printFile.open("print.txt", O_RDWR | O_CREAT | O_TRUNC)) { | |||
Serial.println(F("open fail")); | |||
return; | |||
} |
@@ -4,6 +4,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
SdFat sd; | |||
@@ -95,7 +96,7 @@ void setup(void) { | |||
sd.remove("stamp.txt"); | |||
// create a new file with default timestamps | |||
if (!file.open("default.txt", O_CREAT | O_WRITE)) { | |||
if (!file.open("default.txt", O_WRONLY | O_CREAT)) { | |||
error("open default.txt failed"); | |||
} | |||
cout << F("\nOpen with default times\n"); | |||
@@ -118,7 +119,7 @@ void setup(void) { | |||
SdFile::dateTimeCallback(dateTime); | |||
// create a new file with callback timestamps | |||
if (!file.open("callback.txt", O_CREAT | O_WRITE)) { | |||
if (!file.open("callback.txt", O_WRONLY | O_CREAT)) { | |||
error("open callback.txt failed"); | |||
} | |||
cout << ("\nOpen with callback times\n"); | |||
@@ -150,7 +151,7 @@ void setup(void) { | |||
SdFile::dateTimeCallbackCancel(); | |||
// create a new file with default timestamps | |||
if (!file.open("stamp.txt", O_CREAT | O_WRITE)) { | |||
if (!file.open("stamp.txt", O_WRONLY | O_CREAT)) { | |||
error("open stamp.txt failed"); | |||
} | |||
// set creation date time |
@@ -117,7 +117,7 @@ void setup() { | |||
// create or open /Dir2/copy.bin and truncate it to zero length | |||
SdFile file2; | |||
if (!file2.open("copy.bin", O_WRITE | O_CREAT | O_TRUNC)) { | |||
if (!file2.open("copy.bin", O_WRONLY | O_CREAT | O_TRUNC)) { | |||
sd2.errorExit("file2"); | |||
} | |||
Serial.println(F("Copying test.bin to copy.bin")); |
@@ -3,6 +3,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
/* | |||
* SD chip select pin. Common values are: | |||
* | |||
@@ -61,7 +62,7 @@ void setup() { | |||
printFreeSpace(); | |||
cout << F("Create and write to ") << TEST_FILE << endl; | |||
if (!file.open(TEST_FILE, O_WRITE | O_CREAT)) { | |||
if (!file.open(TEST_FILE, O_WRONLY | O_CREAT)) { | |||
sd.errorHalt(F("Create failed")); | |||
} | |||
file.print(F("Cause a cluster to be allocated")); |
@@ -3,6 +3,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
#include "FreeStack.h" | |||
// Set USE_SDIO to zero for SPI card access. | |||
@@ -130,12 +131,12 @@ void loop() { | |||
cidDmp(); | |||
// open or create file - truncate existing file. | |||
if (!file.open("bench.dat", O_CREAT | O_TRUNC | O_RDWR)) { | |||
if (!file.open("bench.dat", O_RDWR | O_CREAT | O_TRUNC)) { | |||
error("open failed"); | |||
} | |||
// fill buf with known data | |||
for (uint16_t i = 0; i < (BUF_SIZE-2); i++) { | |||
for (size_t i = 0; i < (BUF_SIZE-2); i++) { | |||
buf[i] = 'A' + (i % 26); | |||
} | |||
buf[BUF_SIZE-2] = '\r'; |
@@ -99,7 +99,7 @@ void setup() { | |||
error("Can't create file name"); | |||
} | |||
} | |||
if (!file.open(fileName, O_CREAT | O_WRITE | O_EXCL)) { | |||
if (!file.open(fileName, O_WRONLY | O_CREAT | O_EXCL)) { | |||
error("file.open"); | |||
} | |||
// Read any Serial data. |
@@ -1,6 +1,7 @@ | |||
// Demo of fgets function to read lines from a file. | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD chip select pin | |||
const uint8_t chipSelect = SS; | |||
@@ -16,7 +17,7 @@ void demoFgets() { | |||
char line[25]; | |||
int n; | |||
// open test file | |||
SdFile rdfile("fgets.txt", O_READ); | |||
SdFile rdfile("fgets.txt", O_RDONLY); | |||
// check for open error | |||
if (!rdfile.isOpen()) { | |||
@@ -40,7 +41,7 @@ void demoFgets() { | |||
//------------------------------------------------------------------------------ | |||
void makeTestFile() { | |||
// create or open test file | |||
SdFile wrfile("fgets.txt", O_WRITE | O_CREAT | O_TRUNC); | |||
SdFile wrfile("fgets.txt", O_WRONLY | O_CREAT | O_TRUNC); | |||
// check for open error | |||
if (!wrfile.isOpen()) { |
@@ -4,6 +4,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// create Serial stream | |||
ArduinoOutStream cout(Serial); |
@@ -8,6 +8,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD chip select pin | |||
const uint8_t chipSelect = SS; |
@@ -4,6 +4,7 @@ | |||
*/ | |||
#include <SPI.h> | |||
#include "SdFat.h" | |||
#include "sdios.h" | |||
// SD chip select pin | |||
const uint8_t chipSelect = SS; | |||
@@ -45,7 +46,7 @@ void setup() { | |||
} | |||
} | |||
// create a file and write one line to the file | |||
SdFile file("Name1.txt", O_WRITE | O_CREAT); | |||
SdFile file("Name1.txt", O_WRONLY | O_CREAT); | |||
if (!file.isOpen()) { | |||
error("Name1.txt"); | |||
} | |||
@@ -91,7 +92,7 @@ void setup() { | |||
} | |||
// open file for append in new location and add a line | |||
if (!file.open("dir2/DIR3/NAME3.txt", O_WRITE | O_APPEND)) { | |||
if (!file.open("dir2/DIR3/NAME3.txt", O_WRONLY | O_APPEND)) { | |||
error("dir2/DIR3/NAME3.txt"); | |||
} | |||
file.println("A line for dir2/DIR3/NAME3.txt"); |
@@ -21,8 +21,7 @@ You may need to increase the time between samples if your card has higher | |||
latency. Using a Mega Arduino can help since it has more buffering. | |||
The bintocsv folder contains a PC program for converting binary files to | |||
CSV files. I have included a executable for Windows. Linux and Mac users | |||
can build from the included source files. bintocvs is a command line program. | |||
CSV files. Build it from the included source files. bintocvs is a command line program. | |||
bintocsv binFile csvFile | |||
@@ -1,23 +1,27 @@ | |||
/* Arduino SdFat Library | |||
* Copyright (C) 2012 by William Greiman | |||
/** | |||
* Copyright (c) 20011-2017 Bill Greiman | |||
* This file is part of the SdFat library for SD memory cards. | |||
* | |||
* This file is part of the Arduino SdFat Library | |||
* MIT License | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* Permission is hereby granted, free of charge, to any person obtaining a | |||
* copy of this software and associated documentation files (the "Software"), | |||
* to deal in the Software without restriction, including without limitation | |||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
* and/or sell copies of the Software, and to permit persons to whom the | |||
* Software is furnished to do so, subject to the following conditions: | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* The above copyright notice and this permission notice shall be included | |||
* in all copies or substantial portions of the Software. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with the Arduino SdFat Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |||
* DEALINGS IN THE SOFTWARE. | |||
*/ | |||
/** | |||
\mainpage Arduino %SdFat Library | |||
<CENTER>Copyright © 2012, 2013, 2014, 2015, 2016 by William Greiman | |||
@@ -38,9 +42,9 @@ The main classes in %SdFat are SdFat, SdFatEX, SdFatSoftSpi, SdFatSoftSpiEX, | |||
SdBaseFile, SdFile, File, StdioStream, \ref fstream, \ref ifstream, | |||
and \ref ofstream. | |||
The SdFat, SdFatEX, SdFatSoftSpi and SdFatSoftSpiEX classes maintain a | |||
The SdFat, SdFatEX, SdFatSoftSpi and SdFatSoftSpiEX classes maintain a | |||
FAT volume, a current working directory, and simplify initialization | |||
of other classes. The SdFat and SdFatEX classes uses a fast custom hardware SPI | |||
of other classes. The SdFat and SdFatEX classes uses a fast custom hardware SPI | |||
implementation. The SdFatSoftSpi and SdFatSoftSpiEX classes uses software SPI. | |||
the SdFatEX and SdFatSoftSpiEX use extended multi-block I/O for enhanced | |||
@@ -109,7 +113,7 @@ will be defined. If the symbol ENABLE_SOFTWARE_SPI_CLASS is also nonzero, | |||
the class SdFatSoftSpiEX will be defined. | |||
These classes used extended multi-block SD I/O for better performance. | |||
the SPI bus may not be shared with other devices in this mode. | |||
Set USE_STANDARD_SPI_LIBRARY and ENABLE_SOFTWARE_SPI_CLASS to | |||
enable various SPI options. set USE_STANDARD_SPI_LIBRARY to use the standard | |||
Arduino SPI library. set ENABLE_SOFTWARE_SPI_CLASS to enable the SdFatSoftSpi | |||
@@ -218,7 +222,7 @@ the bug or problem. | |||
The two example programs QuickStart, and SdInfo are useful for troubleshooting. | |||
A message like this from SdInfo with erorCode 0X1 indicates the SD card | |||
A message like this from SdInfo with errorCode 0X1 indicates the SD card | |||
is not seen by SdFat. This is often caused by a wiring error and reformatting | |||
the card will not solve the problem. | |||
<PRE> | |||
@@ -236,7 +240,7 @@ Does another SPI device need to be disabled? | |||
Is there a wiring/soldering problem? | |||
errorCode: 0x1, errorData: 0xff | |||
</PRE> | |||
</PRE> | |||
Here is a message from QuickStart that indicates a formatting problem: | |||
<PRE> | |||
Card successfully initialized. | |||
@@ -284,13 +288,13 @@ Short names are always converted to upper case and their original case | |||
value is lost. Files that have a base-name where all characters have the | |||
same case and an extension where all characters have the same case will | |||
display properly. Examples this type name are UPPER.low, lower.TXT, | |||
UPPER.TXT, and lower.txt. | |||
UPPER.TXT, and lower.txt. | |||
An application which writes to a file using print(), println() or | |||
write() must close the file or call sync() at the appropriate time to | |||
force data and directory information to be written to the SD Card. | |||
Applications must use care calling sync() sync() | |||
Applications must use care calling sync() | |||
since 2048 bytes of I/O is required to update file and | |||
directory information. This includes writing the current data block, reading | |||
the block that contains the directory entry for update, writing the directory |
@@ -1,21 +1,26 @@ | |||
/* Arduino SdFat Library | |||
* Copyright (C) 2011 by William Greiman | |||
/** | |||
* Copyright (c) 20011-2017 Bill Greiman | |||
* This file is part of the SdFat library for SD memory cards. | |||
* | |||
* This file is part of the Arduino SdFat Library | |||
* MIT License | |||
* | |||
* This Library is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* Permission is hereby granted, free of charge, to any person obtaining a | |||
* copy of this software and associated documentation files (the "Software"), | |||
* to deal in the Software without restriction, including without limitation | |||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
* and/or sell copies of the Software, and to permit persons to whom the | |||
* Software is furnished to do so, subject to the following conditions: | |||
* | |||
* This Library is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* The above copyright notice and this permission notice shall be included | |||
* in all copies or substantial portions of the Software. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with the Arduino SdFat Library. If not, see | |||
* <http://www.gnu.org/licenses/>. | |||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |||
* DEALINGS IN THE SOFTWARE. | |||
*/ | |||
#include <SdFatTestSuite.h> | |||
static uint16_t failCount; | |||
@@ -36,8 +41,8 @@ void testBegin() { | |||
while (Serial.read() <= 0) {} | |||
delay(200); // Catch Due reset problem | |||
testOut->print(F("FreeRam: ")); | |||
testOut->println(FreeRam()); | |||
testOut->print(F("FreeStack: ")); | |||
testOut->println(FreeStack()); | |||
testOut->println(); | |||
failCount = 0; | |||
testCount = 0; | |||
@@ -46,8 +51,8 @@ void testBegin() { | |||
void testEnd() { | |||
testOut->println(); | |||
testOut->println(F("Compiled: " __DATE__ " " __TIME__)); | |||
testOut->print(F("FreeRam: ")); | |||
testOut->println(FreeRam()); | |||
testOut->print(F("FreeStack: ")); | |||
testOut->println(FreeStack()); | |||
testOut->print(F("Test count: ")); | |||
testOut->println(testCount); | |||
testOut->print(F("Fail count: ")); |
@@ -0,0 +1,50 @@ | |||
/** | |||
* Copyright (c) 20011-2017 Bill Greiman | |||
* This file is part of the SdFat library for SD memory cards. | |||
* | |||
* MIT License | |||
* | |||
* Permission is hereby granted, free of charge, to any person obtaining a | |||
* copy of this software and associated documentation files (the "Software"), | |||
* to deal in the Software without restriction, including without limitation | |||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
* and/or sell copies of the Software, and to permit persons to whom the | |||
* Software is furnished to do so, subject to the following conditions: | |||
* | |||
* The above copyright notice and this permission notice shall be included | |||
* in all copies or substantial portions of the Software. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |||
* DEALINGS IN THE SOFTWARE. | |||
*/ | |||
#ifndef SdFatTestSuite_h | |||
#define SdFatTestSuite_h | |||
#include "SdFat.h" | |||
#include "FreeStack.h" | |||
#if defined(__arm__) && !defined(strcmp_P) | |||
#define strcmp_P(a, b) strcmp((a), (b)) | |||
#endif // strcmp_P | |||
#if defined(__arm__) && !defined(strncpy_P) | |||
#define strncpy_P(s, t, n) strncpy(s, t, n) | |||
#endif // strncpy_P | |||
#if defined(__arm__) && !defined(strlen_P) | |||
#define strlen_P(str) strlen(str) | |||
#endif // strlen_P | |||
#define testVerifyBool(result) testVerify_P(result, PSTR(#result)) | |||
#define testVerifyMsg(result, msg) testVerify_P(result, PSTR(msg)) | |||
#define testVerifyStr(result, expect) testVerify_P(result, PSTR(expect)) | |||
void testBegin(); | |||
void testEnd(); | |||
void testVerify_P(bool b, PGM_P msg); | |||
void testVerify_P(char* result, PGM_P expect); | |||
#endif // SdFatTestSuite_h |