diff --git a/src/generic/usb_cdc.c b/src/generic/usb_cdc.c index dfc88511..0478dda5 100644 --- a/src/generic/usb_cdc.c +++ b/src/generic/usb_cdc.c @@ -12,7 +12,7 @@ #include "generic/usbstd.h" // struct usb_device_descriptor #include "generic/usbstd_cdc.h" // struct usb_cdc_header_descriptor #include "sched.h" // sched_wake_task -#include "usb_cdc.h" // usb_notify_setup +#include "usb_cdc.h" // usb_notify_ep0 // XXX - move to Kconfig #define CONFIG_USB_VENDOR_ID 0x2341 @@ -300,7 +300,7 @@ static uint_fast8_t usb_xfer_size; static void usb_do_stall(void) { - usb_set_stall(); + usb_stall_ep0(); usb_state = US_READY; } @@ -314,9 +314,9 @@ usb_state_xfer(void) xs = USB_CDC_EP0_SIZE; int_fast8_t ret; if (usb_state == US_SEND) - ret = usb_send_setup(usb_xfer, xs); + ret = usb_send_ep0(usb_xfer, xs); else - ret = usb_read_setup(usb_xfer, xs); + ret = usb_read_ep0(usb_xfer, xs); if (ret == xs) { // Success usb_xfer += xs; @@ -324,7 +324,7 @@ usb_state_xfer(void) if (!usb_xfer_size && xs < USB_CDC_EP0_SIZE) { // Transfer completed successfully if (usb_state == US_READ) - usb_send_setup(NULL, 0); + usb_send_ep0(NULL, 0); usb_state = US_READY; return; } @@ -370,7 +370,7 @@ static void usb_req_set_configuration(struct usb_ctrlrequest *req) { usb_set_configure(); - usb_send_setup(NULL, 0); + usb_send_ep0(NULL, 0); usb_notify_bulk_in(); } @@ -395,14 +395,14 @@ usb_req_get_line_coding(struct usb_ctrlrequest *req) static void usb_req_line_state(struct usb_ctrlrequest *req) { - usb_send_setup(NULL, 0); + usb_send_ep0(NULL, 0); } static void usb_state_ready(void) { struct usb_ctrlrequest req; - int_fast8_t ret = usb_read_setup(&req, sizeof(req)); + int_fast8_t ret = usb_read_ep0(&req, sizeof(req)); if (ret != sizeof(req)) // XXX - should verify that packet was sent with a setup token return; @@ -418,18 +418,18 @@ usb_state_ready(void) } // State tracking dispatch -static struct task_wake usb_setup_wake; +static struct task_wake usb_ep0_wake; void -usb_notify_setup(void) +usb_notify_ep0(void) { - sched_wake_task(&usb_setup_wake); + sched_wake_task(&usb_ep0_wake); } void -usb_setup_task(void) +usb_ep0_task(void) { - if (!sched_check_wake(&usb_setup_wake)) + if (!sched_check_wake(&usb_ep0_wake)) return; switch (usb_state) { case US_READY: usb_state_ready(); break; @@ -437,12 +437,12 @@ usb_setup_task(void) case US_READ: usb_state_xfer(); break; } } -DECL_TASK(usb_setup_task); +DECL_TASK(usb_ep0_task); void usb_shutdown(void) { usb_notify_bulk_in(); - usb_notify_setup(); + usb_notify_ep0(); } DECL_SHUTDOWN(usb_shutdown); diff --git a/src/generic/usb_cdc.h b/src/generic/usb_cdc.h index 2e63b7a3..e152916d 100644 --- a/src/generic/usb_cdc.h +++ b/src/generic/usb_cdc.h @@ -14,16 +14,15 @@ enum { // callbacks provided by board specific code int_fast8_t usb_read_bulk_out(void *data, uint_fast8_t max_len); int_fast8_t usb_send_bulk_in(void *data, uint_fast8_t len); -int_fast8_t usb_read_setup(void *data, uint_fast8_t max_len); -int_fast8_t usb_send_setup(const void *data, uint_fast8_t len); -void usb_send_pgm_setup(void *data, uint_fast8_t len); -void usb_set_stall(void); +int_fast8_t usb_read_ep0(void *data, uint_fast8_t max_len); +int_fast8_t usb_send_ep0(const void *data, uint_fast8_t len); +void usb_stall_ep0(void); void usb_set_address(uint_fast8_t addr); void usb_set_configure(void); // usb_cdc.c void usb_notify_bulk_in(void); void usb_notify_bulk_out(void); -void usb_notify_setup(void); +void usb_notify_ep0(void); #endif // usb_cdc.h diff --git a/src/lpc176x/usbserial.c b/src/lpc176x/usbserial.c index 2b6dca00..1dc3836c 100644 --- a/src/lpc176x/usbserial.c +++ b/src/lpc176x/usbserial.c @@ -8,7 +8,7 @@ #include "LPC17xx.h" // LPC_SC #include "byteorder.h" // cpu_to_le32 #include "command.h" // output -#include "generic/usb_cdc.h" // usb_notify_setup +#include "generic/usb_cdc.h" // usb_notify_ep0 #include "internal.h" // gpio_peripheral #include "sched.h" // DECL_INIT #include "usb_cdc_ep.h" // USB_CDC_EP_BULK_IN @@ -184,19 +184,19 @@ usb_send_bulk_in(void *data, uint_fast8_t len) } int_fast8_t -usb_read_setup(void *data, uint_fast8_t max_len) +usb_read_ep0(void *data, uint_fast8_t max_len) { return usb_read_packet(EP0OUT, data, max_len); } int_fast8_t -usb_send_setup(const void *data, uint_fast8_t len) +usb_send_ep0(const void *data, uint_fast8_t len) { return usb_write_packet(EP0IN, data, len); } void -usb_set_stall(void) +usb_stall_ep0(void) { usb_irq_disable(); sie_cmd_write(SIE_CMD_SET_ENDPOINT_STATUS | 0, (1<<7)); @@ -209,7 +209,7 @@ usb_set_address(uint_fast8_t addr) usb_irq_disable(); sie_cmd_write(SIE_CMD_SET_ADDRESS, addr | (1<<7)); usb_irq_enable(); - usb_send_setup(NULL, 0); + usb_send_ep0(NULL, 0); } static void @@ -279,11 +279,11 @@ USB_IRQHandler(void) uint32_t ueis = LPC_USB->USBEpIntSt; if (ueis & (1< // memcpy #include "board/io.h" // readl -#include "board/usb_cdc.h" // usb_notify_setup +#include "board/usb_cdc.h" // usb_notify_ep0 #include "board/usb_cdc_ep.h" // USB_CDC_EP_BULK_IN #include "internal.h" // enable_pclock #include "samd21.h" // USB @@ -122,19 +122,19 @@ usb_send_bulk_in(void *data, uint_fast8_t len) } int_fast8_t -usb_read_setup(void *data, uint_fast8_t max_len) +usb_read_ep0(void *data, uint_fast8_t max_len) { return usb_read_packet(0, 0, data, max_len); } int_fast8_t -usb_send_setup(const void *data, uint_fast8_t len) +usb_send_ep0(const void *data, uint_fast8_t len) { return usb_write_packet(0, 1, data, len); } void -usb_set_stall(void) +usb_stall_ep0(void) { EP0.EPSTATUSSET.reg = USB_DEVICE_EPSTATUS_STALLRQ(3); } @@ -145,7 +145,7 @@ void usb_set_address(uint_fast8_t addr) { writeb(&set_address, addr | USB_DEVICE_DADD_ADDEN); - usb_send_setup(NULL, 0); + usb_send_ep0(NULL, 0); } void @@ -212,7 +212,7 @@ USB_Handler(void) USB->DEVICE.DADD.reg = set_address; set_address = 0; } - usb_notify_setup(); + usb_notify_ep0(); } if (ep & (1<