Example #1
0
// Set Pin value as a boolean
void SetPin(tPin pin, tBoolean val) {
    // Setting pin direction is just a bit set and fairly trivial
    GPIOPinTypeGPIOOutput(PORT_VAL(pin), PIN_VAL(pin));
    
    // Set the actual pin value
    GPIOPinWrite(PORT_VAL(pin), PIN_VAL(pin), val ? 0xff : 0x00);
}
Example #2
0
// Get Pin value as a boolean
tBoolean GetPin(tPin pin) {
    // Setting pin direction is just a bit set and fairly trivial
    GPIOPinTypeGPIOInput(PORT_VAL(pin), PIN_VAL(pin));
    
    // Get the actual pin value
    return GPIOPinRead(PORT_VAL(pin), PIN_VAL(pin)) ? true : false;
}
Example #3
0
// Function to initialize pwm on a pin
// The returned pointer can be used by the SetPWM function
// Frequency must be specified in hertz
// If the number of frequencies passes the number of available
// modules, which is currently 12, then a null pointer is returned
tPWM *InitializePWM(tPin pin, float freq) {
    tPWMModule *mod;
    tPWM *pwm;
    int i;
    
    // Grab the next pwm
    pwm = &pwmBuffer[pwmCount++];
    
    // Setup the pwm events
    pwm->up.state = 0xff;
    pwm->down.state = 0x00;
    
    // Setup the pin
    GPIOPinTypeGPIOOutput(PORT_VAL(pin), PIN_VAL(pin));
    pwm->up.pin = pin;
    pwm->down.pin = pin;
    
    // Calculate period
    pwm->period = (unsigned long)(SysCtlClockGet() / freq);
    
    // Find a module with the given frequency
    for (i = 0; i < PWM_MODULE_COUNT; i++) {
        
        // If we don't find a module we need to make a new one
        if (i == modCount) {
            // Grab the next module
            mod = &modBuffer[modCount++];

            // Initialize
            InitializePWMModule(mod, pwm);
            
            // Return the running pwm
            return pwm;
        }
        
        // If we find a module with the period we're looking for, 
        // stick our pwm in it
        if (modBuffer[i].period == pwm->period) {
            // Grab the module
            mod = &modBuffer[i];
            
            // Add the new signal to the running ones
            InsertPWM(mod, pwm);
            
            // Return the running pwm
            return pwm;
        }
    }
    
    // If no module is available, we put the pwm back and 
    // just return a null for failure
    pwmCount--;
    return 0;
}
Example #4
0
// Internally used function to register a pin interrupt
static void CallOnPinType(tCallback callback, void *data, tPin pin, unsigned long type) {
    tPinTask *task = &pinTaskBuffer[pin];

    // Stop the interrupt first to avoid a race condition
    GPIOPinIntDisable(PORT_VAL(pin), PIN_VAL(pin));
    task->callback = Dummy;
    
    // Make sure the pin is setup as an input
    GPIOPinTypeGPIOInput(PORT_VAL(pin), PIN_VAL(pin));
    
    // If a null pointer is passed then we just leave the Dummy
    // to unregister the callback
    if (callback) {
        task->data = data;
        task->callback = callback;
        
        // Setup the interrupts
        GPIOIntTypeSet(PORT_VAL(pin), PIN_VAL(pin), type);
        GPIOPinIntClear(PORT_VAL(pin), PIN_VAL(pin));
        GPIOPinIntEnable(PORT_VAL(pin), PIN_VAL(pin));
    }
}
Example #5
0
File: Main.c Project: jkcooley/HHHR
//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
        );
    }
}
Example #6
0
// Add a weak pull down resistor to the pin
void PullDownPin(tPin pin) {
    GPIOPadConfigSet(PORT_VAL(pin), PIN_VAL(pin), 
                     GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD);
}
Example #7
0
// Set a pin into high impedance mode
void SetPinZ(tPin pin) {
    // Setting pin direction to input places it in high impedance mode
    GPIOPinTypeGPIOInput(PORT_VAL(pin), PIN_VAL(pin));
}