/**************************************************************************** Module T_SendCommand.c Private Definitions CurrentState SpudCommand array SpudRead array index ES_Event_t RunSendCommand(ES_Event_t CurrentEvent) ---------------------- // default to normal entry to new state // based on our current state: // if current state is WaitingForTimeout // process any events // based on the event type: // if timeout for BYTE_TIMER times out // if index is 11, set it to 0 // Write to data register 3 times // set next state to WaitingForEOT // mark that we are taking a transition // consume this event for the upper state machines // if current state is WaitingForEOT // process any events // based on the event type: // if event is SPUD_EOT // clear interrput register // read data register 3 times // if index is 0 and game status has changed // Post PERMITSISSUED or PERMITSEXPIRED depending on what we read //Updated SpudRead array // Increment index // Start 2ms timer for BYTE_TIME // set next state to WaitingForTimeout // mark that we are taking a transition // consume this event for the upper state machines // if we are making a state transition // Execute exit function for current state // Modify state variable // Execute entry function for new state void StartSendCommand(ES_Event_t CurrentEvent) -------------------------- // to implement entry to a history state or directly to a substate // you can modify the initialization of the CurrentState variable // otherwise just start in the entry state every time the state machine // is started // call the entry function (if any) for the ENTRY_STATE SendCommandState_t QuerySendCommand(void) ----------------------------- // return CurrentState variable uint8_t GetReadSpud (uint8_t Register) -------------------------------- // return SpudRead with index of Register void EOT_ISR(void)---------------------------------------------------- // clear interrupt // Post 2 Master with SPUD_EOT void Spud_SPI_Init(void)----------------------------------------------- //Enable Port A //Enable the clock to the SSI Module //wait for clock // set alt function for PA2-5 //Set MUX position in GPIOPCTL protocol to select the SSI use of the pins //assign digital ports for A //set data direction (output) for A //Set idle high // pull up resistor on PA2 (clock) //wait for clock // Make sure that the SSI is disabled before programming mode bits //Select master mode MS and TXRIS indicating end of transmit (EOT) // Configure the SSI clock source to the system clock // Configure the clock prescaler //Configure clock rate (SCR) // phase, and polarity (SPH and SPO), data size (DDS) // set freescale SPI Mode // Make sure that the SSI is enabled for operation // Enable the NVIC interrupt for the SSI when starting to transmit // global enable uint8_t NumMinersPlaced(void)--------------------------------------------- // Get Neutral location 1 and 2 // if team is CKH // Get miner location 1 and 2 // if the spud reading for miner1 location is good // if the spud is in a valid mining region //increment number of miners placed // if the spud reading for miner 2 location is good // if the spud is in a valid mining region //increment number of miners placed //if team is GHI // Get miner location 1 and 2 // if the spud reading for miner1 location is good // if the spud is in a valid mining region //increment number of miners placed // if the spud reading for miner 2 location is good // if the spud is in a valid mining region //increment number of miners placed //return the number of miners placed static void WriteDataRegister(uint8_t data) --------------------------- //Write data to data register //clear interrupt