Xbee CountUp

Dependencies:   mbed

Fork of HeptaXbee_CountUp by 智也 大野

Committer:
tomoya123
Date:
Tue Dec 13 07:55:03 2016 +0000
Revision:
1:715b80d2a02b
Parent:
0:0a7fa0911e6c
Xbee CountUp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tomoya123 0:0a7fa0911e6c 1 /* mbed Microcontroller Library
tomoya123 0:0a7fa0911e6c 2 * Copyright (c) 2006-2012 ARM Limited
tomoya123 0:0a7fa0911e6c 3 *
tomoya123 0:0a7fa0911e6c 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
tomoya123 0:0a7fa0911e6c 5 * of this software and associated documentation files (the "Software"), to deal
tomoya123 0:0a7fa0911e6c 6 * in the Software without restriction, including without limitation the rights
tomoya123 0:0a7fa0911e6c 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
tomoya123 0:0a7fa0911e6c 8 * copies of the Software, and to permit persons to whom the Software is
tomoya123 0:0a7fa0911e6c 9 * furnished to do so, subject to the following conditions:
tomoya123 0:0a7fa0911e6c 10 *
tomoya123 0:0a7fa0911e6c 11 * The above copyright notice and this permission notice shall be included in
tomoya123 0:0a7fa0911e6c 12 * all copies or substantial portions of the Software.
tomoya123 0:0a7fa0911e6c 13 *
tomoya123 0:0a7fa0911e6c 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
tomoya123 0:0a7fa0911e6c 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
tomoya123 0:0a7fa0911e6c 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
tomoya123 0:0a7fa0911e6c 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
tomoya123 0:0a7fa0911e6c 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tomoya123 0:0a7fa0911e6c 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
tomoya123 0:0a7fa0911e6c 20 * SOFTWARE.
tomoya123 0:0a7fa0911e6c 21 */
tomoya123 0:0a7fa0911e6c 22 #include <string.h>
tomoya123 0:0a7fa0911e6c 23 #include "ff.h"
tomoya123 0:0a7fa0911e6c 24 #include "FATDirHandle.h"
tomoya123 0:0a7fa0911e6c 25
tomoya123 0:0a7fa0911e6c 26 using namespace mbed;
tomoya123 0:0a7fa0911e6c 27
tomoya123 0:0a7fa0911e6c 28 FATDirHandle::FATDirHandle(const FATFS_DIR &the_dir) {
tomoya123 0:0a7fa0911e6c 29 dir = the_dir;
tomoya123 0:0a7fa0911e6c 30 }
tomoya123 0:0a7fa0911e6c 31
tomoya123 0:0a7fa0911e6c 32 int FATDirHandle::closedir() {
tomoya123 0:0a7fa0911e6c 33 delete this;
tomoya123 0:0a7fa0911e6c 34 return 0;
tomoya123 0:0a7fa0911e6c 35 }
tomoya123 0:0a7fa0911e6c 36
tomoya123 0:0a7fa0911e6c 37 struct dirent *FATDirHandle::readdir() {
tomoya123 0:0a7fa0911e6c 38 FILINFO finfo;
tomoya123 0:0a7fa0911e6c 39
tomoya123 0:0a7fa0911e6c 40 #if _USE_LFN
tomoya123 0:0a7fa0911e6c 41 finfo.lfname = cur_entry.d_name;
tomoya123 0:0a7fa0911e6c 42 finfo.lfsize = sizeof(cur_entry.d_name);
tomoya123 0:0a7fa0911e6c 43 #endif // _USE_LFN
tomoya123 0:0a7fa0911e6c 44
tomoya123 0:0a7fa0911e6c 45 FRESULT res = f_readdir(&dir, &finfo);
tomoya123 0:0a7fa0911e6c 46
tomoya123 0:0a7fa0911e6c 47 #if _USE_LFN
tomoya123 0:0a7fa0911e6c 48 if(res != 0 || finfo.fname[0]==0) {
tomoya123 0:0a7fa0911e6c 49 return NULL;
tomoya123 0:0a7fa0911e6c 50 } else {
tomoya123 0:0a7fa0911e6c 51 if(cur_entry.d_name[0]==0) {
tomoya123 0:0a7fa0911e6c 52 // No long filename so use short filename.
tomoya123 0:0a7fa0911e6c 53 memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname));
tomoya123 0:0a7fa0911e6c 54 }
tomoya123 0:0a7fa0911e6c 55 return &cur_entry;
tomoya123 0:0a7fa0911e6c 56 }
tomoya123 0:0a7fa0911e6c 57 #else
tomoya123 0:0a7fa0911e6c 58 if(res != 0 || finfo.fname[0]==0) {
tomoya123 0:0a7fa0911e6c 59 return NULL;
tomoya123 0:0a7fa0911e6c 60 } else {
tomoya123 0:0a7fa0911e6c 61 memcpy(cur_entry.d_name, finfo.fname, sizeof(finfo.fname));
tomoya123 0:0a7fa0911e6c 62 return &cur_entry;
tomoya123 0:0a7fa0911e6c 63 }
tomoya123 0:0a7fa0911e6c 64 #endif /* _USE_LFN */
tomoya123 0:0a7fa0911e6c 65 }
tomoya123 0:0a7fa0911e6c 66
tomoya123 0:0a7fa0911e6c 67 void FATDirHandle::rewinddir() {
tomoya123 0:0a7fa0911e6c 68 dir.index = 0;
tomoya123 0:0a7fa0911e6c 69 }
tomoya123 0:0a7fa0911e6c 70
tomoya123 0:0a7fa0911e6c 71 off_t FATDirHandle::telldir() {
tomoya123 0:0a7fa0911e6c 72 return dir.index;
tomoya123 0:0a7fa0911e6c 73 }
tomoya123 0:0a7fa0911e6c 74
tomoya123 0:0a7fa0911e6c 75 void FATDirHandle::seekdir(off_t location) {
tomoya123 0:0a7fa0911e6c 76 dir.index = location;
tomoya123 0:0a7fa0911e6c 77 }
tomoya123 0:0a7fa0911e6c 78