ThreadX docsThreadX docs
ThreadX
ThreadX Modules
NetX Duo
FileX
GUIX
USBX
TraceX
LevelX
ThreadX
ThreadX Modules
NetX Duo
FileX
GUIX
USBX
TraceX
LevelX
  • USBX Documentation

    • Understand USBX
    • USBX documentation
    • Chapter 1 - Introduction to USBX Device Stack
    • Chapter 2 - USBX Device Stack Installation
    • Chapter 3 - Functional Components of USBX Device Stack
    • Chapter 4 - Description of USBX Device Services
    • Chapter 5 - USBX Device Class Considerations
    • Chapter 1 - Introduction to the USBX Device Stack User Guide Supplement
    • Chapter 2 - USBX Device Class Considerations
    • Chapter 3 - USBX DPUMP Class Considerations
    • Chapter 4 -USBX Pictbridge implementation
    • Chapter 5 - USBX OTG
    • Chapter 6 - USBX Implement controller driver (DCD)
    • Chapter 6 - USBX Implement device class modules
    • USBX Device Stack User Guide
    • Chapter 1 - Introduction to USBX Host Stack
    • Chapter 2 - USBX Host Stack Installation
    • Chapter 3 - Functional Components of USBX Host Stack
    • Chapter 4 - Description of USBX Host Services
    • Chapter 5 - USBX Host Classes API
    • Chapter 6 - USBX CDC-ECM Class Usage
    • Chapter 1 - Introduction to the USBX Host Stack User Guide Supplement
    • USBX Host Classes API
    • USBX DPUMP Class Considerations
    • USBX Pictbridge implementation
    • USBX OTG
    • USBX Host Stack User Guide

Chapter 6 - USBX CDC-ECM Class Usage

USBX contains a CDC-ECM class for the host and device side. This class is designed to be used with NetX Duo, specifically, the USBX CDC-ECM class acts as the driver for NetX Duo. This is why there are no CDC-ECM APIs listed in Chapter 5.

Once NetX Duo and USBX are initialized and an instance of a CDC-ECM device is found by USBX, the application exclusively uses NetX Duo to communicate with the device. Initialization follows the pattern shown in the example below.

UINT status;

/* The USB controller should be the last component initialized so that
everything is ready when data starts being received. */

/* Initialize USBX. */

ux_system_initialize(memory_pointer, UX_USBX_MEMORY_SIZE, UX_NULL, 0);

/* The code below is required for installing the host portion of USBX */
status = ux_host_stack_initialize(UX_NULL);

/* Register cdc_ecm class. */

status = ux_host_stack_class_register(_ux_system_host_class_cdc_ecm_name,
    ux_host_class_cdc_ecm_entry);

/* Perform the initialization of the network driver. */

_ux_network_driver_init();

/* Initialize NetX Duo. Refer to NetX Duo user guide for details to add initialization code. */

/* Register the platform-specific USB controller. */

status = ux_host_stack_hcd_register("controller_name", controller_entry, param1, param2);

/* Find the CDC-ECM class. */
class_cdc_ecm_get();

/* Now wait for the link to be up. */

while (cdc_ecm -> ux_host_class_cdc_ecm_link_state != UX_HOST_CLASS_CDC_ECM_LINK_STATE_UP)
    tx_thread_sleep(10);

/* At this point, everything has been initialized, and we've found a CDC-ECM device.
    Now NetX Duo can be used to communicate with the device. */
Prev
Chapter 5 - USBX Host Classes API
Next
Chapter 1 - Introduction to the USBX Host Stack User Guide Supplement