Beispiel #1
0
/**
 * \brief This function disables the AST Periodic interrupt.
 *
 * \param ast              Base address of the AST (i.e. &AVR32_AST).
 * \param periodic_channel AST Periodic Channel
 */
void ast_disable_periodic_interrupt(volatile avr32_ast_t *ast,
		uint8_t periodic_channel)
{
	/* Disable the AST Periodic Asynchronous Wake-up */
	if (periodic_channel) {
		ast_disable_interrupt(ast, AVR32_AST_IER_PER1_MASK);
	} else {
		ast_disable_interrupt(ast, AVR32_AST_IER_PER0_MASK);
	}
}
Beispiel #2
0
/**
 * \brief This function disables the AST Alarm interrupt.
 *
 * \param ast           Base address of the AST (i.e. &AVR32_AST).
 * \param alarm_channel AST Alarm Channel
 */
void ast_disable_alarm_interrupt(volatile avr32_ast_t *ast,
		uint8_t alarm_channel)
{
	/* Disable the AST Alarm Asynchronous Wake-up */
	if (alarm_channel) {
		ast_disable_interrupt(ast, AVR32_AST_IER_ALARM1_MASK);
	} else {
		ast_disable_interrupt(ast, AVR32_AST_IER_ALARM0_MASK);
	}
}
Beispiel #3
0
/**
 * \brief Test periodic interrupt and wakeup functions in counter mode.
 *
 * \param test Current test case.
 */
static void run_periodic_test(const struct test_case *test)
{
	struct ast_config ast_conf;

	/* Enable the AST. */
	ast_enable(AST);

	ast_conf.mode = AST_COUNTER_MODE;
	ast_conf.osc_type = AST_OSC_32KHZ;
	ast_conf.psel = AST_PSEL_32KHZ_1HZ;
	ast_conf.counter = 0;
	ast_set_config(AST, &ast_conf);

	/* Set periodic 0 to interrupt after 1/16 second in counter mode. */
	ast_clear_interrupt_flag(AST, AST_INTERRUPT_PER);
	ast_write_periodic0_value(AST, AST_PSEL_32KHZ_1HZ - 4);
	/* Set callback for periodic0. */
	flag = 0;
	ast_set_callback(AST, AST_INTERRUPT_PER, ast_per_callback,
		AST_PER_IRQn, 1);
	delay_ms(200);
	test_assert_true(test, flag == 1, "Periodic interrupt not work!");

	/* Set periodic 0 to wakeup after 1/16 second in counter mode. */
	while (!(ast_read_interrupt_mask(AST) & AST_IMR_PER0_1)) {
		ast_enable_interrupt(AST, AST_INTERRUPT_PER);
	}
	ast_enable_wakeup(AST, AST_WAKEUP_PER);

	/* AST can wakeup the device. */
	bpm_enable_wakeup_source(BPM, (1 << BPM_BKUPWEN_AST));

	flag = 0;
	/* Go into WAIT mode. */
	bpm_sleep(BPM, BPM_SM_WAIT);
	delay_ms(200);
	test_assert_true(test, flag == 1, "Periodic wakeup not work!");
	ast_disable_interrupt(AST, AST_INTERRUPT_PER);

	/* Disable the AST. */
	ast_disable(AST);
}
Beispiel #4
0
static void config_ast(void)
{
	struct ast_config ast_conf;

	/* Enable osc32 oscillator*/
	if (!osc_is_ready(OSC_ID_OSC32)) {
		osc_enable(OSC_ID_OSC32);
		osc_wait_ready(OSC_ID_OSC32);
	}

	/* Enable the AST */
	ast_enable(AST);

	ast_conf.mode = AST_COUNTER_MODE;
	ast_conf.osc_type = AST_OSC_32KHZ;
	ast_conf.psel = AST_PSEL_32KHZ_1HZ;
	ast_conf.counter = 0;

	/*
	 * Using counter mode and set it to 0.
	 * Initialize the AST.
	 */
	if (!ast_set_config(AST, &ast_conf)) {
		printf("Error initializing the AST\r\n");
		while (1) {
		}
	}

	/* First clear alarm status. */
	ast_clear_interrupt_flag(AST, AST_INTERRUPT_ALARM);

	/* Enable wakeup from alarm0. */
	ast_enable_wakeup(AST, AST_WAKEUP_ALARM);

	/* Set callback for alarm0. */
	ast_set_callback(AST, AST_INTERRUPT_ALARM, ast_alarm_callback,
		AST_ALARM_IRQn, 1);

	/* Disable first interrupt for alarm0. */
	ast_disable_interrupt(AST, AST_INTERRUPT_ALARM);

}
Beispiel #5
0
/**
 * \brief This function disables the AST Ready interrupt.
 *
 * \param ast              Base address of the AST (i.e. &AVR32_AST).
 */
void ast_disable_clkrdy_interrupt(volatile avr32_ast_t *ast)
{
	/* Disable the AST Counter Overflow Asynchronous Wake-up */
	ast_disable_interrupt(ast, AVR32_AST_IER_CLKRDY_MASK);
}
Beispiel #6
0
/**
 * \brief Callback handler for AST alarm interrupt.
 */
static void ast_alarm_callback(void)
{
	ast_disable_interrupt(AST, AST_INTERRUPT_ALARM);
	ast_clear_interrupt_flag(AST, AST_INTERRUPT_ALARM);
	flag = 2;
}
Beispiel #7
0
/**
 * \brief Callback handler for AST periodic interrupt.
 */
static void ast_per_callback(void)
{
	ast_disable_interrupt(AST, AST_INTERRUPT_PER);
	ast_clear_interrupt_flag(AST, AST_INTERRUPT_PER);
	flag = 1;
}
Beispiel #8
0
/**
 * \brief Callback handler for AST alarm Interrupt.
 */
static void ast_alarm_callback(void)
{
	ast_disable_interrupt(AST, AST_INTERRUPT_ALARM);
	flag = true;
}