annotate Scan/BETKB/scan_loop.c @ 48:8eee22f99cae

Completing the BETKB support - Keyboard is fully functional - LED, Beeper, and keyboard input not yet implemented
author Jacob Alexander <triplehaata@gmail.com>
date Tue, 27 Mar 2012 00:04:43 -0400
parents 0ee2207c5919
children 37f0411655cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
1 /* Copyright (C) 2012 by Jacob Alexander
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
2 *
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
4 * of this software and associated documentation files (the "Software"), to deal
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
5 * in the Software without restriction, including without limitation the rights
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
7 * copies of the Software, and to permit persons to whom the Software is
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
8 * furnished to do so, subject to the following conditions:
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
9 *
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
10 * The above copyright notice and this permission notice shall be included in
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
11 * all copies or substantial portions of the Software.
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
12 *
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
19 * THE SOFTWARE.
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
20 */
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
21
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
22 // ----- Includes -----
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
23
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
24 // AVR Includes
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
25 #include <avr/interrupt.h>
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
26 #include <avr/io.h>
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
27 #include <util/delay.h>
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
28
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
29 // Project Includes
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
30 #include <led.h>
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
31 #include <print.h>
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
32
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
33 // Local Includes
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
34 #include "scan_loop.h"
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
35
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
36
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
37
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
38 // ----- Defines -----
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
39
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
40 // Pinout Defines
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
41 #define RESET_PORT PORTB
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
42 #define RESET_DDR DDRD
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
43 #define RESET_PIN 0
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
44
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
45
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
46 // ----- Macros -----
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
48 // Make sure we haven't overflowed the buffer
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
49 #define bufferAdd(byte) \
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
50 if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER ) \
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
51 KeyIndex_Buffer[KeyIndex_BufferUsed++] = byte
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
52
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
53
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
54
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
55 // ----- Variables -----
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
56
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
57 // Buffer used to inform the macro processing module which keys have been detected as pressed
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
58 volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
59 volatile uint8_t KeyIndex_BufferUsed;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
60
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
61
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
62 // Buffer Signals
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
63 volatile uint8_t BufferReadyToClear;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
64
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
65
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
66
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
67 // ----- Function Declarations -----
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
68
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
69 void processKeyValue( uint8_t keyValue );
48
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
70 void removeKeyValue( uint8_t keyValue );
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
71
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
72
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
73
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
74 // ----- Interrupt Functions -----
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
75
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
76 // USART Receive Buffer Full Interrupt
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
77 ISR(USART1_RX_vect)
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
78 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
79 cli(); // Disable Interrupts
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
80
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
81 uint8_t keyValue = 0x00;
48
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
82 uint8_t keyState = 0x00;
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
83
48
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
84 // Read the scancode packet from the USART (1st to 8th bits)
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
85 keyValue = UDR1;
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
86
48
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
87 // Read the release/press bit (9th bit) XXX Unnecessary, and wrong it seems, parity bit? or something else?
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
88 keyState = UCSR1B & 0x02;
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
89
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
90 // High bit of keyValue, also represents press/release
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
91 keyState = keyValue & 0x80 ? 0x00 : 0x02;
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
92
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
93 // Debug
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
94 char tmpStr[6];
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
95 hexToStr( keyValue & 0x7F, tmpStr );
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
96
48
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
97 // Process the scancode
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
98 switch ( keyState )
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
99 {
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
100 case 0x00: // Released
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
101 dPrintStrs( tmpStr, "R " ); // Debug
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
102
48
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
103 // Remove key from press buffer
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
104 removeKeyValue( keyValue & 0x7F );
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
105 break;
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
106
48
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
107 case 0x02: // Pressed
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
108 dPrintStrs( tmpStr, "P " ); // Debug
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
109
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
110 // New key to process
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
111 processKeyValue( keyValue & 0x7F );
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
112 break;
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
113 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
114
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
115 sei(); // Re-enable Interrupts
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
116 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
117
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
118
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
119
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
120 // ----- Functions -----
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
121
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
122 // Setup
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
123 inline void scan_setup()
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
124 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
125 // Setup the the USART interface for keyboard data input
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
126 // NOTE: The input data signal needs to be inverted for the Teensy USART to properly work
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
127
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
128 // Setup baud rate
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
129 // 16 MHz / ( 16 * Baud ) = UBRR
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
130 // Baud <- 0.823284 ms per bit, thus 1000 / 0.823284 = 1214.65004 -> 823.2824
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
131 // Thus baud setting = 823
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
132 uint16_t baud = 823; // Max setting of 4095
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
133 UBRR1H = (uint8_t)(baud >> 8);
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
134 UBRR1L = (uint8_t)baud;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
135
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
136 // Enable the receiver, transitter, and RX Complete Interrupt as well as 9 bit data
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
137 UCSR1B = 0x9C;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
138
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
139 // Set frame format: 9 data, 1 stop bit, no parity
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
140 // Asynchrounous USART mode
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
141 UCSR1C = 0x06;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
142
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
143 // Initially buffer doesn't need to be cleared (it's empty...)
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
144 BufferReadyToClear = 0;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
145
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
146 // Reset the keyboard before scanning, we might be in a wierd state
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
147 scan_resetKeyboard();
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
148 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
149
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
150
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
151 // Main Detection Loop
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
152 // Not needed for the BETKB, this is just a busy loop
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
153 inline uint8_t scan_loop()
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
154 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
155 return 0;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
156 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
157
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
158 // TODO
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
159 void processKeyValue( uint8_t keyValue )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
160 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
161 // Interpret scan code
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
162 switch ( keyValue )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
163 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
164 default:
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
165 // Make sure the key isn't already in the buffer
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
166 for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
167 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
168 // Key isn't in the buffer yet
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
169 if ( c == KeyIndex_BufferUsed )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
170 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
171 bufferAdd( keyValue );
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
172 break;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
173 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
174
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
175 // Key already in the buffer
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
176 if ( KeyIndex_Buffer[c] == keyValue )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
177 break;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
178 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
179 break;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
180 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
181 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
182
48
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
183 void removeKeyValue( uint8_t keyValue )
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
184 {
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
185 // Check for the released key, and shift the other keys lower on the buffer
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
186 uint8_t c;
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
187 for ( c = 0; c < KeyIndex_BufferUsed; c++ )
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
188 {
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
189 // Key to release found
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
190 if ( KeyIndex_Buffer[c] == keyValue )
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
191 {
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
192 // Shift keys from c position
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
193 for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
194 KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1];
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
195
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
196 // Decrement Buffer
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
197 KeyIndex_BufferUsed--;
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
198
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
199 break;
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
200 }
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
201 }
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
202
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
203 // Error case (no key to release)
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
204 if ( c == KeyIndex_BufferUsed + 1 )
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
205 {
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
206 errorLED( 1 );
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
207 char tmpStr[6];
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
208 hexToStr( keyValue, tmpStr );
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
209 erro_dPrint( "Could not find key to release: ", tmpStr );
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
210 }
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
211 }
8eee22f99cae Completing the BETKB support
Jacob Alexander <triplehaata@gmail.com>
parents: 47
diff changeset
212
47
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
213 // Send data
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
214 uint8_t scan_sendData( uint8_t dataPayload )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
215 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
216 UDR1 = dataPayload;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
217 return 0;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
218 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
219
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
220 // Signal KeyIndex_Buffer that it has been properly read
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
221 // TODO
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
222 void scan_finishedWithBuffer( void )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
223 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
224 return;
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
225 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
226
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
227 // Signal that the keys have been properly sent over USB
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
228 // TODO
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
229 void scan_finishedWithUSBBuffer( void )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
230 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
231 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
232
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
233 // Reset/Hold keyboard
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
234 // NOTE: Does nothing with the BETKB
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
235 void scan_lockKeyboard( void )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
236 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
237 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
238
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
239 // NOTE: Does nothing with the BETKB
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
240 void scan_unlockKeyboard( void )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
241 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
242 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
243
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
244 // Reset Keyboard
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
245 // TODO?
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
246 // - Holds the input read line high to flush the buffer
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
247 // - This does not actually reset the keyboard, but always seems brings it to a sane state
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
248 // - Won't work fully if keys are being pressed done at the same time
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
249 void scan_resetKeyboard( void )
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
250 {
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
251 // Initiate data request line, but don't read the incoming data
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
252 //REQUEST_DATA(); TODO
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
253
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
254 // Not a calculated valued...
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
255 _delay_ms( 50 );
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
256
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
257 // Stop request line
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
258 //STOP_DATA(); TODO
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
259 }
0ee2207c5919 Initial commit of the Burroughs Ergonomic Terminal Keyboard module (BETKB)
Jacob Alexander <triplehaata@gmail.com>
parents:
diff changeset
260