PaulStoffregen
Well-known member
I'm been quiet for the last few days while working on a long-planned change to bring the File class into Teensy's core library, and to remove the Arduino SD library and migrate all SD card use on Teensy to SdFat.
CardInfo:40: error: 'BUILTIN_SDCARD' was not declared in this scope
const int chipSelect = BUILTIN_SDCARD;
CardInfo:40: error: 'BUILTIN_SDCARD' was not declared in this scope
To use the abstraction layer how to you initialize the card.
Guess the next question is if SD lib now working anymore all examples will have to change and anyone using SD lib will have to up their libs.
Going through the SD Lib now to see the public functions/
Initializing SD card...initialization done.
LOG_0816.csv 4364
OV7670.BMP 614466
System Volume Information/
WPSettings.dat 12
IndexerVolumeGuid 76
mtpindex.dat 0
LOG_0001.csv 86201
LOG_0000-afternno.csv 121978
LOG_00001.csv 65318
LOG_62620.csv 183998
done!
3: Having the File class in the core library will allow USBHost_t36 to give File class objects for USB mass storage devices. So any library or code that uses File will be able to access either type of media, and other types of media or virtual files in the future.
@PaulStoffregen
Just tried the updates and its now working but on a implementation note if you plan to download SD and SDfatbeta with Teensyduino.
In the Arduino libraries folder there is already a SD library and if you load the the PJRC SD library in the Teensyduino Libraries folder it defaults to the Arduino SD library. I am using 1.54b2 for testing by the way.
Tried with the standard SD.begin(chipSelect) and SD.sdfs.begin(SdioConfig(DMA_SDIO)); both worked no problem:
...
Going to play more with SD
Oh BTW, think @KurtE mentioned this but Serial.println still prints an extra line - know its small but do you think it can be fixed in 1.54b3?
size_t Print::println(void)
{
uint8_t buf[2]={'\r', '\n'};
return write(buf, 2);
}
SD Library Conflict issue mentioned in post 11: really a non- issue. I for forgot to rename the lib to SD after I copied it from GITHUB
Too many distractions here so just realized it this morning - sorry for the confusion.Whew, that's a relief. I couldn't reproduce it on Linux and really wasn't looking forward to fiddling more with Windows.
File open(const char *filepath, uint8_t mode = FILE_READ) {
oflag_t flags = O_READ;
if (mode == FILE_WRITE) flags = O_READ | O_WRITE | O_CREAT;
FsFile file = sdfs.open(filepath, flags);
[B]// TODO: Arduino's default to seek to end of writable file[/B]
if (file) return File(new SDFile(file));
return File();
}
Well mostly good news.I fixed several bugs. Latest code on github should work for the Datalogger, DumpFile and CardInfo examples.
But CardInfo can't print the root directory because the class name would conflict with SdFat, so I just commented out that last part of the CardInfo example.
Initializing SD card...initialization failed. Things to check:
* is a card inserted?
* is your wiring correct?
* did you change the chipSelect pin to match your shield or module?
Well mostly good news.
Datalogger and Dumpfile are now working
Cardinfo is giving me the following error:
Code:Initializing SD card...initialization failed. Things to check: * is a card inserted? * is your wiring correct? * did you change the chipSelect pin to match your shield or module?
#define SD_CARD_TYPE_SD1 0
#define SD_CARD_TYPE_SD2 1
#define SD_CARD_TYPE_SDHC 3
class Sd2Card
{
public:
bool init(uint8_t speed, uint8_t csPin) {
[COLOR="#FF0000"]#ifdef BUILTIN_SDCARD
Serial.printf("csPin = %d\n",csPin);
if (csPin == BUILTIN_SDCARD) {
return SD.sdfs.begin(SdioConfig(FIFO_SDIO));
//return SD.sdfs.begin(SdioConfig(DMA_SDIO));
} else {
return SD.sdfs.begin(csPin);
}
#endif[/COLOR]
}
uint8_t type() {
return SD.sdfs.card()->type();
}
};