コード例 #1
0
int process_command(char** data){
	if (!data[0]) return 0;
	if (is_equal_string(data[0], "start")){
		int gpio = 0;
		int duty = 0;
		if (!data[1] || !data[2]) return 0;
		gpio = starts_with(data[1], "con:");
		duty = starts_with(data[2], "duty:");
		if (gpio == NA || duty == NA) return 0;
		dbg_print("Starts con %d, duty %d\r\n", gpio, duty);
		start_pwm(gpio, duty);
	} else if (is_equal_string(data[0], "stop")){
		int gpio = 0;
		if (!data[1] ) return 0;
		gpio = starts_with(data[1], "con:");
		if (gpio == NA ) return 0;
		dbg_print("Stops con %d\r\n", gpio);
		stop_pwm(gpio);
	} else if (is_equal_string(data[0], "period")){
		int period = 0;
		if (!data[1] ) return 0;
		period = starts_with(data[1], "");
		if (period == NA ) return 0;
		dbg_print("Period %d\r\n", period);
		set_period(period);
	}
	return 0;
}
コード例 #2
0
ファイル: emitter.cpp プロジェクト: zzchern/isef-lbm
void Emitter :: set_default_params()
{
	set_point_position(field_nx/2, field_ny/2);
	set_speed(0.0, 0.0);
	set_period(256/16);
	create_standart_wave(SIN_EMIT);
	switch_emitter(true);
}
コード例 #3
0
ファイル: acc-sl.c プロジェクト: aoboy/acc-slight
/**
 * @brief initialize_settings
 */
static void initialize_settings(){

    //since we now know the duty cycle we can compute the cycle_length
    set_period();
    //and finally we can now compute the node 'extended' period.
    set_period_upper_bound();
    
    //we set the maximum amount of extra energy to spend.
    set_extra_slots();
}
コード例 #4
0
ファイル: timerfd.c プロジェクト: brho/akaros
int timerfd_settime(int fd, int flags,
                    const struct itimerspec *new_value,
                    struct itimerspec *old_value)
{
	int timerfd, periodfd;
	int ret;
	uint64_t period;
	struct timespec now_timespec = {0};
	struct timespec rel_timespec;

