PS/2 Mouse/Keyboard Port Lecture L9.4
PS/2 Port
PS/2 Port Timing
Keyboard
Make and Break Codes Keyboard Scan Codes – Set 2
Scan code = 15h (Q) PS/2 Port Timing ~25 KhZ clock
--Flip Flops used to condition signals coming from PS2-- Process (pclk, clr, KC, KD) begin if(clr = '1') then DFF1 <= '0'; DFF2 <= '0'; KDI <= '0'; KCI <= '0'; else if (pclk = '1' and pclk'Event) then DFF1 <= KD; KDI <= DFF1; DFF2 <= KC; KCI <= DFF2; end if; end process; Filter clock and data signals from PS/2 port pclk KD DFF1 KDI pclk KC DFF2 KCI pclk <= clkdiv(3); MHz0.32 us period
--Shift Registers used to clock in scan codes from PS2-- Process(KDI, KCI, RST) begin if (RST = '1') then ShiftRegSig1 <= " "; ShiftRegSig2 <= " "; else if (KCI = '0' and KCI'Event) then ShiftRegSig1(10 downto 0) <= KDI & ShiftRegSig1(10 downto 1); ShiftRegSig2(10 downto 1) <= ShiftRegSig1(0) & ShiftRegSig2(10 downto 2); end if; end process; ShiftRegSig1 ShiftRegSig2 KDI D7D6D5D4D3D2D1D0P1 0 D7D6D5D4D3D2D1D0P1
--Wait Register process(ShiftRegSig1, ShiftRegSig2, RST, KCI) begin if(RST = '1')then WaitReg <= " "; else if(KCI'event and KCI = '1' and ShiftRegSig2(8 downto 1) = " ")then WaitReg <= ShiftRegSig1(8 downto 1); end if; end Process; F0
Host-to-Device Communication
1) Bring the Clock line low for at least 100 microseconds. 2) Bring the Data line low. 3) Release the Clock line. 4) Wait for the device to bring the Clock line low. 5) Set/reset the Data line to send the first data bit 6) Wait for the device to bring Clock high. 7) Wait for the device to bring Clock low. 8) Repeat steps 5-7 for the other seven data bits and the parity bit 9) Release the Data line. 10) Wait for the device to bring Data low. 11) Wait for the device to bring Clock low. 12) Wait for the device to release Data and Clock Host-to-Device Communication
Mouse Speed of mouse pressing left & right button sign overflow