]> git.donarmstrong.com Git - kiibohd-controller.git/blobdiff - Scan/MicroSwitch8304/scan_loop.c
Intial commit of the SonyNEWS scan module
[kiibohd-controller.git] / Scan / MicroSwitch8304 / scan_loop.c
index 478a3348ea5d6e6db47ff34416bec1d79e2e95de..b8e4594befcaa9f47357eb452ec57f923455df90 100644 (file)
@@ -78,7 +78,7 @@ inline void scan_setup()
        // Setup baud rate
        // 16 MHz / ( 16 * Baud ) = UBRR
        // Baud <- 0.82020 ms per bit, thus 1000 / 0.82020 = 1219.2
-       // Thus baud = 820
+       // Thus baud setting = 820
        uint16_t baud = 820; // Max setting of 4095
        UBRR1H = (uint8_t)(baud >> 8);
        UBRR1L = (uint8_t)baud;
@@ -94,6 +94,10 @@ inline void scan_setup()
 
        // Initially buffer doesn't need to be cleared (it's empty...)
        BufferReadyToClear = 0;
+
+       // Reset the keyboard before scanning, we might be in a wierd state
+       // Note: This should be run asap, but we need the USART setup to run this command on the 8304
+       scan_resetKeyboard();
 }
 
 
@@ -223,3 +227,10 @@ void scan_unlockKeyboard( void )
        SET_RESET();
 }
 
+// Reset Keyboard
+void scan_resetKeyboard( void )
+{
+       // Reset command for the 8304
+       scan_sendData( 0x92 );
+}
+