-- -- file : shiftOut.jal -- author : special [k] -- date : 28-JAN-2004 -- purpose : Shift out data -- pins : Defined below -- -- Copyright (C) 2004 special [k] -- -- This library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Library General Public -- License as published by the Free Software Foundation; either -- version 2 of the License, or (at your option) any later version. -- -- This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Library General Public License for more details. -- -- You should have received a copy of the GNU Library General Public -- License along with this library; if not, write to the -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- Boston, MA 02111-1307, USA. -- -- -------------------------------------------------------------------------------- -- shiftOut(extOutClock, theOutMode, theOutData) -- If extOutClock = low and theOutMode = high then shift out theData LSB first -- If extOutClock = low and theOutMode = low then shift out theData MSB first -- If extOutClock = high and theOutMode = high then shift out theData LSB first after clock pulse starts -- If extOutClock = high and theOutMode = low then shift out theData MSB first after clock pulse starts -- -------------------------------------------------------------------------------- -- How data is output: -- -- -- ex. shiftOut(low, high, 155) -- 155 = 0b10011011 -- -- 5V --- --- --- --- --- --- --- --- -- CLK | | | | | | | | | | | | | | | | -- 0V ------ --- --- --- --- --- --- --- ------ -- 5V ----- ----- ----- ----- ----- -- DATA | | | | | | | | | | -- 0V ----- - --------- - ----------------- ----- -- -- -- ex. shiftOut(high, high, 155) -- 155 = 0b10011011 -- -- 5V --- --- --- --- --- --- --- --- -- CLK | | | | | | | | | | | | | | | | -- 0V ------ --- --- --- --- --- --- --- ------ -- 5V -------------- -------------- --------- -- DATA | | | | | -- 0V ------- ------- ---------------- -- -- -------------------------------------------------------------------------------- procedure _shiftOutDelay is -- delay_100mS(5) end procedure var volatile bit shiftOutClk is gp4 var volatile bit shiftOutClkDir is gp4_direction var volatile bit shiftOutData is gp5 var volatile bit shiftOutDataDir is gp5_direction procedure shiftOut( bit in extOutClock, bit in theOutMode, byte in theOutData ) is shiftOutData = low shiftOutDataDir = output if extOutClock then shiftOutClk = low shiftOutClkDir = input if theOutMode then -- LSB first var bit dataBit at theOutData : 0 for 8 loop while ! shiftOutClk loop end loop shiftOutData = dataBit theOutData = theOutData >> 1 while shiftOutClk loop end loop end loop else -- MSB first var bit dataBit at theOutData : 7 for 8 loop while ! shiftOutClk loop end loop shiftOutData = dataBit theOutData = theOutData << 1 while shiftOutClk loop end loop end loop end if else shiftOutClk = low shiftOutClkDir = output if theOutMode then -- LSB first var bit dataBit at theOutData : 0 for 8 loop shiftOutData = dataBit theOutData = theOutData >> 1 shiftOutClk = high _shiftOutDelay shiftOutClk = low _shiftOutDelay end loop shiftOutData = low else -- MSB first var bit dataBit at theOutData : 7 for 8 loop shiftOutData = dataBit theOutData = theOutData << 1 shiftOutClk = high _shiftOutDelay shiftOutClk = low _shiftOutDelay end loop shiftOutData = low end if end if end procedure -- --------------------------------------------------------------------------------