test for export
Dependents: F401RE_USBMSD_RAM_copy
Fork of RAM_DISK by
USBMSD_Ram.h@2:ee281ece9011, 2014-11-09 (annotated)
- Committer:
- va009039
- Date:
- Sun Nov 09 03:01:44 2014 +0000
- Revision:
- 2:ee281ece9011
- Parent:
- 1:3d0c421fe52b
update USBDevice
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 1:3d0c421fe52b | 1 | /* mbed USBMSD_Ram Library |
samux | 0:ba333853266b | 2 | * |
samux | 0:ba333853266b | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
samux | 0:ba333853266b | 4 | * of this software and associated documentation files (the "Software"), to deal |
samux | 0:ba333853266b | 5 | * in the Software without restriction, including without limitation the rights |
samux | 0:ba333853266b | 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
samux | 0:ba333853266b | 7 | * copies of the Software, and to permit persons to whom the Software is |
samux | 0:ba333853266b | 8 | * furnished to do so, subject to the following conditions: |
samux | 0:ba333853266b | 9 | * |
samux | 0:ba333853266b | 10 | * The above copyright notice and this permission notice shall be included in |
samux | 0:ba333853266b | 11 | * all copies or substantial portions of the Software. |
samux | 0:ba333853266b | 12 | * |
samux | 0:ba333853266b | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
samux | 0:ba333853266b | 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
samux | 0:ba333853266b | 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
samux | 0:ba333853266b | 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
samux | 0:ba333853266b | 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
samux | 0:ba333853266b | 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
samux | 0:ba333853266b | 19 | * THE SOFTWARE. |
samux | 0:ba333853266b | 20 | */ |
samux | 0:ba333853266b | 21 | |
samux | 0:ba333853266b | 22 | #ifndef USBMSD_RAM_H |
samux | 0:ba333853266b | 23 | #define USBMSD_RAM_H |
samux | 0:ba333853266b | 24 | |
samux | 0:ba333853266b | 25 | #include "mbed.h" |
samux | 0:ba333853266b | 26 | #include "USBMSD.h" |
samux | 0:ba333853266b | 27 | |
samux | 1:3d0c421fe52b | 28 | #define NB_SECTORS (20) |
samux | 1:3d0c421fe52b | 29 | |
va009039 | 2:ee281ece9011 | 30 | /** Use the Ram as mass storage device using the USBMSD class |
samux | 0:ba333853266b | 31 | * |
samux | 0:ba333853266b | 32 | * @code |
samux | 0:ba333853266b | 33 | * #include "mbed.h" |
samux | 0:ba333853266b | 34 | * #include "USBMSD_Ram.h" |
samux | 0:ba333853266b | 35 | * |
va009039 | 2:ee281ece9011 | 36 | * USBMSD_Ram sd; |
samux | 0:ba333853266b | 37 | * |
samux | 0:ba333853266b | 38 | * int main() { |
samux | 0:ba333853266b | 39 | * while(1); |
samux | 0:ba333853266b | 40 | * } |
samux | 0:ba333853266b | 41 | * |
samux | 0:ba333853266b | 42 | * @endcode |
samux | 0:ba333853266b | 43 | */ |
samux | 0:ba333853266b | 44 | class USBMSD_Ram : public USBMSD { |
samux | 0:ba333853266b | 45 | public: |
samux | 0:ba333853266b | 46 | |
samux | 1:3d0c421fe52b | 47 | |
samux | 0:ba333853266b | 48 | USBMSD_Ram(); |
samux | 0:ba333853266b | 49 | virtual int disk_initialize(); |
va009039 | 2:ee281ece9011 | 50 | virtual int disk_write(const uint8_t * data, uint64_t block, uint8_t count); |
va009039 | 2:ee281ece9011 | 51 | virtual int disk_read(uint8_t * data, uint64_t block, uint8_t count); |
samux | 0:ba333853266b | 52 | virtual int disk_status(); |
samux | 0:ba333853266b | 53 | virtual int disk_sync(); |
samux | 1:3d0c421fe52b | 54 | virtual uint64_t disk_sectors(); |
samux | 1:3d0c421fe52b | 55 | virtual uint64_t disk_size(); |
samux | 0:ba333853266b | 56 | |
samux | 0:ba333853266b | 57 | protected: |
samux | 0:ba333853266b | 58 | int _status; |
samux | 1:3d0c421fe52b | 59 | char disk_image[512*NB_SECTORS]; |
samux | 0:ba333853266b | 60 | |
samux | 0:ba333853266b | 61 | }; |
samux | 0:ba333853266b | 62 | |
samux | 0:ba333853266b | 63 | #endif |