Exemplo n.º 1
0
void InitilizeBcsIoSetmode(boolean (*setChanelModeHWPtrLocal)(uint8_t  ,uint8_t)){
	if(setChanelModeHWPtrLocal == NULL){
		setPrintLevelErrorPrint();
		//println_E("Failed IO.SETMODE sanity check: initialization");
		while(1);
	}
	setChanelModeHWPtr = setChanelModeHWPtrLocal;
}
DATA_STRUCT * getBcsIoDataTable(){
	if(dataPtr==NULL){
		setPrintLevelErrorPrint();
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644PA__) && !defined(__AVR_ATmega324P__)
		println_E("Failed IO sanity check: no data table");
#endif
		//println_E("Failed IO sanity check: no data table");
		//FAIL sanity check
		while(1);
	}
	return dataPtr;
}
BYTE GetChannelMode(BYTE chan){
	if(chan<0 || chan>GetNumberOfIOChannels()){
		setPrintLevelErrorPrint();
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644PA__) && !defined(__AVR_ATmega324P__)
		println_E("Failed IO sanity check: channel number out of bounds # ");p_int_E(chan);
#endif
		//FAIL sanity check
		while(1);
	}
	//Strip off the internally stored High Bit
	return getBcsIoDataTable()[chan].PIN.currentChannelMode ;
}
Exemplo n.º 4
0
int main(){
    //setPrintLevelInfoPrint();
    setPrintLevelWarningPrint();
    //setPrintLevelNoPrint();
    hardwareInit();
    RunEveryData loop = {0.0,2000.0};

    while(1){
        if (_RF5==1){
            setPrintLevelErrorPrint();
		p_int_E(0);print_E(" Reset Button Pressed from loop");
		SetColor(1,1,1);
		U1CON = 0x0000;
		DelayMs(100);
		Reset();
	}
        if(RunEvery(&loop)>0){
//            clearPrint();
//            printCartesianData();

        }
        if(     printCalibrations == false &&
                GetPIDCalibrateionState(linkToHWIndex(0))==CALIBRARTION_DONE&&
                GetPIDCalibrateionState(linkToHWIndex(1))==CALIBRARTION_DONE&&
                GetPIDCalibrateionState(linkToHWIndex(2))==CALIBRARTION_DONE

                ){
            printCalibrations = true; 
            int index=0;
            for(index=0;index<3;index++){
                int group = linkToHWIndex(index);
                println_E("For Axis ");p_int_E(group);
                print_E(" upper: ");p_int_E(getPidGroupDataTable(group)->config.upperHistoresis);
                print_E(" lower: ");p_int_E(getPidGroupDataTable(group)->config.lowerHistoresis);
                print_E(" stop: ");p_int_E(getPidGroupDataTable(group)->config.stop);
            }
            startHomingLinks();
            //Print_Level l= getPrintLevel();

            //setPrintLevelInfoPrint();
            printCartesianData();
            int i;
            for(i=0;i<numPidMotors;i++){
                printPIDvals(i);
            }
            //setPrintLevel(l);
        }
        
        bowlerSystem();
    }
}
Exemplo n.º 5
0
boolean setUpNextServo(){

    int diff = positionTemp[sort[sortedIndex]] - lastValue;
    lastValue = positionTemp[sort[sortedIndex]];
    if(diff<0){
        setPrintLevelErrorPrint();
        println_E("Servo.c: Something is wrong!! Current minus last value is less then 0");
        while(1);
    }

    if(diff>MIN_SERVO){
        setTimerServoTicks(diff);
        return true; 
    }
    //Fall through for pin shut off
    servoStateMachineCurrentState = TIME;
    return false; 
}
void InitilizeBcsIo(int numPins,
					DATA_STRUCT * dataPtrLocal,
					BOOL (*setChanelValueHWPtrLocal)(BYTE,BYTE,INT32 *,float),
					BOOL (*getChanelValueHWPtrLocal)(BYTE,BYTE*,INT32 *),
					BOOL (*setAllChanelValueHWPtrLocal)(INT32 *,float),
					BOOL (*getAllChanelValueHWPtrLocal)(INT32 *),
					BOOL (*configChannelHWPtrLocal)(BYTE,BYTE,INT32 *)
){
	if(numPins < 1
	){
		setPrintLevelErrorPrint();
		println_E("Failed IO sanity check: failed initialization channels #");p_int_E(numPins);
		//println_E("Failed IO sanity check: failed initialization channels #");p_int_E(numPins);
		//FAIL sanity check
		while(1);
	}
	if(
			dataPtrLocal==NULL
		){
			setPrintLevelErrorPrint();
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644PA__) && !defined(__AVR_ATmega324P__)
			println_E("Failed IO sanity check: failed initialization dataPtrLocal");
#endif
			//println_E("Failed IO sanity check: failed initialization dataPtrLocal");
			//FAIL sanity check
			while(1);
		}
	if(
			setChanelValueHWPtrLocal==NULL
		){
			setPrintLevelErrorPrint();
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644PA__) && !defined(__AVR_ATmega324P__)
			println_E("Failed IO sanity check: failed initialization setChanelValueHWPtrLocal");
#endif
			//println_E("Failed IO sanity check: failed initialization setChanelValueHWPtrLocal");
			//FAIL sanity check
			while(1);
		}
	if(
			getChanelValueHWPtrLocal==NULL
		){
			setPrintLevelErrorPrint();
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644PA__) && !defined(__AVR_ATmega324P__)
			println_E("Failed IO sanity check: failed initialization getChanelValueHWPtrLocal");
#endif
			//println_E("Failed IO sanity check: failed initialization getChanelValueHWPtrLocal");
			//FAIL sanity check
			while(1);
		}
	if(
			setAllChanelValueHWPtrLocal==NULL
		){
			setPrintLevelErrorPrint();
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644PA__) && !defined(__AVR_ATmega324P__)
			println_E("Failed IO sanity check: failed initialization setAllChanelValueHWPtrLocal");
#endif
			//println_E("Failed IO sanity check: failed initialization setAllChanelValueHWPtrLocal");
			//FAIL sanity check
			while(1);
		}
	if(
			getAllChanelValueHWPtrLocal==NULL
		){
			setPrintLevelErrorPrint();
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644PA__) && !defined(__AVR_ATmega324P__)
			println_E("Failed IO sanity check: failed initialization getAllChanelValueHWPtrLocal");
#endif
			//println_E("Failed IO sanity check: failed initialization getAllChanelValueHWPtrLocal");
			//FAIL sanity check
			while(1);
		}
	if(
			configChannelHWPtrLocal==NULL
		){
			setPrintLevelErrorPrint();
#if !defined(__AVR_ATmega644P__) && !defined(__AVR_ATmega644PA__) && !defined(__AVR_ATmega324P__)
			println_E("Failed IO sanity check: failed initialization configChannelHWPtrLocal");
#endif
			//println_E("Failed IO sanity check: failed initialization configChannelHWPtrLocal");
			//FAIL sanity check
			while(1);

		}

	NumberOfIOChannels = numPins;
	dataPtr = dataPtrLocal;
	setChanelValueHWPtr=setChanelValueHWPtrLocal;
	getChanelValueHWPtr=getChanelValueHWPtrLocal;
	setAllChanelValueHWPtr=setAllChanelValueHWPtrLocal;
	getAllChanelValueHWPtr=getAllChanelValueHWPtrLocal;
	configChannelHWPtr=configChannelHWPtrLocal;
}