Simple USBHost library for STM32F746NG Discovery board. Only either the Fastspeed or the Highspeed port can be used( not both together)
Dependents: DISCO-F746NG_USB_Host
Fork of KL46Z-USBHost by
FATFileSystem/FATFileSystem.h@25:7d6d9fc471bf, 2016-06-17 (annotated)
- Committer:
- DieterGraef
- Date:
- Fri Jun 17 09:00:35 2016 +0000
- Revision:
- 25:7d6d9fc471bf
- Parent:
- 24:5396b6a93262
USB Host now works with both Interfaces even in parallel. Some changes in the USB MSD driver to make it operable
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
DieterGraef | 24:5396b6a93262 | 1 | /* mbed Microcontroller Library |
DieterGraef | 24:5396b6a93262 | 2 | * Copyright (c) 2006-2012 ARM Limited |
DieterGraef | 24:5396b6a93262 | 3 | * |
DieterGraef | 24:5396b6a93262 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
DieterGraef | 24:5396b6a93262 | 5 | * of this software and associated documentation files (the "Software"), to deal |
DieterGraef | 24:5396b6a93262 | 6 | * in the Software without restriction, including without limitation the rights |
DieterGraef | 24:5396b6a93262 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
DieterGraef | 24:5396b6a93262 | 8 | * copies of the Software, and to permit persons to whom the Software is |
DieterGraef | 24:5396b6a93262 | 9 | * furnished to do so, subject to the following conditions: |
DieterGraef | 24:5396b6a93262 | 10 | * |
DieterGraef | 24:5396b6a93262 | 11 | * The above copyright notice and this permission notice shall be included in |
DieterGraef | 24:5396b6a93262 | 12 | * all copies or substantial portions of the Software. |
DieterGraef | 24:5396b6a93262 | 13 | * |
DieterGraef | 24:5396b6a93262 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
DieterGraef | 24:5396b6a93262 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
DieterGraef | 24:5396b6a93262 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
DieterGraef | 24:5396b6a93262 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
DieterGraef | 24:5396b6a93262 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
DieterGraef | 24:5396b6a93262 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
DieterGraef | 24:5396b6a93262 | 20 | * SOFTWARE. |
DieterGraef | 24:5396b6a93262 | 21 | */ |
DieterGraef | 24:5396b6a93262 | 22 | #ifndef MBED_FATFILESYSTEM_H |
DieterGraef | 24:5396b6a93262 | 23 | #define MBED_FATFILESYSTEM_H |
DieterGraef | 24:5396b6a93262 | 24 | |
DieterGraef | 24:5396b6a93262 | 25 | #include "FileSystemLike.h" |
DieterGraef | 24:5396b6a93262 | 26 | #include "FileHandle.h" |
DieterGraef | 24:5396b6a93262 | 27 | #include "ff.h" |
DieterGraef | 24:5396b6a93262 | 28 | #include <stdint.h> |
DieterGraef | 24:5396b6a93262 | 29 | |
DieterGraef | 24:5396b6a93262 | 30 | using namespace mbed; |
DieterGraef | 24:5396b6a93262 | 31 | |
DieterGraef | 24:5396b6a93262 | 32 | /** |
DieterGraef | 24:5396b6a93262 | 33 | * FATFileSystem based on ChaN's Fat Filesystem library v0.8 |
DieterGraef | 24:5396b6a93262 | 34 | */ |
DieterGraef | 24:5396b6a93262 | 35 | class FATFileSystem : public FileSystemLike { |
DieterGraef | 24:5396b6a93262 | 36 | public: |
DieterGraef | 24:5396b6a93262 | 37 | |
DieterGraef | 24:5396b6a93262 | 38 | FATFileSystem(const char* n); |
DieterGraef | 24:5396b6a93262 | 39 | virtual ~FATFileSystem(); |
DieterGraef | 24:5396b6a93262 | 40 | |
DieterGraef | 24:5396b6a93262 | 41 | static FATFileSystem * _ffs[_VOLUMES]; // FATFileSystem objects, as parallel to FatFs drives array |
DieterGraef | 24:5396b6a93262 | 42 | FATFS _fs; // Work area (file system object) for logical drive |
DieterGraef | 24:5396b6a93262 | 43 | char _fsid[2]; |
DieterGraef | 24:5396b6a93262 | 44 | |
DieterGraef | 24:5396b6a93262 | 45 | /** |
DieterGraef | 24:5396b6a93262 | 46 | * Opens a file on the filesystem |
DieterGraef | 24:5396b6a93262 | 47 | */ |
DieterGraef | 24:5396b6a93262 | 48 | virtual FileHandle *open(const char* name, int flags); |
DieterGraef | 24:5396b6a93262 | 49 | |
DieterGraef | 24:5396b6a93262 | 50 | /** |
DieterGraef | 24:5396b6a93262 | 51 | * Removes a file path |
DieterGraef | 24:5396b6a93262 | 52 | */ |
DieterGraef | 24:5396b6a93262 | 53 | virtual int remove(const char *filename); |
DieterGraef | 24:5396b6a93262 | 54 | |
DieterGraef | 24:5396b6a93262 | 55 | /** |
DieterGraef | 24:5396b6a93262 | 56 | * Renames a file |
DieterGraef | 24:5396b6a93262 | 57 | */ |
DieterGraef | 24:5396b6a93262 | 58 | virtual int rename(const char *oldname, const char *newname); |
DieterGraef | 24:5396b6a93262 | 59 | |
DieterGraef | 24:5396b6a93262 | 60 | /** |
DieterGraef | 24:5396b6a93262 | 61 | * Formats a logical drive, FDISK artitioning rule, 512 bytes per cluster |
DieterGraef | 24:5396b6a93262 | 62 | */ |
DieterGraef | 24:5396b6a93262 | 63 | virtual int format(); |
DieterGraef | 24:5396b6a93262 | 64 | |
DieterGraef | 24:5396b6a93262 | 65 | /** |
DieterGraef | 24:5396b6a93262 | 66 | * Opens a directory on the filesystem |
DieterGraef | 24:5396b6a93262 | 67 | */ |
DieterGraef | 24:5396b6a93262 | 68 | virtual DirHandle *opendir(const char *name); |
DieterGraef | 24:5396b6a93262 | 69 | |
DieterGraef | 24:5396b6a93262 | 70 | /** |
DieterGraef | 24:5396b6a93262 | 71 | * Creates a directory path |
DieterGraef | 24:5396b6a93262 | 72 | */ |
DieterGraef | 24:5396b6a93262 | 73 | virtual int mkdir(const char *name, mode_t mode); |
DieterGraef | 24:5396b6a93262 | 74 | |
DieterGraef | 24:5396b6a93262 | 75 | /** |
DieterGraef | 24:5396b6a93262 | 76 | * Mounts the filesystem |
DieterGraef | 24:5396b6a93262 | 77 | */ |
DieterGraef | 24:5396b6a93262 | 78 | virtual int mount(); |
DieterGraef | 24:5396b6a93262 | 79 | |
DieterGraef | 24:5396b6a93262 | 80 | /** |
DieterGraef | 24:5396b6a93262 | 81 | * Unmounts the filesystem |
DieterGraef | 24:5396b6a93262 | 82 | */ |
DieterGraef | 24:5396b6a93262 | 83 | virtual int unmount(); |
DieterGraef | 24:5396b6a93262 | 84 | |
DieterGraef | 24:5396b6a93262 | 85 | virtual int disk_initialize() { return 0; } |
DieterGraef | 24:5396b6a93262 | 86 | virtual int disk_status() { return 0; } |
DieterGraef | 24:5396b6a93262 | 87 | virtual int disk_read(uint8_t * buffer, uint64_t sector, uint8_t count) = 0; |
DieterGraef | 24:5396b6a93262 | 88 | virtual int disk_write(const uint8_t * buffer, uint64_t sector, uint8_t count) = 0; |
DieterGraef | 24:5396b6a93262 | 89 | virtual int disk_sync() { return 0; } |
DieterGraef | 24:5396b6a93262 | 90 | virtual uint64_t disk_sectors() = 0; |
DieterGraef | 24:5396b6a93262 | 91 | |
DieterGraef | 24:5396b6a93262 | 92 | }; |
DieterGraef | 24:5396b6a93262 | 93 | |
DieterGraef | 24:5396b6a93262 | 94 | #endif |