Académique Documents
Professionnel Documents
Culture Documents
This service keeps track of each shift register output and its PWM signal
MODULE VARIABLES
MyPriority
SRStrings
CurrPulseWidth
DelayTime
ES_Framework priority
Array of our shift register strings
Array of the pulse widths on every output we're running
Minimum delay time between shift register updates
Init_SRPWMService
Parameters:
priority number
Returns:
success/failure
Local Variables: Pseudo-code:
Initialize the shift register hardware
Initialize short timer and start if off counting
Return success
Post_SRPWMService
Parameters:
Returns:
Local Variables: Pseudo-code:
ES_PostToService
Return success/failure
Run_SRPWMService
Parameters:
Returns:
Local Variables:
ThisEvent
ReturnEvent
ReturnEvent
PW_ctr
val
PW_idx
NewPW
Pseudo-code:
Switch ThisEvent
ThisEvent is an ES_SHORT_TIMEOUT...
FOR EACH of our shift register strings
FOR EACH of the shift registers in this shift register string
FOR EACH of the outputs in this shift register
Check CurrPulseWidth at this output at this tick (PW_ctr)
Set val at this output LOW or HIGH accordingly
END FOR
Write to shift register
Reset value to be written next time
END FOR
Post to current shift register string
END FOR
Increment PW_ctr modulo MAX_PULSE_WIDTH
PulseWidth
OutputPin
-
Returns:
Local Variables:
Pseudo-code:
Set the current pulse width of OutputPin to PulseWidth
SRPWM_HWInit
Parameters:
Returns:
Local Variables: Pseudo-code:
Initialize the shift register hardware
SRPWM_GetPW
Parameters:
PW_idx
Index of output pin we want to poll for its pulse width
Returns:
uint8_t
The value of the current pulse width at PW_idx
Local Variables: Pseudo-code:
IF PW_idx is not valid
Do nothing
Return 0
END IF
Return the current pulse width at PW_idx
Encode_Idx_PW
Parameters:
PW
PW_idx
uint16_t
-
Returns:
Local Variables:
Pseudo-code:
Shift PW_idx left 8 bits
Logical OR PW and PW_idx
Return the result
ExtractIdx_PW
Parameters:
Param
An event parameter to decode
Returns:
uint8_t
Output pin index extracted from Param
Local Variables: ReturnVal
Holds the decoded value
Pseudo-code:
Return the 8 most significant bits of Param
ExtractIdx_PW
Parameters:
Param
An event parameter to decode
Returns:
uint8_t
Pulse width value extracted from Param
Local Variables: ReturnVal
Holds the decoded value
Pseudo-code:
Return the 8 least significant bits of Param