house keeping

This commit is contained in:
hathach 2013-09-27 22:38:23 +07:00
parent 26f75d6cac
commit eb1a101667
15 changed files with 96 additions and 183 deletions

View File

@ -59,6 +59,7 @@ void board_init(void)
scu_pinmux(0x2, 3, MD_PUP | MD_EZI, FUNC7); // USB0 VBus Power scu_pinmux(0x2, 3, MD_PUP | MD_EZI, FUNC7); // USB0 VBus Power
// USB1 Power: EA4357 channel A U20 is enabled by SJ5 connected to pad 1-2, no more action required // USB1 Power: EA4357 channel A U20 is enabled by SJ5 connected to pad 1-2, no more action required
// TODO Remove R170, R171, solder a pair of 15K to USB1 D+/D- to test with USB1 Host
// TODO Device only USB0 // TODO Device only USB0
// 1.5Kohm pull-up resistor is needed on the USB DP data signal. GPIO28 (base), P9_5 (LPC4357) controls // 1.5Kohm pull-up resistor is needed on the USB DP data signal. GPIO28 (base), P9_5 (LPC4357) controls
@ -66,18 +67,11 @@ void board_init(void)
// GPIO_SetDir(5, BIT_(18), 1); // output // GPIO_SetDir(5, BIT_(18), 1); // output
// GPIO_ClearValue(5, BIT_(18)); // GPIO_ClearValue(5, BIT_(18));
//------------- LED -------------//
//------------- I2C (required by LED) -------------//
// init I2C and set up MIC2555 to have 15k pull-down on USB1 D+ & D-
I2C_Init(LPC_I2C0, 100000); I2C_Init(LPC_I2C0, 100000);
I2C_Cmd(LPC_I2C0, ENABLE); I2C_Cmd(LPC_I2C0, ENABLE);
//------------- LED -------------//
pca9532_init(); pca9532_init();
// ASSERT_INT(0x058d, mic255_get_vendorid(), (void) 0); // verify vendor id
// ASSERT( mic255_regs_write(6, BIN8(1100)), (void) 0); // pull down D+/D- for host
#if CFG_UART_ENABLE #if CFG_UART_ENABLE
//------------- UART -------------// //------------- UART -------------//
scu_pinmux(BOARD_UART_PIN_PORT, BOARD_UART_PIN_TX, MD_PDN, FUNC1); scu_pinmux(BOARD_UART_PIN_PORT, BOARD_UART_PIN_TX, MD_PDN, FUNC1);
@ -162,59 +156,4 @@ uint8_t board_uart_getchar(void)
// ADC_ChannelCmd(LPC_ADC0, ADC_CH_TRIMPOT, ENABLE); // ADC_ChannelCmd(LPC_ADC0, ADC_CH_TRIMPOT, ENABLE);
//} //}
//------------- MIC2555 external OTG transceiver on USB1 -------------//
// MIC2555 1YML = 0101111, 0YML = 0101101
//#define MIC255_ADDR BIN8(0101111)
//static uint8_t mic255_regs_read(uint8_t regs_addr)
//{
// uint8_t value;
//
// ASSERT( SUCCESS == I2C_MasterTransferData(
// LPC_I2C0,
// & (I2C_M_SETUP_Type)
// {
// .sl_addr7bit = MIC255_ADDR,
// .retransmissions_max = 3,
//
// .tx_data = &regs_addr,
// .tx_length = 1,
//
// .rx_data = &value,
// .rx_length = 1
// },
// I2C_TRANSFER_POLLING), 0xFF);
//
// return value;
//}
//static bool mic255_regs_write(uint8_t regs_addr, uint8_t data)
//{
// uint8_t xfer_data[2] = { regs_addr, data} ;
//
// ASSERT( SUCCESS == I2C_MasterTransferData(
// LPC_I2C0,
// & (I2C_M_SETUP_Type)
// {
// .sl_addr7bit = MIC255_ADDR,
// .retransmissions_max = 3,
//
// .tx_data = xfer_data,
// .tx_length = 2,
// },
// I2C_TRANSFER_POLLING), false);
//
// return true;
//}
//static uint16_t mic255_get_vendorid(void)
//{
// uint8_t vendor_low = mic255_regs_read(0);
// uint8_t vendor_high = mic255_regs_read(1);
//
// return (vendor_high << 8) | vendor_low;
//}
#endif #endif

