SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
usb_controller.h File Reference
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include "reg/reg-usb.h"
Include dependency graph for usb_controller.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fifo_info
 
struct  usb_controller_otg
 

Macros

#define USBC_MAX_OPEN_NUM   8
 
#define USBC_MAX_CTL_NUM   3
 
#define USBC_MAX_EP_NUM   6
 
#define USBC0_MAX_FIFO_SIZE   (8 * 1024)
 
#define USBC_EP0_FIFOSIZE   64
 

Typedefs

typedef struct fifo_info fifo_info_t
 
typedef struct usb_controller_otg usb_controller_otg_t
 

Functions

static uint32_t usb_controller_int_tx_pending (uint32_t addr)
 Get the interrupt pending flag of a TX endpoint.
 
static void usb_controller_int_clear_tx_pending (uint32_t addr, uint8_t ep_index)
 Clear the interrupt pending flag of a TX endpoint.
 
static void usb_controller_int_clear_tx_pending_all (uint32_t addr)
 Clear the interrupt pending flags of all TX endpoints.
 
static uint32_t usb_controller_int_rx_pending (uint32_t addr)
 Get the interrupt pending flag of an RX endpoint.
 
static void usb_controller_int_clear_rx_pending (uint32_t addr, uint8_t ep_index)
 Clear the interrupt pending flag of an RX endpoint.
 
static void usb_controller_int_clear_rx_pending_all (uint32_t addr)
 Clear the interrupt pending flags of all RX endpoints.
 
static void usb_controller_int_enable_tx_ep (uint32_t addr, uint8_t ep_index)
 Enable the interrupt of a TX endpoint.
 
static void usb_controller_int_enable_rx_ep (uint32_t addr, uint8_t ep_index)
 Enable the interrupt of an RX endpoint.
 
static void usb_controller_int_disable_tx_ep (uint32_t addr, uint8_t ep_index)
 Disable the interrupt of a TX endpoint.
 
static void usb_controller_int_disable_rx_ep (uint32_t addr, uint8_t ep_index)
 Disable the interrupt of an RX endpoint.
 
static void usb_controller_int_disable_tx_all (uint32_t addr)
 Disable the interrupts of all TX endpoints.
 
static void usb_controller_int_disable_rx_all (uint32_t addr)
 Disable the interrupts of all RX endpoints.
 
uint32_t usb_controller_open_otg (uint32_t otg_no)
 Open the USB OTG controller.
 
int usb_controller_close_otg (uint64_t husb)
 Close the USB OTG controller.
 
void usb_controller_force_id_status (uint64_t husb, uint32_t id_type)
 Set the ID status for the USB controller.
 
void usb_controller_force_vbus_valid (uint64_t husb, uint32_t vbus_type)
 Force the VBUS valid state for the USB controller.
 
void usb_controller_id_pull_enable (uint64_t husb)
 Enable the ID pull-up resistor for the USB controller.
 
void usb_controller_id_pull_disable (uint64_t husb)
 Disable the ID pull-up resistor for the USB controller.
 
void usb_controller_dpdm_pull_enable (uint64_t husb)
 Enable the DP/DM pull-up resistors for the USB controller.
 
void usb_controller_dpdm_pull_disable (uint64_t husb)
 Disable the DP/DM pull-up resistors for the USB controller.
 
void usb_controller_int_disable_usb_misc_all (uint64_t husb)
 Disable all miscellaneous USB interrupts.
 
void usb_controller_int_disable_ep_all (uint64_t husb, uint32_t ep_type)
 Disable all endpoint-specific interrupts.
 
void usb_controller_int_enable_usb_misc_uint (uint64_t husb, uint32_t mask)
 Enable specific miscellaneous USB interrupts.
 
void usb_controller_int_disable_usb_misc_uint (uint64_t husb, uint32_t mask)
 Disable specific miscellaneous USB interrupts.
 
