Initial setup for cap sense controller
| 209 | |
| 210 | // Initial setup for cap sense controller |
| 211 | inline void Scan_setup() |
| 212 | { |
| 213 | // Register Scan CLI dictionary |
| 214 | CLI_registerDictionary( scanCLIDict, scanCLIDictName ); |
| 215 | |
| 216 | // Scan for active strobes |
| 217 | // NOTE1: On IBM PCBs, each strobe line that is *NOT* used is connected to GND. |
| 218 | // This means, the strobe GPIO can be set to Tri-State pull-up to detect which strobe lines are not used. |
| 219 | // NOTE2: This will *NOT* detect floating strobes. |
| 220 | // NOTE3: Rev 0.4, the strobe numbers are reversed, so D0 is actually strobe 0 and C7 is strobe 17 |
| 221 | info_print("Detecting Strobes..."); |
| 222 | |
| 223 | DDRC = 0; |
| 224 | PORTC = C_MASK; |
| 225 | DDRD = 0; |
| 226 | PORTD = D_MASK; |
| 227 | DDRE = 0; |
| 228 | PORTE = E_MASK; |
| 229 | |
| 230 | // Initially there are 0 strobes |
| 231 | total_strobes = 0; |
| 232 | |
| 233 | // Iterate over each the strobes |
| 234 | for ( uint8_t strobe = 0; strobe < MAX_STROBES; strobe++ ) |
| 235 | { |
| 236 | uint8_t detected = 0; |
| 237 | |
| 238 | // If PIN is high, then strobe is *NOT* connected to GND and may be a strobe |
| 239 | switch ( strobe ) |
| 240 | { |
| 241 | |
| 242 | // Strobe Mappings |
| 243 | // Rev Rev |
| 244 | // 0.2 0.4 |
| 245 | #ifndef REV0_4_DEBUG // XXX These pins should be reworked, and connect to GND on Rev 0.4 |
| 246 | case 0: // D0 0 n/c |
| 247 | case 1: // D1 1 n/c |
| 248 | #endif |
| 249 | case 2: // D2 2 15 |
| 250 | case 3: // D3 3 14 |
| 251 | case 4: // D4 4 13 |
| 252 | case 5: // D5 5 12 |
| 253 | case 6: // D6 6 11 |
| 254 | case 7: // D7 7 10 |
| 255 | detected = PIND & (1 << strobe); |
| 256 | break; |
| 257 | |
| 258 | case 8: // E0 8 9 |
| 259 | case 9: // E1 9 8 |
| 260 | detected = PINE & (1 << (strobe - 8)); |
| 261 | break; |
| 262 | |
| 263 | case 10: // C0 10 7 |
| 264 | case 11: // C1 11 6 |
| 265 | case 12: // C2 12 5 |
| 266 | case 13: // C3 13 4 |
| 267 | case 14: // C4 14 3 |
| 268 | case 15: // C5 15 2 |
nothing calls this directly
no test coverage detected
searching dependent graphs…