example: sdio: remove unnecessary STM32SdFatSdio.h files

This commit is contained in:
Daniel Fekete 2017-06-13 19:44:14 +02:00
parent e96d284336
commit 692713d449
11 changed files with 33 additions and 248 deletions

View File

@ -1,40 +1,16 @@
/*
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! important: read installation description below !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SD-Card test for the BlackF407VE
- read card info and print it to the serial monitor
- write test.txt file to card
- read it and print it on the serial monitor
1. Install SdFat-beta from https://github.com/greiman/SdFat-beta
By the way you can install SPIFlash from sketch / library / manage libraries
2. In SdFatConfig.h, Change ENABLE_SDIO_CLASS 0 to 1
If you have installed the library with the library manager in windows your will find the
file here:
C:\Users\..WhatEverUser..\Documents\Arduino\libraries\SdFat\src
sdFatConfig.h:
..
// Enable SDIO driver if available.
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#define ENABLE_SDIO_CLASS 1
#define ENABLE_SDIOEX_CLASS 1
#else // ENABLE_SDIO_CLASS
#define ENABLE_SDIO_CLASS 0 // ==> !! change this to ENABLE_SDIO_CLASS 1 !!
#endif // ENABLE_SDIO_CLASS
...
*/
#include "Arduino.h"
#include "SDIO.h"
#include "STM32SdFatSdio.h"
#include "SdFat.h"
STM32SdFatSdio sd;
SdFatSdio sd;
void setup() {
Serial.begin(115200);

View File

@ -1,38 +0,0 @@
#ifndef _STM32_SDFAT_H_INCLUDED
#define _STM32_SDFAT_H_INCLUDED
#include "SdFat.h"
#include "SDIO.h"
class Stm32SdioCard : public BaseBlockDriver {
public:
bool begin() {
return sdio.begin();
}
bool syncBlocks() {
return true;
}
bool readBlock(uint32_t block, uint8_t* dst) {
return sdio.readBlocks(block, dst, 1);
};
bool writeBlock(uint32_t block, const uint8_t* src) {
return sdio.writeBlocks(block, src, 1);
};
bool readBlocks(uint32_t block, uint8_t* dst, size_t nb) {
return sdio.readBlocks(block, dst, nb);
};
bool writeBlocks(uint32_t block, const uint8_t* src, size_t nb) {
return sdio.writeBlocks(block, src, nb);
};
private:
SDIOClass sdio;
};
class STM32SdFatSdio : public SdFileSystem<Stm32SdioCard> {
public:
bool begin() {
return m_card.begin() && SdFileSystem::begin();
}
};
#endif

View File

@ -1,38 +0,0 @@
#ifndef _STM32_SDFAT_H_INCLUDED
#define _STM32_SDFAT_H_INCLUDED
#include "SdFat.h"
#include "SDIO.h"
class Stm32SdioCard : public BaseBlockDriver {
public:
bool begin() {
return sdio.begin();
}
bool syncBlocks() {
return true;
}
bool readBlock(uint32_t block, uint8_t* dst) {
return sdio.readBlocks(block, dst, 1);
};
bool writeBlock(uint32_t block, const uint8_t* src) {
return sdio.writeBlocks(block, src, 1);
};
bool readBlocks(uint32_t block, uint8_t* dst, size_t nb) {
return sdio.readBlocks(block, dst, nb);
};
bool writeBlocks(uint32_t block, const uint8_t* src, size_t nb) {
return sdio.writeBlocks(block, src, nb);
};
private:
SDIOClass sdio;
};
class STM32SdFatSdio : public SdFileSystem<Stm32SdioCard> {
public:
bool begin() {
return m_card.begin() && SdFileSystem::begin();
}
};
#endif

View File

@ -20,38 +20,15 @@
MAY 2017, ChrisMicro
Installation
============
1. Install SdFat-beta from https://github.com/greiman/SdFat-beta
By the way you can install SPIFlash from sketch / library / manage libraries
2. In SdFatConfig.h, Change ENABLE_SDIO_CLASS 0 to 1
If you have installed the library with the library manager in windows your will find the
file here:
C:\Users\..WhatEverUser..\Documents\Arduino\libraries\SdFat\src
sdFatConfig.h:
..
// Enable SDIO driver if available.
#if defined(__MK64FX512__) || defined(__MK66FX1M0__)
#define ENABLE_SDIO_CLASS 1
#define ENABLE_SDIOEX_CLASS 1
#else // ENABLE_SDIO_CLASS
#define ENABLE_SDIO_CLASS 0 // ==> !! change this to ENABLE_SDIO_CLASS 1 !!
#endif // ENABLE_SDIO_CLASS
...
*/
#include "SDIO.h"
#include "STM32SdFatSdio.h"
#include "SdFat.h"
#include "I2S.h"
I2SClass I2S(SPI2, PC3 /*DIN*/ , PB12 /*LRC*/, PB10 /*SCLK*/);
STM32SdFatSdio SD;
SdFatSdio SD;
File sFile;

View File

@ -1,56 +0,0 @@
#ifndef _STM32_SDFAT_H_INCLUDED
#define _STM32_SDFAT_H_INCLUDED
#include "SdFat.h"
#include "SDIO.h"
class Stm32SdioCard : public BaseBlockDriver {
public:
bool begin() {
return sdio.begin();
}
bool syncBlocks() {
return true;
}
bool readBlock(uint32_t block, uint8_t* dst) {
return sdio.readBlocks(block, dst, 1);
};
bool writeBlock(uint32_t block, const uint8_t* src) {
return sdio.writeBlocks(block, src, 1);
};
bool readBlocks(uint32_t block, uint8_t* dst, size_t nb) {
return sdio.readBlocks(block, dst, nb);
};
bool writeBlocks(uint32_t block, const uint8_t* src, size_t nb) {
return sdio.writeBlocks(block, src, nb);
};
bool erase(uint32_t firstBlock, uint32_t lastBlock) {
return sdio.erase(firstBlock, lastBlock);
};
bool readCID(void* cid){
return sdio.readCID(cid);
};
bool readCSD(void* csd){
return sdio.readCSD(csd);
};
uint32_t cardSize(){
return sdio.cardSize();
};
uint8_t errorCode() {
return sdio.errorCode();
}
uint32_t errorData() {
return sdio.errorData();
}
private:
SDIOClass sdio;
};
class STM32SdFatSdio : public SdFileSystem<Stm32SdioCard> {
public:
bool begin() {
return m_card.begin() && SdFileSystem::begin();
}
};
#endif

View File

@ -1,10 +1,8 @@
/*
* This program is a simple binary write/read benchmark.
*/
#include "SDIO.h"
#include "STM32SdFatSdio.h"
//#include <SPI.h>
//#include "SdFat.h"
#include "SdFat.h"
#include "FreeStack.h"
// Set USE_SDIO to zero for SPI card access.
@ -37,7 +35,7 @@ uint8_t buf[BUF_SIZE];
// Traditional DMA version.
// SdFatSdio sd;
// Faster version.
STM32SdFatSdio sd;
SdFatSdio sd;
//SdFatSdioEX sd;
#else // USE_SDIO
SdFat sd;

View File

@ -1,56 +0,0 @@
#ifndef _STM32_SDFAT_H_INCLUDED
#define _STM32_SDFAT_H_INCLUDED
#include "SdFat.h"
#include "SDIO.h"
class Stm32SdioCard : public BaseBlockDriver {
public:
bool begin() {
return sdio.begin();
}
bool syncBlocks() {
return true;
}
bool readBlock(uint32_t block, uint8_t* dst) {
return sdio.readBlocks(block, dst, 1);
};
bool writeBlock(uint32_t block, const uint8_t* src) {
return sdio.writeBlocks(block, src, 1);
};
bool readBlocks(uint32_t block, uint8_t* dst, size_t nb) {
return sdio.readBlocks(block, dst, nb);
};
bool writeBlocks(uint32_t block, const uint8_t* src, size_t nb) {
return sdio.writeBlocks(block, src, nb);
};
bool erase(uint32_t firstBlock, uint32_t lastBlock) {
return sdio.erase(firstBlock, lastBlock);
};
bool readCID(void* cid){
return sdio.readCID(cid);
};
bool readCSD(void* csd){
return sdio.readCSD(csd);
};
uint32_t cardSize(){
return sdio.cardSize();
};
uint8_t errorCode() {
return sdio.errorCode();
}
uint32_t errorData() {
return sdio.errorData();
}
private:
SDIOClass sdio;
};
class STM32SdFatSdio : public SdFileSystem<Stm32SdioCard> {
public:
bool begin() {
return m_card.begin() && SdFileSystem::begin();
}
};
#endif

View File

@ -6,11 +6,11 @@
Pito 5/2016, no warranties of any kind
Pito 5/2017, no warranties of any kind
*/
#include "SDIO.h"
#include "STM32SdFatSdio.h"
#include "CRC32/CRC32.h"
#include "SdFat.h"
#include "CRC32.h"
SdFatSdio sd;
STM32SdFatSdio sd;
SdFile myFileIn;
SdFile myFileOut;
CRC32 crc;

View File

@ -0,0 +1,22 @@
typedef struct {
void *periphInstance;
dmaRequest request;
DMA_Channel_TypeDef *dmaInstance;
uint8_t dmaHandlesIndex;
uint8_t irqN;
} dma_request_to_instance_t;
const dma_request_to_instance_t dmaRequestToStream[] = {
// TODO SPI, etc...
#ifdef SDIO
{SDIO, SDIO_RXTX, DMA2_Channel4, 4 + 8, DMA2_Channel4_IRQn},
#endif
};
inline static setDmaInstance(DMA_HandleTypeDef *handle, dma_request_to_instance_t dmaRequestToStream) {
handle->Instance = dmaRequestToStream.dmaInstance;
}