void usb_controller_int_enable_ep (uint64_t husb, uint32_t ep_type, uint32_t ep_index)
 Enable interrupts for a specific endpoint.
 
uint32_t usb_controller_int_ep_pending (uint64_t husb, uint32_t ep_type)
 Get the pending interrupt status for a specific endpoint.
 
void usb_controller_int_clear_ep_pending (uint64_t husb, uint32_t ep_type, uint8_t ep_index)
 Clear the pending interrupt flag for a specific endpoint.
 
void usb_controller_int_clear_ep_pending_all (uint64_t husb, uint32_t ep_type)
 Clear the pending interrupt flags for all endpoints of a specific type.
 
uint32_t usb_controller_int_misc_pending (uint64_t husb)
 Get the pending miscellaneous interrupt status.
 
void usb_controller_int_clear_misc_pending (uint64_t husb, uint32_t mask)
 Clear the pending miscellaneous interrupt flag.
 
void usb_controller_int_clear_misc_pending_all (uint64_t husb)
 Clear the pending miscellaneous interrupt flags for all interrupts.
 
uint32_t usb_controller_get_active_ep (uint64_t husb)
 Get the active endpoint for the USB controller.
 
void usb_controller_int_disable_ep (uint64_t husb, uint32_t ep_type, uint8_t ep_index)
 Disable interrupts for a specific endpoint.
 
void usb_controller_select_active_ep (uint64_t husb, uint8_t ep_index)
 Select the active endpoint for the USB controller.
 
void usb_controller_config_fifo_tx_ep_default (uint32_t addr)
 Configure the FIFO for a default transmit endpoint.
 
void usb_controller_config_fifo_tx_ep (uint32_t addr, uint32_t is_double_fifo, uint32_t fifo_size, uint32_t fifo_addr)
 Configure the FIFO for a transmit endpoint.
 
void usb_controller_config_fifo_rx_ep_default (uint32_t addr)
 Configure the FIFO for a default receive endpoint.
 
void usb_controller_config_fifo_rx_ep (uint32_t addr, uint32_t is_double_fifo, uint32_t fifo_size, uint32_t fifo_addr)
 Configure the FIFO for a receive endpoint.
 
void usb_controller_config_fifo (uint64_t husb, uint32_t ep_type, uint32_t is_double_fifo, uint32_t fifo_size, uint32_t fifo_addr)
 Configure the FIFO for a specific endpoint.
 
uint32_t usb_controller_get_vbus_status (uint64_t husb)
 
uint32_t usb_controller_read_len_from_fifo (uint64_t husb, uint32_t ep_type)
 
uint32_t usb_controller_write_packet (uint64_t husb, uint32_t fifo, uint32_t cnt, void *buff)
 
uint32_t usb_controller_read_packet (uint64_t husb, uint32_t fifo, uint32_t cnt, void *buff)
 
void usb_controller_config_fifo_base (uint64_t husb, uint32_t sram_base)
 
uint32_t usb_controller_get_port_fifo_start_addr (uint64_t husb)
 
uint32_t usb_controller_get_port_fifo_size (uint64_t husb)
 
uint32_t usb_controller_select_fifo (uint64_t husb, uint32_t ep_index)
 

Macro Definition Documentation

◆ USBC0_MAX_FIFO_SIZE

#define USBC0_MAX_FIFO_SIZE   (8 * 1024)

◆ USBC_EP0_FIFOSIZE

#define USBC_EP0_FIFOSIZE   64

◆ USBC_MAX_CTL_NUM

#define USBC_MAX_CTL_NUM   3

◆ USBC_MAX_EP_NUM

#define USBC_MAX_EP_NUM   6

◆ USBC_MAX_OPEN_NUM

#define USBC_MAX_OPEN_NUM   8

Typedef Documentation

◆ fifo_info_t

typedef struct fifo_info fifo_info_t

◆ usb_controller_otg_t

Function Documentation

◆ usb_controller_close_otg()

int usb_controller_close_otg ( uint64_t  husb)

