1 /* 2 * URB formatting related definitions 3 */ 4 5 #ifndef _URB_HELPER_H_ 6 #define _URB_HELPER_H_ 7 8 #include <ddekit/usb.h> 9 #include <ddekit/semaphore.h> 10 11 /* Possible values for attach_urb_data's buf_type */ 12 /* Both may be used for single URB */ 13 #define URB_BUF_TYPE_DATA 0 /* attached buffer is data buffer */ 14 #define URB_BUF_TYPE_SETUP 1 /* attached buffer is setup structure */ 15 16 /* Possible values for blocking_urb_submit's check_len */ 17 /* Use URB_SUBMIT_CHECK_LEN when actual data buffer length returned 18 * by HCD must match expected length, supplied in attach_urb_data */ 19 #define URB_SUBMIT_CHECK_LEN 0 /* return error on length mismatch */ 20 #define URB_SUBMIT_ALLOW_MISMATCH 1 /* ignore length check */ 21 22 /* Endpoint configuration related */ 23 #define URB_INVALID_EP (-1) /* default for unset endpoint */ 24 25 /*---------------------------* 26 * declared types * 27 *---------------------------*/ 28 /* URB's endpoint configuration */ 29 typedef struct urb_ep_config { 30 31 ddekit_int32_t ep_num; 32 ddekit_int32_t direction; 33 ddekit_int32_t type; 34 ddekit_int32_t max_packet_size; 35 ddekit_int32_t interval; 36 } 37 urb_ep_config; 38 39 /*---------------------------* 40 * declared functions * 41 *---------------------------*/ 42 void init_urb(struct ddekit_usb_urb *, struct ddekit_usb_dev *, 43 urb_ep_config *); 44 void attach_urb_data(struct ddekit_usb_urb *, int, void *, ddekit_uint32_t); 45 int blocking_urb_submit(struct ddekit_usb_urb *, ddekit_sem_t *, int); 46 47 #endif /* !_URB_HELPER_H_ */ 48