Example #1
0
/**
 * \brief Initialize the chip for low power test.
 */
static void init_chip(void)
{
	/* Wait for the transmission done before changing clock */
	while (!uart_is_tx_empty(CONSOLE_UART)) {
	}

	/* Disable all the peripheral clocks */
	pmc_disable_all_periph_clk();

	/* Disable brownout detector */
	supc_disable_brownout_detector(SUPC);

	/* Initialize the specific board */
	init_specific_board();
}
Example #2
0
/** \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;
}