Bug fixes for USB protocol stack.
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2012-06-01 Niibe Yutaka <gniibe@fsij.org>
|
||||
|
||||
USB bug fixes.
|
||||
* src/usb_ctrl.c (gnuk_usb_event): Bug fix for handling
|
||||
USB_EVENT_CONFIG. Do nothing when current_conf == value.
|
||||
* src/usb_lld.c (std_clear_feature): Bug fix. Always clear DTOG.
|
||||
(usb_lld_init): New argument for FEATURE.
|
||||
|
||||
2012-05-31 Niibe Yutaka <gniibe@fsij.org>
|
||||
|
||||
* polarssl-0.14.0/library/rsa.c (rsa_pkcs1_verify): BUF size is
|
||||
|
||||
@@ -389,7 +389,7 @@ main (int argc, char *argv[])
|
||||
|
||||
flash_unlock ();
|
||||
device_initialize_once ();
|
||||
usb_lld_init ();
|
||||
usb_lld_init (Config_Descriptor.Descriptor[7]);
|
||||
random_init ();
|
||||
|
||||
while (1)
|
||||
|
||||
@@ -347,6 +347,7 @@ gnuk_get_descriptor (uint8_t desc_type, uint16_t index, uint16_t value)
|
||||
static int gnuk_usb_event (uint8_t event_type, uint16_t value)
|
||||
{
|
||||
int i;
|
||||
uint8_t current_conf;
|
||||
|
||||
switch (event_type)
|
||||
{
|
||||
@@ -354,7 +355,8 @@ static int gnuk_usb_event (uint8_t event_type, uint16_t value)
|
||||
bDeviceState = ADDRESSED;
|
||||
return USB_SUCCESS;
|
||||
case USB_EVENT_CONFIG:
|
||||
if (usb_lld_current_configuration () == 0)
|
||||
current_conf = usb_lld_current_configuration ();
|
||||
if (current_conf == 0)
|
||||
{
|
||||
if (value != 1)
|
||||
return USB_UNSUPPORT;
|
||||
@@ -365,7 +367,7 @@ static int gnuk_usb_event (uint8_t event_type, uint16_t value)
|
||||
bDeviceState = CONFIGURED;
|
||||
chEvtSignalI (main_thread, LED_STATUS_MODE);
|
||||
}
|
||||
else
|
||||
else if (current_conf != value)
|
||||
{
|
||||
if (value != 0)
|
||||
return USB_UNSUPPORT;
|
||||
@@ -375,6 +377,7 @@ static int gnuk_usb_event (uint8_t event_type, uint16_t value)
|
||||
gnuk_setup_endpoints_for_interface (i, 1);
|
||||
bDeviceState = ADDRESSED;
|
||||
}
|
||||
/* Do nothing when current_conf == value */
|
||||
return USB_SUCCESS;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -358,13 +358,14 @@ static void st103_ep_clear_dtog_tx (uint8_t ep_num)
|
||||
}
|
||||
}
|
||||
|
||||
void usb_lld_init (void)
|
||||
void usb_lld_init (uint8_t feature)
|
||||
{
|
||||
usb_lld_sys_init ();
|
||||
|
||||
dev_p->state = IN_DATA;
|
||||
|
||||
usb_lld_set_configuration (0);
|
||||
usb_lld_set_feature (feature);
|
||||
|
||||
/* Reset USB */
|
||||
st103_set_cntr (CNTR_FRES);
|
||||
@@ -606,22 +607,10 @@ static int std_clear_feature (uint8_t req, uint16_t value,
|
||||
if (status == 0) /* Disabled */
|
||||
return USB_UNSUPPORT;
|
||||
|
||||
if (index & 0x80)
|
||||
{ /* IN endpoint */
|
||||
if (st103_ep_get_tx_status (endpoint) == EP_TX_STALL)
|
||||
{
|
||||
st103_ep_clear_dtog_tx (endpoint);
|
||||
st103_ep_set_tx_status (endpoint, EP_TX_VALID);
|
||||
}
|
||||
}
|
||||
else
|
||||
{ /* OUT endpoint */
|
||||
if (st103_ep_get_rx_status (endpoint) == EP_RX_STALL)
|
||||
{
|
||||
st103_ep_clear_dtog_rx (endpoint);
|
||||
st103_ep_set_rx_status (endpoint, EP_RX_VALID);
|
||||
}
|
||||
}
|
||||
if (index & 0x80) /* IN endpoint */
|
||||
st103_ep_clear_dtog_tx (endpoint);
|
||||
else /* OUT endpoint */
|
||||
st103_ep_clear_dtog_rx (endpoint);
|
||||
|
||||
// event??
|
||||
return USB_SUCCESS;
|
||||
|
||||
@@ -109,7 +109,7 @@ extern uint32_t bDeviceState;
|
||||
|
||||
#define STM32_USB_IRQ_PRIORITY 11
|
||||
|
||||
extern void usb_lld_init (void);
|
||||
extern void usb_lld_init (uint8_t feature);
|
||||
|
||||
extern void usb_lld_to_pmabuf (const void *src, uint16_t addr, size_t n);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user