SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Functions
usb_device.c File Reference
#include <io.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <common.h>
#include <log.h>
#include <sys-clk.h>
#include "usb.h"
#include "usb_controller.h"
#include "usb_device.h"
Include dependency graph for usb_device.c:

Functions

void usb_device_set_address_default (uint64_t husb)
 Set the default address for the USB device.
 
void usb_device_set_address (uint64_t husb, uint8_t address)
 Set the address for the USB device.
 
uint32_t usb_device_query_transfer_mode (uint64_t husb)
 Query the transfer mode of the USB device.
 
void usb_device_config_transfer_mode (uint64_t husb, uint8_t ts_type, uint8_t speed_mode)
 Configure the transfer mode of the USB device.
 
void usb_device_connect_switch (uint64_t husb, uint32_t is_on)
 Switch the USB device connection on or off.
 
uint32_t usb_device_query_power_status (uint64_t husb)
 Query the power status of the USB device.
 
int usb_device_config_ep (uint64_t husb, uint32_t ts_type, uint32_t ep_type, uint32_t is_double_fifo, uint32_t ep_maxpkt)
 Configure an endpoint of the USB device.
 
int usb_device_config_ep_default (uint64_t husb, uint32_t ep_type)
 Configure a default endpoint of the USB device.
 
int usb_device_config_ep_dma (uint64_t husb, uint32_t ep_type)
 Configure an endpoint of the USB device to use DMA.
 
int usb_device_clear_ep_dma (uint64_t husb, uint32_t ep_type)
 Clear the DMA configuration for an endpoint of the USB device.
 
int usb_device_get_ep_stall (uint64_t husb, uint32_t ep_type)
 Get the stall status of an endpoint of the USB device.
 
int usb_device_ep_send_stall (uint64_t husb, uint32_t ep_type)
 Send a stall condition on an endpoint of the USB device.
 
int usb_device_ep_clear_stall (uint64_t husb, uint32_t ep_type)
 Clear the stall condition on an endpoint of the USB device.
 
uint32_t usb_device_ctrl_get_setup_end (uint64_t husb)
 Get the setup end status of the control endpoint of the USB device.
 
void usb_device_ctrl_clear_setup_end (uint64_t husb)
 Clear the setup end status of the control endpoint of the USB device.
 
int usb_device_write_data_status (uint64_t husb, uint32_t ep_type, uint32_t complete)
 Check the write data status of an endpoint of the USB device.
 
int usb_device_read_data_status (uint64_t husb, uint32_t ep_type, uint32_t complete)
 Check the read data status of an endpoint of the USB device.
 
uint32_t usb_device_get_read_data_ready (uint64_t husb, uint32_t ep_type)
 Check if there is ready data to be read from an endpoint of the USB device.
 
uint32_t usb_device_get_write_data_ready (uint64_t husb, uint32_t ep_type)
 Check if an endpoint of the USB device is ready to write data.
 
uint32_t usb_device_get_write_data_ready_fifo_empty (uint64_t husb, uint32_t ep_type)
 Check if the FIFO of an endpoint of the USB device is empty and ready to write data.
 
int usb_device_iso_update_enable (uint64_t husb)
 Enable ISO update for the USB device.
 
void usb_device_flush_fifo (uint64_t husb, uint32_t ep_type)
 Flush the FIFO of an endpoint of the USB device.
 

Function Documentation

◆ usb_device_clear_ep_dma()

int usb_device_clear_ep_dma ( uint64_t  husb,
uint32_t  ep_type 
)

Clear the DMA configuration for an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_config_ep()

int usb_device_config_ep ( uint64_t  husb,
uint32_t  ts_type,
uint32_t  ep_type,
uint32_t  is_double_fifo,
uint32_t  ep_maxpkt 
)

Configure an endpoint of the USB device.

Parameters
husbThe USB device handle.
ts_typeThe transfer mode type.
ep_typeThe endpoint type.
is_double_fifoWhether to use double FIFO or not.
ep_maxpktThe maximum packet size of the endpoint.
Returns
0 on success, -1 on failure.

◆ usb_device_config_ep_default()

int usb_device_config_ep_default ( uint64_t  husb,
uint32_t  ep_type 
)

Configure a default endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_config_ep_dma()

