summaryrefslogtreecommitdiff
path: root/common/usbx_host_classes
diff options
context:
space:
mode:
Diffstat (limited to 'common/usbx_host_classes')
-rw-r--r--common/usbx_host_classes/CMakeLists.txt1
-rw-r--r--common/usbx_host_classes/inc/ux_host_class_cdc_ecm.h17
-rw-r--r--common/usbx_host_classes/inc/ux_host_class_printer.h2
-rwxr-xr-x[-rw-r--r--]common/usbx_host_classes/inc/ux_host_class_storage.h0
-rw-r--r--common/usbx_host_classes/src/ux_host_class_cdc_ecm_activate.c22
-rw-r--r--common/usbx_host_classes/src/ux_host_class_cdc_ecm_deactivate.c10
-rw-r--r--common/usbx_host_classes/src/ux_host_class_cdc_ecm_thread.c39
-rw-r--r--common/usbx_host_classes/src/ux_host_class_cdc_ecm_transmission_callback.c22
-rw-r--r--common/usbx_host_classes/src/ux_host_class_hub_port_change_connection_process.c57
-rw-r--r--common/usbx_host_classes/src/ux_host_class_printer_device_id_get.c132
-rw-r--r--common/usbx_host_classes/src/ux_host_class_printer_name_get.c17
-rw-r--r--common/usbx_host_classes/src/ux_host_class_printer_soft_reset.c25
-rw-r--r--common/usbx_host_classes/src/ux_host_class_printer_status_get.c25
-rwxr-xr-x[-rw-r--r--]common/usbx_host_classes/src/ux_host_class_storage_entry.c0
-rwxr-xr-x[-rw-r--r--]common/usbx_host_classes/src/ux_host_class_storage_partition_read.c0
-rwxr-xr-x[-rw-r--r--]common/usbx_host_classes/src/ux_host_class_video_frame_interval_get.c0
16 files changed, 335 insertions, 34 deletions
diff --git a/common/usbx_host_classes/CMakeLists.txt b/common/usbx_host_classes/CMakeLists.txt
index 35edc22..4088019 100644
--- a/common/usbx_host_classes/CMakeLists.txt
+++ b/common/usbx_host_classes/CMakeLists.txt
@@ -167,6 +167,7 @@ target_sources(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_printer_activate.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_printer_configure.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_printer_deactivate.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_printer_device_id_get.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_printer_endpoints_get.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_printer_entry.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_printer_name_get.c
diff --git a/common/usbx_host_classes/inc/ux_host_class_cdc_ecm.h b/common/usbx_host_classes/inc/ux_host_class_cdc_ecm.h
index ae5e1c8..f139d03 100644
--- a/common/usbx_host_classes/inc/ux_host_class_cdc_ecm.h
+++ b/common/usbx_host_classes/inc/ux_host_class_cdc_ecm.h
@@ -26,7 +26,7 @@
/* COMPONENT DEFINITION RELEASE */
/* */
/* ux_host_class_cdc_ecm.h PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -46,6 +46,10 @@
/* TX symbols instead of using */
/* them directly, */
/* resulting in version 6.1 */
+/* 02-02-2021 Xiuwen Cai Modified comment(s), added */
+/* compile option for using */
+/* packet pool from NetX, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
@@ -210,6 +214,12 @@
#define UX_HOST_CLASS_CDC_ECM_PACKET_POOL_WAIT 1000
#endif
+/* Define packet pool waiting time in milliseconds. */
+
+#ifndef UX_HOST_CLASS_CDC_ECM_PACKET_POOL_INSTANCE_WAIT
+#define UX_HOST_CLASS_CDC_ECM_PACKET_POOL_INSTANCE_WAIT 100
+#endif
+
/* Define CDC_ECM Class instance structure. */
typedef struct UX_HOST_CLASS_CDC_ECM_STRUCT
@@ -246,8 +256,13 @@ typedef struct UX_HOST_CLASS_CDC_ECM_STRUCT
ULONG ux_host_class_cdc_ecm_link_state;
NX_PACKET *ux_host_class_cdc_ecm_xmit_queue_head;
NX_PACKET *ux_host_class_cdc_ecm_xmit_queue_tail;
+#ifndef UX_HOST_CLASS_CDC_ECM_USE_PACKET_POOL_FROM_NETX
NX_PACKET_POOL ux_host_class_cdc_ecm_packet_pool;
UCHAR *ux_host_class_cdc_ecm_pool_memory;
+#else
+ NX_PACKET_POOL *ux_host_class_cdc_ecm_packet_pool;
+#endif
+
UCHAR ux_host_class_cdc_ecm_node_id[UX_HOST_CLASS_CDC_ECM_NODE_ID_LENGTH];
VOID (*ux_host_class_cdc_ecm_device_status_change_callback)(struct UX_HOST_CLASS_CDC_ECM_STRUCT *cdc_ecm,
ULONG device_state);
diff --git a/common/usbx_host_classes/inc/ux_host_class_printer.h b/common/usbx_host_classes/inc/ux_host_class_printer.h
index 8caa2eb..933c5ba 100644
--- a/common/usbx_host_classes/inc/ux_host_class_printer.h
+++ b/common/usbx_host_classes/inc/ux_host_class_printer.h
@@ -103,6 +103,7 @@ UINT _ux_host_class_printer_deactivate(UX_HOST_CLASS_COMMAND *command);
UINT _ux_host_class_printer_endpoints_get(UX_HOST_CLASS_PRINTER *printer);
UINT _ux_host_class_printer_entry(UX_HOST_CLASS_COMMAND *command);
UINT _ux_host_class_printer_name_get(UX_HOST_CLASS_PRINTER *printer);
+UINT _ux_host_class_printer_device_id_get(UX_HOST_CLASS_PRINTER *printer, UCHAR *descriptor_buffer, ULONG length);
UINT _ux_host_class_printer_read (UX_HOST_CLASS_PRINTER *printer, UCHAR *data_pointer,
ULONG requested_length, ULONG *actual_length);
UINT _ux_host_class_printer_soft_reset(UX_HOST_CLASS_PRINTER *printer);
@@ -114,6 +115,7 @@ UINT _ux_host_class_printer_write(UX_HOST_CLASS_PRINTER *printer, UCHAR * dat
#define ux_host_class_printer_activate _ux_host_class_printer_activate
#define ux_host_class_printer_name_get _ux_host_class_printer_name_get
+#define ux_host_class_printer_device_id_get _ux_host_class_printer_device_id_get
#define ux_host_class_printer_read _ux_host_class_printer_read
#define ux_host_class_printer_soft_reset _ux_host_class_printer_soft_reset
#define ux_host_class_printer_status_get _ux_host_class_printer_status_get
diff --git a/common/usbx_host_classes/inc/ux_host_class_storage.h b/common/usbx_host_classes/inc/ux_host_class_storage.h
index 977d66c..977d66c 100644..100755
--- a/common/usbx_host_classes/inc/ux_host_class_storage.h
+++ b/common/usbx_host_classes/inc/ux_host_class_storage.h
diff --git a/common/usbx_host_classes/src/ux_host_class_cdc_ecm_activate.c b/common/usbx_host_classes/src/ux_host_class_cdc_ecm_activate.c
index 91b7f5b..cdc9b39 100644
--- a/common/usbx_host_classes/src/ux_host_class_cdc_ecm_activate.c
+++ b/common/usbx_host_classes/src/ux_host_class_cdc_ecm_activate.c
@@ -36,7 +36,7 @@ UX_HOST_CLASS_CDC_ECM_NX_ETHERNET_POOL_ALLOCSIZE_ASSERT
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_cdc_ecm_activate PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -85,6 +85,10 @@ UX_HOST_CLASS_CDC_ECM_NX_ETHERNET_POOL_ALLOCSIZE_ASSERT
/* TX symbols instead of using */
/* them directly, */
/* resulting in version 6.1 */
+/* 02-02-2021 Xiuwen Cai Modified comment(s), added */
+/* compile option for using */
+/* packet pool from NetX, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_class_cdc_ecm_activate(UX_HOST_CLASS_COMMAND *command)
@@ -193,7 +197,7 @@ UX_INTERFACE *cur_interface;
if (cdc_ecm -> ux_host_class_cdc_ecm_thread_stack == UX_NULL)
status = UX_MEMORY_INSUFFICIENT;
}
-
+#ifndef UX_HOST_CLASS_CDC_ECM_USE_PACKET_POOL_FROM_NETX
if (status == UX_SUCCESS)
{
@@ -205,7 +209,7 @@ UX_INTERFACE *cur_interface;
if (cdc_ecm -> ux_host_class_cdc_ecm_pool_memory == UX_NULL)
status = UX_MEMORY_INSUFFICIENT;
}
-
+#endif
if (status == UX_SUCCESS)
{
@@ -225,13 +229,13 @@ UX_INTERFACE *cur_interface;
status = _ux_utility_semaphore_create(&cdc_ecm -> ux_host_class_cdc_ecm_interrupt_notification_semaphore, "host CDC-ECM interrupt notification semaphore", 0);
if (status == UX_SUCCESS)
{
-
+#ifndef UX_HOST_CLASS_CDC_ECM_USE_PACKET_POOL_FROM_NETX
/* Create a packet pool. */
status = nx_packet_pool_create(&cdc_ecm -> ux_host_class_cdc_ecm_packet_pool, "host CDC-ECM packet pool",
UX_HOST_CLASS_CDC_ECM_NX_PAYLOAD_SIZE, cdc_ecm -> ux_host_class_cdc_ecm_pool_memory, UX_HOST_CLASS_CDC_ECM_NX_ETHERNET_POOL_ALLOCSIZE);
if (status == UX_SUCCESS)
{
-
+#endif
/* Create the cdc_ecm class thread. We do not start it yet. */
status = _ux_utility_thread_create(&cdc_ecm -> ux_host_class_cdc_ecm_thread,
"ux_host_cdc_ecm_thread", _ux_host_class_cdc_ecm_thread,
@@ -334,7 +338,7 @@ UX_INTERFACE *cur_interface;
/* Delete CDC-ECM thread. */
_ux_utility_thread_delete(&cdc_ecm -> ux_host_class_cdc_ecm_thread);
}
-
+#ifndef UX_HOST_CLASS_CDC_ECM_USE_PACKET_POOL_FROM_NETX
/* Delete packet pool. */
nx_packet_pool_delete(&cdc_ecm -> ux_host_class_cdc_ecm_packet_pool);
}
@@ -344,7 +348,7 @@ UX_INTERFACE *cur_interface;
/* Packet pool creation failed. Notify application. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ENUMERATOR, status);
}
-
+#endif
/* Delete interrupt notification semaphore. */
_ux_utility_semaphore_delete(&cdc_ecm -> ux_host_class_cdc_ecm_interrupt_notification_semaphore);
}
@@ -363,10 +367,10 @@ UX_INTERFACE *cur_interface;
if (cdc_ecm -> ux_host_class_cdc_ecm_interrupt_endpoint != UX_NULL &&
cdc_ecm -> ux_host_class_cdc_ecm_interrupt_endpoint -> ux_endpoint_transfer_request.ux_transfer_request_data_pointer != UX_NULL)
_ux_utility_memory_free(cdc_ecm -> ux_host_class_cdc_ecm_interrupt_endpoint -> ux_endpoint_transfer_request.ux_transfer_request_data_pointer);
-
+#ifndef UX_HOST_CLASS_CDC_ECM_USE_PACKET_POOL_FROM_NETX
if (cdc_ecm -> ux_host_class_cdc_ecm_pool_memory != UX_NULL)
_ux_utility_memory_free(cdc_ecm -> ux_host_class_cdc_ecm_pool_memory);
-
+#endif
if (cdc_ecm -> ux_host_class_cdc_ecm_thread_stack != UX_NULL)
_ux_utility_memory_free(cdc_ecm -> ux_host_class_cdc_ecm_thread_stack);
diff --git a/common/usbx_host_classes/src/ux_host_class_cdc_ecm_deactivate.c b/common/usbx_host_classes/src/ux_host_class_cdc_ecm_deactivate.c
index a2d1aae..6fc0e85 100644
--- a/common/usbx_host_classes/src/ux_host_class_cdc_ecm_deactivate.c
+++ b/common/usbx_host_classes/src/ux_host_class_cdc_ecm_deactivate.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_cdc_ecm_deactivate PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -77,6 +77,10 @@
/* TX symbols instead of using */
/* them directly, */
/* resulting in version 6.1 */
+/* 02-02-2021 Xiuwen Cai Modified comment(s), added */
+/* compile option for using */
+/* packet pool from NetX, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_class_cdc_ecm_deactivate(UX_HOST_CLASS_COMMAND *command)
@@ -179,13 +183,13 @@ UX_TRANSFER *transfer_request;
/* Destroy the notification semaphore. */
_ux_utility_semaphore_delete(&cdc_ecm -> ux_host_class_cdc_ecm_interrupt_notification_semaphore);
-
+#ifndef UX_HOST_CLASS_CDC_ECM_USE_PACKET_POOL_FROM_NETX
/* Delete the packet pool. */
nx_packet_pool_delete(&cdc_ecm -> ux_host_class_cdc_ecm_packet_pool);
/* Free this pool of packets. */
_ux_utility_memory_free(cdc_ecm -> ux_host_class_cdc_ecm_pool_memory);
-
+#endif
/* Before we free the device resources, we need to inform the application
that the device is removed. */
if (_ux_system_host -> ux_system_host_change_function != UX_NULL)
diff --git a/common/usbx_host_classes/src/ux_host_class_cdc_ecm_thread.c b/common/usbx_host_classes/src/ux_host_class_cdc_ecm_thread.c
index af76f64..6911d59 100644
--- a/common/usbx_host_classes/src/ux_host_class_cdc_ecm_thread.c
+++ b/common/usbx_host_classes/src/ux_host_class_cdc_ecm_thread.c
@@ -34,7 +34,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_cdc_ecm_thread PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -82,6 +82,10 @@
/* TX symbols instead of using */
/* them directly, */
/* resulting in version 6.1 */
+/* 02-02-2021 Xiuwen Cai Modified comment(s), added */
+/* compile option for using */
+/* packet pool from NetX, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
VOID _ux_host_class_cdc_ecm_thread(ULONG parameter)
@@ -92,6 +96,9 @@ UX_TRANSFER *transfer_request;
NX_PACKET *packet;
ULONG ip_given_length;
UINT status;
+#ifdef UX_HOST_CLASS_CDC_ECM_USE_PACKET_POOL_FROM_NETX
+USB_NETWORK_DEVICE_TYPE *usb_network_device_ptr;
+#endif
/* Cast the parameter passed in the thread into the cdc_ecm pointer. */
UX_THREAD_EXTENSION_PTR_GET(cdc_ecm, UX_HOST_CLASS_CDC_ECM, parameter)
@@ -117,11 +124,41 @@ UINT status;
while ((cdc_ecm -> ux_host_class_cdc_ecm_link_state == UX_HOST_CLASS_CDC_ECM_LINK_STATE_UP) &&
(cdc_ecm -> ux_host_class_cdc_ecm_device -> ux_device_state == UX_DEVICE_CONFIGURED))
{
+#ifdef UX_HOST_CLASS_CDC_ECM_USE_PACKET_POOL_FROM_NETX
+
+ /* Check if we have packet pool available. */
+ if (cdc_ecm -> ux_host_class_cdc_ecm_packet_pool == UX_NULL)
+ {
+
+ /* Get the network device handle. */
+ usb_network_device_ptr = (USB_NETWORK_DEVICE_TYPE *)(cdc_ecm -> ux_host_class_cdc_ecm_network_handle);
+
+ /* Check if IP instance is available. */
+ if (usb_network_device_ptr -> ux_network_device_ip_instance != UX_NULL)
+ {
+
+ /* Get the packet pool from IP instance. */
+ cdc_ecm -> ux_host_class_cdc_ecm_packet_pool = usb_network_device_ptr -> ux_network_device_ip_instance -> nx_ip_default_packet_pool;
+ }
+ else
+ {
+
+ /* IP instance is not available, wait for application to attach the interface. */
+ _ux_utility_delay_ms(UX_HOST_CLASS_CDC_ECM_PACKET_POOL_INSTANCE_WAIT);
+ }
+ continue;
+ }
+
+ /* We can accept reception. Get a NX Packet. */
+ status = nx_packet_allocate(cdc_ecm -> ux_host_class_cdc_ecm_packet_pool, &packet,
+ NX_RECEIVE_PACKET, UX_MS_TO_TICK(UX_HOST_CLASS_CDC_ECM_PACKET_POOL_WAIT));
+#else
/* We can accept reception. Get a NX Packet. */
status = nx_packet_allocate(&cdc_ecm -> ux_host_class_cdc_ecm_packet_pool, &packet,
NX_RECEIVE_PACKET, UX_MS_TO_TICK(UX_HOST_CLASS_CDC_ECM_PACKET_POOL_WAIT));
+#endif
if (status == NX_SUCCESS)
{
diff --git a/common/usbx_host_classes/src/ux_host_class_cdc_ecm_transmission_callback.c b/common/usbx_host_classes/src/ux_host_class_cdc_ecm_transmission_callback.c
index 82095e6..d088f00 100644
--- a/common/usbx_host_classes/src/ux_host_class_cdc_ecm_transmission_callback.c
+++ b/common/usbx_host_classes/src/ux_host_class_cdc_ecm_transmission_callback.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_cdc_ecm_transmission_callback PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -70,6 +70,9 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), fixed */
+/* ZLP issue for transmission, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
VOID _ux_host_class_cdc_ecm_transmission_callback(UX_TRANSFER *transfer_request)
@@ -111,7 +114,22 @@ UCHAR *packet_header;
/* Check the state of the transfer. */
if (transfer_request -> ux_transfer_request_completion_code == UX_SUCCESS)
{
-
+
+ /* Check if the transfer length is not zero and it is multiple of MPS. */
+ if ((transfer_request -> ux_transfer_request_requested_length != 0) &&
+ (transfer_request -> ux_transfer_request_requested_length % (transfer_request -> ux_transfer_request_endpoint -> ux_endpoint_descriptor.wMaxPacketSize & UX_MAX_PACKET_SIZE_MASK)) == 0)
+ {
+
+ /* Set transfer request length to zero. */
+ transfer_request -> ux_transfer_request_requested_length = 0;
+
+ /* Send the transfer. */
+ _ux_host_stack_transfer_request(transfer_request);
+
+ /* Finished processing. */
+ return;
+ }
+
/* Get the next packet associated with the first packet. */
next_packet = current_packet -> nx_packet_queue_next;
diff --git a/common/usbx_host_classes/src/ux_host_class_hub_port_change_connection_process.c b/common/usbx_host_classes/src/ux_host_class_hub_port_change_connection_process.c
index fb4f7bf..db704f8 100644
--- a/common/usbx_host_classes/src/ux_host_class_hub_port_change_connection_process.c
+++ b/common/usbx_host_classes/src/ux_host_class_hub_port_change_connection_process.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_hub_port_change_connection_process PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -77,11 +77,20 @@
/* optimized based on compile */
/* definitions, */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* handled more fail cases, */
+/* updated internal call, */
+/* added notification for */
+/* device connection, */
+/* added disconnection check */
+/* in enumeration retries, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
VOID _ux_host_class_hub_port_change_connection_process(UX_HOST_CLASS_HUB *hub, UINT port, UINT port_status)
{
+UX_DEVICE *device = UX_NULL;
UINT device_speed;
UINT device_enumeration_retry;
USHORT port_power;
@@ -137,6 +146,10 @@ USHORT local_port_change;
if (status != UX_SUCCESS)
return;
+ /* Check if device is still connected. */
+ if ((local_port_status & UX_HOST_CLASS_HUB_PORT_STATUS_CONNECTION) == 0)
+ return;
+
/* Device connected. Get the device speed. */
if (local_port_status & UX_HOST_CLASS_HUB_PORT_STATUS_LOW_SPEED)
device_speed = UX_LOW_SPEED_DEVICE;
@@ -166,28 +179,56 @@ USHORT local_port_change;
/* Perform the device creation. */
status = _ux_host_stack_new_device_create(UX_DEVICE_HCD_GET(hub -> ux_host_class_hub_device),
hub -> ux_host_class_hub_device,
- port, device_speed, port_power);
+ port, device_speed, port_power,
+ &device);
/* Check return status. */
if (status == UX_SUCCESS)
{
/* Successful device creation. */
+
+ /* If the device instance is ready, notify application for unconfigured device. */
+ if (_ux_system_host -> ux_system_host_change_function)
+ {
+ _ux_system_host -> ux_system_host_change_function(UX_DEVICE_CONNECTION, UX_NULL, (VOID*)device);
+ }
+
/* Just return. */
return;
}
- else if (device_enumeration_retry < UX_HOST_CLASS_HUB_ENUMERATION_RETRY - 1)
+ else
{
- /* Simulate remove to free allocated resources before retry. */
- _ux_host_stack_device_remove(hcd, hub -> ux_host_class_hub_device, port);
+ /* No retry if there are too many devices. */
+ if (status == UX_TOO_MANY_DEVICES)
+ break;
+
+ /* No retry if there is no class found. */
+ if (status == UX_NO_CLASS_MATCH)
+ break;
- /* Wait for a while. */
- _ux_utility_delay_ms(UX_HOST_CLASS_HUB_ENUMERATION_RETRY_DELAY);
+ if (device_enumeration_retry < UX_HOST_CLASS_HUB_ENUMERATION_RETRY - 1)
+ {
+
+ /* Simulate remove to free allocated resources before retry. */
+ _ux_host_stack_device_remove(hcd, hub -> ux_host_class_hub_device, port);
+
+ /* Wait for a while. */
+ _ux_utility_delay_ms(UX_HOST_CLASS_HUB_ENUMERATION_RETRY_DELAY);
+ }
}
}
- /* If we get here, the device did not enumerate completely. */
+ /* If we get here, the device did not enumerate completely.
+ The device is still attached to the hub and therefore there is a
+ physical connection with a unenumerated device. */
+
+ /* If the device instance is ready, notify application for unconfigured device. */
+ if (_ux_system_host -> ux_system_host_change_function)
+ {
+ _ux_system_host -> ux_system_host_change_function(UX_DEVICE_CONNECTION, UX_NULL, (VOID*)device);
+ }
/* Error trap. */
_ux_system_error_handler(UX_SYSTEM_LEVEL_THREAD, UX_SYSTEM_CONTEXT_ROOT_HUB, UX_DEVICE_ENUMERATION_FAILURE);
diff --git a/common/usbx_host_classes/src/ux_host_class_printer_device_id_get.c b/common/usbx_host_classes/src/ux_host_class_printer_device_id_get.c
new file mode 100644
index 0000000..5601fad
--- /dev/null
+++ b/common/usbx_host_classes/src/ux_host_class_printer_device_id_get.c
@@ -0,0 +1,132 @@
+/**************************************************************************/
+/* */
+/* Copyright (c) Microsoft Corporation. All rights reserved. */
+/* */
+/* This software is licensed under the Microsoft Software License */
+/* Terms for Microsoft Azure RTOS. Full text of the license can be */
+/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
+/* and in the root directory of this software. */
+/* */
+/**************************************************************************/
+
+
+/**************************************************************************/
+/**************************************************************************/
+/** */
+/** USBX Component */
+/** */
+/** Printer Class */
+/** */
+/**************************************************************************/
+/**************************************************************************/
+
+
+/* Include necessary system files. */
+
+#define UX_SOURCE_CODE
+
+#include "ux_api.h"
+#include "ux_host_class_printer.h"
+#include "ux_host_stack.h"
+
+
+/**************************************************************************/
+/* */
+/* FUNCTION RELEASE */
+/* */
+/* _ux_host_class_printer_device_id_get PORTABLE C */
+/* 6.1.4 */
+/* AUTHOR */
+/* */
+/* Chaoqiong Xiao, Microsoft Corporation */
+/* */
+/* DESCRIPTION */
+/* */
+/* This function obtains the printer IEEE 1284 device ID string */
+/* (including length in the first two bytes in big endian format). */
+/* */
+/* INPUT */
+/* */
+/* printer Pointer to printer class */
+/* descriptor_buffer Pointer to a buffer to fill */
+/* IEEE 1284 device ID string */
+/* (including length in the */
+/* first two bytes in BE format) */
+/* length Length of buffer in bytes */
+/* */
+/* OUTPUT */
+/* */
+/* Completion Status */
+/* */
+/* CALLS */
+/* */
+/* _ux_host_stack_transfer_request Process transfer request */
+/* _ux_utility_memory_allocate Allocate memory block */
+/* _ux_utility_memory_compare Compare memory block */
+/* _ux_utility_memory_copy Copy memory block */
+/* _ux_utility_memory_free Free memory block */
+/* _ux_utility_short_get_big_endian Get 16-bit value */
+/* */
+/* CALLED BY */
+/* */
+/* Application */
+/* */
+/* RELEASE HISTORY */
+/* */
+/* DATE NAME DESCRIPTION */
+/* */
+/* 02-02-2021 Chaoqiong Xiao Initial Version 6.1.4 */
+/* */
+/**************************************************************************/
+UINT _ux_host_class_printer_device_id_get(UX_HOST_CLASS_PRINTER *printer, UCHAR *descriptor_buffer, ULONG length)
+{
+UX_INTERFACE *interface;
+UX_ENDPOINT *control_endpoint;
+UX_TRANSFER *transfer_request;
+UINT status;
+
+
+ /* If trace is enabled, insert this event into the trace buffer. */
+ UX_TRACE_IN_LINE_INSERT(UX_TRACE_HOST_CLASS_PRINTER_DEVICE_ID_GET, printer, descriptor_buffer, length, 0, UX_TRACE_HOST_CLASS_EVENTS, 0, 0)
+
+ /* Protect thread reentry to this instance. */
+ status = _ux_utility_semaphore_get(&printer -> ux_host_class_printer_semaphore, UX_WAIT_FOREVER);
+ if (status != UX_SUCCESS)
+ return(status);
+
+ /* Protect the control endpoint semaphore here. It will be unprotected in the
+ transfer request function. */
+ status = _ux_utility_semaphore_get(&printer -> ux_host_class_printer_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
+
+ /* Check for status. */
+ if (status != UX_SUCCESS)
+ {
+ _ux_utility_semaphore_put(&printer -> ux_host_class_printer_semaphore);
+ return(status);
+ }
+
+ /* We need to get the default control endpoint transfer request pointer. */
+ control_endpoint = &printer -> ux_host_class_printer_device -> ux_device_control_endpoint;
+ transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
+
+ /* Need interface for wIndex. */
+ interface = printer -> ux_host_class_printer_interface;
+
+ /* Create a transfer request for the GET_DEVICE_ID request. */
+ transfer_request -> ux_transfer_request_data_pointer = descriptor_buffer;
+ transfer_request -> ux_transfer_request_requested_length = length;
+ transfer_request -> ux_transfer_request_function = UX_HOST_CLASS_PRINTER_GET_DEVICE_ID;
+ transfer_request -> ux_transfer_request_type = UX_REQUEST_IN | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_INTERFACE;
+ transfer_request -> ux_transfer_request_value = 0; /* Do not support multiple configuration for now. */
+ transfer_request -> ux_transfer_request_index = (interface -> ux_interface_descriptor.bInterfaceNumber << 8) |
+ (interface -> ux_interface_descriptor.bAlternateSetting );
+
+ /* Send request to HCD layer. */
+ status = _ux_host_stack_transfer_request(transfer_request);
+
+ /* Unprotect thread reentry to this instance. */
+ _ux_utility_semaphore_put(&printer -> ux_host_class_printer_semaphore);
+
+ /* Return completion status. */
+ return(status);
+}
diff --git a/common/usbx_host_classes/src/ux_host_class_printer_name_get.c b/common/usbx_host_classes/src/ux_host_class_printer_name_get.c
index 073ffc7..7e500e0 100644
--- a/common/usbx_host_classes/src/ux_host_class_printer_name_get.c
+++ b/common/usbx_host_classes/src/ux_host_class_printer_name_get.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_printer_name_get PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -64,7 +64,7 @@
/* */
/* CALLED BY */
/* */
-/* Application */
+/* Printer Class */
/* */
/* RELEASE HISTORY */
/* */
@@ -75,6 +75,10 @@
/* verified memset and memcpy */
/* cases, */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* supported interface other */
+/* than number zero, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_class_printer_name_get(UX_HOST_CLASS_PRINTER *printer)
@@ -83,6 +87,7 @@ UINT _ux_host_class_printer_name_get(UX_HOST_CLASS_PRINTER *printer)
UCHAR * descriptor_buffer;
UCHAR * printer_name_buffer;
UCHAR * printer_name;
+UX_INTERFACE *interface;
UX_ENDPOINT *control_endpoint;
UX_TRANSFER *transfer_request;
UINT status;
@@ -101,13 +106,17 @@ UINT printer_name_length;
if(descriptor_buffer == UX_NULL)
return(UX_MEMORY_INSUFFICIENT);
+ /* Need interface for wIndex. */
+ interface = printer -> ux_host_class_printer_interface;
+
/* Create a transfer request for the GET_DEVICE_ID request. */
transfer_request -> ux_transfer_request_data_pointer = descriptor_buffer;
transfer_request -> ux_transfer_request_requested_length = UX_HOST_CLASS_PRINTER_DESCRIPTOR_LENGTH;
transfer_request -> ux_transfer_request_function = UX_HOST_CLASS_PRINTER_GET_DEVICE_ID;
transfer_request -> ux_transfer_request_type = UX_REQUEST_IN | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_INTERFACE;
- transfer_request -> ux_transfer_request_value = 0;
- transfer_request -> ux_transfer_request_index = 0;
+ transfer_request -> ux_transfer_request_value = 0; /* Do not support multiple configuration for now. */
+ transfer_request -> ux_transfer_request_index = (interface -> ux_interface_descriptor.bInterfaceNumber << 8) |
+ (interface -> ux_interface_descriptor.bAlternateSetting );
/* Send request to HCD layer. */
status = _ux_host_stack_transfer_request(transfer_request);
diff --git a/common/usbx_host_classes/src/ux_host_class_printer_soft_reset.c b/common/usbx_host_classes/src/ux_host_class_printer_soft_reset.c
index 3058896..7b81a1d 100644
--- a/common/usbx_host_classes/src/ux_host_class_printer_soft_reset.c
+++ b/common/usbx_host_classes/src/ux_host_class_printer_soft_reset.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_printer_soft_reset PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -70,12 +70,17 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* supported interface other */
+/* than number zero, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_class_printer_soft_reset(UX_HOST_CLASS_PRINTER *printer)
{
+UX_INTERFACE *interface;
UX_ENDPOINT *control_endpoint;
UX_TRANSFER *transfer_request;
UINT status;
@@ -103,23 +108,37 @@ UINT status;
/* Return error. */
return(status);
+ /* Protect the control endpoint semaphore here. It will be unprotected in the
+ transfer request function. */
+ status = _ux_utility_semaphore_get(&printer -> ux_host_class_printer_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
+
+ /* Check for status. */
+ if (status != UX_SUCCESS)
+ {
+ _ux_utility_semaphore_put(&printer -> ux_host_class_printer_semaphore);
+ return(status);
+ }
+
/* We need to get the default control endpoint transfer request pointer. */
control_endpoint = &printer -> ux_host_class_printer_device -> ux_device_control_endpoint;
transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
+ /* Need interface for wIndex. */
+ interface = printer -> ux_host_class_printer_interface;
+
/* Create a transfer_request for the SOFT_RESET request. */
transfer_request -> ux_transfer_request_data_pointer = UX_NULL;
transfer_request -> ux_transfer_request_requested_length = 0;
transfer_request -> ux_transfer_request_function = UX_HOST_CLASS_PRINTER_SOFT_RESET;
transfer_request -> ux_transfer_request_type = UX_REQUEST_OUT | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_INTERFACE;
transfer_request -> ux_transfer_request_value = 0;
- transfer_request -> ux_transfer_request_index = 0;
+ transfer_request -> ux_transfer_request_index = interface -> ux_interface_descriptor.bInterfaceNumber;
/* Send request to HCD layer. */
status = _ux_host_stack_transfer_request(transfer_request);
/* Unprotect thread reentry to this instance. */
- status = _ux_utility_semaphore_put(&printer -> ux_host_class_printer_semaphore);
+ _ux_utility_semaphore_put(&printer -> ux_host_class_printer_semaphore);
/* Return completion status. */
return(status);
diff --git a/common/usbx_host_classes/src/ux_host_class_printer_status_get.c b/common/usbx_host_classes/src/ux_host_class_printer_status_get.c
index 164490c..052a7fe 100644
--- a/common/usbx_host_classes/src/ux_host_class_printer_status_get.c
+++ b/common/usbx_host_classes/src/ux_host_class_printer_status_get.c
@@ -35,7 +35,7 @@
/* FUNCTION RELEASE */
/* */
/* _ux_host_class_printer_status_get PORTABLE C */
-/* 6.1 */
+/* 6.1.4 */
/* AUTHOR */
/* */
/* Chaoqiong Xiao, Microsoft Corporation */
@@ -75,11 +75,16 @@
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
/* resulting in version 6.1 */
+/* 02-02-2021 Chaoqiong Xiao Modified comment(s), */
+/* supported interface other */
+/* than number zero, */
+/* resulting in version 6.1.4 */
/* */
/**************************************************************************/
UINT _ux_host_class_printer_status_get(UX_HOST_CLASS_PRINTER *printer, ULONG *printer_status)
{
+UX_INTERFACE *interface;
UX_ENDPOINT *control_endpoint;
UX_TRANSFER *transfer_request;
UINT status;
@@ -102,6 +107,17 @@ UCHAR * printer_status_buffer;
/* Return error. */
return(status);
+ /* Protect the control endpoint semaphore here. It will be unprotected in the
+ transfer request function. */
+ status = _ux_utility_semaphore_get(&printer -> ux_host_class_printer_device -> ux_device_protection_semaphore, UX_WAIT_FOREVER);
+
+ /* Check for status. */
+ if (status != UX_SUCCESS)
+ {
+ _ux_utility_semaphore_put(&printer -> ux_host_class_printer_semaphore);
+ return(status);
+ }
+
/* We need to get the default control endpoint transfer_request pointer. */
control_endpoint = &printer -> ux_host_class_printer_device -> ux_device_control_endpoint;
transfer_request = &control_endpoint -> ux_endpoint_transfer_request;
@@ -116,13 +132,16 @@ UCHAR * printer_status_buffer;
return(UX_MEMORY_INSUFFICIENT);
}
+ /* Need interface for wIndex. */
+ interface = printer -> ux_host_class_printer_interface;
+
/* Create a transfer_request for the GET_STATUS request. */
transfer_request -> ux_transfer_request_data_pointer = printer_status_buffer;
transfer_request -> ux_transfer_request_requested_length = UX_HOST_CLASS_PRINTER_STATUS_LENGTH;
transfer_request -> ux_transfer_request_function = UX_HOST_CLASS_PRINTER_GET_STATUS;
transfer_request -> ux_transfer_request_type = UX_REQUEST_IN | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_INTERFACE;
transfer_request -> ux_transfer_request_value = 0;
- transfer_request -> ux_transfer_request_index = 0;
+ transfer_request -> ux_transfer_request_index = interface -> ux_interface_descriptor.bInterfaceNumber;
/* Send request to HCD layer. */
status = _ux_host_stack_transfer_request(transfer_request);
@@ -156,7 +175,7 @@ UCHAR * printer_status_buffer;
_ux_utility_memory_free(printer_status_buffer);
/* Unprotect thread reentry to this instance. */
- status = _ux_utility_semaphore_put(&printer -> ux_host_class_printer_semaphore);
+ _ux_utility_semaphore_put(&printer -> ux_host_class_printer_semaphore);
/* Return completion status. */
return(status);
diff --git a/common/usbx_host_classes/src/ux_host_class_storage_entry.c b/common/usbx_host_classes/src/ux_host_class_storage_entry.c
index d8e1c09..d8e1c09 100644..100755
--- a/common/usbx_host_classes/src/ux_host_class_storage_entry.c
+++ b/common/usbx_host_classes/src/ux_host_class_storage_entry.c
diff --git a/common/usbx_host_classes/src/ux_host_class_storage_partition_read.c b/common/usbx_host_classes/src/ux_host_class_storage_partition_read.c
index c3e17fa..c3e17fa 100644..100755
--- a/common/usbx_host_classes/src/ux_host_class_storage_partition_read.c
+++ b/common/usbx_host_classes/src/ux_host_class_storage_partition_read.c
diff --git a/common/usbx_host_classes/src/ux_host_class_video_frame_interval_get.c b/common/usbx_host_classes/src/ux_host_class_video_frame_interval_get.c
index 2bb2b3c..2bb2b3c 100644..100755
--- a/common/usbx_host_classes/src/ux_host_class_video_frame_interval_get.c
+++ b/common/usbx_host_classes/src/ux_host_class_video_frame_interval_get.c