[dev][usb] more usb stack cleanup

This commit is contained in:
Travis Geiselbrecht
2013-10-18 20:13:57 -07:00
parent 90d2942b44
commit 149b658b40
2 changed files with 26 additions and 26 deletions

View File

@@ -165,10 +165,11 @@ status_t usb_callback(usbc_callback_op_t op, const union usb_callback_args *args
LTRACEF("op %d, args %p\n", op, args);
/* start looking for specific things to handle */
if (op == CB_SETUP_MSG) {
if (op == USB_CB_SETUP_MSG) {
const struct usb_setup *setup = args->setup;
DEBUG_ASSERT(setup);
LTRACEF("SETUP: req_type=%#x req=%#x value=%#x index=%#x len=%#x\n", setup->request_type, setup->request, setup->value, setup->index, setup->length);
LTRACEF("SETUP: req_type=%#x req=%#x value=%#x index=%#x len=%#x\n",
setup->request_type, setup->request, setup->value, setup->index, setup->length);
if ((setup->request_type & TYPE_MASK) == TYPE_STANDARD) {
switch (setup->request) {
@@ -287,6 +288,8 @@ status_t usb_callback(usbc_callback_op_t op, const union usb_callback_args *args
default:
LTRACEF("unhandled standard request 0x%x\n", setup->request);
}
} else {
LTRACEF("unhandled nonstandard request 0x%x\n", setup->request);
}
}

View File

@@ -32,32 +32,31 @@ void usbc_init(void);
typedef uint ep_t;
typedef enum {
IN = 0,
OUT
USB_IN = 0,
USB_OUT
} ep_dir_t;
typedef enum {
CB_RESET,
CB_SUSPEND,
CB_RESUME,
CB_DISCONNECT,
CB_ONLINE,
CB_OFFLINE,
CB_SETUP_MSG,
/* endpoint transfer stuff */
CB_EP_RXCOMPLETE,
CB_EP_TXCOMPLETE,
CB_EP_TRANSFER_CANCELLED,
USB_CB_RESET,
USB_CB_SUSPEND,
USB_CB_RESUME,
USB_CB_DISCONNECT,
USB_CB_ONLINE,
USB_CB_OFFLINE,
USB_CB_SETUP_MSG,
} usbc_callback_op_t;
typedef struct {
struct usbc_transfer;
typedef status_t (*ep_callback)(ep_t endpoint, struct usbc_transfer *transfer);
typedef struct usbc_transfer {
ep_callback callback;
status_t result;
void *buf;
size_t buflen;
uint bufpos;
int result;
void *extra; // extra pointer to store whatever you want
} usbc_transfer;
} usbc_transfer_t;
enum {
USB_TRANSFER_RESULT_OK = 0,
@@ -65,11 +64,9 @@ enum {
USB_TRANSFER_RESULT_CANCELLED = -2,
};
typedef status_t (*ep_callback)(ep_t endpoint, usbc_callback_op_t op, usbc_transfer *transfer);
void usbc_setup_endpoint(ep_t ep, ep_dir_t dir, bool active, ep_callback callback, uint width, uint blocksize);
status_t usbc_queue_rx(ep_t ep, usbc_transfer *transfer);
status_t usbc_queue_tx(ep_t ep, usbc_transfer *transfer);
status_t usbc_setup_endpoint(ep_t ep, ep_dir_t dir, uint width);
status_t usbc_queue_rx(ep_t ep, usbc_transfer_t *transfer);
status_t usbc_queue_tx(ep_t ep, usbc_transfer_t *transfer);
/* setup arg is valid during CB_SETUP_MSG */
union usb_callback_args {
@@ -90,9 +87,9 @@ void usbc_ep0_recv(void *buf, size_t len, ep_callback);
bool usbc_is_highspeed(void);
static inline void usbc_dump_transfer(const usbc_transfer *t)
static inline void usbc_dump_transfer(const usbc_transfer_t *t)
{
printf("usb transfer %p: buf %p, buflen %zd, bufpos %u, result %d\n", t, t->buf, t->buflen, t->bufpos, t->result);
printf("usb transfer %p: cb %p buf %p, buflen %zd, bufpos %u, result %d\n", t, t->callback, t->buf, t->buflen, t->bufpos, t->result);
}
#endif