]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Updating AVR abstraction to be compatible with ARM, nearly ready for ARM files
authorJacob Alexander <triplehaata@gmail.com>
Sun, 27 Jan 2013 03:30:36 +0000 (22:30 -0500)
committerJacob Alexander <triplehaata@gmail.com>
Sun, 27 Jan 2013 03:30:36 +0000 (22:30 -0500)
- Very small updates to files, mostly modifying to remove name duplications

29 files changed:
Debug/print/print.c
Debug/print/print.h
Lib/MacroLib.h
Lib/MainLib.h
Lib/ScanLib.h
Lib/USBLib.h
Macro/buffer/macro.c
Scan/BETKB/scan_loop.h
Scan/BudKeypad/matrix.h
Scan/EpsonQX-10/scan_loop.h
Scan/FACOM6684/scan_loop.c
Scan/FACOM6684/scan_loop.h
Scan/HP150/scan_loop.h
Scan/HeathZenith/matrix.h
Scan/IBMConvertible/matrix.h
Scan/Kaypro1/scan_loop.h
Scan/MicroSwitch8304/scan_loop.h
Scan/SKM67001/matrix.h
Scan/SonyNEWS/scan_loop.h
Scan/SonyOA-S3400/scan_loop.h
Scan/Tandy1000/scan_loop.h
Scan/UnivacF3W9/scan_loop.h
Scan/matrix/matrix_template.h
Scan/matrix/scan_loop.c
Scan/matrix/scan_loop.h
USB/pjrc/setup.cmake
USB/pjrc/usb_com.c
USB/pjrc/usb_com.h
arm.cmake

