SAM toolkit demo application.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "conf_board.h"
#include "demo.h"
#include <asf.h>
#include "bitmaps.h"
#include "task.h"
#include "string.h"
#include "rtouch_calibrate.h"
#include "demo_board.h"
Macros | |
#define | NB_INTERVALS 5 |
#define | SCR_PPT_SLIDE_BASENAME "Slide" |
#define | SCR_PPT_SLIDE_DELAY_MAX 20 |
#define | SCR_PPT_SLIDE_DELAY_MIN 1 |
PPT player parameters. More... | |
#define | SCR_PPT_SLIDE_EXT ".bmp" |
#define | SCR_PPT_SLIDE_FOLDER "24bpp/" |
#define | SCR_PPT_SLIDE_MAX 2 |
#define | SCR_PPT_SLIDE_PATH "/demo/slideshow/" |
#define | TASK_USB_STACK_PRIORITY (configMAX_PRIORITIES - 2) |
#define | TASK_USB_STACK_SIZE (3072 / sizeof(portSTACK_TYPE)) |
USB task stack size. More... | |
#define | TASK_WIN_STACK_PRIORITY (configMAX_PRIORITIES - 2) |
#define | TASK_WIN_STACK_SIZE (8192 / sizeof(portSTACK_TYPE)) |
Window stack size. More... | |
#define | TOTAL_SLIDER_NUM 2 |
Total slider number supported. More... | |
Functions | |
void | ADC_Handler (void) |
Handler for ADC interrupt. More... | |
static void | configure_console (void) |
Configure the console UART. More... | |
static void | demo_config_adc (void) |
Initialize ADC. More... | |
static void | demo_configure_tc0 (void) |
Configure Timer Counter 0 (TC0) to generate an interrupt every second. More... | |
uint8_t | demo_get_special_mode_status (demo_special_mode_id id) |
Get if the specific window is active. More... | |
void | demo_set_special_mode_status (demo_special_mode_id id, uint8_t status) |
Set special mode status. More... | |
static void | demo_start_adc (bool on) |
Turn on/off ADC module. More... | |
static void | event_handler (rtouch_event_t const *event) |
int | main (void) |
Main function. More... | |
void | main_msc_disable (void) |
USB mass storage disable. More... | |
bool | main_msc_enable (void) |
USB mass storage enable. More... | |
void | main_msc_notify_trans (void) |
Notify USB transfer. More... | |
static void | main_vbus_action (bool b_high) |
USB VBUS actions. More... | |
static void | setup_gui_root_window (void) |
Configure the root GUI window. More... | |
void | SysTick_Handler (void) |
Handler for Sytem Tick interrupt. More... | |
static void | task_usb (void *pvParameters) |
Process USB tasks. More... | |
static void | task_win (void *pvParameters) |
This task, when activated, send every ten seconds on debug UART the whole report of free heap and total tasks status. More... | |
void | vApplicationIdleHook (void) |
This function is called by FreeRTOS idle task. More... | |
void | vApplicationStackOverflowHook (xTaskHandle *pxTask, signed char *pcTaskName) |
Called if stack overflow during execution. More... | |
void | vApplicationTickHook (void) |
This function is called by FreeRTOS each tick. More... | |
void | xPortSysTickHandler (void) |
Variables | |
uint8_t | adc_buf_ndx |
uint32_t | adc_nb_samples |
uint16_t | current_time_ms_touch |
Current time, set by timer ISR. More... | |
static volatile uint8_t | demo_adc_on = 0 |
ADC on/off flag. More... | |
static char | demo_cur_date [20] |
Demo current date. More... | |
static char | demo_cur_time [20] |
Demo current time. More... | |
static struct gfx_bitmap | demo_ppt |
Demo bitmap used for PPT player. More... | |
static uint8_t | demo_spcial_mode [DEMO_SPEC_MODE_MAX] |
Demo spcial mode; during these special mode, the GUI is not handled by widget. More... | |
uint32_t | fft_delay = 0 |
FFT delay counter. More... | |
bool | fft_update = true |
FFT update flag. More... | |
uint16_t | frame_buffer [AUDIO_NB_BUFFER][AUDIO_FRAME_SIZE] |
static volatile uint32_t | g_ul_tick_count = 0 |
Tick Counter united by ms. More... | |
static xSemaphoreHandle | main_trans_semphr = NULL |
static volatile uint32_t | pontentiometer_value |
static volatile uint32_t | ppt_delay_clapse_counter = 0 |
PPT player clapse delay counter. More... | |
static uint32_t | ppt_silder_index |
Slide index of PPT player. More... | |
static char | ppt_slide_path [128] |
Slide path. More... | |
uint16_t | qt_measurement_period_msec |
Timer period in msec. More... | |
uint8_t | time_to_measure_touch |
Flag set by timer ISR when it's time to measure touch. More... | |
static uint8_t | touch_event_on_ppt = 0 |
The ppt player is existed by touch event. More... | |
static struct gfx_bitmap | win_root_background |
Demo background bitmap. More... | |
static struct gfx_bitmap | win_startup_bmp |
Demo startup bitmap. More... | |
#define NB_INTERVALS 5 |
Referenced by ADC_Handler(), and demo_start_adc().
#define SCR_PPT_SLIDE_BASENAME "Slide" |
Referenced by task_win().
#define SCR_PPT_SLIDE_DELAY_MAX 20 |
#define SCR_PPT_SLIDE_DELAY_MIN 1 |
PPT player parameters.
#define SCR_PPT_SLIDE_EXT ".bmp" |
Referenced by task_win().
#define SCR_PPT_SLIDE_FOLDER "24bpp/" |
Referenced by task_win().
#define SCR_PPT_SLIDE_MAX 2 |
Referenced by task_win().
#define SCR_PPT_SLIDE_PATH "/demo/slideshow/" |
Referenced by task_win().
#define TASK_USB_STACK_PRIORITY (configMAX_PRIORITIES - 2) |
Referenced by main().
#define TASK_USB_STACK_SIZE (3072 / sizeof(portSTACK_TYPE)) |
USB task stack size.
Referenced by main().
#define TASK_WIN_STACK_PRIORITY (configMAX_PRIORITIES - 2) |
Referenced by main().
#define TASK_WIN_STACK_SIZE (8192 / sizeof(portSTACK_TYPE)) |
Window stack size.
Referenced by main().
#define TOTAL_SLIDER_NUM 2 |
Total slider number supported.
void ADC_Handler | ( | void | ) |
Handler for ADC interrupt.
References adc_buf_ndx, ADC_CHANNEL_POTENTIOMETER, adc_enable_interrupt(), adc_get_channel_value(), adc_get_status(), adc_nb_samples, adc_set_comparison_window(), AUDIO_FRAME_SIZE, AUDIO_NB_BUFFER, frame_buffer, NB_INTERVALS, pontentiometer_value, and ppt_delay_clapse_counter.
|
static |
Configure the console UART.
References uart_rs232_options::baudrate, CONF_UART, CONF_UART_BAUDRATE, CONF_UART_PARITY, CONSOLE_UART_ID, stdio_serial_init(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
static |
Initialize ADC.
References ADC_CHANNEL_POTENTIOMETER, adc_check(), adc_configure_timing(), adc_configure_trigger(), adc_enable_channel(), adc_init(), ADC_SETTLING_TIME_3, ADC_STARTUP_TIME_4, ADC_TRIG_TIO_CH_1, demo_configure_tc0(), pmc_enable_periph_clk(), and sysclk_get_cpu_hz().
Referenced by demo_start_adc().
|
static |
Configure Timer Counter 0 (TC0) to generate an interrupt every second.
References pmc_enable_periph_clk(), tc_init(), tc_write_ra(), and tc_write_rc().
Referenced by demo_config_adc().
uint8_t demo_get_special_mode_status | ( | demo_special_mode_id | id | ) |
Get if the specific window is active.
id | Special mode ID. |
References demo_spcial_mode.
Referenced by app_widget_fft_on(), demo_qtouch_event_handler(), event_handler(), and task_win().
void demo_set_special_mode_status | ( | demo_special_mode_id | id, |
uint8_t | status | ||
) |
Set special mode status.
id | Special mode ID. |
status | special mode status. |
References demo_spcial_mode.
Referenced by app_widget_launch_lpm_sleep(), app_widget_launch_lpm_wait(), app_widget_launch_main(), app_widget_launch_qtouch(), app_widget_main_on(), event_handler(), main(), task_win(), widget_frame_command_handler(), widget_qtouch_command_handler(), and widget_settings_frame_command_handler().
|
static |
Turn on/off ADC module.
on | True to start ADC, false to turn off. |
References ADC_CHANNEL_POTENTIOMETER, adc_disable_interrupt(), adc_enable_interrupt(), adc_get_channel_value(), adc_set_comparison_channel(), adc_set_comparison_mode(), adc_set_comparison_window(), demo_adc_on, demo_config_adc(), NB_INTERVALS, pontentiometer_value, ppt_delay_clapse_counter, tc_start(), and tc_stop().
Referenced by event_handler(), and task_win().
|
static |
References win_pointer_event::buttons, DEMO_FFT_MODE, demo_get_special_mode_status(), DEMO_PPT_MODE, demo_set_special_mode_status(), demo_start_adc(), win_pointer_event::is_relative, rtouch_event_struct::panel, win_pointer_event::pos, RTOUCH_MOVE, RTOUCH_PRESS, RTOUCH_RELEASE, touch_event_on_ppt, rtouch_event_struct::type, win_pointer_event::type, WIN_POINTER_MOVE, WIN_POINTER_PRESS, WIN_POINTER_RELEASE, win_queue_pointer_event(), WIN_TOUCH_BUTTON, rtouch_point_struct::x, win_point::x, and win_point::y.
Referenced by main().
int main | ( | void | ) |
Main function.
Execution starts here.
References aat31xx_set_backlight(), app_widget_main_on(), demo_param_t::backlight, BOARD_NAME, demo_param_t::calib_points, configure_console(), demo_param_t::day, demo_draw_bmpfile_init(), DEMO_LCD_CALIBRATE_MODE, demo_parameters_initialize(), demo_qt_init(), demo_set_special_mode_status(), event_handler(), g_demo_parameters, gfx_draw_bitmap(), gfx_init, demo_param_t::hour, init_specific_board(), LCD_HEIGHT, LCD_WIDTH, main_vbus_action(), membag_init(), demo_param_t::minute, demo_param_t::month, pdPASS, rtouch_calibration_point_struct::raw, rtc_set_date(), rtc_set_hour_mode(), rtc_set_time(), rtouch_calibrate(), rtouch_compute_calibration(), rtouch_enable(), rtouch_init(), rtouch_set_event_handler(), demo_param_t::second, setup_gui_root_window(), sleepmgr_init(), sysclk_get_cpu_hz(), sysclk_init(), task_usb(), TASK_USB_STACK_PRIORITY, TASK_USB_STACK_SIZE, task_win(), TASK_WIN_STACK_PRIORITY, TASK_WIN_STACK_SIZE, udc_include_vbus_monitoring(), udc_start(), vSemaphoreCreateBinary, vTaskStartScheduler(), win_init(), rtouch_point_struct::x, xTaskCreate, and demo_param_t::year.
void main_msc_disable | ( | void | ) |
USB mass storage disable.
bool main_msc_enable | ( | void | ) |
USB mass storage enable.
void main_msc_notify_trans | ( | void | ) |
Notify USB transfer.
References pdFALSE, and xSemaphoreGiveFromISR.
|
static |
|
static |
Configure the root GUI window.
Configures the root window background to blank white.
References win_attributes::background, WIN_ATTR_BACKGROUND, win_get_attributes(), win_get_root(), win_root, win_root_background, win_set_attributes(), and win_show().
Referenced by main().
void SysTick_Handler | ( | void | ) |
Handler for Sytem Tick interrupt.
References current_time_ms_touch, fft_delay, fft_update, g_ul_tick_count, qt_measurement_period_msec, rtouch_process(), SYSTICK_FREQ, time_to_measure_touch, and xPortSysTickHandler().
|
static |
Process USB tasks.
References pdTRUE, udi_msc_process_trans(), UNUSED, and xSemaphoreTake.
Referenced by main().
|
static |
This task, when activated, send every ten seconds on debug UART the whole report of free heap and total tasks status.
References app_widget_lpm_on(), app_widget_main_on(), app_widget_settings_on(), COLOR_BLUE, COLOR_WHITE, gfx_bitmap::custom, gfx_bitmap::data, demo_cur_date, demo_cur_time, demo_get_special_mode_status(), DEMO_LCD_CALIBRATE_MODE, DEMO_MAIN_MODE, DEMO_PPT_MODE, demo_qtouch_event_handler(), demo_set_special_mode_status(), DEMO_SLEEP_MODE, demo_start_adc(), DEMO_WAIT_MODE, GFX_COLOR_TRANSPARENT, gfx_draw_bitmap(), gfx_draw_string(), pontentiometer_value, ppt_delay_clapse_counter, ppt_silder_index, ppt_slide_path, rtc_get_date(), rtc_get_time(), rtouch_calibrate(), SCR_PPT_SLIDE_BASENAME, SCR_PPT_SLIDE_EXT, SCR_PPT_SLIDE_FOLDER, SCR_PPT_SLIDE_MAX, SCR_PPT_SLIDE_PATH, sysfont, touch_event_on_ppt, UNUSED, vTaskDelay(), and win_process_events().
Referenced by main().
void vApplicationIdleHook | ( | void | ) |
This function is called by FreeRTOS idle task.
Referenced by portTASK_FUNCTION().
void vApplicationStackOverflowHook | ( | xTaskHandle * | pxTask, |
signed char * | pcTaskName | ||
) |
Called if stack overflow during execution.
void vApplicationTickHook | ( | void | ) |
This function is called by FreeRTOS each tick.
Referenced by vTaskIncrementTick().
void xPortSysTickHandler | ( | void | ) |
Referenced by SysTick_Handler().
uint8_t adc_buf_ndx |
Referenced by ADC_Handler(), and app_widget_fft_on().
uint32_t adc_nb_samples |
Referenced by ADC_Handler(), and app_widget_fft_on().
uint16_t current_time_ms_touch |
Current time, set by timer ISR.
Referenced by demo_qtouch_event_handler(), and SysTick_Handler().
|
static |
ADC on/off flag.
Referenced by demo_start_adc().
|
static |
Demo current date.
Referenced by task_win().
|
static |
Demo current time.
Referenced by task_win().
|
static |
Demo bitmap used for PPT player.
|
static |
Demo spcial mode; during these special mode, the GUI is not handled by widget.
Referenced by demo_get_special_mode_status(), and demo_set_special_mode_status().
uint32_t fft_delay = 0 |
FFT delay counter.
Referenced by app_widget_fft_on(), and SysTick_Handler().
FFT update flag.
Referenced by SysTick_Handler().
uint16_t frame_buffer[AUDIO_NB_BUFFER][AUDIO_FRAME_SIZE] |
Referenced by ADC_Handler(), and adc_input_init().
|
static |
Tick Counter united by ms.
Referenced by SysTick_Handler().
|
static |
|
static |
Referenced by ADC_Handler(), demo_start_adc(), and task_win().
|
static |
PPT player clapse delay counter.
Referenced by ADC_Handler(), demo_start_adc(), and task_win().
|
static |
Slide index of PPT player.
Referenced by task_win().
|
static |
Slide path.
Referenced by task_win().
uint16_t qt_measurement_period_msec |
Timer period in msec.
Referenced by Set_Global_Config(), SysTick_Handler(), and Transmit_Global_Config().
uint8_t time_to_measure_touch |
Flag set by timer ISR when it's time to measure touch.
Referenced by demo_qtouch_event_handler(), and SysTick_Handler().
|
static |
The ppt player is existed by touch event.
Referenced by event_handler(), and task_win().
|
static |
Demo background bitmap.
Referenced by setup_gui_root_window().
|
static |
Demo startup bitmap.