SAM USB Driver.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | NVM_USB_PAD_TRANSN_POS 45 |
#define | NVM_USB_PAD_TRANSN_SIZE 5 |
#define | NVM_USB_PAD_TRANSP_POS 50 |
#define | NVM_USB_PAD_TRANSP_SIZE 5 |
#define | NVM_USB_PAD_TRIM_POS 55 |
#define | NVM_USB_PAD_TRIM_SIZE 3 |
#define | UHD_BULK_INTERVAL_MIN 1 |
Minimal bulk interval value. More... | |
#define | USB_EP_ADDR_MASK 0x0f |
Mask selecting the index part of an endpoint address. More... | |
#define | USB_EP_DIR_IN 0x80 |
Endpoint transfer direction is IN. More... | |
#define | USB_EP_DIR_OUT 0x00 |
Endpoint transfer direction is OUT. More... | |
#define | USB_LPM_ATTRIBUT_BLINKSTATE(value) ((value & 0xF) << 0) |
#define | USB_LPM_ATTRIBUT_BLINKSTATE_L1 USB_LPM_ATTRIBUT_BLINKSTATE(1) |
#define | USB_LPM_ATTRIBUT_BLINKSTATE_MASK (0xF << 0) |
Fields definition from a LPM TOKEN. More... | |
#define | USB_LPM_ATTRIBUT_HIRD(value) ((value & 0xF) << 4) |
#define | USB_LPM_ATTRIBUT_HIRD_MASK (0xF << 4) |
#define | USB_LPM_ATTRIBUT_REMOTEWAKE(value) ((value & 1) << 8) |
#define | USB_LPM_ATTRIBUT_REMOTEWAKE_MASK (1 << 8) |
#define | USB_STATUS_PIPE_CRC16ER (1 << 4) |
Functions | |
static void | _usb_device_interrupt_handler (void) |
static void | _usb_host_interrupt_handler (void) |
Function called by USB interrupt to manage USB host interrupts. More... | |
enum status_code | usb_device_disable_callback (struct usb_module *module_inst, enum usb_device_callback callback_type) |
Disables USB device callback generation for a given type. More... | |
enum status_code | usb_device_enable_callback (struct usb_module *module_inst, enum usb_device_callback callback_type) |
Enables USB device callback generation for a given type. More... | |
void | usb_device_endpoint_abort_job (struct usb_module *module_inst, uint8_t ep) |
Abort ongoing job on the endpoint. More... | |
void | usb_device_endpoint_clear_halt (struct usb_module *module_inst, uint8_t ep) |
Clear endpoint halt state. More... | |
enum status_code | usb_device_endpoint_disable_callback (struct usb_module *module_inst, uint8_t ep, enum usb_device_endpoint_callback callback_type) |
Disables USB device endpoint callback generation for a given type. More... | |
enum status_code | usb_device_endpoint_enable_callback (struct usb_module *module_inst, uint8_t ep, enum usb_device_endpoint_callback callback_type) |
Enables USB device endpoint callback generation for a given type. More... | |
void | usb_device_endpoint_get_config_defaults (struct usb_device_endpoint_config *ep_config) |
Initializes an USB device endpoint configuration structure to defaults. More... | |
bool | usb_device_endpoint_is_configured (struct usb_module *module_inst, uint8_t ep) |
Check if current endpoint is configured. More... | |
bool | usb_device_endpoint_is_halted (struct usb_module *module_inst, uint8_t ep) |
Check if endpoint is halted. More... | |
enum status_code | usb_device_endpoint_read_buffer_job (struct usb_module *module_inst, uint8_t ep_num, uint8_t *pbuf, uint32_t buf_size) |
Start read buffer job on a endpoint. More... | |
enum status_code | usb_device_endpoint_register_callback (struct usb_module *module_inst, uint8_t ep_num, enum usb_device_endpoint_callback callback_type, usb_device_endpoint_callback_t callback_func) |
Registers a USB device endpoint callback. More... | |
enum status_code | usb_device_endpoint_set_config (struct usb_module *module_inst, struct usb_device_endpoint_config *ep_config) |
Writes an USB device endpoint configuration to the hardware module. More... | |
void | usb_device_endpoint_set_halt (struct usb_module *module_inst, uint8_t ep) |
Halt the endpoint (send STALL) More... | |
enum status_code | usb_device_endpoint_setup_buffer_job (struct usb_module *module_inst, uint8_t *pbuf) |
Start setup packet read job on a endpoint. More... | |
enum status_code | usb_device_endpoint_unregister_callback (struct usb_module *module_inst, uint8_t ep_num, enum usb_device_endpoint_callback callback_type) |
Unregisters a USB device endpoint callback. More... | |
enum status_code | usb_device_endpoint_write_buffer_job (struct usb_module *module_inst, uint8_t ep_num, uint8_t *pbuf, uint32_t buf_size) |
Start write buffer job on a endpoint. More... | |
enum status_code | usb_device_register_callback (struct usb_module *module_inst, enum usb_device_callback callback_type, usb_device_callback_t callback_func) |
Registers a USB device callback. More... | |
enum status_code | usb_device_unregister_callback (struct usb_module *module_inst, enum usb_device_callback callback_type) |
Unregisters a USB device callback. More... | |
void | usb_disable (struct usb_module *module_inst) |
Disable the USB module peripheral. More... | |
void | usb_enable (struct usb_module *module_inst) |
Enable the USB module peripheral. More... | |
void | usb_get_config_defaults (struct usb_config *module_config) |
Get the default USB module settings. More... | |
void | USB_Handler (void) |
Interrupt handler for the USB module. More... | |
enum status_code | usb_host_disable_callback (struct usb_module *module_inst, enum usb_host_callback callback_type) |
Disables USB host callback generation for a given type. More... | |
enum status_code | usb_host_enable_callback (struct usb_module *module_inst, enum usb_host_callback callback_type) |
Enables USB host callback generation for a given type. More... | |
enum status_code | usb_host_pipe_abort_job (struct usb_module *module_inst, uint8_t pipe_num) |
USB host abort a pipe job. More... | |
enum status_code | usb_host_pipe_disable_callback (struct usb_module *module_inst, uint8_t pipe_num, enum usb_host_pipe_callback callback_type) |
Disables USB host callback generation for a given type. More... | |
enum status_code | usb_host_pipe_enable_callback (struct usb_module *module_inst, uint8_t pipe_num, enum usb_host_pipe_callback callback_type) |
Enables USB host pipe callback generation for a given type. More... | |
enum status_code | usb_host_pipe_get_config (struct usb_module *module_inst, uint8_t pipe_num, struct usb_host_pipe_config *ep_config) |
Gets an USB host pipe configuration. More... | |
void | usb_host_pipe_get_config_defaults (struct usb_host_pipe_config *ep_config) |
Initializes an USB host pipe configuration structure to defaults. More... | |
enum status_code | usb_host_pipe_lpm_job (struct usb_module *module_inst, uint8_t pipe_num, bool b_remotewakeup, uint8_t hird) |
Sends the LPM package. More... | |
enum status_code | usb_host_pipe_read_job (struct usb_module *module_inst, uint8_t pipe_num, uint8_t *buf, uint32_t buf_size) |
USB host pipe read job. More... | |
enum status_code | usb_host_pipe_register_callback (struct usb_module *module_inst, uint8_t pipe_num, enum usb_host_pipe_callback callback_type, usb_host_pipe_callback_t callback_func) |
Registers a USB host pipe callback. More... | |
void | usb_host_pipe_set_auto_zlp (struct usb_module *module_inst, uint8_t pipe_num, bool value) |
Sets USB host pipe auto ZLP setting value. More... | |
enum status_code | usb_host_pipe_set_config (struct usb_module *module_inst, uint8_t pipe_num, struct usb_host_pipe_config *ep_config) |
Writes an USB host pipe configuration to the hardware module. More... | |
enum status_code | usb_host_pipe_setup_job (struct usb_module *module_inst, uint8_t pipe_num, uint8_t *buf) |
Sends the setup package. More... | |
enum status_code | usb_host_pipe_unregister_callback (struct usb_module *module_inst, uint8_t pipe_num, enum usb_host_pipe_callback callback_type) |
Unregisters a USB host pipe callback. More... | |
enum status_code | usb_host_pipe_write_job (struct usb_module *module_inst, uint8_t pipe_num, uint8_t *buf, uint32_t buf_size) |
USB host pipe write job. More... | |
enum status_code | usb_host_register_callback (struct usb_module *module_inst, enum usb_host_callback callback_type, usb_host_callback_t callback_func) |
Registers a USB host callback. More... | |
enum status_code | usb_host_unregister_callback (struct usb_module *module_inst, enum usb_host_callback callback_type) |
Unregisters a USB host callback. More... | |
enum status_code | usb_init (struct usb_module *module_inst, Usb *const hw, struct usb_config *module_config) |
Initializes USB module instance. More... | |
Variables | |
static const uint16_t | _usb_device_irq_bits [USB_DEVICE_CALLBACK_N] |
static const uint8_t | _usb_endpoint_irq_bits [USB_DEVICE_EP_CALLBACK_N] |
static struct usb_module * | _usb_instances |
Local USB module instance. More... | |
static uint32_t | device_callback_lpm_wakeup_enable |
static struct usb_endpoint_callback_parameter | ep_callback_para |
Device endpoint callback parameter variable, used to transfer info to UDD wrapper layer. More... | |
uint32_t | host_pipe_job_busy_status = 0 |
Bit mask for pipe job busy status. More... | |
static struct usb_pipe_callback_parameter | pipe_callback_para |
Host pipe callback structure variable. More... | |
USB SRAM data containing pipe descriptor table | |
The content of the USB SRAM can be :
| |
union { | |
UsbDeviceDescriptor usb_endpoint_table [USB_EPT_NUM] | |
UsbHostDescriptor usb_pipe_table [USB_PIPE_NUM] | |
} | usb_descriptor_table |
#define NVM_USB_PAD_TRANSN_POS 45 |
Referenced by usb_init().
#define NVM_USB_PAD_TRANSN_SIZE 5 |
Referenced by usb_init().
#define NVM_USB_PAD_TRANSP_POS 50 |
Referenced by usb_init().
#define NVM_USB_PAD_TRANSP_SIZE 5 |
Referenced by usb_init().
#define NVM_USB_PAD_TRIM_POS 55 |
Referenced by usb_init().
#define NVM_USB_PAD_TRIM_SIZE 3 |
Referenced by usb_init().
#define UHD_BULK_INTERVAL_MIN 1 |
Minimal bulk interval value.
Referenced by usb_host_pipe_set_config().
#define USB_EP_ADDR_MASK 0x0f |
Mask selecting the index part of an endpoint address.
Referenced by udd_ep_alloc(), udd_ep_clear_halt(), udd_ep_free(), udd_ep_get_job(), udd_ep_run(), udd_ep_set_halt(), udd_ep_trans_in_next(), udd_ep_trans_out_next(), udd_ep_wait_stall_clear(), udi_phdc_metadata_ack(), udi_phdc_preamplemsg_ack(), udi_phdc_send_metadata(), udi_phdc_send_preamplemsg(), usb_device_endpoint_abort_job(), usb_device_endpoint_clear_halt(), usb_device_endpoint_disable_callback(), usb_device_endpoint_enable_callback(), usb_device_endpoint_is_configured(), usb_device_endpoint_is_halted(), usb_device_endpoint_set_config(), usb_device_endpoint_set_halt(), and usb_host_pipe_set_config().
#define USB_EP_DIR_IN 0x80 |
Endpoint transfer direction is IN.
Referenced by _uhd_pipe_trans_complete(), _usb_device_interrupt_handler(), _usb_ep0_on_tansfer_fail(), main_transfer_done(), udd_ctrl_stall_data(), udd_ep_get_job(), udd_ep_run(), udd_ep_transfer_process(), uhi_aoa_install(), uhi_cdc_install(), uhi_hid_mouse_install(), uhi_vendor_install(), usb_device_endpoint_abort_job(), usb_device_endpoint_clear_halt(), usb_device_endpoint_disable_callback(), usb_device_endpoint_enable_callback(), usb_device_endpoint_is_configured(), usb_device_endpoint_is_halted(), usb_device_endpoint_set_config(), usb_device_endpoint_set_halt(), usb_host_pipe_get_config(), and usb_host_pipe_set_config().
#define USB_EP_DIR_OUT 0x00 |
Endpoint transfer direction is OUT.
Referenced by _usb_device_interrupt_handler(), and udd_ctrl_stall_data().
#define USB_LPM_ATTRIBUT_BLINKSTATE | ( | value | ) | ((value & 0xF) << 0) |
#define USB_LPM_ATTRIBUT_BLINKSTATE_L1 USB_LPM_ATTRIBUT_BLINKSTATE(1) |
Referenced by usb_host_pipe_lpm_job().
#define USB_LPM_ATTRIBUT_BLINKSTATE_MASK (0xF << 0) |
Fields definition from a LPM TOKEN.
#define USB_LPM_ATTRIBUT_HIRD | ( | value | ) | ((value & 0xF) << 4) |
Referenced by usb_host_pipe_lpm_job().
#define USB_LPM_ATTRIBUT_HIRD_MASK (0xF << 4) |
#define USB_LPM_ATTRIBUT_REMOTEWAKE | ( | value | ) | ((value & 1) << 8) |
Referenced by usb_host_pipe_lpm_job().
#define USB_LPM_ATTRIBUT_REMOTEWAKE_MASK (1 << 8) |
Referenced by _usb_device_interrupt_handler().
#define USB_STATUS_PIPE_CRC16ER (1 << 4) |
Referenced by _usb_host_interrupt_handler().
|
static |
References usb_endpoint_callback_parameter::endpoint_address, ep_callback_para, i, usb_endpoint_callback_parameter::out_buffer_size, usb_endpoint_callback_parameter::received_bytes, usb_endpoint_callback_parameter::sent_bytes, usb_descriptor_table, USB_DEVICE_CALLBACK_LPMSUSP, USB_DEVICE_CALLBACK_N, USB_DEVICE_ENDPOINT_CALLBACK_RXSTP, USB_DEVICE_ENDPOINT_CALLBACK_STALL, USB_DEVICE_ENDPOINT_CALLBACK_TRCPT, USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL, USB_EP_DIR_IN, USB_EP_DIR_OUT, and USB_LPM_ATTRIBUT_REMOTEWAKE_MASK.
Referenced by USB_Handler().
|
static |
Function called by USB interrupt to manage USB host interrupts.
USB host interrupt events are split into four sections:
References ctz, NULL, pipe_callback_para, usb_pipe_callback_parameter::pipe_error_status, usb_pipe_callback_parameter::pipe_num, usb_pipe_callback_parameter::required_size, usb_pipe_callback_parameter::transfered_size, usb_descriptor_table, USB_HOST_CALLBACK_CONNECT, USB_HOST_CALLBACK_DISCONNECT, USB_HOST_CALLBACK_DNRSM, USB_HOST_CALLBACK_RAMACER, USB_HOST_CALLBACK_RESET, USB_HOST_CALLBACK_SOF, USB_HOST_CALLBACK_UPRSM, USB_HOST_CALLBACK_WAKEUP, USB_HOST_PIPE_CALLBACK_ERROR, USB_HOST_PIPE_CALLBACK_SETUP, USB_HOST_PIPE_CALLBACK_STALL, USB_HOST_PIPE_CALLBACK_TRANSFER_COMPLETE, USB_HOST_PIPE_TOKEN_IN, USB_HOST_PIPE_TYPE_BULK, USB_HOST_PIPE_TYPE_ISO, and USB_STATUS_PIPE_CRC16ER.
Referenced by USB_Handler().
enum status_code usb_device_disable_callback | ( | struct usb_module * | module_inst, |
enum usb_device_callback | callback_type | ||
) |
Disables USB device callback generation for a given type.
Disables asynchronous callbacks for a given logical type.
[in] | module_inst | Pointer to USB software instance struct |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was disabled successfully. |
References Assert, usb_module::device_enabled_callback_mask, usb_module::hw, and STATUS_OK.
Referenced by _usb_device_lpm_suspend(), _usb_on_suspend(), and _usb_on_wakeup().
enum status_code usb_device_enable_callback | ( | struct usb_module * | module_inst, |
enum usb_device_callback | callback_type | ||
) |
Enables USB device callback generation for a given type.
Enables asynchronous callbacks for a given logical type. This must be called before USB device generate callback events.
[in] | module_inst | Pointer to USB software instance struct |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was enabled successfully. |
References Assert, usb_module::device_enabled_callback_mask, usb_module::hw, and STATUS_OK.
Referenced by _usb_device_lpm_suspend(), _usb_on_suspend(), _usb_on_wakeup(), and udd_attach().
void usb_device_endpoint_abort_job | ( | struct usb_module * | module_inst, |
uint8_t | ep | ||
) |
Abort ongoing job on the endpoint.
module_inst | Pointer to USB software instance struct |
ep | Endpoint address |
References usb_module::hw, USB_EP_ADDR_MASK, and USB_EP_DIR_IN.
Referenced by udd_ep_abort().
void usb_device_endpoint_clear_halt | ( | struct usb_module * | module_inst, |
uint8_t | ep | ||
) |
Clear endpoint halt state.
module_inst | Pointer to USB software instance struct |
ep | Endpoint address |
References usb_module::hw, USB_EP_ADDR_MASK, and USB_EP_DIR_IN.
Referenced by udd_ctrl_stall_data(), and udd_ep_clear_halt().
enum status_code usb_device_endpoint_disable_callback | ( | struct usb_module * | module_inst, |
uint8_t | ep, | ||
enum usb_device_endpoint_callback | callback_type | ||
) |
Disables USB device endpoint callback generation for a given type.
Disables callbacks for a given logical type.
[in] | module_inst | Pointer to USB software instance struct |
[in] | ep | Endpoint to configure |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was disabled successfully. |
References Assert, usb_module::device_endpoint_enabled_callback_mask, usb_module::hw, STATUS_OK, USB_DEVICE_ENDPOINT_CALLBACK_RXSTP, USB_DEVICE_ENDPOINT_CALLBACK_STALL, USB_DEVICE_ENDPOINT_CALLBACK_TRCPT, USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL, USB_EP_ADDR_MASK, and USB_EP_DIR_IN.
Referenced by udd_ep_free().
enum status_code usb_device_endpoint_enable_callback | ( | struct usb_module * | module_inst, |
uint8_t | ep, | ||
enum usb_device_endpoint_callback | callback_type | ||
) |
Enables USB device endpoint callback generation for a given type.
Enables callbacks for a given logical type. This must be called before USB device pipe generate callback events.
[in] | module_inst | Pointer to USB software instance struct |
[in] | ep | Endpoint to configure |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was enabled successfully. |
References Assert, usb_module::device_endpoint_enabled_callback_mask, usb_module::hw, STATUS_OK, USB_DEVICE_ENDPOINT_CALLBACK_RXSTP, USB_DEVICE_ENDPOINT_CALLBACK_STALL, USB_DEVICE_ENDPOINT_CALLBACK_TRCPT, USB_DEVICE_ENDPOINT_CALLBACK_TRFAIL, USB_EP_ADDR_MASK, and USB_EP_DIR_IN.
Referenced by udd_ctrl_ep_enable(), and udd_ep_alloc().
void usb_device_endpoint_get_config_defaults | ( | struct usb_device_endpoint_config * | ep_config | ) |
Initializes an USB device endpoint configuration structure to defaults.
Initializes a given USB device endpoint configuration structure to a set of known default values. This function should be called on all new instances of these configuration structures before being modified by the user application.
The default configuration is as follows:
[out] | ep_config | Configuration structure to initialize to default values |
References Assert, usb_device_endpoint_config::auto_zlp, usb_device_endpoint_config::ep_address, usb_device_endpoint_config::ep_size, usb_device_endpoint_config::ep_type, USB_DEVICE_ENDPOINT_TYPE_CONTROL, and USB_ENDPOINT_8_BYTE.
Referenced by udd_ctrl_ep_enable(), udd_ep_alloc(), and udd_ep_free().
bool usb_device_endpoint_is_configured | ( | struct usb_module * | module_inst, |
uint8_t | ep | ||
) |
Check if current endpoint is configured.
module_inst | Pointer to USB software instance struct |
ep | Endpoint address (direction & number) |
true
if endpoint is configured and ready to use References flag, usb_module::hw, USB_DEVICE_ENDPOINT_TYPE_DISABLE, USB_EP_ADDR_MASK, and USB_EP_DIR_IN.
Referenced by udd_ep_wait_stall_clear().
bool usb_device_endpoint_is_halted | ( | struct usb_module * | module_inst, |
uint8_t | ep | ||
) |
Check if endpoint is halted.
module_inst | Pointer to USB software instance struct |
ep | Endpoint address |
true
if the endpoint is halted References usb_module::hw, USB_EP_ADDR_MASK, and USB_EP_DIR_IN.
Referenced by udd_ep_is_halted(), and udd_ep_wait_stall_clear().
enum status_code usb_device_endpoint_read_buffer_job | ( | struct usb_module * | module_inst, |
uint8_t | ep_num, | ||
uint8_t * | pbuf, | ||
uint32_t | buf_size | ||
) |
Start read buffer job on a endpoint.
module_inst | Pointer to USB module instance |
ep_num | Endpoint number |
pbuf | Pointer to buffer |
buf_size | Size of buffer |
STATUS_OK | Job started successfully |
STATUS_ERR_DENIED | Endpoint is not ready |
References Assert, flag, usb_module::hw, STATUS_ERR_DENIED, STATUS_OK, usb_descriptor_table, and USB_DEVICE_ENDPOINT_TYPE_DISABLE.
Referenced by _usb_ep0_on_setup(), udd_ctrl_out_received(), udd_ep_run(), and udd_ep_trans_out_next().
enum status_code usb_device_endpoint_register_callback | ( | struct usb_module * | module_inst, |
uint8_t | ep_num, | ||
enum usb_device_endpoint_callback | callback_type, | ||
usb_device_endpoint_callback_t | callback_func | ||
) |
Registers a USB device endpoint callback.
Registers a callback function which is implemented by the user.
[in] | module_inst | Pointer to USB software instance struct |
[in] | ep_num | Endpoint to configure |
[in] | callback_type | Callback type given by an enum |
[in] | callback_func | Pointer to callback function |
STATUS_OK | The callback was registered successfully. |
References Assert, usb_module::device_endpoint_callback, usb_module::device_endpoint_registered_callback_mask, and STATUS_OK.
Referenced by udd_ctrl_ep_enable(), and udd_ep_alloc().
enum status_code usb_device_endpoint_set_config | ( | struct usb_module * | module_inst, |
struct usb_device_endpoint_config * | ep_config | ||
) |
Writes an USB device endpoint configuration to the hardware module.
Writes out a given configuration of an USB device endpoint configuration to the hardware module. If the pipe is already configured, the new configuration will replace the existing one.
[in] | module_inst | Pointer to USB software instance struct |
[in] | ep_config | Configuration settings for the endpoint |
STATUS_OK | The device endpoint was configured successfully |
STATUS_ERR_DENIED | The endpoint address is already configured |
References Assert, usb_device_endpoint_config::auto_zlp, usb_device_endpoint_config::ep_address, usb_device_endpoint_config::ep_size, usb_device_endpoint_config::ep_type, usb_module::hw, STATUS_ERR_DENIED, STATUS_OK, usb_descriptor_table, USB_DEVICE_ENDPOINT_TYPE_BULK, USB_DEVICE_ENDPOINT_TYPE_CONTROL, USB_DEVICE_ENDPOINT_TYPE_DISABLE, USB_DEVICE_ENDPOINT_TYPE_INTERRUPT, USB_DEVICE_ENDPOINT_TYPE_ISOCHRONOUS, USB_EP_ADDR_MASK, and USB_EP_DIR_IN.
Referenced by udd_ctrl_ep_enable(), udd_ep_alloc(), and udd_ep_free().
void usb_device_endpoint_set_halt | ( | struct usb_module * | module_inst, |
uint8_t | ep | ||
) |
Halt the endpoint (send STALL)
module_inst | Pointer to USB software instance struct |
ep | Endpoint address |
References usb_module::hw, USB_EP_ADDR_MASK, and USB_EP_DIR_IN.
Referenced by udd_ctrl_overflow(), udd_ctrl_stall_data(), udd_ctrl_underflow(), and udd_ep_set_halt().
enum status_code usb_device_endpoint_setup_buffer_job | ( | struct usb_module * | module_inst, |
uint8_t * | pbuf | ||
) |
Start setup packet read job on a endpoint.
module_inst | Pointer to USB device module instance |
pbuf | Pointer to buffer |
STATUS_OK | Job started successfully |
STATUS_ERR_DENIED | Endpoint is not ready |
References Assert, usb_module::hw, STATUS_OK, and usb_descriptor_table.
Referenced by udd_ctrl_ep_enable(), udd_ctrl_in_sent(), and udd_ctrl_send_zlp_in().
enum status_code usb_device_endpoint_unregister_callback | ( | struct usb_module * | module_inst, |
uint8_t | ep_num, | ||
enum usb_device_endpoint_callback | callback_type | ||
) |
Unregisters a USB device endpoint callback.
Unregisters an callback implemented by the user. Removing it from the internal callback registration table.
[in] | module_inst | Pointer to USB software instance struct |
[in] | ep_num | Endpoint to configure |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was unregistered successfully. |
References Assert, usb_module::device_endpoint_callback, usb_module::device_endpoint_registered_callback_mask, NULL, and STATUS_OK.
Referenced by udd_ep_free().
enum status_code usb_device_endpoint_write_buffer_job | ( | struct usb_module * | module_inst, |
uint8_t | ep_num, | ||
uint8_t * | pbuf, | ||
uint32_t | buf_size | ||
) |
Start write buffer job on a endpoint.
module_inst | Pointer to USB module instance |
ep_num | Endpoint number |
pbuf | Pointer to buffer |
buf_size | Size of buffer |
STATUS_OK | Job started successfully |
STATUS_ERR_DENIED | Endpoint is not ready |
References Assert, flag, usb_module::hw, STATUS_ERR_DENIED, STATUS_OK, usb_descriptor_table, and USB_DEVICE_ENDPOINT_TYPE_DISABLE.
Referenced by udd_ctrl_in_sent(), udd_ctrl_send_zlp_in(), udd_ep_run(), and udd_ep_trans_in_next().
enum status_code usb_device_register_callback | ( | struct usb_module * | module_inst, |
enum usb_device_callback | callback_type, | ||
usb_device_callback_t | callback_func | ||
) |
Registers a USB device callback.
Registers a callback function which is implemented by the user.
[in] | module_inst | Pointer to USB software instance struct |
[in] | callback_type | Callback type given by an enum |
[in] | callback_func | Pointer to callback function |
STATUS_OK | The callback was registered successfully. |
References Assert, usb_module::device_callback, usb_module::device_registered_callback_mask, and STATUS_OK.
Referenced by _usb_on_wakeup(), and udd_attach().
enum status_code usb_device_unregister_callback | ( | struct usb_module * | module_inst, |
enum usb_device_callback | callback_type | ||
) |
Unregisters a USB device callback.
Unregisters an asynchronous callback implemented by the user. Removing it from the internal callback registration table.
[in] | module_inst | Pointer to USB software instance struct |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was unregistered successfully. |
References Assert, usb_module::device_callback, usb_module::device_registered_callback_mask, NULL, and STATUS_OK.
void usb_disable | ( | struct usb_module * | module_inst | ) |
Disable the USB module peripheral.
module_inst | pointer to USB module instance |
References Assert, and usb_module::hw.
void usb_enable | ( | struct usb_module * | module_inst | ) |
Enable the USB module peripheral.
module_inst | pointer to USB module instance |
References Assert, and usb_module::hw.
Referenced by udd_enable(), and uhd_enable().
void usb_get_config_defaults | ( | struct usb_config * | module_config | ) |
Get the default USB module settings.
[out] | module_config | Configuration structure to initialize to default values |
References Assert, GCLK_GENERATOR_3, usb_config::run_in_standby, usb_config::select_host_mode, usb_config::source_generator, usb_config::speed_mode, and USB_SPEED_FULL.
Referenced by udd_enable(), and uhd_enable().
void USB_Handler | ( | void | ) |
Interrupt handler for the USB module.
References _usb_device_interrupt_handler(), and _usb_host_interrupt_handler().
enum status_code usb_host_disable_callback | ( | struct usb_module * | module_inst, |
enum usb_host_callback | callback_type | ||
) |
Disables USB host callback generation for a given type.
Disables asynchronous callbacks for a given logical type.
[in] | module_inst | Pointer to USB software instance struct |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was disabled successfully. |
References Assert, usb_module::host_enabled_callback_mask, usb_module::hw, STATUS_OK, USB_HOST_CALLBACK_CONNECT, USB_HOST_CALLBACK_DISCONNECT, USB_HOST_CALLBACK_DNRSM, USB_HOST_CALLBACK_RAMACER, USB_HOST_CALLBACK_RESET, USB_HOST_CALLBACK_SOF, USB_HOST_CALLBACK_UPRSM, and USB_HOST_CALLBACK_WAKEUP.
Referenced by _uhd_connect(), _uhd_disconnect(), _uhd_downstream_resume(), _uhd_upstream_resume(), _uhd_wakeup(), and uhd_disable().
enum status_code usb_host_enable_callback | ( | struct usb_module * | module_inst, |
enum usb_host_callback | callback_type | ||
) |
Enables USB host callback generation for a given type.
Enables asynchronous callbacks for a given logical type. This must be called before USB host generate callback events.
[in] | module_inst | Pointer to USB software instance struct |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was enabled successfully. |
References Assert, usb_module::host_enabled_callback_mask, usb_module::hw, STATUS_OK, USB_HOST_CALLBACK_CONNECT, USB_HOST_CALLBACK_DISCONNECT, USB_HOST_CALLBACK_DNRSM, USB_HOST_CALLBACK_RAMACER, USB_HOST_CALLBACK_RESET, USB_HOST_CALLBACK_SOF, USB_HOST_CALLBACK_UPRSM, and USB_HOST_CALLBACK_WAKEUP.
Referenced by _uhd_connect(), _uhd_disconnect(), _uhd_ep0_transfer_complete(), _uhd_sof_interrupt(), and uhd_enable().
enum status_code usb_host_pipe_abort_job | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num | ||
) |
USB host abort a pipe job.
USB host pipe abort job by freeze the pipe.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
STATUS_OK | The abort job was set successfully. |
STATUS_ERR_NOT_INITIALIZED | The pipe has not been configured. |
References Assert, usb_module::hw, STATUS_ERR_NOT_INITIALIZED, STATUS_OK, and USB_HOST_PIPE_TYPE_DISABLE.
enum status_code usb_host_pipe_disable_callback | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
enum usb_host_pipe_callback | callback_type | ||
) |
Disables USB host callback generation for a given type.
Disables asynchronous callbacks for a given logical type.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was disabled successfully. |
References Assert, usb_module::host_pipe_enabled_callback_mask, usb_module::hw, STATUS_OK, USB_HOST_PIPE_CALLBACK_ERROR, USB_HOST_PIPE_CALLBACK_SETUP, USB_HOST_PIPE_CALLBACK_STALL, and USB_HOST_PIPE_CALLBACK_TRANSFER_COMPLETE.
enum status_code usb_host_pipe_enable_callback | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
enum usb_host_pipe_callback | callback_type | ||
) |
Enables USB host pipe callback generation for a given type.
Enables asynchronous callbacks for a given logical type. This must be called before USB host pipe generate callback events.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was enabled successfully. |
References Assert, usb_module::host_pipe_enabled_callback_mask, usb_module::hw, STATUS_OK, USB_HOST_PIPE_CALLBACK_ERROR, USB_HOST_PIPE_CALLBACK_SETUP, USB_HOST_PIPE_CALLBACK_STALL, and USB_HOST_PIPE_CALLBACK_TRANSFER_COMPLETE.
Referenced by _uhd_ctrl_phase_setup(), _uhd_pipe_trans_complete(), uhd_ep0_alloc(), and uhd_ep_alloc().
enum status_code usb_host_pipe_get_config | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
struct usb_host_pipe_config * | ep_config | ||
) |
Gets an USB host pipe configuration.
Gets out the configuration of an USB host pipe from the hardware module.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[out] | ep_config | Configuration settings for the pipe |
STATUS_OK | The host pipe configuration was read successfully. |
References Assert, usb_host_pipe_config::binterval, usb_host_pipe_config::device_address, usb_host_pipe_config::endpoint_address, usb_module::hw, if(), usb_host_pipe_config::pipe_type, usb_host_pipe_config::size, STATUS_OK, usb_descriptor_table, USB_EP_DIR_IN, and USB_HOST_PIPE_TOKEN_IN.
Referenced by _uhd_ctrl_phase_data_in(), _uhd_ctrl_phase_data_in_start(), _uhd_ctrl_phase_data_out(), _uhd_ctrl_phase_setup(), _uhd_ctrl_request_end(), _uhd_ep0_error(), _uhd_ep0_stall(), _uhd_ep0_transfer_complete(), _uhd_get_pipe(), _uhd_pipe_finish_job(), _uhd_pipe_trans_complete(), uhd_ep_alloc(), uhd_ep_free(), and uhd_resume().
void usb_host_pipe_get_config_defaults | ( | struct usb_host_pipe_config * | ep_config | ) |
Initializes an USB host pipe configuration structure to defaults.
Initializes a given USB host pipe configuration structure to a set of known default values. This function should be called on all new instances of these configuration structures before being modified by the user application.
The default configuration is as follows:
[out] | ep_config | Configuration structure to initialize to default values |
References Assert, usb_host_pipe_config::binterval, usb_host_pipe_config::device_address, usb_host_pipe_config::endpoint_address, usb_host_pipe_config::pipe_type, usb_host_pipe_config::size, and USB_HOST_PIPE_TYPE_CONTROL.
Referenced by uhd_ep0_alloc(), and uhd_ep_alloc().
enum status_code usb_host_pipe_lpm_job | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
bool | b_remotewakeup, | ||
uint8_t | hird | ||
) |
Sends the LPM package.
Sends the LPM package.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | b_remotewakeup | Remote wake up flag |
[in] | hird | Host Initiated Resume Duration |
STATUS_OK | The setup job was set successfully. |
STATUS_BUSY | The pipe is busy. |
STATUS_ERR_NOT_INITIALIZED | The pipe has not been configured. |
References Assert, usb_module::hw, STATUS_BUSY, STATUS_ERR_NOT_INITIALIZED, STATUS_OK, usb_descriptor_table, USB_HOST_PIPE_TYPE_DISABLE, USB_HOST_PIPE_TYPE_EXTENDED, usb_host_pipe_unfreeze(), USB_LPM_ATTRIBUT_BLINKSTATE_L1, USB_LPM_ATTRIBUT_HIRD, and USB_LPM_ATTRIBUT_REMOTEWAKE.
Referenced by uhd_suspend_lpm().
enum status_code usb_host_pipe_read_job | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
uint8_t * | buf, | ||
uint32_t | buf_size | ||
) |
USB host pipe read job.
USB host pipe read job by set and start an in transaction transfer.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | buf | Pointer to data buffer |
[in] | buf_size | Data buffer size |
STATUS_OK | The read job was set successfully. |
STATUS_BUSY | The pipe is busy. |
STATUS_ERR_NOT_INITIALIZED | The pipe has not been configured. |
References Assert, usb_module::hw, STATUS_BUSY, STATUS_ERR_NOT_INITIALIZED, STATUS_OK, usb_descriptor_table, USB_HOST_PIPE_TOKEN_IN, USB_HOST_PIPE_TYPE_DISABLE, and usb_host_pipe_unfreeze().
Referenced by _uhd_ctrl_phase_data_in(), _uhd_ctrl_phase_data_in_start(), _uhd_ctrl_phase_zlp_in(), and _uhd_pipe_trans_complete().
enum status_code usb_host_pipe_register_callback | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
enum usb_host_pipe_callback | callback_type, | ||
usb_host_pipe_callback_t | callback_func | ||
) |
Registers a USB host pipe callback.
Registers a callback function which is implemented by the user.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | callback_type | Callback type given by an enum |
[in] | callback_func | Pointer to callback function |
STATUS_OK | The callback was registered successfully. |
References Assert, usb_module::host_pipe_callback, usb_module::host_pipe_registered_callback_mask, and STATUS_OK.
Referenced by uhd_ep0_alloc(), and uhd_ep_alloc().
void usb_host_pipe_set_auto_zlp | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
bool | value | ||
) |
Sets USB host pipe auto ZLP setting value.
Set the auto zero length packet of pipe.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | value | Auto ZLP setting value, true to enable |
References Assert, and usb_descriptor_table.
Referenced by _uhd_pipe_trans_complete().
enum status_code usb_host_pipe_set_config | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
struct usb_host_pipe_config * | ep_config | ||
) |
Writes an USB host pipe configuration to the hardware module.
Writes out a given configuration of an USB host pipe configuration to the hardware module. If the pipe is already configured, the new configuration will replace the existing one.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | ep_config | Configuration settings for the pipe |
STATUS_OK | The host pipe was configured successfully. |
References Assert, usb_host_pipe_config::binterval, clz, usb_host_pipe_config::device_address, usb_host_pipe_config::endpoint_address, usb_module::hw, max, min, usb_host_pipe_config::pipe_type, usb_host_pipe_config::size, STATUS_OK, UHD_BULK_INTERVAL_MIN, usb_descriptor_table, USB_EP_ADDR_MASK, USB_EP_DIR_IN, USB_HOST_PIPE_TOKEN_IN, USB_HOST_PIPE_TOKEN_OUT, USB_HOST_PIPE_TOKEN_SETUP, and USB_HOST_PIPE_TYPE_BULK.
Referenced by _uhd_ep0_error(), _uhd_ep0_stall(), _uhd_ep0_transfer_complete(), uhd_ep0_alloc(), and uhd_ep_alloc().
enum status_code usb_host_pipe_setup_job | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
uint8_t * | buf | ||
) |
Sends the setup package.
Sends the setup package.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | buf | Pointer to data buffer |
STATUS_OK | The setup job was set successfully. |
STATUS_BUSY | The pipe is busy. |
STATUS_ERR_NOT_INITIALIZED | The pipe has not been configured. |
References Assert, usb_module::hw, STATUS_BUSY, STATUS_ERR_NOT_INITIALIZED, STATUS_OK, usb_descriptor_table, USB_HOST_PIPE_TOKEN_SETUP, USB_HOST_PIPE_TYPE_DISABLE, and usb_host_pipe_unfreeze().
Referenced by _uhd_ctrl_phase_setup().
enum status_code usb_host_pipe_unregister_callback | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
enum usb_host_pipe_callback | callback_type | ||
) |
Unregisters a USB host pipe callback.
Unregisters an asynchronous callback implemented by the user. Removing it from the internal callback registration table.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was unregistered successfully. |
References Assert, usb_module::host_pipe_callback, usb_module::host_pipe_registered_callback_mask, NULL, and STATUS_OK.
enum status_code usb_host_pipe_write_job | ( | struct usb_module * | module_inst, |
uint8_t | pipe_num, | ||
uint8_t * | buf, | ||
uint32_t | buf_size | ||
) |
USB host pipe write job.
USB host pipe write job by set and start an out transaction transfer.
[in] | module_inst | Pointer to USB software instance struct |
[in] | pipe_num | Pipe to configure |
[in] | buf | Pointer to data buffer |
[in] | buf_size | Data buffer size |
STATUS_OK | The write job was set successfully. |
STATUS_BUSY | The pipe is busy. |
STATUS_ERR_NOT_INITIALIZED | The pipe has not been configured. |
References Assert, usb_module::hw, STATUS_BUSY, STATUS_ERR_NOT_INITIALIZED, STATUS_OK, usb_descriptor_table, USB_HOST_PIPE_TOKEN_OUT, USB_HOST_PIPE_TYPE_DISABLE, and usb_host_pipe_unfreeze().
Referenced by _uhd_ctrl_phase_data_out(), _uhd_ctrl_phase_zlp_out(), and _uhd_pipe_trans_complete().
enum status_code usb_host_register_callback | ( | struct usb_module * | module_inst, |
enum usb_host_callback | callback_type, | ||
usb_host_callback_t | callback_func | ||
) |
Registers a USB host callback.
Registers a callback function which is implemented by the user.
[in] | module_inst | Pointer to USB software instance struct |
[in] | callback_type | Callback type given by an enum |
[in] | callback_func | Pointer to callback function |
STATUS_OK | The callback was registered successfully. |
References Assert, usb_module::host_callback, usb_module::host_registered_callback_mask, and STATUS_OK.
Referenced by uhd_enable().
enum status_code usb_host_unregister_callback | ( | struct usb_module * | module_inst, |
enum usb_host_callback | callback_type | ||
) |
Unregisters a USB host callback.
Unregisters an asynchronous callback implemented by the user. Removing it from the internal callback registration table.
[in] | module_inst | Pointer to USB software instance struct |
[in] | callback_type | Callback type given by an enum |
STATUS_OK | The callback was unregistered successfully. |
References Assert, usb_module::host_callback, usb_module::host_registered_callback_mask, NULL, and STATUS_OK.
enum status_code usb_init | ( | struct usb_module * | module_inst, |
Usb *const | hw, | ||
struct usb_config * | module_config | ||
) |
Initializes USB module instance.
Enables the clock and initializes the USB module, based on the given configuration values.
[in,out] | module_inst | Pointer to the software module instance struct |
[in] | hw | Pointer to the USB hardware module |
[in] | module_config | Pointer to the USB configuration options struct |
STATUS_OK | The module was initialized successfully |
References Assert, usb_module::device_callback, usb_module::device_enabled_callback_mask, usb_module::device_endpoint_callback, usb_module::device_endpoint_enabled_callback_mask, usb_module::device_endpoint_registered_callback_mask, usb_module::device_registered_callback_mask, usb_module::host_callback, usb_module::host_enabled_callback_mask, usb_module::host_pipe_callback, usb_module::host_pipe_enabled_callback_mask, usb_module::host_pipe_registered_callback_mask, usb_module::host_registered_callback_mask, usb_module::hw, i, j, module_inst, system_pinmux_config::mux_position, NULL, NVM_USB_PAD_TRANSN_POS, NVM_USB_PAD_TRANSN_SIZE, NVM_USB_PAD_TRANSP_POS, NVM_USB_PAD_TRANSP_SIZE, NVM_USB_PAD_TRIM_POS, NVM_USB_PAD_TRIM_SIZE, usb_config::run_in_standby, usb_config::select_host_mode, system_gclk_chan_config::source_generator, usb_config::source_generator, usb_config::speed_mode, STATUS_OK, system_apb_clock_set_mask(), SYSTEM_CLOCK_APB_APBB, system_gclk_chan_enable(), system_gclk_chan_get_config_defaults(), system_gclk_chan_set_config(), system_interrupt_enable(), SYSTEM_INTERRUPT_MODULE_USB, system_pinmux_get_config_defaults(), system_pinmux_pin_set_config(), usb_descriptor_table, USB_DEVICE_CALLBACK_N, USB_DEVICE_EP_CALLBACK_N, USB_HOST_CALLBACK_N, USB_HOST_PIPE_CALLBACK_N, USB_SPEED_FULL, and USB_SPEED_LOW.
Referenced by udd_enable(), and uhd_enable().
|
static |
USB Device IRQ Mask Bits Map
|
static |
USB Device IRQ Mask Bits Map
|
static |
Local USB module instance.
|
static |
|
static |
Device endpoint callback parameter variable, used to transfer info to UDD wrapper layer.
Referenced by _usb_device_interrupt_handler(), _usb_ep0_on_setup(), _usb_ep0_on_tansfer_fail(), udd_ctrl_out_received(), udd_ctrl_overflow(), udd_ctrl_underflow(), udd_ep_trans_in_next(), udd_ep_trans_out_next(), and udd_ep_transfer_process().
uint32_t host_pipe_job_busy_status = 0 |
Bit mask for pipe job busy status.
|
static |
Host pipe callback structure variable.
Referenced by _usb_host_interrupt_handler().
COMPILER_WORD_ALIGNED { ... } usb_descriptor_table |
Referenced by _usb_device_interrupt_handler(), _usb_host_interrupt_handler(), usb_device_endpoint_read_buffer_job(), usb_device_endpoint_set_config(), usb_device_endpoint_setup_buffer_job(), usb_device_endpoint_write_buffer_job(), usb_host_pipe_get_config(), usb_host_pipe_lpm_job(), usb_host_pipe_read_job(), usb_host_pipe_set_auto_zlp(), usb_host_pipe_set_config(), usb_host_pipe_setup_job(), usb_host_pipe_write_job(), and usb_init().
UsbDeviceDescriptor usb_endpoint_table[USB_EPT_NUM] |
UsbHostDescriptor usb_pipe_table[USB_PIPE_NUM] |