#include "config.h"
#include "conf_usb.h"
#include "usb_task.h"
#include "lib_mcu/usb/usb_drv.h"
#include "usb_descriptors.h"
#include "lib_mcu/power/power_drv.h"
#include "lib_mcu/wdt/wdt_drv.h"
#include "lib_mcu/pll/pll_drv.h"
#include "modules/usb/device_chap9/usb_device_task.h"
Include dependency graph for usb_task.c:
Go to the source code of this file.
Defines | |
#define | LOG_STR_CODE(str) |
Functions | |
void | usb_task_init (void) |
This function initializes the USB proces. | |
void | usb_task (void) |
Entry point of the USB mamnagement. | |
__interrupt void | usb_general_interrupt () |
USB interrupt subroutine. | |
Variables | |
volatile U16 | g_usb_event = 0 |
Public : U16 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) Usb_clear_all_event() Is_usb_event(x) Is_not_usb_event(x). | |
bit | usb_connected |
Public : (bit) 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 == ENABLED only /. | |
U8 | usb_configuration_nb |
Public : (U8) usb_configuration_nb Store the number of the USB configuration used by the USB device when its value is different from zero, it means the device mode is enumerated Used with USB_DEVICE_FEATURE == ENABLED only /. | |
volatile U8 | private_sof_counter = 0 |
Private : (U8) private_sof_counter Incremented by host SOF interrupt subroutime This counter is used to detect timeout in host requests. | |
volatile S_pipe_int | it_pipe_str [MAX_EP_NB] |
U8 | g_usb_mode = 0x00 |
Public : (U8) g_usb_mode Used in dual role application (both device/host) to store the current mode the usb controller is operating /. | |
U8 | g_old_usb_mode |
Copyright (c) 2006 Atmel.
Please read file license.txt for copyright notice.
The USB task selects the correct USB task (usb_device task or usb_host task to be executed depending on the current mode available.
According to USB_DEVICE_FEATURE and USB_HOST_FEATURE value (located in conf_usb.h file) The usb_task can be configured to support USB DEVICE mode or USB Host mode or both for a dual role device application.
This module also contains the general USB interrupt subroutine. This subroutine is used to detect asynchronous USB events.
Note:
Definition in file usb_task.c.
#define LOG_STR_CODE | ( | str | ) |
Definition at line 53 of file usb_task.c.
__interrupt void usb_general_interrupt | ( | ) |
USB interrupt subroutine.
This function is called each time a USB interrupt occurs. The following USB DEVICE events are taken in charge:
For each event, the user can launch an action by completing the associate define (See conf_usb.h file to add action upon events)
Note: Only interrupts events that are enabled are processed
none |
Definition at line 176 of file usb_task.c.
References DISABLED, EVT_USB_RESET, EVT_USB_RESUME, EVT_USB_SUSPEND, EVT_USB_WAKE_UP, Is_reset_interrupt_enabled, Is_resume_interrupt_enabled, Is_sof_interrupt_enabled, Is_suspend_interrupt_enabled, Is_swake_up_interrupt_enabled, Is_usb_reset, Is_usb_resume, Is_usb_sof, Is_usb_suspend, Is_usb_wake_up, Usb_ack_reset, Usb_ack_resume, Usb_ack_sof, Usb_ack_suspend, Usb_ack_wake_up, Usb_disable_resume_interrupt, Usb_disable_wake_up_interrupt, Usb_enable_wake_up_interrupt, Usb_freeze_clock, usb_init_device(), usb_remote_wup_feature, Usb_reset_action, Usb_resume_action, Usb_send_event, Usb_sof_action, Usb_suspend_action, Usb_unfreeze_clock, and Usb_wake_up_action.
00178 { 00179 // - Device start of frame received 00180 if (Is_usb_sof() && Is_sof_interrupt_enabled()) 00181 { 00182 Usb_ack_sof(); 00183 Usb_sof_action(); 00184 } 00185 // - Device Suspend event (no more USB activity detected) 00186 if (Is_usb_suspend() && Is_suspend_interrupt_enabled()) 00187 { 00188 Usb_enable_wake_up_interrupt(); 00189 Usb_ack_wake_up(); // clear wake up to detect next event 00190 Usb_freeze_clock(); 00191 Usb_send_event(EVT_USB_SUSPEND); 00192 Usb_suspend_action(); 00193 Usb_ack_suspend(); // must be executed last (after Usb_suspend_action()) to allow upstream resume 00194 } 00195 // - Wake up event (USB activity detected): Used to resume 00196 if (Is_usb_wake_up() && Is_swake_up_interrupt_enabled()) 00197 { 00198 Usb_unfreeze_clock(); 00199 Usb_ack_wake_up(); 00200 Usb_disable_wake_up_interrupt(); 00201 Usb_wake_up_action(); 00202 Usb_send_event(EVT_USB_WAKE_UP); 00203 } 00204 // - Resume state bus detection 00205 if (Is_usb_resume() && Is_resume_interrupt_enabled()) 00206 { 00207 Usb_disable_wake_up_interrupt(); 00208 Usb_ack_resume(); 00209 Usb_disable_resume_interrupt(); 00210 Usb_resume_action(); 00211 Usb_send_event(EVT_USB_RESUME); 00212 } 00213 // - USB bus reset detection 00214 if (Is_usb_reset()&& Is_reset_interrupt_enabled()) 00215 { 00216 #if (USB_REMOTE_WAKEUP == ENABLED) 00217 usb_remote_wup_feature = DISABLED; 00218 #endif 00219 Usb_ack_reset(); 00220 usb_init_device(); 00221 Usb_reset_action(); 00222 Usb_send_event(EVT_USB_RESET); 00223 } 00224 00225 }
Here is the call graph for this function:
bit usb_connected |
Public : (bit) 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 == ENABLED only /.
Definition at line 42 of file usb_device_task.c.
Referenced by usb_device_task().
volatile S_pipe_int it_pipe_str[MAX_EP_NB] |
Definition at line 115 of file usb_task.c.