Mercurial > louis > kiibohd-controller
annotate Scan/matrix/matrix.c @ 21:c14f9ac8420f
Reorganization for use with the CMake "Modules"
- Include option is currently "hacked" and needs to be fixed
- Builds on Linux, but Mac and Windows needs to be tested
- Loader script generation isn't complete
author | Jacob Alexander <triplehaata@gmail.com> |
---|---|
date | Wed, 28 Sep 2011 23:25:51 -0700 |
parents | |
children | 2d65da455ef3 |
rev | line source |
---|---|
21
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
1 /* Copyright (C) 2011 by Jacob Alexander |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
2 * |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
3 * Permission is hereby granted, free of charge, to any person obtaining a copy |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
4 * of this software and associated documentation files (the "Software"), to deal |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
5 * in the Software without restriction, including without limitation the rights |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
7 * copies of the Software, and to permit persons to whom the Software is |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
8 * furnished to do so, subject to the following conditions: |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
9 * |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
10 * The above copyright notice and this permission notice shall be included in |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
11 * all copies or substantial portions of the Software. |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
12 * |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
19 * THE SOFTWARE. |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
20 */ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
21 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
22 #include "matrix.h" |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
23 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
24 #define REG_SET(reg) reg |= (1 << ( matrix[row][col] % 10 ) ) |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
25 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
26 #define PIN_SET_COL(pin) \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
27 switch ( scanMode ) { \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
28 case scanCol: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
29 case scanCol_powrRow: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
30 case scanDual: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
31 REG_SET(port##pin); break; \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
32 case scanRow_powrCol: REG_SET(ddr##pin); REG_SET(port##pin); break; \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
33 } \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
34 break |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
35 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
36 #define PIN_SET_ROW(pin) \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
37 switch ( scanMode ) { \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
38 case scanRow: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
39 case scanRow_powrCol: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
40 case scanDual: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
41 REG_SET(port##pin); break; \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
42 case scanCol_powrRow: REG_SET(ddr##pin); REG_SET(port##pin); break; \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
43 } \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
44 break |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
45 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
46 #define PIN_CASE(pinLetter) \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
47 case pin##pinLetter##0: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
48 case pin##pinLetter##1: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
49 case pin##pinLetter##2: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
50 case pin##pinLetter##3: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
51 case pin##pinLetter##4: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
52 case pin##pinLetter##5: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
53 case pin##pinLetter##6: \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
54 case pin##pinLetter##7 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
55 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
56 #define PIN_TEST_COL(pin) \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
57 if ( !( pin & ( 1 << ( matrix[0][col] % 10 ) ) \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
58 detectArray[matrix[row][col]]++; \ |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
59 break |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
60 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
61 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
62 void matrix_pinSetup( uint8_t *matrix ) |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
63 { |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
64 // Setup the variables |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
65 uint8_t portA = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
66 uint8_t portB = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
67 uint8_t portC = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
68 uint8_t portD = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
69 uint8_t portE = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
70 uint8_t portF = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
71 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
72 uint8_t ddrA = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
73 uint8_t ddrB = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
74 uint8_t ddrC = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
75 uint8_t ddrD = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
76 uint8_t ddrE = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
77 uint8_t ddrF = 0x00; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
78 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
79 // Loop through all the pin assignments, for the initial pin settings |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
80 int row, col; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
81 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
82 // Rows |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
83 for ( row = 1; row < sizeof(matrix); row++ ) { |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
84 switch ( matrix[row][col] ) { |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
85 PIN_CASE(A): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
86 PIN_SET_ROW(A); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
87 PIN_CASE(B): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
88 PIN_SET_ROW(B); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
89 PIN_CASE(C): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
90 PIN_SET_ROW(C); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
91 PIN_CASE(D): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
92 PIN_SET_ROW(D); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
93 PIN_CASE(E): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
94 PIN_SET_ROW(E); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
95 PIN_CASE(F): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
96 PIN_SET_ROW(F); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
97 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
98 default: |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
99 continue; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
100 } |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
101 } |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
102 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
103 // Columns |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
104 for ( col = 1; col < sizeof(matrix[0]); row++ ) { |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
105 switch ( matrix[row][col] ) { |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
106 PIN_CASE(A): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
107 PIN_SET_COL(A); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
108 PIN_CASE(B): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
109 PIN_SET_COL(B); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
110 PIN_CASE(C): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
111 PIN_SET_COL(C); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
112 PIN_CASE(D): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
113 PIN_SET_COL(D); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
114 PIN_CASE(E): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
115 PIN_SET_COL(E); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
116 PIN_CASE(F): |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
117 PIN_SET_COL(F); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
118 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
119 default: |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
120 continue; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
121 } |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
122 } |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
123 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
124 // Setting the pins |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
125 DDRA = ddrA; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
126 DDRB = ddrB; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
127 DDRC = ddrC; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
128 DDRD = ddrD; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
129 DDRE = ddrE; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
130 DDRF = ddrF; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
131 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
132 PORTA = portA; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
133 PORTB = portB; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
134 PORTC = portC; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
135 PORTD = portD; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
136 PORTE = portE; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
137 PORTF = portF; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
138 } |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
139 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
140 // TODO Proper matrix scanning |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
141 void matrix_scan( uint8_t *matrix, uint8_t *detectArray ) |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
142 { |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
143 // Column Scan |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
144 #if scanMode == scanCol |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
145 uint8_t col = 1; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
146 uint8_t row = 1; |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
147 for ( ; col < sizeof(matrix[1]); col++ ) { |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
148 switch ( matrix[0][col] / 10 ) { |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
149 case 0: // PINA |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
150 PIN_TEST_COL(PINA); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
151 case 1: // PINB |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
152 PIN_TEST_COL(PINB); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
153 case 2: // PINC |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
154 PIN_TEST_COL(PINC); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
155 case 3: // PIND |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
156 PIN_TEST_COL(PIND); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
157 case 4: // PINE |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
158 PIN_TEST_COL(PINE); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
159 case 5: // PINF |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
160 PIN_TEST_COL(PINF); |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
161 } |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
162 } |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
163 #endif |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
164 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
165 // Row Scan |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
166 #if scanMode == scanRow |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
167 #endif |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
168 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
169 // Column Scan, Power Row |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
170 #if scanMode == scanCol_powrRow |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
171 #endif |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
172 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
173 // Row Scan, Power Column |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
174 #if scanMode == scanRow_powrCol |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
175 #endif |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
176 |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
177 // Dual Scan |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
178 #if scanMode == scanDual |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
179 #endif |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
180 } |
c14f9ac8420f
Reorganization for use with the CMake "Modules"
Jacob Alexander <triplehaata@gmail.com>
parents:
diff
changeset
|
181 |