Ejemplo n.º 1
0
/**
 * \internal
 * \brief Generate a delay in ms
 *
 * \param delay_ms  Number of ms to wait
 */
static void main_delay_ms(uint16_t delay_ms)
{
	uint16_t ticks_delay;

	tc_write_count(CONF_DELAY_TC, 0);
	ticks_delay = (uint64_t)tc_get_resolution(CONF_DELAY_TC) * delay_ms
			/ 1000;
	while (ticks_delay > tc_read_count(CONF_DELAY_TC)) {
	}
}
Ejemplo n.º 2
0
void app_cpu_load_exit_sleep(void)
{
	if (app_cpu_load_sleep) {
		/* It is a sleep mode exit */
		app_cpu_load_sleep = false;
		app_cpu_load_time_sleep += tc_read_count(&TCC1);
		/* Reset Timer counter */
		tc_write_count(&TCC1, 0);
	}
}
Ejemplo n.º 3
0
void app_cpu_load_enter_sleep(void)
{
	/* Disable all interrupts to avoid interrupt
	 * before enter the CPU in sleep mode */
	cpu_irq_disable();
	app_cpu_load_sleep = true;
	app_cpu_load_time_actif += tc_read_count(&TCC1);
	/* Reset Timer counter */
	tc_write_count(&TCC1, 0);
}
Ejemplo n.º 4
0
/**
 * Record a trace event
 * @param event
 * @param data
 */
void hf_trace(uint8_t event, uint8_t data) {
    irqflags_t irq;

    irq = cpu_irq_save();
    t_head->event = event;
    t_head->data = data;
    /* in 250nsec increments */
    t_head->time = tc_read_count(&TCC0);

    if (++t_head >= &trace_records[TRACE_RECORDS])
    t_head = trace_records;
    /* marker */
    t_head->event = 255;
    cpu_irq_restore(irq);
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: Tjalling7/asf
/**
 * \brief Delay function which use a Timer Counter and can be aborted
 * SW1 pressed stop delay.
 *
 * \param delay_ms  delay in ms
 */
static void main_introduction_delay(uint16_t delay_ms)
{
    /* Initialization TC to manage a delay between each slide */
    tc_enable(&TCC1);
    tc_write_clock_source(&TCC1, TC_CLKSEL_DIV1024_gc); /* 24MHz / 1024 */
    tc_set_direction(&TCC1, TC_UP);
    while (delay_ms) {
        tc_write_count(&TCC1, 0);
        uint16_t delay_step = delay_ms;
        if (delay_step > 2800) {
            delay_step = 2500;
        }

        while (tc_read_count(&TCC1) <
                ((24000lu * delay_step) / 1024lu)) {
            if (main_introduction_is_exist()) {
                break;
            }
        }
        delay_ms -= delay_step;
    }
    tc_disable(&TCC1);
}
Ejemplo n.º 6
0
/*! \brief  read the actual timer count from register
 */
uint16_t tmr_read_count(void)
{
	return tc_read_count(TIMER);
}
Ejemplo n.º 7
0
uint16_t qdec_get_position(qdec_config_t *config)
{
	return tc_read_count(config->timer);
}