USB Device Vendor API#

USB Device Vendor API.

Modules#

sl_usbd_vendor_callbacks_t

Typedefs#

typedef void(*
sl_usbd_vendor_async_function_t)(uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint32_t xfer_len, void *p_callback_arg, sl_status_t status)

App callback used for async comm.

Functions#

sl_status_t

FUNCTION PROTOTYPES.

sl_status_t
sl_usbd_vendor_create_instance(bool intr_en, uint16_t interval, sl_usbd_vendor_callbacks_t *p_vendor_callbacks, uint8_t *p_class_nbr)

Add a new instance of the Vendor class.

sl_status_t
sl_usbd_vendor_add_to_configuration(uint8_t class_nbr, uint8_t config_nbr)

Add the Vendor class instance into the specified configuration (see Note #1).

sl_status_t
sl_usbd_vendor_is_enabled(uint8_t class_nbr, bool *p_enabled)

Get the vendor class enable state.

sl_status_t

Add a Microsoft OS extended property to this vendor class instance.

sl_status_t

Abort send the data to the host through the Bulk IN endpoint.

sl_status_t

Abort receive the data from the host through the Interrupt OUT endpoint.

sl_status_t

Abort send the data to the host through the Interrupt IN endpoint.

sl_status_t
sl_usbd_vendor_read_bulk_sync(uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint16_t timeout, uint32_t *p_xfer_len)

Receive the data from the host through the Bulk OUT endpoint.

sl_status_t
sl_usbd_vendor_write_bulk_sync(uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint16_t timeout, bool end, uint32_t *p_xfer_len)

Send data to the host through Bulk IN endpoint.

sl_status_t
sl_usbd_vendor_read_bulk_async(uint8_t class_nbr, void *p_buf, uint32_t buf_len, sl_usbd_vendor_async_function_t async_fnct, void *p_async_arg)

Receive data from the host through the Bulk OUT endpoint.

sl_status_t
sl_usbd_vendor_write_bulk_async(uint8_t class_nbr, void *p_buf, uint32_t buf_len, sl_usbd_vendor_async_function_t async_fnct, void *p_async_arg, bool end)

Send data to the host through the Bulk IN endpoint.

sl_status_t
sl_usbd_vendor_read_interrupt_sync(uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint16_t timeout, uint32_t *p_xfer_len)

Receive data from the the host through the Interrupt OUT endpoint.

sl_status_t
sl_usbd_vendor_write_interrupt_sync(uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint16_t timeout, bool end, uint32_t *p_xfer_len)

Send data to the host through the Interrupt IN endpoint.

sl_status_t
sl_usbd_vendor_read_interrupt_async(uint8_t class_nbr, void *p_buf, uint32_t buf_len, sl_usbd_vendor_async_function_t async_fnct, void *p_async_arg)

Receive data from the host through Interrupt OUT endpoint.

sl_status_t
sl_usbd_vendor_write_interrupt_async(uint8_t class_nbr, void *p_buf, uint32_t buf_len, sl_usbd_vendor_async_function_t async_fnct, void *p_async_arg, bool end)

Send data to the host through the Interrupt IN endpoint.

Typedef Documentation#

sl_usbd_vendor_async_function_t#

typedef void(* sl_usbd_vendor_async_function_t) (uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint32_t xfer_len, void *p_callback_arg, sl_status_t status) )(uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint32_t xfer_len, void *p_callback_arg, sl_status_t status)

App callback used for async comm.


Definition at line 63 of file protocol/usb/inc/sl_usbd_class_vendor.h

Function Documentation#

sl_usbd_vendor_init#

sl_status_t sl_usbd_vendor_init (void)

FUNCTION PROTOTYPES.

Parameters
N/A

VENDOR FUNCTIONS

Initialize the internal structures and variables used by the Vendor class.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 89 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_create_instance#

sl_status_t sl_usbd_vendor_create_instance (bool intr_en, uint16_t interval, sl_usbd_vendor_callbacks_t *p_vendor_callbacks, uint8_t *p_class_nbr)

Add a new instance of the Vendor class.

Parameters
N/Aintr_en

Interrupt endpoints IN and OUT flag:

  • true Pair of interrupt endpoints added to interface.

  • false Pair of interrupt endpoints not added to interface.

N/Ainterval

Endpoint interval in milliseconds (must be a power of 2).

N/Ap_vendor_callbacks

Pointer to vendor callback structure. [Content MUST be persistent]

N/Ap_class_nbr

Pointer to a variable that will receive class instance number, if no errors are returned, or SL_USBD_CLASS_NBR_NONE otherwise.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 108 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_add_to_configuration#

sl_status_t sl_usbd_vendor_add_to_configuration (uint8_t class_nbr, uint8_t config_nbr)