Close the USB OTG controller.

Parameters
husbThe handle to the USB controller.
Returns
Returns the status of the operation.

◆ usb_controller_config_fifo()

void usb_controller_config_fifo ( uint64_t  husb,
uint32_t  ep_type,
uint32_t  is_double_fifo,
uint32_t  fifo_size,
uint32_t  fifo_addr 
)

Configure the FIFO for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.
is_double_fifoWhether the endpoint has double buffering enabled.
fifo_sizeThe size of the FIFO.
fifo_addrThe base address of the FIFO.

◆ usb_controller_config_fifo_base()

void usb_controller_config_fifo_base ( uint64_t  husb,
uint32_t  sram_base 
)

◆ usb_controller_config_fifo_rx_ep()

void usb_controller_config_fifo_rx_ep ( uint32_t  addr,
uint32_t  is_double_fifo,
uint32_t  fifo_size,
uint32_t  fifo_addr 
)

Configure the FIFO for a receive endpoint.

Parameters
addrThe address of the USB controller.
is_double_fifoWhether the endpoint has double buffering enabled.
fifo_sizeThe size of the FIFO.
fifo_addrThe base address of the FIFO.

◆ usb_controller_config_fifo_rx_ep_default()

void usb_controller_config_fifo_rx_ep_default ( uint32_t  addr)

Configure the FIFO for a default receive endpoint.

Parameters
addrThe address of the USB controller.

◆ usb_controller_config_fifo_tx_ep()

void usb_controller_config_fifo_tx_ep ( uint32_t  addr,
uint32_t  is_double_fifo,
uint32_t  fifo_size,
uint32_t  fifo_addr 
)

Configure the FIFO for a transmit endpoint.

Parameters
addrThe address of the USB controller.
is_double_fifoWhether the endpoint has double buffering enabled.
fifo_sizeThe size of the FIFO.
fifo_addrThe base address of the FIFO.

◆ usb_controller_config_fifo_tx_ep_default()

void usb_controller_config_fifo_tx_ep_default ( uint32_t  addr)

Configure the FIFO for a default transmit endpoint.

Parameters
addrThe address of the USB controller.

◆ usb_controller_dpdm_pull_disable()

void usb_controller_dpdm_pull_disable ( uint64_t  husb)

Disable the DP/DM pull-up resistors for the USB controller.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_dpdm_pull_enable()

void usb_controller_dpdm_pull_enable ( uint64_t  husb)

Enable the DP/DM pull-up resistors for the USB controller.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_force_id_status()

void usb_controller_force_id_status ( uint64_t  husb,
uint32_t  id_type 
)

Set the ID status for the USB controller.

Parameters
husbThe handle to the USB controller.
id_typeThe type of ID status to set.

◆ usb_controller_force_vbus_valid()

void usb_controller_force_vbus_valid ( uint64_t  husb,
uint32_t  vbus_type 
)

Force the VBUS valid state for the USB controller.

Parameters
husbThe handle to the USB controller.
vbus_typeThe type of VBUS state to force.

◆ usb_controller_get_active_ep()

uint32_t usb_controller_get_active_ep ( uint64_t  husb)

Get the active endpoint for the USB controller.

Parameters
husbThe handle to the USB controller.
Returns
Returns the active endpoint.

◆ usb_controller_get_port_fifo_size()

uint32_t usb_controller_get_port_fifo_size ( uint64_t  husb)

◆ usb_controller_get_port_fifo_start_addr()

uint32_t usb_controller_get_port_fifo_start_addr ( uint64_t  husb)

◆ usb_controller_get_vbus_status()

uint32_t usb_controller_get_vbus_status ( uint64_t  husb)

◆ usb_controller_id_pull_disable()

void usb_controller_id_pull_disable ( uint64_t  husb)

Disable the ID pull-up resistor for the USB controller.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_id_pull_enable()

void usb_controller_id_pull_enable ( uint64_t  husb)