View File

@ -106,6 +106,7 @@ int __sys_readc (void)
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART #if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
#define retarget_putc(c) board_uart_send( (uint8_t*) &c, 1); #define retarget_putc(c) board_uart_send( (uint8_t*) &c, 1);
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO #elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
volatile int32_t ITM_RxBuffer;
#define retarget_putc(c) ITM_SendChar(c) #define retarget_putc(c) ITM_SendChar(c)
#endif #endif

View File

@ -135,7 +135,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>DLGUARM</Key> <Key>DLGUARM</Key>
<Name></Name> <Name>(106=-1,-1,-1,-1,0)(107=-1,-1,-1,-1,0)</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@ -158,24 +158,7 @@
<Name>-O975 -S0 -C0 -FO7 -FD10000000 -FC800 -FN2 -FF0LPC18xx43xx_512_BA -FS01A000000 -FL080000 -FF1LPC18xx43xx_512_BB -FS11B000000 -FL180000)</Name> <Name>-O975 -S0 -C0 -FO7 -FD10000000 -FC800 -FN2 -FF0LPC18xx43xx_512_BA -FS01A000000 -FL080000 -FF1LPC18xx43xx_512_BB -FS11B000000 -FL180000)</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint> <Breakpoint/>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>353</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\cli.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -387,24 +370,7 @@
<Name>-O975 -S0 -C0 -FO7 -FD10000000 -FC800 -FN2 -FF0LPC18xx43xx_512_BA -FS01A000000 -FL080000 -FF1LPC18xx43xx_512_BB -FS11B000000 -FL180000)</Name> <Name>-O975 -S0 -C0 -FO7 -FD10000000 -FC800 -FN2 -FF0LPC18xx43xx_512_BA -FS01A000000 -FL080000 -FF1LPC18xx43xx_512_BB -FS11B000000 -FL180000)</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint> <Breakpoint/>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>353</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\cli.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -458,10 +424,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>17</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>94</TopLine>
<CurrentLine>1</CurrentLine> <CurrentLine>111</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\main.c</PathWithFileName> <PathWithFileName>..\src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath> <FilenameWithoutPath>main.c</FilenameWithoutPath>
@ -476,7 +442,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>125</TopLine> <TopLine>92</TopLine>
<CurrentLine>145</CurrentLine> <CurrentLine>145</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\cdc_serial_app.c</PathWithFileName> <PathWithFileName>..\src\cdc_serial_app.c</PathWithFileName>
@ -492,8 +458,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>167</TopLine> <TopLine>111</TopLine>
<CurrentLine>180</CurrentLine> <CurrentLine>123</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\keyboard_app.c</PathWithFileName> <PathWithFileName>..\src\keyboard_app.c</PathWithFileName>
<FilenameWithoutPath>keyboard_app.c</FilenameWithoutPath> <FilenameWithoutPath>keyboard_app.c</FilenameWithoutPath>
@ -508,7 +474,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>44</ColumnNumber> <ColumnNumber>44</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>124</TopLine> <TopLine>118</TopLine>
<CurrentLine>127</CurrentLine> <CurrentLine>127</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\mouse_app.c</PathWithFileName> <PathWithFileName>..\src\mouse_app.c</PathWithFileName>
@ -538,10 +504,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>27</ColumnNumber> <ColumnNumber>1</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>121</TopLine>
<CurrentLine>8</CurrentLine> <CurrentLine>150</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\msc_app.c</PathWithFileName> <PathWithFileName>..\src\msc_app.c</PathWithFileName>
<FilenameWithoutPath>msc_app.c</FilenameWithoutPath> <FilenameWithoutPath>msc_app.c</FilenameWithoutPath>
@ -556,7 +522,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>18</ColumnNumber> <ColumnNumber>18</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>4</TopLine> <TopLine>8</TopLine>
<CurrentLine>11</CurrentLine> <CurrentLine>11</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\cli.c</PathWithFileName> <PathWithFileName>..\src\cli.c</PathWithFileName>
@ -594,10 +560,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>78</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>141</TopLine> <TopLine>27</TopLine>
<CurrentLine>142</CurrentLine> <CurrentLine>31</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\boards\embedded_artists\board_ea4357.c</PathWithFileName> <PathWithFileName>..\..\bsp\boards\embedded_artists\board_ea4357.c</PathWithFileName>
<FilenameWithoutPath>board_ea4357.c</FilenameWithoutPath> <FilenameWithoutPath>board_ea4357.c</FilenameWithoutPath>
@ -612,7 +578,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>6</ColumnNumber> <ColumnNumber>6</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>126</TopLine> <TopLine>93</TopLine>
<CurrentLine>135</CurrentLine> <CurrentLine>135</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName> <PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName>
@ -746,10 +712,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>64</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>56</TopLine> <TopLine>23</TopLine>
<CurrentLine>76</CurrentLine> <CurrentLine>33</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\tusb.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\tusb.c</PathWithFileName>
<FilenameWithoutPath>tusb.c</FilenameWithoutPath> <FilenameWithoutPath>tusb.c</FilenameWithoutPath>
@ -810,10 +776,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>61</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>494</TopLine> <TopLine>430</TopLine>
<CurrentLine>501</CurrentLine> <CurrentLine>518</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName>
<FilenameWithoutPath>usbh.c</FilenameWithoutPath> <FilenameWithoutPath>usbh.c</FilenameWithoutPath>
@ -826,10 +792,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>38</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>482</TopLine> <TopLine>1</TopLine>
<CurrentLine>484</CurrentLine> <CurrentLine>5</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName>
<FilenameWithoutPath>ehci.c</FilenameWithoutPath> <FilenameWithoutPath>ehci.c</FilenameWithoutPath>
@ -973,7 +939,7 @@
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>1</TopLine>
<CurrentLine>1</CurrentLine> <CurrentLine>12</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\class\hid_host.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\class\hid_host.c</PathWithFileName>
<FilenameWithoutPath>hid_host.c</FilenameWithoutPath> <FilenameWithoutPath>hid_host.c</FilenameWithoutPath>
@ -986,10 +952,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>1</ColumnNumber> <ColumnNumber>22</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>113</TopLine> <TopLine>59</TopLine>
<CurrentLine>118</CurrentLine> <CurrentLine>64</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\class\msc_host.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\class\msc_host.c</PathWithFileName>
<FilenameWithoutPath>msc_host.c</FilenameWithoutPath> <FilenameWithoutPath>msc_host.c</FilenameWithoutPath>
@ -1090,10 +1056,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>7</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine> <TopLine>777</TopLine>
<CurrentLine>0</CurrentLine> <CurrentLine>782</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_i2c.c</PathWithFileName> <PathWithFileName>..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_i2c.c</PathWithFileName>
<FilenameWithoutPath>lpc43xx_i2c.c</FilenameWithoutPath> <FilenameWithoutPath>lpc43xx_i2c.c</FilenameWithoutPath>
@ -1114,10 +1080,10 @@
<FileType>2</FileType> <FileType>2</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>22</ColumnNumber> <ColumnNumber>54</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>148</TopLine> <TopLine>139</TopLine>
<CurrentLine>151</CurrentLine> <CurrentLine>148</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName> <PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
<FilenameWithoutPath>startup_LPC43xx.s</FilenameWithoutPath> <FilenameWithoutPath>startup_LPC43xx.s</FilenameWithoutPath>
@ -1138,10 +1104,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>20</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>49</TopLine>
<CurrentLine>1</CurrentLine> <CurrentLine>62</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\vendor\fatfs\diskio.c</PathWithFileName> <PathWithFileName>..\..\..\vendor\fatfs\diskio.c</PathWithFileName>
<FilenameWithoutPath>diskio.c</FilenameWithoutPath> <FilenameWithoutPath>diskio.c</FilenameWithoutPath>

