Microchip® Advanced Software Framework

ui.c File Reference

User Interface.

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

#include <asf.h>
#include "ui.h"

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...
 
 ISR (ui_wakeup_isr, AVR32_GPIO_IRQ_GROUP, 0)
 Interrupt handler for interrupt pin change. More...
 
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
 Status of device enumeration. More...
 
static uint16_t ui_device_speed_blink
 Blink frequency depending on device speed. More...
 
static bool ui_hid_mouse_plug = false
 Notify the presence of a USB device mouse. More...
 
static int8_t ui_x
 Manages device mouse moving. More...
 
static int8_t ui_y
 
static int8_t ui_scroll
 
static bool ui_msc_plug = false
 Notify the presence of a USB device MSC. More...
 
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_uhi_hid_mouse_change (uhc_device_t *dev, bool b_plug)
 Notify that a USB device HID has been connected or disconnected. More...
 
void ui_uhi_msc_change (uhc_device_t *dev, bool b_plug)
 Notify that a USB device MSC has been connected or disconnected. 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...
 
static void ui_uhi_hid_mouse_btn (bool b_state)
 
void ui_uhi_hid_mouse_btn_left (bool b_state)
 
void ui_uhi_hid_mouse_btn_right (bool b_state)
 
void ui_uhi_hid_mouse_btn_middle (bool b_state)
 
void ui_uhi_hid_mouse_move (int8_t x, int8_t y, int8_t scroll)
 
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...
 

ISR ( ui_wakeup_isr  ,
AVR32_GPIO_IRQ_GROUP  ,
 
)
static void ui_disable_asynchronous_interrupt ( void  )
static

Disables interrupt pin change.

References eic_disable_line(), EXT_NMI, gpio_disable_pin_interrupt(), and GPIO_JOYSTICK_PUSH.

Referenced by ISR(), and ui_usb_wakeup_event().

static void ui_enable_asynchronous_interrupt ( void  )
static
void ui_init ( void  )

Initializes the user interface.

References LED0, LED1, LED2, LED3, LED_BI0_GREEN, LED_BI0_RED, LED_BI1_GREEN, LED_BI1_RED, and LED_Off().

Referenced by main(), and ui_usb_mode_change().

void ui_start_read ( void  )
void ui_start_write ( void  )
void ui_stop_read ( void  )
void ui_stop_write ( void  )
void ui_test_finish ( bool  b_success)

Displays the result of the test.

Parameters
b_successtrue, if the test is successful

References LED_BI1_GREEN, LED_BI1_RED, and LED_On().

Referenced by main().

void ui_test_flag_reset ( void  )

Resets the status flag of the test.

References LED_BI1_GREEN, LED_BI1_RED, and LED_Off().

Referenced by main().

static void ui_uhi_hid_mouse_btn ( bool  b_state)
static
void ui_uhi_hid_mouse_btn_left ( bool  b_state)
void ui_uhi_hid_mouse_btn_middle ( bool  b_state)
void ui_uhi_hid_mouse_btn_right ( bool  b_state)
void ui_uhi_hid_mouse_change ( uhc_device_t *  dev,
bool  b_plug 
)

Notify that a USB device HID has been connected or disconnected.

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

References ui_hid_mouse_plug.

void ui_uhi_hid_mouse_move ( int8_t  x,
int8_t  y,
int8_t  scroll 
)

References ui_scroll, ui_x, and ui_y.

void ui_uhi_msc_change ( uhc_device_t *  dev,
bool  b_plug 
)

Notify that a USB device MSC has been connected or disconnected.

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

References ui_msc_plug.

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 LED1, LED2, LED3, LED_BI0_GREEN, LED_BI0_RED, LED_BI1_GREEN, LED_BI1_RED, LED_Off(), LED_On(), and ui_enum_status.

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 UHD_SPEED_FULL, UHD_SPEED_HIGH, UHD_SPEED_LOW, ui_device_speed_blink, ui_enum_status, ui_scroll, ui_x, and ui_y.

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 LED0, LED_On(), and ui_init().

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

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().

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_hid_mouse_plug = false
static

Notify the presence of a USB device mouse.

Referenced by ui_uhi_hid_mouse_change(), and ui_usb_sof_event().

bool ui_msc_plug = false
static

Notify the presence of a USB device MSC.

Referenced by ui_uhi_msc_change(), and ui_usb_sof_event().

int8_t ui_scroll
static
int8_t ui_x
static

Manages device mouse moving.

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

int8_t ui_y
static