Enable the ID pull-up resistor for the USB controller.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_int_clear_ep_pending()

void usb_controller_int_clear_ep_pending ( uint64_t  husb,
uint32_t  ep_type,
uint8_t  ep_index 
)

Clear the pending interrupt flag for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.
ep_indexThe index of the endpoint.

◆ usb_controller_int_clear_ep_pending_all()

void usb_controller_int_clear_ep_pending_all ( uint64_t  husb,
uint32_t  ep_type 
)

Clear the pending interrupt flags for all endpoints of a specific type.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.

◆ usb_controller_int_clear_misc_pending()

void usb_controller_int_clear_misc_pending ( uint64_t  husb,
uint32_t  mask 
)

Clear the pending miscellaneous interrupt flag.

Parameters
husbThe handle to the USB controller.
maskThe interrupt mask to clear.

◆ usb_controller_int_clear_misc_pending_all()

void usb_controller_int_clear_misc_pending_all ( uint64_t  husb)

Clear the pending miscellaneous interrupt flags for all interrupts.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_int_clear_rx_pending()

static void usb_controller_int_clear_rx_pending ( uint32_t  addr,
uint8_t  ep_index 
)
inlinestatic

Clear the interrupt pending flag of an RX endpoint.

Parameters
addrThe address of the USB controller.
ep_indexThe index of the RX endpoint.

◆ usb_controller_int_clear_rx_pending_all()

static void usb_controller_int_clear_rx_pending_all ( uint32_t  addr)
inlinestatic

Clear the interrupt pending flags of all RX endpoints.

Parameters
addrThe address of the USB controller.

◆ usb_controller_int_clear_tx_pending()

static void usb_controller_int_clear_tx_pending ( uint32_t  addr,
uint8_t  ep_index 
)
inlinestatic

Clear the interrupt pending flag of a TX endpoint.

Parameters
addrThe address of the USB controller.
ep_indexThe index of the TX endpoint.

◆ usb_controller_int_clear_tx_pending_all()

static void usb_controller_int_clear_tx_pending_all ( uint32_t  addr)
inlinestatic

Clear the interrupt pending flags of all TX endpoints.

Parameters
addrThe address of the USB controller.

◆ usb_controller_int_disable_ep()

void usb_controller_int_disable_ep ( uint64_t  husb,
uint32_t  ep_type,
uint8_t  ep_index 
)

Disable interrupts for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.
ep_indexThe index of the endpoint.

◆ usb_controller_int_disable_ep_all()

void usb_controller_int_disable_ep_all ( uint64_t  husb,
uint32_t  ep_type 
)

Disable all endpoint-specific interrupts.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint to disable interrupts for.

◆ usb_controller_int_disable_rx_all()

static void usb_controller_int_disable_rx_all ( uint32_t  addr)
inlinestatic

Disable the interrupts of all RX endpoints.

Parameters
addrThe address of the USB controller.

◆ usb_controller_int_disable_rx_ep()

static void usb_controller_int_disable_rx_ep ( uint32_t  addr,
uint8_t  ep_index 
)
inlinestatic

Disable the interrupt of an RX endpoint.

Parameters
addrThe address of the USB controller.
ep_indexThe index of the RX endpoint.

◆ usb_controller_int_disable_tx_all()

static void usb_controller_int_disable_tx_all ( uint32_t  addr)
inlinestatic

Disable the interrupts of all TX endpoints.

Parameters
addrThe address of the USB controller.

◆ usb_controller_int_disable_tx_ep()

static void usb_controller_int_disable_tx_ep ( uint32_t  addr,
uint8_t  ep_index 
)
inlinestatic

Disable the interrupt of a TX endpoint.

Parameters
addrThe address of the USB controller.
ep_indexThe index of the TX endpoint.

◆ usb_controller_int_disable_usb_misc_all()

void usb_controller_int_disable_usb_misc_all ( uint64_t  husb)

Disable all miscellaneous USB interrupts.

Parameters
husbThe handle to the USB controller.

