* but not pulled to the shadow buffer.
*/
static uint8_t ao_usb_out_avail;
-static uint8_t ao_usb_running;
+uint8_t ao_usb_running;
static uint8_t ao_usb_configuration;
-static uint8_t ueienx_0;
#define AO_USB_EP0_GOT_RESET 1
#define AO_USB_EP0_GOT_SETUP 2
static void
ao_usb_set_ep0(void)
{
- uint32_t epr;
int e;
ao_usb_sram_addr = 0;
}
ao_usb_set_address(0);
+
+ ao_usb_running = 0;
+
+ /* Reset our internal state
+ */
+
+ ao_usb_ep0_state = AO_USB_EP0_IDLE;
+
+ ao_usb_ep0_in_data = NULL;
+ ao_usb_ep0_in_len = 0;
+
+ ao_usb_ep0_out_data = 0;
+ ao_usb_ep0_out_len = 0;
}
static void
ao_usb_set_configuration(void)
{
- uint32_t epr;
-
debug ("ao_usb_set_configuration\n");
/* Set up the INT end point */
STM_USB_EPR_STAT_RX_DISABLED,
STM_USB_EPR_STAT_TX_NAK);
+ ao_usb_in_flushed = 0;
+ ao_usb_in_pending = 0;
+ ao_wakeup(&ao_usb_in_pending);
+
+ ao_usb_out_avail = 0;
+ ao_usb_configuration = 0;
+
ao_usb_running = 1;
+ ao_wakeup(&ao_usb_running);
}
static uint16_t control_count;
/* Walk through the list of descriptors and find a match
*/
static void
-ao_usb_get_descriptor(uint16_t value)
+ao_usb_get_descriptor(uint16_t value, uint16_t length)
{
const uint8_t *descriptor;
uint8_t type = value >> 8;
len = descriptor[2];
else
len = descriptor[0];
+ if (len > length)
+ len = length;
ao_usb_ep0_in_set(descriptor, len);
break;
}
break;
case AO_USB_REQ_GET_DESCRIPTOR:
debug ("get descriptor %d\n", ao_usb_setup.value);
- ao_usb_get_descriptor(ao_usb_setup.value);
+ ao_usb_get_descriptor(ao_usb_setup.value, ao_usb_setup.length);
break;
case AO_USB_REQ_GET_CONFIGURATION:
debug ("get configuration %d\n", ao_usb_configuration);
if (receive & AO_USB_EP0_GOT_TX_ACK) {
debug ("\tgot tx ack\n");
+#if HAS_FLIGHT && AO_USB_FORCE_IDLE
+ ao_flight_force_idle = 1;
+#endif
/* Wait until the IN packet is received from addr 0
* before assigning our local address
*/