Ejemplo n.º 1
0
/**
 * Create a Dictionary based on a Hashtable.
 *
 * @param   profiling[in]  Activate the profiling mode
 * @return  Pointer to the new Dictionary structure
 */
Dictionary *mr_dictionary_create(bool profiling) {
    int i;
    Dictionary *dico = malloc(sizeof(Dictionary));
    assert(dico != NULL);

    /* Initialize variables for profiling */
    dico->profiling = profiling;
    _timer_init(&dico->timer_put, dico->profiling);

    dico->hash_size = HASH_SIZE;

    dico->hash_tab = malloc(dico->hash_size*sizeof(Bucket));
    assert(dico->hash_tab != NULL);

    /* Set to null first Word pointers in all buckets */
    for (i=0; i<dico->hash_size; i++){
        Bucket *b = &dico->hash_tab[i];
        b->word = NULL;
        #if MAPREDUCE_USE_BUFFALLOC
            b->buffalloc = NULL;
        #endif
    }

    return dico;
}
Ejemplo n.º 2
0
// Create a scheduler structure and initialize hardware
static inline void _sch_timers_init(uint8_t timer_id) {
    // Initialize internal structures
    _sch_timers[timer_id] = calloc(HW_TIMER_MR_AMOUNT, sizeof(timer_sch_t));
    if (_sch_timers[timer_id] == NULL) Show_Error();
    // Initilize hardware - the timers used for scheduling have an offset.
    _timer_init(timer_id);
}
Ejemplo n.º 3
0
// Delays in microseconds using the fast timer
void Delay_us(unsigned int us) {
    if (! _fast_timer_init) {
        _timer_init(FAST_TIMER);
        _fast_timer_init = 1;
    }
    uint32_t cur_us = _timers[FAST_TIMER]->TC;
    while ((_timers[FAST_TIMER]->TC - cur_us) < us);
}
Ejemplo n.º 4
0
void init(void){
	_usart_init();
	_timer_init();

	DDRB |= (1<<PB0)|(1<<PB1)|(1<<PB2)|(1<<PB3)|(1<<PB4)|(1<<PB5)|(1<<PB6)|(1<<PB7); // Ausgänge für die Relais

	sei();
}
Ejemplo n.º 5
0
/*
 * handle ioctl requests
 */
int
PWMIN::ioctl(struct file *filp, int cmd, unsigned long arg)
{
	switch (cmd) {
	case SENSORIOCSQUEUEDEPTH: {
			/* lower bound is mandatory, upper bound is a sanity check */
			if ((arg < 1) || (arg > 500)) {
				return -EINVAL;
			}

			irqstate_t flags = px4_enter_critical_section();

			if (!_reports->resize(arg)) {
				px4_leave_critical_section(flags);
				return -ENOMEM;
			}

			px4_leave_critical_section(flags);

			return OK;
		}

	case SENSORIOCGQUEUEDEPTH:
		return _reports->size();

	case SENSORIOCRESET:
		/* user has asked for the timer to be reset. This may
		 * be needed if the pin was used for a different
		 * purpose (such as PWM output) */
		_timer_init();
		/* also reset the sensor */
		hard_reset();
		return OK;

	default:
		/* give it to the superclass */
		return CDev::ioctl(filp, cmd, arg);
	}
}