2016年1月11日月曜日

Arduino用SdFatとGR-kurumi


GR-kurumiでSDカードを利用するため,Arduino用のSDのライブラリを触ってみた.


標準のSDライブラリは「ファイルのmvやrename」すらないので,
SDライブラリの後継にあたるSdFatを試してみた.

使えないカードとか出るものの,ライブラリのソース(設定)を修正すれば,
とりあえず,使えるということがわかった.

SdFatの最新版置き場


https://github.com/greiman/SdFat


問題

SPIの問題

githubから落とせるソースは独自のSPIのルーチンを経由するため,ヘッダファイル「SdFatConfig.h」を編集して標準のSPIライブラリを経由してSDカードにアクセスするように
変更する必要がある.

SDカードとの組み合わせ

上記の修正をしたためか否かテストしていないが,SdFatはClass4のマイクロSDカードは
対応できるものの,Class 10やUHS表記のあるカードは処理できないようだ.

SdFatの「SdFatConfig.h」修正

要は「カードにアクセスするSPIのルーチンを標準のSPIライブラリに変更する」修正を
すること.

    /**
     * The symbol SD_SPI_CONFIGURATION defines SPI access to the SD card.
     *
     * IF SD_SPI_CONFIGUTATION is define to be zero, only the SdFat class
     * is define and SdFat uses a fast custom SPI implementation.
     *
     * If SD_SPI_CONFIGURATION is define to be one, only the SdFat class is
     * define and SdFat uses the standard Arduino SPI.h library.
     *
     * If SD_SPI_CONFIGURATION is define to be two, only the SdFat class is
     * define and SdFat uses software SPI on the pins defined below.
     *
     * If SD_SPI_CONFIGURATION is define to be three, the three classes, SdFat,
     * SdFatLibSpi, and SdFatSoftSpi are defined.  SdFat uses the fast
     * custom SPI implementation. SdFatLibSpi uses the standard Arduino SPI
     * library.  SdFatSoftSpi is a template class that uses Software SPI. The
     * template parameters define the software SPI pins.  See the ThreeCard
     * example for simultaneous use of all three classes.
     */
    #define SD_SPI_CONFIGURATION 1


0 件のコメント: