Microchip® Advanced Software Framework

ui.c File Reference

User Interface.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>

Macros

#define RESUME_PIN   (GPIO_PUSH_BUTTON_2)
 
#define RESUME_PIO   (PIN_PUSHBUTTON_2_PIO)
 
#define RESUME_PIO_ATTR   (PIN_PUSHBUTTON_2_ATTR)
 
#define RESUME_PIO_ID   (PIN_PUSHBUTTON_2_ID)
 
#define RESUME_PIO_MASK   (PIN_PUSHBUTTON_2_MASK)
 
#define RESUME_PMC_FSTT   (PMC_FSMR_FSTT14)
 

Functions

Internal routines to manage asynchronous interrupt pin change

This interrupt is connected to a switch and allows to wakeup CPU in low sleep mode.

This wakeup the USB devices connected via a downstream resume.

static void ui_enable_asynchronous_interrupt (void)
 Initializes and enables interrupt pin change. More...
 
static void ui_disable_asynchronous_interrupt (void)
 Disables interrupt pin change. More...
 
static void ui_wakeup_handler (uint32_t id, uint32_t mask)
 
Main user interface functions
void ui_init (void)
 Initializes the user interface. More...
 
void ui_usb_mode_change (bool b_host_mode)
 Notify that the USB mode are switched automatically. This is possible only when ID pin is available. More...
 
Callback to show the MSC read and write access
void ui_start_read (void)
 
void ui_stop_read (void)
 
void ui_start_write (void)
 
void ui_stop_write (void)
 

Host mode user interface functions

static uhc_enum_status_t ui_enum_status = UHC_ENUM_DISCONNECT
 
static uint16_t ui_device_speed_blink
 
static bool ui_test_done
 
static bool ui_test_result
 
void ui_usb_vbus_change (bool b_vbus_present)
 Notify that a Vbus are changed Available only in USB hardware with Vbus monitoring. More...
 
void ui_usb_vbus_error (void)
 Notify that a Vbus error has occurred Available only in USB hardware with Vbus monitoring. More...
 
void ui_usb_connection_event (uhc_device_t *dev, bool b_present)
 Notify that a USB device has been connected or disconnected. More...
 
void ui_usb_enum_event (uhc_device_t *dev, uhc_enum_status_t status)
 Notify the end of a USB device enumeration. More...
 
void ui_usb_wakeup_event (void)
 Notify that a USB device or the host has wake up the USB line. More...
 
void ui_usb_sof_event (void)
 Notify that a SOF has been sent (each 1 ms) More...
 
void ui_test_flag_reset (void)
 Resets the status flag of the test. More...
 
void ui_test_finish (bool b_success)
 Displays the result of the test. More...
 

#define RESUME_PIN   (GPIO_PUSH_BUTTON_2)

Referenced by ui_init().

#define RESUME_PIO   (PIN_PUSHBUTTON_2_PIO)

Referenced by ui_init().

#define RESUME_PIO_ATTR   (PIN_PUSHBUTTON_2_ATTR)

Referenced by ui_init().

#define RESUME_PIO_ID   (PIN_PUSHBUTTON_2_ID)

Referenced by ui_init(), and ui_wakeup_handler().

#define RESUME_PIO_MASK   (PIN_PUSHBUTTON_2_MASK)

Referenced by ui_init(), and ui_wakeup_handler().

#define RESUME_PMC_FSTT   (PMC_FSMR_FSTT14)

Referenced by ui_init().

static void ui_disable_asynchronous_interrupt ( void  )
static
static void ui_enable_asynchronous_interrupt ( void  )
static

Initializes and enables interrupt pin change.

References GPIO_PUSH_BUTTON_2, pio_enable_pin_interrupt(), pio_get_interrupt_status(), and pmc_set_fast_startup_input().

Referenced by ui_usb_sof_event().

void ui_start_read ( void  )

References LED2_GPIO, and LED_On().

void ui_start_write ( void  )

References LED2_GPIO, and LED_On().

void ui_stop_read ( void  )

References LED2_GPIO, and LED_Off().

void ui_stop_write ( void  )

References LED2_GPIO, and LED_Off().

void ui_test_finish ( bool  b_success)

Displays the result of the test.

Parameters
b_successtrue, if the test is successfull

References LED0_GPIO, LED_On(), ui_test_done, and ui_test_result.

Referenced by main().

void ui_test_flag_reset ( void  )

Resets the status flag of the test.

References LED0_GPIO, LED_Off(), and ui_test_done.

Referenced by main().

void ui_usb_connection_event ( uhc_device_t dev,
bool  b_present 
)

Notify that a USB device has been connected or disconnected.

Parameters
devPointer on USB device information
b_presenttrue, if the device has been connected

References LED0_GPIO, LED1_GPIO, LED_Off(), LED_On(), UHC_ENUM_DISCONNECT, ui_enum_status, and UNUSED.

Referenced by main_usb_connection_event().

void ui_usb_enum_event ( uhc_device_t dev,
uhc_enum_status_t  status 
)

Notify the end of a USB device enumeration.

Parameters
devPointer on USB device information
statusStatus of the USB enumeration

References uhc_device_t::speed, UHD_SPEED_FULL, UHD_SPEED_HIGH, UHD_SPEED_LOW, ui_device_speed_blink, ui_enum_status, ui_test_done, and UNUSED.

void ui_usb_mode_change ( bool  b_host_mode)

Notify that the USB mode are switched automatically. This is possible only when ID pin is available.

Parameters
b_host_modetrue, if the host mode has been selected

References ui_init(), and UNUSED.

void ui_usb_vbus_change ( bool  b_vbus_present)

Notify that a Vbus are changed Available only in USB hardware with Vbus monitoring.

Parameters
b_vbus_presenttrue, if Vbus is high.

References LED3_GPIO, LED_Off(), and LED_On().

void ui_usb_vbus_error ( void  )

Notify that a Vbus error has occurred Available only in USB hardware with Vbus monitoring.

void ui_usb_wakeup_event ( void  )

Notify that a USB device or the host has wake up the USB line.

References ui_disable_asynchronous_interrupt().

static void ui_wakeup_handler ( uint32_t  id,
uint32_t  mask 
)
static

uint16_t ui_device_speed_blink
static

Blink frequency depending on device speed

Referenced by ui_usb_enum_event(), and ui_usb_sof_event().

uhc_enum_status_t ui_enum_status = UHC_ENUM_DISCONNECT
static

Status of device enumeration

Referenced by ui_usb_connection_event(), ui_usb_enum_event(), and ui_usb_sof_event().

bool ui_test_done
static

Status of the MSC test

Referenced by ui_test_finish(), ui_test_flag_reset(), ui_usb_enum_event(), and ui_usb_sof_event().

bool ui_test_result
static

Result of the MSC test

Referenced by ui_test_finish(), and ui_usb_sof_event().