ソースを参照

Ported to T4

-added T4 aware functions
-chenged transfer from polling to internal DMA (blocking mode)
main
WMXZ-EU 5年前
コミット
3d18f19aaa
5個のファイルの変更1312行の追加1018行の削除
  1. +1
    -1
      examples/CardInfo/CardInfo.ino
  2. +0
    -1002
      utility/KinetisSDHC.c
  3. +1285
    -0
      utility/NXP_SDHC.cpp
  4. +16
    -0
      utility/NXP_SDHC.h
  5. +10
    -15
      utility/Sd2Card.h

+ 1
- 1
examples/CardInfo/CardInfo.ino ファイルの表示

@@ -37,7 +37,7 @@ SdFile root;
// Wiz820+SD board: pin 4
// Teensy 2.0: pin 0
// Teensy++ 2.0: pin 20
const int chipSelect = 4;
const int chipSelect = BUILTIN_SDCARD;

void setup()
{

+ 0
- 1002
utility/KinetisSDHC.c
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 1285
- 0
utility/NXP_SDHC.cpp
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 16
- 0
utility/NXP_SDHC.h ファイルの表示

@@ -0,0 +1,16 @@
#ifndef _NXP_SDHC_H
#define _NXP_SDHC_H

#define SDHC_STATUS_NOINIT 0x01 /* Drive not initialized */
#define SDHC_STATUS_NODISK 0x02 /* No medium in the drive */
#define SDHC_STATUS_PROTECT 0x04 /* Write protected */

uint8_t SDHC_CardInit(void);
uint8_t SDHC_CardGetType(void);
//uint8_t SDHC_CardGetStatus(void);
//uint32_t SDHC_CardGetBlockCnt(void);

int SDHC_CardReadBlock(void * buff, uint32_t sector);
int SDHC_CardWriteBlock(const void * buff, uint32_t sector);

#endif

+ 10
- 15
utility/Sd2Card.h ファイルの表示

@@ -74,15 +74,10 @@ uint8_t const SD_CARD_TYPE_SD2 = 2;
/** High Capacity SD card */
uint8_t const SD_CARD_TYPE_SDHC = 3;
//------------------------------------------------------------------------------
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
extern "C" {
uint8_t KinetisSDHC_InitCard(void);
uint8_t KinetisSDHC_GetCardType(void);
int KinetisSDHC_ReadBlock(void * buff, uint32_t sector);
int KinetisSDHC_WriteBlock(const void * buff, uint32_t sector);
}
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1052__)
#include "NXP_SDHC.h"
#define BUILTIN_SDCARD 254
#endif
#define BUILTIN_SDCARD 254
//------------------------------------------------------------------------------
/**
* \class Sd2Card
@@ -95,11 +90,11 @@ class Sd2Card {
/* Initialize an SD flash memory card with the selected SPI clock rate
* and the SD chip select pin. */
uint8_t init(uint8_t sckRateID, uint8_t chipSelectPin) {
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1052__)
if (chipSelectPin == BUILTIN_SDCARD) {
chipSelectPin_ = BUILTIN_SDCARD;
uint8_t ret = KinetisSDHC_InitCard();
type_ = KinetisSDHC_GetCardType();
uint8_t ret = SDHC_CardInit();
type_ = SDHC_CardGetType();
return (ret == 0) ? true : false;
}
#endif
@@ -109,18 +104,18 @@ class Sd2Card {
uint8_t type(void) const {return type_;}
/** Returns the current value, true or false, for partial block read. */
uint8_t readBlock(uint32_t block, uint8_t* dst) {
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1052__)
if (chipSelectPin_ == BUILTIN_SDCARD) {
return (KinetisSDHC_ReadBlock(dst, block) == 0) ? true : false;
return (SDHC_CardReadBlock(dst, block) == 0) ? true : false;
}
#endif
return SD_readBlock(block, dst);
}
/** Return the card type: SD V1, SD V2 or SDHC */
uint8_t writeBlock(uint32_t block, const uint8_t* src) {
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#if defined(__MK64FX512__) || defined(__MK66FX1M0__) || defined(__IMXRT1052__)
if (chipSelectPin_ == BUILTIN_SDCARD) {
return (KinetisSDHC_WriteBlock(src, block) == 0) ? true : false;
return (SDHC_CardWriteBlock(src, block) == 0) ? true : false;
}
#endif
return SD_writeBlock(block, src);

読み込み中…
キャンセル
保存