31 #define NUM_ENDPOINTS 2
38 .bDeviceSubClass = 0xFF,
39 .bDeviceProtocol = 0xFF,
40 .bMaxPacketSize0 = 64,
47 .bNumConfigurations = 1
59 .bConfigurationValue = 1,
68 .bInterfaceNumber = 0,
69 .bAlternateSetting = 0,
71 .bInterfaceClass = 0xFF,
72 .bInterfaceSubclass = 0xFF,
73 .bInterfaceProtocol = 0xFF,
102 STR_DESCR(9,
'O',
'p',
'e',
'n',
'U',
'L',
'I',
'N',
'K');
105 STR_DESCR(9,
'O',
'p',
'e',
'n',
'U',
'L',
'I',
'N',
'K');
108 STR_DESCR(6,
'0',
'0',
'0',
'0',
'0',
'1');
111 STR_DESCR(12,
'J',
'T',
'A',
'G',
' ',
'A',
'd',
'a',
'p',
't',
'e',
'r');
224 uint8_t ep_num = ep & 0x7F;
231 return ep & 0x80 ? &IN1CS : &OUT1CS;
234 return ep & 0x80 ? &IN2CS : &OUT2CS;
237 return ep & 0x80 ? &IN3CS : &OUT3CS;
240 return ep & 0x80 ? &IN4CS : &OUT4CS;
243 return ep & 0x80 ? &IN5CS : &OUT5CS;
246 return ep & 0x80 ? &IN6CS : &OUT6CS;
249 return ep & 0x80 ? &IN7CS : &OUT7CS;
267 uint8_t togctl_value = (ep & 0x80 >> 3) | (ep & 0x7);
270 TOGCTL = togctl_value;
273 togctl_value |=
TOG_R;
274 TOGCTL = togctl_value;
336 __xdata uint8_t *ep_cs;
370 __xdata uint8_t *ep_cs;
405 __xdata uint8_t descriptor_type;
406 __xdata uint8_t descriptor_index;
411 switch (descriptor_type) {
void delay_ms(uint16_t delay)
uint16_t wIndex
Field that varies according to request.
uint8_t bRequest
Specific request.
uint8_t bmRequestType
Characteristics of a request.
uint16_t wValue
Field that varies according to request.
USB Configuration Descriptor.
uint8_t bDescriptorType
CONFIGURATION descriptor type.
uint8_t bLength
Size of this descriptor in bytes.
uint8_t bConfigurationValue
Value used to select this configuration.
uint8_t bDescriptorType
DEVICE Descriptor Type.
uint8_t bLength
Size of this descriptor in bytes.
uint16_t wMaxPacketSize
Maximum packet size for this endpoint.
uint8_t bInterval
Polling interval (in ms) for this endpoint.
uint8_t bmAttributes
Endpoint Attributes: USB 1.1 spec, table 9-10.
uint8_t bDescriptorType
ENDPOINT descriptor type.
uint8_t bLength
Size of this descriptor in bytes.
USB Interface Descriptor.
uint8_t bDescriptorType
INTERFACE descriptor type.
uint8_t bLength
Size of this descriptor in bytes.
uint8_t bInterfaceNumber
Interface number.
uint8_t bLength
Size of this descriptor in bytes.
void ep2in_isr(void)
EP2 IN: called after the transfer from uC->Host has finished: we sent data.
__code struct usb_string_descriptor strProduct
__code struct usb_string_descriptor strManufacturer
bool usb_handle_clear_feature(void)
Handle CLEAR_FEATURE request.
__code struct usb_endpoint_descriptor Bulk_EP2_OUT_Endpoint_Descriptor
__xdata uint8_t * usb_get_endpoint_cs_reg(uint8_t ep)
Return the control/status register for an endpoint.
void usb_handle_setup_data(void)
Handle the arrival of a USB Control Setup Packet.
void usb_reset_data_toggle(uint8_t ep)
__code struct usb_config_descriptor config_descriptor
__code struct usb_device_descriptor device_descriptor
void usb_handle_set_interface(void)
Handle SET_INTERFACE request.
__code struct usb_string_descriptor *__code en_string_descriptors[4]
__code struct usb_string_descriptor strConfigDescr
bool usb_handle_get_descriptor(void)
Handle GET_DESCRIPTOR request.
void ep2out_isr(void)
EP2 OUT: called after the transfer from Host->uC has finished: we got data.
__code struct usb_language_descriptor language_descriptor
__code struct usb_endpoint_descriptor Bulk_EP2_IN_Endpoint_Descriptor
bool usb_handle_get_status(void)
Handle GET_STATUS request.
__code struct usb_interface_descriptor interface_descriptor00
__code struct usb_string_descriptor strSerialNumber
void usb_init(void)
USB initialization.
bool usb_handle_set_feature(void)
Handle SET_FEATURE request.
#define DESCRIPTOR_TYPE_CONFIGURATION
#define DESCRIPTOR_TYPE_INTERFACE
#define SET_CONFIGURATION
#define DESCRIPTOR_TYPE_DEVICE
#define STR_DESCR(len,...)
#define GET_CONFIGURATION
#define DESCRIPTOR_TYPE_STRING