Dieter Graef / SDFileSystem

Dependencies:   FATFileSystem

Dependents:   DISCO-F746NG_SDFileSystem uzairkhan DISCO-F746NG_Scope_copy

Fork of SDFileSystem by Neil Thiessen

Revision:
23:c03ef1abef0e
Parent:
22:3fa5eaf48e81
Child:
27:8d192c180436
diff -r 3fa5eaf48e81 -r c03ef1abef0e SDFileSystem.h
--- a/SDFileSystem.h	Wed Feb 24 17:46:31 2016 +0000
+++ b/SDFileSystem.h	Thu Mar 31 17:39:48 2016 +0000
@@ -1,6 +1,6 @@
 /* SD/MMC File System Library
  * Copyright (c) 2016 Neil Thiessen
- *
+ * Modified for the use with STM32F746 Discovery (C) 2016 Dieter Greaf
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -18,6 +18,7 @@
 #define SD_FILE_SYSTEM_H
 
 #include "mbed.h"
+#include "stm32746g_discovery_sd.h"
 #include "FATFileSystem.h"
 
 /** SDFileSystem class.
@@ -29,7 +30,7 @@
  * #include "SDFileSystem.h"
  *
  * //Create an SDFileSystem object
- * SDFileSystem sd(p5, p6, p7, p20, "sd");
+ * SDFileSystem sd("sd");
  *
  * int main()
  * {
@@ -65,7 +66,11 @@
  *     sd.unmount();
  * }
  * @endcode
+
  */
+ #define CMD59  (0x40 | 59)
+using namespace mbed;
+
 class SDFileSystem : public FATFileSystem
 {
 public:
@@ -100,7 +105,7 @@
      * @param cdtype The type of card detect switch.
      * @param hz The SPI bus frequency (defaults to 1MHz).
      */
-    SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name, PinName cd = NC, SwitchType cdtype = SWITCH_NONE, int hz = 1000000);
+    SDFileSystem( const char* name);
 
     /** Determine whether or not a card is present
      *
@@ -169,55 +174,21 @@
     virtual uint32_t disk_sectors();
 
 private:
-    //Commands
-    enum Command {
-        CMD0 = (0x40 | 0),      /**< GO_IDLE_STATE */
-        CMD1 = (0x40 | 1),      /**< SEND_OP_COND */
-        CMD8 = (0x40 | 8),      /**< SEND_IF_COND */
-        CMD9 = (0x40 | 9),      /**< SEND_CSD */
-        CMD12 = (0x40 | 12),    /**< STOP_TRANSMISSION */
-        CMD13 = (0x40 | 13),    /**< SEND_STATUS */
-        CMD16 = (0x40 | 16),    /**< SET_BLOCKLEN */
-        CMD17 = (0x40 | 17),    /**< READ_SINGLE_BLOCK */
-        CMD18 = (0x40 | 18),    /**< READ_MULTIPLE_BLOCK */
-        ACMD22 = (0x40 | 22),   /**< SEND_NUM_WR_BLOCKS */
-        ACMD23 = (0x40 | 23),   /**< SET_WR_BLK_ERASE_COUNT */
-        CMD24 = (0x40 | 24),    /**< WRITE_BLOCK */
-        CMD25 = (0x40 | 25),    /**< WRITE_MULTIPLE_BLOCK */
-        ACMD41 = (0x40 | 41),   /**< SD_SEND_OP_COND */
-        ACMD42 = (0x40 | 42),   /**< SET_CLR_CARD_DETECT */
-        CMD55 = (0x40 | 55),    /**< APP_CMD */
-        CMD58 = (0x40 | 58),    /**< READ_OCR */
-        CMD59 = (0x40 | 59)     /**< CRC_ON_OFF */
-    };
-
-    //Member variables
     Timer m_Timer;
-    SPI m_Spi;
-    DigitalOut m_Cs;
     InterruptIn m_Cd;
     int m_CdAssert;
-    const int m_FREQ;
     SDFileSystem::CardType m_CardType;
     bool m_Crc;
     bool m_LargeFrames;
     bool m_WriteValidation;
     int m_Status;
-
+    HAL_SD_CardInfoTypedef m_CardInfo;
     //Internal methods
     void onCardRemoval();
     void checkSocket();
-    bool waitReady(int timeout);
-    bool select();
-    void deselect();
-    char commandTransaction(char cmd, unsigned int arg, unsigned int* resp = NULL);
-    char writeCommand(char cmd, unsigned int arg, unsigned int* resp = NULL);
-    bool readData(char* buffer, int length);
-    char writeData(const char* buffer, char token);
-    bool readBlock(char* buffer, unsigned int lba);
-    bool readBlocks(char* buffer, unsigned int lba, unsigned int count);
-    bool writeBlock(const char* buffer, unsigned int lba);
-    bool writeBlocks(const char* buffer, unsigned int lba, unsigned int count);
+    void DMA2_Stream3_IRQHandler();
+    void DMA2_Stream6_IRQHandler();
+    void SDMMC1_IRQHandler();
 };
 
 #endif