Beispiel #1
0
/**
 * Initialize the PEVC for the example.
 */
static void init_events(void)
{
	struct events_conf    events_config;
	struct events_ch_conf ch_config;

	/* Initialize event module */
	events_get_config_defaults(&events_config);
	events_config.igf_divider = EVENT_IGF_DIVIDER_1024;
	events_init(&events_config);
	events_enable();

	/*
	 * Configure an event channel
	 * - GPIO PAD_EVT 1  --- Generator
	 * - PDCA channel 0  --- User
	 * - Enable falling edge detection for EVS
	 */
	events_ch_get_config_defaults(&ch_config);
	ch_config.channel_id = PEVC_ID_USER_PDCA_0;
	ch_config.generator_id = PEVC_ID_GEN_PAD_1;
	ch_config.sharper_enable = true;
	ch_config.igf_edge = EVENT_IGF_EDGE_FALLING;
	events_ch_configure(&ch_config);

	/* Enable the channel */
	events_ch_enable(PEVC_ID_USER_PDCA_0);
}
Beispiel #2
0
//! [quick_start_init_events_function]
static void init_events(void)
{
	struct events_conf    events_config;
	struct events_ch_conf ch_config;

	/* Initialize event module */
	events_get_config_defaults(&events_config);
	events_init(&events_config);
	events_enable();

	/*
	 * Configure an event channel
	 * - AST periodic event 0 --- Generator
	 * - PDCA channel 0       --- User
	 */
	events_ch_get_config_defaults(&ch_config);
	ch_config.channel_id = PEVC_ID_USER_PDCA_0;
	ch_config.generator_id = PEVC_ID_GEN_AST_2;
	ch_config.shaper_enable = true;
	ch_config.igf_edge = EVENT_IGF_EDGE_NONE;
	events_ch_configure(&ch_config);

	/* Enable the channel */
	events_ch_enable(PEVC_ID_USER_PDCA_0);
}
Beispiel #3
0
/**
 * \brief Test events driver with AST trigger.
 *
 * \param test Current test case.
 */
static void run_events_ast_test(const struct test_case *test)
{
	uint32_t retry_times = 3;
	bool trigger_flag = false;
	struct events_conf    events_config;
	struct events_ch_conf ch_config;

	init_ast();
	init_dacc();

	/* Initialize event module */
	events_get_config_defaults(&events_config);
	events_init(&events_config);
	events_enable();

	/*
	 * Configure an event channel
	 * - AST periodic event 0  --- Generator
	 * - DAC                   --- User
	 */
	events_ch_get_config_defaults(&ch_config);
	ch_config.channel_id = CONF_TEST_USER_ID;
	ch_config.generator_id = CONF_TEST_GEN_ID;
	ch_config.shaper_enable = true;
	ch_config.igf_edge = EVENT_IGF_EDGE_NONE;
	events_ch_configure(&ch_config);

	/* Enable the channel */
	events_ch_enable(CONF_TEST_USER_ID);

	/* Set new DACC value */
	dacc_write_conversion_data(DACC, DACC_MAX_DATA / 2);


	/* Wait for AST event trigger */
	events_ch_clear_trigger_status(CONF_TEST_USER_ID);
	do {
		if (events_ch_is_triggered(CONF_TEST_USER_ID)) {
			trigger_flag = true;
			events_ch_clear_trigger_status(CONF_TEST_USER_ID);
			break;
		}
		delay_ms(1000);
	} while (retry_times--);

	/* Disable the AST */
	ast_disable(AST);

	test_assert_true(test, trigger_flag, "AST event not triggered!");
}
Beispiel #4
0
/**
 * Initialize the PEVC for the example.
 */
static void init_pevc(void)
{
	/* Set input glitch filter divider to 0x0A (2^10) */
	struct events_conf config;
	events_get_config_defaults(&config);
	events_init(&config);

	/*
	 * Setup and enable PEVC channel:
	 * - Generator: PAD_EVT 1
	 * - User: PDCA - channel 0 transfer one word
	 * - Enable falling edge detection for EVS
	 */
	struct events_ch_conf ch_config;
	events_ch_get_config_defaults(&ch_config);
	ch_config.channel_id = PEVC_ID_USER_PDCA_0;
	ch_config.generator_id = PEVC_ID_GEN_PAD_1;
	ch_config.shaper_enable = true;
	ch_config.igf_edge = EVENT_IGF_EDGE_FALLING;
	events_ch_configure(&ch_config);
	events_ch_enable(PEVC_ID_USER_PDCA_0);
}