You are on page 1of 1

*************************************************************************************

Psuedo-code for ShiftRegisterWrite service

SR_Write_Init
Parameters: CustomPin_t RCLKPin, CustomPin_t SCLKPin, CustomPin_t DataPin

Set DataPin low


Set SCLKPin low
Set RCLKPin high
End of SR_Write_Init

SR_GetCurrentRegister
Return LocalRegisterImage
End of SR_GetCurrentRegister

SR_Write
Parameters: uint8_t NewValue, CustomPin_t RCLKPin, CustomPin_t SCLKPin, CustomPin_t DataPin
Set LocalRegisterImage to NewValue
Lower the register clock
For every bit in NewValue
Set bit to the MSB of NewValue
If bit is 0
Lower the DataPin
Else
Raise the DataPin
EndIf
Raise SCLKPin
Lower SCLKPin
Get next bit of NewValue into MSB
EndFor
Raise the register clock to latch the new data
End of SR_Write
End of ShiftRegisterWrite

You might also like