Setup
| 64 | |
| 65 | // Setup |
| 66 | inline void Scan_setup() |
| 67 | { |
| 68 | // Setup the the USART interface for keyboard data input |
| 69 | // NOTE: The input data signal needs to be inverted for the Teensy USART to properly work |
| 70 | |
| 71 | // Setup baud rate |
| 72 | // 16 MHz / ( 16 * Baud ) = UBRR |
| 73 | // Baud <- 0.82020 ms per bit, thus 1000 / 0.82020 = 1219.2 |
| 74 | // Thus baud setting = 820 |
| 75 | uint16_t baud = 820; // Max setting of 4095 |
| 76 | UBRR1H = (uint8_t)(baud >> 8); |
| 77 | UBRR1L = (uint8_t)baud; |
| 78 | |
| 79 | // Enable the receiver, transitter, and RX Complete Interrupt |
| 80 | UCSR1B = 0x98; |
| 81 | |
| 82 | // Set frame format: 8 data, no stop bits or parity |
| 83 | // Asynchrounous USART mode |
| 84 | // 8304 sends encoded scancodes (for example Alphanumeric 0-9 follows their keypad encoding scheme) |
| 85 | // Separate line is for reset |
| 86 | UCSR1C = 0x06; |
| 87 | |
| 88 | // Initially buffer doesn't need to be cleared (it's empty...) |
| 89 | BufferReadyToClear = 0; |
| 90 | |
| 91 | // Reset the keyboard before scanning, we might be in a wierd state |
| 92 | // Note: This should be run asap, but we need the USART setup to run this command on the 8304 |
| 93 | scan_resetKeyboard(); |
| 94 | } |
| 95 | |
| 96 | |
| 97 | // Main Detection Loop |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…