Skip to content

File syn_port_usb.h

FileList > port > syn_port_usb.h

Go to the source code of this file

USB HAL hardware port interface contract.

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

Public Functions

Type Name
SYN_Status syn_port_usb_connect (void)
Signal physical USB connection/attach (e.g. enable D+ pullup).
SYN_Status syn_port_usb_disconnect (void)
Signal physical USB disconnect/detach (e.g. disable D+ pullup).
SYN_Status syn_port_usb_ep_close (uint8_t ep_addr)
Close a hardware endpoint.
SYN_Status syn_port_usb_ep_open (uint8_t ep_addr, uint8_t ep_type, uint16_t max_pkt)
Open and configure a hardware endpoint.
SYN_Status syn_port_usb_ep_read (uint8_t ep_addr, void * buf, uint16_t max_len, uint16_t * out_len)
Read packet from an OUT endpoint FIFO/buffer.
SYN_Status syn_port_usb_ep_stall (uint8_t ep_addr)
Signal STALL condition on an endpoint.
SYN_Status syn_port_usb_ep_write (uint8_t ep_addr, const void * data, uint16_t len)
Write packet to an IN endpoint FIFO/buffer.
SYN_Status syn_port_usb_init (void)
Initialize low-level USB peripheral hardware.
SYN_Status syn_port_usb_set_address (uint8_t addr)
Assign USB device address in hardware controller.

Macros

Type Name
define SYN_USB_EP_TYPE_BULK 2U
define SYN_USB_EP_TYPE_CONTROL 0U
define SYN_USB_EP_TYPE_INTR 3U
define SYN_USB_EP_TYPE_ISOC 1U

Public Functions Documentation

function syn_port_usb_connect

Signal physical USB connection/attach (e.g. enable D+ pullup).

SYN_Status syn_port_usb_connect (
    void
) 

Returns:

SYN_OK on success.


function syn_port_usb_disconnect

Signal physical USB disconnect/detach (e.g. disable D+ pullup).

SYN_Status syn_port_usb_disconnect (
    void
) 

Returns:

SYN_OK on success.


function syn_port_usb_ep_close

Close a hardware endpoint.

SYN_Status syn_port_usb_ep_close (
    uint8_t ep_addr
) 

Parameters:

  • ep_addr Endpoint address.

Returns:

SYN_OK on success.


function syn_port_usb_ep_open

Open and configure a hardware endpoint.

SYN_Status syn_port_usb_ep_open (
    uint8_t ep_addr,
    uint8_t ep_type,
    uint16_t max_pkt
) 

Parameters:

  • ep_addr Bit 7: Direction (0=OUT, 1=IN), Bits 3:0: Endpoint number.
  • ep_type Endpoint type (SYN_USB_EP_TYPE_*).
  • max_pkt Maximum packet size in bytes.

Returns:

SYN_OK on success.


function syn_port_usb_ep_read

Read packet from an OUT endpoint FIFO/buffer.

SYN_Status syn_port_usb_ep_read (
    uint8_t ep_addr,
    void * buf,
    uint16_t max_len,
    uint16_t * out_len
) 

Parameters:

  • ep_addr Endpoint address.
  • buf Destination buffer.
  • max_len Max capacity.
  • out_len Pointer to receive read byte count.

Returns:

SYN_OK on success, SYN_BUSY if no packet available.


function syn_port_usb_ep_stall

Signal STALL condition on an endpoint.

SYN_Status syn_port_usb_ep_stall (
    uint8_t ep_addr
) 

Parameters:

  • ep_addr Endpoint address.

Returns:

SYN_OK on success.


function syn_port_usb_ep_write

Write packet to an IN endpoint FIFO/buffer.

SYN_Status syn_port_usb_ep_write (
    uint8_t ep_addr,
    const void * data,
    uint16_t len
) 

Parameters:

  • ep_addr Endpoint address.
  • data Pointer to payload bytes.
  • len Byte length.

Returns:

SYN_OK on success.


function syn_port_usb_init

Initialize low-level USB peripheral hardware.

SYN_Status syn_port_usb_init (
    void
) 

Returns:

SYN_OK on success.


function syn_port_usb_set_address

Assign USB device address in hardware controller.

SYN_Status syn_port_usb_set_address (
    uint8_t addr
) 

Parameters:

  • addr assigned address (1..127).

Returns:

SYN_OK on success.


Macro Definition Documentation

define SYN_USB_EP_TYPE_BULK

#define SYN_USB_EP_TYPE_BULK `2U`

Bulk Endpoint (2)


define SYN_USB_EP_TYPE_CONTROL

#define SYN_USB_EP_TYPE_CONTROL `0U`

USB Endpoint Types per USB Spec Control Endpoint (0)


define SYN_USB_EP_TYPE_INTR

#define SYN_USB_EP_TYPE_INTR `3U`

Interrupt Endpoint (3)


define SYN_USB_EP_TYPE_ISOC

#define SYN_USB_EP_TYPE_ISOC `1U`

Isochronous Endpoint (1)



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