Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 2 additions & 9 deletions common/core/inc/ux_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ typedef signed char SCHAR;
#define AZURE_RTOS_USBX
#define USBX_MAJOR_VERSION 6
#define USBX_MINOR_VERSION 5
#define USBX_PATCH_VERSION 0
#define USBX_BUILD_VERSION 202601
#define USBX_PATCH_VERSION 1
#define USBX_BUILD_VERSION 202602
#define USBX_HOTFIX_VERSION ' '

/* Macros for concatenating tokens, where UX_CONCATn concatenates n tokens. */
Expand Down Expand Up @@ -2745,7 +2745,6 @@ typedef struct UX_HOST_CLASS_DPUMP_STRUCT
#define ux_device_stack_transfer_run _ux_device_stack_transfer_run

#define ux_hcd_ehci_initialize _ux_hcd_ehci_initialize
#define ux_hcd_isp1161_initialize _ux_hcd_isp1161_initialize
#define ux_hcd_ohci_initialize _ux_hcd_ohci_initialize
#define ux_hcd_sim_host_initialize _ux_hcd_sim_host_initialize
#define ux_dcd_sim_slave_initialize _ux_dcd_sim_slave_initialize
Expand All @@ -2769,7 +2768,6 @@ UINT uxe_system_initialize(VOID *non_cached_memory_pool_start, ULONG non_cach
/* Define USBX Host API prototypes. */

UINT ux_hcd_ehci_initialize(UX_HCD *hcd);
UINT ux_hcd_isp1161_initialize(UX_HCD *hcd);
UINT ux_hcd_ohci_initialize(UX_HCD *hcd);
UINT ux_hcd_sim_host_initialize(UX_HCD *hcd);

Expand Down Expand Up @@ -2805,13 +2803,9 @@ UINT ux_host_stack_transfer_run(UX_TRANSFER *transfer_request);

/* Define USBX Device API prototypes. */

UINT ux_dcd_at91_initialize(ULONG dcd_io);
UINT ux_dcd_isp1181_initialize(ULONG dcd_io, ULONG dcd_irq, ULONG dcd_vbus_address);
UINT ux_dcd_ml6965_initialize(ULONG dcd_io, ULONG dcd_irq, ULONG dcd_vbus_address);
UINT ux_dcd_sim_slave_initialize(VOID);

UINT ux_device_class_storage_entry(UX_SLAVE_CLASS_COMMAND *command);
VOID ux_device_class_storage_thread(ULONG);
UINT ux_device_stack_alternate_setting_get(ULONG interface_value);
UINT ux_device_stack_alternate_setting_set(ULONG interface_value, ULONG alternate_setting_value);
UINT ux_device_stack_class_register(UCHAR *class_name,
Expand Down Expand Up @@ -2839,7 +2833,6 @@ UINT ux_device_stack_interface_set(UCHAR * device_framework, ULONG device_fra
ULONG alternate_setting_value);
UINT ux_device_stack_interface_start(UX_SLAVE_INTERFACE *ux_interface);
UINT ux_device_stack_transfer_request(UX_SLAVE_TRANSFER *transfer_request, ULONG slave_length, ULONG host_length);
UINT ux_device_stack_transfer_request_abort(UX_SLAVE_TRANSFER *transfer_request, ULONG completion_code);
UINT ux_device_stack_microsoft_extension_register(ULONG vendor_request,
UINT (*vendor_request_function)(ULONG, ULONG, ULONG, ULONG, UCHAR *, ULONG *));

Expand Down
3 changes: 2 additions & 1 deletion common/core/inc/ux_hcd_sim_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,12 @@ UINT _ux_hcd_sim_host_transfer_run(UX_HCD_SIM_HOST *hcd_sim_host, UX_TRANSFER
/* Define Device Simulator Class API prototypes. */

#define ux_hcd_sim_host_initialize _ux_hcd_sim_host_initialize
#define ux_hcd_sim_host_uninitialize _ux_hcd_sim_host_uninitialize

/* Determine if a C++ compiler is being used. If so, complete the standard
C conditional started above. */
#ifdef __cplusplus
}
#endif

#endif

17 changes: 13 additions & 4 deletions common/core/src/ux_device_stack_control_request_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,22 @@ ULONG application_data_length;
request_index = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_INDEX);
request_length = _ux_utility_short_get(transfer_request -> ux_slave_transfer_request_setup + UX_SETUP_LENGTH);

/* Filter for GET_DESCRIPTOR/SET_DESCRIPTOR commands. If the descriptor to be returned is not a standard descriptor,
treat the command as a CLASS command. */
if ((request == UX_GET_DESCRIPTOR || request == UX_SET_DESCRIPTOR) && (((request_value >> 8) & UX_REQUEST_TYPE) != UX_REQUEST_TYPE_STANDARD))
/* Per USB HID 1.11 section 7.1.1, GET_DESCRIPTOR/SET_DESCRIPTOR for a
class-defined descriptor type (e.g. HID Report 0x22, Physical 0x23)
may arrive with bmRequestType set to STANDARD rather than CLASS.
Detect this via the high byte of wValue (bDescriptorType): USB-IF
allocates 0x21..0x2F to class-defined descriptors, so re-route any
such request to the class layer. Standard descriptors (< 0x21,
including BOS 0x0F) and vendor descriptors (>= 0x40) are left
unchanged. */
if ((request == UX_GET_DESCRIPTOR || request == UX_SET_DESCRIPTOR) &&
((request_type & UX_REQUEST_TYPE) == UX_REQUEST_TYPE_STANDARD) &&
(((request_value >> 8) & 0xFFu) >= 0x21u) &&
(((request_value >> 8) & 0xFFu) <= 0x2Fu))
{

/* This request is to be handled by the class layer. */
request_type &= (UINT)~UX_REQUEST_TYPE;
request_type &= (ULONG)~UX_REQUEST_TYPE;
request_type |= UX_REQUEST_TYPE_CLASS;
}

Expand Down
5 changes: 5 additions & 0 deletions common/usbx_device_classes/inc/ux_device_class_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ typedef struct UX_SLAVE_CLASS_HID_STRUCT
UINT ux_device_class_hid_state;
UINT (*ux_device_class_hid_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, UX_SLAVE_CLASS_HID_EVENT *);
UINT (*ux_device_class_hid_get_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, UX_SLAVE_CLASS_HID_EVENT *);
VOID (*ux_device_class_hid_set_protocol_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, ULONG protocol);
VOID (*ux_slave_class_hid_instance_activate)(VOID *);
VOID (*ux_slave_class_hid_instance_deactivate)(VOID *);
UCHAR *ux_device_class_hid_report_address;
Expand Down Expand Up @@ -331,6 +332,10 @@ typedef struct UX_SLAVE_CLASS_HID_PARAMETER_STRUCT
ULONG ux_device_class_hid_parameter_report_length;
UINT (*ux_device_class_hid_parameter_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, UX_SLAVE_CLASS_HID_EVENT *);
UINT (*ux_device_class_hid_parameter_get_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, UX_SLAVE_CLASS_HID_EVENT *);

/* Optional callback invoked when protocol changes (boot/report). */
VOID (*ux_device_class_hid_parameter_set_protocol_callback)(struct UX_SLAVE_CLASS_HID_STRUCT *hid, ULONG protocol);

#if defined(UX_DEVICE_CLASS_HID_FLEXIBLE_EVENTS_QUEUE)
ULONG ux_device_class_hid_parameter_event_max_number;
ULONG ux_device_class_hid_parameter_event_max_length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,28 @@ UX_SLAVE_CLASS_HID *hid;

case UX_DEVICE_CLASS_HID_COMMAND_GET_PROTOCOL:

/* Send the protocol. */
/* Send the protocol to host. */
*transfer_request -> ux_slave_transfer_request_data_pointer = (UCHAR)hid -> ux_device_class_hid_protocol;
_ux_device_stack_transfer_request(transfer_request, 1, request_length);
break;

case UX_DEVICE_CLASS_HID_COMMAND_SET_PROTOCOL:

/* Check protocol must be 0 (Boot) or 1 (Report). */
if ((request_value != UX_DEVICE_CLASS_HID_PROTOCOL_BOOT) &&
(request_value != UX_DEVICE_CLASS_HID_PROTOCOL_REPORT))
{
/* Invalid value: not handled. */
return(UX_ERROR);
}

/* Accept the protocol. */
hid -> ux_device_class_hid_protocol = request_value;

/* If there is a callback defined by the application, send the protocol to it. */
if (hid -> ux_device_class_hid_set_protocol_callback != UX_NULL)
hid -> ux_device_class_hid_set_protocol_callback(hid, request_value);

break;

default:
Expand All @@ -198,4 +211,3 @@ UX_SLAVE_CLASS_HID *hid;
/* It's handled. */
return(UX_SUCCESS);
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* SPDX-License-Identifier: MIT
**************************************************************************/


/**************************************************************************/
/**************************************************************************/
/** */
Expand Down Expand Up @@ -166,6 +167,7 @@ UCHAR *buffer;
/* Store the callback function. */
hid -> ux_device_class_hid_callback = hid_parameter -> ux_device_class_hid_parameter_callback;
hid -> ux_device_class_hid_get_callback = hid_parameter -> ux_device_class_hid_parameter_get_callback;
hid -> ux_device_class_hid_set_protocol_callback = hid_parameter -> ux_device_class_hid_parameter_set_protocol_callback;

#if defined(UX_DEVICE_CLASS_HID_FLEXIBLE_EVENTS_QUEUE)

Expand Down
2 changes: 2 additions & 0 deletions common/usbx_host_classes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ target_sources(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_idle_get.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_idle_set.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_idle_set_run.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_protocol_set.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_protocol_get.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_instance_clean.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_interrupt_endpoint_search.c
${CMAKE_CURRENT_LIST_DIR}/src/ux_host_class_hid_item_data_get.c
Expand Down
11 changes: 11 additions & 0 deletions common/usbx_host_classes/inc/ux_host_class_cdc_acm.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,21 @@ extern "C" {

/* Define CDC ACM default values. */

#ifndef UX_HOST_CLASS_CDC_ACM_LINE_CODING_DEFAULT_RATE
#define UX_HOST_CLASS_CDC_ACM_LINE_CODING_DEFAULT_RATE 9600
#endif

#ifndef UX_HOST_CLASS_CDC_ACM_LINE_CODING_DEFAULT_STOP_BIT
#define UX_HOST_CLASS_CDC_ACM_LINE_CODING_DEFAULT_STOP_BIT 0
#endif

#ifndef UX_HOST_CLASS_CDC_ACM_LINE_CODING_DEFAULT_PARITY
#define UX_HOST_CLASS_CDC_ACM_LINE_CODING_DEFAULT_PARITY 0
#endif

#ifndef UX_HOST_CLASS_CDC_ACM_LINE_CODING_DEFAULT_DATA_BIT
#define UX_HOST_CLASS_CDC_ACM_LINE_CODING_DEFAULT_DATA_BIT 8
#endif

/* Define CDC ACM line coding definitions. */

Expand Down
13 changes: 13 additions & 0 deletions common/usbx_host_classes/inc/ux_host_class_gser.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,21 @@ extern "C" {

/* Define CDC ACM default values. */

#ifndef UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_RATE
#define UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_RATE 9600
#endif

#ifndef UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_STOP_BIT
#define UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_STOP_BIT 0
#endif

#ifndef UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_PARITY
#define UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_PARITY 0
#endif

#ifndef UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_DATA_BIT
#define UX_HOST_CLASS_GSER_LINE_CODING_DEFAULT_DATA_BIT 8
#endif

/* Define CDC ACM line coding definitions. */

Expand Down
19 changes: 14 additions & 5 deletions common/usbx_host_classes/inc/ux_host_class_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/** */
/** USBX Component */
/** */
/** HID Class */
/** Host HID Class */
/** */
/**************************************************************************/
/**************************************************************************/
Expand Down Expand Up @@ -548,7 +548,7 @@ extern "C" {
#define UX_HOST_CLASS_HID_CONSUMER_ALTERNATE_AUDIO_DECREMENT 0x173
#define UX_HOST_CLASS_HID_CONSUMER_APPLICATION_LAUNCH_BUTTONS 0x174
#define UX_HOST_CLASS_HID_CONSUMER_AL_LAUNCH_BUTTON_CONFIGURATION 0x180
#define UX_HOST_CLASS_HID_CONSUMER_AL_PROGRAMMABLE_BUTTON 0x181
#define UX_HOST_CLASS_HID_CONSUMER_AL_PROGRAMMABLE_BUTTON 0x181
#define UX_HOST_CLASS_HID_CONSUMER_AL_CONSUMER_CONTROL_CONFIGURATION 0x182
#define UX_HOST_CLASS_HID_CONSUMER_AL_WORD_PROCESSOR 0x183
#define UX_HOST_CLASS_HID_CONSUMER_AL_TEXT_EDITOR 0x184
Expand Down Expand Up @@ -764,6 +764,10 @@ extern "C" {
#define UX_HOST_CLASS_HID_REPORT_TRANSFER_TIMEOUT 10000
#endif

/* HID protocol values. */
#define UX_HOST_CLASS_HID_PROTOCOL_BOOT 0x00
#define UX_HOST_CLASS_HID_PROTOCOL_REPORT 0x01

/* Define HID Class descriptor. */

typedef struct UX_HID_DESCRIPTOR_STRUCT
Expand Down Expand Up @@ -1077,7 +1081,8 @@ VOID _ux_host_class_hid_transfer_request_completed(UX_TRANSFER *transfer_requ
UINT _ux_host_class_hid_tasks_run(UX_HOST_CLASS *hid_class);
UINT _ux_host_class_hid_idle_set_run(UX_HOST_CLASS_HID *hid, USHORT idle_time, USHORT report_id);
UINT _ux_host_class_hid_report_set_run(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS_HID_CLIENT_REPORT *client_report);

UINT _ux_host_class_hid_protocol_set(UX_HOST_CLASS_HID *hid, USHORT protocol);
UINT _ux_host_class_hid_protocol_get(UX_HOST_CLASS_HID *hid, USHORT *protocol);

UINT _uxe_host_class_hid_client_register(UCHAR *hid_client_name,
UINT (*hid_client_handler)(struct UX_HOST_CLASS_HID_CLIENT_COMMAND_STRUCT *));
Expand All @@ -1095,7 +1100,8 @@ UINT _uxe_host_class_hid_report_set(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS_HID

UINT _uxe_host_class_hid_idle_set_run(UX_HOST_CLASS_HID *hid, USHORT idle_time, USHORT report_id);
UINT _uxe_host_class_hid_report_set_run(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS_HID_CLIENT_REPORT *client_report);

UINT _uxe_host_class_hid_protocol_set(UX_HOST_CLASS_HID *hid, USHORT protocol);
UINT _uxe_host_class_hid_protocol_get(UX_HOST_CLASS_HID *hid, USHORT *protocol);

/* Define HID Class API prototypes. */

Expand All @@ -1122,6 +1128,8 @@ UINT _uxe_host_class_hid_report_set_run(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS
#define ux_host_class_hid_report_id_get _uxe_host_class_hid_report_id_get
#define ux_host_class_hid_report_get _uxe_host_class_hid_report_get
#define ux_host_class_hid_report_set _uxe_host_class_hid_report_set
#define ux_host_class_hid_protocol_set _uxe_host_class_hid_protocol_set
#define ux_host_class_hid_protocol_get _uxe_host_class_hid_protocol_get

#else

Expand All @@ -1137,6 +1145,8 @@ UINT _uxe_host_class_hid_report_set_run(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS
#define ux_host_class_hid_report_id_get _ux_host_class_hid_report_id_get
#define ux_host_class_hid_report_get _ux_host_class_hid_report_get
#define ux_host_class_hid_report_set _ux_host_class_hid_report_set
#define ux_host_class_hid_protocol_set _ux_host_class_hid_protocol_set
#define ux_host_class_hid_protocol_get _ux_host_class_hid_protocol_get

#endif

Expand All @@ -1148,4 +1158,3 @@ UINT _uxe_host_class_hid_report_set_run(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS
#endif

#endif

13 changes: 13 additions & 0 deletions common/usbx_host_classes/inc/ux_host_class_prolific.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,21 @@ extern "C" {

/* Define PROLIFIC default values. */

#ifndef UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_RATE
#define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_RATE 19200
#endif

#ifndef UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_STOP_BIT
#define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_STOP_BIT 0
#endif

#ifndef UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_PARITY
#define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_PARITY 0
#endif

#ifndef UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_DATA_BIT
#define UX_HOST_CLASS_PROLIFIC_LINE_CODING_DEFAULT_DATA_BIT 8
#endif

/* Define PROLIFIC line coding definitions. */

Expand Down
30 changes: 26 additions & 4 deletions common/usbx_host_classes/src/ux_host_class_hid_client_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
/* CALLS */
/* */
/* (ux_host_class_hid_client_handler) HID client handler */
/* _ux_utility_memory_allocate Allocate memory block */
/* _ux_utility_memory_copy Copy memory block */
/* _ux_utility_memory_free Release memory block */
/* */
/* CALLED BY */
/* */
Expand All @@ -66,6 +69,7 @@ UINT _ux_host_class_hid_client_search(UX_HOST_CLASS_HID *hid)
{

UX_HOST_CLASS_HID_CLIENT *hid_client;
UX_HOST_CLASS_HID_CLIENT *hid_client_instance;
ULONG hid_client_index;
UINT status;
UX_HOST_CLASS_HID_CLIENT_COMMAND hid_client_command;
Expand Down Expand Up @@ -109,18 +113,36 @@ UX_HOST_CLASS_HID_CLIENT_COMMAND hid_client_command;
if (status == UX_SUCCESS)
{

/* Allocate a per-instance copy of the client struct so that each HID
device gets its own local_instance pointer. This prevents multiple
devices of the same type from sharing a single local_instance. */
hid_client_instance = (UX_HOST_CLASS_HID_CLIENT *)
_ux_utility_memory_allocate(UX_NO_ALIGN, UX_REGULAR_MEMORY,
sizeof(UX_HOST_CLASS_HID_CLIENT));
if (hid_client_instance == UX_NULL)
return(UX_MEMORY_INSUFFICIENT);

/* Copy the registered client entry and clear the local instance
to avoid carrying a stale pointer from a prior activation. */
_ux_utility_memory_copy(hid_client_instance, hid_client,
sizeof(UX_HOST_CLASS_HID_CLIENT));
hid_client_instance -> ux_host_class_hid_client_local_instance = UX_NULL;

/* Update the command to activate the client. */
hid_client_command.ux_host_class_hid_client_command_request = UX_HOST_CLASS_COMMAND_ACTIVATE;

/* Memorize the client for this HID device. */
hid -> ux_host_class_hid_client = hid_client;
/* Store the per-instance client on this HID device. */
hid -> ux_host_class_hid_client = hid_client_instance;

/* Call the HID client with an activate command. */
status = hid_client -> ux_host_class_hid_client_handler(&hid_client_command);
status = hid_client_instance -> ux_host_class_hid_client_handler(&hid_client_command);

/* Unmount the client if activation fail. */
/* Unmount the client if activation failed. */
if (status != UX_SUCCESS)
{
hid -> ux_host_class_hid_client = UX_NULL;
_ux_utility_memory_free(hid_client_instance);
}

/* Return completion status. */
return(status);
Expand Down
13 changes: 12 additions & 1 deletion common/usbx_host_classes/src/ux_host_class_hid_deactivate.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,22 @@ UINT status;
hid_client_command.ux_host_class_hid_client_command_instance = (VOID *) hid;
hid_client_command.ux_host_class_hid_client_command_container = (VOID *) hid -> ux_host_class_hid_class;
hid_client_command.ux_host_class_hid_client_command_request = UX_HOST_CLASS_COMMAND_DEACTIVATE;

/* Call the HID client with a deactivate command if there was a client registered. */
if (hid -> ux_host_class_hid_client != UX_NULL)
{
hid -> ux_host_class_hid_client -> ux_host_class_hid_client_handler(&hid_client_command);

/* Free the per-instance client copy allocated in _ux_host_class_hid_client_search.
Handlers for keyboard/mouse/remote_control null hid_client after freeing their own
combined allocation; simple clients leave hid_client pointing at the per-instance copy. */
if (hid -> ux_host_class_hid_client != UX_NULL)
{
_ux_utility_memory_free(hid -> ux_host_class_hid_client);
hid -> ux_host_class_hid_client = UX_NULL;
}
}

/* Clean all the HID memory fields. */
_ux_host_class_hid_instance_clean(hid);

Expand Down
Loading
Loading