VSF Documented
Data Structures | Macros | Typedefs | Enumerations | Functions
usbd.c File Reference
#include "./usbd.h"
#include "service/trace/vsf_trace.h"

Data Structures

struct  ch32f10x_usbd_reg_t
 
struct  ch32f10x_usbd_pma_t
 

Macros

#define CH32F10X_USBD_CFG_TRACE_ARR   0
 
#define CH32F10X_USBD_CFG_TRACE_SYS   1
 
#define CH32F10X_USBD_CFG_TRACE   CH32F10X_USBD_CFG_TRACE_SYS
 
#define USB_EPR_STAT   3
 
#define USB_EPR_STAT_DISABLED   0
 
#define USB_EPR_STAT_STALL   1
 
#define USB_EPR_STAT_NAK   2
 
#define USB_EPR_STAT_VALID   3
 
#define USB_EPR_STAT_RX_OFFSET   12
 
#define USB_EPR_STAT_TX_OFFSET   4
 
#define USB_EPR_CTR_RX   (1 << 15)
 
#define USB_EPR_CTR_TX   (1 << 7)
 
#define USB_EPR_SETUP   (1 << 11)
 
#define USB_EPR_TYPE   (3 << 9)
 
#define USB_EPR_DTOG_RX   (1 << 14)
 
#define USB_EPR_DTOG_TX   (1 << 6)
 
#define USB_EPR_TOGGLE_BITS
 
#define __IO   volatile
 

Typedefs

typedef struct ch32f10x_usbd_reg_t ch32f10x_usbd_reg_t
 
typedef struct ch32f10x_usbd_pma_t ch32f10x_usbd_pma_t
 
typedef enum vsf_usbd_trace_t vsf_usbd_trace_t
 

Enumerations

enum  vsf_usbd_trace_t {
  VSF_USBD_TRACE_INVALID ,
  VSF_USBD_TRACE_TX ,
  VSF_USBD_TRACE_RX ,
  VSF_USBD_TRACE_TX_SET_STALL ,
  VSF_USBD_TRACE_RX_SET_STALL ,
  VSF_USBD_TRACE_TX_CLEAR_STALL ,
  VSF_USBD_TRACE_RX_CLEAR_STALL ,
  VSF_USBD_TRACE_ON_RESET ,
  VSF_USBD_TRACE_ON_SETUP ,
  VSF_USBD_TRACE_ON_IN ,
  VSF_USBD_TRACE_ON_OUT ,
  VSF_USBD_TRACE_ON_STATUS_IN ,
  VSF_USBD_TRACE_ON_STATUS_OUT ,
  VSF_USBD_TRACE_NUM
}
 

Functions

vsf_err_t ch32f10x_usbd_init (ch32f10x_usbd_t *usbd, usb_dc_cfg_t *cfg)
 
void ch32f10x_usbd_fini (ch32f10x_usbd_t *usbd)
 
void ch32f10x_usbd_reset (ch32f10x_usbd_t *usbd, usb_dc_cfg_t *cfg)
 
void ch32f10x_usbd_connect (ch32f10x_usbd_t *usbd)
 
void ch32f10x_usbd_disconnect (ch32f10x_usbd_t *usbd)
 
void ch32f10x_usbd_wakeup (ch32f10x_usbd_t *usbd)
 
void ch32f10x_usbd_set_address (ch32f10x_usbd_t *usbd, uint_fast8_t addr)
 
uint_fast8_t ch32f10x_usbd_get_address (ch32f10x_usbd_t *usbd)
 
uint_fast16_t ch32f10x_usbd_get_frame_number (ch32f10x_usbd_t *usbd)
 
uint_fast8_t ch32f10x_usbd_get_mframe_number (ch32f10x_usbd_t *usbd)
 
void ch32f10x_usbd_get_setup (ch32f10x_usbd_t *usbd, uint8_t *buffer)
 
void ch32f10x_usbd_status_stage (ch32f10x_usbd_t *usbd, bool is_in)
 
uint_fast8_t ch32f10x_usbd_ep_get_feature (ch32f10x_usbd_t *usbd, uint_fast8_t ep, uint_fast8_t feature)
 
vsf_err_t ch32f10x_usbd_ep_add (ch32f10x_usbd_t *usbd, uint_fast8_t ep, usb_ep_type_t type, uint_fast16_t size)
 
uint_fast16_t ch32f10x_usbd_ep_get_size (ch32f10x_usbd_t *usbd, uint_fast8_t ep)
 
vsf_err_t ch32f10x_usbd_ep_set_stall (ch32f10x_usbd_t *usbd, uint_fast8_t ep)
 
