mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-22 01:21:20 +00:00
working on fatfs integration
fix retarget input for lpcxpresso
This commit is contained in:
parent
f820fc5b86
commit
cf65f859be
@ -46,6 +46,7 @@ void SysTick_Handler (void)
|
||||
system_ticks++;
|
||||
tusb_tick_tock(); // TODO temporarily
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
@ -38,11 +38,19 @@
|
||||
|
||||
#include "board.h"
|
||||
|
||||
//-------------------------------------------------------------------- +
|
||||
// LPCXpresso printf redirection +
|
||||
//-------------------------------------------------------------------- +
|
||||
#if CFG_PRINTF_TARGET != PRINTF_TARGET_DEBUG_CONSOLE
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
|
||||
#define retarget_getchar() board_uart_getchar()
|
||||
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
#define retarget_getchar() ITM_ReceiveChar()
|
||||
#else
|
||||
#error Target is not implemented yet
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// LPCXPRESSO / RED SUITE
|
||||
//--------------------------------------------------------------------+
|
||||
#if defined __CODE_RED
|
||||
// Called by bottom level of printf routine within RedLib C library to write
|
||||
// a character. With the default semihosting stub, this would write the character
|
||||
@ -87,33 +95,20 @@ int __sys_write (int iFileHandle, char *pcBuffer, int iLength)
|
||||
// the character from the UART.
|
||||
int __sys_readc (void)
|
||||
{
|
||||
uint8_t c;
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
|
||||
board_uart_recv(&c, 1);
|
||||
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
c = ITM_ReceiveChar();
|
||||
#else
|
||||
#error Thach, did you forget something
|
||||
#endif
|
||||
|
||||
return (int)c;
|
||||
return (int) retarget_getchar();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// KEIL
|
||||
//--------------------------------------------------------------------+
|
||||
#elif defined __CC_ARM // keil
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
|
||||
#define retarget_putc(c) board_uart_send( (uint8_t*) &c, 1);
|
||||
#define retarget_getchar() board_uart_getchar()
|
||||
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
#define retarget_putc(c) ITM_SendChar(c)
|
||||
#define retarget_getchar() ITM_ReceiveChar()
|
||||
#else
|
||||
#error Thach, did you forget something
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
struct __FILE {
|
||||
uint32_t handle;
|
||||
};
|
||||
|
@ -1150,6 +1150,7 @@
|
||||
<option id="gnu.c.compiler.option.misc.other.740032111" name="Other flags" superClass="gnu.c.compiler.option.misc.other" value="-c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections" valueType="string"/>
|
||||
<option id="gnu.c.compiler.option.include.paths.967143576" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/bsp/lpc43xx/CMSIS_LPC43xx_DriverLib/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/fatfs}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lwip/lwip/src/include/ipv4}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lwip/lpclwip}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/lwip/lwip/src/include}""/>
|
||||
|
@ -85,6 +85,11 @@
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/bsp</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>fatfs</name>
|
||||
<type>2</type>
|
||||
<locationURI>PARENT-3-PROJECT_LOC/vendor/fatfs</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>lwip</name>
|
||||
<type>2</type>
|
||||
@ -103,7 +108,7 @@
|
||||
</linkedResources>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1379572492985</id>
|
||||
<id>1380040598945</id>
|
||||
<name></name>
|
||||
<type>26</type>
|
||||
<matcher>
|
||||
@ -112,7 +117,7 @@
|
||||
</matcher>
|
||||
</filter>
|
||||
<filter>
|
||||
<id>1379572492997</id>
|
||||
<id>1380040598970</id>
|
||||
<name></name>
|
||||
<type>26</type>
|
||||
<matcher>
|
||||
|
@ -158,7 +158,24 @@
|
||||
<Name>-O975 -S0 -C0 -FO7 -FD10000000 -FC800 -FN2 -FF0LPC18xx43xx_512_BA -FS01A000000 -FL080000 -FF1LPC18xx43xx_512_BB -FS11B000000 -FL180000)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>131</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>C:\Users\hathach\Dropbox\tinyusb\workspace\tinyusb\demos\host\src\main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
@ -390,7 +407,24 @@
|
||||
<Name>-O975 -S0 -C0 -FO7 -FD10000000 -FC800 -FN2 -FF0LPC18xx43xx_512_BA -FS01A000000 -FL080000 -FF1LPC18xx43xx_512_BB -FS11B000000 -FL180000)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>131</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>C:\Users\hathach\Dropbox\tinyusb\workspace\tinyusb\demos\host\src\main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
@ -434,7 +468,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>app</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -444,10 +478,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<ColumnNumber>1</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>1</TopLine>
|
||||
<CurrentLine>1</CurrentLine>
|
||||
<TopLine>189</TopLine>
|
||||
<CurrentLine>200</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\src\main.c</PathWithFileName>
|
||||
<FilenameWithoutPath>main.c</FilenameWithoutPath>
|
||||
@ -462,7 +496,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>127</TopLine>
|
||||
<TopLine>94</TopLine>
|
||||
<CurrentLine>145</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\src\cdc_serial_app.c</PathWithFileName>
|
||||
@ -478,7 +512,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>169</TopLine>
|
||||
<TopLine>136</TopLine>
|
||||
<CurrentLine>180</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\src\keyboard_app.c</PathWithFileName>
|
||||
@ -524,10 +558,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>20</ColumnNumber>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>1</TopLine>
|
||||
<CurrentLine>6</CurrentLine>
|
||||
<CurrentLine>1</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\src\msc_app.c</PathWithFileName>
|
||||
<FilenameWithoutPath>msc_app.c</FilenameWithoutPath>
|
||||
@ -540,10 +574,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>2</ColumnNumber>
|
||||
<ColumnNumber>30</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>62</TopLine>
|
||||
<CurrentLine>72</CurrentLine>
|
||||
<TopLine>63</TopLine>
|
||||
<CurrentLine>75</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\src\cli.c</PathWithFileName>
|
||||
<FilenameWithoutPath>cli.c</FilenameWithoutPath>
|
||||
@ -580,10 +614,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>2</ColumnNumber>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<TopLine>136</TopLine>
|
||||
<CurrentLine>142</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\boards\embedded_artists\board_ea4357.c</PathWithFileName>
|
||||
<FilenameWithoutPath>board_ea4357.c</FilenameWithoutPath>
|
||||
@ -596,10 +630,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<ColumnNumber>25</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<TopLine>100</TopLine>
|
||||
<CurrentLine>132</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName>
|
||||
<FilenameWithoutPath>printf_retarget.c</FilenameWithoutPath>
|
||||
@ -734,7 +768,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>58</TopLine>
|
||||
<TopLine>25</TopLine>
|
||||
<CurrentLine>76</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\tinyusb\tusb.c</PathWithFileName>
|
||||
@ -798,7 +832,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>494</TopLine>
|
||||
<TopLine>483</TopLine>
|
||||
<CurrentLine>501</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName>
|
||||
@ -814,7 +848,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>598</TopLine>
|
||||
<TopLine>599</TopLine>
|
||||
<CurrentLine>605</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName>
|
||||
@ -974,7 +1008,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>47</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>2</TopLine>
|
||||
<TopLine>3</TopLine>
|
||||
<CurrentLine>13</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\tinyusb\class\msc_host.c</PathWithFileName>
|
||||
@ -998,8 +1032,8 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<TopLine>533</TopLine>
|
||||
<CurrentLine>553</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_uart.c</PathWithFileName>
|
||||
<FilenameWithoutPath>lpc43xx_uart.c</FilenameWithoutPath>
|
||||
@ -1090,7 +1124,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>startup</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -1100,10 +1134,10 @@
|
||||
<FileType>2</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<ColumnNumber>26</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>144</TopLine>
|
||||
<CurrentLine>158</CurrentLine>
|
||||
<TopLine>145</TopLine>
|
||||
<CurrentLine>154</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
|
||||
<FilenameWithoutPath>startup_LPC43xx.s</FilenameWithoutPath>
|
||||
@ -1112,4 +1146,44 @@
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
<GroupName>fatfs</GroupName>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>41</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>56</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>1</TopLine>
|
||||
<CurrentLine>20</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\vendor\fatfs\diskio.c</PathWithFileName>
|
||||
<FilenameWithoutPath>diskio.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>42</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\vendor\fatfs\ff.c</PathWithFileName>
|
||||
<FilenameWithoutPath>ff.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
</ProjectOpt>
|
||||
|
@ -350,7 +350,7 @@
|
||||
<MiscControls>--gnu --c99 --diag_suppress=66</MiscControls>
|
||||
<Define>CORE_M4 MCU=MCU_LPC43XX BOARD=BOARD_EA4357 TUSB_CFG_OS=TUSB_OS_NONE</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\src;..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\inc;..\..\bsp;..\..\..\tinyusb</IncludePath>
|
||||
<IncludePath>..\src;..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\inc;..\..\bsp;..\..\..\tinyusb;..\..\..\vendor\fatfs</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@ -613,6 +613,21 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>fatfs</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>diskio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\vendor\fatfs\diskio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ff.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\vendor\fatfs\ff.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
<Target>
|
||||
@ -1262,6 +1277,21 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>fatfs</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>diskio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\vendor\fatfs\diskio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>ff.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\..\vendor\fatfs\ff.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
</Groups>
|
||||
</Target>
|
||||
</Targets>
|
||||
|
@ -47,6 +47,9 @@
|
||||
|
||||
#if TUSB_CFG_HOST_MSC
|
||||
|
||||
#include "ff.h"
|
||||
#include "diskio.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
@ -54,6 +57,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
static FATFS fatfs[TUSB_CFG_HOST_DEVICE_MAX] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// tinyusb callback (ISR context)
|
||||
@ -62,6 +66,7 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr)
|
||||
{
|
||||
printf("an msc device is mounted\n");
|
||||
|
||||
//------------- Disk Information -------------//
|
||||
// SCSI VendorID[8] & ProductID[16] from Inquiry Command
|
||||
uint8_t const* p_vendor = tusbh_msc_get_vendor_name(dev_addr);
|
||||
uint8_t const* p_product = tusbh_msc_get_product_name(dev_addr);
|
||||
@ -77,6 +82,14 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr)
|
||||
tusbh_msc_get_capacity(dev_addr, &last_lba, &block_size);
|
||||
printf("Disk Size: %d MB\n", (last_lba+1)/ ((1024*1024)/block_size) );
|
||||
printf("LBA 0-0x%X Block Size: %d\n", last_lba, block_size);
|
||||
|
||||
//------------- file system (only 1 LUN support) -------------//
|
||||
DSTATUS stat = disk_initialize(0);
|
||||
|
||||
if ( disk_is_ready(0) )
|
||||
{
|
||||
f_mount(0, &fatfs[dev_addr-1]);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
116
vendor/fatfs/diskio.c
vendored
Normal file
116
vendor/fatfs/diskio.c
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@file diskio.c
|
||||
@author hathach (tinyusb.org)
|
||||
|
||||
@section LICENSE
|
||||
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2013, hathach (tinyusb.org)
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This file is part of the tinyusb stack.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
|
||||
#include "boards/board.h"
|
||||
#include "tusb.h"
|
||||
|
||||
#include "diskio.h"
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INCLUDE
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MACRO CONSTANT TYPEDEF
|
||||
//--------------------------------------------------------------------+
|
||||
static volatile DSTATUS disk_state = STA_NOINIT;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// IMPLEMENTATION
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
//pdrv Specifies the physical drive number.
|
||||
DSTATUS disk_initialize ( BYTE pdrv )
|
||||
{
|
||||
return disk_state;
|
||||
}
|
||||
|
||||
DSTATUS disk_status (BYTE pdrv)
|
||||
{
|
||||
return disk_state;
|
||||
}
|
||||
|
||||
//pdrv
|
||||
// Specifies the physical drive number.
|
||||
//buff
|
||||
// Pointer to the byte array to store the read data. The size of buffer must be in sector size * sector count.
|
||||
//sector
|
||||
// Specifies the start sector number in logical block address (LBA).
|
||||
//count
|
||||
// Specifies number of sectors to read. The value can be 1 to 128. Generally, a multiple sector transfer request
|
||||
// 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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//DWORD get_fattime (void)
|
||||
//{
|
||||
// union {
|
||||
// struct {
|
||||
// DWORD second : 5;
|
||||
// DWORD minute : 6;
|
||||
// DWORD hour : 5;
|
||||
// DWORD day_in_month : 5;
|
||||
// DWORD month : 4;
|
||||
// DWORD year : 7;
|
||||
// };
|
||||
//
|
||||
// DWORD value
|
||||
// } timestamp =
|
||||
// {
|
||||
// .year = (2013-1980),
|
||||
// .month = 10,
|
||||
// .day_in_month = 21,
|
||||
// };
|
||||
//}
|
29
vendor/fatfs/diskio.h
vendored
29
vendor/fatfs/diskio.h
vendored
@ -13,7 +13,7 @@ extern "C" {
|
||||
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
@ -28,17 +28,6 @@ typedef enum {
|
||||
} DRESULT;
|
||||
|
||||
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv);
|
||||
DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
@ -80,6 +69,22 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
#define CT_SDC (CT_SD1|CT_SD2) /* SD */
|
||||
#define CT_BLOCK 0x08 /* Block addressing */
|
||||
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv);
|
||||
DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
static inline bool disk_is_ready(BYTE pdrv);
|
||||
static inline bool disk_is_ready(BYTE pdrv)
|
||||
{
|
||||
return (disk_status(pdrv) & (STA_NOINIT | STA_NODISK)) == 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
2
vendor/fatfs/ffconf.h
vendored
2
vendor/fatfs/ffconf.h
vendored
@ -20,7 +20,7 @@
|
||||
/ data transfer. This reduces memory consumption 512 bytes each file object. */
|
||||
|
||||
|
||||
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
|
||||
#define _FS_READONLY 1 /* 0:Read/Write or 1:Read only */
|
||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
||||
/ f_truncate and useless f_getfree. */
|
||||
|
3
vendor/fatfs/integer.h
vendored
3
vendor/fatfs/integer.h
vendored
@ -17,7 +17,10 @@ typedef int INT;
|
||||
typedef unsigned int UINT;
|
||||
|
||||
/* These types must be 8-bit integer */
|
||||
#ifndef LPC_TYPES_H // avoid typedef redefinition in lpc_types.h
|
||||
typedef char CHAR;
|
||||
#endif
|
||||
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user