MCPcopy Create free account
hub / github.com/kiibohd/controller / Scan_setup

Function Scan_setup

Scan/Deprecated/MicroSwitch8304/scan_loop.c:66–94  ·  view source on GitHub ↗

Setup

Source from the content-addressed store, hash-verified

64
65// Setup
66inline 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…