void motor_init(){ motor_x_init(); motor_y_init(); motor_z_init(); motor_disable(motor_x); motor_disable(motor_y); motor_disable(motor_z); }
void motor_step_alternative(Motor_Typedef motor, Motor_Direction dir, float speed){ uint32_t delay; delay = (int)((float)1/(((float)speed/2)*200)*1000000); //Need change if different stepping methods implemented if(dir == positive) GPIO_SetBits(MOTOR_DIR_PORT[motor], MOTOR_DIR_PIN[motor]); if(dir == negative) GPIO_ResetBits(MOTOR_DIR_PORT[motor], MOTOR_DIR_PIN[motor]); motor_enable(motor); //enable GPIO_ResetBits(MOTOR_STEP_PORT[motor], MOTOR_STEP_PIN[motor]); motor_delay(delay/2); //need change GPIO_ToggleBits(MOTOR_STEP_PORT[motor], MOTOR_STEP_PIN[motor]); motor_delay(delay/2); motor_disable(motor); //disable to prevent controller overheating }
void motor_init() { unsigned long timer; //configure timer0 for one shot intervals and assign interrupt routine ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); ROM_TimerConfigure(TIMER0_BASE,TIMER_CFG_ONE_SHOT); ROM_TimerControlStall(TIMER0_BASE, TIMER_A, true); TimerIntRegister(TIMER0_BASE, TIMER_A, Timer0A_ISR); ROM_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); //setup RGB led outputs. ROM_SysCtlPeripheralEnable(LED_PERIPH); ROM_GPIOPinTypeGPIOOutput(LED_PORT, LED_R | LED_G | LED_B ); //enable peripherals used for motor ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //set motor pins to outputs ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, MOTOR_PORTA_PINS ); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, MOTOR_PORTB_PINS ); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, MOTOR_PORTD_PINS ); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, MOTOR_PORTE_PINS ); //make sure motors are disabled and step pins are low motor_disable(); motor_unstep(); //start the timer. the ISR will run at the minimum rate //interval until there is a block to execute. timer=calculate_timer(MIN_STEP_RATE); ROM_TimerLoadSet(TIMER0_BASE,TIMER_A, timer); ROM_TimerEnable(TIMER0_BASE,TIMER_A); }