Skip to content

File syn_port_usb_host.h

FileList > port > syn_port_usb_host.h

Go to the source code of this file

USB Host HAL hardware port interface contract. More...

  • #include "syn_port_usb.h"
  • #include "syntropic/common/syn_defs.h"
  • #include "syntropic/drivers/syn_usb.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Public Functions

Type Name
SYN_Status syn_port_usb_host_bus_reset (void)
Issue USB bus reset (10ms SE0 signaling).
bool syn_port_usb_host_device_attached (void)
Check if a downstream USB device is physically attached.
SYN_Status syn_port_usb_host_init (void)
Initialize USB Host controller hardware.
SYN_Status syn_port_usb_host_pipe_close (uint8_t pipe)
Close a host pipe.
SYN_Status syn_port_usb_host_pipe_open (uint8_t pipe, uint8_t dev_addr, uint8_t ep_addr, uint8_t ep_type, uint16_t max_pkt)
Open a host pipe to a device endpoint.
SYN_Status syn_port_usb_host_submit_data (uint8_t pipe, uint8_t * buf, uint16_t len, bool is_in)
Submit a data stage transfer on a pipe (non-blocking).
SYN_Status syn_port_usb_host_submit_setup (uint8_t pipe, const SYN_USB_SetupPacket * pkt)
Submit a control setup packet on a pipe (non-blocking).
SYN_Status syn_port_usb_host_vbus (bool enable)
Enable or disable VBUS 5V power supply to downstream port.
bool syn_port_usb_host_xfer_done (uint8_t pipe)
Check if a submitted transfer has completed.
SYN_Status syn_port_usb_host_xfer_result (uint8_t pipe, uint16_t * actual_len)
Get the result of a completed transfer.

Detailed Description

Provides the hardware abstraction for USB Host controllers. Transfer model is non-blocking: submit a transfer, poll for completion, then read the result. Fits cooperative protothreads.

Public Functions Documentation

function syn_port_usb_host_bus_reset

Issue USB bus reset (10ms SE0 signaling).

SYN_Status syn_port_usb_host_bus_reset (
    void
) 

Returns:

SYN_OK on success.


function syn_port_usb_host_device_attached

Check if a downstream USB device is physically attached.

bool syn_port_usb_host_device_attached (
    void
) 

Returns:

true if device detected on the port.


function syn_port_usb_host_init

Initialize USB Host controller hardware.

SYN_Status syn_port_usb_host_init (
    void
) 

Returns:

SYN_OK on success.


function syn_port_usb_host_pipe_close

Close a host pipe.

SYN_Status syn_port_usb_host_pipe_close (
    uint8_t pipe
) 

Parameters:

  • pipe Pipe index.

Returns:

SYN_OK on success.


function syn_port_usb_host_pipe_open

Open a host pipe to a device endpoint.

SYN_Status syn_port_usb_host_pipe_open (
    uint8_t pipe,
    uint8_t dev_addr,
    uint8_t ep_addr,
    uint8_t ep_type,
    uint16_t max_pkt
) 

Parameters:

  • pipe Pipe index (0..SYN_USB_HOST_MAX_PIPES-1).
  • dev_addr Target device bus address (0 during initial enum).
  • ep_addr Target endpoint address (bit 7 = direction).
  • ep_type Endpoint type (SYN_USB_EP_TYPE_*).
  • max_pkt Maximum packet size.

Returns:

SYN_OK on success.


function syn_port_usb_host_submit_data

Submit a data stage transfer on a pipe (non-blocking).

SYN_Status syn_port_usb_host_submit_data (
    uint8_t pipe,
    uint8_t * buf,
    uint16_t len,
    bool is_in
) 

Parameters:

  • pipe Pipe index.
  • buf Data buffer (IN: filled on completion, OUT: sent).
  • len Byte length.
  • is_in true for IN (device-to-host), false for OUT.

Returns:

SYN_OK if submitted.


function syn_port_usb_host_submit_setup

Submit a control setup packet on a pipe (non-blocking).

SYN_Status syn_port_usb_host_submit_setup (
    uint8_t pipe,
    const SYN_USB_SetupPacket * pkt
) 

Parameters:

  • pipe Pipe index (must be open as Control type).
  • pkt Pointer to 8-byte USB Setup Packet.

Returns:

SYN_OK if submitted.


function syn_port_usb_host_vbus

Enable or disable VBUS 5V power supply to downstream port.

SYN_Status syn_port_usb_host_vbus (
    bool enable
) 

Parameters:

  • enable true to power on, false to power off.

Returns:

SYN_OK on success.


function syn_port_usb_host_xfer_done

Check if a submitted transfer has completed.

bool syn_port_usb_host_xfer_done (
    uint8_t pipe
) 

Parameters:

  • pipe Pipe index.

Returns:

true if the last submitted transfer is complete.


function syn_port_usb_host_xfer_result

Get the result of a completed transfer.

SYN_Status syn_port_usb_host_xfer_result (
    uint8_t pipe,
    uint16_t * actual_len
) 

Parameters:

  • pipe Pipe index.
  • actual_len [out] Actual bytes transferred.

Returns:

SYN_OK on success, SYN_ERROR on transfer error.



The documentation for this class was generated from the following file src/port/syn_port_usb_host.h