/**************************************************************************** Function InitMainXBSM Parameters uint8_t Priority Returns boolean, False if error in initialization, True otherwise Description Saves away the priority assigned to this service and posts an ES_INT event to this state machine Notes Author J. Edward Carryer, 01/26/12, 17:42 ****************************************************************************/ boolean InitMainXBSM ( uint8_t Priority ) { ES_Event ThisEvent; InitializePins(); MyPriority = Priority; // put us into the Initial PseudoState CurrentState = InitPState; // post the initial transition event ThisEvent.EventType = ES_INIT; if (ES_PostToService( MyPriority, ThisEvent) == True) { return True; }else { return False; } }
void UnitTest(){ GPIOPins_t GPIO_pins; unsigned int initOutputPinValues[NUM_OUTPUT_PINS] = {HIGH, HIGH, HIGH, HIGH}; printf("STARTING UNIT TEST\n"); InitializePins(&GPIO_pins, initOutputPinValues); if(DEBUG_STATEMENTS_ON) printf("Pin initialization complete \n"); if(DEBUG_STATEMENTS_ON) DisplayAllPins(GPIO_pins); char userInput = 'N'; while(userInput != 'Y' && userInput != 'y'){ printf("Please connect input pin GPI0 to 3.3 Volts, then type 'Y' and hit enter to continue...\n"); userInput = getchar(); }//END WHILE LOOP assert(ReadInputPinState(&GPIO_pins, GPI0) == HIGH); assert(ReadInputPinState(&GPIO_pins, GPI1) == LOW); assert(ReadInputPinState(&GPIO_pins, GPI2) == LOW); assert(ReadInputPinState(&GPIO_pins, GPI3) == LOW); if(DEBUG_STATEMENTS_ON) DisplayAllPins(GPIO_pins); assert(GPIO_pins.pinValue[0] == HIGH); assert(GPIO_pins.pinValue[1] == LOW); assert(GPIO_pins.pinValue[2] == LOW); assert(GPIO_pins.pinValue[3] == LOW); assert(GPIO_pins.pinValue[4] == HIGH); assert(GPIO_pins.pinValue[5] == HIGH); assert(GPIO_pins.pinValue[6] == HIGH); assert(GPIO_pins.pinValue[7] == HIGH); userInput = 'N'; while(userInput != 'Y' && userInput != 'y'){ userInput = getchar(); //Grab extra carriage return character from first user input printf("Please connect input pin GPI1 to 3.3 Volts, then type 'Y' and hit enter to continue...\n"); userInput = getchar(); //Grab "Is GPI1 connected to 3.3V?" user input }//END WHILE LOOP assert(ReadInputPinState(&GPIO_pins, GPI0) == LOW); assert(ReadInputPinState(&GPIO_pins, GPI1) == HIGH); assert(ReadInputPinState(&GPIO_pins, GPI2) == LOW); assert(ReadInputPinState(&GPIO_pins, GPI3) == LOW); for(int k = NUM_GPIO_PINS/2; k < NUM_GPIO_PINS; k++){ WriteOutputPinState(&GPIO_pins, GPIO_pins.pinName[k], LOW); } if(DEBUG_STATEMENTS_ON) DisplayAllPins(GPIO_pins); assert(GPIO_pins.pinValue[0] == LOW); assert(GPIO_pins.pinValue[1] == HIGH); assert(GPIO_pins.pinValue[2] == LOW); assert(GPIO_pins.pinValue[3] == LOW); assert(GPIO_pins.pinValue[4] == LOW); assert(GPIO_pins.pinValue[5] == LOW); assert(GPIO_pins.pinValue[6] == LOW); assert(GPIO_pins.pinValue[7] == LOW); printf("Unit Test successful. Visit www.spacevr.co/preorder and #BeAnAstronaut today!\n"); }