Mercurial > louis > kiibohd-controller
annotate main.c @ 67:9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
- Abstracted USB Module
- Abstracted compiler specific includes for Scan, Macro, Debug, and USB modules
- Updated CMake build files to support changes
- Added abstractions necessary to main.c as well as a compiler specific include file
author | Jacob Alexander <triplehaata@gmail.com> |
---|---|
date | Sat, 26 Jan 2013 15:05:28 -0500 |
parents | d4552f24e4ad |
children | 23600aaa5e15 |
rev | line source |
---|---|
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
1 /* Copyright (C) 2011-2013 by Jacob Alexander |
0 | 2 * |
3 * Permission is hereby granted, free of charge, to any person obtaining a copy | |
4 * of this software and associated documentation files (the "Software"), to deal | |
5 * in the Software without restriction, including without limitation the rights | |
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
7 * copies of the Software, and to permit persons to whom the Software is | |
8 * furnished to do so, subject to the following conditions: | |
9 * | |
10 * The above copyright notice and this permission notice shall be included in | |
11 * all copies or substantial portions of the Software. | |
12 * | |
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
19 * THE SOFTWARE. | |
20 */ | |
21 | |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
22 // ----- Includes ----- |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
23 |
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
24 // Compiler Includes |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
25 #include <Lib/MainLib.h> |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
26 |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
27 // Project Includes |
25 | 28 #include <macro.h> |
29 #include <scan_loop.h> | |
30 #include <usb_com.h> | |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
31 |
25 | 32 #include <led.h> |
33 #include <print.h> | |
0 | 34 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
35 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
36 |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
37 // ----- Defines ----- |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
38 |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
39 // Verified Keypress Defines |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
40 #define USB_TRANSFER_DIVIDER 10 // 1024 == 1 Send of keypresses per second, 1 == 1 Send of keypresses per ~1 millisecond |
1
0f88e9aad77a
Initial macro line filler design for multiple keyboards matrices.
Jacob Alexander <triplehaata@gmail.com>
parents:
0
diff
changeset
|
41 |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
42 |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
43 |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
44 // ----- Macros ----- |
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
45 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
46 #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) |
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
47 #endif |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
48 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
49 |
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
50 |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
51 // ----- Variables ----- |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
52 |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
53 // Timer Interrupt for flagging a send of the sampled key detection data to the USB host |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
54 uint16_t sendKeypressCounter = 0; |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
55 |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
56 // Flag generated by the timer interrupt |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
57 volatile uint8_t sendKeypresses = 0; |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
58 |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
59 |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
60 |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
61 // ----- Functions ----- |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
62 |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
63 // Initial Pin Setup, make sure they are sane |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
64 inline void pinSetup(void) |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
65 { |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
26
diff
changeset
|
66 |
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
67 // AVR |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
68 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
69 |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
70 // For each pin, 0=input, 1=output |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
26
diff
changeset
|
71 #if defined(__AVR_AT90USB1286__) |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
72 DDRA = 0x00; |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
26
diff
changeset
|
73 #endif |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
74 DDRB = 0x00; |
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
75 DDRC = 0x00; |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
76 DDRD = 0x00; |
16
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
77 DDRE = 0x00; |
5
a8be29294c26
Updating for the latest pinout
Jacob Alexander <triplehaata@gmail.com>
parents:
4
diff
changeset
|
78 DDRF = 0x00; |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
79 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
80 |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
81 // Setting pins to either high or pull-up resistor |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
26
diff
changeset
|
82 #if defined(__AVR_AT90USB1286__) |
16
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
83 PORTA = 0x00; |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
26
diff
changeset
|
84 #endif |
16
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
85 PORTB = 0x00; |
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
86 PORTC = 0x00; |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
87 PORTD = 0x00; |
16
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
88 PORTE = 0x00; |
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
89 PORTF = 0x00; |
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
90 |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
91 // ARM |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
92 #elif defined(_mk20dx128_) |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
93 // TODO |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
94 #endif |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
95 } |
7
18e424630cbd
Adding basic per line keypad detection
Jacob Alexander <haata@users.sf.net>
parents:
6
diff
changeset
|
96 |
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
97 |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
98 inline void usbTimerSetup(void) |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
99 { |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
100 // AVR |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
101 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
102 |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
103 // Setup with 16 MHz clock |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
104 CPU_PRESCALE( 0 ); |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
105 |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
106 // Setup ISR Timer for flagging a kepress send to USB |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
107 // Set to 256 * 1024 (8 bit timer with Clock/1024 prescalar) timer |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
108 TCCR0A = 0x00; |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
109 TCCR0B = 0x03; |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
110 TIMSK0 = (1 << TOIE0); |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
111 |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
112 // ARM |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
113 #elif defined(_mk20dx128_) |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
114 // TODO |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
115 #endif |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
116 } |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
117 |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
118 |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
119 int main(void) |
0 | 120 { |
121 // Configuring Pins | |
2
c3b2eaa4a89d
Significant progress made.
Jacob Alexander <triplehaata@gmail.com>
parents:
1
diff
changeset
|
122 pinSetup(); |
25 | 123 init_errorLED(); |
0 | 124 |
24
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
125 // Setup USB Module |
2d65da455ef3
Formalizing code module structure and inheritance (Large Commit)
Jacob Alexander <triplehaata@gmail.com>
parents:
18
diff
changeset
|
126 usb_setup(); |
0 | 127 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
128 // Setup ISR Timer for flagging a kepress send to USB |
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
129 usbTimerSetup(); |
4
b97797936037
Redefining pinouts and adding key sending code.
Jacob Alexander <triplehaata@gmail.com>
parents:
3
diff
changeset
|
130 |
0 | 131 // Main Detection Loop |
25 | 132 uint8_t ledTimer = 15; // Enable LED for a short time |
133 while ( 1 ) | |
134 { | |
26
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
135 // Setup the scanning module |
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
136 scan_setup(); |
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
137 |
25 | 138 while ( 1 ) |
139 { | |
140 // Acquire Key Indices | |
26
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
141 // Loop continuously until scan_loop returns 0 |
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
142 cli(); |
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
143 while ( scan_loop() ); |
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
144 sei(); |
25 | 145 |
27
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
26
diff
changeset
|
146 // Run Macros over Key Indices and convert to USB Keys |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
26
diff
changeset
|
147 process_macros(); |
8b8cad3db8db
Basic matrix module for the hall effect keypad now working.
Jacob Alexander <triplehaata@gmail.com>
parents:
26
diff
changeset
|
148 |
25 | 149 // Send keypresses over USB if the ISR has signalled that it's time |
150 if ( !sendKeypresses ) | |
151 continue; | |
152 | |
153 // Send USB Data | |
154 usb_send(); | |
155 | |
156 // Clear sendKeypresses Flag | |
157 sendKeypresses = 0; | |
158 | |
159 // Indicate Error, if valid | |
160 errorLED( ledTimer ); | |
26
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
161 |
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
162 if ( ledTimer > 0 ) |
c06a5ebb4fca
Tandy 1000 Converter, basicly works, except for packet mismatches
Jacob Alexander <triplehaata@gmail.com>
parents:
25
diff
changeset
|
163 ledTimer--; |
25 | 164 } |
16
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
165 |
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
166 // Loop should never get here (indicate error) |
25 | 167 ledTimer = 255; |
16
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
168 |
17
85bc68be98df
Code re-factor now compiles.
Jacob Alexander <triplehaata@gmail.com>
parents:
16
diff
changeset
|
169 // HID Debug Error message |
85bc68be98df
Code re-factor now compiles.
Jacob Alexander <triplehaata@gmail.com>
parents:
16
diff
changeset
|
170 erro_print("Detection loop error, this is very bad...bug report!"); |
16
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
171 } |
f74b797ac060
Parts of the upcoming rewrite
Jacob Alexander <triplehaata@gmail.com>
parents:
15
diff
changeset
|
172 } |
0 | 173 |
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
174 |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
175 // ----- Interrupts ----- |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
176 |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
177 // AVR - USB Keyboard Data Send Counter Interrupt |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
178 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
179 |
6
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
180 ISR( TIMER0_OVF_vect ) |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
181 { |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
182 sendKeypressCounter++; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
183 if ( sendKeypressCounter > USB_TRANSFER_DIVIDER ) { |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
184 sendKeypressCounter = 0; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
185 sendKeypresses = 1; |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
186 } |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
187 } |
9df636be6feb
Keyboard functionally working with very very good debouncing.
Jacob Alexander <triplehaata@gmail.com>
parents:
5
diff
changeset
|
188 |
67
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
189 // ARM - USB Keyboard Data Send Counter Interrupt |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
190 #elif defined(_mk20dx128_) |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
191 // TODO |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
192 #endif |
9ad7c1a28661
Preparing for Teensy 3 (ARM) integration, abstracting code hierarchy
Jacob Alexander <triplehaata@gmail.com>
parents:
40
diff
changeset
|
193 |