Archived
1
0

Completing the HP150 converter.

This commit is contained in:
Jacob Alexander 2012-11-17 02:13:06 -08:00
parent 0c39927268
commit 59e443552c
5 changed files with 335 additions and 291 deletions

View File

@ -26,7 +26,7 @@
// ----- Variables ----- // ----- 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[] = { static uint8_t hp150_DefaultMap[] = {
0, // 0x00 0, // 0x00
@ -41,119 +41,119 @@ static uint8_t hp150_DefaultMap[] = {
0, // 0x09 0, // 0x09
0, // 0x0A 0, // 0x0A
0, // 0x0B 0, // 0x0B
0, // 0x0C KEY_MENU, // 0x0C
0, // 0x0D KEY_VOL_DOWN, // 0x0D
0, // 0x0E KEY_VOL_UP, // 0x0E
0, // 0x0F KEY_F8, // 0x0F
0, // 0x10 KEY_F7, // 0x10
0, // 0x11 KEY_F6, // 0x11
0, // 0x12 KEY_F5, // 0x12
0, // 0x13 KEY_PRINTSCREEN, // 0x13
0, // 0x14 KEY_8, // 0x14
0, // 0x15 KEY_END, // 0x15
0, // 0x16 KEY_HOME, // 0x16
0, // 0x17 KEY_BACKSPACE, // 0x17
0, // 0x18 KEY_EQUAL, // 0x18
0, // 0x19 KEY_MINUS, // 0x19
0, // 0x1A KEY_0, // 0x1A
0, // 0x1B KEY_9, // 0x1B
0, // 0x1C KEY_I, // 0x1C
0, // 0x1D KEY_DELETE, // 0x1D
0, // 0x1E KEY_INSERT, // 0x1E
0, // 0x1F KEY_BACKSLASH, // 0x1F
KEY_LEFT_SHIFT, // 0x20 KEY_RIGHT_BRACE, // 0x20
0, // 0x21 KEY_LEFT_BRACE, // 0x21
KEY_Z, // 0x22 KEY_P, // 0x22
KEY_X, // 0x23 KEY_O, // 0x23
KEY_C, // 0x24 KEY_J, // 0x24
KEY_V, // 0x25 KEY_PAGE_UP, // 0x25
KEY_B, // 0x26 KEY_NUM_LOCK, // 0x26
KEY_N, // 0x27 KEY_ENTER, // 0x27
KEY_M, // 0x28 KEY_QUOTE, // 0x28
KEY_COMMA, // 0x29 KEY_SEMICOLON, // 0x29
KEY_PERIOD, // 0x2A KEY_L, // 0x2A
KEY_SLASH, // 0x2B KEY_K, // 0x2B
0, // 0x2C KEY_M, // 0x2C
KEY_RIGHT_SHIFT, // 0x2D KEY_PAGE_DOWN, // 0x2D
KEY_LEFT_ALT, // 0x2E KEY_UP, // 0x2E
KEY_SPACE, // 0x2F KEY_RIGHT_GUI, // 0x2F
KEY_LEFT_CTRL, // 0x30 KEY_1, // 0x30
KEY_A, // 0x31 KEY_SLASH, // 0x31
KEY_S, // 0x32 KEY_PERIOD, // 0x32
KEY_D, // 0x33 KEY_COMMA, // 0x33
KEY_F, // 0x34 0, // 0x34
KEY_G, // 0x35 KEY_RIGHT, // 0x35
KEY_H, // 0x36 KEY_DOWN, // 0x36
KEY_J, // 0x37 KEY_LEFT, // 0x37
KEY_K, // 0x38 KEY_RIGHT_GUI, // 0x38
KEY_L, // 0x39 KEY_RIGHT_ALT, // 0x39
KEY_SEMICOLON, // 0x3A KEY_LEFT_ALT, // 0x3A
KEY_QUOTE, // 0x3B KEY_SPACE, // 0x3B
0, // 0x3C KEY_F4, // 0x3C
KEY_ENTER, // 0x3D KEY_G, // 0x3D
KEY_RIGHT_GUI, // 0x3E KEY_NUMBER, // 0x3E
KEY_LEFT, // 0x3F (KEYPAD_1) KEY_CTRL, // 0x3F
KEY_TAB, // 0x40 KEY_TILDE, // 0x40
KEY_Q, // 0x41 KEY_F1, // 0x41
KEY_W, // 0x42 KEY_F2, // 0x42
KEY_E, // 0x43 KEY_F3, // 0x43
KEY_R, // 0x44 KEY_7, // 0x44
KEY_T, // 0x45 KEY_LEFT_SHIFT, // 0x45
KEY_Y, // 0x46 KEY_RIGHT_SHIFT, // 0x46
KEY_U, // 0x47 KEY_CAPS_LOCK, // 0x47
KEY_I, // 0x48 KEY_3, // 0x48
KEY_O, // 0x49 KEY_4, // 0x49
KEY_P, // 0x4A KEY_5, // 0x4A
KEY_LEFT_BRACE, // 0x4B KEY_6, // 0x4B
KEY_RIGHT_BRACE, // 0x4C KEY_U, // 0x4C
KEY_BACKSLASH, // 0x4D KEY_TAB, // 0x4D
KEY_DELETE, // 0x4E KEY_Q, // 0x4E
KEYPAD_4, // 0x4F KEY_W, // 0x4F
KEY_ESC, // 0x50 KEY_E, // 0x50
KEY_1, // 0x51 KEY_R, // 0x51
KEY_2, // 0x52 KEY_T, // 0x52
KEY_3, // 0x53 KEY_Y, // 0x53
KEY_4, // 0x54 KEY_H, // 0x54
KEY_5, // 0x55 KEY_2, // 0x55
KEY_6, // 0x56 KEY_LEFT_GUI, // 0x56
KEY_7, // 0x57 KEY_A, // 0x57
KEY_8, // 0x58 KEY_S, // 0x58
KEY_9, // 0x59 KEY_D, // 0x59
KEY_0, // 0x5A KEY_F, // 0x5A
KEY_MINUS, // 0x5B KEY_ESC, // 0x5B
KEY_EQUAL, // 0x5C KEYPAD_COMMA, // 0x5C
KEY_TILDE, // 0x5D KEYPAD_TAB, // 0x5D
KEY_BACKSPACE, // 0x5E KEYPAD_6, // 0x5E
KEY_NUM_LOCK, // 0x5F KEYPAD_9, // 0x5F
KEY_LEFT_GUI, // 0x60 KEYPAD_5, // 0x60
KEY_HOME, // 0x61 KEYPAD_8, // 0x61
KEY_END, // 0x62 KEYPAD_4, // 0x62
KEY_INSERT, // 0x63 KEYPAD_7, // 0x63
KEY_DELETE, // 0x64 KEY_TAB, // 0x64
KEY_F1, // 0x65 KEYPAD_MINUS, // 0x65
KEY_F2, // 0x66 KEYPAD_3, // 0x66
KEY_F3, // 0x67 KEYPAD_PLUS, // 0x67
KEY_F4, // 0x68 KEYPAD_2, // 0x68
KEY_F5, // 0x69 KEYPAD_SLASH, // 0x69
KEY_F6, // 0x6A KEYPAD_1, // 0x6A
KEY_F7, // 0x6B KEYPAD_ASTERIX, // 0x6B
KEY_F8, // 0x6C 0, // 0x6C
KEY_F9, // 0x6D KEY_F12, // 0x6D
KEY_F10, // 0x6E KEYPAD_PERIOD, // 0x6E
KEY_PRINTSCREEN, // 0x6F KEY_F11, // 0x6F
KEY_PAGE_UP, // 0x70 0, // 0x70
KEY_PAGE_DOWN, // 0x71 KEY_F10, // 0x71
KEY_F11, // 0x72 KEYPAD_0, // 0x72
KEYPAD_7, // 0x73 KEY_F9, // 0x73
KEYPAD_8, // 0x74 KEY_N, // 0x74
KEYPAD_9, // 0x75 KEY_ESC, // 0x75
KEY_UP, // 0x76 (KEYPAD_5) KEY_GUI, // 0x76
KEYPAD_6, // 0x77 KEY_Z, // 0x77
KEY_DOWN, // 0x78 (KEYPAD_2) KEY_X, // 0x78
KEY_RIGHT, // 0x79 (KEYPAD_3) KEY_C, // 0x79
KEYPAD_0, // 0x7A KEY_V, // 0x7A
KEYPAD_00, // 0x7B KEY_B, // 0x7B
KEYPAD_ENTER, // 0x7C 0, // 0x7C
0, // 0x7D 0, // 0x7D
0, // 0x7E 0, // 0x7E
0, // 0x7F 0, // 0x7F
@ -172,119 +172,119 @@ static uint8_t hp150_ColemakMap[] = {
0, // 0x09 0, // 0x09
0, // 0x0A 0, // 0x0A
0, // 0x0B 0, // 0x0B
0, // 0x0C KEY_MENU, // 0x0C
0, // 0x0D KEY_VOL_DOWN, // 0x0D
0, // 0x0E KEY_VOL_UP, // 0x0E
0, // 0x0F KEY_F8, // 0x0F
0, // 0x10 KEY_F7, // 0x10
0, // 0x11 KEY_F6, // 0x11
0, // 0x12 KEY_F5, // 0x12
0, // 0x13 KEY_PRINTSCREEN, // 0x13
0, // 0x14 KEY_8, // 0x14
0, // 0x15 KEY_END, // 0x15
0, // 0x16 KEY_HOME, // 0x16
0, // 0x17 KEY_BACKSPACE, // 0x17
0, // 0x18 KEY_EQUAL, // 0x18
0, // 0x19 KEY_MINUS, // 0x19
0, // 0x1A KEY_0, // 0x1A
0, // 0x1B KEY_9, // 0x1B
0, // 0x1C KEY_U, // 0x1C
0, // 0x1D KEY_DELETE, // 0x1D
0, // 0x1E KEY_INSERT, // 0x1E
0, // 0x1F KEY_BACKSLASH, // 0x1F
KEY_LEFT_SHIFT, // 0x20 KEY_RIGHT_BRACE, // 0x20
0, // 0x21 KEY_LEFT_BRACE, // 0x21
KEY_Z, // 0x22 KEY_SEMICOLON, // 0x22
KEY_X, // 0x23 KEY_Y, // 0x23
KEY_C, // 0x24 KEY_N, // 0x24
KEY_V, // 0x25 KEY_PAGE_UP, // 0x25
KEY_B, // 0x26 KEY_NUM_LOCK, // 0x26
KEY_K, // 0x27 KEY_ENTER, // 0x27
KEY_M, // 0x28 KEY_QUOTE, // 0x28
KEY_COMMA, // 0x29 KEY_O, // 0x29
KEY_PERIOD, // 0x2A KEY_I, // 0x2A
KEY_SLASH, // 0x2B KEY_E, // 0x2B
0, // 0x2C KEY_M, // 0x2C
KEY_RIGHT_SHIFT, // 0x2D KEY_PAGE_DOWN, // 0x2D
KEY_LEFT_ALT, // 0x2E KEY_UP, // 0x2E
KEY_SPACE, // 0x2F KEY_RIGHT_GUI, // 0x2F
KEY_LEFT_CTRL, // 0x30 KEY_1, // 0x30
KEY_A, // 0x31 KEY_SLASH, // 0x31
KEY_R, // 0x32 KEY_PERIOD, // 0x32
KEY_S, // 0x33 KEY_COMMA, // 0x33
KEY_T, // 0x34 0, // 0x34
KEY_D, // 0x35 KEY_RIGHT, // 0x35
KEY_H, // 0x36 KEY_DOWN, // 0x36
KEY_N, // 0x37 KEY_LEFT, // 0x37
KEY_E, // 0x38 KEY_RIGHT_GUI, // 0x38
KEY_I, // 0x39 KEY_RIGHT_ALT, // 0x39
KEY_O, // 0x3A KEY_LEFT_ALT, // 0x3A
KEY_QUOTE, // 0x3B KEY_SPACE, // 0x3B
0, // 0x3C KEY_F4, // 0x3C
KEY_ENTER, // 0x3D KEY_D, // 0x3D
KEY_RIGHT_GUI, // 0x3E KEY_NUMBER, // 0x3E
KEY_LEFT, // 0x3F (KEYPAD_1) KEY_CTRL, // 0x3F
KEY_TAB, // 0x40 KEY_TILDE, // 0x40
KEY_Q, // 0x41 KEY_F1, // 0x41
KEY_W, // 0x42 KEY_F2, // 0x42
KEY_F, // 0x43 KEY_F3, // 0x43
KEY_P, // 0x44 KEY_7, // 0x44
KEY_G, // 0x45 KEY_LEFT_SHIFT, // 0x45
KEY_J, // 0x46 KEY_RIGHT_SHIFT, // 0x46
KEY_L, // 0x47 KEY_CAPS_LOCK, // 0x47
KEY_U, // 0x48 KEY_3, // 0x48
KEY_Y, // 0x49 KEY_4, // 0x49
KEY_SEMICOLON, // 0x4A KEY_5, // 0x4A
KEY_LEFT_BRACE, // 0x4B KEY_6, // 0x4B
KEY_RIGHT_BRACE, // 0x4C KEY_L, // 0x4C
KEY_BACKSLASH, // 0x4D KEY_TAB, // 0x4D
KEY_DELETE, // 0x4E KEY_Q, // 0x4E
KEYPAD_4, // 0x4F KEY_W, // 0x4F
KEY_ESC, // 0x50 KEY_F, // 0x50
KEY_1, // 0x51 KEY_P, // 0x51
KEY_2, // 0x52 KEY_G, // 0x52
KEY_3, // 0x53 KEY_J, // 0x53
KEY_4, // 0x54 KEY_H, // 0x54
KEY_5, // 0x55 KEY_2, // 0x55
KEY_6, // 0x56 KEY_LEFT_GUI, // 0x56
KEY_7, // 0x57 KEY_A, // 0x57
KEY_8, // 0x58 KEY_R, // 0x58
KEY_9, // 0x59 KEY_S, // 0x59
KEY_0, // 0x5A KEY_T, // 0x5A
KEY_MINUS, // 0x5B KEY_ESC, // 0x5B
KEY_EQUAL, // 0x5C KEYPAD_COMMA, // 0x5C
KEY_TILDE, // 0x5D KEYPAD_TAB, // 0x5D
KEY_BACKSPACE, // 0x5E KEYPAD_6, // 0x5E
KEY_NUM_LOCK, // 0x5F KEYPAD_9, // 0x5F
KEY_LEFT_GUI, // 0x60 KEYPAD_5, // 0x60
KEY_HOME, // 0x61 KEYPAD_8, // 0x61
KEY_END, // 0x62 KEYPAD_4, // 0x62
KEY_INSERT, // 0x63 KEYPAD_7, // 0x63
KEY_DELETE, // 0x64 KEY_TAB, // 0x64
KEY_F1, // 0x65 KEYPAD_MINUS, // 0x65
KEY_F2, // 0x66 KEYPAD_3, // 0x66
KEY_F3, // 0x67 KEYPAD_PLUS, // 0x67
KEY_F4, // 0x68 KEYPAD_2, // 0x68
KEY_F5, // 0x69 KEYPAD_SLASH, // 0x69
KEY_F6, // 0x6A KEYPAD_1, // 0x6A
KEY_F7, // 0x6B KEYPAD_ASTERIX, // 0x6B
KEY_F8, // 0x6C 0, // 0x6C
KEY_F9, // 0x6D KEY_F12, // 0x6D
KEY_F10, // 0x6E KEYPAD_PERIOD, // 0x6E
KEY_PRINTSCREEN, // 0x6F KEY_F11, // 0x6F
KEY_PAGE_UP, // 0x70 0, // 0x70
KEY_PAGE_DOWN, // 0x71 KEY_F10, // 0x71
KEY_F11, // 0x72 KEYPAD_0, // 0x72
KEYPAD_7, // 0x73 KEY_F9, // 0x73
KEYPAD_8, // 0x74 KEY_K, // 0x74
KEYPAD_9, // 0x75 KEY_ESC, // 0x75
KEY_UP, // 0x76 (KEYPAD_5) KEY_GUI, // 0x76
KEYPAD_6, // 0x77 KEY_Z, // 0x77
KEY_DOWN, // 0x78 (KEYPAD_2) KEY_X, // 0x78
KEY_RIGHT, // 0x79 (KEYPAD_3) KEY_C, // 0x79
KEYPAD_0, // 0x7A KEY_V, // 0x7A
KEYPAD_00, // 0x7B KEY_B, // 0x7B
KEYPAD_ENTER, // 0x7C 0, // 0x7C
0, // 0x7D 0, // 0x7D
0, // 0x7E 0, // 0x7E
0, // 0x7F 0, // 0x7F

View File

@ -252,6 +252,7 @@ uint8_t sendCode = 0;
int usbcodeMacro( uint8_t usbCode ) int usbcodeMacro( uint8_t usbCode )
{ {
// Keyboard Input Test Macro // Keyboard Input Test Macro
/*
switch ( usbCode ) switch ( usbCode )
{ {
case KEY_F1: case KEY_F1:
@ -304,7 +305,8 @@ int usbcodeMacro( uint8_t usbCode )
} }
return 1; return 1;
//return 0; */
return 0;
} }

View File

@ -41,6 +41,7 @@
#define DATA_PORT PORTC #define DATA_PORT PORTC
#define DATA_DDR DDRC #define DATA_DDR DDRC
#define DATA_PIN 7 #define DATA_PIN 7
#define DATA_OUT PINC
#define CLOCK_PORT PORTC #define CLOCK_PORT PORTC
#define CLOCK_DDR DDRC #define CLOCK_DDR DDRC
@ -68,6 +69,8 @@ volatile uint8_t KeyIndex_BufferUsed;
volatile uint8_t KeyIndex_Add_InputSignal; // Used to pass the (click/input value) to the keyboard for the clicker 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 currentWaveState = 0;
volatile uint8_t currentWaveDone = 0;
volatile uint8_t positionCounter = 0;
// Buffer Signals // Buffer Signals
@ -90,7 +93,9 @@ ISR( TIMER1_COMPA_vect )
if ( currentWaveState ) if ( currentWaveState )
{ {
CLOCK_PORT &= ~(1 << CLOCK_PIN); 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 else
{ {
@ -109,14 +114,15 @@ inline void scan_setup()
// Setup Timer Pulse (16 bit) // Setup Timer Pulse (16 bit)
// TODO Clock can be adjusted to whatever (read chip datasheets for limits) // 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 // 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(); cli();
TCCR1B = 0x09; TCCR1B = 0x09;
OCR1AH = 0x01; OCR1AH = 0x03;
OCR1AL = 0x09; OCR1AL = 0x1F;
TIMSK1 = (1 << OCIE1A); TIMSK1 = (1 << OCIE1A);
CLOCK_DDR = (1 << CLOCK_PIN); CLOCK_DDR = (1 << CLOCK_PIN);
sei(); sei();
@ -125,9 +131,6 @@ inline void scan_setup()
// Initially buffer doesn't need to be cleared (it's empty...) // Initially buffer doesn't need to be cleared (it's empty...)
BufferReadyToClear = 0; BufferReadyToClear = 0;
// InputSignal is off by default
KeyIndex_Add_InputSignal = 0x00;
// Reset the keyboard before scanning, we might be in a wierd state // Reset the keyboard before scanning, we might be in a wierd state
scan_resetKeyboard(); scan_resetKeyboard();
} }
@ -141,67 +144,75 @@ inline void scan_setup()
// Once the end of the packet has been detected (always the same length), decode the pressed keys // Once the end of the packet has been detected (always the same length), decode the pressed keys
inline uint8_t scan_loop() inline uint8_t scan_loop()
{ {
return 0; // Read on each falling edge/after the falling edge of the clock
} if ( !currentWaveDone )
void processKeyValue( uint8_t keyValue )
{
// Interpret scan code
switch ( keyValue )
{ {
case 0x00: // Break code from input? // Sample the current value 50 times
break; // If there is a signal for 40/50 of the values, then it is active
default: // This works as a very simple debouncing mechanism
// Make sure the key isn't already in the buffer // XXX Could be done more intelligently:
for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ ) // 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 use as a valid signal
if ( total >= 40 )
{ {
// Key isn't in the buffer yet // Reset the scan counter, all the keys have been iterated over
if ( c == KeyIndex_BufferUsed ) // 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 )
{ {
bufferAdd( keyValue ); positionCounter = 0;
// Only send data if enabled // Clear key buffer
if ( KeyIndex_Add_InputSignal ) KeyIndex_BufferUsed = 0;
scan_sendData( KeyIndex_Add_InputSignal );
break;
} }
// Key Press Detected
else
{
char tmp[15];
hexToStr( positionCounter, tmp );
dPrintStrsNL( "Key: ", tmp );
// Key already in the buffer bufferAdd( positionCounter );
if ( KeyIndex_Buffer[c] == keyValue ) }
break;
} }
break;
}
}
void removeKeyValue( uint8_t keyValue ) // Wait until the next falling clock edge for the next DATA scan
{ currentWaveDone++;
// 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];
// Decrement Buffer
KeyIndex_BufferUsed--;
break;
}
} }
// Error case (no key to release) // Check if the clock de-synchronized
if ( c == KeyIndex_BufferUsed + 1 ) // And reset
if ( positionCounter > 128 )
{ {
char tmp[15];
hexToStr( positionCounter, tmp );
erro_dPrint( "De-synchronization detected at: ", tmp );
errorLED( 1 ); errorLED( 1 );
char tmpStr[6];
hexToStr( keyValue, tmpStr ); positionCounter = 0;
erro_dPrint( "Could not find key to release: ", tmpStr ); 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 // Send data
@ -221,12 +232,12 @@ void scan_finishedWithUSBBuffer( void )
} }
// Reset/Hold keyboard // Reset/Hold keyboard
// NOTE: Does nothing with the BETKB // NOTE: Does nothing with the HP150
void scan_lockKeyboard( void ) void scan_lockKeyboard( void )
{ {
} }
// NOTE: Does nothing with the BETKB // NOTE: Does nothing with the HP150
void scan_unlockKeyboard( void ) void scan_unlockKeyboard( void )
{ {
} }
@ -234,6 +245,37 @@ void scan_unlockKeyboard( void )
// Reset Keyboard // Reset Keyboard
void scan_resetKeyboard( void ) 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!");
} }

View File

@ -42,7 +42,7 @@ add_definitions( -I${HEAD_DIR}/Keymap )
#| Keymap Settings #| Keymap Settings
add_definitions( add_definitions(
-DMODIFIER_MASK=hp150_ModifierMask -DMODIFIER_MASK=hp150_ModifierMask
#-DKEYINDEX_MASK=hp150_ColemakMap -DKEYINDEX_MASK=hp150_ColemakMap
-DKEYINDEX_MASK=hp150_DefaultMap #-DKEYINDEX_MASK=hp150_DefaultMap
) )

View File

@ -20,7 +20,7 @@
#| Please the {Scan,Macro,USB,Debug}/module.txt for information on the modules and how to create new ones #| 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 ##| 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 ##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code
set( MacroModule "buffer" ) set( MacroModule "buffer" )