bool ch32f10x_usbd_ep_is_stalled (ch32f10x_usbd_t *usbd, uint_fast8_t ep)
 
vsf_err_t ch32f10x_usbd_ep_clear_stall (ch32f10x_usbd_t *usbd, uint_fast8_t ep)
 
uint_fast32_t ch32f10x_usbd_ep_get_data_size (ch32f10x_usbd_t *usbd, uint_fast8_t ep)
 
vsf_err_t ch32f10x_usbd_ep_transaction_read_buffer (ch32f10x_usbd_t *usbd, uint_fast8_t ep, uint8_t *buffer, uint_fast16_t size)
 
vsf_err_t ch32f10x_usbd_ep_transaction_enable_out (ch32f10x_usbd_t *usbd, uint_fast8_t ep)
 
vsf_err_t ch32f10x_usbd_ep_transaction_set_data_size (ch32f10x_usbd_t *usbd, uint_fast8_t ep, uint_fast16_t size)
 
vsf_err_t ch32f10x_usbd_ep_transaction_write_buffer (ch32f10x_usbd_t *usbd, uint_fast8_t ep, uint8_t *buffer, uint_fast16_t size)
 
vsf_err_t ch32f10x_usbd_ep_transfer_recv (ch32f10x_usbd_t *usbd, uint_fast8_t ep, uint8_t *buffer, uint_fast32_t size)
 
vsf_err_t ch32f10x_usbd_ep_transfer_send (ch32f10x_usbd_t *usbd, uint_fast8_t ep, uint8_t *buffer, uint_fast32_t size, bool zlp)
 
void ch32f10x_usbd_irq (ch32f10x_usbd_t *usbd)
 

Macro Definition Documentation

◆ CH32F10X_USBD_CFG_TRACE_ARR

#define CH32F10X_USBD_CFG_TRACE_ARR   0

◆ CH32F10X_USBD_CFG_TRACE_SYS

#define CH32F10X_USBD_CFG_TRACE_SYS   1

◆ CH32F10X_USBD_CFG_TRACE

#define CH32F10X_USBD_CFG_TRACE   CH32F10X_USBD_CFG_TRACE_SYS

◆ USB_EPR_STAT

#define USB_EPR_STAT   3

◆ USB_EPR_STAT_DISABLED

#define USB_EPR_STAT_DISABLED   0

◆ USB_EPR_STAT_STALL

#define USB_EPR_STAT_STALL   1

◆ USB_EPR_STAT_NAK

#define USB_EPR_STAT_NAK   2

◆ USB_EPR_STAT_VALID

#define USB_EPR_STAT_VALID   3

◆ USB_EPR_STAT_RX_OFFSET

#define USB_EPR_STAT_RX_OFFSET   12

◆ USB_EPR_STAT_TX_OFFSET

#define USB_EPR_STAT_TX_OFFSET   4

◆ USB_EPR_CTR_RX

#define USB_EPR_CTR_RX   (1 << 15)

◆ USB_EPR_CTR_TX

#define USB_EPR_CTR_TX   (1 << 7)

◆ USB_EPR_SETUP

#define USB_EPR_SETUP   (1 << 11)

◆ USB_EPR_TYPE

#define USB_EPR_TYPE   (3 << 9)

◆ USB_EPR_DTOG_RX

#define USB_EPR_DTOG_RX   (1 << 14)

◆ USB_EPR_DTOG_TX

#define USB_EPR_DTOG_TX   (1 << 6)

◆ USB_EPR_TOGGLE_BITS

#define USB_EPR_TOGGLE_BITS
Value:
#define USB_EPR_DTOG_TX
Definition usbd.c:50
#define USB_EPR_STAT_TX_OFFSET
Definition usbd.c:43
#define USB_EPR_DTOG_RX
Definition usbd.c:49
#define USB_EPR_STAT_VALID
Definition usbd.c:41
#define USB_EPR_STAT_RX_OFFSET
Definition usbd.c:42

◆ __IO

#define __IO   volatile

Typedef Documentation

◆ ch32f10x_usbd_reg_t

◆ ch32f10x_usbd_pma_t

◆ vsf_usbd_trace_t

Enumeration Type Documentation

◆ vsf_usbd_trace_t

Enumerator
VSF_USBD_TRACE_INVALID 
VSF_USBD_TRACE_TX 
VSF_USBD_TRACE_RX 
VSF_USBD_TRACE_TX_SET_STALL 
VSF_USBD_TRACE_RX_SET_STALL 
VSF_USBD_TRACE_TX_CLEAR_STALL 
VSF_USBD_TRACE_RX_CLEAR_STALL 
VSF_USBD_TRACE_ON_RESET 
VSF_USBD_TRACE_ON_SETUP 
VSF_USBD_TRACE_ON_IN 
VSF_USBD_TRACE_ON_OUT 
VSF_USBD_TRACE_ON_STATUS_IN 
VSF_USBD_TRACE_ON_STATUS_OUT 
VSF_USBD_TRACE_NUM 

