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:
@@ -130,6 +130,7 @@ namespace Open9xSky9x {
|
||||
#include "radio/src/logs.cpp"
|
||||
#include "radio/src/targets/sky9x/keys_driver.cpp"
|
||||
#include "radio/src/keys.cpp"
|
||||
#include "radio/src/sdcard.cpp"
|
||||
#include "radio/src/targets/simu/simpgmspace.cpp"
|
||||
#include "radio/src/templates.cpp"
|
||||
#include "radio/src/translations.cpp"
|
||||
|
||||
@@ -145,6 +145,7 @@ inline int geteepromsize() {
|
||||
#include "radio/src/haptic.cpp"
|
||||
#include "radio/src/sbus.cpp"
|
||||
#include "radio/src/targets/taranis/haptic_driver.cpp"
|
||||
#include "radio/src/sdcard.cpp"
|
||||
// TODO Because FatFS in not C++ there cannot be namespaces there and the functions are defined several times!
|
||||
#undef SDCARD
|
||||
#include "radio/src/targets/simu/simpgmspace.cpp"
|
||||
|
||||
@@ -341,6 +341,13 @@ LCD_DUAL_BUFFER = NO
|
||||
# Values = NO, YES
|
||||
TARANIS_INTERNAL_PPM = NO
|
||||
|
||||
# Enable disk IO simulation in simulator
|
||||
# Simulator will use FatFs module and simulated IO layer that
|
||||
# uses "./sdcard.image" file as image of SD card.
|
||||
# This file must contain whole SD card from first to last sector
|
||||
# Values = NO, YES
|
||||
DISKIO_SIMU = NO
|
||||
|
||||
#------- END BUILD OPTIONS ---------------------------
|
||||
|
||||
# Define programs and commands.
|
||||
@@ -1537,6 +1544,11 @@ FOXLIB=-L/usr/local/lib \
|
||||
-lFOX-1.6 \
|
||||
-Wl,-rpath,$(FOXPATH)/src/.libs
|
||||
|
||||
ifeq ($(DISKIO_SIMU), YES)
|
||||
CPPDEFS += -DDISKIO_SIMU
|
||||
CPPSRC += FatFs/ff.c FatFs/option/ccsbcs.c
|
||||
endif
|
||||
|
||||
simu: $(LUADEP) stamp_header allsimusrc.cpp Makefile simu.cpp targets/simu/simpgmspace.cpp *.h tra lbm eeprom.bin
|
||||
g++ $(CPPFLAGS) $(INCFLAGS) simu.cpp allsimusrc.cpp $(LUASRC) targets/simu/simpgmspace.cpp -MD -DSIMU -DLUA_USE_APICHECK -O0 -o simu $(FOXINC) $(FOXLIB) -pthread -fexceptions
|
||||
|
||||
|
||||
@@ -44,11 +44,17 @@ void menuGeneralSdManagerInfo(uint8_t event)
|
||||
lcd_puts(10*FW, 2*FH, SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD);
|
||||
|
||||
lcd_putsLeft(3*FH, STR_SD_SIZE);
|
||||
lcd_outdezAtt(10*FW, 3*FH, SD_GET_SIZE_MB(), LEFT);
|
||||
lcd_outdezAtt(10*FW, 3*FH, sdGetSize(), LEFT);
|
||||
lcd_putc(lcdLastPos, 3*FH, 'M');
|
||||
|
||||
lcd_putsLeft(4*FH, STR_SD_SECTORS);
|
||||
lcd_outdezAtt(10*FW, 4*FH, SD_GET_BLOCKNR()/1000, LEFT);
|
||||
#if defined(SD_GET_FREE_BLOCKNR)
|
||||
lcd_outdezAtt(10*FW, 4*FH, SD_GET_FREE_BLOCKNR()/1000, LEFT);
|
||||
lcd_putc(lcdLastPos, 4*FH, '/');
|
||||
lcd_outdezAtt(lcdLastPos+FW, 4*FH, sdGetNoSectors()/1000, LEFT);
|
||||
#else
|
||||
lcd_outdezAtt(10*FW, 4*FH, sdGetNoSectors()/1000, LEFT);
|
||||
#endif
|
||||
lcd_putc(lcdLastPos, 4*FH, 'k');
|
||||
|
||||
lcd_putsLeft(5*FH, STR_SD_SPEED);
|
||||
|
||||
@@ -46,11 +46,17 @@ void menuGeneralSdManagerInfo(uint8_t event)
|
||||
lcd_puts(10*FW, 2*FH, SD_IS_HC() ? STR_SDHC_CARD : STR_SD_CARD);
|
||||
|
||||
lcd_putsLeft(3*FH, STR_SD_SIZE);
|
||||
lcd_outdezAtt(10*FW, 3*FH, SD_GET_SIZE_MB(), LEFT);
|
||||
lcd_outdezAtt(10*FW, 3*FH, sdGetSize(), LEFT);
|
||||
lcd_putc(lcdLastPos, 3*FH, 'M');
|
||||
|
||||
lcd_putsLeft(4*FH, STR_SD_SECTORS);
|
||||
lcd_outdezAtt(10*FW, 4*FH, SD_GET_BLOCKNR()/1000, LEFT);
|
||||
#if defined(SD_GET_FREE_BLOCKNR)
|
||||
lcd_outdezAtt(10*FW, 4*FH, SD_GET_FREE_BLOCKNR()/1000, LEFT);
|
||||
lcd_putc(lcdLastPos, 4*FH, '/');
|
||||
lcd_outdezAtt(lcdLastPos+FW, 4*FH, sdGetNoSectors()/1000, LEFT);
|
||||
#else
|
||||
lcd_outdezAtt(10*FW, 4*FH, sdGetNoSectors()/1000, LEFT);
|
||||
#endif
|
||||
lcd_putc(lcdLastPos, 4*FH, 'k');
|
||||
|
||||
lcd_putsLeft(5*FH, STR_SD_SPEED);
|
||||
@@ -242,7 +248,7 @@ void menuGeneralSdManager(uint8_t _event)
|
||||
case EVT_KEY_LONG(KEY_MENU):
|
||||
if (!READ_ONLY() && s_editMode == 0) {
|
||||
killEvents(_event);
|
||||
// MENU_ADD_ITEM(STR_SD_INFO); TODO: Implement
|
||||
MENU_ADD_ITEM(STR_SD_INFO);
|
||||
MENU_ADD_ITEM(STR_SD_FORMAT);
|
||||
menuHandler = onSdManagerMenu;
|
||||
}
|
||||
|
||||
+3
-1
@@ -59,6 +59,9 @@ const pm_char *openLogs()
|
||||
if (!sdMounted())
|
||||
return STR_NO_SDCARD;
|
||||
|
||||
if (sdGetFreeSectors() == 0)
|
||||
return STR_SDCARD_FULL;
|
||||
|
||||
// check and create folder here
|
||||
strcpy_P(filename, STR_LOGS_PATH);
|
||||
result = f_opendir(&folder, filename);
|
||||
@@ -193,7 +196,6 @@ void writeHeader()
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO test when disk full
|
||||
void writeLogs()
|
||||
{
|
||||
static const pm_char * error_displayed = NULL;
|
||||
|
||||
@@ -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)
|
||||
@@ -74,6 +74,10 @@ void writeHeader();
|
||||
void closeLogs();
|
||||
void writeLogs();
|
||||
|
||||
uint32_t sdGetNoSectors();
|
||||
uint32_t sdGetSize();
|
||||
uint32_t sdGetFreeSectors();
|
||||
|
||||
#if !defined(BOOT)
|
||||
inline const pm_char *SDCARD_ERROR(FRESULT result)
|
||||
{
|
||||
|
||||
@@ -84,14 +84,12 @@
|
||||
|
||||
// SD driver
|
||||
#define sdDone()
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
#if !defined(SIMU)
|
||||
bool sdMounted();
|
||||
void sdMountPoll();
|
||||
void sdPoll10ms();
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_BLOCKNR() (0)
|
||||
#define SD_GET_SIZE_MB() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
#endif
|
||||
|
||||
#define speakerOn() TCCR0A |= (1 << COM0A0)
|
||||
|
||||
@@ -86,16 +86,14 @@
|
||||
#define __BACKLIGHT_OFF PORTC &= ~(1<<OUT_C_LIGHT)
|
||||
#define IS_BACKLIGHT_ON() PORTC &= (1<<OUT_C_LIGHT)
|
||||
|
||||
// SD driver
|
||||
#define sdDone()
|
||||
// SD driver
|
||||
#define sdDone()
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
#if !defined(SIMU)
|
||||
bool sdMounted();
|
||||
void sdMountPoll();
|
||||
void sdPoll10ms();
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_BLOCKNR() (0)
|
||||
#define SD_GET_SIZE_MB() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
bool sdMounted();
|
||||
void sdMountPoll();
|
||||
void sdPoll10ms();
|
||||
#endif
|
||||
|
||||
// Keyboard driver
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
#if defined(DISKIO_SIMU)
|
||||
FILE * diskImage = 0;
|
||||
#endif
|
||||
|
||||
volatile uint8_t pina=0xff, pinb=0xff, pinc=0xff, pind, pine=0xff, pinf=0xff, ping=0xff, pinh=0xff, pinj=0xff, pinl=0;
|
||||
uint8_t portb, portc, porth=0, dummyport;
|
||||
uint16_t dummyport16;
|
||||
@@ -325,6 +329,12 @@ void *main_thread(void *)
|
||||
|
||||
eeReadAll(); // load general setup and selected model
|
||||
|
||||
#if defined(DISKIO_SIMU)
|
||||
f_mount(&g_FATFS_Obj, "", 1);
|
||||
// call sdGetFreeSectors() now because f_getfree() takes a long time first time it's called
|
||||
sdGetFreeSectors();
|
||||
#endif
|
||||
|
||||
#if defined(CPUARM) && defined(SDCARD)
|
||||
referenceSystemAudioFiles();
|
||||
#endif
|
||||
@@ -365,6 +375,12 @@ void *main_thread(void *)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(DISKIO_SIMU)
|
||||
if (diskImage) {
|
||||
fclose(diskImage);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -494,7 +510,7 @@ static void EeFsDump(){
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(SDCARD)
|
||||
#if defined(SDCARD) && !defined(DISKIO_SIMU)
|
||||
namespace simu {
|
||||
#include <dirent.h>
|
||||
}
|
||||
@@ -523,8 +539,14 @@ FRESULT f_stat (const TCHAR * name, FILINFO *)
|
||||
{
|
||||
char *path = convertSimuPath(name);
|
||||
struct stat tmp;
|
||||
TRACE("f_stat(%s)", path);
|
||||
return stat(path, &tmp) ? FR_INVALID_NAME : FR_OK;
|
||||
if (stat(path, &tmp)) {
|
||||
TRACE("f_stat(%s) = error %d (%s)", path, errno, strerror(errno));
|
||||
return FR_INVALID_NAME;
|
||||
}
|
||||
else {
|
||||
TRACE("f_stat(%s) = OK", path);
|
||||
return FR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
FRESULT f_mount (FATFS* ,const TCHAR*, BYTE opt)
|
||||
@@ -535,17 +557,21 @@ FRESULT f_mount (FATFS* ,const TCHAR*, BYTE opt)
|
||||
FRESULT f_open (FIL * fil, const TCHAR *name, BYTE flag)
|
||||
{
|
||||
char *path = convertSimuPath(name);
|
||||
|
||||
TRACE("f_open(%s)", path);
|
||||
|
||||
if (!(flag & FA_WRITE)) {
|
||||
struct stat tmp;
|
||||
if (stat(path, &tmp))
|
||||
if (stat(path, &tmp)) {
|
||||
TRACE("f_open(%s) = INVALID_NAME", path);
|
||||
return FR_INVALID_NAME;
|
||||
}
|
||||
fil->fsize = tmp.st_size;
|
||||
}
|
||||
fil->fs = (FATFS*)fopen(path, (flag & FA_WRITE) ? "wb+" : "rb+");
|
||||
return FR_OK;
|
||||
if ( fil->fs ) {
|
||||
TRACE("f_open(%s) = OK", path);
|
||||
return FR_OK;
|
||||
}
|
||||
TRACE("f_open(%s) = error %d (%s)", path, errno, strerror(errno));
|
||||
return FR_INVALID_NAME;
|
||||
}
|
||||
|
||||
FRESULT f_read (FIL* fil, void* data, UINT size, UINT* read)
|
||||
@@ -590,9 +616,13 @@ FRESULT f_chdir (const TCHAR *name)
|
||||
FRESULT f_opendir (DIR * rep, const TCHAR * name)
|
||||
{
|
||||
char *path = convertSimuPath(name);
|
||||
TRACE("f_opendir(%s)", path);
|
||||
rep->fs = (FATFS *)simu::opendir(path);
|
||||
return FR_OK;
|
||||
if ( rep->fs ) {
|
||||
TRACE("f_opendir(%s) = OK", path);
|
||||
return FR_OK;
|
||||
}
|
||||
TRACE("f_opendir(%s) = error %d (%s)", path, errno, strerror(errno));
|
||||
return FR_INVALID_NAME;
|
||||
}
|
||||
|
||||
FRESULT f_closedir (DIR * rep)
|
||||
@@ -682,13 +712,206 @@ FRESULT f_getcwd (TCHAR *path, UINT sz_path)
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs)
|
||||
{
|
||||
// just fake that we always have some clusters free
|
||||
*nclst = 10;
|
||||
return FR_OK;
|
||||
}
|
||||
|
||||
#if defined(PCBSKY9X)
|
||||
int32_t Card_state = SD_ST_MOUNTED;
|
||||
uint32_t Card_CSD[4]; // TODO elsewhere
|
||||
#endif
|
||||
|
||||
#endif // #if defined(SDCARD) && !defined(DISKIO_SIMU)
|
||||
|
||||
|
||||
#if defined(DISKIO_SIMU)
|
||||
#include "FatFs/diskio.h"
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(CPUARM)
|
||||
FATFS g_FATFS_Obj = { 0};
|
||||
#endif
|
||||
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj) /* Create a sync object */
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int ff_req_grant (_SYNC_t sobj) /* Lock sync object */
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void ff_rel_grant (_SYNC_t sobj) /* Unlock sync object */
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int ff_del_syncobj (_SYNC_t sobj) /* Delete a sync object */
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DWORD get_fattime (void)
|
||||
{
|
||||
time_t tim = time(0);
|
||||
const struct tm * t = gmtime(&tim);
|
||||
|
||||
/* Pack date and time into a DWORD variable */
|
||||
return ((DWORD)(t->tm_year - 80) << 25)
|
||||
| ((uint32_t)(t->tm_mon+1) << 21)
|
||||
| ((uint32_t)t->tm_mday << 16)
|
||||
| ((uint32_t)t->tm_hour << 11)
|
||||
| ((uint32_t)t->tm_min << 5)
|
||||
| ((uint32_t)t->tm_sec >> 1);
|
||||
}
|
||||
|
||||
unsigned int noDiskStatus = 0;
|
||||
|
||||
void traceDiskStatus()
|
||||
{
|
||||
if (noDiskStatus > 0) {
|
||||
TRACE("disk_status() called %d times", noDiskStatus);
|
||||
noDiskStatus = 0;
|
||||
}
|
||||
}
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv)
|
||||
{
|
||||
traceDiskStatus();
|
||||
TRACE("disk_initialize(%u)", pdrv);
|
||||
diskImage = fopen("sdcard.image", "r+");
|
||||
return diskImage ? (DSTATUS)0 : (DSTATUS)STA_NODISK;
|
||||
}
|
||||
|
||||
DSTATUS disk_status (BYTE pdrv)
|
||||
{
|
||||
++noDiskStatus;
|
||||
// TRACE("disk_status(%u)", pdrv);
|
||||
return (DSTATUS)0;
|
||||
}
|
||||
|
||||
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count)
|
||||
{
|
||||
if (diskImage == 0) return RES_NOTRDY;
|
||||
traceDiskStatus();
|
||||
TRACE("disk_read(%u, %p, %u, %u)", pdrv, buff, sector, count);
|
||||
fseek(diskImage, sector*512, SEEK_SET);
|
||||
fread(buff, count, 512, diskImage);
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count)
|
||||
{
|
||||
if (diskImage == 0) return RES_NOTRDY;
|
||||
traceDiskStatus();
|
||||
TRACE("disk_write(%u, %p, %u, %u)", pdrv, buff, sector, count);
|
||||
fseek(diskImage, sector*512, SEEK_SET);
|
||||
fwrite(buff, count, 512, diskImage);
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff)
|
||||
{
|
||||
if (diskImage == 0) return RES_NOTRDY;
|
||||
traceDiskStatus();
|
||||
TRACE("disk_ioctl(%u, %u, %p)", pdrv, cmd, buff);
|
||||
if (pdrv) return RES_PARERR;
|
||||
|
||||
DRESULT res;
|
||||
BYTE *ptr = (BYTE *)buff;
|
||||
|
||||
if (cmd == CTRL_POWER) {
|
||||
switch (*ptr) {
|
||||
case 0: /* Sub control code == 0 (POWER_OFF) */
|
||||
res = RES_OK;
|
||||
break;
|
||||
case 1: /* Sub control code == 1 (POWER_ON) */
|
||||
res = RES_OK;
|
||||
break;
|
||||
case 2: /* Sub control code == 2 (POWER_GET) */
|
||||
*(ptr+1) = (BYTE)1; /* fake powered */
|
||||
res = RES_OK;
|
||||
break;
|
||||
default :
|
||||
res = RES_PARERR;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
switch(cmd) {
|
||||
/* Generic command (Used by FatFs) */
|
||||
case CTRL_SYNC : /* Complete pending write process (needed at _FS_READONLY == 0) */
|
||||
break;
|
||||
|
||||
case GET_SECTOR_COUNT: /* Get media size (needed at _USE_MKFS == 1) */
|
||||
{
|
||||
struct stat buf;
|
||||
if (stat("sdcard.image", &buf) == 0) {
|
||||
DWORD noSectors = buf.st_size / 512;
|
||||
*(DWORD*)buff = noSectors;
|
||||
TRACE("disk_ioctl(GET_SECTOR_COUNT) = %u", noSectors);
|
||||
return RES_OK;
|
||||
}
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
case GET_SECTOR_SIZE: /* Get sector size (needed at _MAX_SS != _MIN_SS) */
|
||||
TRACE("disk_ioctl(GET_SECTOR_SIZE) = 512");
|
||||
*(WORD*)buff = 512;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case GET_BLOCK_SIZE : /* Get erase block size (needed at _USE_MKFS == 1) */
|
||||
*(WORD*)buff = 512 * 4;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
case CTRL_TRIM : /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
|
||||
break;
|
||||
|
||||
/* Generic command (Not used by FatFs) */
|
||||
case CTRL_LOCK : /* Lock/Unlock media removal */
|
||||
case CTRL_EJECT: /* Eject media */
|
||||
case CTRL_FORMAT: /* Create physical format on the media */
|
||||
return RES_PARERR;
|
||||
|
||||
|
||||
/* MMC/SDC specific ioctl command */
|
||||
// case MMC_GET_TYPE 10 /* Get card type */
|
||||
// case MMC_GET_CSD 11 /* Get CSD */
|
||||
// case MMC_GET_CID 12 /* Get CID */
|
||||
// case MMC_GET_OCR 13 /* Get OCR */
|
||||
// case MMC_GET_SDSTAT 14 /* Get SD status */
|
||||
|
||||
/* ATA/CF specific ioctl command */
|
||||
// case ATA_GET_REV 20 /* Get F/W revision */
|
||||
// case ATA_GET_MODEL 21 /* Get model name */
|
||||
// case ATA_GET_SN 22 /* Get serial number */
|
||||
default:
|
||||
return RES_PARERR;
|
||||
}
|
||||
return RES_OK;
|
||||
}
|
||||
|
||||
uint32_t sdIsHC()
|
||||
{
|
||||
return sdGetSize() > 2000000;
|
||||
}
|
||||
|
||||
uint32_t sdGetSpeed()
|
||||
{
|
||||
return 330000;
|
||||
}
|
||||
|
||||
#endif // #if defined(DISKIO_SIMU)
|
||||
|
||||
|
||||
|
||||
bool lcd_refresh = true;
|
||||
display_t lcd_buf[DISPLAY_BUF_SIZE];
|
||||
|
||||
@@ -760,5 +983,5 @@ void turnBacklightOff(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif // #if defined(PCBTARANIS)
|
||||
|
||||
|
||||
@@ -424,10 +424,5 @@ extern char simuSdDirectory[1024];
|
||||
#define sdPoll10ms()
|
||||
#define sd_card_ready() (true)
|
||||
#define sdMounted() (true)
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_BLOCKNR() (0)
|
||||
#define SD_GET_SIZE_MB() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -548,12 +548,13 @@ extern uint32_t transSpeed;
|
||||
#define SD_CSD_BLOCKNR_HC(pSd) ((SD_CSD_C_SIZE_HC(pSd) + 1) * 1024)
|
||||
|
||||
#if !defined(SIMU)
|
||||
#define SD_IS_HC() (Cmd_A41_resp & OCR_SD_CCS)
|
||||
#define SD_GET_BLOCKNR() (SD_IS_HC() ? (SD_CSD_BLOCKNR_HC(Card_CSD)) : (SD_CSD_BLOCKNR(Card_CSD)))
|
||||
|
||||
#define SD_GET_SPEED() (transSpeed)
|
||||
|
||||
#define SD_GET_SIZE_MB() (SD_GET_BLOCKNR() / 2048)
|
||||
#define SD_IS_HC() (Cmd_A41_resp & OCR_SD_CCS)
|
||||
#define SD_GET_BLOCKNR() (SD_IS_HC() ? (SD_CSD_BLOCKNR_HC(Card_CSD)) : (SD_CSD_BLOCKNR(Card_CSD)))
|
||||
#define SD_GET_SPEED() (transSpeed)
|
||||
#else
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_BLOCKNR() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@@ -1087,6 +1087,9 @@ void sdInit()
|
||||
Card_state = SD_ST_DATA;
|
||||
|
||||
if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) {
|
||||
// call sdGetFreeSectors() now because f_getfree() takes a long time first time it's called
|
||||
sdGetFreeSectors();
|
||||
|
||||
referenceSystemAudioFiles();
|
||||
Card_state = SD_ST_MOUNTED;
|
||||
}
|
||||
|
||||
@@ -122,14 +122,21 @@ void delay_01us(uint16_t nb);
|
||||
#endif
|
||||
|
||||
// SD driver
|
||||
#if !defined(SIMU) || defined(DISKIO_SIMU)
|
||||
uint32_t sdIsHC();
|
||||
uint32_t sdGetSpeed();
|
||||
#define SD_IS_HC() (sdIsHC())
|
||||
#define SD_GET_SPEED() (sdGetSpeed())
|
||||
#define SD_GET_FREE_BLOCKNR() (sdGetFreeSectors())
|
||||
#else
|
||||
#define SD_IS_HC() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
#endif
|
||||
|
||||
#if defined(SIMU)
|
||||
#define sdInit()
|
||||
#define sdDone()
|
||||
#else
|
||||
#define SD_IS_HC() (1)
|
||||
#define SD_GET_SIZE_MB() (0)
|
||||
#define SD_GET_BLOCKNR() (0)
|
||||
#define SD_GET_SPEED() (0)
|
||||
void sdInit(void);
|
||||
void sdDone(void);
|
||||
void sdPoll10ms(void);
|
||||
|
||||
@@ -1031,6 +1031,9 @@ void sdInit(void)
|
||||
}
|
||||
|
||||
if (f_mount(&g_FATFS_Obj, "", 1) == FR_OK) {
|
||||
// call sdGetFreeSectors() now because f_getfree() takes a long time first time it's called
|
||||
sdGetFreeSectors();
|
||||
|
||||
referenceSystemAudioFiles();
|
||||
|
||||
#if defined(SPORT_FILE_LOG)
|
||||
@@ -1059,4 +1062,12 @@ uint32_t sdMounted()
|
||||
return g_FATFS_Obj.fs_type != 0;
|
||||
}
|
||||
|
||||
uint32_t sdIsHC()
|
||||
{
|
||||
return (CardType & CT_BLOCK);
|
||||
}
|
||||
|
||||
uint32_t sdGetSpeed()
|
||||
{
|
||||
return 330000;
|
||||
}
|
||||
|
||||
+632
-631
File diff suppressed because it is too large
Load Diff
@@ -579,6 +579,7 @@ extern const pm_char STR_RESET_BTN[];
|
||||
extern const pm_char STR_RESTORE_MODEL[];
|
||||
extern const pm_char STR_SDCARD_ERROR[];
|
||||
extern const pm_char STR_NO_SDCARD[];
|
||||
extern const pm_char STR_SDCARD_FULL[];
|
||||
extern const pm_char STR_INCOMPATIBLE[];
|
||||
extern const pm_char STR_LOGS_PATH[];
|
||||
extern const pm_char STR_LOGS_EXT[];
|
||||
|
||||
@@ -731,6 +731,7 @@
|
||||
#define TR_RESTORE_MODEL "Obnov model z SD"
|
||||
#define TR_SDCARD_ERROR "Chyba SD karty"
|
||||
#define TR_NO_SDCARD "Není SD karta"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Nekompatibilní"
|
||||
#define TR_WARNING "KONTROLA"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
|
||||
@@ -735,6 +735,7 @@
|
||||
#define TR_RESTORE_MODEL "Modell Restore"
|
||||
#define TR_SDCARD_ERROR "SD-Kartenfehler"
|
||||
#define TR_NO_SDCARD "Keine SD-Karte"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Nicht kompatibel"
|
||||
#define TR_WARNING "WARNUNG"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
|
||||
@@ -776,6 +776,7 @@
|
||||
#define TR_RESTORE_MODEL "Restore Model"
|
||||
#define TR_SDCARD_ERROR "SD Card Error"
|
||||
#define TR_NO_SDCARD "No SD Card"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Incompatible"
|
||||
#define TR_WARNING "WARNING"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
|
||||
@@ -728,6 +728,7 @@
|
||||
#define TR_RESTORE_MODEL "Restaurar Modelo"
|
||||
#define TR_SDCARD_ERROR "SDCARD Error"
|
||||
#define TR_NO_SDCARD "No SDCARD"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Incompatible"
|
||||
#define TR_WARNING "AVISO"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
|
||||
@@ -728,6 +728,7 @@
|
||||
#define TR_RESTORE_MODEL "Restore Model"
|
||||
#define TR_SDCARD_ERROR "SDCARD Error"
|
||||
#define TR_NO_SDCARD "No SDCARD"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Incompatible"
|
||||
#define TR_WARNING "WARNING"
|
||||
#define TR_EEPROMWARN "FINSKA"
|
||||
|
||||
@@ -728,6 +728,7 @@
|
||||
#define TR_RESTORE_MODEL "Restaurer Modèle"
|
||||
#define TR_SDCARD_ERROR "Erreur carte SD"
|
||||
#define TR_NO_SDCARD "Carte SD indisponible"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Incompatible"
|
||||
#define TR_WARNING "ALERTE"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
|
||||
@@ -728,6 +728,7 @@
|
||||
#define TR_RESTORE_MODEL TR("Ripr. Modello","Ripristina Modello")
|
||||
#define TR_SDCARD_ERROR "Errore SD"
|
||||
#define TR_NO_SDCARD "No SDCARD"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Incompatibile"
|
||||
#define TR_WARNING "AVVISO"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
|
||||
@@ -726,6 +726,7 @@
|
||||
#define TR_RESTORE_MODEL "Odtwórz model"
|
||||
#define TR_SDCARD_ERROR "Błąd karty SD"
|
||||
#define TR_NO_SDCARD "Brak karty SD"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Niekompatybilne"
|
||||
#define TR_WARNING "UWAGA"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
|
||||
@@ -551,8 +551,8 @@
|
||||
#define OFS_CHECKTRIMS (9*FW)
|
||||
#define TR_SWASHTYPE "Ciclico Tipo"
|
||||
#define TR_COLLECTIVE "Coletivo"
|
||||
#define TR_AILERON "Aileron Source"
|
||||
#define TR_ELEVATOR "Elevator Source"
|
||||
#define TR_AILERON "Aileron Source"
|
||||
#define TR_ELEVATOR "Elevator Source"
|
||||
#define TR_SWASHRING "Anel Coletivo"
|
||||
#define TR_ELEDIRECTION "PFD Sentido"
|
||||
#define TR_AILDIRECTION "AIL Sentido"
|
||||
@@ -728,6 +728,7 @@
|
||||
#define TR_RESTORE_MODEL "Restaura Modelo"
|
||||
#define TR_SDCARD_ERROR "SDCARD Erro"
|
||||
#define TR_NO_SDCARD "Sem SDCARD"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Incompativel"
|
||||
#define TR_WARNING "AVISO"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
|
||||
@@ -551,8 +551,8 @@
|
||||
#define OFS_CHECKTRIMS CENTER_OFS+(9*FW)
|
||||
#define TR_SWASHTYPE "Swashtyp"
|
||||
#define TR_COLLECTIVE "Kollektiv"
|
||||
#define TR_AILERON "Aileron Source"
|
||||
#define TR_ELEVATOR "Elevator Source"
|
||||
#define TR_AILERON "Aileron Source"
|
||||
#define TR_ELEVATOR "Elevator Source"
|
||||
#define TR_SWASHRING "Swashring"
|
||||
#define TR_ELEDIRECTION "HöJD Riktning"
|
||||
#define TR_AILDIRECTION "SKEV Riktning"
|
||||
@@ -728,6 +728,7 @@
|
||||
#define TR_RESTORE_MODEL "återställ Modell"
|
||||
#define TR_SDCARD_ERROR "SDCARD-fel"
|
||||
#define TR_NO_SDCARD "SDCARD saknas"
|
||||
#define TR_SDCARD_FULL "SD Card Full"
|
||||
#define TR_INCOMPATIBLE "Inkompatibel"
|
||||
#define TR_WARNING "VARNING"
|
||||
#define TR_EEPROMWARN "EEPROM"
|
||||
|
||||
Reference in New Issue
Block a user