/** * \brief Main application function * * This function calls all the necessary initialization functions before * launching the calculator widget and entering the main work loop. * * The main work loop is responsible for handling the low level user input, so * it reads touch data from the mXT143E Xplained, translates and passes it on to * the window system's event queue. * * All the processing for the calculator is done by the calculator widget's * event handler function \ref app_calc_handler(). This function is called by * the window system when it maps a user input event to an interaction with the * calculator, i.e., a button press. */ int main(void) { static struct mxt_device device; board_init(); sysclk_init(); membag_init(); gfx_init(); mxt_init(&device); win_init(); setup_gui_root_window(); win_reset_root_geometry(); if (app_widget_launch() == false) { show_out_of_memory_error(); for (;;); } while (true) { struct win_pointer_event win_touch_event; /* Queue touch events from the touchscreen if any are available */ while (read_touch_event(&device, &win_touch_event)) { win_queue_pointer_event(&win_touch_event); } /* Process queued events in the windowing system */ win_process_events(); } }
/** \brief Main function. Execution starts here. */ int main(void) { uint8_t uc_result; /* Initialize the sleep manager */ sleepmgr_init(); membag_init(); sysclk_init(); init_specific_board(); /* Initialize the console uart */ configure_console(); /* Output demo infomation. */ printf("-- SAM Toolkit Demo Example --\n\r"); printf("-- %s\n\r", BOARD_NAME); printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__); /* Configure systick for 1 ms. */ puts("Configure system tick to get 1ms tick period.\r"); if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) { puts("Systick configuration error\r"); while (1) { } } /* Initialize gfx module */ gfx_init(); win_init(); /* Initialize FatFS and bitmap draw interface */ demo_draw_bmpfile_init(); /* Initialize touchscreen without calibration */ rtouch_init(LCD_WIDTH, LCD_HEIGHT); rtouch_enable(); rtouch_set_event_handler(event_handler); /* Initialize demo parameters */ demo_parameters_initialize(); while (g_demo_parameters.calib_points[0].raw.x == 0) { uc_result = rtouch_calibrate(); if (uc_result == 0) { demo_set_special_mode_status(DEMO_LCD_CALIBRATE_MODE, 0); puts("Calibration successful !\r"); break; } else { puts("Calibration failed; error delta is too big ! Please retry calibration procedure...\r"); } } /* Re-caculate the calibration data */ rtouch_compute_calibration( (rtouch_calibration_point_t *)&g_demo_parameters.calib_points[0]); /* Setup root window */ setup_gui_root_window(); gfx_draw_bitmap(&win_startup_bmp, 0, 40); /* Set backlight by the data read from demo parameters */ aat31xx_set_backlight(g_demo_parameters.backlight); /* Default RTC configuration, 24-hour mode */ rtc_set_hour_mode(RTC, 0); rtc_set_time(RTC, g_demo_parameters.hour, g_demo_parameters.minute, g_demo_parameters.second); rtc_set_date( RTC, g_demo_parameters.year, g_demo_parameters.month, g_demo_parameters.day, 1 ); /* Create a semaphore to manage the memories data transfer */ vSemaphoreCreateBinary(main_trans_semphr); /* Turn on main widget */ app_widget_main_on(true); /* Initialize QTouch */ demo_qt_init(); /* Start USB stack to authorize VBus monitoring */ udc_start(); if (!udc_include_vbus_monitoring()) { /* VBUS monitoring is not available on this product * thereby VBUS has to be considered as present */ main_vbus_action(true); } /* Create task to window task */ if (xTaskCreate(task_win, "WIN", TASK_WIN_STACK_SIZE, NULL, TASK_WIN_STACK_PRIORITY, NULL) != pdPASS) { printf("Failed to create test led task\r\n"); } /* Create task to usb mass storage task */ if (xTaskCreate(task_usb, "USB", TASK_USB_STACK_SIZE, NULL, TASK_USB_STACK_PRIORITY, NULL) != pdPASS) { printf("Failed to create test led task\r\n"); } /* Start the scheduler. */ vTaskStartScheduler(); /* Will only get here if there was insufficient memory to create the * idle task. */ return 0; }