コード例 #1
0
/**
 * \brief Test the uart sleepwalking in active mode.
 */
static void uart_sleepwalking_test_active(void)
{
	puts("Test in active mode, press 's' to continue.\r");

	/* Wait for the puts operation to finish. */
	delay_ms(50);

	/* Enable UART IRQ */
	uart_enable_interrupt(CONSOLE_UART, UART_IER_CMP);

	/* Enable UART interrupt */
	NVIC_EnableIRQ(CONSOLE_UART_IRQn);

	/* Set the match condition */
	uart_set_sleepwalking(CONSOLE_UART, 's', true, true, 's');

	/* Enable the sleepwalking in PMC */
	pmc_enable_sleepwalking(CONSOLE_UART_ID);

	/* Wait for the match interrupt */
	while (!cmp_flag) {
	}

	puts("'s' character is received.\r\n\r");

}
コード例 #2
0
/**
 * \brief Test the uart sleepwalking in wait mode.
 */
static void uart_sleepwalking_test_wait(void)
{
	enum sleepmgr_mode current_sleep_mode = SLEEPMGR_WAIT;

	puts("Test in wait mode, press any key to wake up.\r");

	/* Wait for the puts operation to finish. */
	delay_ms(50);

	/* Set the wakeup condition */
	uart_set_sleepwalking(CONSOLE_UART, 0x00, true, false, 0xFF);

	/* Enable the sleepwalking in PMC */
	pmc_enable_sleepwalking(CONSOLE_UART_ID);

	/* Enter wait mode. */
	sleepmgr_init();
	sleepmgr_lock_mode(current_sleep_mode);
	sleepmgr_enter_sleep();

	puts("A character is received, system wake up.\r\n\r");

}
コード例 #3
0
/**
 * \brief Test the usart sleepwalking in wait mode.
 */
static void usart_sleepwalking_test_wait(void)
{
	enum sleepmgr_mode current_sleep_mode = SLEEPMGR_WAIT;

	puts("Test in wait mode, press number '0' to '9' to wake up.\r");

	/* Wait for the puts operation to finish. */
	delay_ms(50);

	/* The sleep manage will set the clock to 24MRC in wait mode,
	 * reconfig the divisor */
	usart_set_async_baudrate(CONSOLE_UART, CONF_UART_BAUDRATE, OSC_MAINCK_24M_RC_HZ);

	/* Wait for the clock stable. */
	delay_ms(5);

	/* Set the wakeup condition */
	usart_set_sleepwalking(CONSOLE_UART, '0', true, true, '9');

	/* Enable the sleepwalking in PMC */
	pmc_enable_sleepwalking(CONSOLE_UART_ID);

	/* Enter wait mode. */
	sleepmgr_init();
	sleepmgr_lock_mode(current_sleep_mode);
	sleepmgr_enter_sleep();

	/* Config the divisor to the original setting */
	usart_set_async_baudrate(CONSOLE_UART, CONF_UART_BAUDRATE, sysclk_get_peripheral_hz());

	/* Wait for the clock stable. */
	delay_ms(5);

	puts("A character is received, system wake up.\r\n\r");

}