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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. Female socket from the front
  24. 4o o3
  25. 2o o1
  26. ==
  27. 1: Data
  28. 2: Power SW(low when press Power key)
  29. 3: Vcc(5V)
  30. 4: GND
  31. Commands
  32. --------
  33. ADB command is 1byte and consists of 4bit-address, 2bit-command
  34. type and 2bit-register. The commands are always sent by Host.
  35. Command format:
  36. 7 6 5 4 3 2 1 0
  37. | | | |------------ address
  38. | |-------- command type
  39. | |---- register
  40. bits commands
  41. ------------------------------------------------------
  42. - - - - 0 0 0 0 Send Request(reset all devices)
  43. A A A A 0 0 0 1 Flush(reset a device)
  44. - - - - 0 0 1 0 Reserved
  45. - - - - 0 0 1 1 Reserved
  46. - - - - 0 1 - - Reserved
  47. A A A A 1 0 R R Listen(write to a device)
  48. A A A A 1 1 R R Talk(read from a device)
  49. The command to read keycodes from keyboard is 0x2C which
  50. consist of keyboard address 2 and Talk against register 0.
  51. Address:
  52. 2: keyboard
  53. 3: mice
  54. Registers:
  55. 0: application(keyobard uses this to store its data.)
  56. 1: application
  57. 2: application(keyboard uses this for LEDs and state of modifiers)
  58. 3: status and command
  59. Communication
  60. -------------
  61. This is a minimum information for keyboard communication.
  62. See "Resources" for detail.
  63. Signaling:
  64. ~~~~____________~~||||||||||||__~~~~~_~~|||||||||||||||__~~~~
  65. |800us | |7 Command 0| | | |15-64 Data 0|Stopbit(0)
  66. +Attention | | | +Startbit(1)
  67. +Startbit(1) | +Tlt(140-260us)
  68. +stopbit(0)
  69. Bit cells:
  70. bit0: ______~~~
  71. 65 :35us
  72. bit1: ___~~~~~~
  73. 35 :65us
  74. bit0 low time: 60-70% of bit cell(42-91us)
  75. bit1 low time: 30-40% of bit cell(21-52us)
  76. bit cell time: 70-130us
  77. [from Apple IIgs Hardware Reference Second Edition]
  78. Criterion for bit0/1:
  79. After 55us if line is low/high then bit is 0/1.
  80. Attention & start bit:
  81. Host asserts low in 560-1040us then places start bit(1).
  82. Tlt(Stop to Start):
  83. Bus stays high in 140-260us then device places start bit(1).
  84. Global reset:
  85. Host asserts low in 2.8-5.2ms. All devices are forced to reset.
  86. Send request from device(Srq):
  87. Device can request to send at commad(Global only?) stop bit.
  88. keep low for 300us to request.
  89. Keyboard Data(Register0)
  90. This 16bit data can contains two keycodes and two released flags.
  91. First keycode is palced in upper byte. When one keyocode is sent,
  92. lower byte is 0xFF.
  93. Release flag is 1 when key is released.
  94. 1514 . . . . . 8 7 6 . . . . . 0
  95. | | | | | | | | | +-+-+-+-+-+-+- Keycode2
  96. | | | | | | | | +--------------- Released2(1 when the key is released)
  97. | +-+-+-+-+-+-+----------------- Keycode1
  98. +------------------------------- Released1(1 when the key is released)
  99. Keycodes:
  100. Scancode consists of 7bit keycode and 1bit release flag.
  101. Device can send two keycodes at once. If just one keycode is sent
  102. keycode1 contains it and keyocode2 is 0xFF.
  103. Power switch:
  104. You can read the state from PSW line(active low) however
  105. the switch has a special scancode 0x7F7F, so you can
  106. also read from Data line. It uses 0xFFFF for release scancode.
  107. Keyboard LEDs & state of keys(Register2)
  108. This register hold current state of three LEDs and nine keys.
  109. The state of LEDs can be changed by sending Listen command.
  110. 1514 . . . . . . 7 6 5 . 3 2 1 0
  111. | | | | | | | | | | | | | | | +- LED1(NumLock)
  112. | | | | | | | | | | | | | | +--- LED2(CapsLock)
  113. | | | | | | | | | | | | | +----- LED3(ScrollLock)
  114. | | | | | | | | | | +-+-+------- Reserved
  115. | | | | | | | | | +------------- ScrollLock
  116. | | | | | | | | +--------------- NumLock
  117. | | | | | | | +----------------- Apple/Command
  118. | | | | | | +------------------- Option
  119. | | | | | +--------------------- Shift
  120. | | | | +----------------------- Control
  121. | | | +------------------------- Reset/Power
  122. | | +--------------------------- CapsLock
  123. | +----------------------------- Delete
  124. +------------------------------- Reserved
  125. END_OF_ADB