Add the Vendor class instance into the specified configuration (see Note #1).

Parameters
N/Aclass_nbr

Class instance number.

N/Aconfig_nbr

Configuration index to which to add the Vendor class instance.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

Note

  • (1) Called several times, it creates multiple instances and configurations. For instance, the following architecture could be created :

    *               FS
    *               |-- Configuration 0
    *                   |-- Interface 0 (Vendor 0)
    *               |-- Configuration 1
    *                   |-- Interface 0 (Vendor 0)
    *                   |-- Interface 1 (Vendor 1)
    *               

    In that example, there are two instances of Vendor class: 'Vendor 0' and '1', and two possible configurations: 'Configuration 0' and '1'. 'Configuration 1' is composed of two interfaces. Each class instance has an association with one of the interfaces. If 'Configuration 1' is activated by the host, it allows the host to access two different functionalities offered by the device.

  • (2) Configuration Descriptor corresponding to a Vendor-specific device has the following format :

    *               Configuration Descriptor
    *               |-- Interface Descriptor (Vendor class)
    *                   |-- Endpoint Descriptor (Bulk OUT)
    *                   |-- Endpoint Descriptor (Bulk IN)
    *                   |-- Endpoint Descriptor (Interrupt OUT) - optional
    *                   |-- Endpoint Descriptor (Interrupt IN)  - optional
    *               

Definition at line 149 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_is_enabled#

sl_status_t sl_usbd_vendor_is_enabled (uint8_t class_nbr, bool *p_enabled)

Get the vendor class enable state.

Parameters
N/Aclass_nbr

Class instance number.

N/Ap_enabled

Pointer to a variable that will receive the enable state. The variable is set to true, if the Vendor class is enabled, and is set to false if the Vendor class is NOT enabled.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 163 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_abort_read_bulk#

sl_status_t sl_usbd_vendor_abort_read_bulk (uint8_t class_nbr)

Add a Microsoft OS extended property to this vendor class instance.

Parameters
N/Aclass_nbr

Class instance number.

N/Aproperty_type

Property type (see Note #2).

  • OS_PROPERTY_TYPE_REG_SZ

  • OS_PROPERTY_TYPE_REG_EXPAND_SZ

  • OS_PROPERTY_TYPE_REG_BINARY

  • OS_PROPERTY_TYPE_REG_DWORD_LITTLE_ENDIAN

  • OS_PROPERTY_TYPE_REG_DWORD_BIG_ENDIAN

  • OS_PROPERTY_TYPE_REG_LINK

  • OS_PROPERTY_TYPE_REG_MULTI_SZ

N/Ap_property_name

Pointer to the buffer that contains the property name. -— Buffer assumed to be persistent -—

N/Aproperty_name_len

Length of the property name in octets.

N/Ap_property

Pointer to the buffer that contains the property name. -— Buffer assumed to be persistent -—

N/Aproperty_len

Length of the property in octets.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

Note

Abort receive the data from the host through the Bulk OUT endpoint.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 216 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_abort_write_bulk#

sl_status_t sl_usbd_vendor_abort_write_bulk (uint8_t class_nbr)

Abort send the data to the host through the Bulk IN endpoint.

Parameters
N/Aclass_nbr

Class instance number.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 225 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_abort_read_interrupt#

sl_status_t sl_usbd_vendor_abort_read_interrupt (uint8_t class_nbr)

Abort receive the data from the host through the Interrupt OUT endpoint.

Parameters
N/Aclass_nbr

Class instance number.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 234 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_abort_write_interrupt#

sl_status_t sl_usbd_vendor_abort_write_interrupt (uint8_t class_nbr)

Abort send the data to the host through the Interrupt IN endpoint.

Parameters
N/Aclass_nbr

Class instance number.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 243 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_read_bulk_sync#

sl_status_t sl_usbd_vendor_read_bulk_sync (uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint16_t timeout, uint32_t *p_xfer_len)

Receive the data from the host through the Bulk OUT endpoint.

Parameters
N/Aclass_nbr

Class instance number.

N/Ap_buf

Pointer to the receive buffer.

N/Abuf_len

Receive the buffer length in octets.

N/Atimeout

Timeout in milliseconds.

N/Ap_xfer_len

Pointer to a variable that will receive transfer length. The variable is set to number of octets received, if no errors are returned, or is set to 0 if any errors are returned.

This function is blocking.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 262 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_write_bulk_sync#

sl_status_t sl_usbd_vendor_write_bulk_sync (uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint16_t timeout, bool end, uint32_t *p_xfer_len)

Send data to the host through Bulk IN endpoint.

Parameters
N/Aclass_nbr

Class instance number.

N/Ap_buf

Pointer to the transmit buffer.

N/Abuf_len

Transmit the buffer length in octets.

N/Atimeout

Timeout in milliseconds.

N/Aend

End-of-transfer flag (see Note #1).

N/Ap_xfer_len

Pointer to a variable that will receive transfer length. The variable is set to number of octets received, if no errors are returned, or is set to 0 if any errors are returned.

This function is blocking.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

Note

  • (1) If the end-of-transfer is set and the transfer length is a multiple of the maximum packet size, a zero-length packet is transferred to signal the end of transfer to the host.


Definition at line 290 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_read_bulk_async#

sl_status_t sl_usbd_vendor_read_bulk_async (uint8_t class_nbr, void *p_buf, uint32_t buf_len, sl_usbd_vendor_async_function_t async_fnct, void *p_async_arg)

Receive data from the host through the Bulk OUT endpoint.

Parameters
N/Aclass_nbr

Class instance number.

N/Ap_buf

Pointer to the receive buffer.

N/Abuf_len

Receive buffer length in octets.

N/Aasync_fnct

Receive the the callback.

N/Ap_async_arg

Additional argument provided by the application for the receive callback.

This function is non-blocking are returns immediately after transfer preparation. Upon transfer completion, a callback provided by the application will be called to finalize the transfer.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 314 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_write_bulk_async#

sl_status_t sl_usbd_vendor_write_bulk_async (uint8_t class_nbr, void *p_buf, uint32_t buf_len, sl_usbd_vendor_async_function_t async_fnct, void *p_async_arg, bool end)

Send data to the host through the Bulk IN endpoint.

Parameters
N/Aclass_nbr

Class instance number.

N/Ap_buf

Pointer to the transmit buffer.

N/Abuf_len

Transmit buffer length in octets.

N/Aasync_fnct

Transmit the callback.

N/Ap_async_arg

Additional argument provided by the application for the transmit callback.

N/Aend

End-of-transfer flag (see Note #1).

This function is non-blocking and returns immediately after transfer preparation. Upon transfer completion, a callback provided by the application will be called to finalize the transfer.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

Note

  • (1) If the end-of-transfer is set and the transfer length is a multiple of the maximum packet size, a zero-length packet is transferred to signal the end of transfer to the host.


Definition at line 342 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_read_interrupt_sync#

sl_status_t sl_usbd_vendor_read_interrupt_sync (uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint16_t timeout, uint32_t *p_xfer_len)

Receive data from the the host through the Interrupt OUT endpoint.

Parameters
N/Aclass_nbr

Class instance number.

N/Ap_buf

Pointer to the receive buffer.

N/Abuf_len

Receive buffer length in octets.

N/Atimeout

Timeout in milliseconds.

N/Ap_xfer_len

Pointer to a variable that will receive transfer length. The variable is set to number of octets received, if no errors are returned, or is set to 0 if any errors are returned.

This function is blocking.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 366 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_write_interrupt_sync#

sl_status_t sl_usbd_vendor_write_interrupt_sync (uint8_t class_nbr, void *p_buf, uint32_t buf_len, uint16_t timeout, bool end, uint32_t *p_xfer_len)

Send data to the host through the Interrupt IN endpoint.

Parameters
N/Aclass_nbr

Class instance number.

N/Ap_buf

Pointer to the transmit buffer.

N/Abuf_len

Transmit buffer length in octets.

N/Atimeout

Timeout in milliseconds.

N/Aend

End-of-transfer flag (see Note #1).

N/Ap_xfer_len

Pointer to a variable that will receive transfer length. The variable is set to number of octets received, if no errors are returned, or is set to 0 if any errors are returned.

This function is blocking.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

Note

  • (1) If the end-of-transfer is set and the transfer length is a multiple of the maximum packet size, a zero-length packet is transferred to signal the end of transfer to the host.


Definition at line 394 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_read_interrupt_async#

sl_status_t sl_usbd_vendor_read_interrupt_async (uint8_t class_nbr, void *p_buf, uint32_t buf_len, sl_usbd_vendor_async_function_t async_fnct, void *p_async_arg)

Receive data from the host through Interrupt OUT endpoint.

Parameters
N/Aclass_nbr

Class instance number.

N/Ap_buf

Pointer to the receive buffer.

N/Abuf_len

Receive buffer length in octets.

N/Aasync_fnct

Receive callback.

N/Ap_async_arg

Additional argument provided by application for the receive callback.

This function is non-blocking and returns immediately after transfer preparation. Upon transfer completion, a callback provided by the application will be called to finalize the transfer.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.


Definition at line 418 of file protocol/usb/inc/sl_usbd_class_vendor.h

sl_usbd_vendor_write_interrupt_async#

sl_status_t sl_usbd_vendor_write_interrupt_async (uint8_t class_nbr, void *p_buf, uint32_t buf_len, sl_usbd_vendor_async_function_t async_fnct, void *p_async_arg, bool end)

Send data to the host through the Interrupt IN endpoint.

Parameters
N/Aclass_nbr

Class instance number.

N/Ap_buf

Pointer to the transmit buffer.

N/Abuf_len

Transmit buffer length in octets.

N/Aasync_fnct

Transmit callback.

N/Ap_async_arg

Additional argument provided by the application for the transmit callback.

N/Aend

End-of-transfer flag (see Note #1).

This function is non-blocking and returns immediately after transfer preparation. Upon transfer completion, a callback provided by the application will be called to finalize the transfer.

Returns

  • Returns SL_STATUS_OK on success or another SL_STATUS code on failure.

Note

  • (1) If the end-of-transfer is set and the transfer length is a multiple of the maximum packet size, a zero-length packet is transferred to signal the end of transfer to the host.


Definition at line 446 of file protocol/usb/inc/sl_usbd_class_vendor.h