Bmag incl gps rettelse

Dependencies:   mbed WDT MODSERIAL BME280

Committer:
gert_lauritsen
Date:
Fri Jul 05 12:55:53 2019 +0000
Branch:
MbedBMAGThrRev
Revision:
61:52a6d0ffd8e5
dato rettel og ID i file lagt ind i version 5

Who changed what in which revision?

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