TEST
Dependencies: max32630fthr Adafruit_FeatherOLED USBDevice
Drivers/USBMSD_BD/USBMSD_BD.h@1:f60eafbf009a, 2019-04-10 (annotated)
- Committer:
- gmehmet
- Date:
- Wed Apr 10 14:56:25 2019 +0300
- Revision:
- 1:f60eafbf009a
upload from local
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
gmehmet | 1:f60eafbf009a | 1 | /* mbed USBMSD_BD Library, for providing file access to Block Devices |
gmehmet | 1:f60eafbf009a | 2 | * Copyright (c) 2008-2010, sford |
gmehmet | 1:f60eafbf009a | 3 | * |
gmehmet | 1:f60eafbf009a | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
gmehmet | 1:f60eafbf009a | 5 | * of this software and associated documentation files (the "Software"), to deal |
gmehmet | 1:f60eafbf009a | 6 | * in the Software without restriction, including without limitation the rights |
gmehmet | 1:f60eafbf009a | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
gmehmet | 1:f60eafbf009a | 8 | * copies of the Software, and to permit persons to whom the Software is |
gmehmet | 1:f60eafbf009a | 9 | * furnished to do so, subject to the following conditions: |
gmehmet | 1:f60eafbf009a | 10 | * |
gmehmet | 1:f60eafbf009a | 11 | * The above copyright notice and this permission notice shall be included in |
gmehmet | 1:f60eafbf009a | 12 | * all copies or substantial portions of the Software. |
gmehmet | 1:f60eafbf009a | 13 | * |
gmehmet | 1:f60eafbf009a | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
gmehmet | 1:f60eafbf009a | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
gmehmet | 1:f60eafbf009a | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
gmehmet | 1:f60eafbf009a | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
gmehmet | 1:f60eafbf009a | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
gmehmet | 1:f60eafbf009a | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
gmehmet | 1:f60eafbf009a | 20 | * THE SOFTWARE. |
gmehmet | 1:f60eafbf009a | 21 | */ |
gmehmet | 1:f60eafbf009a | 22 | |
gmehmet | 1:f60eafbf009a | 23 | #ifndef USBMSD_BD_H |
gmehmet | 1:f60eafbf009a | 24 | #define USBMSD_BD_H |
gmehmet | 1:f60eafbf009a | 25 | |
gmehmet | 1:f60eafbf009a | 26 | #include "mbed.h" |
gmehmet | 1:f60eafbf009a | 27 | #include "BlockDevice.h" |
gmehmet | 1:f60eafbf009a | 28 | #include "USBMSD.h" |
gmehmet | 1:f60eafbf009a | 29 | |
gmehmet | 1:f60eafbf009a | 30 | /** Use the SDcard as mass storage device using the USBMSD class |
gmehmet | 1:f60eafbf009a | 31 | * |
gmehmet | 1:f60eafbf009a | 32 | * @code |
gmehmet | 1:f60eafbf009a | 33 | * #include "mbed.h" |
gmehmet | 1:f60eafbf009a | 34 | * #include "USBMSD_BD.h" |
gmehmet | 1:f60eafbf009a | 35 | * |
gmehmet | 1:f60eafbf009a | 36 | * USBMSD_BD sd(p5, p6, p7, p8); |
gmehmet | 1:f60eafbf009a | 37 | * |
gmehmet | 1:f60eafbf009a | 38 | * int main() { |
gmehmet | 1:f60eafbf009a | 39 | * while(1); |
gmehmet | 1:f60eafbf009a | 40 | * } |
gmehmet | 1:f60eafbf009a | 41 | * |
gmehmet | 1:f60eafbf009a | 42 | * @endcode |
gmehmet | 1:f60eafbf009a | 43 | */ |
gmehmet | 1:f60eafbf009a | 44 | class USBMSD_BD : public USBMSD { |
gmehmet | 1:f60eafbf009a | 45 | public: |
gmehmet | 1:f60eafbf009a | 46 | |
gmehmet | 1:f60eafbf009a | 47 | /** Create the File System for accessing an SD Card using SPI |
gmehmet | 1:f60eafbf009a | 48 | * |
gmehmet | 1:f60eafbf009a | 49 | * @param mosi SPI mosi pin connected to SD Card |
gmehmet | 1:f60eafbf009a | 50 | * @param miso SPI miso pin conencted to SD Card |
gmehmet | 1:f60eafbf009a | 51 | * @param sclk SPI sclk pin connected to SD Card |
gmehmet | 1:f60eafbf009a | 52 | * @param cs DigitalOut pin used as SD Card chip select |
gmehmet | 1:f60eafbf009a | 53 | * @param name The name used to access the virtual filesystem |
gmehmet | 1:f60eafbf009a | 54 | */ |
gmehmet | 1:f60eafbf009a | 55 | USBMSD_BD(BlockDevice *bd); |
gmehmet | 1:f60eafbf009a | 56 | virtual int disk_initialize(); |
gmehmet | 1:f60eafbf009a | 57 | virtual int disk_status(); |
gmehmet | 1:f60eafbf009a | 58 | virtual int disk_read(uint8_t * buffer, uint64_t block_number, uint8_t count); |
gmehmet | 1:f60eafbf009a | 59 | virtual int disk_write(const uint8_t * buffer, uint64_t block_number, uint8_t count); |
gmehmet | 1:f60eafbf009a | 60 | virtual int disk_sync(); |
gmehmet | 1:f60eafbf009a | 61 | virtual uint64_t disk_sectors(); |
gmehmet | 1:f60eafbf009a | 62 | virtual uint64_t disk_size(); |
gmehmet | 1:f60eafbf009a | 63 | |
gmehmet | 1:f60eafbf009a | 64 | protected: |
gmehmet | 1:f60eafbf009a | 65 | |
gmehmet | 1:f60eafbf009a | 66 | uint64_t _sectors; |
gmehmet | 1:f60eafbf009a | 67 | bd_size_t _ssize; |
gmehmet | 1:f60eafbf009a | 68 | |
gmehmet | 1:f60eafbf009a | 69 | uint8_t _status; |
gmehmet | 1:f60eafbf009a | 70 | |
gmehmet | 1:f60eafbf009a | 71 | BlockDevice* _bd; |
gmehmet | 1:f60eafbf009a | 72 | }; |
gmehmet | 1:f60eafbf009a | 73 | |
gmehmet | 1:f60eafbf009a | 74 | #endif |