	timerfd = get_sibling_fd(fd, "timer");
	if (timerfd < 0)
		return -1;
	periodfd = get_sibling_fd(fd, "period");
	if (periodfd < 0) {
		close(timerfd);
		return -1;
	}
	if (old_value) {
		if (__timerfd_gettime(timerfd, periodfd, old_value)) {
			ret = -1;
			goto out;
		}
	}
	if (!new_value->it_value.tv_sec && !new_value->it_value.tv_nsec) {
		ret = set_timer(timerfd, 0);
		goto out;
	}
	period = timespec2tsc(&new_value->it_interval);
	ret = set_period(periodfd, period);
	if (ret < 0)
		goto out;
	/* So the caller is asking for timespecs in wall-clock time (depending
	 * on the clock, actually, (TODO)), and the kernel expects TSC ticks
	 * from boot.  If !ABSTIME, then it's just relative to now.  If it is
	 * ABSTIME, then they are asking in terms of real-world time, which
	 * means ABS - NOW to get the rel time, then convert to tsc ticks. */
	if (flags & TFD_TIMER_ABSTIME) {
		ret = clock_gettime(CLOCK_MONOTONIC, &now_timespec);
		if (ret < 0)
			goto out;
		subtract_timespecs(&rel_timespec, &new_value->it_value,
				   &now_timespec);
	} else {
		rel_timespec = new_value->it_value;
	}
	ret = set_timer(timerfd, timespec2tsc(&rel_timespec) + read_tsc());
	/* fall-through */
out:
	close(timerfd);
	close(periodfd);
	return ret;
}
コード例 #5
0
ファイル: emitter.cpp プロジェクト: zzchern/isef-lbm
void Emitter :: create_special_wave(float* data, unsigned long size)
{
	set_period(size);
	delete wave;
	wave = new float[T];
	for(int i = 0; i < T; ++i)
		wave[i] = float(data[i]);
	float max_value = -1;
	for(int i = 0; i < T; ++i)
		if(wave[i] > max_value)
			max_value = wave[i];
	for(int i = 0; i < T; ++i)
		wave[i] /= max_value;
}
コード例 #6
0
ファイル: server.c プロジェクト: fvdsn/tuned
int main(int argc, char**argv){
	fun_t *f;
	f = f_mult(f_window(f_cu(0,SEC),f_cu(3,SEC)),
			f_sin(f_c(1),f_cu(50,HZ),f_c(0)) );
	f = f_add(f,
	    f_mult(f_window(f_cu(3,SEC),f_cu(6,SEC)),
			f_tri(f_c(1),f_cu(50,HZ),f_c(0)) ));
	f = f_add(f,
	    f_mult(f_window(f_cu(6,SEC),f_cu(9,SEC)),
			f_square(f_c(1),f_cu(50,HZ),f_c(0),f_c(0.5)) ));
	
	set_bpm(f_ramp(f_cu(2,SEC),f_cu(8,SEC),f_c(60),f_c(70)));
	set_period(f_c(4));
	/*
	fun_print(f);
	*/

	f = s_down_sample(f_c(10),f);

	fun_record_16b(f,0,SAMPLING_RATE*10,2,buffer);
	audio_write_stereo_16b(buffer,SAMPLING_RATE*2*2*10,"test.wav");

	return 0;
}
コード例 #7
0
ファイル: PWM_Sysfs.cpp プロジェクト: ArmaJo/ardupilot
void PWM_Sysfs_Base::set_freq(uint32_t freq)
{
    set_period(hz_to_nsec(freq));
}
コード例 #8
0
ファイル: soc-hw.c プロジェクト: dkmatize/digital_ii
void tic_init() //Inicialización de el timer
{
	// Set high M1,M2,M3 and M4
	gpio0->out=0x0F;
	
	// Setup timer0.0 
	timer0->compare0 = set_period();
	timer0->counter0 = 0;
	timer0->tcr0   = TIMER_EN | TIMER_AR | TIMER_IRQEN;

	// Setup timer0.1 
	timer0->compare1 = set_duty(pwm_d[0]);
	timer0->counter1 = 0;	
	timer0->tcr1     = TIMER_EN | TIMER_AR | TIMER_IRQEN;
	
	// Setup timer0.2 
	timer0->compare2 = set_period();
	timer0->counter2 = 0;
	timer0->tcr2   = TIMER_EN | TIMER_AR | TIMER_IRQEN;

	// Setup timer0.3 
	timer0->compare3 = set_duty(pwm_d[1]);
	timer0->counter3 = 0;	
	timer0->tcr3     = TIMER_EN | TIMER_AR | TIMER_IRQEN;
	
	// Setup timer0.4 
	timer0->compare4 = set_period();
	timer0->counter4 = 0;
	timer0->tcr4   = TIMER_EN | TIMER_AR | TIMER_IRQEN;

	// Setup timer0.5 
	timer0->compare5 = set_duty(pwm_d[2]);
	timer0->counter5 = 0;	
	timer0->tcr5     = TIMER_EN | TIMER_AR | TIMER_IRQEN;
	
	// Setup timer0.6 
	timer0->compare6 = set_period();
	timer0->counter6 = 0;
	timer0->tcr6   = TIMER_EN | TIMER_AR | TIMER_IRQEN;

	// Setup timer0.7 
	timer0->compare7 = set_duty(pwm_d[3]);
	timer0->counter7 = 0;	
	timer0->tcr7     = TIMER_EN | TIMER_AR | TIMER_IRQEN;
	
	isr_register(3, &tic_isr_0);
	isr_register(4, &tic_isr_1);
	isr_register(5, &tic_isr_2);
	isr_register(6, &tic_isr_3);
	isr_register(7, &tic_isr_4);
	isr_register(8, &tic_isr_5);
	isr_register(9, &tic_isr_6);
	isr_register(10, &tic_isr_7);

	//Button function register
	isr_register(15, &tic_isr_15);
	isr_register(16, &tic_isr_16);
	isr_register(17, &tic_isr_17);
	isr_register(18, &tic_isr_18);
	isr_register(19, &tic_isr_19);

}
コード例 #9
0
 periodic(unsigned period_ = 0) {
   set_period(period_);
 }
コード例 #10
0
ファイル: emitter.cpp プロジェクト: zzchern/isef-lbm
void Emitter :: set_frequency(float value)
{
	set_period(int(1.0/value));
}