0% found this document useful (0 votes)
118 views3 pages

Pseudocode Spi HSM

The document describes a state machine for a master state machine (MasterSM). It initializes SPI protocol and enables interrupts. It then starts the master state machine in the WaitingInSPI state. The master state machine switches between states - WaitingInSPI, Registering, Acknowledging, GetTeamInfo, TeamInfo, GetGameStatus, and GameStatus - based on timeout events and received data. It checks received data for errors and decodes messages correctly before transitioning to the next state.

Uploaded by

api-438120791
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views3 pages

Pseudocode Spi HSM

The document describes a state machine for a master state machine (MasterSM). It initializes SPI protocol and enables interrupts. It then starts the master state machine in the WaitingInSPI state. The master state machine switches between states - WaitingInSPI, Registering, Acknowledging, GetTeamInfo, TeamInfo, GetGameStatus, and GameStatus - based on timeout events and received data. It checks received data for errors and decodes messages correctly before transitioning to the next state.

Uploaded by

api-438120791
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

InitMasterSM

Initialize SPI protocol


Enable Global Interrupts
Start Timer to trigger action
Start MasterSM to be run with ES_ENTRY

RunMasterSM
switch Current State
case WaitinginSPI
CurrentEvent=DuringWaitinginSPI
If Current Event is ES_TIMEOUT, make Next State to Registering and trigger a one second timer, perform Exit
function for current state and entry function for next state

case Registering
CurrentEvent=DuringRegistering
If Current Event is ES_EOT, make Next State to Acknowledging, perform Exit function for current state and entry
function for next state
If Current Event is ES_ERROR, make Next State to Registering, perform Exit function for current state and entry
function for next state

case Acknowledging
CurrentEvent=DuringAcknowledging
If Current Event is ES_DECODED, make Next State to GetTeamInfo and trigger a one second timer, perform Exit
function for current state and entry function for next state
If Current Event is ES_ERROR, make Next State to Registering, perform Exit function for current state and entry
function for next state

case GetTeamInfo
CurrentEvent=DuringGTI
If Current Event is ES_EOT, make Next State to TeamInfo, perform Exit function for current state and entry
function for next state

case TeamInfo
CurrentEvent=DuringTI
If Current Event is ES_DECODED, make Next State to GetGameStatus and trigger a one second timer, perform Exit
function for current state and entry function for next state
If Current Event is ES_ERROR, make Next State to Registering, perform Exit function for current state and entry
function for next state

case GetGameStatus
CurrentEvent=DuringGGS
If Current Event is ES_EOT, make Next State to GameStatus, perform Exit function for current state and entry
function for next state

case GameStatus
CurrentEvent=DuringGS
If Current Event is ES_DECODED, make Next State to GetGameStatus and trigger a one second timer, perform Exit
function for current state and entry function for next state
If Current Event is ES_ERROR, make Next State to Registering, perform Exit function for current state and entry
function for next state

StartMasterSM
CurrentState to be made as Waiting in SPI
RunMasterSM to be run with CurrentEvent
DuringWaitinginSPI
-------

DuringRegistering
If Timeout is received, send registration bits at specified time intervals based on Team switch status

DuringAcknowledging
If ES_RECEIVED is received, check for correctness of received bytes
If received bytes is not in the right format, post ES_ERROR to service
If registration is successful, post ES_DECODED to service

DuringGetTeamINFO
If Timeout is received, send registration bits at specified time intervals based on Team switch status

DuringTeamINFO
If ES_RECEIVED is received, check for correctness of received bytes
If received bytes is not in the right format, post ES_ERROR to service
else, decode relevant messages and post ES_DECODED to service
DuringGetGameStatus
If Timeout is received, send registration bits at specified time intervals based on Team switch status

DuringGameStatus
If ES_RECEIVED is received, check for correctness of received bytes
If received bytes is not in the right format, post ES_ERROR to service
else, decode relevant messages and post ES_DECODED to service.
If Game has started, post ES_START to all services.
If Game ends, post ES_GAMEOVER to all services.

CommandGeneratorResponse
Clear the source of Interrupt
Read required number of data from the data register
Post ES_RECEIVED to Service

QueryWest
Return 1 if West Recycling accepts your ball, else return 0

QueryEast
Return 1 if East Recycling accepts your ball, else return 0

QueryColour
Return the colour of your ball

QueryFrequency
Return the frequency to activate recycling center

QueryTeam
Return Team

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy