예제 #1
0
파일: spindle.c 프로젝트: ejluttmann/TinyG
//static void _exec_spindle_control(uint8_t spindle_mode, float f, float *vector, float *flag)
static void _exec_spindle_control(float *value, float *flag)
{
	uint8_t spindle_mode = (uint8_t)value[0];
	cm_set_spindle_mode(MODEL, spindle_mode);

 #ifdef __AVR
	if (spindle_mode == SPINDLE_CW) {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			gpio_set_bit_off(SPINDLE_BIT);
			gpio_set_bit_on(SPINDLE_DIR);
		} else {
			gpio_set_bit_on(SPINDLE_BIT);
			gpio_set_bit_off(SPINDLE_DIR);
		}
	} else if (spindle_mode == SPINDLE_CCW) {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			gpio_set_bit_off(SPINDLE_BIT);
			gpio_set_bit_off(SPINDLE_DIR);
		} else {
			gpio_set_bit_on(SPINDLE_BIT);
			gpio_set_bit_on(SPINDLE_DIR);
		}
	} else {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			gpio_set_bit_on(SPINDLE_BIT);	// failsafe: any error causes stop
		} else {
			gpio_set_bit_off(SPINDLE_BIT);	// failsafe: any error causes stop
		}
	}
#endif // __AVR
#ifdef __ARM
	if (spindle_mode == SPINDLE_CW) {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			spindle_enable_pin.clear();
			spindle_dir_pin.set();
		} else {
			spindle_enable_pin.set();
			spindle_dir_pin.clear();
		}
	} else if (spindle_mode == SPINDLE_CCW) {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			spindle_enable_pin.clear();
			spindle_dir_pin.clear();
		} else {
			spindle_enable_pin.set();
			spindle_dir_pin.set();
		}
	} else {
 	    if (cm.gm.spindle_active_dir == SPINDLE_ACTIVE_LOW) {
			spindle_enable_pin.set();	// failsafe: any error causes stop
		} else {
			spindle_enable_pin.clear();	// failsafe: any error causes stop
		}
	}
#endif // __ARM

	// PWM spindle control
	pwm_set_duty(PWM_1, cm_get_spindle_pwm(spindle_mode) );
}
예제 #2
0
파일: spindle.c 프로젝트: dandumit/TinyG
//static void _exec_spindle_control(uint8_t spindle_mode, float f, float *vector, float *flag)
static void _exec_spindle_control(float *value, float *flag)
{
	uint8_t spindle_mode = (uint8_t)value[0];
	cm_set_spindle_mode(MODEL, spindle_mode);

	//if (spindle_mode == SPINDLE_CW) { gpio_set_bit_on(SPINDLE_BIT); gpio_set_bit_off(SPINDLE_DIR); 	} 
	if (spindle_mode == SPINDLE_CCW) { //M8
		gpio_set_bit_on(SPINDLE_BIT);
		//gpio_set_bit_on(SPINDLE_DIR);
	} else {
		gpio_set_bit_off(SPINDLE_BIT);	// failsafe: any error causes stop
	}
	// PWM spindle control
	pwm_set_duty(PWM_1, cm_get_spindle_pwm(spindle_mode) );
}
예제 #3
0
파일: spindle.c 프로젝트: ADTL/TinyG
static void _exec_spindle_control(uint8_t spindle_mode, float f)
{
	cm_set_spindle_mode(spindle_mode);
 	if (spindle_mode == SPINDLE_CW) {
		gpio_set_bit_on(SPINDLE_BIT);
		gpio_set_bit_off(SPINDLE_DIR);
	} else if (spindle_mode == SPINDLE_CCW) {
		gpio_set_bit_on(SPINDLE_BIT);
		gpio_set_bit_on(SPINDLE_DIR);
	} else {
		gpio_set_bit_off(SPINDLE_BIT);	// failsafe: any error causes stop
	}
    
    // PWM spindle control
    pwm_set_duty(PWM_1, cm_get_spindle_pwm(spindle_mode) );
}