void setupServos(void) { // PA2 & PA3 ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_2|GPIO_PIN_3); // Zero out configs servoInit(); // Bind pads to servo configs servo = servoAttach(GPIO_PORTA_BASE, GPIO_PIN_2); servo2 = servoAttach(GPIO_PORTA_BASE, GPIO_PIN_3); // Start the servo timers servoStart(); }
/* * @Brief: Initializes the servo peripheral * @param uint8_t servoNumber * @param uint8_t config * @return nothing * @IMPORTANT: this function uses Timer 1, 2 and 3 to generate the servo signals, so * they won't be available to use. */ bool_t servoConfig( uint8_t servoNumber, uint8_t config ){ bool_t ret_val = 1; switch(config){ case ENABLE_SERVO_TIMERS: servoInitTimers(); break; case DISABLE_SERVO_TIMERS: ret_val = 0; break; case ENABLE_SERVO_OUTPUT: ret_val = servoAttach( servoNumber ); break; case DISABLE_SERVO_OUTPUT: ret_val = servoDetach( servoNumber ); break; default: ret_val = 0; break; } return ret_val; }