// intialize io objects void initialize_pins(){ left_motor = InitializeServoMotor(left_motor_pin, false); right_motor = InitializeServoMotor(right_motor_pin, true); //in_motor = InitializeServoMotor(in_motor_pin, true); //brush_motor = InitializeServoMotor(brush_motor_pin, true); //release_servo = InitializeServo(release_servo_pin); side_ir_sensor = InitializeADC(side_ir_sensor_pin); front_ir_sensor = InitializeADC(front_ir_sensor_pin); goal_ir_sensor = InitializeADC(goal_ir_sensor_pin); }
void initIRSensor(void) { // don't initialize this if we've already done so if (initialized) { return; } initialized = true; // initialize 4 pins to be used for ADC input adc[0] = InitializeADC(PIN_E4); // Left IR adc[1] = InitializeADC(PIN_D3); // Front IR adc[2] = InitializeADC(PIN_E5); // Right IR }
int main() { // Set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); //Initialize peripherals InitializeDisplay(); InitializeTimers(); InitializeADC(); InitializeInterrupts(); //Main program loop unsigned long avgADCValue = 0; while(1) { if(BufOneReadyToRead) { avgADCValue = GetAvgOfBuf(1); usnprintf(str, 25, "Buf1: %5u", avgADCValue); RIT128x96x4StringDraw(str, 0, 0, 15); BufOneReadyToRead = 0; } else if(BufTwoReadyToRead) { avgADCValue = GetAvgOfBuf(2); usnprintf(str, 25, "Buf2: %5u", avgADCValue); RIT128x96x4StringDraw(str, 0, 10, 15); BufTwoReadyToRead = 0; } } }
//-----------------------Public functions------------------------------// void InitializeSharp() { //-------------HARDWARE-------------// InitializeRCC( DriverSelectSharp ); InitializeGPIO( DriverSelectSharp ); InitializeADC( DriverSelectSharp ); //-------------SOFTWARE-------------// priv_MeanBufferInitialize(); oSharp.Perform = pub_Perform; }
//-----------------------Public functions------------------------------// void InitializeBattery() { //-------------HARDWARE-------------// InitializeRCC( DriverSelectBattery ); InitializeGPIO( DriverSelectBattery ); InitializeADC( DriverSelectBattery ); //-------------SOFTWARE-------------// priv_MeanBufferInitialize(); oBattery.Perform = pub_Perform; oBattery.AdjustPwm = pub_AdjustPwm; oBattery.IsDischarged = pub_IsDischarged; }
//Initializes motors and IR Sebsors void initMotorsSensors(void) { if (!initialized) { initialized = true; Motors[0] = InitializeServoMotor(PIN_B6, false); Motors[1] = InitializeServoMotor(PIN_B7, false); Motors[2] = InitializeServoMotor(PIN_C4, false); Motors[3] = InitializeServoMotor(PIN_C5, false); marservo = InitializeServo(PIN_B2); pingservo = InitializeServo(PIN_F3); SetServo(marservo,0.1f); SetServo(pingservo,0.1f); GPIOPadConfigSet(PORT_VAL(PIN_B6), PIN_VAL(PIN_B6), GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPadConfigSet(PORT_VAL(PIN_B7), PIN_VAL(PIN_B7), GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPadConfigSet(PORT_VAL(PIN_C4), PIN_VAL(PIN_C4), GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPadConfigSet(PORT_VAL(PIN_C5), PIN_VAL(PIN_C5), GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); adc[0] = InitializeADC(PIN_D0); adc[1] = InitializeADC(PIN_D1); adc[2] = InitializeADC(PIN_D2); adc[3] = InitializeADC(PIN_D3); turn=0; gls = InitializeGPIOLineSensor( PIN_B5, PIN_B0, PIN_B1, PIN_E4, PIN_E5, PIN_B4, PIN_A5, PIN_A6 ); } }
void initIRSensor(void) { adc[0] = InitializeADC(PIN_D0); adc[1] = InitializeADC(PIN_D1); adc[2] = InitializeADC(PIN_D2); adc[3] = InitializeADC(PIN_D3); }
void initIRSensor(void) { adc[0] = InitializeADC(PIN_E5); adc[1] = InitializeADC(PIN_E4); adc[2] = InitializeADC(PIN_B4); }