Microchip® Advanced Software Framework

usb_task.c File Reference
#include "compiler.h"
#include "intc.h"
#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_task.h"
#include "cycle_counter.h"
#include "usb_host_task.h"

Functions

uint32_t host_get_timeout (void)
 
void host_suspend_action (void)
 
 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...
 
 while ((i=Host_get_interrupt_pipe_number())< MAX_PEP_NB)
 

Variables

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...
 
static const char log_device_disconnected [] = "Device disconnected\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...
 
t_cpu_time timer_vbus_low
 

void host_suspend_action ( void  )
Todo:
Implement this on the silicon version

References cpu_irq_enable.

ISR ( usb_general_interrupt  ,
AVR32_USBB_IRQ_GROUP  ,
USB_INT_LEVEL   
)
UNUSED ( )

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 mem_name(), mem_removal(), mem_unload(), memory_2_ram(), ram_2_memory(), stream_state(), and stream_stop().

const char log_device_disconnected[] = "Device disconnected\r\n"
static
t_cpu_time timer_vbus_low

Referenced by usb_host_task().