Esempio n. 1
0
/**
 * \brief Low power application entry point.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	/* Initialize the SAM system */
	sysclk_init();
	g_ul_current_mck = sysclk_get_cpu_hz();
	board_init();

	/* Initialize the console uart */
	configure_console();

	/* Output example information */
	puts(STRING_HEADER);

	/* Initialize the chip for the power consumption test */
	init_chip();

	/* Set default clock and re-configure UART */
	set_default_working_clock();
	reconfigure_console(g_ul_current_mck, CONF_UART_BAUDRATE);

	/* Test core consumption */
	test_core();

	while (1) {
	}
}
Esempio n. 2
0
/**
 * \brief Test wait mode.
 */
static void test_wait_mode(void)
{
	puts(STRING_WAIT);

#if SAMG55
	/* Wait for the transmission done before changing clock */
	while (!usart_is_tx_empty(CONSOLE_UART)) {
	}
#else
	/* Wait for the transmission done before changing clock */
	while (!uart_is_tx_empty(CONSOLE_UART)) {
	}
#endif

	/* Configure fast RC oscillator */
	pmc_switch_mck_to_sclk(PMC_MCKR_PRES_CLK_1);
#if (SAMG)
	pmc_switch_mainck_to_fastrc(CKGR_MOR_MOSCRCF_8_MHz);
#else
	pmc_switch_mainck_to_fastrc(CKGR_MOR_MOSCRCF_4_MHz);
#endif
	pmc_switch_mck_to_mainck(PMC_PCK_PRES_CLK_1);

#if (SAMG)
	g_ul_current_mck = 8000000; /* 8MHz */
#else
	g_ul_current_mck = 4000000; /* 4MHz */
#endif
	/* Disable unused clock to save power */
	pmc_osc_disable_xtal(0);
	example_disable_pll();

	/* Set wakeup input for fast startup */
	example_set_wakeup_from_wait_mode();

	/* Enter into wait Mode */
	pmc_enable_waitmode();

	/* Set default clock and re-configure UART */
	set_default_working_clock();
	reconfigure_console(g_ul_current_mck, CONF_UART_BAUDRATE);

	puts("Exit from wait Mode.\r");
}
Esempio n. 3
0
/**
 * \brief Test sleep Mode.
 */
static void test_sleep_mode(void)
{
	/* Configure button for waking up sleep mode */
	configure_button();

	/* Select clock for sleep mode */
	user_change_clock(STRING_SLEEP);

	/* Disable UART */
	pmc_disable_periph_clk(CONSOLE_UART_ID);

	/* Enter into sleep Mode */
	pmc_enable_sleepmode(0);

	/* Set default clock and re-configure UART */
	set_default_working_clock();
	reconfigure_console(g_ul_current_mck, CONF_UART_BAUDRATE);

	puts("Exit from sleep Mode.\r");
}
Esempio n. 4
0
/**
 * \brief Test active mode.
 */
static void test_active_mode(void)
{
	/* Configure button for exiting from active mode */
	configure_button();

	g_ul_button_pressed = 0;

	/* Select clock for active mode */
	user_change_clock(STRING_ACTIVE);

	/* Test active mode */
	do {
		/* Run Fibonacci calculation, n = 10 (may be changed) */
		fib(10);
	} while (!g_ul_button_pressed);

	/* Set default clock and re-configure UART */
	set_default_working_clock();
	reconfigure_console(g_ul_current_mck, CONF_UART_BAUDRATE);

	puts("Exit from active mode.\r");
}