diff options
| author | hathach <[email protected]> | 2013-09-25 16:20:38 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-09-25 16:20:38 +0700 |
| commit | 1fee50b9fe64c32f62baa8f96e1fa3687fa7da5d (patch) | |
| tree | def8c534d35e86c914da89517d6ecd3334a51716 /vendor | |
| parent | cf65f859be27d71fb64c1c0bca07585f4df37f75 (diff) | |
add tusbh_msc_status
reanme PRINTF_TARGET_DEBUG_CONSOLE to PRINTF_TARGET_SEMIHOST
add read10 implementation
able to read fat root sector
Diffstat (limited to 'vendor')
| -rw-r--r-- | vendor/fatfs/diskio.c | 24 | ||||
| -rw-r--r-- | vendor/fatfs/diskio.h | 2 |
2 files changed, 21 insertions, 5 deletions
diff --git a/vendor/fatfs/diskio.c b/vendor/fatfs/diskio.c index 85862e47a..17b7d5447 100644 --- a/vendor/fatfs/diskio.c +++ b/vendor/fatfs/diskio.c @@ -36,19 +36,18 @@ */ /**************************************************************************/ -#include "boards/board.h" #include "tusb.h" -#include "diskio.h" - +#if TUSB_CFG_HOST_MSC //--------------------------------------------------------------------+ // INCLUDE //--------------------------------------------------------------------+ +#include "diskio.h" //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ -static volatile DSTATUS disk_state = STA_NOINIT; + volatile DSTATUS disk_state = STA_NOINIT; //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION @@ -70,7 +69,7 @@ DSTATUS disk_status (BYTE pdrv) } //pdrv -// Specifies the physical drive number. +// Specifies the physical drive number --> == dev_addr-1 //buff // Pointer to the byte array to store the read data. The size of buffer must be in sector size * sector count. //sector @@ -80,7 +79,20 @@ DSTATUS disk_status (BYTE pdrv) // must not be split into single sector transactions to the device, or you may not get good read performance. DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count) { + uint8_t usb_addr = pdrv+1; + tusbh_msc_read10(usb_addr, 0, buff, sector, count); +#if TUSB_CFG_OS == TUSB_OS_NONE + while ( tusbh_msc_status(usb_addr) == TUSB_INTERFACE_STATUS_BUSY ) + { + // timeout here + } + return tusbh_msc_status(usb_addr) == TUSB_INTERFACE_STATUS_READY ? RES_OK : RES_ERROR; +#else + #error semaphore instead of blocking +#endif + + return RES_ERROR; } @@ -114,3 +126,5 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff) // .day_in_month = 21, // }; //} + +#endif diff --git a/vendor/fatfs/diskio.h b/vendor/fatfs/diskio.h index 5a69f69d6..9b1f9a28f 100644 --- a/vendor/fatfs/diskio.h +++ b/vendor/fatfs/diskio.h @@ -18,6 +18,8 @@ extern "C" { /* Status of Disk Functions */ typedef BYTE DSTATUS; +extern volatile DSTATUS disk_state; + /* Results of Disk Functions */ typedef enum { RES_OK = 0, /* 0: Successful */ |