index 2952c149202672db93ba5fada63f864bb08698d5..04590adab2e8f58e8e83a3c8b4e84a83ec97c544 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 by Jacob Alexander
+/* Copyright (C) 2011-2013 by Jacob Alexander
  * 
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
 // USB HID String Output
 void usb_debug_putstr( char* s )
 {
+#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
        while ( *s != '\0' )
                usb_debug_putchar( *s++ );
+#elif defined(_mk20dx128_) // ARM
+       // Count characters until NULL character, then send the amount counted
+       uint32_t count = 0;
+       while ( s[count] != '\0' )
+               count++;
+
+       usb_serial_write( s, count );
+#endif
 }
 
 // Multiple string Output
@@ -64,6 +73,7 @@ void usb_debug_putstrs( char* first, ... )
 // Print a constant string
 void _print(const char *s)
 {
+#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
        char c;
 
        // Acquire the character from flash, and print it, as long as it's not NULL
@@ -74,6 +84,9 @@ void _print(const char *s)
                        usb_debug_putchar('\r');
                usb_debug_putchar(c);
        }
+#elif defined(_mk20dx128_) // ARM
+       usb_debug_putstr( (char*)s );
+#endif
 }
 
 
index e5ba872f991540cbe4e557ec5c50d7e199894358..b67f9200d2ab21b13ef364cad6f8c4ed0fe9bfac 100644 (file)
@@ -32,7 +32,7 @@
 
 #elif defined(_mk20dx128_)
 
-#include "arm/usb_keyboard.h"
+#include "arm/usb_serial.h"
 
 #endif
 
index 9bf22a81b07d7a771864a3dbc8394ff7a54fb79b..8b92489d8a68902e5e89625213203ba5bafc3187 100644 (file)
 // Additional includes should only be added to this file if they should be added to *all* Macro modules.
 
 
-// ----- Includes -----
-
 #ifndef __MACROLIB_H
 #define __MACROLIB_H
 
+// ----- Includes -----
+
+#include <Lib/Interrupts.h>
+
+
+
 // ARM
 #if defined(_mk20dx128_)
 
@@ -43,7 +47,6 @@
 // AVR
 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
 
-#include <avr/interrupt.h>
 #include <util/delay.h>
 
 #endif
index 9ccb7e320b4be246923ba70320dae55d2a1859df..b3aa20e750208fba226180698811214351e691e6 100644 (file)
 // Additional includes should only be added to this file if they should be added to *all* Scan modules.
 
 
+#ifndef __MAINLIB_H
+#define __MAINLIB_H
+
 // ----- Includes -----
 
-#ifndef __MACROLIB_H
-#define __MACROLIB_H
+#include <Lib/Interrupts.h>
+
+
 
 // ARM
 #if defined(_mk20dx128_)
@@ -43,7 +47,6 @@
 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
 
 #include <avr/io.h>
-#include <avr/interrupt.h>
 
 #endif
 
index 5d6d6d6eff88c8978e5a9c003bda7179d704e1a5..d14b09102ccf9d7dbee90d4f3254ed8925f183ac 100644 (file)
 // Additional includes should only be added to this file if they should be added to *all* Scan modules.
 
 
-// ----- Includes -----
-
 #ifndef __SCANLIB_H
 #define __SCANLIB_H
 
+// ----- Includes -----
+
+#include <Lib/Interrupts.h>
+
+
+
 // ARM
 #if defined(_mk20dx128_)
 
@@ -43,7 +47,6 @@
 // AVR
 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
 
-#include <avr/interrupt.h>
 #include <avr/io.h>
 #include <util/delay.h>
 
index 7ebd0343b89f7b676f1e0efb95a5fc7358ac5d58..59b837c13625b9881cf32e8f9e991eb4c308ad62 100644 (file)
 // Additional includes should only be added to this file if they should be added to *all* Scan modules.
 
 
-// ----- Includes -----
+#ifndef __USBLIB_H
+#define __USBLIB_H
 
-#ifndef __MACROLIB_H
-#define __MACROLIB_H
+// ----- Includes -----
 
 // ARM
 #if defined(_mk20dx128_)
index e25b0c9fc2d80538beef8a372c14cb7585f51f2a..b7d645eeef547335cca427b9d860cf9f79a2c4df 100644 (file)
@@ -77,6 +77,7 @@ inline void macro_finishedWithBuffer( uint8_t sentKeys )
 
 void jumpToBootloader(void)
 {
+#if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
        cli();
        // disable watchdog, if enabled
        // disable all peripherals
@@ -110,6 +111,7 @@ void jumpToBootloader(void)
        PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
        asm volatile("jmp 0x1FC00");
 #endif
+#endif
 }
 
 // Given a sampling array, and the current number of detected keypress
index e49160636aaee2596df49ca8be9307bcd953898e..dbd1106df6cfc5c316ac603c90cd6f238afcf20f 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x7F // 127 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_KEYS 0x7F // 127 - Size of the array space for the keyboard(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index 14306236280daf91e91401c0463c853ff296abb7..978059a21f9961e51da9ae347783facd17a36e15 100644 (file)
@@ -36,7 +36,7 @@
 
 // ----- Key Settings -----
 
-#define KEYBOARD_SIZE 16 // # of keys
+#define KEYBOARD_KEYS 16 // # of keys
 #define MAX_ROW_SIZE  16 // # of keys in the largest row
 #define MAX_COL_SIZE   1 // # of keys in the largest column
 
index 1e056266dcb1c58f4d8d42858272cc0254cea3b4..6171ba0dab97715147322ca0ea7e4fd1712ee994 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x68 // 104 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_KEYS 0x68 // 104 - Size of the array space for the keyboard(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index 57e3683aa0d35140a2c94f994b7d5175344ec9e7..e2225aa76dbde25e03e7ada078a043b199834318 100644 (file)
@@ -108,7 +108,6 @@ ISR(USART1_RX_vect)
 inline void scan_setup()
 {
        // Setup the the USART interface for keyboard data input
-       // NOTE: The input data signal needs to be inverted for the Teensy USART to properly work
        
        // Setup baud rate
        // 16 MHz / ( 16 * Baud ) = UBRR
index cec677cc261e585cde22cbac40c5015f0dbaaf79..c46a2a76ba69785de12767099bca4caf7dc800a8 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x7F // 127 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_KEYS 0x7F // 127 - Size of the array space for the keyboard(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index e49160636aaee2596df49ca8be9307bcd953898e..dbd1106df6cfc5c316ac603c90cd6f238afcf20f 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x7F // 127 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_KEYS 0x7F // 127 - Size of the array space for the keyboard(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index b8c029e44c5c05d3f8d3978eaddd963db9c824c8..451fe3994e848e1f87bab0317a7acc13c1576eff 100644 (file)
@@ -36,7 +36,7 @@
 
 // ----- Key Settings -----
 
-#define KEYBOARD_SIZE 63 // # of keys
+#define KEYBOARD_KEYS 63 // # of keys
 #define MAX_ROW_SIZE  12 // # of keys in the largest row
 #define MAX_COL_SIZE   9 // # of keys in the largest column
 
index 5802d6f1aa0ea16d11852d4ddeee447c444cad7e..e89b82a2159a13384c5968570ca053b26698f3da 100644 (file)
@@ -36,7 +36,7 @@
 
 // ----- Key Settings -----
 
-#define KEYBOARD_SIZE 90 // # of keys (It actually has 78, but there are markings up to 81 on the PCB and scan lines enough for 90
+#define KEYBOARD_KEYS 90 // # of keys (It actually has 78, but there are markings up to 81 on the PCB and scan lines enough for 90
 #define MAX_ROW_SIZE   6 // # of rows
 #define MAX_COL_SIZE  15 // # of columns
 
index 661c2048efe5c6ed8f42b30a128c40a925742c50..9f84f5d926945c949e361dde3b089962cfd33f71 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x4c // 76 - Size of the array space for the keyboardr(max index)
+#define KEYBOARD_KEYS 0x4c // 76 - Size of the array space for the keyboardr(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index 0a46ffa7940264783a3a5dec727bdffe4152e1ef..1f0c6760cd276665b1a42ce819e07fe8f353d0d7 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x62 // 98 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_KEYS 0x62 // 98 - Size of the array space for the keyboard(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index ebb2833fa99b2c19cabdbf0a8752a6903ea41a0b..406e97c9d85180db96ca67450b82a2fc495def14 100644 (file)
@@ -36,7 +36,7 @@
 
 // ----- Key Settings -----
 
-#define KEYBOARD_SIZE 85 // # of keys (It actually has 66, but there are markings up to 80 on the PCB); 85 due to there being 5 "switch" keys, that have no numbers
+#define KEYBOARD_KEYS 85 // # of keys (It actually has 66, but there are markings up to 80 on the PCB); 85 due to there being 5 "switch" keys, that have no numbers
 #define MAX_ROW_SIZE   9 // # of keys in the largest row
 #define MAX_COL_SIZE   9 // # of keys in the largest column
 
index 1e056266dcb1c58f4d8d42858272cc0254cea3b4..6171ba0dab97715147322ca0ea7e4fd1712ee994 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x68 // 104 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_KEYS 0x68 // 104 - Size of the array space for the keyboard(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index 7d7f309669382d919da86dc8939e077cee1c717f..74b0a22fe26faf66ae12c1d47e43d28e6411cd7f 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0xFF // 255 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_KEYS 0xFF // 255 - Size of the array space for the keyboard(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index 911960a92ce29bcb05d3f42dd6e0623731c5fa42..b2905054ef2a40311539b1920900f592b76a8708 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x5A // 90 - Size of the array space for the keyboardr(max index)
+#define KEYBOARD_KEYS 0x5A // 90 - Size of the array space for the keyboardr(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index 8f2e69e1a1ae9a10e3936afc995e8c52d32cf7d8..4449e9ffecdf7bd14f48c5deffe357a43374febd 100644 (file)
@@ -33,7 +33,7 @@
 
 // ----- Defines -----
 
-#define KEYBOARD_SIZE 0x68 // 104 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_KEYS 0x68 // 104 - Size of the array space for the keyboard(max index)
 #define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
 
 
index 1573af4b3f036cc1bc2c5e5d646d213f73795d2f..719fd0a80b285894eece09dc0279a6140af230e6 100644 (file)
@@ -38,7 +38,7 @@
 
 // -- Example for scanCol --
 /*
-#define KEYBOARD_SIZE 16 // # of keys
+#define KEYBOARD_KEYS 16 // # of keys
 #define MAX_ROW_SIZE  16 // # of keys in the largest row
 #define MAX_COL_SIZE   1 // # of keys in the largest column
 */
