Compare commits

..

3 commits

Author SHA1 Message Date
1585940b80 Add Layouts directory to the search path for BaseMap and PartialMap
Oh. And reformat part of the file because tabs are of the devil.
2016-04-30 13:22:39 -07:00
ccfe28a1d7 Use MDErgo1 for the Scan Module 2016-04-30 11:01:56 -07:00
0ffd873978 Change the target chip 2016-04-30 10:32:19 -07:00
12 changed files with 71 additions and 849 deletions

View file

@ -22,9 +22,9 @@ set( CHIP
# "at90usb646" # Teensy++ 1.0 (avr)
# "at90usb1286" # Teensy++ 2.0 (avr)
# "mk20dx128" # Teensy 3.0 (arm)
"mk20dx128vlf5" # McHCK mk20dx128vlf5
# "mk20dx128vlf5" # McHCK mk20dx128vlf5
# "mk20dx256" # Teensy 3.1,3.2 (arm)
# "mk20dx256vlh7" # Kiibohd-dfu mk20dx256vlh7
"mk20dx256vlh7" # Kiibohd-dfu mk20dx256vlh7
CACHE STRING "Microcontroller Chip"
)
@ -65,7 +65,7 @@ include( initialize )
#| Please look at the {Scan,Macro,Output,Debug} for information on the modules and how to create new ones
##| Deals with acquiring the keypress information and turning it into a key index
set( ScanModule "MD1"
set( ScanModule "MDErgo1"
CACHE STRING "Scan Module" )
##| Provides the mapping functions for DefaultMap and handles any macro processing before sending to the OutputModule

View file

@ -20,22 +20,22 @@ if ( "${MacroModule}" STREQUAL "PartialMap" )
#
if ( NOT EXISTS "${PROJECT_SOURCE_DIR}/kll/kll.py" )
message ( STATUS "Downloading latest kll version:" )
message ( STATUS "Downloading latest kll version:" )
# Make sure git is available
find_package ( Git REQUIRED )
# Make sure git is available
find_package ( Git REQUIRED )
# Clone kll git repo
execute_process ( COMMAND ${GIT_EXECUTABLE} clone https://github.com/kiibohd/kll.git
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
# Clone kll git repo
execute_process ( COMMAND ${GIT_EXECUTABLE} clone https://github.com/kiibohd/kll.git
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
elseif ( REFRESH_KLL ) # Otherwise attempt to update the repo
message ( STATUS "Checking for latest kll version:" )
message ( STATUS "Checking for latest kll version:" )
# Clone kll git repo
execute_process ( COMMAND ${GIT_EXECUTABLE} pull --rebase
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/kll
)
# Clone kll git repo
execute_process ( COMMAND ${GIT_EXECUTABLE} pull --rebase
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/kll
)
endif () # kll/kll.py exists
@ -48,8 +48,8 @@ endif () # kll/kll.py exists
#| Add each of the detected capabilities.kll
foreach ( filename ${ScanModule_KLL} ${MacroModule_KLL} ${OutputModule_KLL} ${DebugModule_KLL} )
set ( BaseMap_Args ${BaseMap_Args} ${filename} )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${filename} )
set ( BaseMap_Args ${BaseMap_Args} ${filename} )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${filename} )
endforeach ()
#| If set BaseMap cannot be found, use default map
@ -57,65 +57,71 @@ set ( pathname "${PROJECT_SOURCE_DIR}/${ScanModulePath}" )
string ( REPLACE " " ";" MAP_LIST ${BaseMap} ) # Change spaces to semicolons
foreach ( MAP ${MAP_LIST} )
# Only check the Scan Module for BaseMap .kll files, default to defaultMap.kll
if ( NOT EXISTS ${pathname}/${MAP}.kll )
set ( BaseMap_Args ${BaseMap_Args} ${pathname}/defaultMap.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${pathname}/defaultMap.kll )
elseif ( EXISTS "${pathname}/${MAP}.kll" )
set ( BaseMap_Args ${BaseMap_Args} ${pathname}/${MAP}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${pathname}/${MAP}.kll )
else ()
message ( FATAL " Could not find '${MAP}.kll' BaseMap in Scan module directory" )
endif ()
# Only check the Scan Module for BaseMap .kll files, default to defaultMap.kll
if ( NOT EXISTS ${pathname}/${MAP}.kll )
set ( BaseMap_Args ${BaseMap_Args} ${pathname}/defaultMap.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${pathname}/defaultMap.kll )
elseif ( EXISTS "${pathname}/${MAP}.kll" )
set ( BaseMap_Args ${BaseMap_Args} ${pathname}/${MAP}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${pathname}/${MAP}.kll )
else ()
message ( FATAL " Could not find '${MAP}.kll' BaseMap in Scan module directory" )
endif ()
endforeach ()
#| Configure DefaultMap if specified
if ( NOT "${DefaultMap}" STREQUAL "" )
set ( DefaultMap_Args -d )
set ( DefaultMap_Args -d )
string ( REPLACE " " ";" MAP_LIST ${DefaultMap} ) # Change spaces to semicolons
foreach ( MAP ${MAP_LIST} )
# Check if kll file is in build directory, otherwise default to layout directory
if ( EXISTS "${PROJECT_BINARY_DIR}/${MAP}.kll" )
set ( DefaultMap_Args ${DefaultMap_Args} ${MAP}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_BINARY_DIR}/${MAP}.kll )
elseif ( EXISTS "${PROJECT_SOURCE_DIR}/kll/layouts/${MAP}.kll" )
set ( DefaultMap_Args ${DefaultMap_Args} ${PROJECT_SOURCE_DIR}/kll/layouts/${MAP}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_SOURCE_DIR}/kll/layouts/${MAP}.kll )
else ()
message ( FATAL " Could not find '${MAP}.kll' DefaultMap" )
endif ()
endforeach ()
string ( REPLACE " " ";" MAP_LIST ${DefaultMap} ) # Change spaces to semicolons
foreach ( MAP ${MAP_LIST} )
# Check if kll file is in build directory, otherwise default to layout directory
if ( EXISTS "${PROJECT_BINARY_DIR}/${MAP}.kll" )
set ( DefaultMap_Args ${DefaultMap_Args} ${MAP}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_BINARY_DIR}/${MAP}.kll )
elseif ( EXISTS "${PROJECT_SOURCE_DIR}/kll/layouts/${MAP}.kll" )
set ( DefaultMap_Args ${DefaultMap_Args} ${PROJECT_SOURCE_DIR}/kll/layouts/${MAP}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_SOURCE_DIR}/kll/layouts/${MAP}.kll )
elseif ( EXISTS "${PROJECT_SOURCE_DIR}/Layouts/${MAP}.kll" )
set ( PartialMap_Args ${PartialMap_Args} ${PROJECT_SOURCE_DIR}/Layouts/${MAP}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_SOURCE_DIR}/Layouts/${MAP}.kll )
else ()
message ( FATAL " Could not find '${MAP}.kll' DefaultMap" )
endif ()
endforeach ()
endif ()
#| Configure PartialMaps if specified
if ( NOT "${PartialMaps}" STREQUAL "" )
# For each partial layer
foreach ( MAP ${PartialMaps} )
set ( PartialMap_Args ${PartialMap_Args} -p )
# For each partial layer
foreach ( MAP ${PartialMaps} )
set ( PartialMap_Args ${PartialMap_Args} -p )
# Combine each layer
string ( REPLACE " " ";" MAP_LIST ${MAP} ) # Change spaces to semicolons
foreach ( MAP_PART ${MAP_LIST} )
# Check if kll file is in build directory, otherwise default to layout directory
if ( EXISTS "${PROJECT_BINARY_DIR}/${MAP_PART}.kll" )
set ( PartialMap_Args ${PartialMap_Args} ${MAP_PART}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_BINARY_DIR}/${MAP_PART}.kll )
elseif ( EXISTS "${PROJECT_SOURCE_DIR}/kll/layouts/${MAP_PART}.kll" )
set ( PartialMap_Args ${PartialMap_Args} ${PROJECT_SOURCE_DIR}/kll/layouts/${MAP_PART}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_SOURCE_DIR}/kll/layouts/${MAP_PART}.kll )
else ()
message ( FATAL " Could not find '${MAP_PART}.kll' PartialMap" )
endif ()
endforeach ()
endforeach ()
# Combine each layer
string ( REPLACE " " ";" MAP_LIST ${MAP} ) # Change spaces to semicolons
foreach ( MAP_PART ${MAP_LIST} )
# Check if kll file is in build directory, otherwise default to layout directory
if ( EXISTS "${PROJECT_BINARY_DIR}/${MAP_PART}.kll" )
set ( PartialMap_Args ${PartialMap_Args} ${MAP_PART}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_BINARY_DIR}/${MAP_PART}.kll )
elseif ( EXISTS "${PROJECT_SOURCE_DIR}/kll/layouts/${MAP_PART}.kll" )
set ( PartialMap_Args ${PartialMap_Args} ${PROJECT_SOURCE_DIR}/kll/layouts/${MAP_PART}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_SOURCE_DIR}/kll/layouts/${MAP_PART}.kll )
elseif ( EXISTS "${PROJECT_SOURCE_DIR}/Layouts/${MAP_PART}.kll" )
set ( PartialMap_Args ${PartialMap_Args} ${PROJECT_SOURCE_DIR}/Layouts/${MAP_PART}.kll )
set ( KLL_DEPENDS ${KLL_DEPENDS} ${PROJECT_SOURCE_DIR}/Layouts/${MAP_PART}.kll )
else ()
message ( FATAL " Could not find '${MAP_PART}.kll' PartialMap" )
endif ()
endforeach ()
endforeach ()
endif ()
#| Print list of layout sources used
message ( STATUS "Detected Layout Files:" )
foreach ( filename ${KLL_DEPENDS} )
message ( "${filename}" )
message ( "${filename}" )
endforeach ()
@ -133,15 +139,15 @@ set ( kll_output --outputs ${kll_outputname} )
#| KLL Cmd
set ( kll_cmd ${PROJECT_SOURCE_DIR}/kll/kll.py ${BaseMap_Args} ${DefaultMap_Args} ${PartialMap_Args} ${kll_backend} ${kll_template} ${kll_output} )
add_custom_command ( OUTPUT ${kll_outputname}
COMMAND ${kll_cmd}
DEPENDS ${KLL_DEPENDS}
COMMENT "Generating KLL Layout"
COMMAND ${kll_cmd}
DEPENDS ${KLL_DEPENDS}
COMMENT "Generating KLL Layout"
)
#| KLL Regen Convenience Target
add_custom_target ( kll_regen
COMMAND ${kll_cmd}
COMMENT "Re-generating KLL Layout"
COMMAND ${kll_cmd}
COMMENT "Re-generating KLL Layout"
)
#| Append generated file to required sources so it becomes a dependency in the main build

