Professional Documents
Culture Documents
This state machine/service controls the adafruit using the shift register and
also performs low level shift register operations.
The other services would post to this function for sound effect with an
EventParam which will decide which sound pin to play.
Would also include the function to stop the sound
InitSoundSM
Initializes hardware pins:
Port A5 as Data
A6 as SCLK
A7 as RCLK
All are digital outputs for shift register
Sets Data and SCLK low
Sets RCLK High
Initializes Service
PostSoundSM
Posts to State Machine received event with priority
RunSoundSM
if Event is SOUND_STOP(ThisEvent.EventType == SOUND_STOP)
Writes all High output values for Sound Shift Register
if Event is SOUND_PLAY
Reads and Selects from Event.Param
If Event.Param case is 0:
Writes bit 0 Lo in Sound Shift Register
If Event.Param case is 1:
Writes bit 1 Lo in Sound Shift Register
If Event.Param case is 2:
Writes bit 2 Lo in Sound Shift Register
If Event.Param case is 3:
Writes bit 3 Lo in Sound Shift Register
If Event.Param case is 4:
Writes bit 4 Lo in Sound Shift Register
//******************************************HELPER
FUNCTIONS******************************************
// This function writes to the shift register given the value recieved
SR_Sound_Write