Open FFBoard
Open source force feedback firmware
hcd_dwc2.c File Reference

Go to the source code of this file.

Classes

struct  hcd_endpoint_t
 
struct  hcd_endpoint_t::TU_ATTR_PACKED
 
struct  hcd_xfer_t
 
struct  hcd_xfer_t::TU_ATTR_PACKED
 
struct  hcd_data_t
 

Enumerations

enum  { HPRT_W1_MASK = HPRT_CONN_DETECT | HPRT_ENABLE | HPRT_ENABLE_CHANGE | HPRT_OVER_CURRENT_CHANGE | HPRT_SUSPEND }
 
enum  { HCD_XFER_ERROR_MAX = 3 }
 
enum  { HCD_XFER_PERIOD_SPLIT_NYET_MAX = 3 }
 

Functions

 TU_VERIFY_STATIC (CFG_TUH_DWC2_ENDPOINT_MAX<=255, "currently only use 8-bit for index")
 
static TU_ATTR_ALWAYS_INLINE tusb_speed_t hprt_speed_get (dwc2_regs_t *dwc2)
 
static TU_ATTR_ALWAYS_INLINE bool dma_host_enabled (const dwc2_regs_t *dwc2)
 
static TU_ATTR_ALWAYS_INLINE uint8_t channel_alloc (dwc2_regs_t *dwc2)
 
static TU_ATTR_ALWAYS_INLINE bool edpt_is_periodic (uint8_t ep_type)
 
static TU_ATTR_ALWAYS_INLINE uint8_t req_queue_avail (const dwc2_regs_t *dwc2, bool is_period)
 
static TU_ATTR_ALWAYS_INLINE void channel_dealloc (dwc2_regs_t *dwc2, uint8_t ch_id)
 
static TU_ATTR_ALWAYS_INLINE bool channel_disable (const dwc2_regs_t *dwc2, dwc2_channel_t *channel)
 
static TU_ATTR_ALWAYS_INLINE bool channel_send_in_token (const dwc2_regs_t *dwc2, dwc2_channel_t *channel)
 
static TU_ATTR_ALWAYS_INLINE uint8_t channel_find_enabled (dwc2_regs_t *dwc2, uint8_t dev_addr, uint8_t ep_num, uint8_t ep_dir)
 
static TU_ATTR_ALWAYS_INLINE uint8_t edpt_alloc (void)
 
static TU_ATTR_ALWAYS_INLINE uint8_t edpt_find_opened (uint8_t dev_addr, uint8_t ep_num, uint8_t ep_dir)
 
static TU_ATTR_ALWAYS_INLINE uint16_t cal_packet_count (uint16_t len, uint16_t ep_size)
 
static TU_ATTR_ALWAYS_INLINE uint8_t cal_next_pid (uint8_t pid, uint8_t packet_count)
 
static void dfifo_host_init (uint8_t rhport)
 
bool hcd_configure (uint8_t rhport, uint32_t cfg_id, const void *cfg_param)
 
bool hcd_init (uint8_t rhport, const tusb_rhport_init_t *rh_init)
 
void hcd_int_enable (uint8_t rhport)
 
void hcd_int_disable (uint8_t rhport)
 
uint32_t hcd_frame_number (uint8_t rhport)
 
bool hcd_port_connect_status (uint8_t rhport)
 
void hcd_port_reset (uint8_t rhport)
 
void hcd_port_reset_end (uint8_t rhport)
 
tusb_speed_t hcd_port_speed_get (uint8_t rhport)
 
void hcd_device_close (uint8_t rhport, uint8_t dev_addr)
 
bool hcd_edpt_open (uint8_t rhport, uint8_t dev_addr, const tusb_desc_endpoint_t *desc_ep)
 
static void channel_xfer_out_wrapup (dwc2_regs_t *dwc2, uint8_t ch_id)
 
static bool channel_xfer_start (dwc2_regs_t *dwc2, uint8_t ch_id)
 
static bool edpt_xfer_kickoff (dwc2_regs_t *dwc2, uint8_t ep_id)
 
