From 62e6e30481dff5e2b7420f7fdb55f5890cb8357a Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Tue, 3 Nov 2015 21:02:28 +0100 Subject: [PATCH] [Horus] Massstorage working now Still a problem on Windows which doesn't want to format the SD card. Also it seems I am not able to rename the card. It reminds me some issue we already had on Taranis. --- radio/src/targets/Horus/diskio.cpp | 4 ++-- radio/src/targets/Horus/usbd_storage_msd.cpp | 13 ++----------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/radio/src/targets/Horus/diskio.cpp b/radio/src/targets/Horus/diskio.cpp index 046e31430..0c5d122e8 100644 --- a/radio/src/targets/Horus/diskio.cpp +++ b/radio/src/targets/Horus/diskio.cpp @@ -259,12 +259,12 @@ DRESULT disk_ioctl ( switch (ctrl) { case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */ - *(DWORD*)buff = SDCardInfo.CardCapacity / BLOCK_SIZE; + *(DWORD*)buff = SDCardInfo.CardCapacity / SDCardInfo.CardBlockSize; res = RES_OK; break; case GET_SECTOR_SIZE : /* Get R/W sector size (WORD) */ - *(WORD*)buff = BLOCK_SIZE; + *(WORD*)buff = SDCardInfo.CardBlockSize; res = RES_OK; break; } diff --git a/radio/src/targets/Horus/usbd_storage_msd.cpp b/radio/src/targets/Horus/usbd_storage_msd.cpp index 62cef6c19..fd3fbcd98 100644 --- a/radio/src/targets/Horus/usbd_storage_msd.cpp +++ b/radio/src/targets/Horus/usbd_storage_msd.cpp @@ -131,17 +131,8 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si if (!SD_CARD_PRESENT()) return -1; - *block_size = BLOCKSIZE; - - static DWORD sector_count = 0; - if (sector_count == 0) { - if (disk_ioctl(0, GET_SECTOR_COUNT, §or_count) != RES_OK) { - sector_count = 0; - return -1; - } - } - - *block_num = sector_count; // sector_count; + *block_size = SDCardInfo.CardBlockSize; + *block_num = (SDCardInfo.CardCapacity / SDCardInfo.CardBlockSize) - 1; return 0; }