#include "compiler.h"
#include "intc.h"
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_task.h"
#include "cycle_counter.h"
#include "usb_descriptors.h"
#include "usb_device_task.h"
#include "usb_host_task.h"
#include "pm_uc3c.h"
Functions | |
U32 | host_get_timeout (void) |
void | host_suspend_action (void) |
static void | usb_general_interrupt (void) |
USB interrupt routine. More... | |
static portBASE_TYPE | usb_general_interrupt_non_naked (void) |
Entry point of the USB management. More... | |
void | usb_suspend_action (void) |
void | usb_task (void *pvParameters) |
Entry point of the USB mamnagement. More... | |
void | usb_task_init (void) |
This function initializes the USB process. More... | |
Variables | |
static volatile U8 | g_old_usb_mode |
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) Is_usb_event(x) Usb_clear_all_event() More... | |
volatile U8 | g_usb_mode = USB_MODE_UNDEFINED |
Public: U8 g_usb_mode Used in dual-role application (both device/host) to store the current mode the USB controller is operating. More... | |
static const char | log_device_disconnected [] = "Device disconnected\r\n" |
static const char | log_pin_id_changed [] = "Pin Id changed\r\n" |
volatile U32 | private_sof_counter |
Private: U8 private_sof_counter Incremented by host SOF interrupt subroutine 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... | |
xTaskHandle | usb_device_tsk |
Handle to the USB Device task. More... | |
xTaskHandle | usb_host_tsk |
Handle to the USB Host task. More... | |
static xSemaphoreHandle | usb_tsk_semphr = NULL |
Handle to the USB task semaphore. More... | |
USB interrupt routine.
When FreeRTOS is used, the USB interrupt routine may trigger task switches, so it must use special OS prologue and epilogue. This function must be naked in order to have no stack frame. usb_general_interrupt_non_naked is therefore used for the required stack frame of the interrupt routine.
References usb_general_interrupt_non_naked().
Referenced by usb_task().
|
static |
Entry point of the USB management.
Depending on the USB mode supported (HOST/DEVICE/DUAL_ROLE) the function calls the corresponding USB management function. USB interrupt routine
This function is called each time a USB interrupt occurs. The following USB DEVICE events are taken in charge:
The following USB HOST events are taken in charge:
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...).
References device_state, DEVICE_UNATTACHED, S_pipe_int::enable, EVT_HOST_DISCONNECTION, EVT_HOST_HWUP, EVT_HOST_SOF, EVT_USB_DEVICE_FUNCTION, EVT_USB_HOST_FUNCTION, EVT_USB_POWERED, EVT_USB_RESET, EVT_USB_RESUME, EVT_USB_SUSPEND, EVT_USB_UNPOWERED, EVT_USB_WAKE_UP, g_old_usb_mode, g_usb_mode, S_pipe_int::handler, Host_ack_device_connection, Host_ack_device_disconnection, Host_ack_hwup, Host_ack_sof, Host_device_connection_action, Host_device_disconnection_action, host_disable_all_pipes(), Host_disable_hwup_interrupt, Host_disable_sof_interrupt, Host_get_interrupt_pipe_number, Host_get_pipe_type, Host_hwup_action, Host_reset_pipe, Host_sof_action, Is_host_attached, Is_host_device_connection, Is_host_device_connection_interrupt_enabled, Is_host_device_disconnection, Is_host_device_disconnection_interrupt_enabled, Is_host_hwup, Is_host_hwup_interrupt_enabled, Is_host_sof, Is_host_sof_interrupt_enabled, Is_usb_clock_frozen, Is_usb_device, Is_usb_full_speed_mode, Is_usb_id_device, Is_usb_id_interrupt_enabled, Is_usb_id_transition, Is_usb_reset, Is_usb_reset_interrupt_enabled, Is_usb_resume, Is_usb_resume_interrupt_enabled, Is_usb_sof, Is_usb_sof_interrupt_enabled, Is_usb_suspend, Is_usb_suspend_interrupt_enabled, Is_usb_vbus_high, Is_usb_vbus_interrupt_enabled, Is_usb_vbus_transition, Is_usb_wake_up, Is_usb_wake_up_interrupt_enabled, log_device_disconnected, log_pin_id_changed, LOG_STR, MAX_PEP_NB, pdFALSE, PIPE_DELAY_TIMEOUT, private_sof_counter, S_pipe_int::status, taskENTER_CRITICAL, taskEXIT_CRITICAL, timeout, TIMEOUT_DELAY, TYPE_INTERRUPT, Usb_ack_id_transition, Usb_ack_reset, Usb_ack_resume, Usb_ack_sof, Usb_ack_suspend, Usb_ack_vbus_transition, Usb_ack_wake_up, usb_configuration_nb, usb_connected, Usb_detach, Usb_disable, Usb_disable_otg_pad, Usb_disable_resume_interrupt, Usb_disable_wake_up_interrupt, Usb_enable_wake_up_interrupt, Usb_freeze_clock, Usb_id_transition_action, usb_init_device(), USB_MODE_DEVICE, USB_MODE_HOST, Usb_reset_action, Usb_resume_action, Usb_send_event, Usb_sof_action, usb_start_device(), Usb_suspend_action, Usb_unfreeze_clock, Usb_vbus_off_action, Usb_vbus_on_action, Usb_wake_up_action, void, and xSemaphoreGiveFromISR.
Referenced by usb_general_interrupt().
|
static |
Referenced by usb_general_interrupt_non_naked(), and usb_task().
|
static |
Referenced by usb_general_interrupt_non_naked().
|
static |
Referenced by usb_general_interrupt_non_naked().
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 usb_device_task(), usb_device_task_init(), usb_general_interrupt_non_naked(), and usb_start_device().
xTaskHandle usb_device_tsk |
Handle to the USB Device task.
Referenced by usb_device_task_init(), and usb_task().
xTaskHandle usb_host_tsk |
Handle to the USB Host task.
Referenced by usb_host_task_init(), and usb_task().
|
static |
Handle to the USB task semaphore.