Function Documentation

◆ ch32f10x_usbd_init()

vsf_err_t ch32f10x_usbd_init ( ch32f10x_usbd_t usbd,
usb_dc_cfg_t cfg 
)

◆ ch32f10x_usbd_fini()

void ch32f10x_usbd_fini ( ch32f10x_usbd_t usbd)

◆ ch32f10x_usbd_reset()

void ch32f10x_usbd_reset ( ch32f10x_usbd_t usbd,
usb_dc_cfg_t cfg 
)

◆ ch32f10x_usbd_connect()

void ch32f10x_usbd_connect ( ch32f10x_usbd_t usbd)

◆ ch32f10x_usbd_disconnect()

void ch32f10x_usbd_disconnect ( ch32f10x_usbd_t usbd)

◆ ch32f10x_usbd_wakeup()

void ch32f10x_usbd_wakeup ( ch32f10x_usbd_t usbd)

◆ ch32f10x_usbd_set_address()

void ch32f10x_usbd_set_address ( ch32f10x_usbd_t usbd,
uint_fast8_t  addr 
)

◆ ch32f10x_usbd_get_address()

uint_fast8_t ch32f10x_usbd_get_address ( ch32f10x_usbd_t usbd)

◆ ch32f10x_usbd_get_frame_number()

uint_fast16_t ch32f10x_usbd_get_frame_number ( ch32f10x_usbd_t usbd)

◆ ch32f10x_usbd_get_mframe_number()

uint_fast8_t ch32f10x_usbd_get_mframe_number ( ch32f10x_usbd_t usbd)

◆ ch32f10x_usbd_get_setup()

void ch32f10x_usbd_get_setup ( ch32f10x_usbd_t usbd,
uint8_t buffer 
)

◆ ch32f10x_usbd_status_stage()

void ch32f10x_usbd_status_stage ( ch32f10x_usbd_t usbd,
bool  is_in 
)

◆ ch32f10x_usbd_ep_get_feature()

uint_fast8_t ch32f10x_usbd_ep_get_feature ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep,
uint_fast8_t  feature 
)

◆ ch32f10x_usbd_ep_add()

vsf_err_t ch32f10x_usbd_ep_add ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep,
usb_ep_type_t  type,
uint_fast16_t  size 
)

◆ ch32f10x_usbd_ep_get_size()

uint_fast16_t ch32f10x_usbd_ep_get_size ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep 
)

◆ ch32f10x_usbd_ep_set_stall()

vsf_err_t ch32f10x_usbd_ep_set_stall ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep 
)

◆ ch32f10x_usbd_ep_is_stalled()

bool ch32f10x_usbd_ep_is_stalled ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep 
)

◆ ch32f10x_usbd_ep_clear_stall()

vsf_err_t ch32f10x_usbd_ep_clear_stall ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep 
)

◆ ch32f10x_usbd_ep_get_data_size()

uint_fast32_t ch32f10x_usbd_ep_get_data_size ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep 
)

◆ ch32f10x_usbd_ep_transaction_read_buffer()

vsf_err_t ch32f10x_usbd_ep_transaction_read_buffer ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep,
uint8_t buffer,
uint_fast16_t  size 
)

◆ ch32f10x_usbd_ep_transaction_enable_out()

vsf_err_t ch32f10x_usbd_ep_transaction_enable_out ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep 
)

◆ ch32f10x_usbd_ep_transaction_set_data_size()

vsf_err_t ch32f10x_usbd_ep_transaction_set_data_size ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep,
uint_fast16_t  size 
)

◆ ch32f10x_usbd_ep_transaction_write_buffer()

vsf_err_t ch32f10x_usbd_ep_transaction_write_buffer ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep,
uint8_t buffer,
uint_fast16_t  size 
)

◆ ch32f10x_usbd_ep_transfer_recv()

vsf_err_t ch32f10x_usbd_ep_transfer_recv ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep,
uint8_t buffer,
uint_fast32_t  size 
)

◆ ch32f10x_usbd_ep_transfer_send()

vsf_err_t ch32f10x_usbd_ep_transfer_send ( ch32f10x_usbd_t usbd,
uint_fast8_t  ep,
uint8_t buffer,
uint_fast32_t  size,
bool  zlp 
)

◆ ch32f10x_usbd_irq()

void ch32f10x_usbd_irq ( ch32f10x_usbd_t usbd)