# HG changeset patch # User Jacob Alexander # Date 1359257436 18000 # Node ID 87658fa6091b23f636b31021924cc5011c379227 # Parent 2c0c2fbd76c92773f44b54cd92943c571901efa7 Updating AVR abstraction to be compatible with ARM, nearly ready for ARM files - Very small updates to files, mostly modifying to remove name duplications diff -r 2c0c2fbd76c9 -r 87658fa6091b Debug/print/print.c --- a/Debug/print/print.c Sat Jan 26 15:43:59 2013 -0500 +++ b/Debug/print/print.c Sat Jan 26 22:30:36 2013 -0500 @@ -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 @@ -34,8 +34,17 @@ // 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 @@ // 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 @@ usb_debug_putchar('\r'); usb_debug_putchar(c); } +#elif defined(_mk20dx128_) // ARM + usb_debug_putstr( (char*)s ); +#endif } diff -r 2c0c2fbd76c9 -r 87658fa6091b Debug/print/print.h --- a/Debug/print/print.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Debug/print/print.h Sat Jan 26 22:30:36 2013 -0500 @@ -32,7 +32,7 @@ #elif defined(_mk20dx128_) -#include "arm/usb_keyboard.h" +#include "arm/usb_serial.h" #endif diff -r 2c0c2fbd76c9 -r 87658fa6091b Lib/MacroLib.h --- a/Lib/MacroLib.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Lib/MacroLib.h Sat Jan 26 22:30:36 2013 -0500 @@ -24,10 +24,14 @@ // Additional includes should only be added to this file if they should be added to *all* Macro modules. +#ifndef __MACROLIB_H +#define __MACROLIB_H + // ----- Includes ----- -#ifndef __MACROLIB_H -#define __MACROLIB_H +#include + + // ARM #if defined(_mk20dx128_) @@ -43,7 +47,6 @@ // AVR #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) -#include #include #endif diff -r 2c0c2fbd76c9 -r 87658fa6091b Lib/MainLib.h --- a/Lib/MainLib.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Lib/MainLib.h Sat Jan 26 22:30:36 2013 -0500 @@ -24,10 +24,14 @@ // 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 + + // ARM #if defined(_mk20dx128_) @@ -43,7 +47,6 @@ #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) #include -#include #endif diff -r 2c0c2fbd76c9 -r 87658fa6091b Lib/ScanLib.h --- a/Lib/ScanLib.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Lib/ScanLib.h Sat Jan 26 22:30:36 2013 -0500 @@ -24,10 +24,14 @@ // Additional includes should only be added to this file if they should be added to *all* Scan modules. +#ifndef __SCANLIB_H +#define __SCANLIB_H + // ----- Includes ----- -#ifndef __SCANLIB_H -#define __SCANLIB_H +#include + + // ARM #if defined(_mk20dx128_) @@ -43,7 +47,6 @@ // AVR #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) -#include #include #include diff -r 2c0c2fbd76c9 -r 87658fa6091b Lib/USBLib.h --- a/Lib/USBLib.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Lib/USBLib.h Sat Jan 26 22:30:36 2013 -0500 @@ -24,10 +24,10 @@ // 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_) diff -r 2c0c2fbd76c9 -r 87658fa6091b Macro/buffer/macro.c --- a/Macro/buffer/macro.c Sat Jan 26 15:43:59 2013 -0500 +++ b/Macro/buffer/macro.c Sat Jan 26 22:30:36 2013 -0500 @@ -77,6 +77,7 @@ 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 @@ 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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/BETKB/scan_loop.h --- a/Scan/BETKB/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/BETKB/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/BudKeypad/matrix.h --- a/Scan/BudKeypad/matrix.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/BudKeypad/matrix.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/EpsonQX-10/scan_loop.h --- a/Scan/EpsonQX-10/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/EpsonQX-10/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/FACOM6684/scan_loop.c --- a/Scan/FACOM6684/scan_loop.c Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/FACOM6684/scan_loop.c Sat Jan 26 22:30:36 2013 -0500 @@ -108,7 +108,6 @@ 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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/FACOM6684/scan_loop.h --- a/Scan/FACOM6684/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/FACOM6684/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/HP150/scan_loop.h --- a/Scan/HP150/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/HP150/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/HeathZenith/matrix.h --- a/Scan/HeathZenith/matrix.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/HeathZenith/matrix.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/IBMConvertible/matrix.h --- a/Scan/IBMConvertible/matrix.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/IBMConvertible/matrix.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/Kaypro1/scan_loop.h --- a/Scan/Kaypro1/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/Kaypro1/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/MicroSwitch8304/scan_loop.h --- a/Scan/MicroSwitch8304/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/MicroSwitch8304/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/SKM67001/matrix.h --- a/Scan/SKM67001/matrix.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/SKM67001/matrix.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/SonyNEWS/scan_loop.h --- a/Scan/SonyNEWS/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/SonyNEWS/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/SonyOA-S3400/scan_loop.h --- a/Scan/SonyOA-S3400/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/SonyOA-S3400/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/Tandy1000/scan_loop.h --- a/Scan/Tandy1000/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/Tandy1000/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/UnivacF3W9/scan_loop.h --- a/Scan/UnivacF3W9/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/UnivacF3W9/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/matrix/matrix_template.h --- a/Scan/matrix/matrix_template.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/matrix/matrix_template.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 */ diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/matrix/scan_loop.c --- a/Scan/matrix/scan_loop.c Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/matrix/scan_loop.c Sat Jan 26 22:30:36 2013 -0500 @@ -67,7 +67,7 @@ // 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]; diff -r 2c0c2fbd76c9 -r 87658fa6091b Scan/matrix/scan_loop.h --- a/Scan/matrix/scan_loop.h Sat Jan 26 15:43:59 2013 -0500 +++ b/Scan/matrix/scan_loop.h Sat Jan 26 22:30:36 2013 -0500 @@ -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; diff -r 2c0c2fbd76c9 -r 87658fa6091b USB/pjrc/setup.cmake --- a/USB/pjrc/setup.cmake Sat Jan 26 15:43:59 2013 -0500 +++ b/USB/pjrc/setup.cmake Sat Jan 26 22:30:36 2013 -0500 @@ -29,6 +29,7 @@ arm/usb_dev.c arm/usb_keyboard.c arm/usb_mem.c + arm/usb_serial.c ) endif ( ${COMPILER_FAMILY} MATCHES "avr" ) diff -r 2c0c2fbd76c9 -r 87658fa6091b USB/pjrc/usb_com.c --- a/USB/pjrc/usb_com.c Sat Jan 26 15:43:59 2013 -0500 +++ b/USB/pjrc/usb_com.c Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b USB/pjrc/usb_com.h --- a/USB/pjrc/usb_com.h Sat Jan 26 15:43:59 2013 -0500 +++ b/USB/pjrc/usb_com.h Sat Jan 26 22:30:36 2013 -0500 @@ -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 diff -r 2c0c2fbd76c9 -r 87658fa6091b arm.cmake --- a/arm.cmake Sat Jan 26 15:43:59 2013 -0500 +++ b/arm.cmake Sat Jan 26 22:30:36 2013 -0500 @@ -55,6 +55,7 @@ #| Mostly for convenience functions like interrupt handlers set( COMPILER_SRCS Lib/${CHIP}.c + Lib/delay.c )