Professional Documents
Culture Documents
Call InitSSIHW
Move our state into Waiting
Initialize the SPUD timer
RunSPUDSM:
Switch on current state:
Waiting:
If this event is SendCommand
Disable the interrupt
Write the value of the address at the ReadIndex
to the SSIDR
Write 0x00 to SSIDR
Write 0x00 to SSIDR
Enable the interrupt
Change state to SendingBytes
End if
SendingBytes:
If this event is EOTReceived
Change state to Waiting4Timeout
End if
If the ErrorFlag is not up
Increment ReadIndex
If ReadIndex is at the maximum value
Set ReadIndex to 0
` End if
End if
Waiting4Timeout:
If this event is Timeout of the SPUD timer
Change state to Waiting
End if
End
If this event is Timeout of the SPUD timer
Post SendCommand to SPUDSM
End if
QuerySPUDSM:
Return state of SPUDSM
CheckSTATUS:
If CurrentByte is not equal to LastByte
If CurrentByte is 01
Post PermitsIssued to MasterSM and LEDService
Else if CurrentByte is 10 or 00
Post PermitsExpired to MasterSM and LEDService
End if
End if
Set LastByte to CurrentByte
CheckC1MLOC1:
If CurrentByte is not equal to LastByte
Post MINERLocationChanged with Param CurrentByte to Brains
End if
Set LastByte to CurrentByte
CheckC1MLOC2:
If CurrentByte is not equal to LastByte
Post MINERLocationChanged with Param CurrentByte to Brains
End if
Set LastByte to CurrentByte
CheckC2MLOC1:
If CurrentByte is not equal to LastByte
Post MINERLocationChanged with Param CurrentByte to Brains
End if
Set LastByte to CurrentByte
CheckC2MLOC2:
If CurrentByte is not equal to LastByte
Post MINERLocationChanged with Param CurrentByte to Brains
End if
Set LastByte to CurrentByte
CheckPUR1:
If CurrentByte is not equal to LastByte
Post ResourceLocationChanged with Param CurrentByte to
Brains
End if
Set LastByte to CurrentByte
CheckPUR2:
If CurrentByte is not equal to LastByte
Post ResourceLocationChanged with Param CurrentByte to
Brains
End if
Set LastByte to CurrentByte
QuerySTATUS:
Return value of the STATUS register
QueryC1MLOC1:
If C1MLOC1 is known
Return value of the C1MLOC1 register plus 1
Else
Return 0x00
End if
QueryC1MLOC2:
If C1MLOC2 is known
Return value of the C1MLOC2 register plus 1
Else
Return 0x00
End if
QueryC2MLOC1:
If C2MLOC1 is known
Return value of the C2MLOC1 register plus 1
Else
Return 0x00
End if
QueryC2MLOC2:
If C2MLOC2 is known
Return value of the C2MLOC2 register plus 1
Else
Return 0x00
End if
QueryC1RES:
Return value of C1RESH and C1RESL
QueryC2RES:
Return value of C2RESH and C2RESL
QueryPUR1:
Return value of PUR1
QueryPUR2:
Return value of PUR2
InitSSIHW:
Enable the clock to the GPIO port A
Enable the clock to the SSI module
Wait for GPIO port A to be ready
Program the PGIO to use the alternate functions to the SSI pins
Set mux position in GPIOCTL to select SSI use of the pins
Program the port lines for digital I/O
Program the required data directions on the port lines (Output
for Clk, Fss, and Tx, Input for Rx)
Program the pull up on the clock line
Wait for the SSI0 to be ready
Disable the SSI before programming mode bits
Select master mode (MS) and TXRIS indicating End of Transmit
Configure the SSI clock source to the system clock
Configure the clock prescalar to 24
Configure SCR to 110, SPH, SPO, FRF, DSS
Locally enable interrupts
Enable the SSI for operation
Enable the NVIC interrupt for SSI
Enable the interrupts globally
SPUDISR:
Disable the interrupt
Read all 3 bytes from the SD0 pin
Check for errors in Byte1 and Byte2
If there is an error
Set ErrorFlag to true
Else
Set ErrorFlag to false
End if
Initialize the SPUD timer
Post EOTReceived to SPUDSM