View file

@ -1,11 +0,0 @@
Name = CapSenseCapabilities;
Version = 0.1;
Author = "HaaTa (Jacob Alexander) 2016";
KLL = 0.3d;
# Modified Date
Date = 2016-04-11;
# Defines available to the CapSense sub-module
# TODO Add cap sense configuration here

View file

@ -1,241 +0,0 @@
/* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
*/
// ----- Includes -----
// Compiler Includes
#include <Lib/ScanLib.h>
// Project Includes
#include <cli.h>
#include <kll_defs.h>
#include <led.h>
#include <print.h>
#include <macro.h>
#include <Lib/delay.h>
// Local Includes
#include "matrix_scan.h"
// Matrix Configuration
//#include <matrix.h>
// ----- Defines -----
// ----- Function Declarations -----
// CLI Functions
void cliFunc_matrixDebug( char* args );
void cliFunc_matrixInfo( char* args );
void cliFunc_matrixState( char* args );
// ----- Variables -----
// Scan Module command dictionary
CLIDict_Entry( matrixDebug, "Enables matrix debug mode, prints out each scan code." NL "\t\tIf argument \033[35mT\033[0m is given, prints out each scan code state transition." );
CLIDict_Entry( matrixInfo, "Print info about the configured matrix." );
CLIDict_Entry( matrixState, "Prints out the current scan table N times." NL "\t\t \033[1mO\033[0m - Off, \033[1;33mP\033[0m - Press, \033[1;32mH\033[0m - Hold, \033[1;35mR\033[0m - Release, \033[1;31mI\033[0m - Invalid" );
CLIDict_Def( matrixCLIDict, "Matrix Module Commands" ) = {
CLIDict_Item( matrixDebug ),
CLIDict_Item( matrixInfo ),
CLIDict_Item( matrixState ),
{ 0, 0, 0 } // Null entry for dictionary end
};
// ----- Functions -----
// TODO
// - Support multiple ADCs
// - Channel/Mux setup
void ADC_setup( ADC adc )
{
// Enable ADC clock
#if defined(_mk20dx128_) || defined(_mk20dx128vlf5_)
SIM_SCGC6 |= SIM_SCGC6_ADC0;
#elif defined(_mk20dx256_) || defined(_mk20dx256vlh7_)
SIM_SCGC6 |= SIM_SCGC6_ADC0;
SIM_SCGC3 |= SIM_SCGC3_ADC1;
#endif
// Lookup base ADC register
volatile unsigned int *ADC_SC1A = (unsigned int*)(&ADC_reg_offset_map[adc]);
// Calculate Register offsets
volatile unsigned int *ADC_CFG1 = (unsigned int*)(&ADC_SC1A) + 0x08;
volatile unsigned int *ADC_CFG2 = (unsigned int*)(&ADC_SC1A) + 0x0C;
volatile unsigned int *ADC_SC2 = (unsigned int*)(&ADC_SC1A) + 0x20;
volatile unsigned int *ADC_SC3 = (unsigned int*)(&ADC_SC1A) + 0x24;
volatile unsigned int *ADC_PG = (unsigned int*)(&ADC_SC1A) + 0x2C;
volatile unsigned int *ADC_CLPS = (unsigned int*)(&ADC_SC1A) + 0x38;
volatile unsigned int *ADC_CLP4 = (unsigned int*)(&ADC_SC1A) + 0x3C;
volatile unsigned int *ADC_CLP3 = (unsigned int*)(&ADC_SC1A) + 0x40;
volatile unsigned int *ADC_CLP2 = (unsigned int*)(&ADC_SC1A) + 0x44;
volatile unsigned int *ADC_CLP1 = (unsigned int*)(&ADC_SC1A) + 0x48;
volatile unsigned int *ADC_CLP0 = (unsigned int*)(&ADC_SC1A) + 0x4C;
// Make sure calibration has stopped
*ADC_SC3 = 0;
// - CFG1 -
// ADIV: (input)/2 divider
// ADICLK: (bus)/2 divider
// MODE: 16-bit
// ADLSMP: Long sample
//ADC_CFG1 = ADC_CFG1_ADIV(1) | ADC_CFG1_ADICLK(1) | ADC_CFG1_MODE(3) | ADC_CFG1_ADLSMP;
// ADIV: (input)/8 divider
*ADC_CFG1 = ADC_CFG1_ADIV(3) | ADC_CFG1_ADICLK(1) | ADC_CFG1_MODE(3) | ADC_CFG1_ADLSMP;
// - CFG2 -
// ADLSTS: 6 extra ADCK cycles; 10 ADCK cycles total sample time
//ADC_CFG2 = ADC_CFG2_ADLSTS(2);
// ADLSTS: 20 extra ADCK cycles; 24 ADCK cycles total sample time
*ADC_CFG2 = ADC_CFG2_ADLSTS(0);
// - SC2 -
// REFSEL: Use default 3.3V reference
*ADC_SC2 = ADC_SC2_REFSEL(0);
/*
// Setup VREF to 1.2 V
VREF_TRM = 0x60;
VREF_SC = 0xE1; // Enable 1.2 volt ref
// REFSEL: Use 1.2V reference VREF
*ADC_SC2 = ADC_SC2_REFSEL(1);
*/
// - SC3 -
// CAL: Start calibration
// AVGE: Enable hardware averaging
// AVGS: 32 samples averaged
// 32 sample averaging
*ADC_SC3 = ADC_SC3_CAL | ADC_SC3_AVGE | ADC_SC3_AVGS(3);
// Wait for calibration
while ( *ADC_SC3 & ADC_SC3_CAL );
// Apply computed calibration offset
// XXX Note, for single-ended, only the plus side offsets have to be applied
// For differential the minus side also has to be set as well
__disable_irq(); // Disable interrupts while reading/setting offsets
// Set calibration
// ADC Plus-Side Gain Register
// See Section 31.4.7 in the datasheet (mk20dx256vlh7) for details
uint16_t sum = *ADC_CLPS + *ADC_CLP4 + *ADC_CLP3 + *ADC_CLP2 + *ADC_CLP1 + *ADC_CLP0;
sum = (sum / 2) | 0x8000;
*ADC_PG = sum;
__enable_irq(); // Re-enable interrupts
// Start ADC reading loop
// - SC1A -
// ADCH: Channel DAD0 (A10)
// AIEN: Enable interrupt
//*ADC_SC1A = ADC_SC1_AIEN | ADC_SC1_ADCH(0);
// Enable ADC0 IRQ Vector
//NVIC_ENABLE_IRQ( IRQ_ADC0 );
}
// TODO
// - Enable/Disable strobe detection (IBM)
// - Setup strobe matrix
void Strobe_setup()
{
}
// TODO
// - Setup ADCs
// - Setup ADC muxes
// - Setup voltage stab
void Sense_setup()
{
}
void Matrix_setup()
{
// Register Matrix CLI dictionary
CLI_registerDictionary( matrixCLIDict, matrixCLIDictName );
// Setup sense
Sense_setup();
// Setup strobes
Strobe_setup();
}
// Scan the matrix for keypresses
// NOTE: scanNum should be reset to 0 after a USB send (to reset all the counters)
void Matrix_scan( uint16_t scanNum )
{
}
// Called by parent scan module whenever the available current changes
// current - mA
void Matrix_currentChange( unsigned int current )
{
// TODO - Any potential power savings?
}
// ----- CLI Command Functions -----
void cliFunc_matrixInfo( char* args )
{
}
void cliFunc_matrixDebug( char* args )
{
// Parse number from argument
// NOTE: Only first argument is used
char* arg1Ptr;
char* arg2Ptr;
CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
// Set the matrix debug flag depending on the argument
// If no argument, set to scan code only
// If set to T, set to state transition
switch ( arg1Ptr[0] )
{
// T as argument
case 'T':
case 't':
break;
// No argument
case '\0':
break;
// Invalid argument
default:
return;
}
}
void cliFunc_matrixState( char* args )
{
}

