Create unions in usb_setup_t so that value, index, and length can be read as words, not just high/low bytes.

This commit is contained in:
Jared Boone
2012-10-13 17:06:24 -07:00
parent 3c17bad743
commit f32c6b34ca
2 changed files with 24 additions and 9 deletions

View File

@ -67,7 +67,7 @@ static void usb_send_descriptor(
usb_endpoint_t* const endpoint,
uint8_t* const descriptor_data
) {
const uint32_t setup_length = (endpoint->setup.length_h << 8) | endpoint->setup.length_l;
const uint32_t setup_length = endpoint->setup.length;
uint32_t descriptor_length = descriptor_data[0];
if( descriptor_data[1] == USB_DESCRIPTOR_TYPE_CONFIGURATION ) {
descriptor_length = (descriptor_data[3] << 8) | descriptor_data[2];
@ -221,7 +221,7 @@ static void usb_standard_request_set_configuration(
static void usb_standard_request_get_configuration_setup(
usb_endpoint_t* const endpoint
) {
if( (endpoint->setup.length_h == 0) && (endpoint->setup.length_l == 1) ) {
if( endpoint->setup.length == 1 ) {
endpoint->buffer[0] = 0;
if( endpoint->device->configuration ) {
endpoint->buffer[0] = endpoint->device->configuration->number;

View File

@ -30,15 +30,30 @@
#define ATTR_ALIGNED(x) __attribute__ ((aligned(x)))
#define ATTR_SECTION(x) __attribute__ ((section(x)))
typedef struct {
typedef struct ATTR_PACKED {
uint8_t request_type;
uint8_t request;
union {
struct {
uint8_t value_l;
uint8_t value_h;
};
uint16_t value;
};
union {
struct {
uint8_t index_l;
uint8_t index_h;
};
uint16_t index;
};
union {
struct {
uint8_t length_l;
uint8_t length_h;
};
uint16_t length;
};
} usb_setup_t;
typedef enum {