bool hcd_edpt_xfer (uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr, uint8_t *buffer, uint16_t buflen)
 
bool hcd_edpt_abort_xfer (uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr)
 
bool hcd_setup_send (uint8_t rhport, uint8_t dev_addr, const uint8_t setup_packet[8])
 
bool hcd_edpt_clear_stall (uint8_t rhport, uint8_t dev_addr, uint8_t ep_addr)
 
static void channel_xfer_in_retry (dwc2_regs_t *dwc2, uint8_t ch_id, uint32_t hcint)
 
static TU_ATTR_ALWAYS_INLINE void print_hcint (uint32_t hcint)
 
static void handle_rxflvl_irq (uint8_t rhport)
 
static bool handle_txfifo_empty (dwc2_regs_t *dwc2, bool is_periodic)
 
static bool handle_channel_in_slave (dwc2_regs_t *dwc2, uint8_t ch_id, uint32_t hcint)
 
static bool handle_channel_out_slave (dwc2_regs_t *dwc2, uint8_t ch_id, uint32_t hcint)
 
static bool handle_channel_in_dma (dwc2_regs_t *dwc2, uint8_t ch_id, uint32_t hcint)
 
static bool handle_channel_out_dma (dwc2_regs_t *dwc2, uint8_t ch_id, uint32_t hcint)
 
static void handle_channel_irq (uint8_t rhport, bool in_isr)
 
static bool handle_sof_irq (uint8_t rhport, bool in_isr)
 
static void port0_enable (dwc2_regs_t *dwc2, tusb_speed_t speed)
 
static void handle_hprt_irq (uint8_t rhport, bool in_isr)
 
void hcd_int_handler (uint8_t rhport, bool in_isr)
 

Variables

hcd_data_t _hcd_data
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
HPRT_W1_MASK 

Definition at line 47 of file hcd_dwc2.c.

◆ anonymous enum

anonymous enum
Enumerator
HCD_XFER_ERROR_MAX 

Definition at line 51 of file hcd_dwc2.c.

◆ anonymous enum

anonymous enum
Enumerator
HCD_XFER_PERIOD_SPLIT_NYET_MAX 

Definition at line 55 of file hcd_dwc2.c.

Function Documentation

◆ cal_next_pid()

static TU_ATTR_ALWAYS_INLINE uint8_t cal_next_pid ( uint8_t  pid,
uint8_t  packet_count 
)
inlinestatic

Definition at line 232 of file hcd_dwc2.c.

◆ cal_packet_count()

static TU_ATTR_ALWAYS_INLINE uint16_t cal_packet_count ( uint16_t  len,
uint16_t  ep_size 
)
inlinestatic

Definition at line 224 of file hcd_dwc2.c.

◆ channel_alloc()

static TU_ATTR_ALWAYS_INLINE uint8_t channel_alloc ( dwc2_regs_t dwc2)
inlinestatic

Definition at line 136 of file hcd_dwc2.c.

◆ channel_dealloc()

static TU_ATTR_ALWAYS_INLINE void channel_dealloc ( dwc2_regs_t dwc2,
uint8_t  ch_id 
)
inlinestatic

Definition at line 162 of file hcd_dwc2.c.

◆ channel_disable()

static TU_ATTR_ALWAYS_INLINE bool channel_disable ( const dwc2_regs_t dwc2,
dwc2_channel_t channel 
)
inlinestatic

Definition at line 168 of file hcd_dwc2.c.

◆ channel_find_enabled()

static TU_ATTR_ALWAYS_INLINE uint8_t channel_find_enabled ( dwc2_regs_t dwc2,
uint8_t  dev_addr,
uint8_t  ep_num,
uint8_t  ep_dir 
)
inlinestatic

Definition at line 184 of file hcd_dwc2.c.

◆ channel_send_in_token()

static TU_ATTR_ALWAYS_INLINE bool channel_send_in_token ( const dwc2_regs_t dwc2,
dwc2_channel_t channel 
)
inlinestatic

Definition at line 177 of file hcd_dwc2.c.

