Microchip® Advanced Software Framework

demo.c File Reference

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 ADC_CHANNEL_POTENTIOMETER   ADC_CHANNEL_5
 
#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 ADC_CHANNEL_POTENTIOMETER   ADC_CHANNEL_5
#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.

static void configure_console ( void  )
static
static void demo_config_adc ( void  )
static
static void demo_configure_tc0 ( void  )
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.

Parameters
idSpecial mode ID.
Returns
Special mode status.

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 
)
static void demo_start_adc ( bool  on)
static
void main_msc_disable ( void  )

USB mass storage disable.

Called by MSC interface Callback running when USB Host disable MSC interface.

bool main_msc_enable ( void  )

USB mass storage enable.

Called by MSC interface Callback running when USB Host enable MSC interface.

void main_msc_notify_trans ( void  )

Notify USB transfer.

Called when a data transfer on MSC must be executed Thus, the udi_msc_process_trans() function must be called.

References pdFALSE, and xSemaphoreGiveFromISR.

static void main_vbus_action ( bool  b_high)
static

USB VBUS actions.

References udc_attach(), and udc_detach().

static void setup_gui_root_window ( void  )
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  )
static void task_usb ( void *  pvParameters)
static

Process USB tasks.

References pdTRUE, udi_msc_process_trans(), UNUSED, and xSemaphoreTake.

Referenced by main().

void vApplicationIdleHook ( void  )

This function is called by FreeRTOS idle task.

void vApplicationStackOverflowHook ( xTaskHandle pxTask,
signed char *  pcTaskName 
)

Called if stack overflow during execution.

void vApplicationTickHook ( void  )

This function is called by FreeRTOS each tick.

This function will be called by each tick interrupt if configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h. User code can be added here, but the tick hook is called from an interrupt context, so code must not attempt to block, and only the interrupt safe FreeRTOS API functions can be used (those that end in FromISR()).

void xPortSysTickHandler ( void  )

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.

volatile uint8_t demo_adc_on = 0
static

ADC on/off flag.

Referenced by demo_start_adc().

char demo_cur_date[20]
static

Demo current date.

Referenced by task_win().

char demo_cur_time[20]
static

Demo current time.

Referenced by task_win().

struct gfx_bitmap demo_ppt
static
Initial value:
= {
.width = 240, .height = 320,
.type = GFX_BITMAP_EXT,
}
Definition: gfx_generic.h:68

Demo bitmap used for PPT player.

uint8_t demo_spcial_mode[DEMO_SPEC_MODE_MAX]
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().

bool fft_update = true

FFT update flag.

Referenced by SysTick_Handler().

volatile uint32_t g_ul_tick_count = 0
static

Tick Counter united by ms.

Referenced by SysTick_Handler().

xSemaphoreHandle main_trans_semphr = NULL
static
volatile uint32_t pontentiometer_value
static
volatile uint32_t ppt_delay_clapse_counter = 0
static

PPT player clapse delay counter.

Referenced by ADC_Handler(), demo_start_adc(), and task_win().

uint32_t ppt_silder_index
static

Slide index of PPT player.

Referenced by task_win().

char ppt_slide_path[128]
static

Slide path.

Referenced by task_win().

uint8_t time_to_measure_touch

Flag set by timer ISR when it's time to measure touch.

uint8_t touch_event_on_ppt = 0
static

The ppt player is existed by touch event.

Referenced by event_handler(), and task_win().

struct gfx_bitmap win_root_background
static
Initial value:
= {
.data.color = GFX_COLOR(255, 255, 255),
}
#define GFX_COLOR(r, g, b)
It is not possible to define a color that is outside the color spectrum for the ILI9488 driver...
Definition: gfx_ili9488_90_00028_a0.h:67
Definition: gfx_generic.h:62

Demo background bitmap.

Referenced by setup_gui_root_window().

struct gfx_bitmap win_startup_bmp
static
Initial value:
= {
.width = 240, .height = 240,
.type = GFX_BITMAP_EXT,
.data.custom = DEMO_BMP_INTRO_SAM4S
}
Definition: gfx_generic.h:68
#define DEMO_BMP_INTRO_SAM4S
Definition: bitmaps.h:46

Demo startup bitmap.