usb-api.h
00001 #ifndef __USB_API_H__SYN81IFYBN__
00002 #define __USB_API_H__SYN81IFYBN__
00003
00004 #include <sys/process.h>
00005
00006 typedef struct _USBBuffer USBBuffer;
00007
00008 struct _USBBuffer
00009 {
00010 USBBuffer *next;
00011 uint8_t *data;
00012 uint16_t left;
00013 uint16_t flags;
00014 uint32_t id;
00015 };
00016
00017
00018 #define USB_BUFFER_SUBMITTED 0x01
00019
00020
00021
00022 #define USB_BUFFER_SHORT_END 0x02
00023
00024
00025 #define USB_BUFFER_PACKET_END 0x04
00026
00027
00028 #define USB_BUFFER_NOTIFY 0x08
00029
00030
00031 #define USB_BUFFER_IN 0x40
00032
00033
00034
00035
00036 #define USB_BUFFER_SETUP 0x20
00037
00038
00039
00040 #define USB_BUFFER_HALT 0x100
00041
00042
00043
00044
00045 #define USB_BUFFER_SHORT_PACKET 0x10
00046
00047
00048 #define USB_BUFFER_FAILED 0x80
00049
00050
00051 #define USB_BUFFER_ARCH_FLAG_1 0x1000
00052 #define USB_BUFFER_ARCH_FLAG_2 0x2000
00053 #define USB_BUFFER_ARCH_FLAG_3 0x4000
00054 #define USB_BUFFER_ARCH_FLAG_4 0x8000
00055
00056 void
00057 usb_setup(void);
00058
00059
00060
00061 struct USBRequestHandler
00062 {
00063 uint8_t request_type;
00064 uint8_t request_type_mask;
00065 uint8_t request;
00066 uint8_t request_mask;
00067
00068 unsigned int (*handler_func)();
00069 };
00070
00071
00072 struct USBRequestHandlerHook
00073 {
00074 struct USBRequestHandlerHook *next;
00075 const struct USBRequestHandler * const handler;
00076 };
00077
00078 void
00079 usb_register_request_handler(struct USBRequestHandlerHook *hook);
00080
00081 void
00082 usb_prepend_request_handler(struct USBRequestHandlerHook *hook);
00083
00084 void
00085 usb_setup_bulk_endpoint(uint8_t addr);
00086 void
00087 usb_setup_interrupt_endpoint(uint8_t addr);
00088
00089
00090
00091 void
00092 usb_submit_recv_buffer(uint8_t ep_addr, USBBuffer *buffer);
00093
00094
00095
00096
00097
00098 void
00099 usb_submit_xmit_buffer(uint8_t ep_addr, USBBuffer *buffer);
00100
00101
00102 int
00103 usb_send_pending(uint8_t ep_addr);
00104
00105
00106
00107 void
00108 usb_discard_all_buffers(uint8_t ep_addr);
00109
00110 void
00111 usb_disable_endpoint(uint8_t addr);
00112
00113
00114 void
00115 usb_halt_endpoint(uint8_t addr, int halt);
00116
00117
00118
00119 void
00120 usb_set_ep_event_process(uint8_t addr, struct process *p);
00121
00122
00123 void
00124 usb_set_global_event_process(struct process *p);
00125
00126
00127 #define USB_EVENT_CONFIG 0x01
00128 #define USB_EVENT_SUSPEND 0x02
00129 #define USB_EVENT_RESUME 0x04
00130 #define USB_EVENT_RESET 0x08
00131
00132
00133
00134 unsigned int
00135 usb_get_global_events(void);
00136
00137
00138 #define USB_EP_EVENT_NOTIFICATION 0x01
00139 unsigned int
00140 usb_get_ep_events(uint8_t addr);
00141
00142 unsigned int
00143 usb_get_current_configuration(void);
00144
00145 #endif