◆ channel_xfer_in_retry()

static void channel_xfer_in_retry ( dwc2_regs_t dwc2,
uint8_t  ch_id,
uint32_t  hcint 
)
static

Definition at line 681 of file hcd_dwc2.c.

◆ channel_xfer_out_wrapup()

static void channel_xfer_out_wrapup ( dwc2_regs_t dwc2,
uint8_t  ch_id 
)
static

Definition at line 495 of file hcd_dwc2.c.

◆ channel_xfer_start()

static bool channel_xfer_start ( dwc2_regs_t dwc2,
uint8_t  ch_id 
)
static

Definition at line 518 of file hcd_dwc2.c.

◆ dfifo_host_init()

static void dfifo_host_init ( uint8_t  rhport)
static

Definition at line 283 of file hcd_dwc2.c.

◆ dma_host_enabled()

static TU_ATTR_ALWAYS_INLINE bool dma_host_enabled ( const dwc2_regs_t dwc2)
inlinestatic

Definition at line 129 of file hcd_dwc2.c.

◆ edpt_alloc()

static TU_ATTR_ALWAYS_INLINE uint8_t edpt_alloc ( void  )
inlinestatic

Definition at line 199 of file hcd_dwc2.c.

◆ edpt_find_opened()

static TU_ATTR_ALWAYS_INLINE uint8_t edpt_find_opened ( uint8_t  dev_addr,
uint8_t  ep_num,
uint8_t  ep_dir 
)
inlinestatic

Definition at line 213 of file hcd_dwc2.c.

◆ edpt_is_periodic()

static TU_ATTR_ALWAYS_INLINE bool edpt_is_periodic ( uint8_t  ep_type)
inlinestatic

Definition at line 150 of file hcd_dwc2.c.

◆ edpt_xfer_kickoff()

static bool edpt_xfer_kickoff ( dwc2_regs_t dwc2,
uint8_t  ep_id 
)
static

Definition at line 600 of file hcd_dwc2.c.

◆ handle_channel_in_dma()

static bool handle_channel_in_dma ( dwc2_regs_t dwc2,
uint8_t  ch_id,
uint32_t  hcint 
)
static

Definition at line 972 of file hcd_dwc2.c.

◆ handle_channel_in_slave()

static bool handle_channel_in_slave ( dwc2_regs_t dwc2,
uint8_t  ch_id,
uint32_t  hcint 
)
static

Definition at line 814 of file hcd_dwc2.c.

◆ handle_channel_irq()

static void handle_channel_irq ( uint8_t  rhport,
bool  in_isr 
)
static

Definition at line 1113 of file hcd_dwc2.c.

◆ handle_channel_out_dma()

static bool handle_channel_out_dma ( dwc2_regs_t dwc2,
uint8_t  ch_id,
uint32_t  hcint 
)
static

Definition at line 1052 of file hcd_dwc2.c.

◆ handle_channel_out_slave()

static bool handle_channel_out_slave ( dwc2_regs_t dwc2,
uint8_t  ch_id,
uint32_t  hcint 
)
static

Definition at line 905 of file hcd_dwc2.c.

◆ handle_hprt_irq()

static void handle_hprt_irq ( uint8_t  rhport,
bool  in_isr 
)
static

Definition at line 1232 of file hcd_dwc2.c.

◆ handle_rxflvl_irq()

static void handle_rxflvl_irq ( uint8_t  rhport)
static

Definition at line 739 of file hcd_dwc2.c.

◆ handle_sof_irq()

static bool handle_sof_irq ( uint8_t  rhport,
bool  in_isr 
)
static

Definition at line 1157 of file hcd_dwc2.c.

◆ handle_txfifo_empty()

static bool handle_txfifo_empty ( dwc2_regs_t dwc2,
bool  is_periodic 
)
static

Definition at line 781 of file hcd_dwc2.c.

◆ hcd_configure()

bool hcd_configure ( uint8_t  rhport,
uint32_t  cfg_id,
const void *  cfg_param 
)

Definition at line 322 of file hcd_dwc2.c.

