void GetRotationalSpeeds (void) { //Calculate 'rotational speed' if (!(PCA0CPM0 & 0x01)) { //if the CCF0 interrupt is disabled, //the corresponding rotational speed can be calculated if(DIR1B1==1 && DIR1B0==0) { //Rotating Direction Information from CPLD //Rotating Direction Motor1: Counter-Clockwise MeasuredRotationalSpeed[M1] = -RPS(PCA0CP0_Count2.U32 - PCA0CP0_Count1.U32); } else if(DIR1B1==0 && DIR1B0==1){ //Rotating Direction Motor1: Clockwise MeasuredRotationalSpeed[M1] = RPS(PCA0CP0_Count2.U32 - PCA0CP0_Count1.U32); } } else { MeasuredRotationalSpeed[M1] = 0.0; //v = v2 + v2 - v1; } //v1 = v2; //v2 = v; if (!(PCA0CPM1 & 0x01)) { //if the CCF1 interrupt is disabled, //the corresponding rotational speed can be calculated if(DIR2B1==1 && DIR2B0==0) { //Rotating Direction Information from CPLD //Rotating Direction Motor2: Counter-Clockwise MeasuredRotationalSpeed[M2] = -RPS(PCA0CP1_Count2.U32 - PCA0CP1_Count1.U32); } else if(DIR2B1==0 && DIR2B0==1){ //Rotating Direction Motor2: Clockwise MeasuredRotationalSpeed[M2] = RPS(PCA0CP1_Count2.U32 - PCA0CP1_Count1.U32); } } else MeasuredRotationalSpeed[M2] = 0.0; if (!(PCA0CPM2 & 0x01)) { //if the CCF2 interrupt is disabled, //the corresponding rotational speed can be calculated if(DIR3B1==1 && DIR3B0==0) { //Rotating Direction Information from CPLD //Rotating Direction Motor3: Counter-Clockwise MeasuredRotationalSpeed[M3] = -RPS(PCA0CP2_Count2.U32 - PCA0CP2_Count1.U32); } else if(DIR3B1==0 && DIR3B0==1){ //Rotating Direction Motor3: Clockwise MeasuredRotationalSpeed[M3] = RPS(PCA0CP2_Count2.U32 - PCA0CP2_Count1.U32); } } else MeasuredRotationalSpeed[M3] = 0.0; }
int main(void) { enum Choice{ /* nothing = 0, playRPS = 1, playRPSLS = 2, SeeRules = 3, Exit = 4 */ nothing, playRPS, playRPSLS, SeeRules, Exit }; int Selection; Selection = nothing; do{ /*loop until user exits*/ printf("\nMAIN MENU: \nWhat would like to play?\n To play Rock/Paper/Scissors enter 1 \n To play Rock/Paper/Scsissors/Lizard/Spock enter 2 \n To see the rules enter 3 \n To Exit enter 4 \n Total Score = %i\nEnter Value: ", TotalScore); scanf("%i", &Selection); switch (Selection){ case playRPS: RPS(); break; case playRPSLS: RPSLS(); break; case SeeRules: Rules(); break; case Exit: break; default: printf("\n Enter one of the listed values. \n"); } }while(Selection != Exit); return 0; }