Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f5c15f547a3c
Choose a base ref
...
head repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 34d7f03d81ca
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jul 31, 2019

  1. Copy the full SHA
    86e85b7 View commit details
  2. Copy the full SHA
    34d7f03 View commit details
Showing with 7 additions and 10 deletions.
  1. +7 −10 software/glasgow/applet/interface/ps2_host/__init__.py
17 changes: 7 additions & 10 deletions software/glasgow/applet/interface/ps2_host/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Ref: IBM PS/2 Hardware Technical Reference ­- Keyboard and Auxiliary Device Controller
# Accession: G00031
# Ref: IBM PS/2 Hardware Technical Reference ­- Keyboards (101- and 102-Key)
# Accession: G00037

# PS/2 Physical Layer
# -------------------
@@ -8,14 +10,9 @@
# half-duplex SPI, but this comparison is misleading. In fact, tracing the communication of PS/2
# devices, one can notice that sample/setup points appear to be shifted 90° in phase compared to
# the clock, i.e. they are not edge triggered. This is similar to how an I²C master should be
# implemented (but often isn't). The IBM reference uses the word "sampling" when describing
# the protocol, as well as many min/max timing intervals, and one might conjecture that the way
# this originally worked is by the peripheral checking the clock/data lines at a regular interval,
# and advancing its internal FSM depending on the values on those lines. It appears that the data
# line is sampled somewhere during clock low, and set up somewhere during clock high.
#
# In this applet, we implement PS/2 as edge-triggered to avoid introducing arbitrary delays, but
# this is somewhat dirty (although seems to work well).
# implemented (but often isn't). The IBM keyboard reference describes that "Data is valid before
# the trailing edge and beyond the leading edge of the clock pulse", so the host may sample at
# either edge or anywhere during the low half-period of the clock.
#
# PS/2 Protocol Framing
# ---------------------
@@ -320,11 +317,11 @@ async def send_command(self, cmd, ret=0):
.format(cmd))
cmd_ack, *result, error = await self._lower.read(1 + ret + 1)
result = bytes(result)
self._log("cmd=%02x ack=%#02x ret=<%s>", cmd, cmd_ack, result.hex())
self._log("cmd=%02x ack=%02x ret=<%s>", cmd, cmd_ack, result.hex())
if error > 0:
raise PS2HostError("parity error in byte {} in response to command {:#04x}"
.format(error - 1, cmd))
if cmd_ack == 0xfa: # ACK
if cmd_ack in (0xfa, 0xee): # ACK
pass
elif cmd_ack in (0xfe, 0xfc, 0xfd): # NAK
# Response FE means resend according to the protocol, but really it means that