Skip to content

File syn_usb.c

FileList > drivers > syn_usb.c

Go to the source code of this file

Zero-Heap Modular USB 2.0 Device Core Protocol Engine Implementation.

  • #include "syntropic/drivers/syn_usb.h"
  • #include <string.h>

Public Static Attributes

Type Name
const uint8_t CONFIG_HEADER_TEMPLATE = /* multi line expression */

Public Functions

Type Name
SYN_Status syn_usb_init (SYN_USB_Device * dev, const uint8_t * device_desc)
Initialize USB Device Core with standard 18-byte Device Descriptor.
bool syn_usb_is_configured (const SYN_USB_Device * dev)
Check if USB device is in CONFIGURED state.
SYN_Status syn_usb_process_setup (SYN_USB_Device * dev, const SYN_USB_SetupPacket * pkt, uint8_t * resp, uint16_t * rlen)
Process Control Setup packet from Host (EP0).
SYN_Status syn_usb_register_class (SYN_USB_Device * dev, const SYN_USB_ClassDriver * cls, const uint8_t * iface_desc, uint16_t iface_desc_len)
Register a class driver and append its interface descriptors.
SYN_Status syn_usb_set_raw_config_desc (SYN_USB_Device * dev, const uint8_t * desc, uint16_t len)
Set raw configuration descriptor pointer (overrides auto-assembly).
SYN_Status syn_usb_set_string_desc (SYN_USB_Device * dev, uint8_t index, const uint8_t * desc)
Set string descriptor pointer for a given index.

Public Static Attributes Documentation

variable CONFIG_HEADER_TEMPLATE

const uint8_t CONFIG_HEADER_TEMPLATE[9];

Standard Configuration Descriptor Header Template (9 bytes)


Public Functions Documentation

function syn_usb_init

Initialize USB Device Core with standard 18-byte Device Descriptor.

SYN_Status syn_usb_init (
    SYN_USB_Device * dev,
    const uint8_t * device_desc
) 

Parameters:

  • dev Pointer to USB device instance.
  • device_desc Pointer to 18-byte standard USB device descriptor.

Returns:

SYN_OK on success.


function syn_usb_is_configured

Check if USB device is in CONFIGURED state.

bool syn_usb_is_configured (
    const SYN_USB_Device * dev
) 

Parameters:

  • dev Pointer to USB device context.

Returns:

true if device is configured.


function syn_usb_process_setup

Process Control Setup packet from Host (EP0).

SYN_Status syn_usb_process_setup (
    SYN_USB_Device * dev,
    const SYN_USB_SetupPacket * pkt,
    uint8_t * resp,
    uint16_t * rlen
) 

Parameters:

  • dev Pointer to USB device context.
  • pkt Pointer to received Setup Packet.
  • resp Output buffer for data stage response.
  • rlen Output pointer to receive response byte length.

Returns:

SYN_OK on success.


function syn_usb_register_class

Register a class driver and append its interface descriptors.

SYN_Status syn_usb_register_class (
    SYN_USB_Device * dev,
    const SYN_USB_ClassDriver * cls,
    const uint8_t * iface_desc,
    uint16_t iface_desc_len
) 

Parameters:

  • dev Pointer to USB device context.
  • cls Class driver vtable and binding context.
  • iface_desc Pointer to class interface descriptor payload.
  • iface_desc_len Length of interface descriptor payload.

Returns:

SYN_OK on success.


function syn_usb_set_raw_config_desc

Set raw configuration descriptor pointer (overrides auto-assembly).

SYN_Status syn_usb_set_raw_config_desc (
    SYN_USB_Device * dev,
    const uint8_t * desc,
    uint16_t len
) 

Parameters:

  • dev Pointer to USB device context.
  • desc Pointer to raw configuration descriptor.
  • len Length in bytes.

Returns:

SYN_OK on success.


function syn_usb_set_string_desc

Set string descriptor pointer for a given index.

SYN_Status syn_usb_set_string_desc (
    SYN_USB_Device * dev,
    uint8_t index,
    const uint8_t * desc
) 

Parameters:

  • dev Pointer to USB device context.
  • index String index (0=Language ID, 1=Manufacturer, 2=Product, etc).
  • desc Pointer to UNICODE string descriptor.

Returns:

SYN_OK on success.



The documentation for this class was generated from the following file src/syntropic/drivers/syn_usb.c