30 #define USB_VENDOR_ID_POLOLU 0x1FFB
34 #define USB_EP0_PACKET_SIZE 32
42 USB_STATE_DETACHED = 0,
43 USB_STATE_ATTACHED = 1,
44 USB_STATE_POWERED = 2,
45 USB_STATE_DEFAULT = 4,
46 USB_STATE_ADDRESS = 8,
47 USB_STATE_CONFIGURED = 16
51 #define USB_REQUEST_GET_STATUS 0u
52 #define USB_REQUEST_CLEAR_FEATURE 1u
53 #define USB_REQUEST_SET_FEATURE 3u
54 #define USB_REQUEST_SET_ADDRESS 5u
55 #define USB_REQUEST_GET_DESCRIPTOR 6u
56 #define USB_REQUEST_SET_DESCRIPTOR 7u
57 #define USB_REQUEST_GET_CONFIGURATION 8u
58 #define USB_REQUEST_SET_CONFIGURATION 9u
59 #define USB_REQUEST_GET_INTERFACE 10u
60 #define USB_REQUEST_SET_INTERFACE 11u
61 #define USB_REQUEST_SYNCH_FRAME 12u
64 #define USB_REQUEST_TYPE_STANDARD 0u
65 #define USB_REQUEST_TYPE_CLASS 1u
66 #define USB_REQUEST_TYPE_VENDOR 2u
69 #define USB_RECIPIENT_DEVICE 0u
70 #define USB_RECIPIENT_INTERFACE 1u
71 #define USB_RECIPIENT_ENDPOINT 2u
72 #define USB_RECIPIENT_OTHER 3u
75 #define USB_DESCRIPTOR_TYPE_DEVICE 1u
76 #define USB_DESCRIPTOR_TYPE_CONFIGURATION 2u
77 #define USB_DESCRIPTOR_TYPE_STRING 3u
78 #define USB_DESCRIPTOR_TYPE_INTERFACE 4u
79 #define USB_DESCRIPTOR_TYPE_ENDPOINT 5u
80 #define USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER 6u
81 #define USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION 7u
82 #define USB_DESCRIPTOR_TYPE_INTERFACE_POWER 8u
83 #define USB_DESCRIPTOR_TYPE_ENDPOINT_CLASS_SPECIFIC 0x25u
84 #define USB_DESCRIPTOR_TYPE_INTERFACE_ASSOCIATION 0x0Bu
87 #define USB_FEATURE_DEVICE_REMOTE_WAKEUP 1u
88 #define USB_FEATURE_ENDPOINT_HALT 0u
89 #define USB_FEATURE_TEST_MODE 2u
92 #define USB_CONFIG_ATTR_DEFAULT (1<<7) //Default Value (bit 7 must be set to 1)
93 #define USB_CONFIG_ATTR_SELF_POWERED (1<<6) //Self-powered
94 #define USB_CONFIG_ATTR_REMOTE_WAKEUP (1<<5) //Remote Wakeup
102 #define USB_ENDPOINT_ADDRESS_IN 0x80
103 #define USB_ENDPOINT_ADDRESS_OUT 0x00
106 #define USB_TRANSFER_TYPE_CONTROL 0
107 #define USB_TRANSFER_TYPE_ISOCHRONOUS 1
108 #define USB_TRANSFER_TYPE_BULK 2
109 #define USB_TRANSFER_TYPE_INTERRUPT 3
113 #define USB_LANGUAGE_EN_US 0x0409
132 unsigned recipient:5;
133 unsigned requestType:2;
134 unsigned direction:1;
213 #define USBCSOL_OUTPKT_RDY 0x01
216 #define USBCSIL_INPKT_RDY 0x01
217 #define USBCSIL_PKT_PRESENT 0x02
230 #define DEFINE_STRING_DESCRIPTOR(name,char_count,...) static uint16 CODE name[] = { (2*(char_count+1)) | (USB_DESCRIPTOR_TYPE_STRING<<8), __VA_ARGS__ };
struct USB_DESCRIPTOR_DEVICE USB_DESCRIPTOR_DEVICE
void usbCallbackInitEndpoints(void)
uint8 CODE usbStringDescriptorCount
void usbInitEndpointOut(uint8 endpointNumber, uint8 maxPacketSize)
volatile BIT usbActivityFlag
enum USB_DEVICE_STATES XDATA usbDeviceState
void usbControlWrite(uint16 bytesCount, uint8 XDATA *source)
USB_DESCRIPTOR_DEVICE CODE usbDeviceDescriptor
struct USB_DESCRIPTOR_CONFIGURATION USB_DESCRIPTOR_CONFIGURATION
struct USB_DESCRIPTOR_INTERFACE USB_DESCRIPTOR_INTERFACE
struct USB_DESCRIPTOR_ENDPOINT USB_DESCRIPTOR_ENDPOINT
uint8 bConfigurationValue
USB_SETUP_PACKET XDATA usbSetupPacket
void usbShowStatusWithGreenLed(void)
void usbWriteFifo(uint8 endpointNumber, uint8 count, const uint8 XDATA *buffer)
void usbInitEndpointIn(uint8 endpointNumber, uint8 maxPacketSize)
void usbReadFifo(uint8 endpointNumber, uint8 count, uint8 XDATA *buffer)
void usbCallbackSetupHandler(void)
void usbControlStall(void)
void usbControlAcknowledge(void)
void usbCallbackControlWriteHandler(void)
void usbControlRead(uint16 bytesCount, uint8 XDATA *source)
void usbCallbackClassDescriptorHandler(void)
volatile BIT usbSuspendMode
uint16 CODE *CODE usbStringDescriptors[]
struct USB_DESCRIPTOR_INTERFACE_ASSOCIATION USB_DESCRIPTOR_INTERFACE_ASSOCIATION