Atmel 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...
 

Todo:
ID pin hot state change!!!

References CPU_RESET_CALLBACK, device_state, DEVICE_UNATTACHED, EVT_USB_DEVICE_FUNCTION, EVT_USB_HOST_FUNCTION, g_old_usb_mode, g_usb_mode, Host_device_disconnection_action, Is_host_attached, Is_usb_device, Is_usb_id_device, log_pin_id_changed, LOG_STR, Reset_CPU, taskENTER_CRITICAL, taskEXIT_CRITICAL, Usb_ack_id_transition, usb_configuration_nb, usb_connected, Usb_disable, Usb_disable_otg_pad, Usb_id_transition_action, USB_MODE_DEVICE, USB_MODE_HOST, Usb_send_event, Usb_vbus_off_action, and xSemaphoreGiveFromISR.

Referenced by audio_mixer_dacs_setup_direct(), audio_mixer_dacs_start_direct(), consume_markers(), create_colorindex(), decode_mcu(), decode_mcu_AC_first(), decode_mcu_DC_first(), decode_mcu_DC_refine(), encode_mcu_gather(), finish_output_pass(), flashc_memset64(), free_pool(), host_read_p_rxpacket(), ieee11073_decode_metadata(), jinit_d_post_controller(), jpeg_lib_decode_ex(), jpeg_make_c_derived_tbl(), jpeg_make_d_derived_tbl(), jpeg_new_colormap(), jpeg_set_marker_processor(), low_level_output(), merged_2v_upsample(), METHODDEF(), mxt_process_messages(), navigation_task(), pbuf_header(), plug_holes(), post_process_1pass(), post_process_2pass(), post_process_prepass(), prepare_for_output_pass(), process_data_context_main(), process_data_simple_main(), process_pqueue(), process_restart(), request_virt_barray(), request_virt_sarray(), sep_upsample(), sfh7770_set_threshold(), skip_input_data(), smoothing_ok(), start_output_pass(), start_pass_2_quant(), start_pass_coef(), start_pass_huff_decoder(), start_pass_prep(), uhi_msc_scsi_test_unit_ready_sense(), usb_read_ep_rxpacket(), usb_stream_process(), and wlif_poll().

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_disable(), 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_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 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.

Referenced by ai_hid_class_get_device_status(), if(), usb_device_task(), usb_device_task_init(), usb_general_interrupt(), and usb_start_device().