You are on page 1of 1

Pseudo-code for the VibrationService module (a service)

Data private to the module: MyPriority

Functions private to the module: nothing

InitVibrationService
Takes a priority number, returns True.

Initialize the MyPriority variable with the passed in parameter.

Setup PortB, Pin 15 for digital output

Post Event ES_Init to this service

End of InitVibrationService

PostVibrationService
Takes an ES_Event_t, returns nothing

Call ES_PostToService with MyPriority and ThisEvent

End of PostVibrationService

RunVibrationService
The EventType field of ThisEvent will be one of: HAPTIC_ON,
HAPTIC_OFF

ThisEvent is HAPTIC_ON
Set LAT bit on B15 to high
End of HAPTIC_ON block

ThisEvent is HAPTIC_OFF
Set LAT bit on B15 to low
End of HAPTIC_OFF block

Return ES_NO_EVENT
End of RunVibrationService

You might also like