usb: move the request handler buffer to the USB device code
In order to unify the legacy and composite code, move the class and vendor request handler buffer into the USB device code, just like in composite mode. The option is renamed from USB_COMPOSITE_BUFFER_SIZE into USB_REQUEST_BUFFER_SIZE and also replaces the USB_DFU_MAX_XFER_SIZE and USB_HID_MAX_PAYLOAD_SIZE options. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
67de7ec86d
commit
819e749ccd
20 changed files with 13 additions and 108 deletions
|
@ -71,18 +71,13 @@ config USB_DW_USB_2_0
|
||||||
default y
|
default y
|
||||||
|
|
||||||
if USB_DEVICE_HID
|
if USB_DEVICE_HID
|
||||||
config USB_HID_MAX_PAYLOAD_SIZE
|
config USB_REQUEST_BUFFER_SIZE
|
||||||
default 128
|
default 128
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config USB_COMPOSITE_BUFFER_SIZE
|
|
||||||
default 128
|
|
||||||
|
|
||||||
if USB_DFU_CLASS
|
if USB_DFU_CLASS
|
||||||
|
config USB_REQUEST_BUFFER_SIZE
|
||||||
config USB_DFU_MAX_XFER_SIZE
|
|
||||||
default 4096
|
default 4096
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
config USB_DEVICE_STACK
|
config USB_DEVICE_STACK
|
||||||
|
|
|
@ -159,19 +159,6 @@ struct usb_interface_cfg_data {
|
||||||
* handler.
|
* handler.
|
||||||
*/
|
*/
|
||||||
usb_request_handler custom_handler;
|
usb_request_handler custom_handler;
|
||||||
/**
|
|
||||||
* This data area, allocated by the application, is used to store
|
|
||||||
* Class specific command data and must be large enough to store the
|
|
||||||
* largest payload associated with the largest supported Class'
|
|
||||||
* command set. This data area may be used for USB IN or OUT
|
|
||||||
* communications.
|
|
||||||
*/
|
|
||||||
u8_t *payload_data;
|
|
||||||
/**
|
|
||||||
* This data area, allocated by the application, is used to store
|
|
||||||
* Vendor specific payload.
|
|
||||||
*/
|
|
||||||
u8_t *vendor_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,7 @@ CONFIG_USB_DEVICE_PID=0x101
|
||||||
CONFIG_GPIO=y
|
CONFIG_GPIO=y
|
||||||
CONFIG_USB=y
|
CONFIG_USB=y
|
||||||
CONFIG_USB_DEVICE_STACK=y
|
CONFIG_USB_DEVICE_STACK=y
|
||||||
|
CONFIG_USB_REQUEST_BUFFER_SIZE=300
|
||||||
CONFIG_UART_INTERRUPT_DRIVEN=y
|
CONFIG_UART_INTERRUPT_DRIVEN=y
|
||||||
|
|
||||||
CONFIG_TEST_RANDOM_GENERATOR=y
|
CONFIG_TEST_RANDOM_GENERATOR=y
|
||||||
|
|
|
@ -24,9 +24,6 @@ LOG_MODULE_REGISTER(wpanusb);
|
||||||
/* Max packet size for endpoints */
|
/* Max packet size for endpoints */
|
||||||
#define WPANUSB_BULK_EP_MPS 64
|
#define WPANUSB_BULK_EP_MPS 64
|
||||||
|
|
||||||
/* Max wpanusb command data size */
|
|
||||||
#define WPANUSB_CLASS_MAX_DATA_SIZE 100
|
|
||||||
|
|
||||||
#define WPANUSB_ENDP_BULK_IN 0x81
|
#define WPANUSB_ENDP_BULK_IN 0x81
|
||||||
|
|
||||||
static struct ieee802154_radio_api *radio_api;
|
static struct ieee802154_radio_api *radio_api;
|
||||||
|
@ -37,8 +34,6 @@ static struct k_fifo tx_queue;
|
||||||
/* IEEE802.15.4 frame + 1 byte len + 1 byte LQI */
|
/* IEEE802.15.4 frame + 1 byte len + 1 byte LQI */
|
||||||
u8_t tx_buf[IEEE802154_MTU + 1 + 1];
|
u8_t tx_buf[IEEE802154_MTU + 1 + 1];
|
||||||
|
|
||||||
u8_t interface_data[WPANUSB_CLASS_MAX_DATA_SIZE];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stack for the tx thread.
|
* Stack for the tx thread.
|
||||||
*/
|
*/
|
||||||
|
@ -359,16 +354,11 @@ static void tx_thread(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: FIXME: correct buffer size */
|
|
||||||
static u8_t buffer[300];
|
|
||||||
|
|
||||||
static struct usb_cfg_data wpanusb_config = {
|
static struct usb_cfg_data wpanusb_config = {
|
||||||
.usb_device_description = (u8_t *)&wpanusb_desc,
|
.usb_device_description = (u8_t *)&wpanusb_desc,
|
||||||
.cb_usb_status = wpanusb_status_cb,
|
.cb_usb_status = wpanusb_status_cb,
|
||||||
.interface = {
|
.interface = {
|
||||||
.vendor_handler = wpanusb_vendor_handler,
|
.vendor_handler = wpanusb_vendor_handler,
|
||||||
.vendor_data = buffer,
|
|
||||||
.payload_data = interface_data,
|
|
||||||
.class_handler = NULL,
|
.class_handler = NULL,
|
||||||
.custom_handler = NULL,
|
.custom_handler = NULL,
|
||||||
},
|
},
|
||||||
|
|
|
@ -24,8 +24,6 @@ LOG_MODULE_REGISTER(webusb);
|
||||||
|
|
||||||
/* Max packet size for Bulk endpoints */
|
/* Max packet size for Bulk endpoints */
|
||||||
#define CDC_BULK_EP_MPS 64
|
#define CDC_BULK_EP_MPS 64
|
||||||
/* Max CDC ACM class request max data size */
|
|
||||||
#define CDC_CLASS_REQ_MAX_DATA_SIZE 8
|
|
||||||
/* Number of interfaces */
|
/* Number of interfaces */
|
||||||
#define WEBUSB_NUM_ITF 0x01
|
#define WEBUSB_NUM_ITF 0x01
|
||||||
/* Number of Endpoints in the custom interface */
|
/* Number of Endpoints in the custom interface */
|
||||||
|
@ -35,8 +33,6 @@ LOG_MODULE_REGISTER(webusb);
|
||||||
|
|
||||||
static struct webusb_req_handlers *req_handlers;
|
static struct webusb_req_handlers *req_handlers;
|
||||||
|
|
||||||
u8_t interface_data[CDC_CLASS_REQ_MAX_DATA_SIZE];
|
|
||||||
|
|
||||||
u8_t rx_buf[64];
|
u8_t rx_buf[64];
|
||||||
|
|
||||||
/* Structure representing the global USB description */
|
/* Structure representing the global USB description */
|
||||||
|
@ -312,8 +308,6 @@ USBD_CFG_DATA_DEFINE(webusb) struct usb_cfg_data webusb_config = {
|
||||||
.class_handler = NULL,
|
.class_handler = NULL,
|
||||||
.custom_handler = webusb_custom_handle_req,
|
.custom_handler = webusb_custom_handle_req,
|
||||||
.vendor_handler = webusb_vendor_handle_req,
|
.vendor_handler = webusb_vendor_handle_req,
|
||||||
.vendor_data = interface_data,
|
|
||||||
.payload_data = interface_data,
|
|
||||||
},
|
},
|
||||||
.num_endpoints = ARRAY_SIZE(webusb_ep_data),
|
.num_endpoints = ARRAY_SIZE(webusb_ep_data),
|
||||||
.endpoint = webusb_ep_data
|
.endpoint = webusb_ep_data
|
||||||
|
|
|
@ -57,9 +57,8 @@ config USB_COMPOSITE_DEVICE
|
||||||
help
|
help
|
||||||
Enable composite USB device driver.
|
Enable composite USB device driver.
|
||||||
|
|
||||||
config USB_COMPOSITE_BUFFER_SIZE
|
config USB_REQUEST_BUFFER_SIZE
|
||||||
int "Set buffer size for Class Handler"
|
int "Set buffer size for Class and Vendor request handlers"
|
||||||
depends on USB_COMPOSITE_DEVICE
|
|
||||||
default 256 if USB_DEVICE_NETWORK_RNDIS
|
default 256 if USB_DEVICE_NETWORK_RNDIS
|
||||||
default 64
|
default 64
|
||||||
|
|
||||||
|
|
|
@ -141,11 +141,6 @@ config USB_DFU_WAIT_DELAY_MS
|
||||||
help
|
help
|
||||||
A thread can wait for a prescribed time (in ms) for DFU to begin
|
A thread can wait for a prescribed time (in ms) for DFU to begin
|
||||||
|
|
||||||
config USB_DFU_MAX_XFER_SIZE
|
|
||||||
int
|
|
||||||
depends on USB_DFU_CLASS
|
|
||||||
default 64
|
|
||||||
|
|
||||||
config USB_DFU_DETACH_TIMEOUT
|
config USB_DFU_DETACH_TIMEOUT
|
||||||
int
|
int
|
||||||
depends on USB_DFU_CLASS
|
depends on USB_DFU_CLASS
|
||||||
|
|
|
@ -23,10 +23,6 @@
|
||||||
#include <logging/log.h>
|
#include <logging/log.h>
|
||||||
LOG_MODULE_REGISTER(usb_bluetooth);
|
LOG_MODULE_REGISTER(usb_bluetooth);
|
||||||
|
|
||||||
#if !defined(CONFIG_USB_COMPOSITE_DEVICE)
|
|
||||||
static u8_t interface_data[64];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static K_FIFO_DEFINE(rx_queue);
|
static K_FIFO_DEFINE(rx_queue);
|
||||||
static K_FIFO_DEFINE(tx_queue);
|
static K_FIFO_DEFINE(tx_queue);
|
||||||
|
|
||||||
|
@ -300,7 +296,6 @@ USBD_CFG_DATA_DEFINE(hci) struct usb_cfg_data bluetooth_config = {
|
||||||
.class_handler = bluetooth_class_handler,
|
.class_handler = bluetooth_class_handler,
|
||||||
.custom_handler = NULL,
|
.custom_handler = NULL,
|
||||||
.vendor_handler = NULL,
|
.vendor_handler = NULL,
|
||||||
.payload_data = NULL,
|
|
||||||
},
|
},
|
||||||
.num_endpoints = ARRAY_SIZE(bluetooth_ep_data),
|
.num_endpoints = ARRAY_SIZE(bluetooth_ep_data),
|
||||||
.endpoint = bluetooth_ep_data,
|
.endpoint = bluetooth_ep_data,
|
||||||
|
@ -319,7 +314,6 @@ static int bluetooth_init(struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
||||||
bluetooth_config.interface.payload_data = interface_data;
|
|
||||||
bluetooth_config.usb_device_description =
|
bluetooth_config.usb_device_description =
|
||||||
usb_get_device_descriptor();
|
usb_get_device_descriptor();
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
|
|
|
@ -67,9 +67,6 @@ LOG_MODULE_REGISTER(usb_cdc_acm);
|
||||||
/* Size of the internal buffer used for storing received data */
|
/* Size of the internal buffer used for storing received data */
|
||||||
#define CDC_ACM_BUFFER_SIZE (CONFIG_CDC_ACM_BULK_EP_MPS)
|
#define CDC_ACM_BUFFER_SIZE (CONFIG_CDC_ACM_BULK_EP_MPS)
|
||||||
|
|
||||||
/* Max CDC ACM class request max data size */
|
|
||||||
#define CDC_CLASS_REQ_MAX_DATA_SIZE 8
|
|
||||||
|
|
||||||
/* Serial state notification timeout */
|
/* Serial state notification timeout */
|
||||||
#define CDC_CONTROL_SERIAL_STATE_TIMEOUT_US 100000
|
#define CDC_CONTROL_SERIAL_STATE_TIMEOUT_US 100000
|
||||||
|
|
||||||
|
@ -189,9 +186,6 @@ struct cdc_acm_dev_data_t {
|
||||||
struct ring_buf *rx_ringbuf;
|
struct ring_buf *rx_ringbuf;
|
||||||
struct ring_buf *tx_ringbuf;
|
struct ring_buf *tx_ringbuf;
|
||||||
/* Interface data buffer */
|
/* Interface data buffer */
|
||||||
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
|
||||||
u8_t interface_data[CDC_CLASS_REQ_MAX_DATA_SIZE];
|
|
||||||
#endif
|
|
||||||
/* CDC ACM line coding properties. LE order */
|
/* CDC ACM line coding properties. LE order */
|
||||||
struct cdc_acm_line_coding line_coding;
|
struct cdc_acm_line_coding line_coding;
|
||||||
/* CDC ACM line state bitmap, DTE side */
|
/* CDC ACM line state bitmap, DTE side */
|
||||||
|
@ -531,7 +525,6 @@ static int cdc_acm_init(struct device *dev)
|
||||||
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
||||||
struct usb_cfg_data *cfg = (void *)dev->config->config_info;
|
struct usb_cfg_data *cfg = (void *)dev->config->config_info;
|
||||||
|
|
||||||
cfg->interface.payload_data = dev_data->interface_data;
|
|
||||||
cfg->usb_device_description = usb_get_device_descriptor();
|
cfg->usb_device_description = usb_get_device_descriptor();
|
||||||
|
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
|
@ -1001,7 +994,6 @@ static const struct uart_driver_api cdc_acm_driver_api = {
|
||||||
.interface = { \
|
.interface = { \
|
||||||
.class_handler = cdc_acm_class_handle_req, \
|
.class_handler = cdc_acm_class_handle_req, \
|
||||||
.custom_handler = NULL, \
|
.custom_handler = NULL, \
|
||||||
.payload_data = NULL, \
|
|
||||||
}, \
|
}, \
|
||||||
.num_endpoints = ARRAY_SIZE(cdc_acm_ep_data_##x), \
|
.num_endpoints = ARRAY_SIZE(cdc_acm_ep_data_##x), \
|
||||||
.endpoint = cdc_acm_ep_data_##x, \
|
.endpoint = cdc_acm_ep_data_##x, \
|
||||||
|
|
|
@ -36,12 +36,6 @@ config HID_INTERRUPT_EP_MPS
|
||||||
help
|
help
|
||||||
USB HID Device interrupt endpoint size
|
USB HID Device interrupt endpoint size
|
||||||
|
|
||||||
config USB_HID_MAX_PAYLOAD_SIZE
|
|
||||||
int
|
|
||||||
default 64
|
|
||||||
help
|
|
||||||
Max allowed payload size over USB HID Class
|
|
||||||
|
|
||||||
config USB_HID_POLL_INTERVAL_MS
|
config USB_HID_POLL_INTERVAL_MS
|
||||||
int "Polling interval"
|
int "Polling interval"
|
||||||
default 9
|
default 9
|
||||||
|
|
|
@ -640,16 +640,11 @@ static void hid_interface_config(struct usb_desc_header *head,
|
||||||
.interface = { \
|
.interface = { \
|
||||||
.class_handler = hid_class_handle_req, \
|
.class_handler = hid_class_handle_req, \
|
||||||
.custom_handler = hid_custom_handle_req, \
|
.custom_handler = hid_custom_handle_req, \
|
||||||
.payload_data = NULL, \
|
|
||||||
}, \
|
}, \
|
||||||
.num_endpoints = ARRAY_SIZE(hid_ep_data_##x), \
|
.num_endpoints = ARRAY_SIZE(hid_ep_data_##x), \
|
||||||
.endpoint = hid_ep_data_##x, \
|
.endpoint = hid_ep_data_##x, \
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(CONFIG_USB_COMPOSITE_DEVICE)
|
|
||||||
static u8_t interface_data[CONFIG_USB_HID_MAX_PAYLOAD_SIZE];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int usb_hid_init(const struct device *dev)
|
int usb_hid_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
struct usb_cfg_data *cfg = (void *)dev->config->config_info;
|
struct usb_cfg_data *cfg = (void *)dev->config->config_info;
|
||||||
|
@ -665,7 +660,6 @@ int usb_hid_init(const struct device *dev)
|
||||||
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
cfg->interface.payload_data = interface_data;
|
|
||||||
cfg->usb_device_description = usb_get_device_descriptor();
|
cfg->usb_device_description = usb_get_device_descriptor();
|
||||||
|
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
|
|
|
@ -23,10 +23,6 @@ LOG_MODULE_REGISTER(usb_loopback);
|
||||||
#define LOOPBACK_OUT_EP_IDX 0
|
#define LOOPBACK_OUT_EP_IDX 0
|
||||||
#define LOOPBACK_IN_EP_IDX 1
|
#define LOOPBACK_IN_EP_IDX 1
|
||||||
|
|
||||||
#if !defined(CONFIG_USB_COMPOSITE_DEVICE)
|
|
||||||
static u8_t interface_data[64];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static u8_t loopback_buf[1024];
|
static u8_t loopback_buf[1024];
|
||||||
|
|
||||||
/* usb.rst config structure start */
|
/* usb.rst config structure start */
|
||||||
|
@ -179,8 +175,6 @@ USBD_CFG_DATA_DEFINE(loopback) struct usb_cfg_data loopback_config = {
|
||||||
.class_handler = NULL,
|
.class_handler = NULL,
|
||||||
.custom_handler = NULL,
|
.custom_handler = NULL,
|
||||||
.vendor_handler = loopback_vendor_handler,
|
.vendor_handler = loopback_vendor_handler,
|
||||||
.vendor_data = loopback_buf,
|
|
||||||
.payload_data = NULL,
|
|
||||||
},
|
},
|
||||||
.num_endpoints = ARRAY_SIZE(ep_cfg),
|
.num_endpoints = ARRAY_SIZE(ep_cfg),
|
||||||
.endpoint = ep_cfg,
|
.endpoint = ep_cfg,
|
||||||
|
@ -192,7 +186,6 @@ static int loopback_init(struct device *dev)
|
||||||
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
loopback_config.interface.payload_data = interface_data;
|
|
||||||
loopback_config.usb_device_description = usb_get_device_descriptor();
|
loopback_config.usb_device_description = usb_get_device_descriptor();
|
||||||
|
|
||||||
/* usb.rst configure USB controller start */
|
/* usb.rst configure USB controller start */
|
||||||
|
|
|
@ -862,7 +862,6 @@ USBD_CFG_DATA_DEFINE(msd) struct usb_cfg_data mass_storage_config = {
|
||||||
.interface = {
|
.interface = {
|
||||||
.class_handler = mass_storage_class_handle_req,
|
.class_handler = mass_storage_class_handle_req,
|
||||||
.custom_handler = NULL,
|
.custom_handler = NULL,
|
||||||
.payload_data = NULL,
|
|
||||||
},
|
},
|
||||||
.num_endpoints = ARRAY_SIZE(mass_ep_data),
|
.num_endpoints = ARRAY_SIZE(mass_ep_data),
|
||||||
.endpoint = mass_ep_data
|
.endpoint = mass_ep_data
|
||||||
|
@ -901,10 +900,6 @@ static void mass_thread_main(int arg1, int unused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
|
||||||
static u8_t interface_data[64];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialize USB mass storage setup
|
* @brief Initialize USB mass storage setup
|
||||||
*
|
*
|
||||||
|
@ -957,7 +952,6 @@ static int mass_storage_init(struct device *dev)
|
||||||
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
#ifndef CONFIG_USB_COMPOSITE_DEVICE
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mass_storage_config.interface.payload_data = interface_data;
|
|
||||||
mass_storage_config.usb_device_description =
|
mass_storage_config.usb_device_description =
|
||||||
usb_get_device_descriptor();
|
usb_get_device_descriptor();
|
||||||
/* Initialize the USB driver with the right configuration */
|
/* Initialize the USB driver with the right configuration */
|
||||||
|
|
|
@ -437,7 +437,6 @@ USBD_CFG_DATA_DEFINE(netusb) struct usb_cfg_data netusb_config = {
|
||||||
.class_handler = ecm_class_handler,
|
.class_handler = ecm_class_handler,
|
||||||
.custom_handler = NULL,
|
.custom_handler = NULL,
|
||||||
.vendor_handler = NULL,
|
.vendor_handler = NULL,
|
||||||
.payload_data = NULL,
|
|
||||||
},
|
},
|
||||||
.num_endpoints = ARRAY_SIZE(ecm_ep_data),
|
.num_endpoints = ARRAY_SIZE(ecm_ep_data),
|
||||||
.endpoint = ecm_ep_data,
|
.endpoint = ecm_ep_data,
|
||||||
|
|
|
@ -286,7 +286,6 @@ USBD_CFG_DATA_DEFINE(netusb) struct usb_cfg_data netusb_config = {
|
||||||
.class_handler = NULL,
|
.class_handler = NULL,
|
||||||
.custom_handler = NULL,
|
.custom_handler = NULL,
|
||||||
.vendor_handler = NULL,
|
.vendor_handler = NULL,
|
||||||
.payload_data = NULL,
|
|
||||||
},
|
},
|
||||||
.num_endpoints = ARRAY_SIZE(eem_ep_data),
|
.num_endpoints = ARRAY_SIZE(eem_ep_data),
|
||||||
.endpoint = eem_ep_data,
|
.endpoint = eem_ep_data,
|
||||||
|
|
|
@ -1173,7 +1173,6 @@ USBD_CFG_DATA_DEFINE(netusb) struct usb_cfg_data netusb_config = {
|
||||||
.class_handler = rndis_class_handler,
|
.class_handler = rndis_class_handler,
|
||||||
.custom_handler = NULL,
|
.custom_handler = NULL,
|
||||||
.vendor_handler = NULL,
|
.vendor_handler = NULL,
|
||||||
.payload_data = NULL,
|
|
||||||
},
|
},
|
||||||
.num_endpoints = ARRAY_SIZE(rndis_ep_data),
|
.num_endpoints = ARRAY_SIZE(rndis_ep_data),
|
||||||
.endpoint = rndis_ep_data,
|
.endpoint = rndis_ep_data,
|
||||||
|
|
|
@ -26,11 +26,6 @@ static struct __netusb {
|
||||||
const struct netusb_function *func;
|
const struct netusb_function *func;
|
||||||
} netusb;
|
} netusb;
|
||||||
|
|
||||||
#if !defined(CONFIG_USB_COMPOSITE_DEVICE)
|
|
||||||
/* TODO: FIXME: correct buffer size */
|
|
||||||
static u8_t interface_data[300];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int netusb_send(struct device *dev, struct net_pkt *pkt)
|
static int netusb_send(struct device *dev, struct net_pkt *pkt)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -154,7 +149,6 @@ static void netusb_init(struct net_if *iface)
|
||||||
|
|
||||||
LOG_DBG("Registering function %u", i);
|
LOG_DBG("Registering function %u", i);
|
||||||
|
|
||||||
cfg->interface.payload_data = interface_data;
|
|
||||||
cfg->usb_device_description = usb_get_device_descriptor();
|
cfg->usb_device_description = usb_get_device_descriptor();
|
||||||
|
|
||||||
ret = usb_set_config(cfg);
|
ret = usb_set_config(cfg);
|
||||||
|
|
|
@ -58,12 +58,7 @@ LOG_MODULE_REGISTER(usb_dfu);
|
||||||
|
|
||||||
#define NUMOF_ALTERNATE_SETTINGS 2
|
#define NUMOF_ALTERNATE_SETTINGS 2
|
||||||
|
|
||||||
#ifdef CONFIG_USB_COMPOSITE_DEVICE
|
#define USB_DFU_MAX_XFER_SIZE CONFIG_USB_REQUEST_BUFFER_SIZE
|
||||||
#define USB_DFU_MAX_XFER_SIZE (MIN(CONFIG_USB_COMPOSITE_BUFFER_SIZE, \
|
|
||||||
CONFIG_USB_DFU_MAX_XFER_SIZE))
|
|
||||||
#else
|
|
||||||
#define USB_DFU_MAX_XFER_SIZE CONFIG_USB_DFU_MAX_XFER_SIZE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FIRMWARE_IMAGE_0_LABEL "image-1"
|
#define FIRMWARE_IMAGE_0_LABEL "image-1"
|
||||||
#define FIRMWARE_IMAGE_1_LABEL "image-0"
|
#define FIRMWARE_IMAGE_1_LABEL "image-0"
|
||||||
|
@ -711,7 +706,6 @@ USBD_CFG_DATA_DEFINE(dfu) struct usb_cfg_data dfu_config = {
|
||||||
.interface = {
|
.interface = {
|
||||||
.class_handler = dfu_class_handle_req,
|
.class_handler = dfu_class_handle_req,
|
||||||
.custom_handler = dfu_custom_handle_req,
|
.custom_handler = dfu_custom_handle_req,
|
||||||
.payload_data = dfu_data.buffer,
|
|
||||||
},
|
},
|
||||||
.num_endpoints = 0,
|
.num_endpoints = 0,
|
||||||
};
|
};
|
||||||
|
@ -728,7 +722,6 @@ USBD_CFG_DATA_DEFINE(dfu_mode) struct usb_cfg_data dfu_mode_config = {
|
||||||
.interface = {
|
.interface = {
|
||||||
.class_handler = dfu_class_handle_req,
|
.class_handler = dfu_class_handle_req,
|
||||||
.custom_handler = dfu_custom_handle_req,
|
.custom_handler = dfu_custom_handle_req,
|
||||||
.payload_data = dfu_data.buffer,
|
|
||||||
},
|
},
|
||||||
.num_endpoints = 0,
|
.num_endpoints = 0,
|
||||||
};
|
};
|
||||||
|
|
|
@ -158,6 +158,9 @@ static struct usb_dev_priv {
|
||||||
u8_t *data_store[MAX_NUM_REQ_HANDLERS];
|
u8_t *data_store[MAX_NUM_REQ_HANDLERS];
|
||||||
/* Buffer used for storing standard usb request data */
|
/* Buffer used for storing standard usb request data */
|
||||||
u8_t std_req_data[MAX_STD_REQ_MSG_SIZE];
|
u8_t std_req_data[MAX_STD_REQ_MSG_SIZE];
|
||||||
|
/* Buffer used for storing class and vendor request data */
|
||||||
|
u8_t class_vendor_req_data[CONFIG_USB_REQUEST_BUFFER_SIZE];
|
||||||
|
|
||||||
/** Variable to check whether the usb has been enabled */
|
/** Variable to check whether the usb has been enabled */
|
||||||
bool enabled;
|
bool enabled;
|
||||||
/** Variable to check whether the usb has been configured */
|
/** Variable to check whether the usb has been configured */
|
||||||
|
@ -1043,14 +1046,14 @@ int usb_set_config(struct usb_cfg_data *config)
|
||||||
if (config->interface.class_handler != NULL) {
|
if (config->interface.class_handler != NULL) {
|
||||||
usb_register_request_handler(REQTYPE_TYPE_CLASS,
|
usb_register_request_handler(REQTYPE_TYPE_CLASS,
|
||||||
config->interface.class_handler,
|
config->interface.class_handler,
|
||||||
config->interface.payload_data);
|
usb_dev.class_vendor_req_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* register vendor request handler */
|
/* register vendor request handler */
|
||||||
if (config->interface.vendor_handler || usb_os_desc_enabled()) {
|
if (config->interface.vendor_handler || usb_os_desc_enabled()) {
|
||||||
usb_register_request_handler(REQTYPE_TYPE_VENDOR,
|
usb_register_request_handler(REQTYPE_TYPE_VENDOR,
|
||||||
usb_handle_vendor_request,
|
usb_handle_vendor_request,
|
||||||
config->interface.vendor_data);
|
usb_dev.class_vendor_req_data);
|
||||||
|
|
||||||
if (config->interface.vendor_handler) {
|
if (config->interface.vendor_handler) {
|
||||||
usb_dev.vendor_req_handler =
|
usb_dev.vendor_req_handler =
|
||||||
|
@ -1522,8 +1525,6 @@ int usb_wakeup_request(void)
|
||||||
|
|
||||||
#ifdef CONFIG_USB_COMPOSITE_DEVICE
|
#ifdef CONFIG_USB_COMPOSITE_DEVICE
|
||||||
|
|
||||||
static u8_t iface_data_buf[CONFIG_USB_COMPOSITE_BUFFER_SIZE];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The functions class_handler(), custom_handler() and vendor_handler()
|
* The functions class_handler(), custom_handler() and vendor_handler()
|
||||||
* go through the interfaces one after the other and compare the
|
* go through the interfaces one after the other and compare the
|
||||||
|
@ -1659,12 +1660,12 @@ static int usb_composite_init(struct device *dev)
|
||||||
/* register class request handlers for each interface*/
|
/* register class request handlers for each interface*/
|
||||||
usb_register_request_handler(REQTYPE_TYPE_CLASS,
|
usb_register_request_handler(REQTYPE_TYPE_CLASS,
|
||||||
class_handler,
|
class_handler,
|
||||||
iface_data_buf);
|
usb_dev.class_vendor_req_data);
|
||||||
|
|
||||||
/* register vendor request handlers */
|
/* register vendor request handlers */
|
||||||
usb_register_request_handler(REQTYPE_TYPE_VENDOR,
|
usb_register_request_handler(REQTYPE_TYPE_VENDOR,
|
||||||
vendor_handler,
|
vendor_handler,
|
||||||
iface_data_buf);
|
usb_dev.class_vendor_req_data);
|
||||||
|
|
||||||
/* register class request handlers for each interface*/
|
/* register class request handlers for each interface*/
|
||||||
usb_register_custom_req_handler(custom_handler);
|
usb_register_custom_req_handler(custom_handler);
|
||||||
|
|
|
@ -101,8 +101,6 @@ struct usb_test_config {
|
||||||
.class_handler = NULL, \
|
.class_handler = NULL, \
|
||||||
.custom_handler = NULL, \
|
.custom_handler = NULL, \
|
||||||
.vendor_handler = NULL, \
|
.vendor_handler = NULL, \
|
||||||
.vendor_data = NULL, \
|
|
||||||
.payload_data = NULL, \
|
|
||||||
}, \
|
}, \
|
||||||
.num_endpoints = ARRAY_SIZE(ep_cfg_##x), \
|
.num_endpoints = ARRAY_SIZE(ep_cfg_##x), \
|
||||||
.endpoint = ep_cfg_##x, \
|
.endpoint = ep_cfg_##x, \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue