Timingmotor Final
Timingmotor Final
InitTimingMotor
Parameters:
priority number of this service
Returns:
success/failure
Local Variables: Pseudo-code:
Takes a priority number, returns True
Initialize the PWM port
Initialize the period of the timing motor
Set the CurrentState to InitTM
Enable the port and the pin for the vibration motor
Make pin digital and output
Post Event ES_INIT to TimingMotor queue
PostTimingMotor
Parameters:
Returns:
Local Variables: Pseudo-code:
ES_PostToService
Return success/failure
RunTimingMotorSM
Parameters:
ThisEvent
Event we are handling
Returns:
ReturnEvent ES_NO_EVENT if no errors
Local Variables: ReturnEvent ES_Event to return (ES_NO_EVENT if no errors)
Pseudo-code:
Switch CurrentState
CurrentState is InitTM
Put motor into initial position
Put vibration motor initially off
Set CurrentState to WaitForStart
CurrentState is WaitForStart
IF ThisEvent is WAITING
Set the position of the motor to the max position
Set the timing motor timer for one second
ELSE IF ThisEvent is RESET
Set PulseWidth to initial value of pulse width
Set the motor to PulseWidth
Stop the current timer
Set CurrentState to timing