working on fatfs integration
fix retarget input for lpcxpresso
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
Reference in New Issue
Block a user