int usb_device_config_ep_dma ( uint64_t  husb,
uint32_t  ep_type 
)

Configure an endpoint of the USB device to use DMA.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_config_transfer_mode()

void usb_device_config_transfer_mode ( uint64_t  husb,
uint8_t  ts_type,
uint8_t  speed_mode 
)

Configure the transfer mode of the USB device.

Parameters
husbThe USB device handle.
ts_typeThe transfer mode type.
speed_modeThe speed mode.

◆ usb_device_connect_switch()

void usb_device_connect_switch ( uint64_t  husb,
uint32_t  is_on 
)

Switch the USB device connection on or off.

Parameters
husbThe USB device handle.
is_onWhether to turn the connection on (1) or off (0).

◆ usb_device_ctrl_clear_setup_end()

void usb_device_ctrl_clear_setup_end ( uint64_t  husb)

Clear the setup end status of the control endpoint of the USB device.

Parameters
husbThe USB device handle.

◆ usb_device_ctrl_get_setup_end()

uint32_t usb_device_ctrl_get_setup_end ( uint64_t  husb)

Get the setup end status of the control endpoint of the USB device.

Parameters
husbThe USB device handle.
Returns
The setup end status.

◆ usb_device_ep_clear_stall()

int usb_device_ep_clear_stall ( uint64_t  husb,
uint32_t  ep_type 
)

Clear the stall condition on an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_ep_send_stall()

int usb_device_ep_send_stall ( uint64_t  husb,
uint32_t  ep_type 
)

Send a stall condition on an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_flush_fifo()

void usb_device_flush_fifo ( uint64_t  husb,
uint32_t  ep_type 
)

Flush the FIFO of an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.

◆ usb_device_get_ep_stall()

int usb_device_get_ep_stall ( uint64_t  husb,
uint32_t  ep_type 
)

Get the stall status of an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
1 if stalled, 0 if not stalled.

◆ usb_device_get_read_data_ready()

uint32_t usb_device_get_read_data_ready ( uint64_t  husb,
uint32_t  ep_type 
)

Check if there is ready data to be read from an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
1 if ready, 0 if not ready.

◆ usb_device_get_write_data_ready()

uint32_t usb_device_get_write_data_ready ( uint64_t  husb,
uint32_t  ep_type 
)

Check if an endpoint of the USB device is ready to write data.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
1 if ready, 0 if not ready.

◆ usb_device_get_write_data_ready_fifo_empty()

uint32_t usb_device_get_write_data_ready_fifo_empty ( uint64_t  husb,
uint32_t  ep_type 
)

Check if the FIFO of an endpoint of the USB device is empty and ready to write data.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
1 if ready, 0 if not ready.

◆ usb_device_iso_update_enable()

int usb_device_iso_update_enable ( uint64_t  husb)

Enable ISO update for the USB device.

Parameters
husbThe USB device handle.
Returns
0 on success, -1 on failure.

◆ usb_device_query_power_status()

uint32_t usb_device_query_power_status ( uint64_t  husb)

Query the power status of the USB device.

Parameters
husbThe USB device handle.
Returns
The power status.

◆ usb_device_query_transfer_mode()

uint32_t usb_device_query_transfer_mode ( uint64_t  husb)

Query the transfer mode of the USB device.

Parameters
husbThe USB device handle.
Returns
The transfer mode.

◆ usb_device_read_data_status()

int usb_device_read_data_status ( uint64_t  husb,
uint32_t  ep_type,
uint32_t  complete 
)

Check the read data status of an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
completeWhether the read operation is complete (1) or not (0).
Returns
0 on success, -1 on failure.

◆ usb_device_set_address()

void usb_device_set_address ( uint64_t  husb,
uint8_t  address 
)

Set the address for the USB device.

Parameters
husbThe USB device handle.
addressThe address to set.

◆ usb_device_set_address_default()

void usb_device_set_address_default ( uint64_t  husb)

Set the default address for the USB device.

Parameters
husbThe USB device handle.

◆ usb_device_write_data_status()

int usb_device_write_data_status ( uint64_t  husb,
uint32_t  ep_type,
uint32_t  complete 
)

Check the write data status of an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
completeWhether the write operation is complete (1) or not (0).
Returns
0 on success, -1 on failure.