Psuedoshiftregread

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

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

Psuedo-code for ShiftRegisterRead service

SR_Read_Init
Parameters: CustomPin_t LoadPin, CustomPin_t CLKPin, CustomPin_t DataPin

Set DataPin low


Set CLKPin low
Set LoadPin high
End of SR_Read_Init

SR_Read_GetCurrentRegister
Return LocalRegisterImage
End of SR_Read_GetCurrentRegister

SR_Read
Parameters: CustomPin_t LoadPin, CustomPin_t CLKPin, CustomPin_t DataPin
Local Variable: uint8_t Input
Set Input to 0
Lower the load bit to put values into Qn registers
Pulse the clock high then low to shift the next data bit
Raise the load bit to no longer read values into Qn registers

For each bit in Input


Get next Input bit into MSB
Sample DataPin and set to NewData
If NewData is not 0
Set Input’s lowest bit to 1
EndIf
Pulse the clock line high then low to shift next data bit
EndFor
Return Input
End of SR_Read

You might also like