Example #1
0
/**
 * \internal
 * \brief Test the callback API
 *
 * This test tests the callback API for the TCC. The TCC uses one-shot mode.
 *
 * \param test Current test case.
 */
static void run_callback_test(const struct test_case *test)
{
	test_assert_true(test,
			tcc_init_success == true,
			"TCC initialization failed, skipping test");

	test_assert_true(test,
			basic_functionality_test_passed == true,
			"Basic functionality test failed, skipping test");

	/* Setup TCC0 */
	tcc_reset(&tcc_test0_module);
	tcc_get_config_defaults(&tcc_test0_config, CONF_TEST_TCC0);

	tcc_test0_config.counter.period = 4000;
	tcc_test0_config.compare.wave_generation = TCC_WAVE_GENERATION_NORMAL_FREQ;
	tcc_test0_config.compare.match[TCC_MATCH_CAPTURE_CHANNEL_0] = 3990;

	tcc_init(&tcc_test0_module, CONF_TEST_TCC0, &tcc_test0_config);

	/* Setup callbacks */
	tcc_register_callback(&tcc_test0_module, tcc_callback_function,
			TCC_CALLBACK_CHANNEL_0);
	tcc_enable_callback(&tcc_test0_module, TCC_CALLBACK_CHANNEL_0);

	tcc_enable(&tcc_test0_module);

	while ((tcc_get_status(&tcc_test0_module) &
			TCC_STATUS_COUNT_OVERFLOW) == 0) {
		/* Wait for overflow of TCC1 */
	}

	tcc_disable(&tcc_test0_module);
	tcc_clear_status(&tcc_test0_module, TCC_STATUS_COUNT_OVERFLOW);

	test_assert_true(test,
			callback_function_entered == 1,
			"The callback has failed callback_function_entered = %d",
			(int)callback_function_entered);

	/* Test disable callback function */
	tcc_disable_callback(&tcc_test0_module, TCC_CALLBACK_CHANNEL_0);
	tcc_set_count_value(&tcc_test0_module, 0x00000000);

	tcc_enable(&tcc_test0_module);

	while (!(tcc_get_status(&tcc_test0_module) & TCC_STATUS_COUNT_OVERFLOW)) {
		/* Wait for overflow of TC1*/
	}

	/* Test tcc_disable() */
	tcc_disable(&tcc_test0_module);

	test_assert_true(test,
			callback_function_entered == 1,
			"Disabling the callback has failed");
}
Example #2
0
void sw_timer_disable(struct sw_timer_module *const module_inst)
{
	struct tcc_module *tcc_module;
	
	Assert(module_inst);
	
	tcc_module = &module_inst->tcc_inst;
	tcc_disable(tcc_module);
}
static void deinit_timer(void)
{
	tcc_disable_callback(&tempTccModule, TCC_CALLBACK_CHANNEL_3);
	tcc_disable(&tempTccModule);
}