diff --git a/Keyboards/README.markdown b/Keyboards/README.markdown index c9c93fa..ff8e60c 100644 --- a/Keyboards/README.markdown +++ b/Keyboards/README.markdown @@ -29,6 +29,7 @@ Projects * infinity.bash (Infinity Keyboard 2014/10/15) * template.bash (Example template for new keyboards) +* whitefox.bash (Soon?) **Extra files** diff --git a/Keyboards/whitefox.bash b/Keyboards/whitefox.bash new file mode 100755 index 0000000..c5ff835 --- /dev/null +++ b/Keyboards/whitefox.bash @@ -0,0 +1,72 @@ +#!/bin/bash +# This is a build script template +# These build scripts are just a convenience for configuring your keyboard (less daunting than CMake) +# Jacob Alexander 2015 + + + +################# +# Configuration # +################# + +# Feel free to change the variables in this section to configure your keyboard + +BuildPath="WhiteFox" + +## KLL Configuration ## + +# Generally shouldn't be changed, this will affect every layer +BaseMap="defaultMap" + +# This is the default layer of the keyboard +# NOTE: To combine kll files into a single layout, separate them by spaces +# e.g. DefaultMap="mylayout mylayoutmod" +DefaultMap="stdFuncMap" + +# This is where you set the additional layers +# NOTE: Indexing starts at 1 +# NOTE: Each new layer is another array entry +# e.g. PartialMaps[1]="layer1 layer1mod" +# PartialMaps[2]="layer2" +# PartialMaps[3]="layer3" +PartialMaps[1]="whitefox" + + + +########################## +# Advanced Configuration # +########################## + +# Don't change the variables in this section unless you know what you're doing +# These are useful for completely custom keyboards +# NOTE: Changing any of these variables will require a force build to compile correctly + +# Keyboard Module Configuration +ScanModule="WhiteFox" +MacroModule="PartialMap" +OutputModule="pjrcUSB" +DebugModule="full" + +# Microcontroller +Chip="mk20dx256vlh7" + +# Compiler Selection +Compiler="gcc" + + + +######################## +# Bash Library Include # +######################## + +# Shouldn't need to touch this section + +# Check if the library can be found +if [ ! -f cmake.bash ]; then + echo "ERROR: Cannot find 'cmake.bash'" + exit 1 +fi + +# Load the library +source cmake.bash + diff --git a/Macro/PartialMap/macro.c b/Macro/PartialMap/macro.c index 89444dc..8cebce4 100644 --- a/Macro/PartialMap/macro.c +++ b/Macro/PartialMap/macro.c @@ -456,7 +456,7 @@ inline void Macro_interconnectAdd( void *trigger_ptr ) case 0x03: break; default: - erro_print("Invalid key state"); + erro_msg("Invalid key state - "); error = 1; break; } @@ -464,11 +464,18 @@ inline void Macro_interconnectAdd( void *trigger_ptr ) // Invalid TriggerGuide type default: - erro_print("Invalid type"); + erro_msg("Invalid type - "); error = 1; break; } + // Check if ScanCode is out of range + if ( scanCode > MaxScanCode ) + { + warn_msg("ScanCode is out of range/not defined - "); + error = 1; + } + // Display TriggerGuide if ( error ) { @@ -529,6 +536,15 @@ inline void Macro_keyState( uint8_t scanCode, uint8_t state ) case 0x01: // Pressed case 0x02: // Held case 0x03: // Released + // Check if ScanCode is out of range + if ( scanCode > MaxScanCode ) + { + warn_msg("ScanCode is out of range/not defined: "); + printHex( scanCode ); + print( NL ); + return; + } + macroTriggerListBuffer[ macroTriggerListBufferSize ].scanCode = scanCode; macroTriggerListBuffer[ macroTriggerListBufferSize ].state = state; macroTriggerListBuffer[ macroTriggerListBufferSize ].type = 0x00; // Normal key @@ -549,6 +565,15 @@ inline void Macro_analogState( uint8_t scanCode, uint8_t state ) // TODO Handle change for interconnect if ( state != 0x00 ) { + // Check if ScanCode is out of range + if ( scanCode > MaxScanCode ) + { + warn_msg("ScanCode is out of range/not defined: "); + printHex( scanCode ); + print( NL ); + return; + } + macroTriggerListBuffer[ macroTriggerListBufferSize ].scanCode = scanCode; macroTriggerListBuffer[ macroTriggerListBufferSize ].state = state; macroTriggerListBuffer[ macroTriggerListBufferSize ].type = 0x02; // Analog key @@ -567,6 +592,9 @@ inline void Macro_ledState( uint8_t ledCode, uint8_t state ) // TODO Handle change for interconnect if ( state != 0x00 ) { + // Check if LedCode is out of range + // TODO + macroTriggerListBuffer[ macroTriggerListBufferSize ].scanCode = ledCode; macroTriggerListBuffer[ macroTriggerListBufferSize ].state = state; macroTriggerListBuffer[ macroTriggerListBufferSize ].type = 0x01; // LED key diff --git a/README.markdown b/README.markdown index 90e44aa..f020072 100644 --- a/README.markdown +++ b/README.markdown @@ -12,7 +12,9 @@ Please refer to the [KLL](https://github.com/kiibohd/kll) repo or [kiibohd.com]( Official Keyboards ------------------ -* MD1 (Infinity Keyboard 2014/10/15) +* MD1 (Infinity Keyboard/IC60 2014/10/15) +* MDErgo1 (Infinity Ergodox /ICED 2015/03/31) +* WhiteFox (Soon to be released?) The Kiibohd firmware supports a lot of other keyboards, but these are more obscure/custom/lesser known. diff --git a/Scan/WhiteFox/defaultMap.kll b/Scan/WhiteFox/defaultMap.kll new file mode 100644 index 0000000..474d8ba --- /dev/null +++ b/Scan/WhiteFox/defaultMap.kll @@ -0,0 +1,129 @@ +Name = WhiteFox; +Version = 0.2; +Author = "HaaTa (Jacob Alexander) 2015"; +KLL = 0.3c; + +# Modified Date +Date = 2015-08-16; + + +S0x00 : U"Esc"; +S0x01 : U"1"; +S0x02 : U"2"; +S0x03 : U"3"; +S0x04 : U"4"; +S0x05 : U"5"; +S0x06 : U"6"; +S0x07 : U"7"; +S0x08 : U"8"; +S0x09 : U"9"; +S0x0A : U"0"; +S0x0B : U"Minus"; +S0x0C : U"Equal"; +S0x0D : U"Hash"; +S0x0E : U"Backspace"; +S0x0F : U"BackTick"; +S0x10 : U"Tab"; +S0x11 : U"Q"; +S0x12 : U"W"; +S0x13 : U"E"; +S0x14 : U"R"; +S0x15 : U"T"; +S0x16 : U"Y"; +S0x17 : U"U"; +S0x18 : U"I"; +S0x19 : U"O"; +S0x1A : U"P"; +S0x1B : U"LBrace"; +S0x1C : U"RBrace"; +S0x1D : U"Backslash"; +S0x1E : U"Delete"; +S0x1F : U"CapsLock"; +S0x20 : U"A"; +S0x21 : U"S"; +S0x22 : U"D"; +S0x23 : U"F"; +S0x24 : U"G"; +S0x25 : U"H"; +S0x26 : U"J"; +S0x27 : U"K"; +S0x28 : U"L"; +S0x29 : U"Semicolon"; +S0x2A : U"Quote"; +S0x2B : U"App"; +S0x2C : U"Enter"; +S0x2D : U"PageUp"; +S0x2E : U"LShift"; +S0x2F : U"ISO Slash"; +S0x30 : U"Z"; +S0x31 : U"X"; +S0x32 : U"C"; +S0x33 : U"V"; +S0x34 : U"B"; +S0x35 : U"N"; +S0x36 : U"M"; +S0x37 : U"Comma"; +S0x38 : U"Period"; +S0x39 : U"Slash"; +S0x3A : U"RShift"; +S0x3B : U"Up"; +S0x3C : U"PageDown"; +S0x3D : U"Ctrl"; +S0x3E : U"Function1"; +S0x3F : U"LAlt"; +S0x40 : U"Space"; +S0x41 : U"RAlt"; +S0x42 : U"Gui"; +S0x43 : U"Menu"; +S0x44 : U"Left"; +S0x45 : U"Down"; +S0x46 : U"Right"; + + +# Defines available to the WhiteFox Scan Module + +# LED Default Enable Mask Override +# +# Each LED is represented by a single bit +# See (http://www.issi.com/WW/pdf/31FL3731C.pdf) for details +ISSILedMask1 = " + 0xFF, 0x00, /* C1-1 -> C1-16 */ + 0xFF, 0x00, /* C2-1 -> C2-16 */ + 0xFF, 0x00, /* C3-1 -> C3-16 */ + 0xFF, 0x00, /* C4-1 -> C4-16 */ + 0xFF, 0x00, /* C5-1 -> C5-16 */ + 0xFF, 0x00, /* C6-1 -> C6-16 */ + 0xFF, 0x00, /* C7-1 -> C7-16 */ + 0xFF, 0x00, /* C8-1 -> C8-16 */ + 0xFE, 0x00, /* C9-1 -> C9-16 */ +"; + +# LED Brightness Override +# +# Each LED channel supports 256 levels (8-bit control) +# By default, LEDs are set to 0 brightness +ISSILedBrightness1 = " +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C1-1 -> C1-16 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C2-1 -> C2-16 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C3-1 -> C3-16 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C4-1 -> C4-16 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C5-1 -> C5-16 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C6-1 -> C6-16 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C7-1 -> C7-16 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C8-1 -> C8-16 */ +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C9-1 -> C9-16 */ +"; + +# Full brightness example +#ISSILedBrightness1 = " +#0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C1-1 -> C1-16 */ +#0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C2-1 -> C2-16 */ +#0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C3-1 -> C3-16 */ +#0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C4-1 -> C4-16 */ +#0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C5-1 -> C5-16 */ +#0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C6-1 -> C6-16 */ +#0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C7-1 -> C7-16 */ +#0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C8-1 -> C8-16 */ +#0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C9-1 -> C9-16 */ +#"; + diff --git a/Scan/WhiteFox/matrix.h b/Scan/WhiteFox/matrix.h new file mode 100644 index 0000000..f2037e0 --- /dev/null +++ b/Scan/WhiteFox/matrix.h @@ -0,0 +1,56 @@ +/* Copyright (C) 2014-2015 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +// ----- Includes ----- + +// Project Includes +#include + + + +// ----- Matrix Definition ----- + +// Freescale ARM MK20's support GPIO PTA, PTB, PTC, PTD and PTE 0..31 +// Not all chips have access to all of these pins (most don't have 160 pins :P) +// +// NOTE: +// Before using a pin, make sure it supports being a GPIO *and* doesn't have a default pull-up/pull-down +// Checking this is completely on the ownness of the user + +// MDErgo1 +// +// Column (Strobe) - 9 Total +// PTB2,3,18,19 +// PTC0,9..11 +// PTD0 +// +// Rows (Sense) - 5 Total +// PTD1,4..7 + +// Define Rows (Sense) and Columns (Strobes) +GPIO_Pin Matrix_cols[] = { gpio(B,2), gpio(B,3), gpio(B,18), gpio(B,19), gpio(C,0), gpio(C,8), gpio(C,9), gpio(C,10), gpio(C,11) }; +GPIO_Pin Matrix_rows[] = { gpio(D,0), gpio(D,1), gpio(D,4), gpio(D,5), gpio(D,6), gpio(D,7), gpio(C,1), gpio(C,2) }; + +// Define type of scan matrix +Config Matrix_type = Config_Pulldown; + diff --git a/Scan/WhiteFox/pinout b/Scan/WhiteFox/pinout new file mode 100644 index 0000000..cb2f687 --- /dev/null +++ b/Scan/WhiteFox/pinout @@ -0,0 +1,112 @@ +Pin Usage +========= + +mk20dx256vlh7 + + ---- +|Keys| + ---- + +* Strobe (Columns) + +PTB2 +PTB3 +PTB18 +PTB19 +PTC0 +PTC9 +PTC10 +PTC11 +PTD0 + +* Sense (Rows) + +PTD1 +PTD4 +PTD5 +PTD6 +PTD7 +PTC1 +PTC2 +PTC3 + + + ----- +|Clock| + ----- + +PTA18 <-> PTA19 + + + --- +|I2C| + --- + +* IS31FL3731C + +PTB0 - SCL0 (add header pin, label as SCL0) +PTB1 - SDA0 (add header pin, label as SDA0) +PTB17 - INTB Chip 1 +PTB16 - SDB (tied to all Chips, hardware shutdown) + + + + --- +|DAC| + --- + +DAC0 (N/C) + + + ---- +|UART| + ---- + +* Comm - For bi-directional communication between halves + +PTA1 - RX0 (Master Side) +PTA2 - TX0 (Master Side) + +PTD2 - RX2 (UART Debug Header) +PTD3 - TX2 (UART Debug Header) + + + ----- +|Debug| + ----- + +* SWD - (Main reflash header) + +PTA0 (Pull-down) +PTA3 (Pull-up) + +* LEDs + +PTA5 (LED only for PCB, not Teensy) + +* UARTs + +PTD2 - RX2 (UART Debug Header, label as RX2) +PTD3 - TX2 (UART Debug Header, label as TX2) + + + ------ +|Unused| + ------ + +* GPIO + +PTA4 +PTA12 +PTA13 +PTC4 +PTC5 +PTC6 +PTC7 +PTE0 +PTE1 + +* Analog + +TODO + diff --git a/Scan/WhiteFox/scan_loop.c b/Scan/WhiteFox/scan_loop.c new file mode 100644 index 0000000..16cefa2 --- /dev/null +++ b/Scan/WhiteFox/scan_loop.c @@ -0,0 +1,92 @@ +/* Copyright (C) 2014-2015 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// ----- Includes ----- + +// Compiler Includes +#include + +// Project Includes +#include +#include +#include +#include +#include +#include +#include + +// Local Includes +#include "scan_loop.h" + + + +// ----- Function Declarations ----- + +// ----- Variables ----- + +// Number of scans since the last USB send +uint16_t Scan_scanCount = 0; + + + +// ----- Functions ----- + +// Setup +inline void Scan_setup() +{ + // Setup GPIO pins for matrix scanning + Matrix_setup(); + + // Setup ISSI chip to control the leds + LED_setup(); + + // Reset scan count + Scan_scanCount = 0; +} + + +// Main Detection Loop +inline uint8_t Scan_loop() +{ + // Scan Matrix + Matrix_scan( Scan_scanCount++ ); + + // Process any LED events + LED_scan(); + + return 0; +} + + +// Signal from Macro Module that all keys have been processed (that it knows about) +inline void Scan_finishedWithMacro( uint8_t sentKeys ) +{ +} + + +// Signal from Output Module that all keys have been processed (that it knows about) +inline void Scan_finishedWithOutput( uint8_t sentKeys ) +{ + // Reset scan loop indicator (resets each key debounce state) + // TODO should this occur after USB send or Macro processing? + Scan_scanCount = 0; +} + diff --git a/Scan/WhiteFox/scan_loop.h b/Scan/WhiteFox/scan_loop.h new file mode 100644 index 0000000..17a06fc --- /dev/null +++ b/Scan/WhiteFox/scan_loop.h @@ -0,0 +1,40 @@ +/* Copyright (C) 2014-2015 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#pragma once + +// ----- Includes ----- + +// Compiler Includes +#include + + + +// ----- Functions ----- + +// Functions to be called by main.c +void Scan_setup( void ); +uint8_t Scan_loop( void ); + +// Call-backs +void Scan_finishedWithMacro( uint8_t sentKeys ); // Called by Macro Module +void Scan_finishedWithOutput( uint8_t sentKeys ); // Called by Output Module + diff --git a/Scan/WhiteFox/setup.cmake b/Scan/WhiteFox/setup.cmake new file mode 100644 index 0000000..9860b1a --- /dev/null +++ b/Scan/WhiteFox/setup.cmake @@ -0,0 +1,31 @@ +###| CMake Kiibohd Controller Scan Module |### +# +# Written by Jacob Alexander in 2014-2015 for the Kiibohd Controller +# +# Released into the Public Domain +# +### + + +### +# Required Sub-modules +# +AddModule ( Scan ISSILed ) +AddModule ( Scan MatrixARM ) + + +### +# Module C files +# +set ( Module_SRCS + scan_loop.c +) + + +### +# Compiler Family Compatibility +# +set ( ModuleCompatibility + arm +) +