changeset 72:4c2712f25157

Main USB timer now working, basic Teensy 3 support working. - No scan modules are functional yet, but all of the API code is now "hardware support" complete
author Jacob Alexander <triplehaata@gmail.com>
date Wed, 30 Jan 2013 19:20:42 -0500
parents 8a344117d851
children 872273398943
files main.c
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/main.c	Wed Jan 30 18:13:49 2013 -0500
+++ b/main.c	Wed Jan 30 19:20:42 2013 -0500
@@ -90,7 +90,7 @@
 
 // ARM
 #elif defined(_mk20dx128_)
-	// TODO
+	// TODO - Should be cleared, but not that necessary due to the pin layout
 #endif
 }
 
@@ -113,15 +113,19 @@
 #elif defined(_mk20dx128_)
 	// 48 MHz clock by default
 
+	// System Clock Gating Register Disable
+	SIM_SCGC6 |= SIM_SCGC6_PIT;
+
 	// Enable Timers
-	/* TODO Fixme!!
 	PIT_MCR = 0x00;
 
 	// Setup ISR Timer for flagging a kepress send to USB
 	// 1 ms / (1 / 48 MHz) - 1 = 47999 cycles -> 0xBB7F
 	PIT_LDVAL0 = 0x0000BB7F;
 	PIT_TCTRL0 = 0x3; // Enable Timer 0 interrupts, and Enable Timer 0
-	*/
+
+	// Insert the required vector for Timer 0
+	NVIC_ENABLE_IRQ( IRQ_PIT_CH0 );
 #endif
 }
 
@@ -135,12 +139,11 @@
 	// Setup USB Module
 	usb_setup();
 
-	print("TEST");
 	// Setup ISR Timer for flagging a kepress send to USB
 	usbTimerSetup();
 
 	// Main Detection Loop
-	uint8_t ledTimer = 15; // Enable LED for a short time
+	uint8_t ledTimer = F_CPU / 1000000; // Enable LED for a short time
 	while ( 1 )
 	{
 		// Setup the scanning module
@@ -154,10 +157,6 @@
 			while ( scan_loop() );
 			sei();
 
-			// XXX DEBUG
-			dPrint("AAAAAAA\r\n");
-			print("AAAAAAB\r\n");
-
 			// Run Macros over Key Indices and convert to USB Keys
 			process_macros();
 
@@ -201,5 +200,10 @@
 		sendKeypressCounter = 0;
 		sendKeypresses = 1;
 	}
+
+#if defined(_mk20dx128_) // ARM
+	// Clear the interrupt flag
+	PIT_TFLG0 = 1;
+#endif
 }