Atmel Software Framework

example_hid.c File Reference

Trackpad demo for mXT143E Xplained.

Copyright (c) 2012-2015 Atmel Corporation. All rights reserved.

#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(), 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, 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 HID interface Callback running when USB Host disable mouse interface.

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 HID interface Callback running when USB Host enable mouse interface.

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.

Called by UDC when USB Host request to disable remote wakeup.

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.

Called by UDC when USB Host request to enable remote wakeup.

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.

Turn on a led to notify active mode Called when the USB line is resumed from the suspend state.

Called by UDD when the USB line exit of suspend state.

Called by USB stack when the bus resumes from suspend.

References ui_wakeup().

void main_sof_action ( void  )

Handle start of frame.

Manages the leds behaviors Called when a start of frame is received on USB line each 1ms.

Called when a start of frame is received on USB line.

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.

Enters the application in low power mode Callback called when USB host sets USB line in suspend state.

Called by USB stack when host suspends the bus.

References ui_powerdown().

static void mxt_init ( struct mxt_device device)
static

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