@@ -46,7 +46,7 @@
 
 // -- Example for scanRow --
 /*
-#define KEYBOARD_SIZE 16 // # of keys
+#define KEYBOARD_KEYS 16 // # of keys
 #define MAX_ROW_SIZE   1 // # of keys in the largest row
 #define MAX_COL_SIZE  16 // # of keys in the largest column
 */
@@ -54,7 +54,7 @@
 
 // -- Example for scanRow_powrCol, scanCol_powrRow, and scanDual --
 /*
-#define KEYBOARD_SIZE 69 // # of keys
+#define KEYBOARD_KEYS 69 // # of keys
 #define MAX_ROW_SIZE   8 // # of keys in the largest row
 #define MAX_COL_SIZE   9 // # of keys in the largest column
 */
index 34b72cac54bf72cbb835dc1ffdcb04a098969454..3bca0548de787d2a4b0bacb4a3b114ba0ee3f9eb 100644 (file)
@@ -67,7 +67,7 @@ uint8_t scan_count = 0;
 
 // This is where the matrix scan data is held, as well as debouncing is evaluated to, which (depending on the read value) is handled
 //  by the macro module
-uint8_t KeyIndex_Array[KEYBOARD_SIZE + 1];
+uint8_t KeyIndex_Array[KEYBOARD_KEYS + 1];
 
 
 