View file

@ -1,175 +0,0 @@
/* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
// ----- Includes -----
// KLL Generated Defines
#include <kll_defs.h>
// ----- Defines -----
// ----- Enums -----
// Freescale MK20s have GPIO ports A...E
typedef enum Port {
Port_A = 0,
Port_B = 1,
Port_C = 2,
Port_D = 3,
Port_E = 4,
} Port;
// Each port has a possible 32 pins
typedef enum Pin {
Pin_0 = 0,
Pin_1 = 1,
Pin_2 = 2,
Pin_3 = 3,
Pin_4 = 4,
Pin_5 = 5,
Pin_6 = 6,
Pin_7 = 7,
Pin_8 = 8,
Pin_9 = 9,
Pin_10 = 10,
Pin_11 = 11,
Pin_12 = 12,
Pin_13 = 13,
Pin_14 = 14,
Pin_15 = 15,
Pin_16 = 16,
Pin_17 = 17,
Pin_18 = 18,
Pin_19 = 19,
Pin_20 = 20,
Pin_21 = 21,
Pin_22 = 22,
Pin_23 = 23,
Pin_24 = 24,
Pin_25 = 25,
Pin_26 = 26,
Pin_27 = 27,
Pin_28 = 28,
Pin_29 = 29,
Pin_30 = 30,
Pin_31 = 31,
} Pin;
// Depending on the microcontroller, it can have 1 or more ADCs
typedef enum ADC {
#if defined(_mk20dx128_) || defined(_mk20dx128vlf5_)
ADC_0 = 0,
#elif defined(_mk20dx256_) || defined(_mk20dx256vlh7_)
ADC_0 = 0,
ADC_1 = 1,
#endif
} ADC;
// ADC Register offset map
unsigned int *ADC_reg_offset_map[] = {
#if defined(_mk20dx128_) || defined(_mk20dx128vlf5_)
(unsigned int*)(&ADC0_SC1A),
#elif defined(_mk20dx256_) || defined(_mk20dx256vlh7_)
(unsigned int*)(&ADC0_SC1A),
(unsigned int*)(&ADC1_SC1A),
#endif
};
// Each ADC has a possible 32 channels
typedef enum Channel {
Channel_0 = 0,
Channel_1 = 1,
Channel_2 = 2,
Channel_3 = 3,
Channel_4 = 4,
Channel_5 = 5,
Channel_6 = 6,
Channel_7 = 7,
Channel_8 = 8,
Channel_9 = 9,
Channel_10 = 10,
Channel_11 = 11,
Channel_12 = 12,
Channel_13 = 13,
Channel_14 = 14,
Channel_15 = 15,
Channel_16 = 16,
Channel_17 = 17,
Channel_18 = 18,
Channel_19 = 19,
Channel_20 = 20,
Channel_21 = 21,
Channel_22 = 22,
Channel_23 = 23,
Channel_24 = 24,
Channel_25 = 25,
Channel_26 = 26,
Channel_27 = 27,
Channel_28 = 28,
Channel_29 = 29,
Channel_30 = 30,
Channel_31 = 31,
} Channel;
// Type of pin
typedef enum Type {
Type_StrobeOn,
Type_StrobeOff,
Type_StrobeSetup,
Type_Sense,
Type_SenseSetup,
} Type;
// Keypress States
typedef enum KeyPosition {
KeyState_Off = 0,
KeyState_Press = 1,
KeyState_Hold = 2,
KeyState_Release = 3,
KeyState_Invalid,
} KeyPosition;
// ----- Structs -----
// Struct container for defining Strobe pins
typedef struct GPIO_Pin {
Port port;
Pin pin;
} GPIO_Pin;
// Struct container for defining Sense pins
typedef struct ADC_Pin {
Port port;
Pin pin;
ADC adc;
Channel ch;
} ADC_Pin;
// ----- Functions -----
void Matrix_setup();
void Matrix_scan( uint16_t scanNum );
void Matrix_currentChange( unsigned int current );

View file

@ -1,27 +0,0 @@
/* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
// ----- Macros -----
// Convenience Macros
#define gpio( port, pin ) { Port_##port, Pin_##pin }
#define sense( port, pin, adc, ch ) { Port_##port, Pin_##pin, ADC_##adc, Channel_##ch }
#define Matrix_colsNum sizeof( Matrix_cols ) / sizeof( GPIO_Pin )
#define Matrix_rowsNum sizeof( Matrix_rows ) / sizeof( GPIO_Pin )
#define Matrix_maxKeys sizeof( Matrix_scanArray ) / sizeof( KeyState )

View file

@ -1,30 +0,0 @@
###| CMake Kiibohd Controller Scan Module |###
#
# Written by Jacob Alexander in 2016 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
matrix_scan.c
)
###
# Compiler Family Compatibility
#
set ( ModuleCompatibility
arm
)

View file

@ -1,73 +0,0 @@
Name = CapTest1;
Version = 0.3d;
Author = "HaaTa (Jacob Alexander) 2016";
KLL = 0.3c;
# Modified Date
Date = 2016-04-11;
# TODO
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"Backslash";
S0x0E : U"Backtick";
S0x0F : U"Tab";
S0x10 : U"Q";
S0x11 : U"W";
S0x12 : U"E";
S0x13 : U"R";
S0x14 : U"T";
S0x15 : U"Y";
S0x16 : U"U";
S0x17 : U"I";
S0x18 : U"O";
S0x19 : U"P";
S0x1A : U"LBrace";
S0x1B : U"RBrace";
S0x1C : U"Backspace";
S0x1D : U"Ctrl";
S0x1E : U"A";
S0x1F : U"S";
S0x20 : U"D";
S0x21 : U"F";
S0x22 : U"G";
S0x23 : U"H";
S0x24 : U"J";
S0x25 : U"K";
S0x26 : U"L";
S0x27 : U"Semicolon";
S0x28 : U"Quote";
S0x29 : U"Enter";
S0x2A : U"LShift";
S0x2B : U"Z";
S0x2C : U"X";
S0x2D : U"C";
S0x2E : U"V";
S0x2F : U"B";
S0x30 : U"N";
S0x31 : U"M";
S0x32 : U"Comma";
S0x33 : U"Period";
S0x34 : U"Slash";
S0x35 : U"RShift";
S0x36 : U"Function1"; # Fun key
S0x37 : U"Function2"; # Left Blank Key
S0x38 : U"LAlt";
S0x39 : U"LGui";
S0x3A : U"Space";
S0x3B : U"RGui";
S0x3C : U"RAlt";
S0x3D : U"Function3"; # Right Blank Key 1
S0x3E : U"Function4"; # Right Blank Key 2

View file

@ -1,63 +0,0 @@
/* Copyright (C) 2014-2016 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
// ----- Includes -----
// Project Includes
#include <matrix_setup.h>
// ----- Matrix Definition -----
// CapTest
// (TODO)
//
// Strobe
// PTB0..3,16,17
// PTC4,5
// PTD0
//
// Sense
// PTD1..7
// -- Strobes --
// Format
// gpio( <port letter>, <port #> )
// 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)
//
GPIO_Pin Matrix_strobe[] = { gpio(B,0), gpio(B,1), gpio(B,2), gpio(B,3), gpio(B,16), gpio(B,17), gpio(C,4), gpio(C,5), gpio(D,0) };
// -- Sense --
// Format
// sense( <port letter>, <port #>, <adc #>, <adc channel #> )
// Freescale ARM MK20's support 32 ADC channels
// However, not every channel is useful for reading from an input pin.
//
// NOTE: Be careful that you are not using a strobe and a sense at the same time!
//
ADC_Pin Matrix_sense[] = { sense(B,4,0,5) };
// TODO
// Misc pins required for control

View file

@ -1,92 +0,0 @@
/* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
*/
// ----- Includes -----
// Compiler Includes
#include <Lib/ScanLib.h>
// Project Includes
#include <cli.h>
#include <led.h>
#include <print.h>
#include <matrix_scan.h>
#include <macro.h>
#include <output_com.h>
// 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 cap sense matrix pins for scanning
Matrix_setup();
// Reset scan count
Scan_scanCount = 0;
}
// Main Detection Loop
inline uint8_t Scan_loop()
{
Matrix_scan( Scan_scanCount++ );
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;
}
// Signal from the Output Module that the available current has changed
// current - mA
void Scan_currentChange( unsigned int current )
{
// Indicate to all submodules current change
Matrix_currentChange( current );
}
// ----- Capabilities -----

View file

@ -1,40 +0,0 @@
/* Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
*/
#pragma once
// ----- Includes -----
// Compiler Includes
#include <stdint.h>
// ----- Functions -----
// Functions to be called by main.c
void Scan_setup();
uint8_t Scan_loop();
// Call-backs
void Scan_finishedWithMacro( uint8_t sentKeys ); // Called by Macro Module
void Scan_finishedWithOutput( uint8_t sentKeys ); // Called by Output Module
void Scan_currentChange( unsigned int current ); // Called by Output Module
// ----- Capabilities -----

View file

@ -1,32 +0,0 @@
###| CMake Kiibohd Controller Scan Module |###
#
# Written by Jacob Alexander in 2016 for the Kiibohd Controller
#
# Released into the Public Domain
#
###
###
# Required Submodules
#
AddModule ( Scan CapSense )
###
# Module C files
#
set ( Module_SRCS
scan_loop.c
)
###
# Compiler Family Compatibility
#
set ( ModuleCompatibility
arm
)