View File

@ -161,6 +161,7 @@ void cli_init(void)
{ {
memclr_(cli_buffer, CLI_MAX_BUFFER); memclr_(cli_buffer, CLI_MAX_BUFFER);
f_getlabel(NULL, volume_label, NULL); f_getlabel(NULL, volume_label, NULL);
cli_command_prompt();
} }
void cli_poll(char ch) void cli_poll(char ch)

View File

@ -116,7 +116,6 @@ void os_none_start_scheduler(void)
} }
} }
#endif #endif
volatile int32_t ITM_RxBuffer;
int main(void) int main(void)
{ {

View File

@ -106,7 +106,6 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr)
f_chdir("/"); // root as current dir f_chdir("/"); // root as current dir
cli_init(); cli_init();
cli_command_prompt();
} }
} }

View File

@ -73,8 +73,8 @@
//------------- CLASS -------------// //------------- CLASS -------------//
#define TUSB_CFG_HOST_HUB 0 #define TUSB_CFG_HOST_HUB 0
#define TUSB_CFG_HOST_HID_KEYBOARD 0 #define TUSB_CFG_HOST_HID_KEYBOARD 1
#define TUSB_CFG_HOST_HID_MOUSE 0 #define TUSB_CFG_HOST_HID_MOUSE 1
#define TUSB_CFG_HOST_HID_GENERIC 0 #define TUSB_CFG_HOST_HID_GENERIC 0
#define TUSB_CFG_HOST_MSC 1 #define TUSB_CFG_HOST_MSC 1
#define TUSB_CFG_HOST_CDC 0 #define TUSB_CFG_HOST_CDC 0
@ -96,7 +96,7 @@
// COMMON CONFIGURATION // COMMON CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_DEBUG 2 #define TUSB_CFG_DEBUG 3
//#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build //#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build
//#define TUSB_CFG_OS_TASK_PRIO //#define TUSB_CFG_OS_TASK_PRIO

