Skip to content

Commit

Permalink
Version for Arduino ide 1.6.0
Browse files Browse the repository at this point in the history
This version include the SPI card driver for Arduino Due
  • Loading branch information
gallegojm committed Feb 14, 2015
1 parent 40f89c2 commit ce58d9c
Show file tree
Hide file tree
Showing 8 changed files with 1,110 additions and 12 deletions.
40 changes: 36 additions & 4 deletions FatFs/FatFs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@
* Copyright (c) 2014 by Jean-Michel Gallego
*
* Use version R0.10c of FatFs updated at November 26, 2014
*
* 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 SdSpiCard Library. If not, see
* <http://www.gnu.org/licenses/>.
*/

#include "FatFs.h"

Sd2Card card;
FatFsCard card;

extern "C" int sd_status()
{
Expand Down Expand Up @@ -43,7 +57,7 @@ extern "C" int sd_disk_ioctl( uint8_t cmd )
case CTRL_SYNC : // Make sure that data has been written
res = RES_OK;
// res = spiRec() == 0XFF ? RES_OK : RES_NOTRDY ;
// res = card.waitNotBusy( 100 ) ? RES_OK : RES_NOTRDY ;
// res = card.waitNotBusy( SD_WRITE_TIMEOUT ) ? RES_OK : RES_NOTRDY ;
break;

default:
Expand Down Expand Up @@ -72,6 +86,23 @@ extern "C" void ff_memfree (void* mblock)
=========================================================== */

/*
bool FatFsCard::begin( uint8_t csPin, uint8_t sckDiv )
{
uint32_t t0 = millis();
this.csPin = csPin;
SPI.begin( csPin );
SPI.beginTransaction( csPin, SPI_SCK_INIT_DIVISOR, MSBFIRST, SPI_MODE0 );
Serial.println( (uint32_t) millis() - t0 );
// must supply min of 74 clock cycles
for (uint8_t i = 0; i < 10; i++) {
SPI.send( 0XFF );
}
}
*/

uint8_t ffs_result;

// Initialize SD card and file system
Expand All @@ -82,9 +113,10 @@ uint8_t ffs_result;
bool FatFsClass::begin( uint8_t csPin, uint8_t sckDiv )
{
ffs_result = 0;
if( ! card.init( sckDiv, csPin ))
// if( ! card.init( sckDiv, csPin ))
if( ! card.begin( csPin, sckDiv ))
return false;
ffs_result = f_mount( & ffs, "", 1 );
ffs_result = f_mount( & ffs, "", 1 );
return ffs_result == 0;
}

Expand Down
29 changes: 28 additions & 1 deletion FatFs/FatFs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,43 @@
* Copyright (c) 2014 by Jean-Michel Gallego
*
* Use version R0.10c of FatFs updated at November 26, 2014
*
* 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 SdSpiCard Library. If not, see
* <http://www.gnu.org/licenses/>.
*/

#ifndef FATFS_H
#define FATFS_H

#include <Arduino.h>
#include <SdSpiCard.h>
#include <FatFsCard.h>
#include "ff.h"
#include "diskio.h"

#define SPI_SCK_INIT_DIVISOR 400000

/*
class FatFsCard : public Sd2Card
{
public:
// bool begin( uint8_t csPin, uint8_t sckDiv = SPI_HALF_SPEED );
private:
uint8_t csPin;
};
*/

class FatFsClass
{
public:
Expand Down
Loading

0 comments on commit ce58d9c

Please sign in to comment.