- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# include/usb/request.h

Go to the documentation of this file.

    00001
    00044 #ifndef USB_BUFFER_H_INCLUDED
    00045 #define USB_BUFFER_H_INCLUDED
    00046
    00047 #include <bitops.h>
    00048 #include <buffer.h>
    00049 #include <types.h>
    00050
    00051 struct udc;
    00052
    00057 enum usb_request_flag {
    00066         USB_REQ_SHORT_PKT,
    00067 };
    00068
    00075 struct usb_request {
    00077         struct slist            buf_list;
    00079         struct slist_node       node;
    00084         unsigned long           flags;
    00090         void (*req_done)(struct udc *udc, struct usb_request *req);
    00095         void                    *context;
    00100         int                     status;
    00106         size_t                  bytes_xfered;
    00107 };
    00108
    00109 extern void usb_req_init(struct usb_request *req);
    00110
    00120 static inline void usb_req_add_buffer(struct usb_request *req,
    00121                 struct buffer *buf)
    00122 {
    00123         slist_insert_tail(&req->buf_list, &buf->node);
    00124 }
    00125
    00126 extern struct usb_request *usb_req_alloc(void);
    00127 extern void usb_req_free(struct usb_request *req);
    00128 extern void usb_init(void);
    00129
    00130 extern struct usb_request *usb_req_alloc_single_tx(
    00131                 const void *data, size_t len);
    00132 extern struct usb_request *usb_req_alloc_single_rx(void *data, size_t len);
    00133 extern void usb_req_free_all(struct usb_request *req);
    00134
    00138 static inline struct buffer *usb_req_get_first_buffer(
    00139                 struct usb_request *req)
    00140 {
    00141         return slist_peek_head(&req->buf_list, struct buffer, node);
    00142 }
    00143
    00148 #define usb_req_for_each_buffer(req, buf)                       \
    00149         slist_for_each(&req->buf_list, buf, node)
    00150
    00155 #define usb_req_for_each_buffer_safe(req, buf, next)            \
    00156         slist_for_each_safe(&req->buf_list, buf, next, node)
    00157
    00158 #endif /* USB_BUFFER_H_INCLUDED */