View File

@ -280,10 +280,8 @@ void test_control_xfer_error_stall(void)
TEST_ASSERT_TRUE( p_control_qhd->qtd_overlay.alternate.terminate); TEST_ASSERT_TRUE( p_control_qhd->qtd_overlay.alternate.terminate);
TEST_ASSERT_FALSE( p_control_qhd->qtd_overlay.halted); TEST_ASSERT_FALSE( p_control_qhd->qtd_overlay.halted);
#if 0 // no neeed
TEST_ASSERT_FALSE( p_setup->used ); TEST_ASSERT_FALSE( p_setup->used );
TEST_ASSERT_FALSE( p_data->used ); TEST_ASSERT_FALSE( p_data->used );
TEST_ASSERT_FALSE( p_status->used ); TEST_ASSERT_FALSE( p_status->used );
#endif
} }

View File

@ -84,7 +84,7 @@ enum {
HID_REQUEST_CONTROL_SET_PROTOCOL = 0x0b HID_REQUEST_CONTROL_SET_PROTOCOL = 0x0b
}; };
typedef ATTR_PREPACKED struct ATTR_PACKED { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */ uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */
uint8_t bDescriptorType; /**< Constant name specifying type of HID descriptor. */ uint8_t bDescriptorType; /**< Constant name specifying type of HID descriptor. */

View File

@ -74,19 +74,33 @@ bool tusbh_msc_is_mounted(uint8_t dev_addr)
msch_data[dev_addr-1].is_initialized; msch_data[dev_addr-1].is_initialized;
} }
bool tusbh_msc_is_busy(uint8_t dev_addr)
{
return msch_data[dev_addr-1].is_initialized &&
hcd_pipe_is_busy(msch_data[dev_addr-1].bulk_in);
}
bool tusbh_msc_is_failed(uint8_t dev_addr)
{
return msch_data[dev_addr-1].is_initialized &&
hcd_pipe_is_error(msch_data[dev_addr-1].bulk_in);
}
// TODO tusbh_msc_is_stalled
uint8_t const* tusbh_msc_get_vendor_name(uint8_t dev_addr) uint8_t const* tusbh_msc_get_vendor_name(uint8_t dev_addr)
{ {
return tusbh_msc_is_mounted(dev_addr) ? msch_data[dev_addr-1].vendor_id : NULL; return msch_data[dev_addr-1].is_initialized ? msch_data[dev_addr-1].vendor_id : NULL;
} }
uint8_t const* tusbh_msc_get_product_name(uint8_t dev_addr) uint8_t const* tusbh_msc_get_product_name(uint8_t dev_addr)
{ {
return tusbh_msc_is_mounted(dev_addr) ? msch_data[dev_addr-1].product_id : NULL; return msch_data[dev_addr-1].is_initialized ? msch_data[dev_addr-1].product_id : NULL;
} }
tusb_error_t tusbh_msc_get_capacity(uint8_t dev_addr, uint32_t* p_last_lba, uint32_t* p_block_size) tusb_error_t tusbh_msc_get_capacity(uint8_t dev_addr, uint32_t* p_last_lba, uint32_t* p_block_size)
{ {
if ( !tusbh_msc_is_mounted(dev_addr) ) return TUSB_ERROR_MSCH_DEVICE_NOT_MOUNTED; if ( !msch_data[dev_addr-1].is_initialized ) return TUSB_ERROR_MSCH_DEVICE_NOT_MOUNTED;
ASSERT(p_last_lba != NULL && p_block_size != NULL, TUSB_ERROR_INVALID_PARA); ASSERT(p_last_lba != NULL && p_block_size != NULL, TUSB_ERROR_INVALID_PARA);
(*p_last_lba) = msch_data[dev_addr-1].last_lba; (*p_last_lba) = msch_data[dev_addr-1].last_lba;
@ -95,16 +109,6 @@ tusb_error_t tusbh_msc_get_capacity(uint8_t dev_addr, uint32_t* p_last_lba, uint
return TUSB_ERROR_NONE; return TUSB_ERROR_NONE;
} }
tusb_interface_status_t tusbh_msc_status(uint8_t dev_addr)
{
if ( !tusbh_msc_is_mounted(dev_addr) ) return TUSB_INTERFACE_STATUS_INVALID_PARA;
if ( hcd_pipe_is_busy(msch_data[dev_addr-1].bulk_in) ) return TUSB_INTERFACE_STATUS_BUSY;
if ( hcd_pipe_is_stalled(msch_data[dev_addr-1].bulk_in) ) return TUSB_INTERFACE_STATUS_ERROR;
return TUSB_INTERFACE_STATUS_READY;
}
static inline void msc_cbw_add_signature(msc_cmd_block_wrapper_t *p_cbw, uint8_t lun) ATTR_ALWAYS_INLINE; static inline void msc_cbw_add_signature(msc_cmd_block_wrapper_t *p_cbw, uint8_t lun) ATTR_ALWAYS_INLINE;
static inline void msc_cbw_add_signature(msc_cmd_block_wrapper_t *p_cbw, uint8_t lun) static inline void msc_cbw_add_signature(msc_cmd_block_wrapper_t *p_cbw, uint8_t lun)
{ {

View File

@ -59,7 +59,9 @@
// MASS STORAGE Application API // MASS STORAGE Application API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
bool tusbh_msc_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; bool tusbh_msc_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
tusb_interface_status_t tusbh_msc_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT; bool tusbh_msc_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
bool tusbh_msc_is_failed(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
uint8_t const* tusbh_msc_get_vendor_name(uint8_t dev_addr); uint8_t const* tusbh_msc_get_vendor_name(uint8_t dev_addr);
uint8_t const* tusbh_msc_get_product_name(uint8_t dev_addr); uint8_t const* tusbh_msc_get_product_name(uint8_t dev_addr);
tusb_error_t tusbh_msc_get_capacity(uint8_t dev_addr, uint32_t* p_last_lba, uint32_t* p_block_size); tusb_error_t tusbh_msc_get_capacity(uint8_t dev_addr, uint32_t* p_last_lba, uint32_t* p_block_size);
@ -95,7 +97,7 @@ typedef struct {
uint16_t block_size; uint16_t block_size;
uint32_t last_lba; // last logical block address uint32_t last_lba; // last logical block address
bool is_initialized; volatile bool is_initialized;
uint8_t vendor_id[8]; uint8_t vendor_id[8];
uint8_t product_id[16]; uint8_t product_id[16];

View File

@ -61,7 +61,7 @@
// STANDARD DESCRIPTORS // STANDARD DESCRIPTORS
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
/// USB Standard Device Descriptor (section 9.6.1, table 9-8) /// USB Standard Device Descriptor (section 9.6.1, table 9-8)
typedef ATTR_PREPACKED struct ATTR_PACKED { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< DEVICE Descriptor Type. uint8_t bDescriptorType ; ///< DEVICE Descriptor Type.
uint16_t bcdUSB ; ///< BUSB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H). This field identifies the release of the USB Specification with which the device and its descriptors are compliant. uint16_t bcdUSB ; ///< BUSB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H). This field identifies the release of the USB Specification with which the device and its descriptors are compliant.
@ -82,7 +82,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED {
} tusb_descriptor_device_t; } tusb_descriptor_device_t;
/// USB Standard Configuration Descriptor (section 9.6.1 table 9-10) */ /// USB Standard Configuration Descriptor (section 9.6.1 table 9-10) */
typedef ATTR_PREPACKED struct ATTR_PACKED { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bLength ; ///< Size of this descriptor in bytes
uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type
uint16_t wTotalLength ; ///< Total length of data returned for this configuration. Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or vendor-specific) returned for this configuration. uint16_t wTotalLength ; ///< Total length of data returned for this configuration. Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or vendor-specific) returned for this configuration.
@ -95,7 +95,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED {
} tusb_descriptor_configuration_t; } tusb_descriptor_configuration_t;
/// USB Standard Interface Descriptor (section 9.6.1 table 9-12) /// USB Standard Interface Descriptor (section 9.6.1 table 9-12)
typedef ATTR_PREPACKED struct ATTR_PACKED { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bLength ; ///< Size of this descriptor in bytes
uint8_t bDescriptorType ; ///< INTERFACE Descriptor Type uint8_t bDescriptorType ; ///< INTERFACE Descriptor Type
@ -109,13 +109,13 @@ typedef ATTR_PREPACKED struct ATTR_PACKED {
} tusb_descriptor_interface_t; } tusb_descriptor_interface_t;
/// USB Standard Endpoint Descriptor (section 9.6.1 table 9-13) /// USB Standard Endpoint Descriptor (section 9.6.1 table 9-13)
typedef ATTR_PREPACKED struct ATTR_PACKED { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bLength ; ///< Size of this descriptor in bytes
uint8_t bDescriptorType ; ///< ENDPOINT Descriptor Type uint8_t bDescriptorType ; ///< ENDPOINT Descriptor Type
uint8_t bEndpointAddress ; ///< The address of the endpoint on the USB device described by this descriptor. The address is encoded as follows: \n Bit 3...0: The endpoint number \n Bit 6...4: Reserved, reset to zero \n Bit 7: Direction, ignored for control endpoints 0 = OUT endpoint 1 = IN endpoint. uint8_t bEndpointAddress ; ///< The address of the endpoint on the USB device described by this descriptor. The address is encoded as follows: \n Bit 3...0: The endpoint number \n Bit 6...4: Reserved, reset to zero \n Bit 7: Direction, ignored for control endpoints 0 = OUT endpoint 1 = IN endpoint.
ATTR_PREPACKED struct ATTR_PACKED { ATTR_PACKED_STRUCT(struct) {
uint8_t xfer : 2; uint8_t xfer : 2;
uint8_t sync : 2; uint8_t sync : 2;
uint8_t usage : 2; uint8_t usage : 2;
@ -132,7 +132,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED {
} tusb_descriptor_endpoint_t; } tusb_descriptor_endpoint_t;
/// USB Other Speed Configuration Descriptor (section 9.6.1 table 9-11) /// USB Other Speed Configuration Descriptor (section 9.6.1 table 9-11)
typedef ATTR_PREPACKED struct ATTR_PACKED { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of descriptor uint8_t bLength ; ///< Size of descriptor
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
uint16_t wTotalLength ; ///< Total length of data returned uint16_t wTotalLength ; ///< Total length of data returned
@ -145,7 +145,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED {
} tusb_descriptor_other_speed_t; } tusb_descriptor_other_speed_t;
/// USB Device Qualifier Descriptor (section 9.6.1 table 9-9) /// USB Device Qualifier Descriptor (section 9.6.1 table 9-9)
typedef ATTR_PREPACKED struct ATTR_PACKED { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of descriptor uint8_t bLength ; ///< Size of descriptor
uint8_t bDescriptorType ; ///< Device Qualifier Type uint8_t bDescriptorType ; ///< Device Qualifier Type
uint16_t bcdUSB ; ///< USB specification version number (e.g., 0200H for V2.00) uint16_t bcdUSB ; ///< USB specification version number (e.g., 0200H for V2.00)
@ -159,7 +159,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED {
} tusb_descriptor_device_qualifier_t; } tusb_descriptor_device_qualifier_t;
/// USB Interface Association Descriptor (IAD ECN) /// USB Interface Association Descriptor (IAD ECN)
typedef ATTR_PREPACKED struct ATTR_PACKED typedef ATTR_PACKED_STRUCT(struct)
{ {
uint8_t bLength ; ///< Size of descriptor uint8_t bLength ; ///< Size of descriptor
uint8_t bDescriptorType ; ///< Other_speed_Configuration Type uint8_t bDescriptorType ; ///< Other_speed_Configuration Type
@ -175,7 +175,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED
} tusb_descriptor_interface_association_t; } tusb_descriptor_interface_association_t;
/// USB Header Descriptor /// USB Header Descriptor
typedef ATTR_PREPACKED struct ATTR_PACKED typedef ATTR_PACKED_STRUCT(struct)
{ {
uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bLength ; ///< Size of this descriptor in bytes
uint8_t bDescriptorType ; ///< Descriptor Type uint8_t bDescriptorType ; ///< Descriptor Type

View File

@ -430,7 +430,7 @@ tusb_error_t hcd_pipe_queue_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint
tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete) tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete)
{ {
hcd_pipe_queue_xfer(pipe_hdl, buffer, total_bytes); ASSERT_STATUS ( hcd_pipe_queue_xfer(pipe_hdl, buffer, total_bytes) );
ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle(pipe_hdl); ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle(pipe_hdl);
@ -481,8 +481,14 @@ bool hcd_pipe_is_busy(pipe_handle_t pipe_hdl)
return !p_qhd->qtd_overlay.halted && (p_qhd->p_qtd_list_head != NULL); return !p_qhd->qtd_overlay.halted && (p_qhd->p_qtd_list_head != NULL);
} }
bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl) bool hcd_pipe_is_error(pipe_handle_t pipe_hdl)
{ {
ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle( pipe_hdl );
return p_qhd->qtd_overlay.halted;
}
bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl)
{ // TODO to be remove
ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle( pipe_hdl ); ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle( pipe_hdl );
return (p_qhd->p_qtd_list_head == NULL); return (p_qhd->p_qtd_list_head == NULL);
} }
@ -679,13 +685,11 @@ static void qhd_xfer_error_isr(ehci_qhd_t * p_qhd)
p_qhd->qtd_overlay.alternate.terminate = 1; p_qhd->qtd_overlay.alternate.terminate = 1;
p_qhd->qtd_overlay.halted = 0; p_qhd->qtd_overlay.halted = 0;
#if 0 // no need to mark control qtds as not used ehci_qtd_t *p_setup = get_control_qtds(p_qhd->device_address);
ehci_qtd_t *p_setup = get_control_qtds(dev_addr);
ehci_qtd_t *p_data = p_setup + 1; ehci_qtd_t *p_data = p_setup + 1;
ehci_qtd_t *p_status = p_setup + 2; ehci_qtd_t *p_status = p_setup + 2;
p_setup->used = p_data->used = p_status = 0; p_setup->used = p_data->used = p_status->used = 0;
#endif
} }
// call USBH callback // call USBH callback

View File

@ -203,8 +203,8 @@ typedef struct {
uint8_t interval_ms; // polling interval in frames (or milisecond) uint8_t interval_ms; // polling interval in frames (or milisecond)
uint8_t reserved; uint8_t reserved;
ehci_qtd_t *p_qtd_list_head; // head of the scheduled TD list ehci_qtd_t * volatile p_qtd_list_head; // head of the scheduled TD list
ehci_qtd_t *p_qtd_list_tail; // tail of the scheduled TD list ehci_qtd_t * volatile p_qtd_list_tail; // tail of the scheduled TD list
}ATTR_ALIGNED(32) ehci_qhd_t; }ATTR_ALIGNED(32) ehci_qhd_t;
/// Highspeed Isochronous Transfer Descriptor (section 3.3) /// Highspeed Isochronous Transfer Descriptor (section 3.3)

View File

@ -56,14 +56,14 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// IMPLEMENTATION // IMPLEMENTATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
static tusb_error_t wait_for_io_complete(uint8_t usb_addr) static DRESULT wait_for_io_complete(uint8_t usb_addr)
{ {
#if TUSB_CFG_OS == TUSB_OS_NONE #if TUSB_CFG_OS == TUSB_OS_NONE
while ( tusbh_msc_status(usb_addr) == TUSB_INTERFACE_STATUS_BUSY ) while ( tusbh_msc_is_busy(usb_addr) )
{ {
// timeout here // timeout here
} }
return tusbh_msc_status(usb_addr) == TUSB_INTERFACE_STATUS_READY ? RES_OK : RES_ERROR; return tusbh_msc_is_failed(usb_addr) ? RES_ERROR : RES_OK;
#else #else
#error semaphore instead of blocking #error semaphore instead of blocking
#endif #endif