Skip to content

Commit

Permalink
avr: Remove some code from USB driver
Browse files Browse the repository at this point in the history
Don't initialize ep0 in/out lens in set_ep0. These values
get set when processing relevant setup packets.

Assign instead of modify registers.

As all bytes sent with ep0_queue_byte were always zero, remove
the ability to send arbitrary bytes.

Signed-off-by: Keith Packard <keithp@keithp.com>
  • Loading branch information
keith-packard committed May 20, 2019
1 parent 2b1470d commit f703e3a
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions avr/ao-usb-avr.c
Expand Up @@ -66,9 +66,7 @@ _ao_usb_set_ep0(void)
(0 << TXINE)); /* Disable IN interrupt */

ao_usb_address = 0;
ao_usb_ep0_in_len = 0;
ao_usb_ep0_in_pending = false;
ao_usb_ep0_out_len = 0;
}

static void
Expand Down Expand Up @@ -98,7 +96,7 @@ _ao_usb_set_configuration(void)

/* Set the OUT max packet size, double buffered */
UENUM = AO_USB_OUT_EP;
UECONX |= (1 << EPEN); /* Enable */
UECONX = (1 << EPEN); /* Enable */

UECFG0X = ((2 << EPTYPE0) | /* Bulk */
(0 << EPDIR)); /* Out */
Expand All @@ -107,9 +105,9 @@ _ao_usb_set_configuration(void)
(1 << EPBK0) | /* Double bank */
(1 << ALLOC)); /* Allocate */

UEIENX |= (1 << RXOUTE); /* Enable OUT interrupt */
UEIENX = (1 << RXOUTE); /* Enable OUT interrupt */

ao_usb_running = 1;
ao_usb_running = true;
}

ISR(USB_GEN_vect)
Expand Down Expand Up @@ -191,28 +189,19 @@ _ao_usb_ep0_fill(uint8_t len)
UEINTX &= ~((1 << RXSTPI) | (1 << RXOUTI));
}

static void
ao_usb_ep0_queue_byte(uint8_t a)
{
ao_usb_ep0_in_buf[ao_usb_ep0_in_len++] = a;
}

static void
_ao_usb_ep0_setup(void)
{
/* Pull the setup packet out of the fifo */
ao_usb_ep0_out_data = (uint8_t *) &ao_usb_setup;
ao_usb_ep0_out_len = 8;
_ao_usb_ep0_fill(8);
if (ao_usb_ep0_out_len != 0)
return;

ao_usb_ep0_in_data = ao_usb_ep0_in_buf;
ao_usb_ep0_in_len = 0;
switch(ao_usb_setup.request) {
case AO_USB_REQ_GET_STATUS:
ao_usb_ep0_queue_byte(0);
ao_usb_ep0_queue_byte(0);
ao_usb_ep0_in_len = 2;
break;
case AO_USB_REQ_SET_ADDRESS:
ao_usb_address = ao_usb_setup.value;
Expand All @@ -221,13 +210,13 @@ _ao_usb_ep0_setup(void)
ao_usb_get_descriptor(ao_usb_setup.value);
break;
case AO_USB_REQ_GET_CONFIGURATION:
ao_usb_ep0_queue_byte(0);
ao_usb_ep0_in_len = 1;
break;
case AO_USB_REQ_SET_CONFIGURATION:
_ao_usb_set_configuration();
break;
case AO_USB_REQ_GET_INTERFACE:
ao_usb_ep0_queue_byte(0);
ao_usb_ep0_in_len = 1;
break;
case AO_USB_REQ_SET_INTERFACE:
break;
Expand Down

0 comments on commit f703e3a

Please sign in to comment.