◆ hcd_device_close()

void hcd_device_close ( uint8_t  rhport,
uint8_t  dev_addr 
)

Definition at line 430 of file hcd_dwc2.c.

◆ hcd_edpt_abort_xfer()

bool hcd_edpt_abort_xfer ( uint8_t  rhport,
uint8_t  dev_addr,
uint8_t  ep_addr 
)

Definition at line 633 of file hcd_dwc2.c.

◆ hcd_edpt_clear_stall()

bool hcd_edpt_clear_stall ( uint8_t  rhport,
uint8_t  dev_addr,
uint8_t  ep_addr 
)

Definition at line 665 of file hcd_dwc2.c.

◆ hcd_edpt_open()

bool hcd_edpt_open ( uint8_t  rhport,
uint8_t  dev_addr,
const tusb_desc_endpoint_t desc_ep 
)

Definition at line 445 of file hcd_dwc2.c.

◆ hcd_edpt_xfer()

bool hcd_edpt_xfer ( uint8_t  rhport,
uint8_t  dev_addr,
uint8_t  ep_addr,
uint8_t *  buffer,
uint16_t  buflen 
)

Definition at line 611 of file hcd_dwc2.c.

◆ hcd_frame_number()

uint32_t hcd_frame_number ( uint8_t  rhport)

Definition at line 390 of file hcd_dwc2.c.

◆ hcd_init()

bool hcd_init ( uint8_t  rhport,
const tusb_rhport_init_t rh_init 
)

Definition at line 331 of file hcd_dwc2.c.

◆ hcd_int_disable()

void hcd_int_disable ( uint8_t  rhport)

Definition at line 385 of file hcd_dwc2.c.

◆ hcd_int_enable()

void hcd_int_enable ( uint8_t  rhport)

Definition at line 380 of file hcd_dwc2.c.

◆ hcd_int_handler()

void hcd_int_handler ( uint8_t  rhport,
bool  in_isr 
)

Definition at line 1271 of file hcd_dwc2.c.

◆ hcd_port_connect_status()

bool hcd_port_connect_status ( uint8_t  rhport)

Definition at line 400 of file hcd_dwc2.c.

◆ hcd_port_reset()

void hcd_port_reset ( uint8_t  rhport)

Definition at line 407 of file hcd_dwc2.c.

◆ hcd_port_reset_end()

void hcd_port_reset_end ( uint8_t  rhport)

Definition at line 415 of file hcd_dwc2.c.

◆ hcd_port_speed_get()

tusb_speed_t hcd_port_speed_get ( uint8_t  rhport)

Definition at line 423 of file hcd_dwc2.c.

◆ hcd_setup_send()

bool hcd_setup_send ( uint8_t  rhport,
uint8_t  dev_addr,
const uint8_t  setup_packet[8] 
)

Definition at line 655 of file hcd_dwc2.c.

◆ hprt_speed_get()

static TU_ATTR_ALWAYS_INLINE tusb_speed_t hprt_speed_get ( dwc2_regs_t dwc2)
inlinestatic

Definition at line 115 of file hcd_dwc2.c.

◆ port0_enable()

static void port0_enable ( dwc2_regs_t dwc2,
tusb_speed_t  speed 
)
static

Definition at line 1184 of file hcd_dwc2.c.

◆ print_hcint()

static TU_ATTR_ALWAYS_INLINE void print_hcint ( uint32_t  hcint)
inlinestatic

Definition at line 721 of file hcd_dwc2.c.

◆ req_queue_avail()

static TU_ATTR_ALWAYS_INLINE uint8_t req_queue_avail ( const dwc2_regs_t dwc2,
bool  is_period 
)
inlinestatic

Definition at line 154 of file hcd_dwc2.c.

◆ TU_VERIFY_STATIC()

TU_VERIFY_STATIC ( CFG_TUH_DWC2_ENDPOINT_MAX<=  255,
"currently only use 8-bit for index"   
)

Variable Documentation

◆ _hcd_data

hcd_data_t _hcd_data

Definition at line 110 of file hcd_dwc2.c.