Microchip® Advanced Software Framework

example_hid.c File Reference

Trackpad demo for mXT143E Xplained.

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

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

Functions

int main (void)
 Main application function. More...
 
static void mxt_init (struct mxt_device *device)
 Set maXTouch configuration. More...
 
Callback functions for the USB stack
void main_suspend_action (void)
 Handle suspend of bus. More...
 
void main_resume_action (void)
 Handle resume of bus. More...
 
void main_sof_action (void)
 Handle start of frame. More...
 
void main_remotewakeup_enable (void)
 Handle enabling of remote wake-up. More...
 
void main_remotewakeup_disable (void)
 Handle disabling of remote wake-up. More...
 
bool main_mouse_enable (void)
 Handle HID interface enable. More...
 
void main_mouse_disable (void)
 Handle HID interface disable. More...
 

Variables

static bool main_b_mouse_enable = false
 Flag to indicate if HID is currently enabled. More...
 

int main ( void  )

Main application function.

This function ensures that the hardware and drivers are initialized before entering an infinite work loop.

In the work loop, the maXTouch device is polled for new touch events and any new event is passed on to the user interface implementation for processing. The loop then attempts to enter sleep.

The user interface processing itself is not started by the work loop, but by the USB callback function for start of frame.

References board_init(), COLOR_BACKGROUND, cpu_irq_enable, GFX_COLOR_TRANSPARENT, GFX_COLOR_WHITE, gfx_draw_filled_rect, gfx_draw_string_aligned(), gfx_get_height(), gfx_get_width(), gfx_init, irq_initialize_vectors, main_b_mouse_enable, mxt_init(), mxt_is_message_pending(), mxt_read_touch_event(), sleepmgr_enter_sleep(), sleepmgr_init(), STATUS_OK, sysclk_init(), sysfont, TEXT_ALIGN_CENTER, TEXT_POS_CENTER, udc_start(), ui_flag_new_touch_event(), ui_init(), ui_powerdown(), ui_process(), and ui_touch_event.

void main_mouse_disable ( void  )

Handle HID interface disable.

Called by the USB stack when the host disables the mouse interface.

References main_b_mouse_enable.

bool main_mouse_enable ( void  )

Handle HID interface enable.

Called by the USB stack when the host enables the mouse interface.

Return values
trueSignal that mouse started up OK

References main_b_mouse_enable.

void main_remotewakeup_disable ( void  )

Handle disabling of remote wake-up.

This is called by the USB stack when the host requests remote wake-up to be disabled, and will request the user interface to disable wake-up.

References ui_wakeup_disable().

void main_remotewakeup_enable ( void  )

Handle enabling of remote wake-up.

This is called by the USB stack when the host requests remote wake-up to be enabled, and will request the user interface to enable wake-up.

References ui_wakeup_enable().

void main_resume_action ( void  )

Handle resume of bus.

Called by USB stack when the bus resumes from suspend.

References ui_wakeup().

void main_sof_action ( void  )

Handle start of frame.

Called by USB stack when a start of frame is received, i.e., every millisecond during normal operation. This function triggers processing of the user interface if the HID interface has been enabled.

References main_b_mouse_enable, udd_get_frame_number(), and ui_process().

void main_suspend_action ( void  )

Handle suspend of bus.

Called by USB stack when host suspends the bus.

References ui_powerdown().

bool main_b_mouse_enable = false
static

Flag to indicate if HID is currently enabled.

Referenced by main(), main_mouse_disable(), main_mouse_enable(), and main_sof_action().