Mercurial > ~darius > hgwebdir.cgi > tempctrl
diff usb.h @ 31:4e417d84365e
- Rename some more functions to be consistent.
- Add some delays when talking to the 'D12 - probably not needed.
- Add some comments at the top of each function.
- Log endpoint errors.
- Whitespace changes.
- Remove exact_Bytes crap.
- Many other changes I have made in an attempt to get it to work
consistently (but no luck yet).
author | darius |
---|---|
date | Mon, 10 Apr 2006 17:27:48 +0930 |
parents | 845934a4e7fe |
children | fed32b382de2 |
line wrap: on
line diff
--- a/usb.h Mon Apr 10 17:23:51 2006 +0930 +++ b/usb.h Mon Apr 10 17:27:48 2006 +0930 @@ -14,7 +14,7 @@ uint16_t wValue; uint16_t wIndex; uint16_t wLength; -} USB_SETUP_REQUEST; +} __attribute__ ((packed)) USB_SETUP_REQUEST; typedef struct { uint8_t bLength; @@ -31,7 +31,7 @@ uint8_t iProduct; uint8_t iSerialNumber; uint8_t bNumConfigurations; -} USB_DEVICE_DESCRIPTOR; +} __attribute__ ((packed)) USB_DEVICE_DESCRIPTOR; typedef struct { uint8_t bLength; @@ -40,7 +40,7 @@ uint8_t bmAttributes; uint16_t wMaxPacketSize; uint8_t bInterval; -} USB_ENDPOINT_DESCRIPTOR; +} __attribute__ ((packed)) USB_ENDPOINT_DESCRIPTOR; typedef struct { uint8_t bLength; @@ -51,7 +51,7 @@ uint8_t iConfiguration; uint8_t bmAttributes; uint8_t MaxPower; -} USB_CONFIGURATION_DESCRIPTOR; +} __attribute__ ((packed)) USB_CONFIGURATION_DESCRIPTOR; typedef struct { uint8_t bLength; @@ -63,7 +63,7 @@ uint8_t bInterfaceSubClass; uint8_t bInterfaceProtocol; uint8_t iInterface; -} USB_INTERFACE_DESCRIPTOR; +} __attribute__ ((packed)) USB_INTERFACE_DESCRIPTOR; typedef struct { uint8_t bLength; @@ -73,7 +73,7 @@ uint8_t bNumDescriptors; uint8_t b1stDescType; uint16_t w1stDescLength; -} USB_HID_DESCRIPTOR; +} __attribute__ ((packed)) USB_HID_DESCRIPTOR; typedef struct { USB_CONFIGURATION_DESCRIPTOR ConfigDescriptor; @@ -83,19 +83,19 @@ USB_INTERFACE_DESCRIPTOR InterfaceDescriptor1; USB_ENDPOINT_DESCRIPTOR EndpointDescriptor10; USB_ENDPOINT_DESCRIPTOR EndpointDescriptor11; -} USB_CONFIG_DATA; +} __attribute__ ((packed)) USB_CONFIG_DATA; typedef struct { uint8_t bLength; uint8_t bDescriptorType; char bString[]; -} STRING_DESCRIPTOR; +} __attribute__ ((packed)) STRING_DESCRIPTOR; typedef struct { uint8_t bLength; uint8_t bDescriptorType; uint16_t wLANGID0; -} LANGID_DESCRIPTOR; +} __attribute__ ((packed)) LANGID_DESCRIPTOR; #define D12_SET_ADDRESS_ENABLE 0xD0 #define D12_SET_ENDPOINT_ENABLE 0xD8 @@ -127,7 +127,11 @@ #define D12_INT_BUS_RESET 0x40 #define D12_INT_SUSPEND 0x80 +#define D12_LAST_TRAN_OK 0x01 +#define D12_LAST_TRAN_ERRMSK 0x1e #define D12_LAST_TRAN_SETUP 0x20 +#define D12_LAST_TRAN_DATA 0x40 +#define D12_LAST_TRAN_OFLOW 0x80 #define STANDARD_DEVICE_REQUEST 0x00 #define STANDARD_INTERFACE_REQUEST 0x01 @@ -148,6 +152,7 @@ #define SET_INTERFACE 11 #define SYNCH_FRAME 12 +#define VENDOR_DOTEMP 125 #define VENDOR_UPDATE 126 #define VENDOR_RESET 127 @@ -174,11 +179,13 @@ uint8_t d12_read_endpt(uint8_t endpt, uint8_t *buffer); void d12_ep0_irq(void); -void d12_getdescriptor(USB_SETUP_REQUEST *SetupPacket); -void d12_stallctrlendpt(void); +void d12_handle_setup(void); +void d12_getdescriptor(USB_SETUP_REQUEST *setuppkt); +void d12_stallendpt(uint8_t ep); uint8_t d12_read_endpt(uint8_t endpt, uint8_t *buffer); void d12_write_endpt(uint8_t endpt, const uint8_t *buffer, uint8_t bytes); -void d12_write_buffer_ep0(void); +void d12_send_data_ep0(void); +void d12_receive_data_ep1(void); void d12_send_data_ep2(void); void d12_receive_data_ep2(void);