diff --git a/epicardium/modules/filesystem_fileops.c b/epicardium/fs/fileops.c similarity index 73% rename from epicardium/modules/filesystem_fileops.c rename to epicardium/fs/fileops.c index c285c0e6129fda0e2c35711231c3cae6f5d67179..2d9c7ca3f2198421d825cdf67acfdb9b33f52a15 100644 --- a/epicardium/modules/filesystem_fileops.c +++ b/epicardium/fs/fileops.c @@ -6,20 +6,7 @@ * */ -#include "modules/filesystem.h" -#include "epicardium.h" - -extern int -efs_open(EpicFileSystem *fs, const char *filename, const char *modeString); -extern int efs_close(EpicFileSystem *fs, int fd); -extern int efs_read(EpicFileSystem *fs, int fd, void *buf, size_t nbytes); -extern int -efs_write(EpicFileSystem *fs, int fd, const void *buf, size_t nbytes); -extern int efs_flush(EpicFileSystem *fs, int fd); -extern int efs_seek(EpicFileSystem *fs, int fd, long offset, int whence); -extern int efs_tell(EpicFileSystem *fs, int fd); -extern int -efs_stat(EpicFileSystem *fs, const char *filename, struct epic_stat *stat); +#include "fs/internal.h" int epic_file_open(const char *filename, const char *mode) { diff --git a/epicardium/fs/internal.h b/epicardium/fs/internal.h new file mode 100644 index 0000000000000000000000000000000000000000..3ae4cf4ef6e88e36fa10dce7ccc2967f6862bd8e --- /dev/null +++ b/epicardium/fs/internal.h @@ -0,0 +1,41 @@ +#ifndef EPICARCIUM_FS_INTERNAL_H_INCLUDED +#define EPICARCIUM_FS_INTERNAL_H_INCLUDED + +#include <stdint.h> +#include <stddef.h> +#include <stdbool.h> + +#include "epicardium.h" + +/* Number of bits to use for indexing into our internal pool of files/directories + * This indirectly specifies the size of the pool as 1^EPIC_FAT_FD_INDEX_BITS + * Increase if number of open file descriptors is not enough, but be aware of + * memory usage of the pool! + */ +#define EPIC_FAT_FD_INDEX_BITS 4 +#define EPIC_FAT_STATIC_SEMAPHORE 1 + +// forward declaration, actual definition is in filesystem_fat.c +typedef struct EpicFileSystem EpicFileSystem; + +int efs_open(EpicFileSystem *fs, const char *filename, const char *modeString); +int efs_close(EpicFileSystem *fs, int fd); +int efs_read(EpicFileSystem *fs, int fd, void *buf, size_t nbytes); +int efs_write(EpicFileSystem *fs, int fd, const void *buf, size_t nbytes); +int efs_flush(EpicFileSystem *fs, int fd); +int efs_seek(EpicFileSystem *fs, int fd, long offset, int whence); +int efs_tell(EpicFileSystem *fs, int fd); +int efs_stat(EpicFileSystem *fs, const char *filename, struct epic_stat *stat); +/** + * lock global filesystem + * + * locks the global mutex and, if the global EpicFileSystem has been initialized correctly + * passes it to *fs + * + * Upon successful return, the filesystem has to be re-locked with epic_fs_unlock_global + * In case of error, the filesystem will be left in a locked state. + */ +bool efs_lock_global(EpicFileSystem** fs, int* ec); +void efs_unlock_global(EpicFileSystem* fs); + +#endif// EPICARCIUM_FS_INTERNAL_H_INCLUDED diff --git a/epicardium/meson.build b/epicardium/meson.build index 9b3880a81e8dcf3ea17ef76411328cc54a2f15f1..b014b421ccb500d7b5922f86df33dbd90aa293e6 100644 --- a/epicardium/meson.build +++ b/epicardium/meson.build @@ -74,6 +74,7 @@ elf = executable( 'cdcacm.c', 'main.c', 'support.c', + 'fs/fileops.c', module_sources, l0der_sources, ble_sources, diff --git a/epicardium/modules/filesystem.h b/epicardium/modules/filesystem.h index cf00968f52e1217946ccd6c184742b4c29a68a3e..7a638d5ab4a87d39fe5b3bd4edd5b3c1901dc194 100644 --- a/epicardium/modules/filesystem.h +++ b/epicardium/modules/filesystem.h @@ -6,18 +6,6 @@ #include <stdbool.h> #include "epicardium.h" -/* Number of bits to use for indexing into our internal pool of files/directories - * This indirectly specifies the size of the pool as 1^EPIC_FAT_FD_INDEX_BITS - * Increase if number of open file descriptors is not enough, but be aware of - * memory usage of the pool! - */ -#define EPIC_FAT_FD_INDEX_BITS 4 -#define EPIC_FAT_STATIC_SEMAPHORE 1 - -#define EPIC_FAT_MAX_OPENED (1 << (EPIC_FAT_FD_INDEX_BITS)) - -typedef struct EpicFileSystem EpicFileSystem; - /** * module initialization - to be called once at startup before any FreeRTOS tasks * have been started @@ -34,13 +22,4 @@ int fatfs_attach(void); /** close all opened FDs, sync and deinitialize FLASH layer */ void fatfs_detach(void); -/** - * lock global filesystem - * - * Upon successful return, the filesystem has to be re-locked with epic_fs_unlock_global - * In case of error, the filesystem will be left in a locked state. - */ -bool efs_lock_global(EpicFileSystem** fs, int* ec); -void efs_unlock_global(EpicFileSystem* fs); - #endif//EPICARDIUM_MODULE_FILESYSTEM_INCLUDED diff --git a/epicardium/modules/filesystem_fat.c b/epicardium/modules/filesystem_fat.c index f6908812bcc69588224975df7817cd9523211059..82e04e20bc927d3fb647cfb0de8eca01ab98cdf8 100644 --- a/epicardium/modules/filesystem_fat.c +++ b/epicardium/modules/filesystem_fat.c @@ -17,6 +17,7 @@ #include <FreeRTOS.h> #include <semphr.h> +#include "fs/internal.h" #include "modules/filesystem.h" #include "epicardium.h" #include "card10.h" @@ -30,6 +31,7 @@ #endif /* clang-format off */ +#define EPIC_FAT_MAX_OPENED (1 << (EPIC_FAT_FD_INDEX_BITS)) #define EPIC_FAT_FD_GENERATION_BITS (31 - (EPIC_FAT_FD_INDEX_BITS)) #define EPIC_FAT_FD_INDEX_MASK (uint32_t)((1u << EPIC_FAT_FD_INDEX_BITS) - 1) #define EPIC_FAT_FD_INDEX(fd) ((uint32_t)(fd)&EPIC_FAT_FD_INDEX_MASK) @@ -79,16 +81,6 @@ static StaticSemaphore_t s_globalLockBuffer; static SemaphoreHandle_t s_globalLock = NULL; -bool globalLockAccquire() -{ - return (int)(xSemaphoreTake(s_globalLock, FF_FS_TIMEOUT) == pdTRUE); -} - -void globalLockRelease() -{ - xSemaphoreGive(s_globalLock); -} - void fatfs_init() { static volatile bool s_initCalled = false; @@ -168,7 +160,7 @@ void fatfs_detach() } } -const char *f_get_rc_string(FRESULT rc) +static const char *f_get_rc_string(FRESULT rc) { static const TCHAR *rcstrings = _T("OK\0DISK_ERR\0INT_ERR\0NOT_READY\0NO_FILE\0NO_PATH\0INVALID_NAME\0") @@ -186,6 +178,16 @@ const char *f_get_rc_string(FRESULT rc) return p; } +static bool globalLockAccquire() +{ + return (int)(xSemaphoreTake(s_globalLock, FF_FS_TIMEOUT) == pdTRUE); +} + +static void globalLockRelease() +{ + xSemaphoreGive(s_globalLock); +} + bool efs_lock_global(EpicFileSystem **fs, int *rc) { *fs = NULL; @@ -209,7 +211,7 @@ void efs_unlock_global(EpicFileSystem *fs) globalLockRelease(); } -bool efs_get_opened( +static bool efs_get_opened( EpicFileSystem *fs, int fd, enum epic_stat_type expected, diff --git a/epicardium/modules/meson.build b/epicardium/modules/meson.build index 482dd7604623b1d521ccf3f2d2bb8fd7e20ca28a..4e0781b30767d53b881bbb91da1a5356be500acc 100644 --- a/epicardium/modules/meson.build +++ b/epicardium/modules/meson.build @@ -1,7 +1,6 @@ module_sources = files( 'display.c', 'filesystem_fat.c', - 'filesystem_fileops.c', 'leds.c', 'light_sensor.c', 'log.c', diff --git a/epicardium/modules/modules.h b/epicardium/modules/modules.h index 5e140cc6e140d86be50eff90fb2d6afd065cd846..4a7bc2557aea29d2d79a96e0c00cefc786f917f5 100644 --- a/epicardium/modules/modules.h +++ b/epicardium/modules/modules.h @@ -1,6 +1,8 @@ #ifndef MODULES_H #define MODULES_H +#include <stdint.h> + /* ---------- Serial ------------------------------------------------------- */ #define SERIAL_READ_BUFFER_SIZE 128 void vSerialTask(void *pvParameters); diff --git a/lib/ff13/Source/diskio.c b/lib/ff13/Source/diskio.c index eb1ab11d8a1bf8351fde713152f84798cc9c66ba..6b90b70580a6c7de712b726172cf8ed8f861924b 100644 --- a/lib/ff13/Source/diskio.c +++ b/lib/ff13/Source/diskio.c @@ -7,22 +7,22 @@ /* storage control modules to the FatFs module with a defined API. */ /*-----------------------------------------------------------------------*/ +#include "diskio.h" /* FatFs lower layer API */ #include <stdbool.h> -#include "diskio.h" /* FatFs lower layer API */ /* Definitions of physical drive number for each drive */ -#define DEV_FLASH 0 /* Example: Map MMC/SD card to physical drive 1 */ -#define DEV_SD 1 /* Example: Map MMC/SD card to physical drive 1 */ +#define DEV_FLASH 0 /* Example: Map MMC/SD card to physical drive 1 */ +#define DEV_SD 1 /* Example: Map MMC/SD card to physical drive 1 */ -#define SDHC 0 +#define SDHC 0 -#define SECTOR_SIZE 512UL +#define SECTOR_SIZE 512UL /*local vaiables*/ static uint8_t rtc_en; static bool s_diskio_initialized = false; -#if SDHC //TODO: implement deinitialization with SDHC as well +#if SDHC /* # of times to check for a card, should be > 1 to detect both SD and MMC */ #define INIT_CARD_RETRIES 10 @@ -40,8 +40,8 @@ extern int mx25_init(void); extern int mx25_start(void); extern int mx25_stop(void); extern uint32_t mx25_size(void); -extern int mx25_read(uint32_t lba, uint8_t *buffer); -extern int mx25_write(uint32_t lba, uint8_t *buffer); +extern int mx25_read(uint32_t lba, uint8_t* buffer); +extern int mx25_write(uint32_t lba, uint8_t* buffer); extern int mx25_sync(void); extern int mx25_ready(void); @@ -49,8 +49,15 @@ extern int mx25_ready(void); /* Get Drive Status */ /*-----------------------------------------------------------------------*/ -DSTATUS disk_status(BYTE pdrv /* Physical drive nmuber to identify the drive */ -) { +DSTATUS disk_status ( + BYTE pdrv /* Physical drive nmuber to identify the drive */ +) +{ +#if 0 + #define STA_NOINIT 0x01 /* Drive not initialized */ + #define STA_NODISK 0x02 /* No medium in the drive */ + #define STA_PROTECT 0x04 /* Write protected */ +#endif DSTATUS status = 0; if (!s_diskio_initialized) { @@ -62,61 +69,63 @@ DSTATUS disk_status(BYTE pdrv /* Physical drive nmuber to identify the drive */ } #if SDHC - if (pdrv == 1) { - if (!SDHC_Card_Inserted()) { - init_done = 0; - status = STA_NOINIT | STA_NODISK; - } - } + if(pdrv == 1) { + if (!SDHC_Card_Inserted()) { + init_done = 0; + status = STA_NOINIT | STA_NODISK; + } + } #endif - return status; + return status; } + + /*-----------------------------------------------------------------------*/ /* Inidialize a Drive */ /*-----------------------------------------------------------------------*/ -DSTATUS -disk_initialize(BYTE pdrv /* Physical drive nmuber to identify the drive */ -) { - DSTATUS status = STA_NOINIT; +DSTATUS disk_initialize ( + BYTE pdrv /* Physical drive nmuber to identify the drive */ +) +{ + DSTATUS status = STA_NOINIT; rtc_en = 0; s_diskio_initialized = true; #if (FF_FS_NORTC == 0) - //Initialize RTC - if (MXC_RTC->cn & MXC_F_RTC_CN_WE) { - rtc_en = 1; - } else { - start_time_sec = (FF_NORTC_YEAR - 1980) * SEC_IN_YEAR_AVG; - start_time_sec += FF_NORTC_MON * SEC_IN_MONTH_AVG; - start_time_sec += FF_NORTC_MDAY * SEC_IN_DAY; - if (RTC_init(MXC_RTC, start_time_sec, 0) == E_NO_ERROR) { - rtc_en = 1; - } - } + //Initialize RTC + if (MXC_RTC->cn & MXC_F_RTC_CN_WE) { + rtc_en = 1; + } else { + start_time_sec = (FF_NORTC_YEAR-1980)*SEC_IN_YEAR_AVG; + start_time_sec += FF_NORTC_MON*SEC_IN_MONTH_AVG; + start_time_sec += FF_NORTC_MDAY*SEC_IN_DAY; + if(RTC_init(MXC_RTC, start_time_sec, 0) == E_NO_ERROR) { + rtc_en = 1; + } + } #endif - if (pdrv == 0) { - if (mx25_start() == 0) { - status = RES_OK; - } - } + if(pdrv == 0) { + if(mx25_start() == 0) { + status = RES_OK; + } + } #if SDHC - if (pdrv == 1) { - if (SDHC_Card_Inserted() && - (SDHC_Lib_InitCard(INIT_CARD_RETRIES) == E_NO_ERROR)) { - /* Card initialized and ready for work */ - init_done = 1; - status = 0; - } else { - status = STA_NOINIT; - } - } + if(pdrv == 1) { + if (SDHC_Card_Inserted() && (SDHC_Lib_InitCard(INIT_CARD_RETRIES) == E_NO_ERROR)) { + /* Card initialized and ready for work */ + init_done = 1; + status = 0; + } else { + status = STA_NOINIT; + } + } #endif - return status; + return status; } void disk_deinitialize() @@ -132,245 +141,240 @@ void disk_deinitialize() /* Read Sector(s) */ /*-----------------------------------------------------------------------*/ -DRESULT disk_read( - BYTE pdrv, /* Physical drive nmuber to identify the drive */ - BYTE *buff, /* Data buffer to store read data */ - DWORD sector, /* Start sector in LBA */ - UINT count /* Number of sectors to read */ -) { - DRESULT status = RES_ERROR; - - if (!s_diskio_initialized) { - status = STA_NOINIT | STA_NODISK; - } else if (pdrv == 0) { - int sector_offset; - status = RES_OK; - for (sector_offset = 0; sector_offset < count; - sector_offset++) { - if (mx25_read( - sector + sector_offset, - (uint8_t *)buff + - SECTOR_SIZE * sector_offset) == 1) { - status = RES_ERROR; - break; - } - } - } +DRESULT disk_read ( + BYTE pdrv, /* Physical drive nmuber to identify the drive */ + BYTE *buff, /* Data buffer to store read data */ + DWORD sector, /* Start sector in LBA */ + UINT count /* Number of sectors to read */ +) +{ + DRESULT status = RES_ERROR; + + if (!s_diskio_initialized) { + status = STA_NOINIT | STA_NODISK; + } else if (pdrv == 0) { + int sector_offset; + status = RES_OK; + for(sector_offset = 0; sector_offset < count; sector_offset++) { + if(mx25_read(sector + sector_offset, (uint8_t*)buff + SECTOR_SIZE * sector_offset) == 1) { + status = RES_ERROR; + break; + } + } + } #if SDHC - if (pdrv == 1) { - if (SDHC_Lib_Read(buff, sector, count, SDHC_LIB_SINGLE_DATA) == - E_NO_ERROR) { - status = RES_OK; - } - } + if(pdrv == 1) { + if (SDHC_Lib_Read(buff, sector, count, SDHC_LIB_SINGLE_DATA) == E_NO_ERROR) { + status = RES_OK; + } + } #endif - return status; + return status; } + + /*-----------------------------------------------------------------------*/ /* Write Sector(s) */ /*-----------------------------------------------------------------------*/ -DRESULT disk_write( - BYTE pdrv, /* Physical drive nmuber to identify the drive */ - const BYTE *buff, /* Data to be written */ - DWORD sector, /* Start sector in LBA */ - UINT count /* Number of sectors to write */ -) { - DRESULT status = RES_ERROR; - - if (!s_diskio_initialized) { - status = STA_NOINIT | STA_NODISK; - } else if (pdrv == 0) { - int sector_offset; - status = RES_OK; - for (sector_offset = 0; sector_offset < count; - sector_offset++) { - if (mx25_write( - sector + sector_offset, - (uint8_t *)buff + - SECTOR_SIZE * sector_offset) == 1) { - status = RES_ERROR; - break; - } - } - } +DRESULT disk_write ( + BYTE pdrv, /* Physical drive nmuber to identify the drive */ + const BYTE *buff, /* Data to be written */ + DWORD sector, /* Start sector in LBA */ + UINT count /* Number of sectors to write */ +) +{ + DRESULT status = RES_ERROR; + + if (!s_diskio_initialized) { + status = STA_NOINIT | STA_NODISK; + } else if (pdrv == 0) { + int sector_offset; + status = RES_OK; + for(sector_offset = 0; sector_offset < count; sector_offset++) { + if(mx25_write(sector + sector_offset, (uint8_t*)buff + SECTOR_SIZE * sector_offset) == 1) { + status = RES_ERROR; + break; + } + } + } #if SDHC - if (pdrv == 1) { - if (SDHC_Lib_Write( - sector, (void *)buff, count, SDHC_LIB_SINGLE_DATA) != - E_NO_ERROR) { - status = RES_ERROR; - } else { - status = RES_OK; - } - } + if(pdrv == 1) { + if (SDHC_Lib_Write(sector, (void *)buff, count, SDHC_LIB_SINGLE_DATA) != E_NO_ERROR) { + status = RES_ERROR; + } else { + status = RES_OK; + } + } #endif - return status; + return status; } + + /*-----------------------------------------------------------------------*/ /* Miscellaneous Functions */ /*-----------------------------------------------------------------------*/ -DRESULT disk_ioctl( - BYTE pdrv, /* Physical drive nmuber (0..) */ - BYTE cmd, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) { - DRESULT status = RES_PARERR; - - if (!s_diskio_initialized) { - status = STA_NOINIT | STA_NODISK; - } else if (pdrv == 0) { - switch (cmd) { - case CTRL_SYNC: - /* Mandatory */ - status = mx25_sync(); - break; - case GET_SECTOR_COUNT: - /* Mandatory */ - *((DWORD *)buff) = mx25_size() / SECTOR_SIZE; - status = RES_OK; - break; - case GET_BLOCK_SIZE: - /* Mandatory */ - *((DWORD *)buff) = SECTOR_SIZE; - status = RES_OK; - break; - default: - status = RES_PARERR; - break; - } - } +DRESULT disk_ioctl ( + BYTE pdrv, /* Physical drive nmuber (0..) */ + BYTE cmd, /* Control code */ + void *buff /* Buffer to send/receive control data */ +) +{ + DRESULT status = RES_PARERR; + + if (!s_diskio_initialized) { + status = STA_NOINIT | STA_NODISK; + } else if (pdrv == 0) { + switch(cmd) { + case CTRL_SYNC: + /* Mandatory */ + status = mx25_sync(); + break; + case GET_SECTOR_COUNT: + /* Mandatory */ + *((DWORD *)buff) = mx25_size() / SECTOR_SIZE; + status = RES_OK; + break; + case GET_BLOCK_SIZE: + /* Mandatory */ + *((DWORD *)buff) = SECTOR_SIZE; + status = RES_OK; + break; + default: + status = RES_PARERR; + break; + } + } #if SDHC - if (pdrv == 1) { - switch (cmd) { - case CTRL_SYNC: - /* Mandatory */ - status = ctrl_sync(buff); - break; - case GET_SECTOR_COUNT: - /* Mandatory */ - status = get_sector_count(buff); - break; - case GET_BLOCK_SIZE: - /* Mandatory */ - status = get_block_size(buff); - break; - case MMC_GET_CSD: - /* Optional */ - status = mmc_get_csd(buff); - break; - default: - status = RES_PARERR; - break; - } - } + if(pdrv == 1) { + switch(cmd) { + case CTRL_SYNC: + /* Mandatory */ + status = ctrl_sync(buff); + break; + case GET_SECTOR_COUNT: + /* Mandatory */ + status = get_sector_count(buff); + break; + case GET_BLOCK_SIZE: + /* Mandatory */ + status = get_block_size(buff); + break; + case MMC_GET_CSD: + /* Optional */ + status = mmc_get_csd(buff); + break; + default: + status = RES_PARERR; + break; + } + } #endif - return status; + return status; } -DWORD get_fattime(void) -{ - if (rtc_en) { - DWORD result; - uint32_t seconds; - uint8_t year, month, day, hour, minute, half_seconds; - - //Convert RTC Seconds to time - seconds = MXC_RTC->sec + (FF_RTC_EPOCH_DELTA); - year = seconds / SEC_IN_YEAR_AVG; //year from epoch - seconds = seconds % SEC_IN_YEAR_AVG; //seconds from Jan 1, $year - month = seconds / SEC_IN_MONTH_AVG; - seconds = seconds % SEC_IN_MONTH_AVG; - day = seconds / SEC_IN_DAY; //hours from 12:00am - seconds = seconds % SEC_IN_DAY; - hour = seconds / SEC_IN_HOUR; - seconds = seconds % SEC_IN_HOUR; - minute = seconds / SEC_IN_MINUTE; - seconds = seconds % SEC_IN_MINUTE; - half_seconds = seconds * 2; - - /* Mask bits for inclusion in result */ - year &= 0x7F; - month &= 0x0F; - day &= 0x1F; - hour &= 0x1F; - minute &= 0x3F; - half_seconds &= 0x1F; - - /* Add fields into 32bit result */ - result = year << 25; - result |= month << 21; - result |= day << 16; - result |= hour << 11; - result |= minute << 5; - result |= half_seconds; - return result; - } else { - return RES_NOTRDY; - } +DWORD get_fattime(void) { + if(rtc_en) { + DWORD result; + uint32_t seconds; + uint8_t year, month, day, hour, minute, half_seconds; + + //Convert RTC Seconds to time + seconds = MXC_RTC->sec + (FF_RTC_EPOCH_DELTA); + year = seconds/SEC_IN_YEAR_AVG; //year from epoch + seconds = seconds%SEC_IN_YEAR_AVG; //seconds from Jan 1, $year + month = seconds/SEC_IN_MONTH_AVG; + seconds = seconds%SEC_IN_MONTH_AVG; + day = seconds/SEC_IN_DAY; //hours from 12:00am + seconds = seconds%SEC_IN_DAY; + hour = seconds/SEC_IN_HOUR; + seconds = seconds%SEC_IN_HOUR; + minute = seconds/SEC_IN_MINUTE; + seconds = seconds%SEC_IN_MINUTE; + half_seconds = seconds*2; + + /* Mask bits for inclusion in result */ + year &= 0x7F; + month &= 0x0F; + day &= 0x1F; + hour &= 0x1F; + minute &= 0x3F; + half_seconds &= 0x1F; + + /* Add fields into 32bit result */ + result = year<<25; + result |= month<<21; + result |= day<<16; + result |= hour<<11; + result |= minute<<5; + result |= half_seconds; + return result; + } + else { + return RES_NOTRDY; + } } #if SDHC static DRESULT ctrl_sync(void *buff) { - return RES_OK; + return RES_OK; } static DRESULT get_sector_count(void *buff) { - DRESULT status = RES_ERROR; + DRESULT status = RES_ERROR; - mxc_sdhc_csd_regs_t csd; + mxc_sdhc_csd_regs_t csd; - if (init_done) { - if (SDHC_Lib_GetCSD(&csd) == E_NO_ERROR) { - *((DWORD *)buff) = - SDHC_Lib_GetCapacity(&csd) / FF_MIN_SS; - status = RES_OK; - } - } else { - status = RES_NOTRDY; - } + if (init_done) { + if (SDHC_Lib_GetCSD(&csd) == E_NO_ERROR) { + *((DWORD *)buff) = SDHC_Lib_GetCapacity(&csd) / FF_MIN_SS; + status = RES_OK; + } + } else { + status = RES_NOTRDY; + } - return status; + return status; } static DRESULT get_block_size(void *buff) { - DRESULT status = RES_ERROR; - - mxc_sdhc_csd_regs_t csd; - if (init_done) { - if (SDHC_Lib_GetCSD(&csd) == E_NO_ERROR) { - *((DWORD *)buff) = SDHC_Lib_GetBlockSize(&csd); - status = RES_OK; - } - } else { - status = RES_NOTRDY; - } - - return status; + DRESULT status = RES_ERROR; + + mxc_sdhc_csd_regs_t csd; + if (init_done) { + if (SDHC_Lib_GetCSD(&csd) == E_NO_ERROR) { + *((DWORD *)buff) = SDHC_Lib_GetBlockSize(&csd); + status = RES_OK; + } + } else { + status = RES_NOTRDY; + } + + return status; } static DRESULT mmc_get_csd(void *buff) { - DRESULT status = RES_ERROR; + DRESULT status = RES_ERROR; - if (init_done) { - if (SDHC_Lib_GetCSD(buff) == E_NO_ERROR) { - status = RES_OK; - } - } else { - status = RES_NOTRDY; - } + if (init_done) { + if (SDHC_Lib_GetCSD(buff) == E_NO_ERROR) { + status = RES_OK; + } + } else { + status = RES_NOTRDY; + } - return status; + return status; } #endif diff --git a/pycardium/modules/qstrdefs.h b/pycardium/modules/qstrdefs.h index 23fb73e5a347c5825f1fa34e4db8119a137e0a7e..dedc57c05513debe59a7441493dcf7d86ec0060d 100644 --- a/pycardium/modules/qstrdefs.h +++ b/pycardium/modules/qstrdefs.h @@ -61,7 +61,6 @@ Q(encoding) Q(file) Q(FileIO) Q(flush) -Q(usbstorage) Q(mode) Q(r) Q(read)