#define STR_DESCR(len,...) { len*2+2, DESCRIPTOR_TYPE_STRING, { __VA_ARGS__ } }
/** USB Device Descriptor. See USB 1.1 spec, pp. 196 - 198 */
-typedef struct {
+struct usb_device_descriptor {
u8 bLength; ///< Size of this descriptor in bytes.
u8 bDescriptorType; ///< DEVICE Descriptor Type.
u16 bcdUSB; ///< USB specification release number (BCD).
u8 iProduct; ///< Index of product string descriptor.
u8 iSerialNumber; ///< Index of string descriptor containing serial #.
u8 bNumConfigurations; ///< Number of possible configurations.
-} usb_device_descriptor_t;
+};
/** USB Configuration Descriptor. See USB 1.1 spec, pp. 199 - 200 */
-typedef struct {
+struct usb_config_descriptor {
u8 bLength; ///< Size of this descriptor in bytes.
u8 bDescriptorType; ///< CONFIGURATION descriptor type.
u16 wTotalLength; ///< Combined total length of all descriptors.
u8 iConfiguration; ///< Index of configuration string descriptor.
u8 bmAttributes; ///< Configuration characteristics.
u8 MaxPower; ///< Maximum power consumption in 2 mA units.
-} usb_config_descriptor_t;
+};
/** USB Interface Descriptor. See USB 1.1 spec, pp. 201 - 203 */
-typedef struct {
+struct usb_interface_descriptor {
u8 bLength; ///< Size of this descriptor in bytes.
u8 bDescriptorType; ///< INTERFACE descriptor type.
u8 bInterfaceNumber; ///< Interface number.
u8 bInterfaceSubclass; ///< Subclass code.
u8 bInterfaceProtocol; ///< Protocol code.
u8 iInterface; ///< Index of interface string descriptor.
-} usb_interface_descriptor_t;
+};
/** USB Endpoint Descriptor. See USB 1.1 spec, pp. 203 - 204 */
-typedef struct {
+struct usb_endpoint_descriptor {
u8 bLength; ///< Size of this descriptor in bytes.
u8 bDescriptorType; ///< ENDPOINT descriptor type.
u8 bEndpointAddress; ///< Endpoint Address: USB 1.1 spec, table 9-10.
u8 bmAttributes; ///< Endpoint Attributes: USB 1.1 spec, table 9-10.
u16 wMaxPacketSize; ///< Maximum packet size for this endpoint.
u8 bInterval; ///< Polling interval (in ms) for this endpoint.
-} usb_endpoint_descriptor_t;
+};
/** USB Language Descriptor. See USB 1.1 spec, pp. 204 - 205 */
-typedef struct {
+struct usb_language_descriptor {
u8 bLength; ///< Size of this descriptor in bytes.
u8 bDescriptorType; ///< STRING descriptor type.
u16 wLANGID[]; ///< LANGID codes.
-} usb_language_descriptor_t;
+};
/** USB String Descriptor. See USB 1.1 spec, pp. 204 - 205 */
-typedef struct {
+struct usb_string_descriptor {
u8 bLength; ///< Size of this descriptor in bytes.
u8 bDescriptorType; ///< STRING descriptor type.
u16 bString[]; ///< UNICODE encoded string.
-} usb_string_descriptor_t;
+};
/********************** USB Control Endpoint 0 related *********************/
/** USB Control Setup Data. See USB 1.1 spec, pp. 183 - 185 */
-typedef struct {
+struct setup_data {
u8 bmRequestType; ///< Characteristics of a request.
u8 bRequest; ///< Specific request.
u16 wValue; ///< Field that varies according to request.
u16 wIndex; ///< Field that varies according to request.
u16 wLength; ///< Number of bytes to transfer in data stage.
-} setup_data_t;
+};
/* External declarations for variables that need to be accessed outside of
* the USB module */
extern volatile bool EP2_out;
extern volatile bool EP2_in;
-extern volatile __xdata __at 0x7FE8 setup_data_t setup_data;
+extern volatile __xdata __at 0x7FE8 struct setup_data setup_data;
/*
* USB Request Types (bmRequestType): See USB 1.1 spec, page 183, table 9-2
/************************** EZ-USB specific stuff **************************/
/** USB Interrupts. See AN2131-TRM, page 9-4 for details */
-typedef enum {
+enum usb_isr {
SUDAV_ISR = 13,
SOF_ISR,
SUTOK_ISR,
EP6OUT_ISR,
EP7IN_ISR,
EP7OUT_ISR
-} USB_ISR;
+};
/*************************** Function Prototypes ***************************/
volatile bool EP2_out = 0;
volatile bool EP2_in = 0;
-volatile __xdata __at 0x7FE8 setup_data_t setup_data;
+volatile __xdata __at 0x7FE8 struct setup_data setup_data;
/* Define number of endpoints (except Control Endpoint 0) in a central place.
* Be sure to include the neccessary endpoint descriptors! */
* old-fashioned way...
*/
-__code usb_device_descriptor_t device_descriptor = {
- /* .bLength = */ sizeof(usb_device_descriptor_t),
+__code struct usb_device_descriptor device_descriptor = {
+ /* .bLength = */ sizeof(struct usb_device_descriptor),
/* .bDescriptorType = */ DESCRIPTOR_TYPE_DEVICE,
/* .bcdUSB = */ 0x0110, /* BCD: 01.00 (Version 1.0 USB spec) */
/* .bDeviceClass = */ 0xFF, /* 0xFF = vendor-specific */
/* WARNING: ALL config, interface and endpoint descriptors MUST be adjacent! */
-__code usb_config_descriptor_t config_descriptor = {
- /* .bLength = */ sizeof(usb_config_descriptor_t),
+__code struct usb_config_descriptor config_descriptor = {
+ /* .bLength = */ sizeof(struct usb_config_descriptor),
/* .bDescriptorType = */ DESCRIPTOR_TYPE_CONFIGURATION,
- /* .wTotalLength = */ sizeof(usb_config_descriptor_t) +
- sizeof(usb_interface_descriptor_t) +
- NUM_ENDPOINTS * sizeof(usb_endpoint_descriptor_t),
+ /* .wTotalLength = */ sizeof(struct usb_config_descriptor) +
+ sizeof(struct usb_interface_descriptor) +
+ (NUM_ENDPOINTS *
+ sizeof(struct usb_endpoint_descriptor)),
/* .bNumInterfaces = */ 1,
/* .bConfigurationValue = */ 1,
/* .iConfiguration = */ 4, /* String describing this configuration */
/* .MaxPower = */ 50 /* 100 mA */
};
-__code usb_interface_descriptor_t interface_descriptor00 = {
- /* .bLength = */ sizeof(usb_interface_descriptor_t),
+__code struct usb_interface_descriptor interface_descriptor00 = {
+ /* .bLength = */ sizeof(struct usb_interface_descriptor),
/* .bDescriptorType = */ DESCRIPTOR_TYPE_INTERFACE,
/* .bInterfaceNumber = */ 0,
/* .bAlternateSetting = */ 0,
/* .iInterface = */ 0
};
-__code usb_endpoint_descriptor_t Bulk_EP2_IN_Endpoint_Descriptor = {
- /* .bLength = */ sizeof(usb_endpoint_descriptor_t),
+__code struct usb_endpoint_descriptor Bulk_EP2_IN_Endpoint_Descriptor = {
+ /* .bLength = */ sizeof(struct usb_endpoint_descriptor),
/* .bDescriptorType = */ 0x05,
/* .bEndpointAddress = */ 2 | USB_DIR_IN,
/* .bmAttributes = */ 0x02,
/* .bInterval = */ 0
};
-__code usb_endpoint_descriptor_t Bulk_EP2_OUT_Endpoint_Descriptor = {
- /* .bLength = */ sizeof(usb_endpoint_descriptor_t),
+__code struct usb_endpoint_descriptor Bulk_EP2_OUT_Endpoint_Descriptor = {
+ /* .bLength = */ sizeof(struct usb_endpoint_descriptor),
/* .bDescriptorType = */ 0x05,
/* .bEndpointAddress = */ 2 | USB_DIR_OUT,
/* .bmAttributes = */ 0x02,
/* .bInterval = */ 0
};
-__code usb_language_descriptor_t language_descriptor = {
+__code struct usb_language_descriptor language_descriptor = {
/* .bLength = */ 4,
/* .bDescriptorType = */ DESCRIPTOR_TYPE_STRING,
/* .wLANGID = */ {0x0409 /* US English */}
};
-__code usb_string_descriptor_t strManufacturer = STR_DESCR(9,'O','p','e','n','U','L','I','N','K');
-__code usb_string_descriptor_t strProduct = STR_DESCR(9,'O','p','e','n','U','L','I','N','K');
-__code usb_string_descriptor_t strSerialNumber = STR_DESCR(6, '0','0','0','0','0','1');
-__code usb_string_descriptor_t strConfigDescr = STR_DESCR(12, 'J','T','A','G',' ','A','d','a','p','t','e','r');
+__code struct usb_string_descriptor strManufacturer =
+ STR_DESCR(9,'O','p','e','n','U','L','I','N','K');
+
+__code struct usb_string_descriptor strProduct =
+ STR_DESCR(9,'O','p','e','n','U','L','I','N','K');
+
+__code struct usb_string_descriptor strSerialNumber =
+ STR_DESCR(6, '0','0','0','0','0','1');
+
+__code struct usb_string_descriptor strConfigDescr =
+ STR_DESCR(12, 'J','T','A','G',' ','A','d','a','p','t','e','r');
/* Table containing pointers to string descriptors */
-__code usb_string_descriptor_t* __code en_string_descriptors[4] = {
+__code struct usb_string_descriptor* __code en_string_descriptors[4] = {
&strManufacturer,
&strProduct,
&strSerialNumber,