# HG changeset patch # User Jacob Alexander # Date 1353147186 28800 # Node ID 613743bf5bdd5700b588c11ba2878338fa13eb54 # Parent c6fdd7005ea0056b2c7d2a355219fc9fa182cb45 Completing the HP150 converter. diff -r c6fdd7005ea0 -r 613743bf5bdd Keymap/hp150.h --- a/Keymap/hp150.h Thu Nov 15 01:28:31 2012 -0800 +++ b/Keymap/hp150.h Sat Nov 17 02:13:06 2012 -0800 @@ -26,7 +26,7 @@ // ----- Variables ----- -static uint8_t hp150_ModifierMask[] = { 0x20, 0x2D, 0x2E, 0x30, 0x3E, 0x60 }; +static uint8_t hp150_ModifierMask[] = { 0x2F, 0x39, 0x3A, 0x3F, 0x45, 0x46, 0x76 }; static uint8_t hp150_DefaultMap[] = { 0, // 0x00 @@ -41,119 +41,119 @@ 0, // 0x09 0, // 0x0A 0, // 0x0B - 0, // 0x0C - 0, // 0x0D - 0, // 0x0E - 0, // 0x0F - 0, // 0x10 - 0, // 0x11 - 0, // 0x12 - 0, // 0x13 - 0, // 0x14 - 0, // 0x15 - 0, // 0x16 - 0, // 0x17 - 0, // 0x18 - 0, // 0x19 - 0, // 0x1A - 0, // 0x1B - 0, // 0x1C - 0, // 0x1D - 0, // 0x1E - 0, // 0x1F - KEY_LEFT_SHIFT, // 0x20 - 0, // 0x21 - KEY_Z, // 0x22 - KEY_X, // 0x23 - KEY_C, // 0x24 - KEY_V, // 0x25 - KEY_B, // 0x26 - KEY_N, // 0x27 - KEY_M, // 0x28 - KEY_COMMA, // 0x29 - KEY_PERIOD, // 0x2A - KEY_SLASH, // 0x2B - 0, // 0x2C - KEY_RIGHT_SHIFT, // 0x2D - KEY_LEFT_ALT, // 0x2E - KEY_SPACE, // 0x2F - KEY_LEFT_CTRL, // 0x30 - KEY_A, // 0x31 - KEY_S, // 0x32 - KEY_D, // 0x33 - KEY_F, // 0x34 - KEY_G, // 0x35 - KEY_H, // 0x36 - KEY_J, // 0x37 - KEY_K, // 0x38 - KEY_L, // 0x39 - KEY_SEMICOLON, // 0x3A - KEY_QUOTE, // 0x3B - 0, // 0x3C - KEY_ENTER, // 0x3D - KEY_RIGHT_GUI, // 0x3E - KEY_LEFT, // 0x3F (KEYPAD_1) - KEY_TAB, // 0x40 - KEY_Q, // 0x41 - KEY_W, // 0x42 - KEY_E, // 0x43 - KEY_R, // 0x44 - KEY_T, // 0x45 - KEY_Y, // 0x46 - KEY_U, // 0x47 - KEY_I, // 0x48 - KEY_O, // 0x49 - KEY_P, // 0x4A - KEY_LEFT_BRACE, // 0x4B - KEY_RIGHT_BRACE, // 0x4C - KEY_BACKSLASH, // 0x4D - KEY_DELETE, // 0x4E - KEYPAD_4, // 0x4F - KEY_ESC, // 0x50 - KEY_1, // 0x51 - KEY_2, // 0x52 - KEY_3, // 0x53 - KEY_4, // 0x54 - KEY_5, // 0x55 - KEY_6, // 0x56 - KEY_7, // 0x57 - KEY_8, // 0x58 - KEY_9, // 0x59 - KEY_0, // 0x5A - KEY_MINUS, // 0x5B - KEY_EQUAL, // 0x5C - KEY_TILDE, // 0x5D - KEY_BACKSPACE, // 0x5E - KEY_NUM_LOCK, // 0x5F - KEY_LEFT_GUI, // 0x60 - KEY_HOME, // 0x61 - KEY_END, // 0x62 - KEY_INSERT, // 0x63 - KEY_DELETE, // 0x64 - KEY_F1, // 0x65 - KEY_F2, // 0x66 - KEY_F3, // 0x67 - KEY_F4, // 0x68 - KEY_F5, // 0x69 - KEY_F6, // 0x6A - KEY_F7, // 0x6B - KEY_F8, // 0x6C - KEY_F9, // 0x6D - KEY_F10, // 0x6E - KEY_PRINTSCREEN, // 0x6F - KEY_PAGE_UP, // 0x70 - KEY_PAGE_DOWN, // 0x71 - KEY_F11, // 0x72 - KEYPAD_7, // 0x73 - KEYPAD_8, // 0x74 - KEYPAD_9, // 0x75 - KEY_UP, // 0x76 (KEYPAD_5) - KEYPAD_6, // 0x77 - KEY_DOWN, // 0x78 (KEYPAD_2) - KEY_RIGHT, // 0x79 (KEYPAD_3) - KEYPAD_0, // 0x7A - KEYPAD_00, // 0x7B - KEYPAD_ENTER, // 0x7C + KEY_MENU, // 0x0C + KEY_VOL_DOWN, // 0x0D + KEY_VOL_UP, // 0x0E + KEY_F8, // 0x0F + KEY_F7, // 0x10 + KEY_F6, // 0x11 + KEY_F5, // 0x12 + KEY_PRINTSCREEN, // 0x13 + KEY_8, // 0x14 + KEY_END, // 0x15 + KEY_HOME, // 0x16 + KEY_BACKSPACE, // 0x17 + KEY_EQUAL, // 0x18 + KEY_MINUS, // 0x19 + KEY_0, // 0x1A + KEY_9, // 0x1B + KEY_I, // 0x1C + KEY_DELETE, // 0x1D + KEY_INSERT, // 0x1E + KEY_BACKSLASH, // 0x1F + KEY_RIGHT_BRACE, // 0x20 + KEY_LEFT_BRACE, // 0x21 + KEY_P, // 0x22 + KEY_O, // 0x23 + KEY_J, // 0x24 + KEY_PAGE_UP, // 0x25 + KEY_NUM_LOCK, // 0x26 + KEY_ENTER, // 0x27 + KEY_QUOTE, // 0x28 + KEY_SEMICOLON, // 0x29 + KEY_L, // 0x2A + KEY_K, // 0x2B + KEY_M, // 0x2C + KEY_PAGE_DOWN, // 0x2D + KEY_UP, // 0x2E + KEY_RIGHT_GUI, // 0x2F + KEY_1, // 0x30 + KEY_SLASH, // 0x31 + KEY_PERIOD, // 0x32 + KEY_COMMA, // 0x33 + 0, // 0x34 + KEY_RIGHT, // 0x35 + KEY_DOWN, // 0x36 + KEY_LEFT, // 0x37 + KEY_RIGHT_GUI, // 0x38 + KEY_RIGHT_ALT, // 0x39 + KEY_LEFT_ALT, // 0x3A + KEY_SPACE, // 0x3B + KEY_F4, // 0x3C + KEY_G, // 0x3D + KEY_NUMBER, // 0x3E + KEY_CTRL, // 0x3F + KEY_TILDE, // 0x40 + KEY_F1, // 0x41 + KEY_F2, // 0x42 + KEY_F3, // 0x43 + KEY_7, // 0x44 + KEY_LEFT_SHIFT, // 0x45 + KEY_RIGHT_SHIFT, // 0x46 + KEY_CAPS_LOCK, // 0x47 + KEY_3, // 0x48 + KEY_4, // 0x49 + KEY_5, // 0x4A + KEY_6, // 0x4B + KEY_U, // 0x4C + KEY_TAB, // 0x4D + KEY_Q, // 0x4E + KEY_W, // 0x4F + KEY_E, // 0x50 + KEY_R, // 0x51 + KEY_T, // 0x52 + KEY_Y, // 0x53 + KEY_H, // 0x54 + KEY_2, // 0x55 + KEY_LEFT_GUI, // 0x56 + KEY_A, // 0x57 + KEY_S, // 0x58 + KEY_D, // 0x59 + KEY_F, // 0x5A + KEY_ESC, // 0x5B + KEYPAD_COMMA, // 0x5C + KEYPAD_TAB, // 0x5D + KEYPAD_6, // 0x5E + KEYPAD_9, // 0x5F + KEYPAD_5, // 0x60 + KEYPAD_8, // 0x61 + KEYPAD_4, // 0x62 + KEYPAD_7, // 0x63 + KEY_TAB, // 0x64 + KEYPAD_MINUS, // 0x65 + KEYPAD_3, // 0x66 + KEYPAD_PLUS, // 0x67 + KEYPAD_2, // 0x68 + KEYPAD_SLASH, // 0x69 + KEYPAD_1, // 0x6A + KEYPAD_ASTERIX, // 0x6B + 0, // 0x6C + KEY_F12, // 0x6D + KEYPAD_PERIOD, // 0x6E + KEY_F11, // 0x6F + 0, // 0x70 + KEY_F10, // 0x71 + KEYPAD_0, // 0x72 + KEY_F9, // 0x73 + KEY_N, // 0x74 + KEY_ESC, // 0x75 + KEY_GUI, // 0x76 + KEY_Z, // 0x77 + KEY_X, // 0x78 + KEY_C, // 0x79 + KEY_V, // 0x7A + KEY_B, // 0x7B + 0, // 0x7C 0, // 0x7D 0, // 0x7E 0, // 0x7F @@ -172,119 +172,119 @@ 0, // 0x09 0, // 0x0A 0, // 0x0B - 0, // 0x0C - 0, // 0x0D - 0, // 0x0E - 0, // 0x0F - 0, // 0x10 - 0, // 0x11 - 0, // 0x12 - 0, // 0x13 - 0, // 0x14 - 0, // 0x15 - 0, // 0x16 - 0, // 0x17 - 0, // 0x18 - 0, // 0x19 - 0, // 0x1A - 0, // 0x1B - 0, // 0x1C - 0, // 0x1D - 0, // 0x1E - 0, // 0x1F - KEY_LEFT_SHIFT, // 0x20 - 0, // 0x21 - KEY_Z, // 0x22 - KEY_X, // 0x23 - KEY_C, // 0x24 - KEY_V, // 0x25 - KEY_B, // 0x26 - KEY_K, // 0x27 - KEY_M, // 0x28 - KEY_COMMA, // 0x29 - KEY_PERIOD, // 0x2A - KEY_SLASH, // 0x2B - 0, // 0x2C - KEY_RIGHT_SHIFT, // 0x2D - KEY_LEFT_ALT, // 0x2E - KEY_SPACE, // 0x2F - KEY_LEFT_CTRL, // 0x30 - KEY_A, // 0x31 - KEY_R, // 0x32 - KEY_S, // 0x33 - KEY_T, // 0x34 - KEY_D, // 0x35 - KEY_H, // 0x36 - KEY_N, // 0x37 - KEY_E, // 0x38 - KEY_I, // 0x39 - KEY_O, // 0x3A - KEY_QUOTE, // 0x3B - 0, // 0x3C - KEY_ENTER, // 0x3D - KEY_RIGHT_GUI, // 0x3E - KEY_LEFT, // 0x3F (KEYPAD_1) - KEY_TAB, // 0x40 - KEY_Q, // 0x41 - KEY_W, // 0x42 - KEY_F, // 0x43 - KEY_P, // 0x44 - KEY_G, // 0x45 - KEY_J, // 0x46 - KEY_L, // 0x47 - KEY_U, // 0x48 - KEY_Y, // 0x49 - KEY_SEMICOLON, // 0x4A - KEY_LEFT_BRACE, // 0x4B - KEY_RIGHT_BRACE, // 0x4C - KEY_BACKSLASH, // 0x4D - KEY_DELETE, // 0x4E - KEYPAD_4, // 0x4F - KEY_ESC, // 0x50 - KEY_1, // 0x51 - KEY_2, // 0x52 - KEY_3, // 0x53 - KEY_4, // 0x54 - KEY_5, // 0x55 - KEY_6, // 0x56 - KEY_7, // 0x57 - KEY_8, // 0x58 - KEY_9, // 0x59 - KEY_0, // 0x5A - KEY_MINUS, // 0x5B - KEY_EQUAL, // 0x5C - KEY_TILDE, // 0x5D - KEY_BACKSPACE, // 0x5E - KEY_NUM_LOCK, // 0x5F - KEY_LEFT_GUI, // 0x60 - KEY_HOME, // 0x61 - KEY_END, // 0x62 - KEY_INSERT, // 0x63 - KEY_DELETE, // 0x64 - KEY_F1, // 0x65 - KEY_F2, // 0x66 - KEY_F3, // 0x67 - KEY_F4, // 0x68 - KEY_F5, // 0x69 - KEY_F6, // 0x6A - KEY_F7, // 0x6B - KEY_F8, // 0x6C - KEY_F9, // 0x6D - KEY_F10, // 0x6E - KEY_PRINTSCREEN, // 0x6F - KEY_PAGE_UP, // 0x70 - KEY_PAGE_DOWN, // 0x71 - KEY_F11, // 0x72 - KEYPAD_7, // 0x73 - KEYPAD_8, // 0x74 - KEYPAD_9, // 0x75 - KEY_UP, // 0x76 (KEYPAD_5) - KEYPAD_6, // 0x77 - KEY_DOWN, // 0x78 (KEYPAD_2) - KEY_RIGHT, // 0x79 (KEYPAD_3) - KEYPAD_0, // 0x7A - KEYPAD_00, // 0x7B - KEYPAD_ENTER, // 0x7C + KEY_MENU, // 0x0C + KEY_VOL_DOWN, // 0x0D + KEY_VOL_UP, // 0x0E + KEY_F8, // 0x0F + KEY_F7, // 0x10 + KEY_F6, // 0x11 + KEY_F5, // 0x12 + KEY_PRINTSCREEN, // 0x13 + KEY_8, // 0x14 + KEY_END, // 0x15 + KEY_HOME, // 0x16 + KEY_BACKSPACE, // 0x17 + KEY_EQUAL, // 0x18 + KEY_MINUS, // 0x19 + KEY_0, // 0x1A + KEY_9, // 0x1B + KEY_U, // 0x1C + KEY_DELETE, // 0x1D + KEY_INSERT, // 0x1E + KEY_BACKSLASH, // 0x1F + KEY_RIGHT_BRACE, // 0x20 + KEY_LEFT_BRACE, // 0x21 + KEY_SEMICOLON, // 0x22 + KEY_Y, // 0x23 + KEY_N, // 0x24 + KEY_PAGE_UP, // 0x25 + KEY_NUM_LOCK, // 0x26 + KEY_ENTER, // 0x27 + KEY_QUOTE, // 0x28 + KEY_O, // 0x29 + KEY_I, // 0x2A + KEY_E, // 0x2B + KEY_M, // 0x2C + KEY_PAGE_DOWN, // 0x2D + KEY_UP, // 0x2E + KEY_RIGHT_GUI, // 0x2F + KEY_1, // 0x30 + KEY_SLASH, // 0x31 + KEY_PERIOD, // 0x32 + KEY_COMMA, // 0x33 + 0, // 0x34 + KEY_RIGHT, // 0x35 + KEY_DOWN, // 0x36 + KEY_LEFT, // 0x37 + KEY_RIGHT_GUI, // 0x38 + KEY_RIGHT_ALT, // 0x39 + KEY_LEFT_ALT, // 0x3A + KEY_SPACE, // 0x3B + KEY_F4, // 0x3C + KEY_D, // 0x3D + KEY_NUMBER, // 0x3E + KEY_CTRL, // 0x3F + KEY_TILDE, // 0x40 + KEY_F1, // 0x41 + KEY_F2, // 0x42 + KEY_F3, // 0x43 + KEY_7, // 0x44 + KEY_LEFT_SHIFT, // 0x45 + KEY_RIGHT_SHIFT, // 0x46 + KEY_CAPS_LOCK, // 0x47 + KEY_3, // 0x48 + KEY_4, // 0x49 + KEY_5, // 0x4A + KEY_6, // 0x4B + KEY_L, // 0x4C + KEY_TAB, // 0x4D + KEY_Q, // 0x4E + KEY_W, // 0x4F + KEY_F, // 0x50 + KEY_P, // 0x51 + KEY_G, // 0x52 + KEY_J, // 0x53 + KEY_H, // 0x54 + KEY_2, // 0x55 + KEY_LEFT_GUI, // 0x56 + KEY_A, // 0x57 + KEY_R, // 0x58 + KEY_S, // 0x59 + KEY_T, // 0x5A + KEY_ESC, // 0x5B + KEYPAD_COMMA, // 0x5C + KEYPAD_TAB, // 0x5D + KEYPAD_6, // 0x5E + KEYPAD_9, // 0x5F + KEYPAD_5, // 0x60 + KEYPAD_8, // 0x61 + KEYPAD_4, // 0x62 + KEYPAD_7, // 0x63 + KEY_TAB, // 0x64 + KEYPAD_MINUS, // 0x65 + KEYPAD_3, // 0x66 + KEYPAD_PLUS, // 0x67 + KEYPAD_2, // 0x68 + KEYPAD_SLASH, // 0x69 + KEYPAD_1, // 0x6A + KEYPAD_ASTERIX, // 0x6B + 0, // 0x6C + KEY_F12, // 0x6D + KEYPAD_PERIOD, // 0x6E + KEY_F11, // 0x6F + 0, // 0x70 + KEY_F10, // 0x71 + KEYPAD_0, // 0x72 + KEY_F9, // 0x73 + KEY_K, // 0x74 + KEY_ESC, // 0x75 + KEY_GUI, // 0x76 + KEY_Z, // 0x77 + KEY_X, // 0x78 + KEY_C, // 0x79 + KEY_V, // 0x7A + KEY_B, // 0x7B + 0, // 0x7C 0, // 0x7D 0, // 0x7E 0, // 0x7F diff -r c6fdd7005ea0 -r 613743bf5bdd Macro/buffer/macro.c --- a/Macro/buffer/macro.c Thu Nov 15 01:28:31 2012 -0800 +++ b/Macro/buffer/macro.c Sat Nov 17 02:13:06 2012 -0800 @@ -252,6 +252,7 @@ int usbcodeMacro( uint8_t usbCode ) { // Keyboard Input Test Macro + /* switch ( usbCode ) { case KEY_F1: @@ -304,7 +305,8 @@ } return 1; - //return 0; + */ + return 0; } diff -r c6fdd7005ea0 -r 613743bf5bdd Scan/HP150/scan_loop.c --- a/Scan/HP150/scan_loop.c Thu Nov 15 01:28:31 2012 -0800 +++ b/Scan/HP150/scan_loop.c Sat Nov 17 02:13:06 2012 -0800 @@ -41,6 +41,7 @@ #define DATA_PORT PORTC #define DATA_DDR DDRC #define DATA_PIN 7 +#define DATA_OUT PINC #define CLOCK_PORT PORTC #define CLOCK_DDR DDRC @@ -68,6 +69,8 @@ volatile uint8_t KeyIndex_Add_InputSignal; // Used to pass the (click/input value) to the keyboard for the clicker volatile uint8_t currentWaveState = 0; +volatile uint8_t currentWaveDone = 0; +volatile uint8_t positionCounter = 0; // Buffer Signals @@ -90,7 +93,9 @@ if ( currentWaveState ) { CLOCK_PORT &= ~(1 << CLOCK_PIN); - currentWaveState--; + currentWaveState--; // Keeps track of the clock value (for direct clock output) + currentWaveDone--; // Keeps track of whether the current falling edge has been processed + positionCounter++; // Counts the number of falling edges, reset is done by the controlling section (reset, or main scan) } else { @@ -109,14 +114,15 @@ // Setup Timer Pulse (16 bit) // TODO Clock can be adjusted to whatever (read chip datasheets for limits) - // 16 MHz / (2 * Prescaler * (1 + OCR1A)) = 1200.1 baud + // This seems like a good scan speed, as there don't seem to be any periodic + // de-synchronization events, and is fast enough for scanning keys + // Anything much more (100k baud), tends to cause a lot of de-synchronization + // 16 MHz / (2 * Prescaler * (1 + OCR1A)) = 10k baud // Prescaler is 1 - // Twice every 1200 baud (actually 1200.1, timer isn't accurate enough) - // This is close to 820 us, but a bit slower cli(); TCCR1B = 0x09; - OCR1AH = 0x01; - OCR1AL = 0x09; + OCR1AH = 0x03; + OCR1AL = 0x1F; TIMSK1 = (1 << OCIE1A); CLOCK_DDR = (1 << CLOCK_PIN); sei(); @@ -125,9 +131,6 @@ // Initially buffer doesn't need to be cleared (it's empty...) BufferReadyToClear = 0; - // InputSignal is off by default - KeyIndex_Add_InputSignal = 0x00; - // Reset the keyboard before scanning, we might be in a wierd state scan_resetKeyboard(); } @@ -141,67 +144,75 @@ // Once the end of the packet has been detected (always the same length), decode the pressed keys inline uint8_t scan_loop() { - return 0; -} - -void processKeyValue( uint8_t keyValue ) -{ - // Interpret scan code - switch ( keyValue ) + // Read on each falling edge/after the falling edge of the clock + if ( !currentWaveDone ) { - case 0x00: // Break code from input? - break; - default: - // Make sure the key isn't already in the buffer - for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ ) - { - // Key isn't in the buffer yet - if ( c == KeyIndex_BufferUsed ) - { - bufferAdd( keyValue ); + // Sample the current value 50 times + // If there is a signal for 40/50 of the values, then it is active + // This works as a very simple debouncing mechanism + // XXX Could be done more intelligently: + // Take into account the frequency of the clock + overhead, and space out the reads + // Or do something like "dual edge" statistics, where you query the stats from both rising and falling edges + // then make a decision (probably won't do much better against the last source of noise, but would do well for debouncing) + uint8_t total = 0; + uint8_t c = 0; + for ( ; c < 50; c++ ) + if ( DATA_OUT & (1 << DATA_PIN) ) + total++; - // Only send data if enabled - if ( KeyIndex_Add_InputSignal ) - scan_sendData( KeyIndex_Add_InputSignal ); - break; - } - // Key already in the buffer - if ( KeyIndex_Buffer[c] == keyValue ) - break; - } - break; - } -} + // Only use as a valid signal + if ( total >= 40 ) + { + // Reset the scan counter, all the keys have been iterated over + // Ideally this should reset at 128, however + // due to noise in the cabling, this often moves around + // The minimum this can possibly set to is 124 as there + // are keys to service at 123 (0x78) + // Usually, unless there is lots of interference, + // this should limit most of the noise. + if ( positionCounter >= 124 ) + { + positionCounter = 0; -void removeKeyValue( uint8_t keyValue ) -{ - // Check for the released key, and shift the other keys lower on the buffer - uint8_t c; - for ( c = 0; c < KeyIndex_BufferUsed; c++ ) - { - // Key to release found - if ( KeyIndex_Buffer[c] == keyValue ) - { - // Shift keys from c position - for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ ) - KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1]; + // Clear key buffer + KeyIndex_BufferUsed = 0; + } + // Key Press Detected + else + { + char tmp[15]; + hexToStr( positionCounter, tmp ); + dPrintStrsNL( "Key: ", tmp ); - // Decrement Buffer - KeyIndex_BufferUsed--; + bufferAdd( positionCounter ); + } + } - break; - } + // Wait until the next falling clock edge for the next DATA scan + currentWaveDone++; } - // Error case (no key to release) - if ( c == KeyIndex_BufferUsed + 1 ) + // Check if the clock de-synchronized + // And reset + if ( positionCounter > 128 ) { + char tmp[15]; + hexToStr( positionCounter, tmp ); + erro_dPrint( "De-synchronization detected at: ", tmp ); errorLED( 1 ); - char tmpStr[6]; - hexToStr( keyValue, tmpStr ); - erro_dPrint( "Could not find key to release: ", tmpStr ); + + positionCounter = 0; + KeyIndex_BufferUsed = 0; + + // A keyboard reset requires interrupts to be enabled + sei(); + scan_resetKeyboard(); + cli(); } + + // Regardless of what happens, always return 0 + return 0; } // Send data @@ -221,12 +232,12 @@ } // Reset/Hold keyboard -// NOTE: Does nothing with the BETKB +// NOTE: Does nothing with the HP150 void scan_lockKeyboard( void ) { } -// NOTE: Does nothing with the BETKB +// NOTE: Does nothing with the HP150 void scan_unlockKeyboard( void ) { } @@ -234,6 +245,37 @@ // Reset Keyboard void scan_resetKeyboard( void ) { - // TODO Determine the scan period, and the interval to scan each bit + info_print("Attempting to synchronize the keyboard, do not press any keys..."); + errorLED( 1 ); + + // Do a proper keyboard reset (flushes the ripple counters) + RESET_PORT |= (1 << RESET_PIN); + _delay_us(10); + RESET_PORT &= ~(1 << RESET_PIN); + + // Delay main keyboard scanning, until the bit counter is synchronized + uint8_t synchronized = 0; + while ( !synchronized ) + { + // Read on each falling edge/after the falling edge of the clock + if ( !currentWaveDone ) + { + // Read the current data value + if ( DATA_OUT & (1 << DATA_PIN) ) + { + // Check if synchronized + // There are 128 positions to scan for with the HP150 keyboard protocol + if ( positionCounter == 128 ) + synchronized = 1; + + positionCounter = 0; + } + + // Wait until the next falling clock edge for the next DATA scan + currentWaveDone++; + } + } + + info_print("Keyboard Synchronized!"); } diff -r c6fdd7005ea0 -r 613743bf5bdd Scan/HP150/setup.cmake --- a/Scan/HP150/setup.cmake Thu Nov 15 01:28:31 2012 -0800 +++ b/Scan/HP150/setup.cmake Sat Nov 17 02:13:06 2012 -0800 @@ -42,7 +42,7 @@ #| Keymap Settings add_definitions( -DMODIFIER_MASK=hp150_ModifierMask - #-DKEYINDEX_MASK=hp150_ColemakMap - -DKEYINDEX_MASK=hp150_DefaultMap + -DKEYINDEX_MASK=hp150_ColemakMap + #-DKEYINDEX_MASK=hp150_DefaultMap ) diff -r c6fdd7005ea0 -r 613743bf5bdd setup.cmake --- a/setup.cmake Thu Nov 15 01:28:31 2012 -0800 +++ b/setup.cmake Sat Nov 17 02:13:06 2012 -0800 @@ -20,7 +20,7 @@ #| Please the {Scan,Macro,USB,Debug}/module.txt for information on the modules and how to create new ones ##| Deals with acquiring the keypress information and turning it into a key index -set( ScanModule "IBMConvertible" ) +set( ScanModule "HP150" ) ##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code set( MacroModule "buffer" )