diff --git a/Scan/MatrixARM/matrix_scan.c b/Scan/MatrixARM/matrix_scan.c
index 8463b26..a9018df 100644
--- a/Scan/MatrixARM/matrix_scan.c
+++ b/Scan/MatrixARM/matrix_scan.c
@@ -196,6 +196,7 @@ void Matrix_setup()
print( NL );
info_msg("Max Keys: ");
printHex( Matrix_maxKeys );
+ print( NL );
// Clear out Debounce Array
for ( uint8_t item = 0; item < Matrix_maxKeys; item++ )
diff --git a/Scan/PortSwap/capabilities.kll b/Scan/PortSwap/capabilities.kll
new file mode 100644
index 0000000..347f39b
--- /dev/null
+++ b/Scan/PortSwap/capabilities.kll
@@ -0,0 +1,14 @@
+Name = PortSwapCapabilities;
+Version = 0.1;
+Author = "HaaTa (Jacob Alexander) 2015";
+KLL = 0.3d;
+
+# Modified Date
+Date = 2015-10-23;
+
+# Cross interconnect pins, required for complex cabling arrangements
+portCross => Port_cross_capability();
+
+# Capability to swap the USB port mapping
+portSwap => Port_swap_capability();
+
diff --git a/Scan/PortSwap/port_scan.c b/Scan/PortSwap/port_scan.c
new file mode 100644
index 0000000..40efc9a
--- /dev/null
+++ b/Scan/PortSwap/port_scan.c
@@ -0,0 +1,199 @@
+/* Copyright (C) 2015 by Jacob Alexander
+ *
+ * This file is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this file. If not, see .
+ */
+
+// ----- Includes -----
+
+// Compiler Includes
+#include
+
+// Project Includes
+#include
+#include
+#include
+#include
+
+// USB Includes
+#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
+#include
+#elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_)
+#include
+#endif
+
+// Interconnect Includes
+#include
+
+// Local Includes
+#include "port_scan.h"
+
+
+
+// ----- Defines -----
+
+
+
+// ----- Structs -----
+
+
+
+// ----- Function Declarations -----
+
+// CLI Functions
+void cliFunc_portCross( char* args );
+void cliFunc_portSwap ( char* args );
+
+
+
+// ----- Variables -----
+
+uint32_t Port_lastcheck_ms;
+
+// Scan Module command dictionary
+CLIDict_Entry( portCross, "Cross interconnect pins." );
+CLIDict_Entry( portSwap, "Swap USB ports manually, forces usb and interconnect to re-negotiate if necessary." );
+
+CLIDict_Def( portCLIDict, "Port Swap Module Commands" ) = {
+ CLIDict_Item( portCross ),
+ CLIDict_Item( portSwap ),
+ { 0, 0, 0 } // Null entry for dictionary end
+};
+
+
+
+// ----- Functions -----
+
+void Port_swap()
+{
+ info_print("USB Port Swap");
+
+ // PTA13 - USB Swap
+ GPIOA_PTOR |= (1<<13);
+
+ // Re-initialize usb
+ // Call usb_configured() to check if usb is ready
+ usb_init();
+}
+
+void Port_cross()
+{
+ info_print("Interconnect Line Cross");
+
+ // PTA12 - UART Tx/Rx cross-over
+ GPIOA_PTOR |= (1<<12);
+
+ // Reset interconnects
+ Connect_reset();
+}
+
+// Setup
+inline void Port_setup()
+{
+ // Register Scan CLI dictionary
+ CLI_registerDictionary( portCLIDict, portCLIDictName );
+
+ // PTA12 - UART Tx/Rx cross-over
+ // Start, disabled
+ GPIOA_PDDR |= (1<<12);
+ PORTA_PCR12 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
+ GPIOA_PCOR |= (1<<12);
+
+ // PTA13 - USB Swap
+ // Start, disabled
+ GPIOA_PDDR |= (1<<13);
+ PORTA_PCR13 = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1);
+ GPIOA_PCOR |= (1<<13);
+
+ // Starting point for automatic port swapping
+ Port_lastcheck_ms = systick_millis_count;
+}
+
+// Port State processing loop
+inline uint8_t Port_scan()
+{
+ // TODO Add in interconnect line cross
+
+ #define USBPortSwapDelay_ms 1000
+ // Wait 1000 ms before checking
+ // Only check for swapping after delay
+ uint32_t wait_ms = systick_millis_count - Port_lastcheck_ms;
+ if ( wait_ms > USBPortSwapDelay_ms )
+ {
+ // Update timeout
+ Port_lastcheck_ms = systick_millis_count;
+
+ // USB not initialized, attempt to swap
+ if ( !usb_configured() )
+ {
+ Port_swap();
+ }
+ }
+
+ return 0;
+}
+
+
+
+// ----- Capabilities -----
+
+void Port_swap_capability( uint8_t state, uint8_t stateType, uint8_t *args )
+{
+ // Display capability name
+ if ( stateType == 0xFF && state == 0xFF )
+ {
+ print("Port_swap_capability()");
+ return;
+ }
+
+ // Only only release
+ // TODO Analog
+ if ( state != 0x03 )
+ return;
+
+ Port_swap();
+}
+
+void Port_cross_capability( uint8_t state, uint8_t stateType, uint8_t *args )
+{
+ // Display capability name
+ if ( stateType == 0xFF && state == 0xFF )
+ {
+ print("Port_cross_capability()");
+ return;
+ }
+
+ // Only only release
+ // TODO Analog
+ if ( state != 0x03 )
+ return;
+
+ Port_cross();
+}
+
+
+
+// ----- CLI Command Functions -----
+
+void cliFunc_portSwap( char* args )
+{
+ print( NL );
+ Port_swap();
+}
+
+void cliFunc_portCross( char* args )
+{
+ print( NL );
+ Port_cross();
+}
+
diff --git a/Scan/PortSwap/port_scan.h b/Scan/PortSwap/port_scan.h
new file mode 100644
index 0000000..0e6cb2f
--- /dev/null
+++ b/Scan/PortSwap/port_scan.h
@@ -0,0 +1,30 @@
+/* Copyright (C) 2015 by Jacob Alexander
+ *
+ * This file is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This file is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this file. If not, see .
+ */
+
+#pragma once
+
+// ----- Includes -----
+
+// Compiler Includes
+#include
+
+
+
+// ----- Functions -----
+
+void Port_setup();
+uint8_t Port_scan();
+
diff --git a/Scan/PortSwap/setup.cmake b/Scan/PortSwap/setup.cmake
new file mode 100644
index 0000000..035377a
--- /dev/null
+++ b/Scan/PortSwap/setup.cmake
@@ -0,0 +1,30 @@
+###| CMake Kiibohd Controller Scan Module |###
+#
+# Written by Jacob Alexander in 2015 for the Kiibohd Controller
+#
+# Released into the Public Domain
+#
+###
+
+
+###
+# Sub-module flag, cannot be included stand-alone
+#
+set ( SubModule 1 )
+
+
+###
+# Module C files
+#
+set ( Module_SRCS
+ port_scan.c
+)
+
+
+###
+# Compiler Family Compatibility
+#
+set ( ModuleCompatibility
+ arm
+)
+