Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ADB.txt 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. ADB Protocol
  2. ============
  3. Resources
  4. ---------
  5. ADB - The Untold Story: Space Aliens Ate My Mouse
  6. http://developer.apple.com/legacy/mac/library/#technotes/hw/hw_01.html
  7. Apple IIgs Hardware Reference Second Edition [p80(Chapter6 p121)]
  8. ftp://ftp.apple.asimov.net/pub/apple_II/documentation/Apple%20IIgs%20Hardware%20Reference.pdf
  9. ADB Keycode
  10. http://72.0.193.250/Documentation/macppc/adbkeycodes/
  11. http://m0115.web.fc2.com/m0115.jpg
  12. [Inside Macintosh volume V, pages 191-192]
  13. ADB Signaling
  14. http://kbdbabel.sourceforge.net/doc/kbd_signaling_pcxt_ps2_adb.pdf
  15. ADB Overview & History
  16. http://en.wikipedia.org/wiki/Apple_Desktop_Bus
  17. Microchip Application Note: ADB device(with code for PIC16C)
  18. http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011062
  19. AVR ATtiny2131 ADB to PS/2 converter(Japanese)
  20. http://hp.vector.co.jp/authors/VA000177/html/KeyBoardA5DEA5CBA5A2II.html
  21. Pinouts
  22. -------
  23. ADB female socket from the front:
  24. __________
  25. | | <--- top
  26. | 4o o3 |
  27. |2o o1|
  28. | == |
  29. |________| <--- bottom
  30. | | <--- 4pins
  31. ADB female socket from bottom:
  32. ========== <--- front
  33. | |
  34. | |
  35. |2o o1|
  36. |4o o3|
  37. ---------- <--- back
  38. 1: Data
  39. 2: Power SW(low when press Power key)
  40. 3: Vcc(5V)
  41. 4: GND
  42. Commands
  43. --------
  44. ADB command is 1byte and consists of 4bit-address, 2bit-command
  45. type and 2bit-register. The commands are always sent by Host.
  46. Command format:
  47. 7 6 5 4 3 2 1 0
  48. | | | |------------ address
  49. | |-------- command type
  50. | |---- register
  51. bits commands
  52. ------------------------------------------------------
  53. - - - - 0 0 0 0 Send Request(reset all devices)
  54. A A A A 0 0 0 1 Flush(reset a device)
  55. - - - - 0 0 1 0 Reserved
  56. - - - - 0 0 1 1 Reserved
  57. - - - - 0 1 - - Reserved
  58. A A A A 1 0 R R Listen(write to a device)
  59. A A A A 1 1 R R Talk(read from a device)
  60. The command to read keycodes from keyboard is 0x2C which
  61. consist of keyboard address 2 and Talk against register 0.
  62. Address:
  63. 2: keyboard
  64. 3: mice
  65. Registers:
  66. 0: application(keyobard uses this to store its data.)
  67. 1: application
  68. 2: application(keyboard uses this for LEDs and state of modifiers)
  69. 3: status and command
  70. Communication
  71. -------------
  72. This is a minimum information for keyboard communication.
  73. See "Resources" for detail.
  74. Signaling:
  75. ~~~~____________~~||||||||||||__~~~~~_~~|||||||||||||||__~~~~
  76. |800us | |7 Command 0| | | |15-64 Data 0|Stopbit(0)
  77. +Attention | | | +Startbit(1)
  78. +Startbit(1) | +Tlt(140-260us)
  79. +stopbit(0)
  80. Bit cells:
  81. bit0: ______~~~
  82. 65 :35us
  83. bit1: ___~~~~~~
  84. 35 :65us
  85. bit0 low time: 60-70% of bit cell(42-91us)
  86. bit1 low time: 30-40% of bit cell(21-52us)
  87. bit cell time: 70-130us
  88. [from Apple IIgs Hardware Reference Second Edition]
  89. Criterion for bit0/1:
  90. After 55us if line is low/high then bit is 0/1.
  91. Attention & start bit:
  92. Host asserts low in 560-1040us then places start bit(1).
  93. Tlt(Stop to Start):
  94. Bus stays high in 140-260us then device places start bit(1).
  95. Global reset:
  96. Host asserts low in 2.8-5.2ms. All devices are forced to reset.
  97. Send request from device(Srq):
  98. Device can request to send at commad(Global only?) stop bit.
  99. keep low for 300us to request.
  100. Keyboard Data(Register0)
  101. This 16bit data can contains two keycodes and two released flags.
  102. First keycode is palced in upper byte. When one keyocode is sent,
  103. lower byte is 0xFF.
  104. Release flag is 1 when key is released.
  105. 1514 . . . . . 8 7 6 . . . . . 0
  106. | | | | | | | | | +-+-+-+-+-+-+- Keycode2
  107. | | | | | | | | +--------------- Released2(1 when the key is released)
  108. | +-+-+-+-+-+-+----------------- Keycode1
  109. +------------------------------- Released1(1 when the key is released)
  110. Keycodes:
  111. Scancode consists of 7bit keycode and 1bit release flag.
  112. Device can send two keycodes at once. If just one keycode is sent
  113. keycode1 contains it and keyocode2 is 0xFF.
  114. Power switch:
  115. You can read the state from PSW line(active low) however
  116. the switch has a special scancode 0x7F7F, so you can
  117. also read from Data line. It uses 0xFFFF for release scancode.
  118. Keyboard LEDs & state of keys(Register2)
  119. This register hold current state of three LEDs and nine keys.
  120. The state of LEDs can be changed by sending Listen command.
  121. 1514 . . . . . . 7 6 5 . 3 2 1 0
  122. | | | | | | | | | | | | | | | +- LED1(NumLock)
  123. | | | | | | | | | | | | | | +--- LED2(CapsLock)
  124. | | | | | | | | | | | | | +----- LED3(ScrollLock)
  125. | | | | | | | | | | +-+-+------- Reserved
  126. | | | | | | | | | +------------- ScrollLock
  127. | | | | | | | | +--------------- NumLock
  128. | | | | | | | +----------------- Apple/Command
  129. | | | | | | +------------------- Option
  130. | | | | | +--------------------- Shift
  131. | | | | +----------------------- Control
  132. | | | +------------------------- Reset/Power
  133. | | +--------------------------- CapsLock
  134. | +----------------------------- Delete
  135. +------------------------------- Reserved
  136. END_OF_ADB