Documente Academic
Documente Profesional
Documente Cultură
DuringWait2Send
DuringSPISendByte
InitHW4SPI
ReadFromREF
WriteToREF
DecodeGameState
PrintCurrentCommand
InitREFCommSM
init MyPriority using the passed-in parameter
init hardware for SPI
PostREFCommSM
Post an event to service with saved priority
End of PostREFCommSM
RunREFCommSM
set MakeTransition to false
Set NextState to CurrentState;
default to normal entry to new state
assume no error
StartREFCommSM
if there is more than 1 state to the top level machine you will need
to initialize the state variable
init CurrentState to Wait2Send
now we need to let the Run function init the lower level state machines
use LocalEvent to keep the compiler from complaining about unused var
End of StartREFCommSM
EOTISR
Disable interrupt
read received bytes from REF
post SSI_EOT event to REFCommSM to handle it
End of EOTISR
/***************************************************************************
private functions
***************************************************************************/
DuringWait2Send
assme no re-mapping or comsumption
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringWait2Send
DuringSPISendByte
assme no re-mapping or comsumption
return either Event, if you don't want to allow the lower level machine
to remap the current event, or ReturnEvent if you do want to allow it.
End of DuringSPISendByte
InitHW4SPI
Enable the clock to the GPIO port (PA 2-5)
Enable the clock to SSI module (SSI Module 0 Run Mode Clock)
Wait for the GPIO port to be ready
Program the GPIO to use the alternate functions on the SSI pins
Set mux position in GPIOPCTL to select the SSI use of the pins
Program the Port A lines for digital I/O
If using SPI mode 3, program the pull-up on the clock line (PA2)
Wait for the SSI0 to be ready
Make sure that the SSI is disabled before programming mode bits
Select master mode (MS) & TXRIS indicating End of Transmit (EOT)
Configure the SSI clock source to the system clock
Configure the clock pre-scaler to get 14KHz frequency (max: 961kHz)
Configure clock rate (SCR), phase & polarity (SPH, SPO), mode (FRF), data
size (DSS)
freescale SPI Frame Format
data size is 8 bits
Locally enable interrupts (TXIM in SSIIM)
Make sure that the SSI is enabled for operation
Enable globally
End of InitHW4SPI
ReadFromREF
read four bytes from SSI data register into CurrentGameState[4]
End of ReadFromREF
WriteToREF
write four bytes in QueryCommand into SSI data register
End of WriteToREF
DecodeGameState
create a new event with event type as ES_NO_EVENT