Bmag incl gps rettelse

Dependencies:   mbed WDT MODSERIAL BME280

Committer:
gert_lauritsen
Date:
Tue Jul 09 09:54:41 2019 +0000
Branch:
MbedBMAGThrRev
Revision:
64:06b9b8ffd5a6
Parent:
61:52a6d0ffd8e5
dataline version to 4 and fw til 1.0.0.7

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gert_lauritsen 61:52a6d0ffd8e5 1 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 2 /* Low level disk I/O module skeleton for FatFs (C)ChaN, 2014 */
gert_lauritsen 61:52a6d0ffd8e5 3 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 4 /* If a working storage control module is available, it should be */
gert_lauritsen 61:52a6d0ffd8e5 5 /* attached to the FatFs via a glue function rather than modifying it. */
gert_lauritsen 61:52a6d0ffd8e5 6 /* This is an example of glue functions to attach various exsisting */
gert_lauritsen 61:52a6d0ffd8e5 7 /* storage control modules to the FatFs module with a defined API. */
gert_lauritsen 61:52a6d0ffd8e5 8 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 9
gert_lauritsen 61:52a6d0ffd8e5 10 #include "diskio.h"
gert_lauritsen 61:52a6d0ffd8e5 11 #include "mbed_debug.h"
gert_lauritsen 61:52a6d0ffd8e5 12 #include "FATFileSystem.h"
gert_lauritsen 61:52a6d0ffd8e5 13
gert_lauritsen 61:52a6d0ffd8e5 14 using namespace mbed;
gert_lauritsen 61:52a6d0ffd8e5 15
gert_lauritsen 61:52a6d0ffd8e5 16 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 17 /* Get Drive Status */
gert_lauritsen 61:52a6d0ffd8e5 18 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 19
gert_lauritsen 61:52a6d0ffd8e5 20 DSTATUS disk_status (
gert_lauritsen 61:52a6d0ffd8e5 21 BYTE pdrv /* Physical drive nmuber to identify the drive */
gert_lauritsen 61:52a6d0ffd8e5 22 )
gert_lauritsen 61:52a6d0ffd8e5 23 {
gert_lauritsen 61:52a6d0ffd8e5 24 debug_if(FFS_DBG, "disk_status on pdrv [%d]\n", pdrv);
gert_lauritsen 61:52a6d0ffd8e5 25 return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_status();
gert_lauritsen 61:52a6d0ffd8e5 26 }
gert_lauritsen 61:52a6d0ffd8e5 27
gert_lauritsen 61:52a6d0ffd8e5 28 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 29 /* Inidialize a Drive */
gert_lauritsen 61:52a6d0ffd8e5 30 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 31
gert_lauritsen 61:52a6d0ffd8e5 32 DSTATUS disk_initialize (
gert_lauritsen 61:52a6d0ffd8e5 33 BYTE pdrv /* Physical drive nmuber to identify the drive */
gert_lauritsen 61:52a6d0ffd8e5 34 )
gert_lauritsen 61:52a6d0ffd8e5 35 {
gert_lauritsen 61:52a6d0ffd8e5 36 debug_if(FFS_DBG, "disk_initialize on pdrv [%d]\n", pdrv);
gert_lauritsen 61:52a6d0ffd8e5 37 return (DSTATUS)FATFileSystem::_ffs[pdrv]->disk_initialize();
gert_lauritsen 61:52a6d0ffd8e5 38 }
gert_lauritsen 61:52a6d0ffd8e5 39
gert_lauritsen 61:52a6d0ffd8e5 40 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 41 /* Read Sector(s) */
gert_lauritsen 61:52a6d0ffd8e5 42 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 43
gert_lauritsen 61:52a6d0ffd8e5 44 DRESULT disk_read (
gert_lauritsen 61:52a6d0ffd8e5 45 BYTE pdrv, /* Physical drive nmuber to identify the drive */
gert_lauritsen 61:52a6d0ffd8e5 46 BYTE* buff, /* Data buffer to store read data */
gert_lauritsen 61:52a6d0ffd8e5 47 DWORD sector, /* Sector address in LBA */
gert_lauritsen 61:52a6d0ffd8e5 48 UINT count /* Number of sectors to read */
gert_lauritsen 61:52a6d0ffd8e5 49 )
gert_lauritsen 61:52a6d0ffd8e5 50 {
gert_lauritsen 61:52a6d0ffd8e5 51 debug_if(FFS_DBG, "disk_read(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv);
gert_lauritsen 61:52a6d0ffd8e5 52 if (FATFileSystem::_ffs[pdrv]->disk_read((uint8_t*)buff, sector, count))
gert_lauritsen 61:52a6d0ffd8e5 53 return RES_PARERR;
gert_lauritsen 61:52a6d0ffd8e5 54 else
gert_lauritsen 61:52a6d0ffd8e5 55 return RES_OK;
gert_lauritsen 61:52a6d0ffd8e5 56 }
gert_lauritsen 61:52a6d0ffd8e5 57
gert_lauritsen 61:52a6d0ffd8e5 58 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 59 /* Write Sector(s) */
gert_lauritsen 61:52a6d0ffd8e5 60 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 61
gert_lauritsen 61:52a6d0ffd8e5 62 #if _USE_WRITE
gert_lauritsen 61:52a6d0ffd8e5 63 DRESULT disk_write (
gert_lauritsen 61:52a6d0ffd8e5 64 BYTE pdrv, /* Physical drive nmuber to identify the drive */
gert_lauritsen 61:52a6d0ffd8e5 65 const BYTE* buff, /* Data to be written */
gert_lauritsen 61:52a6d0ffd8e5 66 DWORD sector, /* Sector address in LBA */
gert_lauritsen 61:52a6d0ffd8e5 67 UINT count /* Number of sectors to write */
gert_lauritsen 61:52a6d0ffd8e5 68 )
gert_lauritsen 61:52a6d0ffd8e5 69 {
gert_lauritsen 61:52a6d0ffd8e5 70 debug_if(FFS_DBG, "disk_write(sector %d, count %d) on pdrv [%d]\n", sector, count, pdrv);
gert_lauritsen 61:52a6d0ffd8e5 71 if (FATFileSystem::_ffs[pdrv]->disk_write((uint8_t*)buff, sector, count))
gert_lauritsen 61:52a6d0ffd8e5 72 return RES_PARERR;
gert_lauritsen 61:52a6d0ffd8e5 73 else
gert_lauritsen 61:52a6d0ffd8e5 74 return RES_OK;
gert_lauritsen 61:52a6d0ffd8e5 75 }
gert_lauritsen 61:52a6d0ffd8e5 76 #endif
gert_lauritsen 61:52a6d0ffd8e5 77
gert_lauritsen 61:52a6d0ffd8e5 78 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 79 /* Miscellaneous Functions */
gert_lauritsen 61:52a6d0ffd8e5 80 /*-----------------------------------------------------------------------*/
gert_lauritsen 61:52a6d0ffd8e5 81
gert_lauritsen 61:52a6d0ffd8e5 82 #if _USE_IOCTL
gert_lauritsen 61:52a6d0ffd8e5 83 DRESULT disk_ioctl (
gert_lauritsen 61:52a6d0ffd8e5 84 BYTE pdrv, /* Physical drive nmuber (0..) */
gert_lauritsen 61:52a6d0ffd8e5 85 BYTE cmd, /* Control code */
gert_lauritsen 61:52a6d0ffd8e5 86 void* buff /* Buffer to send/receive control data */
gert_lauritsen 61:52a6d0ffd8e5 87 )
gert_lauritsen 61:52a6d0ffd8e5 88 {
gert_lauritsen 61:52a6d0ffd8e5 89 debug_if(FFS_DBG, "disk_ioctl(%d)\n", cmd);
gert_lauritsen 61:52a6d0ffd8e5 90 switch(cmd) {
gert_lauritsen 61:52a6d0ffd8e5 91 case CTRL_SYNC:
gert_lauritsen 61:52a6d0ffd8e5 92 if(FATFileSystem::_ffs[pdrv] == NULL) {
gert_lauritsen 61:52a6d0ffd8e5 93 return RES_NOTRDY;
gert_lauritsen 61:52a6d0ffd8e5 94 } else if(FATFileSystem::_ffs[pdrv]->disk_sync()) {
gert_lauritsen 61:52a6d0ffd8e5 95 return RES_ERROR;
gert_lauritsen 61:52a6d0ffd8e5 96 }
gert_lauritsen 61:52a6d0ffd8e5 97 return RES_OK;
gert_lauritsen 61:52a6d0ffd8e5 98 case GET_SECTOR_COUNT:
gert_lauritsen 61:52a6d0ffd8e5 99 if(FATFileSystem::_ffs[pdrv] == NULL) {
gert_lauritsen 61:52a6d0ffd8e5 100 return RES_NOTRDY;
gert_lauritsen 61:52a6d0ffd8e5 101 } else {
gert_lauritsen 61:52a6d0ffd8e5 102 DWORD res = FATFileSystem::_ffs[pdrv]->disk_sectors();
gert_lauritsen 61:52a6d0ffd8e5 103 if(res > 0) {
gert_lauritsen 61:52a6d0ffd8e5 104 *((DWORD*)buff) = res; // minimum allowed
gert_lauritsen 61:52a6d0ffd8e5 105 return RES_OK;
gert_lauritsen 61:52a6d0ffd8e5 106 } else {
gert_lauritsen 61:52a6d0ffd8e5 107 return RES_ERROR;
gert_lauritsen 61:52a6d0ffd8e5 108 }
gert_lauritsen 61:52a6d0ffd8e5 109 }
gert_lauritsen 61:52a6d0ffd8e5 110 case GET_BLOCK_SIZE:
gert_lauritsen 61:52a6d0ffd8e5 111 *((DWORD*)buff) = 1; // default when not known
gert_lauritsen 61:52a6d0ffd8e5 112 return RES_OK;
gert_lauritsen 61:52a6d0ffd8e5 113
gert_lauritsen 61:52a6d0ffd8e5 114 }
gert_lauritsen 61:52a6d0ffd8e5 115 return RES_PARERR;
gert_lauritsen 61:52a6d0ffd8e5 116 }
gert_lauritsen 61:52a6d0ffd8e5 117 #endif