index c0f7aa31da6bb67a73e3515f823d5c23f88840ff..d3fa133a0eebb96eabde052ec7166a9e35282e32 100644 (file)
@@ -45,8 +45,8 @@
 
 // NOTE: Highest Bit: Valid keypress (0x80 is valid keypress)
 //        Other Bits: Pressed state sample counter
-extern                       uint8_t KeyIndex_Array [KEYBOARD_SIZE + 1];
-                static const uint8_t KeyIndex_Size = KEYBOARD_SIZE;
+extern                       uint8_t KeyIndex_Array [KEYBOARD_KEYS + 1];
+                static const uint8_t KeyIndex_Size = KEYBOARD_KEYS;
 
 extern volatile              uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
 extern volatile              uint8_t KeyIndex_BufferUsed;
index 90b23a1e634428a1648d273afaa81728844786cb..171615e28cd0db89da9df56a1682de8113b5406b 100644 (file)
@@ -29,6 +29,7 @@ elseif ( ${COMPILER_FAMILY} MATCHES "arm" )
                arm/usb_dev.c
                arm/usb_keyboard.c
                arm/usb_mem.c
+               arm/usb_serial.c
        )
 
 endif ( ${COMPILER_FAMILY} MATCHES "avr" )
index f9ed08f183914c550874da516551812a2631162b..91f18c9abf34f31edf46595ad7afe4099399b6f7 100644 (file)
@@ -32,6 +32,7 @@
 #include "avr/usb_keyboard_debug.h"
 #elif defined(_mk20dx128_)
 #include "arm/usb_keyboard.h"
+#include "arm/usb_dev.h"
 #endif
 
 // Local Includes
index db47095d36212063d203d6355353dc203a30f23b..f0589b0fdedeaea5a82d4b67be0950bfbbf68baa 100644 (file)
@@ -38,6 +38,7 @@
 
 
 // You can change these to give your code its own name.
+// TODO Add to Teensy 3
 #define STR_MANUFACTURER       L"MfgName"
 #define STR_PRODUCT            L"Keyboard"
 
@@ -47,7 +48,8 @@
 // INF file is needed to load the driver.  These numbers need to
 // match the INF file.
 #define VENDOR_ID              0x16C0
-#define PRODUCT_ID             0x047D
+#define PRODUCT_ID             0x0487 // New ID for Teensy 3
+//#define PRODUCT_ID           0x047D // Old ID for Teensy 2
 
 
 
index 176d906f3d89600752aa3ccfe9a352065b7d6ce2..518283b831b85ca241c011760e4a32187be9c807 100644 (file)
--- a/arm.cmake
+++ b/arm.cmake
@@ -55,6 +55,7 @@ message( "${CPU}" )
 #| Mostly for convenience functions like interrupt handlers
 set( COMPILER_SRCS
        Lib/${CHIP}.c
+       Lib/delay.c
 )