Fixes #2007: Handle full SD card in openLogs(). SD card info menu implemented for Taranis, added display of free sectors. Disk IO simulation (all ported from master)

This commit is contained in:
Damjan Adamic
2015-02-20 21:59:24 +01:00
parent 9e65cd386b
commit 9d777f799d
28 changed files with 1048 additions and 680 deletions
+88
View File
@@ -1,3 +1,44 @@
/*
* Authors (alphabetical order)
* - Andre Bernet <bernet.andre@gmail.com>
* - Andreas Weitl
* - Bertrand Songis <bsongis@gmail.com>
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
* - Cameron Weeks <th9xer@gmail.com>
* - Erez Raviv
* - Gabriel Birkus
* - Jean-Pierre Parisy
* - Karl Szmutny
* - Michael Blandford
* - Michal Hlavinka
* - Pat Mackenzie
* - Philip Moss
* - Rob Thomson
* - Romolo Manfredini <romolo.manfredini@gmail.com>
* - Thomas Husterer
*
* opentx is based on code named
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
* and the original (and ongoing) project by
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <stdint.h>
#include "../../FatFs/diskio.h"
#include "../../FatFs/ff.h"
#define LIST_NONE_SD_FILE 1
bool listSdFiles(const char *path, const char *extension, const uint8_t maxlen, const char *selection, uint8_t flags=0)
@@ -142,6 +183,7 @@ bool listSdFiles(const char *path, const char *extension, const uint8_t maxlen,
return s_menu_count;
}
#if defined(PCBTARANIS)
const char *fileCopy(const char *filename, const char *srcDir, const char *destDir)
{
FIL srcFile;
@@ -186,3 +228,49 @@ const char *fileCopy(const char *filename, const char *srcDir, const char *destD
return NULL;
}
#endif // #if defined(PCBTARANIS)
#if !defined(SIMU) || defined(DISKIO_SIMU)
uint32_t sdGetNoSectors()
{
static DWORD noSectors = 0;
if (noSectors == 0 ) {
disk_ioctl(0, GET_SECTOR_COUNT, &noSectors);
}
return noSectors;
}
uint32_t sdGetSize()
{
return (sdGetNoSectors() * 512) / 1000000;
}
uint32_t sdGetFreeSectors()
{
DWORD nofree;
FATFS * fat;
if (f_getfree("", &nofree, &fat) != FR_OK) {
return 0;
}
return nofree * fat->csize;
}
#else // #if !defined(SIMU) || defined(DISKIO_SIMU)
uint32_t sdGetNoSectors()
{
return 0;
}
uint32_t sdGetSize()
{
return 0;
}
uint32_t sdGetFreeSectors()
{
return 10;
}
#endif // #if !defined(SIMU) || defined(DISKIO_SIMU)