Пример #1
0
void sw_timer_init(struct sw_timer_module *const module_inst, struct sw_timer_config *const config)
{
	struct tcc_config tcc_conf;
	struct tcc_module *tcc_module;
	Tcc *hw[] = TCC_INSTS;
	
	Assert(module_inst);
	Assert(config);
	Assert(config->tcc_dev < TCC_INST_NUM);
	Assert(config->tcc_callback_channel < TCC_NUM_CHANNELS);
	
	module_inst->accuracy = config->accuracy;
	
	/* Start the TCC module. */
	tcc_module = &module_inst->tcc_inst;
	tcc_get_config_defaults(&tcc_conf, hw[config->tcc_dev]);
	tcc_conf.counter.period = system_cpu_clock_get_hz() / (64 * 1000 / config->accuracy);
	tcc_conf.counter.clock_prescaler = TCC_CLOCK_PRESCALER_DIV64;
	tcc_init(tcc_module, hw[config->tcc_dev], &tcc_conf);
	tcc_register_callback(tcc_module, sw_timer_tcc_callback, config->tcc_callback_channel + TCC_CALLBACK_CHANNEL_0);
	tcc_enable_callback(tcc_module, config->tcc_callback_channel + TCC_CALLBACK_CHANNEL_0);
}
Пример #2
0
/**
 * \brief Main application function. 
 *
 * Start the sensor task then start the scheduler.
 *
 * \return program return value.
 */
int main(void)
{
#if SAMD21
	system_init();
#elif SAME70
	sysclk_init();
	board_init();
#endif

	/* Initialize the UART console. */
	configure_console();

	/* Initialize the delay driver. */
	delay_init();
			
	/* Enable SysTick interrupt for non busy wait delay. */
#if SAMD21
	if (SysTick_Config(system_cpu_clock_get_hz()/1000)) {
		puts("main: SysTick configuration error!");
		while (1);
	}
#elif SAME70
	if (SysTick_Config(sysclk_get_main_hz()/1000)) {
		puts("main: SysTick configuration error!");
		while (1);
	}
#endif


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

	/* Start the demo task. */
	demo_start();
	
	return 0;
}