◆ usb_controller_int_disable_usb_misc_uint()

void usb_controller_int_disable_usb_misc_uint ( uint64_t  husb,
uint32_t  mask 
)

Disable specific miscellaneous USB interrupts.

Parameters
husbThe handle to the USB controller.
maskThe interrupt mask to enable.

◆ usb_controller_int_enable_ep()

void usb_controller_int_enable_ep ( uint64_t  husb,
uint32_t  ep_type,
uint32_t  ep_index 
)

Enable interrupts for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint to enable interrupts for.
ep_indexThe index of the endpoint to enable interrupts for.

◆ usb_controller_int_enable_rx_ep()

static void usb_controller_int_enable_rx_ep ( uint32_t  addr,
uint8_t  ep_index 
)
inlinestatic

Enable the interrupt of an RX endpoint.

Parameters
addrThe address of the USB controller.
ep_indexThe index of the RX endpoint.

◆ usb_controller_int_enable_tx_ep()

static void usb_controller_int_enable_tx_ep ( uint32_t  addr,
uint8_t  ep_index 
)
inlinestatic

Enable the interrupt of a TX endpoint.

Parameters
addrThe address of the USB controller.
ep_indexThe index of the TX endpoint.

◆ usb_controller_int_enable_usb_misc_uint()

void usb_controller_int_enable_usb_misc_uint ( uint64_t  husb,
uint32_t  mask 
)

Enable specific miscellaneous USB interrupts.

Parameters
husbThe handle to the USB controller.
maskThe interrupt mask to enable.

◆ usb_controller_int_ep_pending()

uint32_t usb_controller_int_ep_pending ( uint64_t  husb,
uint32_t  ep_type 
)

Get the pending interrupt status for a specific endpoint.

Parameters
husbThe handle to the USB controller.
ep_typeThe type of endpoint.
Returns
Returns the pending interrupt status.

◆ usb_controller_int_misc_pending()

uint32_t usb_controller_int_misc_pending ( uint64_t  husb)

Get the pending miscellaneous interrupt status.

Parameters
husbThe handle to the USB controller.
Returns
Returns the pending miscellaneous interrupt status.

◆ usb_controller_int_rx_pending()

static uint32_t usb_controller_int_rx_pending ( uint32_t  addr)
inlinestatic

Get the interrupt pending flag of an RX endpoint.

Parameters
addrThe address of the USB controller.
Returns
Returns the interrupt pending flag of the RX endpoint.

◆ usb_controller_int_tx_pending()

static uint32_t usb_controller_int_tx_pending ( uint32_t  addr)
inlinestatic

Get the interrupt pending flag of a TX endpoint.

Parameters
addrThe address of the USB controller.
Returns
Returns the interrupt pending flag of the TX endpoint.

◆ usb_controller_open_otg()

uint32_t usb_controller_open_otg ( uint32_t  otg_no)

Open the USB OTG controller.

Parameters
otg_noThe OTG controller number.
Returns
Returns the status of the operation.

◆ usb_controller_read_len_from_fifo()

uint32_t usb_controller_read_len_from_fifo ( uint64_t  husb,
uint32_t  ep_type 
)

◆ usb_controller_read_packet()

uint32_t usb_controller_read_packet ( uint64_t  husb,
uint32_t  fifo,
uint32_t  cnt,
void *  buff 
)

◆ usb_controller_select_active_ep()

void usb_controller_select_active_ep ( uint64_t  husb,
uint8_t  ep_index 
)

Select the active endpoint for the USB controller.

Parameters
husbThe handle to the USB controller.
ep_indexThe index of the endpoint to select as active.

◆ usb_controller_select_fifo()

uint32_t usb_controller_select_fifo ( uint64_t  husb,
uint32_t  ep_index 
)

◆ usb_controller_write_packet()

uint32_t usb_controller_write_packet ( uint64_t  husb,
uint32_t  fifo,
uint32_t  cnt,
void *  buff 
)