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 Norimasa Okamoto

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?

UserRevisionLine numberNew 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 #include <string.h>
DieterGraef 24:5396b6a93262 23 #include "ff.h"
DieterGraef 24:5396b6a93262 24 #include "FATDirHandle.h"
DieterGraef 24:5396b6a93262 25
DieterGraef 24:5396b6a93262 26 using namespace mbed;
DieterGraef 24:5396b6a93262 27
DieterGraef 24:5396b6a93262 28 FATDirHandle::FATDirHandle(const FATFS_DIR &the_dir) {
DieterGraef 24:5396b6a93262 29 dir = the_dir;
DieterGraef 24:5396b6a93262 30 }
DieterGraef 24:5396b6a93262 31
DieterGraef 24:5396b6a93262 32 int FATDirHandle::closedir() {
DieterGraef 24:5396b6a93262 33 int retval = f_closedir(&dir);
DieterGraef 24:5396b6a93262 34 delete this;
DieterGraef 24:5396b6a93262 35 return retval;
DieterGraef 24:5396b6a93262 36 }
DieterGraef 24:5396b6a93262 37
DieterGraef 24:5396b6a93262 38 struct dirent *FATDirHandle::readdir() {
DieterGraef 24:5396b6a93262 39 FILINFO finfo;
DieterGraef 24:5396b6a93262 40
DieterGraef 24:5396b6a93262 41 #if _USE_LFN
DieterGraef 24:5396b6a93262 42 finfo.lfname = cur_entry.d_name;
DieterGraef 24:5396b6a93262 43 finfo.lfsize = sizeof(cur_entry.d_name);
DieterGraef 24:5396b6a93262 44 #endif // _USE_LFN
DieterGraef 24:5396b6a93262 45
DieterGraef 24:5396b6a93262 46 FRESULT res = f_readdir(&dir, &finfo);
DieterGraef 24:5396b6a93262 47
DieterGraef 24:5396b6a93262 48 #if _USE_LFN
DieterGraef 24:5396b6a93262 49 if(res != 0 || finfo.fname[0]==0) {
DieterGraef 24:5396b6a93262 50 return NULL;
DieterGraef 24:5396b6a93262 51 } else {
DieterGraef 24:5396b6a93262 52 if(cur_entry.d_name[0]==0) {
DieterGraef 24:5396b6a93262 53 // No long filename so use short filename.
DieterGraef 24:5396b6a93262 54 memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname));
DieterGraef 24:5396b6a93262 55 }
DieterGraef 24:5396b6a93262 56 return &cur_entry;
DieterGraef 24:5396b6a93262 57 }
DieterGraef 24:5396b6a93262 58 #else
DieterGraef 24:5396b6a93262 59 if(res != 0 || finfo.fname[0]==0) {
DieterGraef 24:5396b6a93262 60 return NULL;
DieterGraef 24:5396b6a93262 61 } else {
DieterGraef 24:5396b6a93262 62 memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname));
DieterGraef 24:5396b6a93262 63 return &cur_entry;
DieterGraef 24:5396b6a93262 64 }
DieterGraef 24:5396b6a93262 65 #endif /* _USE_LFN */
DieterGraef 24:5396b6a93262 66 }
DieterGraef 24:5396b6a93262 67
DieterGraef 24:5396b6a93262 68 void FATDirHandle::rewinddir() {
DieterGraef 24:5396b6a93262 69 dir.index = 0;
DieterGraef 24:5396b6a93262 70 }
DieterGraef 24:5396b6a93262 71
DieterGraef 24:5396b6a93262 72 off_t FATDirHandle::telldir() {
DieterGraef 24:5396b6a93262 73 return dir.index;
DieterGraef 24:5396b6a93262 74 }
DieterGraef 24:5396b6a93262 75
DieterGraef 24:5396b6a93262 76 void FATDirHandle::seekdir(off_t location) {
DieterGraef 24:5396b6a93262 77 dir.index = location;
DieterGraef 24:5396b6a93262 78 }
DieterGraef 24:5396b6a93262 79