Microchip® Advanced Software Framework

ui.c File Reference

User Interface.

Copyright (c) 2014-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...
 
static void UI_WAKEUP_HANDLER (void)
 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 has automatically switched. This is only possible when the ID pin is available. More...
 

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_data_transfer = false
 
void ui_usb_vbus_change (bool b_vbus_present)
 Notify that a new Vbus transition has been detected. 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 woken up the USB line. More...
 
void ui_usb_sof_event (void)
 Notify that a SOF has been sent (each 1 ms) More...
 
void ui_com_rx_start (void)
 Called when a data is received on CDC. More...
 
void ui_com_rx_stop (void)
 Called when all pending data are sent on com port. More...
 
void ui_com_tx_start (void)
 Called when a data is received on com port. More...
 
void ui_com_tx_stop (void)
 Called when all pending data are sent on CDC. More...
 
void ui_com_error (void)
 Called when a communication error occur. More...
 
void ui_com_overflow (void)
 Called when an overflow occur. More...
 

void ui_com_error ( void  )

Called when a communication error occur.

void ui_com_overflow ( void  )

Called when an overflow occur.

Referenced by usart_rx_callback().

void ui_com_rx_start ( void  )

Called when a data is received on CDC.

References LED_0_PIN, LED_On, and ui_data_transfer.

Referenced by uart_rx_notify(), and usart_tx_callback().

void ui_com_rx_stop ( void  )

Called when all pending data are sent on com port.

References ui_data_transfer.

Referenced by usart_tx_callback().

void ui_com_tx_start ( void  )

Called when a data is received on com port.

References LED_0_PIN, LED_On, and ui_data_transfer.

Referenced by usart_rx_callback().

void ui_com_tx_stop ( void  )

Called when all pending data are sent on CDC.

References ui_data_transfer.

Referenced by usart_rx_callback().

static void ui_disable_asynchronous_interrupt ( void  )
static
void ui_init ( void  )

Initializes the user interface.

References LED_0_PIN, and LED_Off.

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 LED_0_PIN, LED_On, ui_enum_status, and UNUSED.

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 CDC_PAR_NONE, CDC_STOP_BITS_1, CPU_TO_LE32, usb_cdc_line_coding_t::dwDTERate, uart_config(), uart_open(), UHD_SPEED_FULL, UHD_SPEED_HIGH, UHD_SPEED_LOW, uhi_cdc_open(), ui_device_speed_blink, and ui_enum_status.

void ui_usb_mode_change ( bool  b_host_mode)

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

Parameters
b_host_modetrue, if the host mode has been selected

References LED_0_PIN, LED_Off, and LED_On.

void ui_usb_vbus_change ( bool  b_vbus_present)

Notify that a new Vbus transition has been detected. 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 woken up the USB line.

References ui_disable_asynchronous_interrupt().

static void UI_WAKEUP_HANDLER ( void  )
static

Interrupt handler for interrupt pin change.

References uhc_is_suspend(), uhc_resume(), and ui_disable_asynchronous_interrupt().

Referenced by ui_enable_asynchronous_interrupt().

bool ui_data_transfer = false
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().