Microchip® Advanced Software Framework

applications/uc3-audio-player/usb_task.c File Reference
#include "compiler.h"
#include "intc.h"
#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_task.h"
#include "usb_descriptors.h"
#include "usb_device_task.h"
#include "usb_host_task.h"

Functions

uint32_t host_get_timeout (void)
 
 if (Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
 
 ISR (usb_general_interrupt, AVR32_USBB_IRQ_GROUP, USB_INT_LEVEL)
 
 UNUSED (i)
 USB interrupt routine. More...
 
void usb_task (void)
 Entry point of the USB mamnagement. More...
 
void usb_task_init (void)
 This function initializes the USB process. More...
 

Variables

static volatile uint8_t g_old_usb_mode
 
volatile bool g_sav_int_sof_enable
 
volatile uint16_t g_usb_event = 0
 Public: uint16_t g_usb_event usb_connected is used to store USB events detected upon USB general interrupt subroutine Its value is managed by the following macros (See usb_task.h file) Usb_send_event(x) Usb_ack_event(x) Is_usb_event(x) Usb_clear_all_event() More...
 
volatile uint8_t g_usb_mode = USB_MODE_UNDEFINED
 Public: uint8_t g_usb_mode Used in dual-role application (both device/host) to store the current mode the USB controller is operating. More...
 
volatile S_pipe_int it_pipe_str [MAX_PEP_NB]
 
static const char log_device_disconnected [] = "Device disconnected\r\n"
 
static const char log_pin_id_changed [] = "Pin Id changed\r\n"
 
volatile uint32_t private_sof_counter
 Private: uint8_t private_sof_counter Incremented by host SOF interrupt subroutime This counter is used to detect time-out in host requests. More...
 
volatile bool usb_connected
 Public: bool usb_connected usb_connected is set to true when VBus has been detected usb_connected is set to false otherwise Used with USB_DEVICE_FEATURE == true only. More...
 

UNUSED ( i  )

USB interrupt routine.

This function is called each time a USB interrupt occurs. The following USB DEVICE events are taken in charge:

  • VBus On / Off
  • Start-of-Frame
  • Suspend
  • Wake-Up
  • Resume
  • Reset

The following USB HOST events are taken in charge:

  • Device connection
  • Device Disconnection
  • Start-of-Frame
  • ID pin change
  • SOF (or Keep alive in low-speed) sent
  • Wake-up on USB line detected
  • Pipe events

For each event, the user can launch an action by completing the associated #define (see the conf_usb.h file to add actions on events).

Note: Only interrupt events that are enabled are processed.

Warning: If device and host tasks are not tasks in an RTOS, rough events like ID transition, VBus transition, device disconnection, etc. that need to kill then restart these tasks may lead to an undefined state if they occur just before something is activated in the USB macro (e.g. pipe/endpoint transfer...).

Returns
Nothing in the standalone configuration; a boolean indicating whether a task switch is required in the FreeRTOS configuration

Referenced by at25dfx_spi_deselect_device(), at25dfx_spi_select_device(), main(), main_keyboard_led(), main_memories_trans_task(), main_usb_connection_event(), mem_name(), mem_removal(), mem_unload(), memory_2_ram(), ram_2_memory(), run_osc_test(), run_pll_dfll_test(), run_sync_clock_test(), run_usb_cdc_test(), run_usb_mouse_test(), sd_mmc_is_write_protected(), sd_mmc_removal(), sd_mmc_spi_get_bus_width(), sd_mmc_spi_get_response_128(), sleepmgr_lock_mode(), sleepmgr_unlock_mode(), stream_state(), stream_stop(), udi_cdc_data_sent(), udi_cdc_line_coding_received(), udi_cdc_serial_state_msg_sent(), udi_hid_generic_report_in_sent(), udi_hid_generic_report_out_received(), udi_hid_kbd_report_sent(), udi_hid_mouse_report_sent(), udi_hid_multi_touch_report_in_sent(), udi_msc_cbw_received(), udi_msc_csw_sent(), udi_msc_data_sent(), udi_msc_trans_ack(), uhc_dev_get_string(), uhc_enumeration_step10(), uhc_enumeration_step12(), uhc_enumeration_step13(), uhc_enumeration_step14(), uhc_enumeration_step15(), uhc_enumeration_step6(), uhc_setup_request_callback(), uhi_cdc_rx_received(), uhi_cdc_sof(), uhi_cdc_tx_send(), uhi_hid_mouse_report_reception(), uhi_msc_cbw_rst_stall(), uhi_msc_cbw_sent(), uhi_msc_csw_received(), uhi_msc_data_csw_rst_stall(), uhi_msc_data_transfered(), uhi_msc_enable_step2(), uhi_msc_enable_step5(), usart_spi_deselect_device(), usart_spi_select_device(), and usart_spi_setup_device().

volatile uint8_t g_old_usb_mode
static

Referenced by if().

volatile bool g_sav_int_sof_enable
volatile S_pipe_int it_pipe_str[MAX_PEP_NB]
const char log_device_disconnected[] = "Device disconnected\r\n"
static
const char log_pin_id_changed[] = "Pin Id changed\r\n"
static

Referenced by if().

volatile bool usb_connected

Public: bool usb_connected usb_connected is set to true when VBus has been detected usb_connected is set to false otherwise Used with USB_DEVICE_FEATURE == true only.

Public: bool usb_connected usb_connected is set to true when VBus has been detected usb_connected is set to false otherwise Used with USB_DEVICE_FEATURE == true only.