Skip to content

File syn_usb_host_cdc.c

FileList > drivers > syn_usb_host_cdc.c

Go to the source code of this file

Zero-Heap USB 2.0 Host CDC ACM Class Driver Implementation.

  • #include "syntropic/drivers/syn_usb_host_cdc.h"
  • #include "port/syn_port_usb.h"
  • #include "port/syn_port_usb_host.h"
  • #include <string.h>

Public Functions

Type Name
SYN_Status syn_usb_host_cdc_init (SYN_USB_HostCDC * hcdc)
Initialize USB Host CDC instance with defaults (115200 8N1).
SYN_Status syn_usb_host_cdc_read (SYN_USB_HostCDC * hcdc, void * buf, size_t max_len, size_t * out_len)
Read bytes from USB Host CDC RX buffer.
SYN_Status syn_usb_host_cdc_register (SYN_USB_Host * host, SYN_USB_HostCDC * hcdc)
Register USB Host CDC class driver with USB Host Core.
bool syn_usb_host_cdc_rx_available (const SYN_USB_HostCDC * hcdc)
Check if receive data is available.
bool syn_usb_host_cdc_tx_ready (const SYN_USB_HostCDC * hcdc)
Check if transmit buffer is ready.
SYN_Status syn_usb_host_cdc_write (SYN_USB_HostCDC * hcdc, const void * data, size_t len)
Write bytes to USB Host CDC TX buffer.

Public Static Functions

Type Name
void host_cdc_disconnected (void * ctx)
Host class disconnected callback.
SYN_Status host_cdc_probe (void * ctx, uint8_t dev_addr, const uint8_t * iface_desc, uint16_t len)
Host class probe callback for CDC ACM interfaces.
void host_cdc_process (void * ctx)
Host class process/tick callback.

Public Functions Documentation

function syn_usb_host_cdc_init

Initialize USB Host CDC instance with defaults (115200 8N1).

SYN_Status syn_usb_host_cdc_init (
    SYN_USB_HostCDC * hcdc
) 

Parameters:

  • hcdc Pointer to USB Host CDC instance.

Returns:

SYN_OK on success.


function syn_usb_host_cdc_read

Read bytes from USB Host CDC RX buffer.

SYN_Status syn_usb_host_cdc_read (
    SYN_USB_HostCDC * hcdc,
    void * buf,
    size_t max_len,
    size_t * out_len
) 

Parameters:

  • hcdc Pointer to USB Host CDC instance.
  • buf Pointer to destination buffer.
  • max_len Max capacity.
  • out_len Pointer to receive read byte count.

Returns:

SYN_OK on success.


function syn_usb_host_cdc_register

Register USB Host CDC class driver with USB Host Core.

SYN_Status syn_usb_host_cdc_register (
    SYN_USB_Host * host,
    SYN_USB_HostCDC * hcdc
) 

Parameters:

  • host Pointer to USB Host instance.
  • hcdc Pointer to USB Host CDC instance.

Returns:

SYN_OK on success.


function syn_usb_host_cdc_rx_available

Check if receive data is available.

bool syn_usb_host_cdc_rx_available (
    const SYN_USB_HostCDC * hcdc
) 

Parameters:

  • hcdc Pointer to USB Host CDC instance.

Returns:

true if unread data is present.


function syn_usb_host_cdc_tx_ready

Check if transmit buffer is ready.

bool syn_usb_host_cdc_tx_ready (
    const SYN_USB_HostCDC * hcdc
) 

Parameters:

  • hcdc Pointer to USB Host CDC instance.

Returns:

true if transmit buffer is available.


function syn_usb_host_cdc_write

Write bytes to USB Host CDC TX buffer.

SYN_Status syn_usb_host_cdc_write (
    SYN_USB_HostCDC * hcdc,
    const void * data,
    size_t len
) 

Parameters:

  • hcdc Pointer to USB Host CDC instance.
  • data Pointer to data bytes.
  • len Byte length.

Returns:

SYN_OK on success.


Public Static Functions Documentation

function host_cdc_disconnected

Host class disconnected callback.

static void host_cdc_disconnected (
    void * ctx
) 

Parameters:


function host_cdc_probe

Host class probe callback for CDC ACM interfaces.

static SYN_Status host_cdc_probe (
    void * ctx,
    uint8_t dev_addr,
    const uint8_t * iface_desc,
    uint16_t len
) 

Parameters:

  • ctx Context pointer (SYN_USB_HostCDC).
  • dev_addr Device bus address.
  • iface_desc Pointer to interface descriptor payload.
  • len Descriptor byte length.

Returns:

SYN_OK on successful claim.


function host_cdc_process

Host class process/tick callback.

static void host_cdc_process (
    void * ctx
) 

Parameters:



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