[bknr-cvs] hans changed trunk/projects/symbolics-keyboard/teensy-firmware/

BKNR Commits bknr at bknr.net
Tue Apr 7 11:47:42 UTC 2009


Revision: 4365
Author: hans
URL: http://bknr.net/trac/changeset/4365

documentation
A   trunk/projects/symbolics-keyboard/teensy-firmware/README.txt
U   trunk/projects/symbolics-keyboard/teensy-firmware/symbolics.c

Added: trunk/projects/symbolics-keyboard/teensy-firmware/README.txt
===================================================================
--- trunk/projects/symbolics-keyboard/teensy-firmware/README.txt	                        (rev 0)
+++ trunk/projects/symbolics-keyboard/teensy-firmware/README.txt	2009-04-07 11:47:42 UTC (rev 4365)
@@ -0,0 +1,53 @@
+Symbolics keyboard adapter, based on Teensy keyboard example.
+
+The Symbolics keyboard acts as a shift register with 128 bits.  Each
+key is represented by one bit in the shift register.  The hardware
+interface consists of a clear line which is used to signal the
+beginning of a read cycle, a clock line, and a data line.  All signals
+are active low.  The keyboard changes the data line on the rising edge
+of the clock.  It should be read near the falling edge of the clock by
+the host.
+
+The keyboard needs to be interfaced to the Teensy board as
+follows. The wire colors specified are those used in the original
+modular cable supplied with the keyboard:
+
+blue  5V
+green GND
+red   D4   DIN
+black D5   CLK
+white D6   CLR
+
+The keyboard implements two locking functions, caps lock and mode
+lock.  Both of these are implemented as switches, not as buttons.
+Host systems do not usually expect switches on keyboards, so
+precautions must be taken to synchronize their state to the host's
+state.
+
+The "Caps Lock" key is implemented so that it works as usual, i.e. it
+is transmitted to the host as if it were a button.  The host sends
+back its caps lock state through the keyboard LEDs.  Thus, the
+controller firmware can synchronize the host's state with the state of
+the caps lock switch on the keyboard.
+
+The "Mode Lock" key is used to switch the keyboard between the classic
+Symbolics layout and a variant that assigns the modifier keys on the
+right side of the space bar to be cursor keys.  This mode is called
+f_mode.
+
+The "Local" key is used as a modifier key to trigger functions in the
+converter firmware.  The following functions are implemented:
+
+Local-B boots the AVR into the boot loader so that it can be
+reprogrammed through USB by the host.
+
+Local-V sends the Subversion revision number of this file to the host.
+
+Mapping of the symbolics key number to an USB key number is done
+through the mapping table defined in the file keymap.inc.  There are
+two separate tables, one for normal mode and one for f_mode.  The
+mapping table is normally autogenerated by the keymap generation
+program contained in make-keymap.lisp, but it can be manually edited
+if no Lisp evironment is available.
+
+Author: Hans Huebner (hans.huebner at gmail.com).


Property changes on: trunk/projects/symbolics-keyboard/teensy-firmware/README.txt
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/projects/symbolics-keyboard/teensy-firmware/symbolics.c
===================================================================
--- trunk/projects/symbolics-keyboard/teensy-firmware/symbolics.c	2009-04-07 10:56:59 UTC (rev 4364)
+++ trunk/projects/symbolics-keyboard/teensy-firmware/symbolics.c	2009-04-07 11:47:42 UTC (rev 4365)
@@ -1,29 +1,16 @@
 // -*- C++ -*- (this is really C)
 
-// Symbolics keyboard adapter, based on Teensy keyboard example.
+// -*- C++ -*-
 
-// The Symbolics keyboard acts as a shift register with 128 bits.  The
-// hardware interface consists of a clear line which is used to signal
-// the beginning of a read cycle, a clock line, and a data line.  All
-// signals are active low.  The keyboard changes the data line on the
-// rising edge of the clock.  It should be read near the falling edge
-// of the clock by the host.
+// Symbolics keyboard to USB adapter
 
-// The keyboard needs to be interfaced to the Teensy board as
-// follows. The wire colors specified are those used in the original
-// modular cable supplied with the keyboard:
-//
-// blue  5V
-// green GND
-// red   D4   DIN
-// black D5   CLK
-// white D6   CLR
+// See the README.txt file for documentation
 
-// The keyboard implements two locking functions, caps lock and mode
-// lock.  Both of these are implemented as switches, not as buttons,
-// so precautions must be made to synchronize their state to the
-// host's caps lock state.
+// Copyright 2009 by Hans Huebner (hans.huebner at gmail.com).
+// Additional copyrights apply.
 
+// This is the original copyright notice for this file:
+
 /* Keyboard example for Teensy USB Development Board
  * http://www.pjrc.com/teensy/usb_keyboard.html
  * Copyright (c) 2008 PJRC.COM, LLC
@@ -87,6 +74,8 @@
 void
 init_keyboard_interface(void)
 {
+  // Initialize I/O ports used to interface to the keyboard
+  
   DDRD = MASK_CLOCK | MASK_CLEAR;
   PORTD = MASK_CLOCK | MASK_CLEAR | MASK_DIN;
 }
@@ -94,30 +83,34 @@
 void
 poll_keyboard(uint8_t* state)
 {
-    PORTD &= ~MASK_CLEAR;
-    _delay_us(10);
-    PORTD |= MASK_CLEAR;
-    _delay_us(100);
-    for (int i = 0; i < 16; i++) {
-      uint8_t buf = 0;
-      for (int j = 0; j < 8; j++) {
-        buf >>= 1;
-        PORTD &= ~MASK_CLOCK;
-        _delay_us(10);
-        PORTD |= MASK_CLOCK;
-        _delay_us(40);
-        if (!(PIND & MASK_DIN)) {
-          buf |= 0x80;
-        }
+  // Read the keyboard shift register into the memory region pointed
+  // to by state.
+  
+  PORTD &= ~MASK_CLEAR;
+  _delay_us(10);
+  PORTD |= MASK_CLEAR;
+  _delay_us(100);
+  for (int i = 0; i < 16; i++) {
+    uint8_t buf = 0;
+    for (int j = 0; j < 8; j++) {
+      buf >>= 1;
+      PORTD &= ~MASK_CLOCK;
+      _delay_us(10);
+      PORTD |= MASK_CLOCK;
+      _delay_us(40);
+      if (!(PIND & MASK_DIN)) {
+        buf |= 0x80;
       }
-      state[i] = buf;
     }
+    state[i] = buf;
+  }
 }
 
 void
 jump_to_loader(void)
 {
   // Jump to the HalfKay (or any other) boot loader
+
   USBCON = 0;
   asm("jmp 0x3000");
 }
@@ -159,9 +152,11 @@
 
   // Evaluate key press.
   switch (keyboard_keys[0]) {
+
   case KEY_B:
     jump_to_loader();
     break;
+
   case KEY_V:
     report_version();
     break;
@@ -171,8 +166,8 @@
 void
 send_keys(uint8_t* state)
 {
-  // A change of state has been detected by the main loop, report all
-  // currently pressed keys to the host.
+  // Report all currently pressed keys to the host.  This function
+  // will be called when a change of state has been detected.
   
   uint8_t local = 0;
   uint8_t caps_lock_pressed = 0;





More information about the Bknr-cvs mailing list