aboutsummaryrefslogtreecommitdiff
path: root/example-cdc
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2016-03-08 20:20:49 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2016-03-08 20:20:49 +0900
commit90ac7f7c137fbddbf0725be68d9ee8776f777aa9 (patch)
tree2da59bec33363aaf9167ff2376c3442e9b013067 /example-cdc
parentfd8aee3cb0f9243f600b9576863ad5c8457529b6 (diff)
update usb stack from Gnuk development branch
Diffstat (limited to 'example-cdc')
-rw-r--r--example-cdc/usb-cdc.c54
-rw-r--r--example-cdc/usb_lld.h23
-rw-r--r--example-cdc/usb_stm32f103.c123
3 files changed, 98 insertions, 102 deletions
diff --git a/example-cdc/usb-cdc.c b/example-cdc/usb-cdc.c
index 7bb768a..5b569b4 100644
--- a/example-cdc/usb-cdc.c
+++ b/example-cdc/usb-cdc.c
@@ -20,7 +20,7 @@ static struct stream stream;
/* USB Device Descriptor */
static const uint8_t vcom_device_desc[18] = {
18, /* bLength */
- USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
+ DEVICE_DESCRIPTOR, /* bDescriptorType */
0x10, 0x01, /* bcdUSB = 1.1 */
0x02, /* bDeviceClass (CDC). */
0x00, /* bDeviceSubClass. */
@@ -38,7 +38,7 @@ static const uint8_t vcom_device_desc[18] = {
/* Configuration Descriptor tree for a CDC.*/
static const uint8_t vcom_config_desc[67] = {
9,
- USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
+ CONFIG_DESCRIPTOR, /* bDescriptorType: Configuration */
/* Configuration Descriptor.*/
67, 0x00, /* wTotalLength. */
0x02, /* bNumInterfaces. */
@@ -48,7 +48,7 @@ static const uint8_t vcom_config_desc[67] = {
50, /* bMaxPower (100mA). */
/* Interface Descriptor.*/
9,
- USB_INTERFACE_DESCRIPTOR_TYPE,
+ INTERFACE_DESCRIPTOR,
0x00, /* bInterfaceNumber. */
0x00, /* bAlternateSetting. */
0x01, /* bNumEndpoints. */
@@ -87,14 +87,14 @@ static const uint8_t vcom_config_desc[67] = {
0x01, /* bSlaveInterface0 (Data Class Interface). */
/* Endpoint 2 Descriptor.*/
7,
- USB_ENDPOINT_DESCRIPTOR_TYPE,
+ ENDPOINT_DESCRIPTOR,
ENDP2|0x80, /* bEndpointAddress. */
0x03, /* bmAttributes (Interrupt). */
0x08, 0x00, /* wMaxPacketSize. */
0xFF, /* bInterval. */
/* Interface Descriptor.*/
9,
- USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */
+ INTERFACE_DESCRIPTOR, /* bDescriptorType: */
0x01, /* bInterfaceNumber. */
0x00, /* bAlternateSetting. */
0x02, /* bNumEndpoints. */
@@ -104,14 +104,14 @@ static const uint8_t vcom_config_desc[67] = {
0x00, /* iInterface. */
/* Endpoint 3 Descriptor.*/
7,
- USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
+ ENDPOINT_DESCRIPTOR, /* bDescriptorType: Endpoint */
ENDP3, /* bEndpointAddress. */
0x02, /* bmAttributes (Bulk). */
0x40, 0x00, /* wMaxPacketSize. */
0x00, /* bInterval. */
/* Endpoint 1 Descriptor.*/
7,
- USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
+ ENDPOINT_DESCRIPTOR, /* bDescriptorType: Endpoint */
ENDP1|0x80, /* bEndpointAddress. */
0x02, /* bmAttributes (Bulk). */
0x40, 0x00, /* wMaxPacketSize. */
@@ -124,13 +124,13 @@ static const uint8_t vcom_config_desc[67] = {
*/
static const uint8_t vcom_string0[4] = {
4, /* bLength */
- USB_STRING_DESCRIPTOR_TYPE,
+ STRING_DESCRIPTOR,
0x09, 0x04 /* LangID = 0x0409: US-English */
};
static const uint8_t vcom_string1[] = {
23*2+2, /* bLength */
- USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
+ STRING_DESCRIPTOR, /* bDescriptorType */
/* Manufacturer: "Flying Stone Technology" */
'F', 0, 'l', 0, 'y', 0, 'i', 0, 'n', 0, 'g', 0, ' ', 0, 'S', 0,
't', 0, 'o', 0, 'n', 0, 'e', 0, ' ', 0, 'T', 0, 'e', 0, 'c', 0,
@@ -139,7 +139,7 @@ static const uint8_t vcom_string1[] = {
static const uint8_t vcom_string2[] = {
14*2+2, /* bLength */
- USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
+ STRING_DESCRIPTOR, /* bDescriptorType */
/* Product name: "Chopstx Sample" */
'C', 0, 'h', 0, 'o', 0, 'p', 0, 's', 0, 't', 0, 'x', 0, ' ', 0,
'S', 0, 'a', 0, 'm', 0, 'p', 0, 'l', 0, 'e', 0,
@@ -150,7 +150,7 @@ static const uint8_t vcom_string2[] = {
*/
static const uint8_t vcom_string3[28] = {
28, /* bLength */
- USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
+ STRING_DESCRIPTOR, /* bDescriptorType */
'0', 0, '.', 0, '0', 0, '0', 0, /* Version number */
};
@@ -184,7 +184,7 @@ usb_cb_device_reset (void)
#define CDC_CTRL_DTR 0x0001
void
-usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no, uint16_t value)
+usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no, struct req_args *arg)
{
uint8_t type_rcp = req & (REQUEST_TYPE|RECIPIENT);
@@ -194,7 +194,7 @@ usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no, uint16_t value)
/* Open/close the connection. */
chopstx_mutex_lock (&stream.mtx);
stream.flags &= ~FLAG_CONNECTED;
- stream.flags |= ((value & CDC_CTRL_DTR) != 0)? FLAG_CONNECTED : 0;
+ stream.flags |= ((arg->value & CDC_CTRL_DTR) != 0)? FLAG_CONNECTED : 0;
chopstx_cond_signal (&stream.cnd);
chopstx_mutex_unlock (&stream.mtx);
}
@@ -217,17 +217,17 @@ static struct line_coding line_coding = {
static int
-vcom_port_data_setup (uint8_t req, uint8_t req_no, struct control_info *detail)
+vcom_port_data_setup (uint8_t req, uint8_t req_no, struct req_args *arg)
{
if (USB_SETUP_GET (req))
{
if (req_no == USB_CDC_REQ_GET_LINE_CODING)
- return usb_lld_reply_request (&line_coding, sizeof(line_coding), detail);
+ return usb_lld_reply_request (&line_coding, sizeof(line_coding), arg);
}
else /* USB_SETUP_SET (req) */
{
if (req_no == USB_CDC_REQ_SET_LINE_CODING
- && detail->len == sizeof (line_coding))
+ && arg->len == sizeof (line_coding))
{
usb_lld_set_data_to_recv (&line_coding, sizeof (line_coding));
return USB_SUCCESS;
@@ -240,29 +240,29 @@ vcom_port_data_setup (uint8_t req, uint8_t req_no, struct control_info *detail)
}
int
-usb_cb_setup (uint8_t req, uint8_t req_no, struct control_info *detail)
+usb_cb_setup (uint8_t req, uint8_t req_no, struct req_args *arg)
{
uint8_t type_rcp = req & (REQUEST_TYPE|RECIPIENT);
- if (type_rcp == (CLASS_REQUEST | INTERFACE_RECIPIENT) && detail->index == 0)
- return vcom_port_data_setup (req, req_no, detail);
+ if (type_rcp == (CLASS_REQUEST | INTERFACE_RECIPIENT) && arg->index == 0)
+ return vcom_port_data_setup (req, req_no, arg);
return USB_UNSUPPORT;
}
int
usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
- struct control_info *detail)
+ struct req_args *arg)
{
if (rcp != DEVICE_RECIPIENT)
return USB_UNSUPPORT;
if (desc_type == DEVICE_DESCRIPTOR)
return usb_lld_reply_request (vcom_device_desc, sizeof (vcom_device_desc),
- detail);
+ arg);
else if (desc_type == CONFIG_DESCRIPTOR)
return usb_lld_reply_request (vcom_config_desc, sizeof (vcom_config_desc),
- detail);
+ arg);
else if (desc_type == STRING_DESCRIPTOR)
{
const uint8_t *str;
@@ -290,7 +290,7 @@ usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
return USB_UNSUPPORT;
}
- return usb_lld_reply_request (str, size, detail);
+ return usb_lld_reply_request (str, size, arg);
}
return USB_UNSUPPORT;
@@ -369,11 +369,11 @@ usb_cb_handle_event (uint8_t event_type, uint16_t value)
int
-usb_cb_interface (uint8_t cmd, struct control_info *detail)
+usb_cb_interface (uint8_t cmd, struct req_args *arg)
{
const uint8_t zero = 0;
- uint16_t interface = detail->index;
- uint16_t alt = detail->value;
+ uint16_t interface = arg->index;
+ uint16_t alt = arg->value;
if (interface >= NUM_INTERFACES)
return USB_UNSUPPORT;
@@ -390,7 +390,7 @@ usb_cb_interface (uint8_t cmd, struct control_info *detail)
}
case USB_GET_INTERFACE:
- return usb_lld_reply_request (&zero, 1, detail);
+ return usb_lld_reply_request (&zero, 1, arg);
default:
case USB_QUERY_INTERFACE:
diff --git a/example-cdc/usb_lld.h b/example-cdc/usb_lld.h
index fd4bc08..34a1068 100644
--- a/example-cdc/usb_lld.h
+++ b/example-cdc/usb_lld.h
@@ -1,9 +1,3 @@
-#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
-#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
-#define USB_STRING_DESCRIPTOR_TYPE 0x03
-#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
-#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
-
#define STANDARD_ENDPOINT_DESC_SIZE 0x09
/* endpoints enumeration */
@@ -24,7 +18,7 @@
enum RECIPIENT_TYPE
{
- DEVICE_RECIPIENT, /* Recipient device */
+ DEVICE_RECIPIENT = 0, /* Recipient device */
INTERFACE_RECIPIENT, /* Recipient interface */
ENDPOINT_RECIPIENT, /* Recipient endpoint */
OTHER_RECIPIENT
@@ -55,19 +49,20 @@ enum
USB_SUCCESS = 1,
};
-struct control_info {
+struct req_args {
uint16_t value;
uint16_t index;
uint16_t len;
};
void usb_cb_device_reset (void);
-int usb_cb_setup (uint8_t req, uint8_t req_no, struct control_info *detail);
-int usb_cb_interface (uint8_t cmd, struct control_info *detail);
+int usb_cb_setup (uint8_t req, uint8_t req_no, struct req_args *arg);
+int usb_cb_interface (uint8_t cmd, struct req_args *arg);
int usb_cb_get_descriptor (uint8_t rcp, uint8_t desc_type, uint8_t desc_index,
- struct control_info *detail);
+ struct req_args *arg);
int usb_cb_handle_event (uint8_t event_type, uint16_t value);
-void usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no, uint16_t value);
+void usb_cb_ctrl_write_finish (uint8_t req, uint8_t req_no,
+ struct req_args *arg);
enum {
USB_EVENT_ADDRESS,
@@ -103,7 +98,7 @@ void usb_lld_txcpy (const void *src, int ep_num, int offset, size_t len);
void usb_lld_tx_enable (int ep_num, size_t len);
void usb_lld_write (uint8_t ep_num, const void *buf, size_t len);
int usb_lld_reply_request (const void *buf, size_t buflen,
- struct control_info *ctrl);
+ struct req_args *arg);
void usb_lld_rx_enable (int ep_num);
int usb_lld_rx_data_len (int ep_num);
void usb_lld_rxcpy (uint8_t *dst, int ep_num, int offset, size_t len);
@@ -114,7 +109,7 @@ void usb_lld_setup_endpoint (int ep_num, int ep_type, int ep_kind,
void usb_lld_set_configuration (uint8_t config);
uint8_t usb_lld_current_configuration (void);
void usb_lld_set_feature (uint8_t feature);
-void usb_lld_set_data_to_recv (const void *p, size_t len);
+void usb_lld_set_data_to_recv (void *p, size_t len);
void usb_lld_prepare_shutdown (void);
void usb_lld_shutdown (void);
diff --git a/example-cdc/usb_stm32f103.c b/example-cdc/usb_stm32f103.c
index ac96dda..7df3841 100644
--- a/example-cdc/usb_stm32f103.c
+++ b/example-cdc/usb_stm32f103.c
@@ -62,6 +62,8 @@ struct DEVICE_INFO
uint8_t bRequest;
/**/
uint16_t value;
+ uint16_t index;
+ uint16_t len;
};
static struct DEVICE_INFO device_info;
@@ -462,26 +464,26 @@ static void handle_datastage_in (void)
st103_ep_set_tx_status (ENDP0, EP_TX_VALID);
}
-typedef int (*HANDLER) (uint8_t req, struct control_info *detail);
+typedef int (*HANDLER) (uint8_t req, struct req_args *arg);
-static int std_none (uint8_t req, struct control_info *detail)
+static int std_none (uint8_t req, struct req_args *arg)
{
- (void)req; (void)detail;
+ (void)req; (void)arg;
return USB_UNSUPPORT;
}
-static int std_get_status (uint8_t req, struct control_info *detail)
+static int std_get_status (uint8_t req, struct req_args *arg)
{
uint8_t rcp = req & RECIPIENT;
uint16_t status_info = 0;
- if (detail->value != 0 || detail->len != 2 || (detail->index >> 8) != 0
+ if (arg->value != 0 || arg->len != 2 || (arg->index >> 8) != 0
|| (req & REQUEST_DIR) == 0)
return USB_UNSUPPORT;
if (rcp == DEVICE_RECIPIENT)
{
- if (detail->index == 0)
+ if (arg->index == 0)
{
/* Get Device Status */
uint8_t feature = dev_p->current_feature;
@@ -498,7 +500,7 @@ static int std_get_status (uint8_t req, struct control_info *detail)
else /* Self-powered */
status_info &= ~1;
- return usb_lld_reply_request (&status_info, 2, detail);
+ return usb_lld_reply_request (&status_info, 2, arg);
}
}
else if (rcp == INTERFACE_RECIPIENT)
@@ -508,21 +510,21 @@ static int std_get_status (uint8_t req, struct control_info *detail)
if (dev_p->current_configuration == 0)
return USB_UNSUPPORT;
- r = usb_cb_interface (USB_QUERY_INTERFACE, detail);
+ r = usb_cb_interface (USB_QUERY_INTERFACE, arg);
if (r != USB_SUCCESS)
return USB_UNSUPPORT;
- return usb_lld_reply_request (&status_info, 2, detail);
+ return usb_lld_reply_request (&status_info, 2, arg);
}
else if (rcp == ENDPOINT_RECIPIENT)
{
- uint8_t endpoint = (detail->index & 0x0f);
+ uint8_t endpoint = (arg->index & 0x0f);
uint16_t status;
- if ((detail->index & 0x70) || endpoint == ENDP0)
+ if ((arg->index & 0x70) || endpoint == ENDP0)
return USB_UNSUPPORT;
- if ((detail->index & 0x80))
+ if ((arg->index & 0x80))
{
status = st103_ep_get_tx_status (endpoint);
if (status == 0) /* Disabled */
@@ -539,13 +541,13 @@ static int std_get_status (uint8_t req, struct control_info *detail)
status_info |= 1; /* OUT Endpoint stalled */
}
- return usb_lld_reply_request (&status_info, 2, detail);
+ return usb_lld_reply_request (&status_info, 2, arg);
}
return USB_UNSUPPORT;
}
-static int std_clear_feature (uint8_t req, struct control_info *detail)
+static int std_clear_feature (uint8_t req, struct req_args *arg)
{
uint8_t rcp = req & RECIPIENT;
@@ -554,10 +556,10 @@ static int std_clear_feature (uint8_t req, struct control_info *detail)
if (rcp == DEVICE_RECIPIENT)
{
- if (detail->len != 0 || detail->index != 0)
+ if (arg->len != 0 || arg->index != 0)
return USB_UNSUPPORT;
- if (detail->value == DEVICE_REMOTE_WAKEUP)
+ if (arg->value == DEVICE_REMOTE_WAKEUP)
{
dev_p->current_feature &= ~(1 << 5);
return USB_SUCCESS;
@@ -565,17 +567,17 @@ static int std_clear_feature (uint8_t req, struct control_info *detail)
}
else if (rcp == ENDPOINT_RECIPIENT)
{
- uint8_t endpoint = (detail->index & 0x0f);
+ uint8_t endpoint = (arg->index & 0x0f);
uint16_t status;
if (dev_p->current_configuration == 0)
return USB_UNSUPPORT;
- if (detail->len != 0 || (detail->index >> 8) != 0
- || detail->value != ENDPOINT_STALL || endpoint == ENDP0)
+ if (arg->len != 0 || (arg->index >> 8) != 0
+ || arg->value != ENDPOINT_STALL || endpoint == ENDP0)
return USB_UNSUPPORT;
- if ((detail->index & 0x80))
+ if ((arg->index & 0x80))
status = st103_ep_get_tx_status (endpoint);
else
status = st103_ep_get_rx_status (endpoint);
@@ -583,7 +585,7 @@ static int std_clear_feature (uint8_t req, struct control_info *detail)
if (status == 0) /* Disabled */
return USB_UNSUPPORT;
- if (detail->index & 0x80) /* IN endpoint */
+ if (arg->index & 0x80) /* IN endpoint */
st103_ep_clear_dtog_tx (endpoint);
else /* OUT endpoint */
st103_ep_clear_dtog_rx (endpoint);
@@ -595,7 +597,7 @@ static int std_clear_feature (uint8_t req, struct control_info *detail)
return USB_UNSUPPORT;
}
-static int std_set_feature (uint8_t req, struct control_info *detail)
+static int std_set_feature (uint8_t req, struct req_args *arg)
{
uint8_t rcp = req & RECIPIENT;
@@ -604,10 +606,10 @@ static int std_set_feature (uint8_t req, struct control_info *detail)
if (rcp == DEVICE_RECIPIENT)
{
- if (detail->len != 0 || detail->index != 0)
+ if (arg->len != 0 || arg->index != 0)
return USB_UNSUPPORT;
- if (detail->value == DEVICE_REMOTE_WAKEUP)
+ if (arg->value == DEVICE_REMOTE_WAKEUP)
{
dev_p->current_feature |= 1 << 5;
// event??
@@ -616,17 +618,17 @@ static int std_set_feature (uint8_t req, struct control_info *detail)
}
else if (rcp == ENDPOINT_RECIPIENT)
{
- uint8_t endpoint = (detail->index & 0x0f);
+ uint8_t endpoint = (arg->index & 0x0f);
uint32_t status;
if (dev_p->current_configuration == 0)
return USB_UNSUPPORT;
- if (detail->len != 0 || (detail->index >> 8) != 0
- || detail->value != 0 || endpoint == ENDP0)
+ if (arg->len != 0 || (arg->index >> 8) != 0
+ || arg->value != 0 || endpoint == ENDP0)
return USB_UNSUPPORT;
- if ((detail->index & 0x80))
+ if ((arg->index & 0x80))
status = st103_ep_get_tx_status (endpoint);
else
status = st103_ep_get_rx_status (endpoint);
@@ -634,7 +636,7 @@ static int std_set_feature (uint8_t req, struct control_info *detail)
if (status == 0) /* Disabled */
return USB_UNSUPPORT;
- if (detail->index & 0x80)
+ if (arg->index & 0x80)
/* IN endpoint */
st103_ep_set_tx_status (endpoint, EP_TX_STALL);
else
@@ -648,59 +650,58 @@ static int std_set_feature (uint8_t req, struct control_info *detail)
return USB_UNSUPPORT;
}
-static int std_set_address (uint8_t req, struct control_info *detail)
+static int std_set_address (uint8_t req, struct req_args *arg)
{
uint8_t rcp = req & RECIPIENT;
if ((req & REQUEST_DIR) == 1)
return USB_UNSUPPORT;
- if (rcp == DEVICE_RECIPIENT && detail->len == 0 && detail->value <= 127
- && detail->index == 0 && dev_p->current_configuration == 0)
+ if (rcp == DEVICE_RECIPIENT && arg->len == 0 && arg->value <= 127
+ && arg->index == 0 && dev_p->current_configuration == 0)
return USB_SUCCESS;
return USB_UNSUPPORT;
}
-static int std_get_descriptor (uint8_t req, struct control_info *detail)
+static int std_get_descriptor (uint8_t req, struct req_args *arg)
{
uint8_t rcp = req & RECIPIENT;
if ((req & REQUEST_DIR) == 0)
return USB_UNSUPPORT;
- return usb_cb_get_descriptor (rcp, (detail->value >> 8),
- (detail->value & 0xff), detail);
+ return usb_cb_get_descriptor (rcp, (arg->value >> 8),
+ (arg->value & 0xff), arg);
}
-static int std_get_configuration (uint8_t req, struct control_info *detail)
+static int std_get_configuration (uint8_t req, struct req_args *arg)
{
uint8_t rcp = req & RECIPIENT;
- (void)detail;
if ((req & REQUEST_DIR) == 0)
return USB_UNSUPPORT;
if (rcp == DEVICE_RECIPIENT)
- return usb_lld_reply_request (&dev_p->current_configuration, 1, detail);
+ return usb_lld_reply_request (&dev_p->current_configuration, 1, arg);
return USB_UNSUPPORT;
}
-static int std_set_configuration (uint8_t req, struct control_info *detail)
+static int std_set_configuration (uint8_t req, struct req_args *arg)
{
uint8_t rcp = req & RECIPIENT;
if ((req & REQUEST_DIR) == 1)
return USB_UNSUPPORT;
- if (rcp == DEVICE_RECIPIENT && detail->index == 0 && detail->len == 0)
- return usb_cb_handle_event (USB_EVENT_CONFIG, detail->value);
+ if (rcp == DEVICE_RECIPIENT && arg->index == 0 && arg->len == 0)
+ return usb_cb_handle_event (USB_EVENT_CONFIG, arg->value);
return USB_UNSUPPORT;
}
-static int std_get_interface (uint8_t req, struct control_info *detail)
+static int std_get_interface (uint8_t req, struct req_args *arg)
{
uint8_t rcp = req & RECIPIENT;
@@ -709,35 +710,34 @@ static int std_get_interface (uint8_t req, struct control_info *detail)
if (rcp == INTERFACE_RECIPIENT)
{
- if (detail->value != 0 || (detail->index >> 8) != 0 || detail->len != 1)
+ if (arg->value != 0 || (arg->index >> 8) != 0 || arg->len != 1)
return USB_UNSUPPORT;
if (dev_p->current_configuration == 0)
return USB_UNSUPPORT;
- return usb_cb_interface (USB_GET_INTERFACE, detail);
+ return usb_cb_interface (USB_GET_INTERFACE, arg);
}
return USB_UNSUPPORT;
}
-static int std_set_interface (uint8_t req, struct control_info *detail)
+static int std_set_interface (uint8_t req, struct req_args *arg)
{
uint8_t rcp = req & RECIPIENT;
if ((req & REQUEST_DIR) == 1 || rcp != INTERFACE_RECIPIENT
- || detail->len != 0 || (detail->index >> 8) != 0
- || (detail->value >> 8) != 0 || dev_p->current_configuration == 0)
+ || arg->len != 0 || (arg->index >> 8) != 0
+ || (arg->value >> 8) != 0 || dev_p->current_configuration == 0)
return USB_UNSUPPORT;
- return usb_cb_interface (USB_SET_INTERFACE, detail);
+ return usb_cb_interface (USB_SET_INTERFACE, arg);
}
static void handle_setup0 (void)
{
const uint16_t *pw;
- struct control_info ctrl;
uint16_t w;
uint8_t req_no;
int r = USB_UNSUPPORT;
@@ -749,11 +749,11 @@ static void handle_setup0 (void)
dev_p->bmRequestType = w & 0xff;
dev_p->bRequest = req_no = w >> 8;
pw++;
- ctrl.value = *pw++;
+ dev_p->value = *pw++;
pw++;
- ctrl.index = *pw++;
+ dev_p->index = *pw++;
pw++;
- ctrl.len = *pw;
+ dev_p->len = *pw;
data_p->addr = NULL;
data_p->len = 0;
@@ -777,11 +777,13 @@ static void handle_setup0 (void)
default: handler = std_none; break;
}
- r = (*handler) (dev_p->bmRequestType, &ctrl);
+ r = (*handler) (dev_p->bmRequestType,
+ (struct req_args *)&dev_p->value);
}
}
else
- r = usb_cb_setup (dev_p->bmRequestType, req_no, &ctrl);
+ r = usb_cb_setup (dev_p->bmRequestType, req_no,
+ (struct req_args *)&dev_p->value);
if (r != USB_SUCCESS)
dev_p->state = STALLED;
@@ -789,8 +791,7 @@ static void handle_setup0 (void)
{
if (USB_SETUP_SET (dev_p->bmRequestType))
{
- dev_p->value = ctrl.value;
- if (ctrl.len == 0)
+ if (dev_p->len == 0)
{
dev_p->state = WAIT_STATUS_IN;
st103_set_tx_count (ENDP0, 0);
@@ -819,8 +820,8 @@ static void handle_in0 (void)
usb_cb_handle_event (USB_EVENT_ADDRESS, dev_p->value);
}
else
- usb_cb_ctrl_write_finish (dev_p->bmRequestType, dev_p->bRequest,
- dev_p->value);
+ usb_cb_ctrl_write_finish (dev_p->bmRequestType, dev_p->bRequest,
+ (struct req_args *)&dev_p->value);
dev_p->state = STALLED;
}
@@ -1042,9 +1043,9 @@ void usb_lld_set_feature (uint8_t feature)
dev_p->current_feature = feature;
}
-void usb_lld_set_data_to_recv (const void *p, size_t len)
+void usb_lld_set_data_to_recv (void *p, size_t len)
{
- data_p->addr = (uint8_t *)p;
+ data_p->addr = p;
data_p->len = len;
}
@@ -1129,7 +1130,7 @@ void usb_lld_from_pmabuf (void *dst, uint16_t addr, size_t n)
* BUFLEN: size of the data.
*/
int
-usb_lld_reply_request (const void *buf, size_t buflen, struct control_info *ctl)
+usb_lld_reply_request (const void *buf, size_t buflen, struct req_args *ctl)
{
uint32_t len_asked = ctl->len;
uint32_t len;