diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index 8ae1316..0000000 --- a/.clang-tidy +++ /dev/null @@ -1,16 +0,0 @@ ---- -Checks: 'clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*' -HeaderFilterRegex: '' -AnalyzeTemporaryDtors: false -User: hyatt -CheckOptions: - - key: google-readability-braces-around-statements.ShortStatementLines - value: '1' - - key: google-readability-function-size.StatementThreshold - value: '800' - - key: google-readability-namespace-comments.ShortNamespaceLines - value: '10' - - key: google-readability-namespace-comments.SpacesBeforeComments - value: '2' -... - diff --git a/.gitignore b/.gitignore index 574420d..e404153 100644 --- a/.gitignore +++ b/.gitignore @@ -41,7 +41,6 @@ .Trashes ehthumbs.db Thumbs.db -*.attr # Editor generated files # ########################## @@ -56,7 +55,6 @@ tags CMakeFiles CMakeCache.txt cmake_install.cmake -compile_commands.json # External Repos # ################## diff --git a/98-kiibohd.rules b/98-kiibohd.rules index 3dccd01..5e28301 100644 --- a/98-kiibohd.rules +++ b/98-kiibohd.rules @@ -2,26 +2,17 @@ ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{ID_MM_DEVICE_IGNORE}="1" ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", ENV{MTP_NO_PROBE}="1" SUBSYSTEMS=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", MODE:="0666" - # Kiibohd Serial Interface -KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", SYMLINK+="kiibohd", MODE:="0666", -KERNEL=="ttyACM*", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b04d", SYMLINK+="kiibohd", MODE:="0666" -KERNEL=="ttyACM*", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="f05c", SYMLINK+="kiibohd", MODE:="0666" - +KERNEL=="ttyACM*", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="04[789]?", MODE:="0666" +KERNEL=="ttyACM*", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b04d", MODE:="0666" # Kiibohd Device SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b04d", MODE:="0666" - # DFU Bootloader (MCHCK) ATTRS{idVendor}=="2323", ATTRS{idProduct}=="0001", ENV{ID_MM_DEVICE_IGNORE}="1" ATTRS{idVendor}=="2323", ATTRS{idProduct}=="0001", ENV{MTP_NO_PROBE}="1" SUBSYSTEMS=="usb", ATTRS{idVendor}=="2323", ATTRS{idProduct}=="0001", MODE:="0666" - # Kiibohd DFU Bootloader ATTRS{idVendor}=="1C11", ATTRS{idProduct}=="b007", ENV{ID_MM_DEVICE_IGNORE}="1" ATTRS{idVendor}=="1C11", ATTRS{idProduct}=="b007", ENV{MTP_NO_PROBE}="1" SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="b007", MODE:="0666" -# Kiibohd Force Gauge -SUBSYSTEM=="tty", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="f05c", GROUP="users", MODE="0666", SYMLINK+="force" -SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", ATTRS{idProduct}=="f05c", MODE:="0666" - diff --git a/Bootloader/Scripts/easyMode.bash b/Bootloader/Scripts/easyMode.bash index ece0b53..65b4848 100644 --- a/Bootloader/Scripts/easyMode.bash +++ b/Bootloader/Scripts/easyMode.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Just in case there was an extra ledTest.bash (don't care if error) rm /dev/ttyACM0 diff --git a/Bootloader/Scripts/generateManufacturingImage.bash b/Bootloader/Scripts/generateManufacturingImage.bash index 455e570..ef46e2d 100755 --- a/Bootloader/Scripts/generateManufacturingImage.bash +++ b/Bootloader/Scripts/generateManufacturingImage.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Combines a given bootloader image and firmware image into a single firmware binary # Manufacturing deliverable diff --git a/Bootloader/Scripts/ledTest.bash b/Bootloader/Scripts/ledTest.bash index 9c8565f..07aa9d8 100644 --- a/Bootloader/Scripts/ledTest.bash +++ b/Bootloader/Scripts/ledTest.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash printf "led\r" > /dev/ttyACM0 diff --git a/Bootloader/Scripts/swdLoad.bash b/Bootloader/Scripts/swdLoad.bash index 6c333bf..12b1e9b 100755 --- a/Bootloader/Scripts/swdLoad.bash +++ b/Bootloader/Scripts/swdLoad.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Loads firmware image using an SWD Flasher # Uses MCHCK ruby flasher toolchain # NOTE: Only tested with a buspirate on Linux diff --git a/Bootloader/debug.h b/Bootloader/debug.h index ceb7d88..83e9bac 100644 --- a/Bootloader/debug.h +++ b/Bootloader/debug.h @@ -53,7 +53,6 @@ void uart_serial_setup(); // Convenience #define printHex(hex) printHex_op(hex, 1) -#define printHex32(hex) printHex_op(hex, 1) void printHex_op( uint32_t in, uint8_t op ); #else @@ -61,7 +60,6 @@ void printHex_op( uint32_t in, uint8_t op ); #define uart_serial_write(buf,size) #define uart_serial_setup() #define printHex(hex) -#define printHex32(hex) #define printHex_op(in,op) #endif diff --git a/Bootloader/dfu.desc.c b/Bootloader/dfu.desc.c index a0ce1f8..dc11fef 100644 --- a/Bootloader/dfu.desc.c +++ b/Bootloader/dfu.desc.c @@ -1,5 +1,5 @@ // Originally Generated from MCHCK Toolkit -/* Copyright (c) Jacob Alexander 2014-2016 +/* Copyright (c) Jacob Alexander 2014-2015 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,7 +38,7 @@ static const struct usb_config_1 usb_config_1 = { .bConfigurationValue = 1, .iConfiguration = 0, .one = 1, - .bMaxPower = 50 + .bMaxPower = 100 }, .usb_function_0 = { .iface = { diff --git a/CMakeLists.txt b/CMakeLists.txt index f6c5ef1..1f14bbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ ###| CMAKE Kiibohd Controller |### # -# Jacob Alexander 2011-2016 +# Jacob Alexander 2011-2015 # Due to this file's usefulness: # # Released into the Public Domain @@ -22,11 +22,10 @@ set( CHIP # "at90usb646" # Teensy++ 1.0 (avr) # "at90usb1286" # Teensy++ 2.0 (avr) # "mk20dx128" # Teensy 3.0 (arm) -# "mk20dx128vlf5" # McHCK mk20dx128vlf5 -# "mk20dx256" # Teensy 3.1,3.2 (arm) - "mk20dx256vlh7" # Kiibohd-dfu mk20dx256vlh7 - CACHE STRING "Microcontroller Chip" -) + "mk20dx128vlf5" # McHCK mk20dx128vlf5 +# "mk20dx256" # Teensy 3.1 (arm) +# "mk20dx256vlh7" # Kiibohd-dfu mk20dx256vlh7 + CACHE STRING "Microcontroller Chip" ) @@ -34,14 +33,13 @@ set( CHIP # Compiler Selection # -#| gcc has been tested much more (and will likely give smaller binaries) -#| clang does work though +#| *** EXPERIMENTAL *** +#| Stick with gcc unless you know what you're doing #| Currently only arm is supported with clang set( COMPILER "gcc" # arm-none-eabi-gcc / avr-gcc - Default # "clang" # arm-none-eabi - CACHE STRING "Compiler Type" -) + CACHE STRING "Compiler Type" ) @@ -65,7 +63,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 "MDErgo1" +set( ScanModule "MD1" CACHE STRING "Scan Module" ) ##| Provides the mapping functions for DefaultMap and handles any macro processing before sending to the OutputModule @@ -74,13 +72,11 @@ set( MacroModule "PartialMap" ##| Sends the current list of usb key codes through USB HID set( OutputModule "pjrcUSB" - CACHE STRING "Output Module" -) + CACHE STRING "Output Module" ) ##| Debugging source to use, each module has it's own set of defines that it sets set( DebugModule "full" - CACHE STRING "Debug Module" -) + CACHE STRING "Debug Module" ) diff --git a/Debug/cli/cli.c b/Debug/cli/cli.c index 5c83ee6..03fb3ca 100644 --- a/Debug/cli/cli.c +++ b/Debug/cli/cli.c @@ -21,12 +21,14 @@ // ----- Includes ----- +// Compiler Includes +//#include + // Project Includes #include #include "cli.h" #include #include -#include @@ -159,12 +161,15 @@ void CLI_process() } else { - // Add the command to the history - CLI_saveHistory( CLILineBuffer ); + // Only do command-related stuff if there was actually a command + // Avoids clogging command history with blanks // Process the current line buffer CLI_commandLookup(); + // Add the command to the history + CLI_saveHistory( CLILineBuffer ); + // Keep the array circular, discarding the older entries if ( CLIHistoryTail < CLIHistoryHead ) CLIHistoryHead = ( CLIHistoryHead + 1 ) % CLIMaxHistorySize; @@ -422,11 +427,6 @@ inline void CLI_saveHistory( char *buff ) return; } - // Don't write empty lines to the history - const char *cursor = buff; - while (*cursor == ' ') { cursor++; } // advance past the leading whitespace - if (*cursor == '\0') { return ; } - // Copy the line to the history int i; for (i = 0; i < CLILineBufferCurrent; i++) @@ -517,14 +517,6 @@ void cliFunc_led( char* args ) void cliFunc_reload( char* args ) { - if ( flashModeEnabled_define == 0 ) - { - print( NL ); - warn_print("flashModeEnabled not set, cancelling firmware reload..."); - info_msg("Set flashModeEnabled to 1 in your kll configuration."); - return; - } - // Request to output module to be set into firmware reload mode Output_firmwareReload(); } diff --git a/Keyboards/README.markdown b/Keyboards/README.markdown index 9240c18..c9c93fa 100644 --- a/Keyboards/README.markdown +++ b/Keyboards/README.markdown @@ -28,9 +28,7 @@ Projects -------- * infinity.bash (Infinity Keyboard 2014/10/15) -* ergodox.bash (Infinity Ergodox 2015/08/15) * template.bash (Example template for new keyboards) -* whitefox.bash (Soon?) **Extra files** diff --git a/Keyboards/cmake.bash b/Keyboards/cmake.bash index 9587abe..61995b0 100644 --- a/Keyboards/cmake.bash +++ b/Keyboards/cmake.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # This is bash lib file for the convenience build scripts # Don't call this script directly # Jacob Alexander 2015 @@ -82,19 +82,7 @@ done mkdir -p "${BuildPath}" cd "${BuildPath}" cmake -DCHIP="${Chip}" -DCOMPILER="${Compiler}" -DScanModule="${ScanModule}" -DMacroModule="${MacroModule}" -DOutputModule="${OutputModule}" -DDebugModule="${DebugModule}" -DBaseMap="${BaseMap}" -DDefaultMap="${DefaultMap}" -DPartialMaps="${PartialMapsExpanded}" "${CMakeListsPath}" -return_code=$? -if [ $return_code != 0 ] ; then - echo "Error in cmake. Exiting..." - exit $return_code -fi - make -return_code=$? -if [ $return_code != 0 ] ; then - echo "Error in make. Exiting..." - exit $return_code -fi echo "Firmware has been compiled into: '${BuildPath}'" -cd - diff --git a/Keyboards/ergodox.bash b/Keyboards/ergodox.bash deleted file mode 100755 index 85f85a2..0000000 --- a/Keyboards/ergodox.bash +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env 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 # -################# - -######## Left Side ######## - -# Feel free to change the variables in this section to configure your keyboard - -BuildPath="ICED-L" - -## KLL Configuration ## - -# Generally shouldn't be changed, this will affect every layer -BaseMap="defaultMap leftHand slave1 rightHand" - -# 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="mdergo1Overlay lcdFuncMap" - -# 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]="iced_func" -PartialMaps[2]="iced_numpad" - - - -########################## -# 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="MDErgo1" -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 - - - -######################### -# Re-run for right side # -######################### - -######## Right Side ######## - -# Feel free to change the variables in this section to configure your keyboard - -BuildPath="ICED-R" - -## KLL Configuration ## - -# Only changing the basemap (everything else is the same) -# Generally shouldn't be changed, this will affect every layer -BaseMap="defaultMap rightHand slave1 leftHand" - -# Load the library (starts the build) -source cmake.bash - - diff --git a/Keyboards/infinity.bash b/Keyboards/infinity.bash index b790dd5..259183f 100755 --- a/Keyboards/infinity.bash +++ b/Keyboards/infinity.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/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 @@ -11,7 +11,7 @@ # Feel free to change the variables in this section to configure your keyboard -BuildPath="IC60" +BuildPath="template" ## KLL Configuration ## diff --git a/Keyboards/template.bash b/Keyboards/template.bash index c522726..b1e876f 100755 --- a/Keyboards/template.bash +++ b/Keyboards/template.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/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 diff --git a/Keyboards/whitefox.bash b/Keyboards/whitefox.bash deleted file mode 100755 index 049986a..0000000 --- a/Keyboards/whitefox.bash +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env 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/Lib/CMake/arm.cmake b/Lib/CMake/arm.cmake index 31fe0cd..be04de2 100644 --- a/Lib/CMake/arm.cmake +++ b/Lib/CMake/arm.cmake @@ -1,6 +1,6 @@ ###| CMAKE Kiibohd Controller |### # -# Jacob Alexander 2011-2016 +# Jacob Alexander 2011-2014 # Due to this file's usefulness: # # Released into the Public Domain @@ -111,13 +111,6 @@ set( COMPILER_SRCS Lib/delay.c ) -#| Clang needs a few more functions for linking -if ( "${COMPILER}" MATCHES "clang" ) - set( COMPILER_SRCS ${COMPILER_SRCS} - Lib/clang.c - ) -endif () - message( STATUS "Compiler Source Files:" ) message( "${COMPILER_SRCS}" ) diff --git a/Lib/CMake/build.cmake b/Lib/CMake/build.cmake index de58ea0..b3209bf 100644 --- a/Lib/CMake/build.cmake +++ b/Lib/CMake/build.cmake @@ -135,23 +135,3 @@ elseif ( DEFINED TEENSY ) endif() endif() - - -### -# Compiler Command Generation -# - -#| Generate list of compiler commands for clang-tidy usage -set( CMAKE_EXPORT_COMPILE_COMMANDS ON ) - -#| Make sure symlink exists (for convenience) -if ( UNIX ) - # Make sure symlink is created immediately - execute_process ( COMMAND ln -sfn ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/. ) - - # Also update before each build - add_custom_command( TARGET ${TARGET_ELF} POST_BUILD - COMMAND ln -sfn ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/. - ) -endif () - diff --git a/Lib/CMake/kll.cmake b/Lib/CMake/kll.cmake index dce9f17..36802e4 100644 --- a/Lib/CMake/kll.cmake +++ b/Lib/CMake/kll.cmake @@ -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,71 +57,65 @@ 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 ) - 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 () + 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 () 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 ) - 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 () + # 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 () endif () #| Print list of layout sources used message ( STATUS "Detected Layout Files:" ) foreach ( filename ${KLL_DEPENDS} ) - message ( "${filename}" ) + message ( "${filename}" ) endforeach () @@ -139,15 +133,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 diff --git a/Lib/CMake/modules.cmake b/Lib/CMake/modules.cmake index d13b868..0951d4d 100644 --- a/Lib/CMake/modules.cmake +++ b/Lib/CMake/modules.cmake @@ -277,7 +277,7 @@ if ( CTAGS_EXECUTABLE ) endforeach () # Generate the ctags - execute_process ( COMMAND ctags --fields=+l ${CTAG_PATHS} + execute_process ( COMMAND ctags ${CTAG_PATHS} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) endif () diff --git a/Lib/CMake/sizeCalculator b/Lib/CMake/sizeCalculator index b0ab2e6..affb163 100755 --- a/Lib/CMake/sizeCalculator +++ b/Lib/CMake/sizeCalculator @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash #| Jacob Alexander 2014 #| Arg List #| 1 - size binary (e.g. avr-size) diff --git a/Lib/CMake/writer b/Lib/CMake/writer index a5eb27b..23f94dd 100755 --- a/Lib/CMake/writer +++ b/Lib/CMake/writer @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash #| Jacob Alexander 2014 #| Arg List #| 1 - File to write to (e.g. final_chip) diff --git a/Lib/clang.c b/Lib/clang.c deleted file mode 100644 index f502409..0000000 --- a/Lib/clang.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2016 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. - */ - - -// This file adds various functions that clang doesn't link properly -// AFAIK, clang doesn't have an elegant solution for this, so this is what we gotta do... - -// ----- Includes ----- - -// Compiler Includes -#include - - -void __aeabi_memcpy( void *dest, const void *src, size_t n ) -{ - (void)memcpy(dest, src, n); -} - -void __aeabi_memcpy4( void *dest, const void *src, size_t n ) -{ - memcpy(dest, src, n); -} - -void __aeabi_memclr( void *dest, size_t n ) -{ - memset(dest, 0, n); -} - -void __aeabi_memclr4( void *dest, size_t n ) -{ - memset(dest, 0, n); -} - -void __aeabi_memmove( void *dest, const void *src, size_t n ) -{ - (void)memmove(dest, src, n); -} - -void __aeabi_memset( void *s, size_t n, int c ) -{ - (void)memset(s, c, n); -} - diff --git a/Lib/mk20dx.c b/Lib/mk20dx.c index ec6908c..47759a4 100644 --- a/Lib/mk20dx.c +++ b/Lib/mk20dx.c @@ -106,41 +106,28 @@ void nmi_default_isr() // NVIC - Hard Fault ISR void hard_fault_default_isr() { - print("Hard Fault! SCB_HFSR: "); - printHex32( SCB_HFSR ); - print( NL ); - SOFTWARE_RESET(); + print("Hard Fault!" NL ); } // NVIC - Memory Manager Fault ISR void memmanage_fault_default_isr() { - print("Memory Manager Fault! SCB_CFSR: "); - printHex32( SCB_CFSR ); - print(" SCB_MMAR: "); - printHex32( SCB_MMAR ); - print( NL ); + print("Memory Manager Fault!" NL ); } // NVIC - Bus Fault ISR void bus_fault_default_isr() { - print("Bus Fault! SCB_CFSR: "); - printHex32( SCB_CFSR ); - print(" SCB_BFAR: "); - printHex32( SCB_BFAR ); - print( NL ); + print("Bus Fault!" NL ); } // NVIC - Usage Fault ISR void usage_fault_default_isr() { - print("Usage Fault! SCB_CFSR: "); - printHex32( SCB_CFSR ); - print( NL ); + print("Usage Fault!" NL ); } diff --git a/Lib/mk20dx.h b/Lib/mk20dx.h index ae69dd4..aff530a 100644 --- a/Lib/mk20dx.h +++ b/Lib/mk20dx.h @@ -511,37 +511,11 @@ #define DMA_ERQ_ERQ1 ((uint32_t)1<<1) // Enable DMA Request 1 #define DMA_ERQ_ERQ2 ((uint32_t)1<<2) // Enable DMA Request 2 #define DMA_ERQ_ERQ3 ((uint32_t)1<<3) // Enable DMA Request 3 -#define DMA_ERQ_ERQ4 ((uint32_t)1<<4) // Enable DMA Request 4 -#define DMA_ERQ_ERQ5 ((uint32_t)1<<5) // Enable DMA Request 5 -#define DMA_ERQ_ERQ6 ((uint32_t)1<<6) // Enable DMA Request 6 -#define DMA_ERQ_ERQ7 ((uint32_t)1<<7) // Enable DMA Request 7 -#define DMA_ERQ_ERQ8 ((uint32_t)1<<8) // Enable DMA Request 8 -#define DMA_ERQ_ERQ9 ((uint32_t)1<<9) // Enable DMA Request 9 -#define DMA_ERQ_ERQ10 ((uint32_t)1<<10) // Enable DMA Request 10 -#define DMA_ERQ_ERQ11 ((uint32_t)1<<11) // Enable DMA Request 11 -#define DMA_ERQ_ERQ12 ((uint32_t)1<<12) // Enable DMA Request 12 -#define DMA_ERQ_ERQ13 ((uint32_t)1<<13) // Enable DMA Request 13 -#define DMA_ERQ_ERQ14 ((uint32_t)1<<14) // Enable DMA Request 14 -#define DMA_ERQ_ERQ15 ((uint32_t)1<<15) // Enable DMA Request 15 -#define DMA_ERQ_ERQ16 ((uint32_t)1<<16) // Enable DMA Request 16 #define DMA_EEI *(volatile uint32_t *)0x40008014 // Enable Error Interrupt Register #define DMA_EEI_EEI0 ((uint32_t)1<<0) // Enable Error Interrupt 0 #define DMA_EEI_EEI1 ((uint32_t)1<<1) // Enable Error Interrupt 1 #define DMA_EEI_EEI2 ((uint32_t)1<<2) // Enable Error Interrupt 2 #define DMA_EEI_EEI3 ((uint32_t)1<<3) // Enable Error Interrupt 3 -#define DMA_EEI_EEI4 ((uint32_t)1<<4) // Enable Error Interrupt 4 -#define DMA_EEI_EEI5 ((uint32_t)1<<5) // Enable Error Interrupt 5 -#define DMA_EEI_EEI6 ((uint32_t)1<<6) // Enable Error Interrupt 6 -#define DMA_EEI_EEI7 ((uint32_t)1<<7) // Enable Error Interrupt 7 -#define DMA_EEI_EEI8 ((uint32_t)1<<8) // Enable Error Interrupt 8 -#define DMA_EEI_EEI9 ((uint32_t)1<<9) // Enable Error Interrupt 9 -#define DMA_EEI_EEI10 ((uint32_t)1<<10) // Enable Error Interrupt 10 -#define DMA_EEI_EEI11 ((uint32_t)1<<11) // Enable Error Interrupt 11 -#define DMA_EEI_EEI12 ((uint32_t)1<<12) // Enable Error Interrupt 12 -#define DMA_EEI_EEI13 ((uint32_t)1<<13) // Enable Error Interrupt 13 -#define DMA_EEI_EEI14 ((uint32_t)1<<14) // Enable Error Interrupt 14 -#define DMA_EEI_EEI15 ((uint32_t)1<<15) // Enable Error Interrupt 15 -#define DMA_EEI_EEI16 ((uint32_t)1<<16) // Enable Error Interrupt 16 #define DMA_CEEI *(volatile uint8_t *)0x40008018 // Clear Enable Error Interrupt Register #define DMA_CEEI_CEEI(n) ((uint8_t)(n & 3)<<0) // Clear Enable Error Interrupt #define DMA_CEEI_CAEE ((uint8_t)1<<6) // Clear All Enable Error Interrupts @@ -1494,8 +1468,6 @@ typedef struct { #define UART0_MA2 *(volatile uint8_t *)0x4006A009 // UART Match Address Registers 2 #define UART0_C4 *(volatile uint8_t *)0x4006A00A // UART Control Register 4 #define UART0_C5 *(volatile uint8_t *)0x4006A00B // UART Control Register 5 -#define UART_C5_TDMAS 0x80 -#define UART_C5_RDMAS 0x20 #define UART0_ED *(volatile uint8_t *)0x4006A00C // UART Extended Data Register #define UART0_MODEM *(volatile uint8_t *)0x4006A00D // UART Modem Register #define UART0_IR *(volatile uint8_t *)0x4006A00E // UART Infrared Register @@ -1979,9 +1951,7 @@ typedef struct { #define SCB_CFSR *(volatile uint32_t *)0xE000ED28 // Configurable Fault Status Register #define SCB_HFSR *(volatile uint32_t *)0xE000ED2C // HardFault Status #define SCB_DFSR *(volatile uint32_t *)0xE000ED30 // Debug Fault Status -#define SCB_MMAR *(volatile uint32_t *)0xE000ED34 // MemManage Fault Address -#define SCB_BFAR *(volatile uint32_t *)0xE000ED38 // BusFault Addreses Register -#define SCB_AFSR *(volatile uint32_t *)0xE000ED3C // Auxilary Fault Status Register +#define SCB_MMFAR *(volatile uint32_t *)0xE000ED34 // MemManage Fault Address #define SYST_CSR *(volatile uint32_t *)0xE000E010 // SysTick Control and Status #define SYST_CSR_COUNTFLAG (uint32_t)0x00010000 diff --git a/LoadFile/load.dfu b/LoadFile/load.dfu index 5c7719c..d99c5e6 100755 --- a/LoadFile/load.dfu +++ b/LoadFile/load.dfu @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Convenience script for loading firmware onto a dfu type device # By default, initiates dfu-util diff --git a/LoadFile/load.teensy b/LoadFile/load.teensy index b86dd11..751a97f 100755 --- a/LoadFile/load.teensy +++ b/LoadFile/load.teensy @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Convenience script for loading firmware onto a teensy type device # By default, initiates teensy-load-cli diff --git a/LoadFile/winload.teensy b/LoadFile/winload.teensy index 4928197..1d86daf 100755 --- a/LoadFile/winload.teensy +++ b/LoadFile/winload.teensy @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash # Convenience script for loading firmware onto a teensy type device # By default, initiates teensy-load-cli diff --git a/Macro/PartialMap/capabilities.kll b/Macro/PartialMap/capabilities.kll index 09ac6a2..4572c05 100644 --- a/Macro/PartialMap/capabilities.kll +++ b/Macro/PartialMap/capabilities.kll @@ -1,22 +1,17 @@ Name = PartialMapCapabilities; -Version = 0.2; -Author = "HaaTa (Jacob Alexander) 2014-2015"; -KLL = 0.3b; +Version = 0.1; +Author = "HaaTa (Jacob Alexander) 2014"; +KLL = 0.3a; # Modified Date -Date = 2015-09-24; +Date = 2014-11-21; # Capabilties available to the PartialMap module -layerState => Macro_layerState_capability( layer : 2, state : 1 ); -layerLatch => Macro_layerLatch_capability( layer : 2 ); -layerLock => Macro_layerLock_capability( layer : 2 ); -layerShift => Macro_layerShift_capability( layer : 2 ); -# By default, rotate to the next layer -# The current rotating layer is stored separately to the layer stack -# But still sets the layer stack using the layerLock/unlock mechanism -# Argument 0 -> Next, 1 -> Previous -layerRotate => Macro_layerRotate_capability( previous : 1 ); +layerState => Macro_layerState_capability( layer : 2, state : 1 ); +layerLatch => Macro_layerLatch_capability( layer : 2 ); +layerLock => Macro_layerLock_capability( layer : 2 ); +layerShift => Macro_layerShift_capability( layer : 2 ); # Defines available to the PartialMap module stateWordSize => StateWordSize_define; diff --git a/Macro/PartialMap/macro.c b/Macro/PartialMap/macro.c index dc51751..89444dc 100644 --- a/Macro/PartialMap/macro.c +++ b/Macro/PartialMap/macro.c @@ -135,7 +135,7 @@ uint16_t macroStepCounter = 0; // Key Trigger List Buffer and Layer Cache // The layer cache is set on press only, hold and release events refer to the value set on press TriggerGuide macroTriggerListBuffer[ MaxScanCode ]; -var_uint_t macroTriggerListBufferSize = 0; +uint8_t macroTriggerListBufferSize = 0; var_uint_t macroTriggerListLayerCache[ MaxScanCode ]; // Pending Trigger Macro Index List @@ -170,8 +170,8 @@ uint8_t macroInterconnectCacheSize = 0; // Sets the given layer with the specified layerState void Macro_layerState( uint8_t state, uint8_t stateType, uint16_t layer, uint8_t layerState ) { - // Ignore if layer does not exist or trying to manipulate layer 0/Default layer - if ( layer >= LayerNum || layer == 0 ) + // Ignore if layer does not exist + if ( layer >= LayerNum ) return; // Is layer in the LayerIndexStack? @@ -350,58 +350,6 @@ void Macro_layerShift_capability( uint8_t state, uint8_t stateType, uint8_t *arg } -// Rotate layer to next/previous -// Uses state variable to keep track of the current layer position -// Layers are still evaluated using the layer stack -uint16_t Macro_rotationLayer; -void Macro_layerRotate_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("Macro_layerRotate(previous)"); - return; - } - - // Only use capability on press - // TODO Analog - // XXX Could also be on release, but that's sorta dumb -HaaTa - if ( stateType == 0x00 && state != 0x01 ) // All normal key conditions except press - return; - - // Unset previous rotation layer if not 0 - if ( Macro_rotationLayer != 0 ) - { - Macro_layerState( state, stateType, Macro_rotationLayer, 0x04 ); - } - - // Get direction of rotation, 0, next, non-zero previous - uint8_t direction = *args; - - // Next - if ( !direction ) - { - Macro_rotationLayer++; - - // Invalid layer - if ( Macro_rotationLayer >= LayerNum ) - Macro_rotationLayer = 0; - } - // Previous - else - { - Macro_rotationLayer--; - - // Layer wrap - if ( Macro_rotationLayer >= LayerNum ) - Macro_rotationLayer = LayerNum - 1; - } - - // Toggle the computed layer rotation - Macro_layerState( state, stateType, Macro_rotationLayer, 0x04 ); -} - - // ----- Functions ----- @@ -422,26 +370,11 @@ nat_ptr_t *Macro_layerLookup( TriggerGuide *guide, uint8_t latch_expire ) nat_ptr_t **map = (nat_ptr_t**)LayerIndex[ cachedLayer ].triggerMap; const Layer *layer = &LayerIndex[ cachedLayer ]; - // Cache trigger list before attempting to expire latch - nat_ptr_t *trigger_list = map[ scanCode - layer->first ]; - - // Check if latch has been pressed for this layer - uint8_t latch = LayerState[ cachedLayer ] & 0x02; - if ( latch && latch_expire ) - { - Macro_layerState( 0, 0, cachedLayer, 0x02 ); -#if defined(ConnectEnabled_define) && defined(LCDEnabled_define) - // Evaluate the layerStack capability if available (LCD + Interconnect) - extern void LCD_layerStack_capability( uint8_t state, uint8_t stateType, uint8_t *args ); - LCD_layerStack_capability( 0, 0, 0 ); -#endif - } - - return trigger_list; + return map[ scanCode - layer->first ]; } // If no trigger macro is defined at the given layer, fallthrough to the next layer - for ( uint16_t layerIndex = macroLayerIndexStackSize; layerIndex != 0xFFFF; layerIndex-- ) + for ( uint16_t layerIndex = 0; layerIndex < macroLayerIndexStackSize; layerIndex++ ) { // Lookup Layer const Layer *layer = &LayerIndex[ macroLayerIndexStack[ layerIndex ] ]; @@ -465,9 +398,9 @@ nat_ptr_t *Macro_layerLookup( TriggerGuide *guide, uint8_t latch_expire ) // Determine if layer has key defined // Make sure scanCode is between layer first and last scancodes if ( map != 0 - && scanCode <= layer->last - && scanCode >= layer->first - && *map[ scanCode - layer->first ] != 0 ) + && scanCode <= layer->last + && scanCode >= layer->first + && *map[ scanCode - layer->first ] != 0 ) { // Set the layer cache macroTriggerListLayerCache[ scanCode ] = macroLayerIndexStack[ layerIndex ]; @@ -485,9 +418,9 @@ nat_ptr_t *Macro_layerLookup( TriggerGuide *guide, uint8_t latch_expire ) // Make sure scanCode is between layer first and last scancodes if ( map != 0 - && scanCode <= layer->last - && scanCode >= layer->first - && *map[ scanCode - layer->first ] != 0 ) + && scanCode <= layer->last + && scanCode >= layer->first + && *map[ scanCode - layer->first ] != 0 ) { // Set the layer cache to default map macroTriggerListLayerCache[ scanCode ] = 0; @@ -523,7 +456,7 @@ inline void Macro_interconnectAdd( void *trigger_ptr ) case 0x03: break; default: - erro_msg("Invalid key state - "); + erro_print("Invalid key state"); error = 1; break; } @@ -531,18 +464,11 @@ inline void Macro_interconnectAdd( void *trigger_ptr ) // Invalid TriggerGuide type default: - erro_msg("Invalid type - "); + erro_print("Invalid type"); error = 1; break; } - // Check if ScanCode is out of range - if ( trigger->scanCode > MaxScanCode ) - { - warn_msg("ScanCode is out of range/not defined - "); - error = 1; - } - // Display TriggerGuide if ( error ) { @@ -557,7 +483,7 @@ inline void Macro_interconnectAdd( void *trigger_ptr ) // Add trigger to the Interconnect Cache // During each processing loop, a scancode may be re-added depending on it's state - for ( var_uint_t c = 0; c < macroInterconnectCacheSize; c++ ) + for ( uint8_t c = 0; c < macroInterconnectCacheSize; c++ ) { // Check if the same ScanCode if ( macroInterconnectCache[ c ].scanCode == trigger->scanCode ) @@ -603,15 +529,6 @@ 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 @@ -632,15 +549,6 @@ 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 @@ -659,9 +567,6 @@ 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 @@ -699,7 +604,7 @@ inline void Macro_appendResultMacroToPendingList( const TriggerMacro *triggerMac uint8_t scanCode = ((TriggerGuide*)&triggerMacro->guide[ pos - TriggerGuideSize ])->scanCode; // Lookup scanCode in buffer list for the current state and stateType - for ( var_uint_t keyIndex = 0; keyIndex < macroTriggerListBufferSize; keyIndex++ ) + for ( uint8_t keyIndex = 0; keyIndex < macroTriggerListBufferSize; keyIndex++ ) { if ( macroTriggerListBuffer[ keyIndex ].scanCode == scanCode ) { @@ -905,7 +810,7 @@ TriggerMacroEval Macro_evalTriggerMacro( var_uint_t triggerMacroIndex ) TriggerMacroVote vote = TriggerMacroVote_Invalid; // Iterate through the key buffer, comparing to each key in the combo - for ( var_uint_t key = 0; key < macroTriggerListBufferSize; key++ ) + for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ ) { // Lookup key information TriggerGuide *keyInfo = ¯oTriggerListBuffer[ key ]; @@ -959,7 +864,7 @@ TriggerMacroEval Macro_evalTriggerMacro( var_uint_t triggerMacroIndex ) } // If passing and in Waiting state, set macro state to Press else if ( overallVote & TriggerMacroVote_Pass - && ( record->state == TriggerMacro_Waiting || record->state == TriggerMacro_Press ) ) + && ( record->state == TriggerMacro_Waiting || record->state == TriggerMacro_Press ) ) { record->state = TriggerMacro_Press; @@ -1065,7 +970,7 @@ inline ResultMacroEval Macro_evalResultMacro( var_uint_t resultMacroIndex ) inline void Macro_updateTriggerMacroPendingList() { // Iterate over the macroTriggerListBuffer to add any new Trigger Macros to the pending list - for ( var_uint_t key = 0; key < macroTriggerListBufferSize; key++ ) + for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ ) { // TODO LED States // TODO Analog Switches @@ -1279,9 +1184,6 @@ inline void Macro_setup() // Make sure macro trigger buffer is empty macroTriggerListBufferSize = 0; - // Set the current rotated layer to 0 - Macro_rotationLayer = 0; - // Initialize TriggerMacro states for ( var_uint_t macro = 0; macro < TriggerMacroNum; macro++ ) { @@ -1378,19 +1280,6 @@ void cliFunc_capSelect( char* args ) printHex( argSet[2] ); print( "..." NL ); - // Make sure this isn't the reload capability - // If it is, and the remote reflash define is not set, ignore - if ( flashModeEnabled_define == 0 ) for ( uint32_t cap = 0; cap < CapabilitiesNum; cap++ ) - { - if ( CapabilitiesList[ cap ].func == (const void*)Output_flashMode_capability ) - { - print( NL ); - warn_print("flashModeEnabled not set, cancelling firmware reload..."); - info_msg("Set flashModeEnabled to 1 in your kll configuration."); - return; - } - } - void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(CapabilitiesList[ cap ].func); capability( argSet[0], argSet[1], &argSet[2] ); } @@ -1586,7 +1475,7 @@ void cliFunc_macroList( char* args ) info_msg("Pending Key Events: "); printInt16( (uint16_t)macroTriggerListBufferSize ); print(" : "); - for ( var_uint_t key = 0; key < macroTriggerListBufferSize; key++ ) + for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ ) { printHex( macroTriggerListBuffer[ key ].scanCode ); print(" "); diff --git a/Macro/PartialMap/macro.h b/Macro/PartialMap/macro.h index 2df411e..eae77dd 100644 --- a/Macro/PartialMap/macro.h +++ b/Macro/PartialMap/macro.h @@ -23,6 +23,15 @@ +// ----- Capabilities ----- + +void Macro_layerState_capability( uint8_t state, uint8_t stateType, uint8_t *args ); +void Macro_layerLatch_capability( uint8_t state, uint8_t stateType, uint8_t *args ); +void Macro_layerLock_capability( uint8_t state, uint8_t stateType, uint8_t *args ); +void Macro_layerShift_capability( uint8_t state, uint8_t stateType, uint8_t *args ); + + + // ----- Functions ----- void Macro_analogState( uint8_t scanCode, uint8_t state ); diff --git a/Macro/PartialMap/usb_hid.h b/Macro/PartialMap/usb_hid.h index 4f5cd7a..a7d5581 100644 --- a/Macro/PartialMap/usb_hid.h +++ b/Macro/PartialMap/usb_hid.h @@ -74,8 +74,8 @@ #define KEY_SPACE 0x2C #define KEY_MINUS 0x2D #define KEY_EQUAL 0x2E -#define KEY_LEFT_BRACKET 0x2F -#define KEY_RIGHT_BRACKET 0x30 +#define KEY_LEFT_BRACE 0x2F +#define KEY_RIGHT_BRACE 0x30 #define KEY_BACKSLASH 0x31 #define KEY_NUMBER 0x32 #define KEY_SEMICOLON 0x33 @@ -438,15 +438,7 @@ #define CONSUMER_BROADCAST_MODE 0x064 #define CONSUMER_SNAPSHOT 0x065 #define CONSUMER_STILL 0x066 -// 0x067 - 0x06E Reserved? -#define CONSUMER_BRIGHTNESS_INCREMENT 0x06F -#define CONSUMER_BRIGHTNESS_DECREMENT 0x070 - -#define CONSUMER_BACKLIGHT_TOGGLE 0x072 -#define CONSUMER_BRIGHTNESS_MIN 0x073 -#define CONSUMER_BRIGHTNESS_MAX 0x074 -#define CONSUMER_BRIGHTNESS_AUTO 0x075 -// 0x076 - 0x07F Reserved +// 0x067 - 0x07F Reserved #define CONSUMER_ASSIGN_SELECTION 0x081 #define CONSUMER_MODE_STEP 0x082 @@ -778,6 +770,5 @@ #define AC_SPLIT 0x29A #define AC_DISTRIBUTE_HORIZONTALLY 0x29B #define AC_DISTRIBUTE_VERTICALLY 0x29C -#define AC_NEXT_KEYBOARD_LAYOUT_SEL 0x29D -// 0x29E-0xFFFF Reserved +// 0x29D-0xFFFF Reserved diff --git a/Output/pjrcUSB/arm/usb_desc.c b/Output/pjrcUSB/arm/usb_desc.c index b0be2a0..0a44d5c 100644 --- a/Output/pjrcUSB/arm/usb_desc.c +++ b/Output/pjrcUSB/arm/usb_desc.c @@ -1,7 +1,7 @@ /* Teensyduino Core Library * http://www.pjrc.com/teensy/ * Copyright (c) 2013 PJRC.COM, LLC. - * Modified by Jacob Alexander (2013-2016) + * Modified by Jacob Alexander (2013-2014) * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -34,9 +34,6 @@ // Local Includes #include "usb_desc.h" -// Generated Includes -#include - // ----- Macros ----- @@ -97,7 +94,7 @@ static uint8_t usb_debug_descriptor[] = { -// ----- USB HID Report Descriptors ----- +// ----- USB HID Report Descriptsors ----- // Each HID interface needs a special report descriptor that tells // the meaning and format of the data. @@ -263,11 +260,8 @@ static uint8_t nkro_keyboard_report_desc[] = { 0x95, 0x01, // Report Count (1), 0x81, 0x03, // Input (Constant), 0xc0, // End Collection - Keyboard -}; -// System Control and Consumer Control -static uint8_t sys_ctrl_report_desc[] = { - // System Control Collection (8 bits) + // System Control Collection // // NOTES: // Not bothering with NKRO for this table. If there's need, I can implement it. -HaaTa @@ -285,7 +279,7 @@ static uint8_t sys_ctrl_report_desc[] = { 0x81, 0x00, // Input (Data, Array), 0xc0, // End Collection - System Control - // Consumer Control Collection - Media Keys (16 bits) + // Consumer Control Collection - Media Keys // // NOTES: // Not bothering with NKRO for this table. If there's a need, I can implement it. -HaaTa @@ -296,139 +290,49 @@ static uint8_t sys_ctrl_report_desc[] = { 0x85, 0x03, // Report ID (3), 0x75, 0x10, // Report Size (16), 0x95, 0x01, // Report Count (1), - 0x16, 0x01, 0x00, // Logical Minimum (1), - 0x26, 0x9D, 0x02, // Logical Maximum (669), + 0x16, 0x20, 0x00, // Logical Minimum (32), + 0x26, 0x9C, 0x02, // Logical Maximum (668), 0x05, 0x0C, // Usage Page (Consumer), - 0x19, 0x01, // Usage Minimum (1), - 0x2A, 0x9D, 0x02, // Usage Maximum (669), + 0x19, 0x20, // Usage Minimum (32), + 0x2A, 0x9C, 0x02, // Usage Maximum (668), 0x81, 0x00, // Input (Data, Array), 0xc0, // End Collection - Consumer Control }; +/* MOUSE // Mouse Protocol 1, HID 1.11 spec, Appendix B, page 59-60, with wheel extension static uint8_t mouse_report_desc[] = { - 0x05, 0x01, // Usage Page (Generic Desktop) - 0x09, 0x02, // Usage (Mouse) - 0xA1, 0x01, // Collection (Application) - 0x09, 0x02, // Usage (Mouse) - 0xA1, 0x02, // Collection (Logical) - 0x09, 0x01, // Usage (Pointer) - - // Buttons (16 bits) - 0xA1, 0x00, // Collection (Physical) - Buttons - 0x05, 0x09, // Usage Page (Button) - 0x19, 0x01, // Usage Minimum (Button 1) - 0x29, 0x10, // Usage Maximum (Button 16) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x10, // Report Count (16) - 0x81, 0x02, // Input (Data,Var,Abs) - - // Pointer (32 bits) - 0x05, 0x01, // Usage PAGE (Generic Desktop) - 0x09, 0x30, // Usage (X) - 0x09, 0x31, // Usage (Y) - 0x16, 0x01, 0x80, // Logical Minimum (-32 767) - 0x26, 0xFF, 0x7F, // Logical Maximum (32 767) - 0x75, 0x10, // Report Size (16) - 0x95, 0x02, // Report Count (2) - 0x81, 0x06, // Input (Data,Var,Rel) - - /* - // Vertical Wheel - // - Multiplier (2 bits) - 0xa1, 0x02, // Collection (Logical) - 0x09, 0x48, // Usage (Resolution Multiplier) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x35, 0x01, // Physical Minimum (1) - 0x45, 0x04, // Physical Maximum (4) - 0x75, 0x02, // Report Size (2) - 0x95, 0x01, // Report Count (1) - 0xa4, // Push - 0xb1, 0x02, // Feature (Data,Var,Abs) - // - Device (8 bits) - 0x09, 0x38, // Usage (Wheel) - 0x15, 0x81, // Logical Minimum (-127) - 0x25, 0x7f, // Logical Maximum (127) - 0x35, 0x00, // Physical Minimum (0) - reset physical - 0x45, 0x00, // Physical Maximum (0) - 0x75, 0x08, // Report Size (8) - 0x81, 0x06, // Input (Data,Var,Rel) - 0xc0, // End Collection - Vertical Wheel - - // Horizontal Wheel - // - Multiplier (2 bits) - 0xa1, 0x02, // Collection (Logical) - 0x09, 0x48, // Usage (Resolution Multiplier) - 0xb4, // Pop - 0xb1, 0x02, // Feature (Data,Var,Abs) - // - Padding (4 bits) - 0x35, 0x00, // Physical Minimum (0) - reset physical - 0x45, 0x00, // Physical Maximum (0) - 0x75, 0x04, // Report Size (4) - 0xb1, 0x03, // Feature (Cnst,Var,Abs) - // - Device (8 bits) - 0x05, 0x0c, // Usage Page (Consumer Devices) - 0x0a, 0x38, 0x02, // Usage (AC Pan) - 0x15, 0x81, // Logical Minimum (-127) - 0x25, 0x7f, // Logical Maximum (127) - 0x75, 0x08, // Report Size (8) - 0x81, 0x06, // Input (Data,Var,Rel) - 0xc0, // End Collection - Horizontal Wheel - - */ - 0xc0, // End Collection - Buttons - 0xc0, // End Collection - Mouse Logical - 0xc0 // End Collection - Mouse Application -}; - -// Joystick Protocol, HID 1.11 spec, Apendix D, page 64-65 -static uint8_t joystick_report_desc[] = { - 0x05, 0x01, // Usage Page (Generic Desktop) - 0x09, 0x04, // Usage (Joystick) - 0xA1, 0x01, // Collection (Application) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x20, // Report Count (32) - 0x05, 0x09, // Usage Page (Button) - 0x19, 0x01, // Usage Minimum (Button #1) - 0x29, 0x20, // Usage Maximum (Button #32) - 0x81, 0x02, // Input (variable,absolute) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x07, // Logical Maximum (7) - 0x35, 0x00, // Physical Minimum (0) - 0x46, 0x3B, 0x01, // Physical Maximum (315) - 0x75, 0x04, // Report Size (4) - 0x95, 0x01, // Report Count (1) - 0x65, 0x14, // Unit (20) - 0x05, 0x01, // Usage Page (Generic Desktop) - 0x09, 0x39, // Usage (Hat switch) - 0x81, 0x42, // Input (variable,absolute,null_state) - 0x05, 0x01, // Usage Page (Generic Desktop) - 0x09, 0x01, // Usage (Pointer) - 0xA1, 0x00, // Collection () - 0x15, 0x00, // Logical Minimum (0) - 0x26, 0xFF, 0x03, // Logical Maximum (1023) - 0x75, 0x0A, // Report Size (10) - 0x95, 0x04, // Report Count (4) - 0x09, 0x30, // Usage (X) - 0x09, 0x31, // Usage (Y) - 0x09, 0x32, // Usage (Z) - 0x09, 0x35, // Usage (Rz) - 0x81, 0x02, // Input (variable,absolute) - 0xC0, // End Collection - 0x15, 0x00, // Logical Minimum (0) - 0x26, 0xFF, 0x03, // Logical Maximum (1023) - 0x75, 0x0A, // Report Size (10) - 0x95, 0x02, // Report Count (2) - 0x09, 0x36, // Usage (Slider) - 0x09, 0x36, // Usage (Slider) - 0x81, 0x02, // Input (variable,absolute) - 0xC0 // End Collection + 0x05, 0x01, // Usage Page (Generic Desktop) + 0x09, 0x02, // Usage (Mouse) + 0xA1, 0x01, // Collection (Application) + 0x05, 0x09, // Usage Page (Button) + 0x19, 0x01, // Usage Minimum (Button #1) + 0x29, 0x03, // Usage Maximum (Button #3) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x95, 0x03, // Report Count (3) + 0x75, 0x01, // Report Size (1) + 0x81, 0x02, // Input (Data, Variable, Absolute) + 0x95, 0x01, // Report Count (1) + 0x75, 0x05, // Report Size (5) + 0x81, 0x03, // Input (Constant) + 0x05, 0x01, // Usage Page (Generic Desktop) + 0x09, 0x30, // Usage (X) + 0x09, 0x31, // Usage (Y) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x7F, // Logical Maximum (32767) + 0x75, 0x10, // Report Size (16), + 0x95, 0x02, // Report Count (2), + 0x81, 0x02, // Input (Data, Variable, Absolute) + 0x09, 0x38, // Usage (Wheel) + 0x15, 0x81, // Logical Minimum (-127) + 0x25, 0x7F, // Logical Maximum (127) + 0x75, 0x08, // Report Size (8), + 0x95, 0x01, // Report Count (1), + 0x81, 0x06, // Input (Data, Variable, Relative) + 0xC0 // End Collection }; +*/ @@ -448,7 +352,7 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { 1, // bConfigurationValue 0, // iConfiguration 0xA0, // bmAttributes - 250, // bMaxPower - Entry Index 8 + 250, // bMaxPower // --- Keyboard HID --- Boot Mode Keyboard Interface // - 9 bytes - @@ -461,13 +365,13 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { 0x03, // bInterfaceClass (0x03 = HID) 0x01, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot) 0x01, // bInterfaceProtocol (0x01 = Keyboard) - KEYBOARD_INTERFACE + 4, // iInterface + 0, // iInterface // - 9 bytes - // HID interface descriptor, HID 1.11 spec, section 6.2.1 9, // bLength 0x21, // bDescriptorType 0x11, 0x01, // bcdHID - KeyboardLocale_define, // bCountryCode + 0, // bCountryCode 1, // bNumDescriptors 0x22, // bDescriptorType LSB(sizeof(keyboard_report_desc)), // wDescriptorLength @@ -492,13 +396,13 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { 0x03, // bInterfaceClass (0x03 = HID) 0x00, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot) 0x01, // bInterfaceProtocol (0x01 = Keyboard) - NKRO_KEYBOARD_INTERFACE + 4, // iInterface + 0, // iInterface // - 9 bytes - // HID interface descriptor, HID 1.11 spec, section 6.2.1 9, // bLength 0x21, // bDescriptorType 0x11, 0x01, // bcdHID - KeyboardLocale_define, // bCountryCode + 0, // bCountryCode 1, // bNumDescriptors 0x22, // bDescriptorType LSB(sizeof(nkro_keyboard_report_desc)), // wDescriptorLength @@ -522,7 +426,7 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { 0x02, // bFunctionClass 0x02, // bFunctionSubClass 0x01, // bFunctionProtocol - CDC_STATUS_INTERFACE + 4, // iFunction + 0, // iFunction // --- Serial CDC --- CDC Data Interface // - 9 bytes - @@ -535,7 +439,7 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { 0x02, // bInterfaceClass 0x02, // bInterfaceSubClass 0x01, // bInterfaceProtocol - CDC_STATUS_INTERFACE + 4, // iInterface + 0, // iInterface // - 5 bytes - // CDC Header Functional Descriptor, CDC Spec 5.2.3.1, Table 26 5, // bFunctionLength @@ -580,7 +484,7 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { 0x0A, // bInterfaceClass 0x00, // bInterfaceSubClass 0x00, // bInterfaceProtocol - CDC_DATA_INTERFACE + 4, // iInterface + 0, // iInterface // - 7 bytes - // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 7, // bLength @@ -598,7 +502,8 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { CDC_TX_SIZE, 0, // wMaxPacketSize 0, // bInterval -// --- Mouse Interface --- +/* +// Mouse Interface // - 9 bytes - // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 9, // bLength @@ -608,8 +513,8 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { 1, // bNumEndpoints 0x03, // bInterfaceClass (0x03 = HID) 0x00, // bInterfaceSubClass (0x01 = Boot) - 0x02, // bInterfaceProtocol (0x02 = Mouse) - MOUSE_INTERFACE + 4, // iInterface + 0x00, // bInterfaceProtocol (0x02 = Mouse) + 0, // iInterface // - 9 bytes - // HID interface descriptor, HID 1.11 spec, section 6.2.1 9, // bLength @@ -628,72 +533,10 @@ static uint8_t config_descriptor[CONFIG_DESC_SIZE] = { 0x03, // bmAttributes (0x03=intr) MOUSE_SIZE, 0, // wMaxPacketSize MOUSE_INTERVAL, // bInterval - -// --- Joystick Interface --- -// - 9 bytes - - // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 - 9, // bLength - 4, // bDescriptorType - JOYSTICK_INTERFACE, // bInterfaceNumber - 0, // bAlternateSetting - 1, // bNumEndpoints - 0x03, // bInterfaceClass (0x03 = HID) - 0x00, // bInterfaceSubClass - 0x00, // bInterfaceProtocol - JOYSTICK_INTERFACE + 4, // iInterface -// - 9 bytes - - // HID interface descriptor, HID 1.11 spec, section 6.2.1 - 9, // bLength - 0x21, // bDescriptorType - 0x11, 0x01, // bcdHID - 0, // bCountryCode - 1, // bNumDescriptors - 0x22, // bDescriptorType - LSB(sizeof(joystick_report_desc)), // wDescriptorLength - MSB(sizeof(joystick_report_desc)), -// - 7 bytes - - // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 - 7, // bLength - 5, // bDescriptorType - JOYSTICK_ENDPOINT | 0x80, // bEndpointAddress - 0x03, // bmAttributes (0x03=intr) - JOYSTICK_SIZE, 0, // wMaxPacketSize - JOYSTICK_INTERVAL, // bInterval - -// --- System/Consumer Control --- -// - 9 bytes - - // interface descriptor, USB spec 9.6.5, page 267-269, Table 9-12 - 9, // bLength - 4, // bDescriptorType - SYS_CTRL_INTERFACE, // bInterfaceNumber - 0, // bAlternateSetting - 1, // bNumEndpoints - 0x03, // bInterfaceClass (0x03 = HID) - 0x01, // bInterfaceSubClass (0x00 = Non-Boot, 0x01 = Boot) - 0x00, // bInterfaceProtocol (0x00 = None) - SYS_CTRL_INTERFACE + 4, // iInterface -// - 9 bytes - - // HID interface descriptor, HID 1.11 spec, section 6.2.1 - 9, // bLength - 0x21, // bDescriptorType - 0x11, 0x01, // bcdHID - KeyboardLocale_define, // bCountryCode - 1, // bNumDescriptors - 0x22, // bDescriptorType - LSB(sizeof(sys_ctrl_report_desc)), // wDescriptorLength - MSB(sizeof(sys_ctrl_report_desc)), -// - 7 bytes - - // endpoint descriptor, USB spec 9.6.6, page 269-271, Table 9-13 - 7, // bLength - 5, // bDescriptorType - SYS_CTRL_ENDPOINT | 0x80, // bEndpointAddress - 0x03, // bmAttributes (0x03=intr) - SYS_CTRL_SIZE, 0, // wMaxPacketSize - SYS_CTRL_INTERVAL, // bInterval +#endif // MOUSE_INTERFACE +*/ }; -uint8_t *usb_bMaxPower = &config_descriptor[8]; - // ----- String Descriptors ----- @@ -721,23 +564,21 @@ struct usb_string_descriptor_struct string0 = { {0x0409} }; -#define usb_string_descriptor(name, str) \ - struct usb_string_descriptor_struct name = { \ - sizeof(str), \ - 3, \ - {str} \ - } - -usb_string_descriptor( usb_string_manufacturer_name_default, STR_MANUFACTURER ); -usb_string_descriptor( usb_string_product_name_default, STR_PRODUCT ); -usb_string_descriptor( usb_string_serial_number_default, STR_SERIAL ); -usb_string_descriptor( usb_string_keyboard_name, KEYBOARD_NAME ); -usb_string_descriptor( usb_string_nkro_keyboard_name, NKRO_KEYBOARD_NAME ); -usb_string_descriptor( usb_string_cdc_status_name, CDC_STATUS_NAME ); -usb_string_descriptor( usb_string_cdc_data_name, CDC_DATA_NAME ); -usb_string_descriptor( usb_string_mouse_name, MOUSE_NAME ); -usb_string_descriptor( usb_string_joystick_name, JOYSTICK_NAME ); -usb_string_descriptor( usb_string_sys_ctrl_name, SYS_CTRL_NAME ); +struct usb_string_descriptor_struct usb_string_manufacturer_name_default = { + sizeof(STR_MANUFACTURER), + 3, + {STR_MANUFACTURER} +}; +struct usb_string_descriptor_struct usb_string_product_name_default = { + sizeof(STR_PRODUCT), + 3, + {STR_PRODUCT} +}; +struct usb_string_descriptor_struct usb_string_serial_number_default = { + sizeof(STR_SERIAL), + 3, + {STR_SERIAL} +}; @@ -751,36 +592,18 @@ const usb_descriptor_list_t usb_descriptor_list[] = { {0x0200, 0x0000, config_descriptor, sizeof(config_descriptor)}, {0x0600, 0x0000, device_qualifier_descriptor, sizeof(device_qualifier_descriptor)}, {0x0A00, 0x0000, usb_debug_descriptor, sizeof(usb_debug_descriptor)}, - {0x2200, KEYBOARD_INTERFACE, keyboard_report_desc, sizeof(keyboard_report_desc)}, {0x2100, KEYBOARD_INTERFACE, config_descriptor + KEYBOARD_DESC_OFFSET, 9}, - {0x2200, NKRO_KEYBOARD_INTERFACE, nkro_keyboard_report_desc, sizeof(nkro_keyboard_report_desc)}, {0x2100, NKRO_KEYBOARD_INTERFACE, config_descriptor + NKRO_KEYBOARD_DESC_OFFSET, 9}, - +/* MOUSE {0x2200, MOUSE_INTERFACE, mouse_report_desc, sizeof(mouse_report_desc)}, - {0x2100, MOUSE_INTERFACE, config_descriptor + MOUSE_DESC_OFFSET, 9}, - - {0x2200, JOYSTICK_INTERFACE, joystick_report_desc, sizeof(joystick_report_desc)}, - {0x2100, JOYSTICK_INTERFACE, config_descriptor + JOYSTICK_DESC_OFFSET, 9}, - - {0x2200, SYS_CTRL_INTERFACE, sys_ctrl_report_desc, sizeof(sys_ctrl_report_desc)}, - {0x2100, SYS_CTRL_INTERFACE, config_descriptor + SYS_CTRL_DESC_OFFSET, 9}, - -#define iInterfaceString(num, var) \ - {0x0300 + 4 + num, 0x409, (const uint8_t *)&var, 0 } - + {0x2100, MOUSE_INTERFACE, config_descriptor+MOUSE_DESC_OFFSET, 9}, +*/ {0x0300, 0x0000, (const uint8_t *)&string0, 0}, {0x0301, 0x0409, (const uint8_t *)&usb_string_manufacturer_name, 0}, {0x0302, 0x0409, (const uint8_t *)&usb_string_product_name, 0}, {0x0303, 0x0409, (const uint8_t *)&usb_string_serial_number, 0}, - iInterfaceString( KEYBOARD_INTERFACE, usb_string_keyboard_name ), - iInterfaceString( NKRO_KEYBOARD_INTERFACE, usb_string_nkro_keyboard_name ), - iInterfaceString( CDC_STATUS_INTERFACE, usb_string_cdc_status_name ), - iInterfaceString( CDC_DATA_INTERFACE, usb_string_cdc_data_name ), - iInterfaceString( MOUSE_INTERFACE, usb_string_mouse_name ), - iInterfaceString( JOYSTICK_INTERFACE, usb_string_joystick_name ), - iInterfaceString( SYS_CTRL_INTERFACE, usb_string_sys_ctrl_name ), {0, 0, NULL, 0} }; diff --git a/Output/pjrcUSB/arm/usb_desc.h b/Output/pjrcUSB/arm/usb_desc.h index 0e769a1..e3b6fb5 100644 --- a/Output/pjrcUSB/arm/usb_desc.h +++ b/Output/pjrcUSB/arm/usb_desc.h @@ -1,7 +1,7 @@ /* Teensyduino Core Library * http://www.pjrc.com/teensy/ * Copyright (c) 2013 PJRC.COM, LLC. - * Modified by Jacob Alexander (2013-2016) + * Modified by Jacob Alexander (2013-2015) * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -54,21 +54,19 @@ #define DEVICE_SUBCLASS 0x00 #define DEVICE_PROTOCOL 0x00 #define EP0_SIZE 64 -#define NUM_ENDPOINTS 8 +#define NUM_ENDPOINTS 5 #define NUM_USB_BUFFERS 30 -#define NUM_INTERFACE 7 +#define NUM_INTERFACE 4 #define KEYBOARD_INTERFACE 0 // Keyboard #define KEYBOARD_ENDPOINT 1 #define KEYBOARD_SIZE 8 #define KEYBOARD_INTERVAL 1 -#define KEYBOARD_NAME L"Boot Keyboard" #define NKRO_KEYBOARD_INTERFACE 1 // NKRO Keyboard #define NKRO_KEYBOARD_ENDPOINT 2 #define NKRO_KEYBOARD_SIZE 64 #define NKRO_KEYBOARD_INTERVAL 1 -#define NKRO_KEYBOARD_NAME L"NKRO Keyboard" #define CDC_IAD_DESCRIPTOR 1 #define CDC_STATUS_INTERFACE 2 @@ -79,34 +77,25 @@ #define CDC_ACM_SIZE 16 #define CDC_RX_SIZE 64 #define CDC_TX_SIZE 64 -#define CDC_STATUS_NAME L"Virtual Serial Port - Status" -#define CDC_DATA_NAME L"Virtual Serial Port - Data" #define MOUSE_INTERFACE 4 // Mouse #define MOUSE_ENDPOINT 6 #define MOUSE_SIZE 8 -#define MOUSE_INTERVAL 1 -#define MOUSE_NAME L"Mouse" +#define MOUSE_INTERVAL 2 #define JOYSTICK_INTERFACE 5 // Joystick #define JOYSTICK_ENDPOINT 7 #define JOYSTICK_SIZE 16 #define JOYSTICK_INTERVAL 1 -#define JOYSTICK_NAME L"Joystick" - -#define SYS_CTRL_INTERFACE 6 // Media Keys -#define SYS_CTRL_ENDPOINT 8 -#define SYS_CTRL_SIZE 8 -#define SYS_CTRL_INTERVAL 1 -#define SYS_CTRL_NAME L"Media Keys" #define KEYBOARD_DESC_OFFSET (9 + 9) #define NKRO_KEYBOARD_DESC_OFFSET (9 + 9+9+7 + 9) #define SERIAL_CDC_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 8) +#define CONFIG_DESC_SIZE (9 + 9+9+7 + 9+9+7 + 8+9+5+5+4+5+7+9+7+7) + +// XXX Unused #define MOUSE_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 8+9+5+5+4+5+7+9+7+7 + 9) #define JOYSTICK_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 8+9+5+5+4+5+7+9+7+7 + 9+9+7 + 9) -#define SYS_CTRL_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 8+9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9) -#define CONFIG_DESC_SIZE (9 + 9+9+7 + 9+9+7 + 8+9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9+9+7) #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY @@ -115,7 +104,6 @@ #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY #define ENDPOINT7_CONFIG ENDPOINT_TRANSIMIT_ONLY -#define ENDPOINT8_CONFIG ENDPOINT_TRANSIMIT_ONLY @@ -137,5 +125,3 @@ extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS]; extern const usb_descriptor_list_t usb_descriptor_list[]; -extern uint8_t *usb_bMaxPower; - diff --git a/Output/pjrcUSB/arm/usb_dev.c b/Output/pjrcUSB/arm/usb_dev.c index c0e4566..1f2e725 100644 --- a/Output/pjrcUSB/arm/usb_dev.c +++ b/Output/pjrcUSB/arm/usb_dev.c @@ -1,7 +1,7 @@ /* Teensyduino Core Library * http://www.pjrc.com/teensy/ * Copyright (c) 2013 PJRC.COM, LLC. - * Modifications by Jacob Alexander (2013-2016) + * Modifications by Jacob Alexander (2013-2015) * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -34,7 +34,6 @@ // Project Includes #include #include -#include // Local Includes #include "usb_dev.h" @@ -168,18 +167,12 @@ volatile uint8_t usb_reboot_timer = 0; static uint8_t reply_buffer[8]; -static uint8_t power_neg_delay; -static uint32_t power_neg_time; - // ----- Functions ----- static void endpoint0_stall() { - #ifdef UART_DEBUG_UNKNOWN - print("STALL" NL ); - #endif USB0_ENDPT0 = USB_ENDPT_EPSTALL | USB_ENDPT_EPRXEN | USB_ENDPT_EPTXEN | USB_ENDPT_EPHSHK; } @@ -191,34 +184,6 @@ static void endpoint0_transmit( const void *data, uint32_t len ) ep0_tx_bdt_bank ^= 1; } -// Used to check any USB state changes that may not have a proper interrupt -// Called once per scan loop, should take minimal processing time or it may affect other modules -void usb_device_check() -{ - // Check to see if we're still waiting for the next USB request after Get Configuration Descriptor - // If still waiting, restart the USB initialization with a lower power requirement - if ( power_neg_delay ) - { - // Check if 100 ms has elapsed - if ( systick_millis_count - power_neg_time > 100 ) - { - // Update bMaxPower - // The value set is in increments of 2 mA - // So 50 * 2 mA = 100 mA - // XXX Currently only transitions to 100 mA - // It may be possible to transition down again to 20 mA - *usb_bMaxPower = 50; - - // Re-initialize USB - power_neg_delay = 0; - usb_configuration = 0; // Clear USB configuration if we have one - USB0_CONTROL = 0; // Disable D+ Pullup to simulate disconnect - delay(10); // Delay is necessary to simulate disconnect - usb_init(); - } - } -} - static void usb_setup() { const uint8_t *data = NULL; @@ -230,18 +195,10 @@ static void usb_setup() const uint8_t *cfg; int i; - // If another request is made, disable the power negotiation check - // See GET_DESCRIPTOR - Configuration - if ( power_neg_delay ) - { - power_neg_delay = 0; - } - switch ( setup.wRequestAndType ) { case 0x0500: // SET_ADDRESS - goto send; - + break; case 0x0900: // SET_CONFIGURATION #ifdef UART_DEBUG print("CONFIGURE - "); @@ -250,10 +207,6 @@ static void usb_setup() Output_Available = usb_configuration; reg = &USB0_ENDPT1; cfg = usb_endpoint_config_table; - - // Now configured so we can utilize bMaxPower now - Output_update_usb_current( *usb_bMaxPower * 2 ); - // clear all BDT entries, free any allocated memory... for ( i = 4; i < ( NUM_ENDPOINTS + 1) * 4; i++ ) { @@ -335,21 +288,18 @@ static void usb_setup() table[ index( i, TX, EVEN ) ].desc = 0; table[ index( i, TX, ODD ) ].desc = 0; } - goto send; - + break; case 0x0880: // GET_CONFIGURATION reply_buffer[0] = usb_configuration; datalen = 1; data = reply_buffer; - goto send; - + break; case 0x0080: // GET_STATUS (device) reply_buffer[0] = 0; reply_buffer[1] = 0; datalen = 2; data = reply_buffer; - goto send; - + break; case 0x0082: // GET_STATUS (endpoint) if ( setup.wIndex > NUM_ENDPOINTS ) { @@ -363,72 +313,32 @@ static void usb_setup() reply_buffer[0] = 1; data = reply_buffer; datalen = 2; - goto send; - + break; case 0x0100: // CLEAR_FEATURE (device) - switch ( setup.wValue ) - { - // CLEAR_FEATURE(DEVICE_REMOTE_WAKEUP) - // See SET_FEATURE(DEVICE_REMOTE_WAKEUP) for details - case 0x1: - goto send; - } - - warn_msg("SET_FEATURE - Device wValue("); - printHex( setup.wValue ); - print( ")" NL ); - endpoint0_stall(); - return; - case 0x0101: // CLEAR_FEATURE (interface) // TODO: Currently ignoring, perhaps useful? -HaaTa - warn_msg("CLEAR_FEATURE - Interface wValue("); - printHex( setup.wValue ); - print(") wIndex("); - printHex( setup.wIndex ); - print( ")" NL ); endpoint0_stall(); return; - - case 0x0102: // CLEAR_FEATURE (endpoint) + case 0x0102: // CLEAR_FEATURE (interface) i = setup.wIndex & 0x7F; if ( i > NUM_ENDPOINTS || setup.wValue != 0 ) { endpoint0_stall(); return; } - (*(uint8_t *)(&USB0_ENDPT0 + setup.wIndex * 4)) &= ~0x02; + //(*(uint8_t *)(&USB0_ENDPT0 + setup.wIndex * 4)) &= ~0x02; // TODO: do we need to clear the data toggle here? - goto send; + //break; - case 0x0300: // SET_FEATURE (device) - switch ( setup.wValue ) - { - // SET_FEATURE(DEVICE_REMOTE_WAKEUP) - // XXX: Only used to confirm Remote Wake - // Used on Mac OSX and Windows not on Linux - // Good post on the behaviour: - // http://community.silabs.com/t5/8-bit-MCU/Remote-wakeup-HID/m-p/74957#M30802 - case 0x1: - goto send; - } - - warn_msg("SET_FEATURE - Device wValue("); - printHex( setup.wValue ); - print( ")" NL ); + // FIXME: Clearing causes keyboard to freeze, likely an invalid clear + // XXX: Ignoring seems to work, though this may not be the ideal behaviour -HaaTa endpoint0_stall(); return; - + case 0x0300: // SET_FEATURE (device) case 0x0301: // SET_FEATURE (interface) // TODO: Currently ignoring, perhaps useful? -HaaTa - warn_msg("SET_FEATURE - Interface wValue("); - printHex( setup.wValue ); - print(") wIndex("); - printHex( setup.wIndex ); - print( ")" NL ); endpoint0_stall(); return; - case 0x0302: // SET_FEATURE (endpoint) i = setup.wIndex & 0x7F; if ( i > NUM_ENDPOINTS || setup.wValue != 0 ) @@ -439,8 +349,7 @@ static void usb_setup() } (*(uint8_t *)(&USB0_ENDPT0 + setup.wIndex * 4)) |= 0x02; // TODO: do we need to clear the data toggle here? - goto send; - + break; case 0x0680: // GET_DESCRIPTOR case 0x0681: #ifdef UART_DEBUG @@ -466,27 +375,6 @@ static void usb_setup() { datalen = list->length; } - - // XXX Power negotiation hack -HaaTa - // Some devices such as the Apple Ipad do not support bMaxPower greater than 100 mA - // However, there is no provision in the basic USB 2.0 stack for power negotiation - // To get around this: - // * Attempt to set bMaxPower to 500 mA first - // * If more than 100 ms passes since retrieving a Get Configuration Descriptor - // (Descriptor with bMaxPower in it) - // * Change usb_bMaxPower to 50 (100 mA) - // * Restart the USB init process - // According to notes online, it says that some Apple devices can only do 20 mA - // However, in my testing this hasn't been the case - // (you can also draw as much current as you want if you just lie in the descriptor :P) - // If this becomes an issue we can use this hack a second time to negotiate down to 20 mA - // (which should be fine for just the mcu) - if ( setup.wValue == 0x0200 && setup.wIndex == 0x0 ) - { - power_neg_delay = 1; - power_neg_time = systick_millis_count; - } - #if UART_DEBUG print("Desc found, "); printHex32( (uint32_t)data ); @@ -513,7 +401,8 @@ static void usb_setup() case 0x2221: // CDC_SET_CONTROL_LINE_STATE usb_cdc_line_rtsdtr = setup.wValue; //serial_print("set control line state\n"); - goto send; + endpoint0_stall(); + return; case 0x21A1: // CDC_GET_LINE_CODING data = (uint8_t*)usb_cdc_line_coding; @@ -523,50 +412,30 @@ static void usb_setup() case 0x2021: // CDC_SET_LINE_CODING // XXX Needed? //serial_print("set coding, waiting...\n"); - return; + endpoint0_stall(); + return; // Cannot stall here (causes issues) case 0x0921: // HID SET_REPORT - // Interface - switch ( setup.wIndex & 0xFF ) - { - // Keyboard Interface - case KEYBOARD_INTERFACE: - break; - // NKRO Keyboard Interface - case NKRO_KEYBOARD_INTERFACE: - break; - default: - warn_msg("Unknown interface - "); - printHex( setup.wIndex ); - print( NL ); - endpoint0_stall(); - break; - } - + #ifdef UART_DEBUG + print("SET_REPORT - "); + printHex( setup.wValue ); + print(" - "); + printHex( setup.wValue & 0xFF ); + print( NL ); + #endif + USBKeys_LEDs = setup.wValue & 0xFF; + endpoint0_stall(); return; case 0x01A1: // HID GET_REPORT #ifdef UART_DEBUG print("GET_REPORT - "); - printHex( setup.wIndex ); + printHex( USBKeys_LEDs ); print(NL); #endif - // Search through descriptors returning necessary info - for ( list = usb_descriptor_list; 1; list++ ) - { - if ( list->addr == NULL ) - break; - if ( list->wValue != 0x2200 ) - continue; - if ( setup.wIndex == list->wIndex ) - { - data = list->addr; - datalen = list->length; - goto send; - } - } - endpoint0_stall(); - return; + data = (uint8_t*)&USBKeys_LEDs; + datalen = 1; + goto send; case 0x0A21: // HID SET_IDLE #ifdef UART_DEBUG @@ -576,7 +445,8 @@ static void usb_setup() #endif USBKeys_Idle_Config = (setup.wValue >> 8); USBKeys_Idle_Count = 0; - goto send; + endpoint0_stall(); + return; case 0x0B21: // HID SET_PROTOCOL #ifdef UART_DEBUG @@ -587,7 +457,8 @@ static void usb_setup() print(NL); #endif USBKeys_Protocol = setup.wValue & 0xFF; // 0 - Boot Mode, 1 - NKRO Mode - goto send; + endpoint0_stall(); + return; // case 0xC940: default: @@ -601,16 +472,10 @@ static void usb_setup() send: #ifdef UART_DEBUG print("setup send "); - printHex32( (uint32_t)data ); + printHex32((uint32_t)data); print(","); - for ( uint8_t c = 0; c < datalen; c++ ) - { - printHex( data[c] ); - print(" "); - } - print(","); - printHex( datalen ); - print( NL ); + printHex(datalen); + print(NL); #endif if ( datalen > setup.wLength ) @@ -720,10 +585,6 @@ static void usb_control( uint32_t stat ) printHex(setup.wIndex); print(", len:"); printHex(setup.wLength); - print(" -- "); - printHex32(setup.word1); - print(" "); - printHex32(setup.word2); print(NL); #endif // actually "do" the setup request @@ -731,25 +592,11 @@ static void usb_control( uint32_t stat ) // unfreeze the USB, now that we're ready USB0_CTL = USB_CTL_USBENSOFEN; // clear TXSUSPENDTOKENBUSY bit break; - case 0x01: // OUT transaction received from host case 0x02: - #ifdef UART_DEBUG_UNKNOWN - print("PID=OUT wRequestAndType:"); - printHex(setup.wRequestAndType); - print(", wValue:"); - printHex(setup.wValue); - print(", wIndex:"); - printHex(setup.wIndex); - print(", len:"); - printHex(setup.wLength); - print(" -- "); - printHex32(setup.word1); - print(" "); - printHex32(setup.word2); - print(NL); + #ifdef UART_DEBUG + print("PID=OUT"NL); #endif - // CDC Interface if ( setup.wRequestAndType == 0x2021 /*CDC_SET_LINE_CODING*/ ) { @@ -768,38 +615,17 @@ static void usb_control( uint32_t stat ) endpoint0_transmit( NULL, 0 ); } - // Keyboard SET_REPORT - if ( setup.wRequestAndType == 0x921 && setup.wValue & 0x200 ) + // Keyboard Interface + if ( setup.word1 == 0x02000921 && setup.word2 == ( (1<<16) | KEYBOARD_INTERFACE ) ) { - // Interface - switch ( setup.wIndex & 0xFF ) - { - // Keyboard Interface - case KEYBOARD_INTERFACE: - USBKeys_LEDs = buf[0]; - endpoint0_transmit( NULL, 0 ); - break; - // NKRO Keyboard Interface - case NKRO_KEYBOARD_INTERFACE: - // Only use 2nd byte, first byte is the report id - USBKeys_LEDs = buf[1]; - endpoint0_transmit( NULL, 0 ); - break; - default: - warn_msg("Unknown interface - "); - printHex( setup.wIndex ); - print( NL ); - break; - } - - #ifdef UART_DEBUG - for ( size_t len = 0; len < setup.wLength; len++ ) - { - printHex( buf[ len ] ); - print(" "); - } - print( NL ); - #endif + USBKeys_LEDs = buf[0]; + endpoint0_transmit( NULL, 0 ); + } + // NKRO Keyboard Interface + if ( setup.word1 == 0x02000921 && setup.word2 == ( (1<<16) | NKRO_KEYBOARD_INTERFACE ) ) + { + USBKeys_LEDs = buf[0]; + endpoint0_transmit( NULL, 0 ); } // give the buffer back @@ -837,7 +663,6 @@ static void usb_control( uint32_t stat ) } break; - default: #ifdef UART_DEBUG print("PID=unknown:"); @@ -964,11 +789,6 @@ void usb_rx_memory( usb_packet_t *packet ) void usb_tx( uint32_t endpoint, usb_packet_t *packet ) { - // Since we are transmitting data, USB will be brought out of sleep/suspend - // if it's in that state - // Use the currently set descriptor value - Output_update_usb_current( *usb_bMaxPower * 2 ); - bdt_t *b = &table[ index( endpoint, TX, EVEN ) ]; uint8_t next; @@ -1019,8 +839,31 @@ void usb_tx( uint32_t endpoint, usb_packet_t *packet ) void usb_device_reload() { // MCHCK +#if defined(_mk20dx128vlf5_) + + // MCHCK Kiibohd Variant + // Check to see if PTA3 (has a pull-up) is connected to GND (usually via jumper) + // Only allow reload if the jumper is present (security) + GPIOA_PDDR &= ~(1<<3); // Input + PORTA_PCR3 = PORT_PCR_PFE | PORT_PCR_MUX(1); // Internal pull-up + + // Check for jumper + if ( GPIOA_PDIR & (1<<3) ) + { + print( NL ); + warn_print("Security jumper not present, cancelling firmware reload..."); + info_msg("Replace jumper on middle 2 pins, or manually press the firmware reload button."); + } + else + { + // Copies variable into the VBAT register, must be identical to the variable in the bootloader to jump to the bootloader flash mode + for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ ) + (&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ]; + SOFTWARE_RESET(); + } + // Kiibohd mk20dx256vlh7 -#if defined(_mk20dx128vlf5_) || defined(_mk20dx256vlh7_) +#elif defined(_mk20dx256vlh7_) // Copies variable into the VBAT register, must be identical to the variable in the bootloader to jump to the bootloader flash mode for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ ) (&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ]; @@ -1145,8 +988,8 @@ restart: break; default: tx_state[ endpoint ] = ((uint32_t)b & 8) - ? TX_STATE_ODD_FREE - : TX_STATE_EVEN_FREE; + ? TX_STATE_ODD_FREE + : TX_STATE_EVEN_FREE; break; } } @@ -1268,12 +1111,9 @@ restart: USB0_ISTAT = USB_ISTAT_ERROR; } - // USB Host signalling device to enter 'sleep' state - // The USB Module triggers this interrupt when it detects the bus has been idle for 3 ms if ( (status & USB_ISTAT_SLEEP /* 10 */ ) ) { - info_print("Host has requested USB sleep/suspend state"); - Output_update_usb_current( 100 ); // Set to 100 mA + //serial_print("sleep\n"); USB0_ISTAT = USB_ISTAT_SLEEP; } } @@ -1330,9 +1170,6 @@ uint8_t usb_init() // enable d+ pullup USB0_CONTROL = USB_CONTROL_DPPULLUPNONOTG; - // Do not check for power negotiation delay until Get Configuration Descriptor - power_neg_delay = 0; - return 1; } diff --git a/Output/pjrcUSB/arm/usb_dev.h b/Output/pjrcUSB/arm/usb_dev.h index 827f843..0f445de 100644 --- a/Output/pjrcUSB/arm/usb_dev.h +++ b/Output/pjrcUSB/arm/usb_dev.h @@ -81,7 +81,6 @@ static inline uint32_t usb_rx_byte_count(uint32_t endpoint) } void usb_device_reload(); -void usb_device_check(); extern void usb_serial_flush_callback(); diff --git a/Output/pjrcUSB/arm/usb_joystick.c b/Output/pjrcUSB/arm/usb_joystick.c deleted file mode 100644 index 2b5ea79..0000000 --- a/Output/pjrcUSB/arm/usb_joystick.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Teensyduino Core Library - * http://www.pjrc.com/teensy/ - * Copyright (c) 2013 PJRC.COM, LLC. - * Modified by Jacob Alexander (2015) - * - * 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: - * - * 1. The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * 2. If the Software is incorporated into a build system that allows - * selection among a list of target devices, then similar target - * devices manufactured by PJRC.COM must be included in the list of - * target devices and selectable in the same manner. - * - * 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 // for memcpy() - -// Project Includes -#include -#include - -// Local Includes -#include "usb_dev.h" -#include "usb_joystick.h" - - - -// ----- Defines ----- - -// Maximum number of transmit packets to queue so we don't starve other endpoints for memory -#define TX_PACKET_LIMIT 3 - -// When the PC isn't listening, how long do we wait before discarding data? -#define TX_TIMEOUT_MSEC 30 - -#if F_CPU == 168000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1100) -#elif F_CPU == 144000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 932) -#elif F_CPU == 120000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 764) -#elif F_CPU == 96000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596) -#elif F_CPU == 72000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 512) -#elif F_CPU == 48000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428) -#elif F_CPU == 24000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 262) -#endif - - - -// ----- Variables ----- - -uint32_t usb_joystick_data[3]; - - -static uint8_t transmit_previous_timeout = 0; - - - -// ----- Functions ----- - -int usb_joystick_send() -{ - uint32_t wait_count=0; - usb_packet_t *tx_packet; - - //serial_print("send"); - //serial_print("\n"); - while (1) { - if (!usb_configuration) { - //serial_print("error1\n"); - return -1; - } - if (usb_tx_packet_count(JOYSTICK_ENDPOINT) < TX_PACKET_LIMIT) { - tx_packet = usb_malloc(); - if (tx_packet) break; - } - if (++wait_count > TX_TIMEOUT || transmit_previous_timeout) { - transmit_previous_timeout = 1; - //serial_print("error2\n"); - return -1; - } - yield(); - } - transmit_previous_timeout = 0; - memcpy(tx_packet->buf, usb_joystick_data, 12); - tx_packet->len = 12; - usb_tx(JOYSTICK_ENDPOINT, tx_packet); - //serial_print("ok\n"); - return 0; -} - diff --git a/Output/pjrcUSB/arm/usb_joystick.h b/Output/pjrcUSB/arm/usb_joystick.h deleted file mode 100644 index a0b5c23..0000000 --- a/Output/pjrcUSB/arm/usb_joystick.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Teensyduino Core Library - * http://www.pjrc.com/teensy/ - * Copyright (c) 2013 PJRC.COM, LLC. - * Modified by Jacob Alexander (2015) - * - * 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: - * - * 1. The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * 2. If the Software is incorporated into a build system that allows - * selection among a list of target devices, then similar target - * devices manufactured by PJRC.COM must be included in the list of - * target devices and selectable in the same manner. - * - * 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 - -// Local Includes -#include - - - -// ----- Functions ----- - -int usb_joystick_send(); -extern uint32_t usb_joystick_data[3]; // TODO - Move, more generic - diff --git a/Output/pjrcUSB/arm/usb_keyboard.c b/Output/pjrcUSB/arm/usb_keyboard.c index d362bb3..d3c9632 100644 --- a/Output/pjrcUSB/arm/usb_keyboard.c +++ b/Output/pjrcUSB/arm/usb_keyboard.c @@ -52,16 +52,10 @@ // When the PC isn't listening, how long do we wait before discarding data? #define TX_TIMEOUT_MSEC 50 -#if F_CPU == 168000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1100) -#elif F_CPU == 144000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 932) -#elif F_CPU == 120000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 764) -#elif F_CPU == 96000000 +#if F_CPU == 96000000 #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596) #elif F_CPU == 72000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 512) + #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 512) // XXX Correct? #elif F_CPU == 48000000 #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428) #elif F_CPU == 24000000 @@ -95,7 +89,7 @@ void usb_keyboard_send() if ( USBKeys_Protocol == 0 ) // Boot Mode { - if ( usb_tx_packet_count( KEYBOARD_ENDPOINT ) < TX_PACKET_LIMIT ) + if ( usb_tx_packet_count( NKRO_KEYBOARD_ENDPOINT ) < TX_PACKET_LIMIT ) { tx_packet = usb_malloc(); if ( tx_packet ) @@ -104,18 +98,7 @@ void usb_keyboard_send() } else if ( USBKeys_Protocol == 1 ) // NKRO Mode { - if ( usb_tx_packet_count( NKRO_KEYBOARD_ENDPOINT ) < TX_PACKET_LIMIT ) - { - tx_packet = usb_malloc(); - if ( tx_packet ) - break; - } - } - else if ( USBKeys_Changed & - ( USBKeyChangeState_System | USBKeyChangeState_Consumer ) - ) - { - if ( usb_tx_packet_count( SYS_CTRL_ENDPOINT ) < TX_PACKET_LIMIT ) + if ( usb_tx_packet_count( KEYBOARD_ENDPOINT ) < TX_PACKET_LIMIT ) { tx_packet = usb_malloc(); if ( tx_packet ) @@ -135,47 +118,6 @@ void usb_keyboard_send() // Pointer to USB tx packet buffer uint8_t *tx_buf = tx_packet->buf; - // Check system control keys - if ( USBKeys_Changed & USBKeyChangeState_System ) - { - if ( Output_DebugMode ) - { - print("SysCtrl["); - printHex_op( USBKeys_SysCtrl, 2 ); - print( "] " NL ); - } - - *tx_buf++ = 0x02; // ID - *tx_buf = USBKeys_SysCtrl; - tx_packet->len = 2; - - // Send USB Packet - usb_tx( SYS_CTRL_ENDPOINT, tx_packet ); - USBKeys_Changed &= ~USBKeyChangeState_System; // Mark sent - return; - } - - // Check consumer control keys - if ( USBKeys_Changed & USBKeyChangeState_Consumer ) - { - if ( Output_DebugMode ) - { - print("ConsCtrl["); - printHex_op( USBKeys_ConsCtrl, 2 ); - print( "] " NL ); - } - - *tx_buf++ = 0x03; // ID - *tx_buf++ = (uint8_t)(USBKeys_ConsCtrl & 0x00FF); - *tx_buf = (uint8_t)(USBKeys_ConsCtrl >> 8); - tx_packet->len = 3; - - // Send USB Packet - usb_tx( SYS_CTRL_ENDPOINT, tx_packet ); - USBKeys_Changed &= ~USBKeyChangeState_Consumer; // Mark sent - return; - } - switch ( USBKeys_Protocol ) { // Send boot keyboard interrupt packet(s) @@ -215,6 +157,45 @@ void usb_keyboard_send() dbug_msg("NKRO USB: "); } + // Check system control keys + if ( USBKeys_Changed & USBKeyChangeState_System ) + { + if ( Output_DebugMode ) + { + print("SysCtrl["); + printHex_op( USBKeys_SysCtrl, 2 ); + print( "] " NL ); + } + + *tx_buf++ = 0x02; // ID + *tx_buf = USBKeys_SysCtrl; + tx_packet->len = 2; + + // Send USB Packet + usb_tx( NKRO_KEYBOARD_ENDPOINT, tx_packet ); + USBKeys_Changed &= ~USBKeyChangeState_System; // Mark sent + } + + // Check consumer control keys + if ( USBKeys_Changed & USBKeyChangeState_Consumer ) + { + if ( Output_DebugMode ) + { + print("ConsCtrl["); + printHex_op( USBKeys_ConsCtrl, 2 ); + print( "] " NL ); + } + + *tx_buf++ = 0x03; // ID + *tx_buf++ = (uint8_t)(USBKeys_ConsCtrl & 0x00FF); + *tx_buf = (uint8_t)(USBKeys_ConsCtrl >> 8); + tx_packet->len = 3; + + // Send USB Packet + usb_tx( NKRO_KEYBOARD_ENDPOINT, tx_packet ); + USBKeys_Changed &= ~USBKeyChangeState_Consumer; // Mark sent + } + // Standard HID Keyboard if ( USBKeys_Changed ) { diff --git a/Output/pjrcUSB/arm/usb_mouse.c b/Output/pjrcUSB/arm/usb_mouse.c deleted file mode 100644 index 5de7712..0000000 --- a/Output/pjrcUSB/arm/usb_mouse.c +++ /dev/null @@ -1,296 +0,0 @@ -/* Teensyduino Core Library - * http://www.pjrc.com/teensy/ - * Copyright (c) 2013 PJRC.COM, LLC. - * Modified by Jacob Alexander (2015-2016) - * - * 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: - * - * 1. The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * 2. If the Software is incorporated into a build system that allows - * selection among a list of target devices, then similar target - * devices manufactured by PJRC.COM must be included in the list of - * target devices and selectable in the same manner. - * - * 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 // for memcpy() - -// Project Includes -#include -#include - -// Local Includes -#include "usb_dev.h" -#include "usb_mouse.h" - - - -// ----- Defines ----- - -// Maximum number of transmit packets to queue so we don't starve other endpoints for memory -#define TX_PACKET_LIMIT 3 - -// When the PC isn't listening, how long do we wait before discarding data? -#define TX_TIMEOUT_MSEC 30 - -#if F_CPU == 168000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 1100) -#elif F_CPU == 144000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 932) -#elif F_CPU == 120000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 764) -#elif F_CPU == 96000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 596) -#elif F_CPU == 72000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 512) -#elif F_CPU == 48000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 428) -#elif F_CPU == 24000000 - #define TX_TIMEOUT (TX_TIMEOUT_MSEC * 262) -#endif - -//#define DEFAULT_XRES 640 -//#define DEFAULT_YRES 480 - -//#define DEFAULT_XRES 800 -//#define DEFAULT_YRES 600 - -//#define DEFAULT_XRES 1024 -//#define DEFAULT_YRES 768 - -//#define DEFAULT_XRES 1280 -//#define DEFAULT_YRES 720 - -//#define DEFAULT_XRES 1280 -//#define DEFAULT_YRES 800 - -#define DEFAULT_XRES 1366 -#define DEFAULT_YRES 768 - -//#define DEFAULT_XRES 1440 -//#define DEFAULT_YRES 900 - -//#define DEFAULT_XRES 1920 -//#define DEFAULT_YRES 1080 - -//#define DEFAULT_XRES 2560 -//#define DEFAULT_YRES 1440 - -//#define DEFAULT_XRES 2560 -//#define DEFAULT_YRES 1600 - -//#define DEFAULT_XRES 2880 -//#define DEFAULT_YRES 1800 - -//#define DEFAULT_XRES 3840 -//#define DEFAULT_YRES 2160 - -//#define DEFAULT_XRES 7680 -//#define DEFAULT_YRES 4320 - - -#define DEFAULT_XSCALE ((0x80000000ul+DEFAULT_XRES/2)/DEFAULT_XRES) -#define DEFAULT_YSCALE ((0x80000000ul+DEFAULT_YRES/2)/DEFAULT_YRES) - - - -// ----- Variables ----- - -static uint8_t transmit_previous_timeout = 0; - -// which buttons are currently pressed -uint8_t usb_mouse_buttons_state = 0; - -static uint16_t usb_mouse_resolution_x = DEFAULT_XRES; -static uint16_t usb_mouse_resolution_y = DEFAULT_YRES; -static uint16_t usb_mouse_position_x = DEFAULT_XRES / 2; -static uint16_t usb_mouse_position_y = DEFAULT_YRES / 2; -static uint32_t usb_mouse_scale_x = DEFAULT_XSCALE; -static uint32_t usb_mouse_scale_y = DEFAULT_YSCALE; -static uint32_t usb_mouse_offset_x = DEFAULT_XSCALE / 2 - 1; -static uint32_t usb_mouse_offset_y = DEFAULT_YSCALE / 2 - 1; - - - -// ----- Functions ----- - -// Process pending mouse commands -// XXX Missing mouse movement and wheels -// Proper support will require KLL generation of the USB descriptors -// Similar support will be required for joystick control -void usb_mouse_send() -{ - uint32_t wait_count = 0; - usb_packet_t *tx_packet; - - // Wait till ready - while ( 1 ) - { - if ( !usb_configuration ) - { - erro_print("USB not configured..."); - return; - } - - // Attempt to acquire a USB packet for the mouse endpoint - if ( usb_tx_packet_count( MOUSE_ENDPOINT ) < TX_PACKET_LIMIT ) - { - tx_packet = usb_malloc(); - if ( tx_packet ) - break; - } - - if ( ++wait_count > TX_TIMEOUT || transmit_previous_timeout ) - { - transmit_previous_timeout = 1; - warn_print("USB Transmit Timeout..."); - return; - } - yield(); - } - - transmit_previous_timeout = 0; - - // Prepare USB Mouse Packet - // TODO Dynamically generate this code based on KLL requirements - uint16_t *packet_data = (uint16_t*)(&tx_packet->buf[0]); - packet_data[0] = USBMouse_Buttons; - packet_data[1] = USBMouse_Relative_x; - packet_data[2] = USBMouse_Relative_y; - tx_packet->len = 6; - usb_tx( MOUSE_ENDPOINT, tx_packet ); - - // Clear status and state - USBMouse_Buttons = 0; - USBMouse_Relative_x = 0; - USBMouse_Relative_y = 0; - USBMouse_Changed = 0; -} - - -// Move the mouse. x, y and wheel are -127 to 127. Use 0 for no movement. -int usb_mouse_move(int8_t x, int8_t y, int8_t wheel) -{ - uint32_t wait_count=0; - usb_packet_t *tx_packet; - - //serial_print("move"); - //serial_print("\n"); - if (x == -128) x = -127; - if (y == -128) y = -127; - if (wheel == -128) wheel = -127; - - while (1) { - if (!usb_configuration) { - return -1; - } - if (usb_tx_packet_count(MOUSE_ENDPOINT) < TX_PACKET_LIMIT) { - tx_packet = usb_malloc(); - if (tx_packet) break; - } - if (++wait_count > TX_TIMEOUT || transmit_previous_timeout) { - transmit_previous_timeout = 1; - return -1; - } - yield(); - } - transmit_previous_timeout = 0; - *(tx_packet->buf + 0) = 1; - *(tx_packet->buf + 1) = usb_mouse_buttons_state; - *(tx_packet->buf + 2) = x; - *(tx_packet->buf + 3) = y; - *(tx_packet->buf + 4) = wheel; - tx_packet->len = 5; - usb_tx(MOUSE_ENDPOINT, tx_packet); - return 0; -} - -int usb_mouse_position(uint16_t x, uint16_t y) -{ - uint32_t wait_count=0, val32; - usb_packet_t *tx_packet; - - if (x >= usb_mouse_resolution_x) x = usb_mouse_resolution_x - 1; - usb_mouse_position_x = x; - if (y >= usb_mouse_resolution_y) y = usb_mouse_resolution_y - 1; - usb_mouse_position_y = y; - - while (1) { - if (!usb_configuration) { - return -1; - } - if (usb_tx_packet_count(MOUSE_ENDPOINT) < TX_PACKET_LIMIT) { - tx_packet = usb_malloc(); - if (tx_packet) break; - } - if (++wait_count > TX_TIMEOUT || transmit_previous_timeout) { - transmit_previous_timeout = 1; - return -1; - } - yield(); - } - transmit_previous_timeout = 0; - *(tx_packet->buf + 0) = 2; - val32 = usb_mouse_position_x * usb_mouse_scale_x + usb_mouse_offset_x; - //serial_print("position:"); - //serial_phex16(usb_mouse_position_x); - //serial_print("->"); - //serial_phex32(val32); - *(tx_packet->buf + 1) = val32 >> 16; - *(tx_packet->buf + 2) = val32 >> 24; - val32 = usb_mouse_position_y * usb_mouse_scale_y + usb_mouse_offset_y; - //serial_print(","); - //serial_phex16(usb_mouse_position_y); - //serial_print("->"); - //serial_phex32(val32); - //serial_print("\n"); - *(tx_packet->buf + 3) = val32 >> 16; - *(tx_packet->buf + 4) = val32 >> 24; - tx_packet->len = 5; - usb_tx(MOUSE_ENDPOINT, tx_packet); - return 0; -} - -void usb_mouse_screen_size(uint16_t width, uint16_t height, uint8_t mac) -{ - if (width < 128) width = 128; - else if (width > 7680) width = 7680; - if (height < 128) height = 128; - else if (height > 7680) height = 7680; - usb_mouse_resolution_x = width; - usb_mouse_resolution_y = height; - usb_mouse_position_x = width / 2; - usb_mouse_position_y = height / 2; - usb_mouse_scale_x = (0x80000000ul + (width >> 1)) / width; - usb_mouse_scale_y = (0x80000000ul + (height >> 1)) / height; - usb_mouse_offset_x = (usb_mouse_scale_x >> 1) - 1; - usb_mouse_offset_y = (usb_mouse_scale_y >> 1) - 1; - if (mac) { - // ugly workaround for Mac's HID coordinate scaling: - // http://lists.apple.com/archives/usb/2011/Jun/msg00032.html - usb_mouse_offset_x += 161061273ul; - usb_mouse_offset_y += 161061273ul; - usb_mouse_scale_x = (1825361101ul + (width >> 1)) / width; - usb_mouse_scale_y = (1825361101ul + (height >> 1)) / height; - } -} - diff --git a/Output/pjrcUSB/arm/usb_mouse.h b/Output/pjrcUSB/arm/usb_mouse.h deleted file mode 100644 index 397d967..0000000 --- a/Output/pjrcUSB/arm/usb_mouse.h +++ /dev/null @@ -1,53 +0,0 @@ -/* Teensyduino Core Library - * http://www.pjrc.com/teensy/ - * Copyright (c) 2013 PJRC.COM, LLC. - * Modified by Jacob Alexander (2015-2016) - * - * 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: - * - * 1. The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * 2. If the Software is incorporated into a build system that allows - * selection among a list of target devices, then similar target - * devices manufactured by PJRC.COM must be included in the list of - * target devices and selectable in the same manner. - * - * 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 - -// Local Includes -#include - - - -// ----- Functions ----- - -// Proces pending mouse commands -void usb_mouse_send(); - -// TODO - More generic -int usb_mouse_move( int8_t x, int8_t y, int8_t wheel ); -int usb_mouse_position( uint16_t x, uint16_t y ); -void usb_mouse_screen_size( uint16_t width, uint16_t height, uint8_t mac ); - diff --git a/Output/pjrcUSB/capabilities.kll b/Output/pjrcUSB/capabilities.kll index c83f910..04e6d12 100644 --- a/Output/pjrcUSB/capabilities.kll +++ b/Output/pjrcUSB/capabilities.kll @@ -1,10 +1,10 @@ Name = pjrcUSBCapabilities; -Version = 0.8; -Author = "HaaTa (Jacob Alexander) 2014-2016"; -KLL = 0.3d; +Version = 0.4; +Author = "HaaTa (Jacob Alexander) 2014-2015"; +KLL = 0.3b; # Modified Date -Date = 2016-03-21; +Date = 2015-05-02; # Output capabilities @@ -12,28 +12,8 @@ consCtrlOut => Output_consCtrlSend_capability( consCode : 2 ); noneOut => Output_noneSend_capability(); sysCtrlOut => Output_sysCtrlSend_capability( sysCode : 1 ); usbKeyOut => Output_usbCodeSend_capability( usbCode : 1 ); -mouseOut => Output_usbMouse_capability( mouseCode : 2, relative_x : 2, relative_y : 2 ); # Configuration capabilities kbdProtocolBoot => Output_kbdProtocolBoot_capability(); kbdProtocolNKRO => Output_kbdProtocolNKRO_capability(); -# Locale Settings -keyboardLocale => KeyboardLocale_define; -keyboardLocale = 0; - -# Default KRO Mode -# Set to 0 for Boot Mode (6KRO) -# Set to 1 for NKRO Mode (default) -usbProtocol => USBProtocol_define; -usbProtocol = 1; - -# Bootloader Mode capability -# XXX -# By default this is disabled on purpose -# It is a large security hazard -flashModeEnabled => flashModeEnabled_define; -flashModeEnabled = 0; - -flashMode => Output_flashMode_capability(); - diff --git a/Output/pjrcUSB/output_com.c b/Output/pjrcUSB/output_com.c index 39ee0b0..dc6bfcd 100644 --- a/Output/pjrcUSB/output_com.c +++ b/Output/pjrcUSB/output_com.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2011-2016 by Jacob Alexander +/* Copyright (C) 2011-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 @@ -37,12 +37,8 @@ #include "arm/usb_dev.h" #include "arm/usb_keyboard.h" #include "arm/usb_serial.h" -#include "arm/usb_mouse.h" #endif -// KLL -#include - // Local Includes #include "output_com.h" @@ -51,15 +47,14 @@ // ----- Macros ----- // Used to build a bitmap lookup table from a byte addressable array -#define byteLookup( byte ) \ - case (( byte ) * ( 8 )): bytePosition = byte; byteShift = 0; break; \ - case (( byte ) * ( 8 ) + ( 1 )): bytePosition = byte; byteShift = 1; break; \ - case (( byte ) * ( 8 ) + ( 2 )): bytePosition = byte; byteShift = 2; break; \ - case (( byte ) * ( 8 ) + ( 3 )): bytePosition = byte; byteShift = 3; break; \ - case (( byte ) * ( 8 ) + ( 4 )): bytePosition = byte; byteShift = 4; break; \ - case (( byte ) * ( 8 ) + ( 5 )): bytePosition = byte; byteShift = 5; break; \ - case (( byte ) * ( 8 ) + ( 6 )): bytePosition = byte; byteShift = 6; break; \ - case (( byte ) * ( 8 ) + ( 7 )): bytePosition = byte; byteShift = 7; break +#define byteLookup( byte ) case (( byte ) * ( 8 )): bytePosition = byte; byteShift = 0; break; \ + case (( byte ) * ( 8 ) + ( 1 )): bytePosition = byte; byteShift = 1; break; \ + case (( byte ) * ( 8 ) + ( 2 )): bytePosition = byte; byteShift = 2; break; \ + case (( byte ) * ( 8 ) + ( 3 )): bytePosition = byte; byteShift = 3; break; \ + case (( byte ) * ( 8 ) + ( 4 )): bytePosition = byte; byteShift = 4; break; \ + case (( byte ) * ( 8 ) + ( 5 )): bytePosition = byte; byteShift = 5; break; \ + case (( byte ) * ( 8 ) + ( 6 )): bytePosition = byte; byteShift = 6; break; \ + case (( byte ) * ( 8 ) + ( 7 )): bytePosition = byte; byteShift = 7; break @@ -116,25 +111,15 @@ uint8_t USBKeys_SentCLI = 0; // 1=num lock, 2=caps lock, 4=scroll lock, 8=compose, 16=kana volatile uint8_t USBKeys_LEDs = 0; -// Currently pressed mouse buttons, bitmask, 0 represents no buttons pressed -volatile uint16_t USBMouse_Buttons = 0; - -// Relative mouse axis movement, stores pending movement -volatile uint16_t USBMouse_Relative_x = 0; -volatile uint16_t USBMouse_Relative_y = 0; - // Protocol setting from the host. // 0 - Boot Mode // 1 - NKRO Mode (Default, unless set by a BIOS or boot interface) -volatile uint8_t USBKeys_Protocol = USBProtocol_define; +volatile uint8_t USBKeys_Protocol = 1; // Indicate if USB should send update // OS only needs update if there has been a change in state USBKeyChangeState USBKeys_Changed = USBKeyChangeState_None; -// Indicate if USB should send update -USBMouseChangeState USBMouse_Changed = 0; - // the idle configuration, how often we send the report to the // host (ms * 4) even when it hasn't changed uint8_t USBKeys_Idle_Config = 125; @@ -152,14 +137,6 @@ volatile uint8_t Output_Available = 0; // 1 - Debug enabled uint8_t Output_DebugMode = 0; -// mA - Set by outside module if not using USB (i.e. Interconnect) -// Generally set to 100 mA (low power) or 500 mA (high power) -uint16_t Output_ExtCurrent_Available = 0; - -// mA - Set by USB module (if exists) -// Initially 100 mA, but may be negotiated higher (e.g. 500 mA) -uint16_t Output_USBCurrent_Available = 0; - // ----- Capabilities ----- @@ -507,76 +484,6 @@ void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *a } } -void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("Output_flashMode()"); - return; - } - - // Start flash mode - Output_firmwareReload(); -} - -// Sends a mouse command over the USB Output buffer -// XXX This function *will* be changing in the future -// If you use it, be prepared that your .kll files will break in the future (post KLL 0.5) -// Argument #1: USB Mouse Button (16 bit) -// Argument #2: USB X Axis (16 bit) relative -// Argument #3: USB Y Axis (16 bit) relative -void Output_usbMouse_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("Output_usbMouse(mouseButton,relX,relY)"); - return; - } - - // Determine which mouse button was sent - // The USB spec defines up to a max of 0xFFFF buttons - // The usual are: - // 1 - Button 1 - (Primary) - // 2 - Button 2 - (Secondary) - // 3 - Button 3 - (Tertiary) - uint16_t mouse_button = *(uint16_t*)(&args[0]); - - // X/Y Relative Axis - uint16_t mouse_x = *(uint16_t*)(&args[2]); - uint16_t mouse_y = *(uint16_t*)(&args[4]); - - // Adjust for bit shift - uint16_t mouse_button_shift = mouse_button - 1; - - // Only send mouse button if in press or hold state - if ( stateType == 0x00 && state == 0x03 ) // Release state - { - // Release - if ( mouse_button ) - USBMouse_Buttons &= ~(1 << mouse_button_shift); - } - else - { - // Press or hold - if ( mouse_button ) - USBMouse_Buttons |= (1 << mouse_button_shift); - - if ( mouse_x ) - USBMouse_Relative_x = mouse_x; - if ( mouse_y ) - USBMouse_Relative_y = mouse_y; - } - - // Trigger updates - if ( mouse_button ) - USBMouse_Changed |= USBMouseChangeState_Buttons; - - if ( mouse_x || mouse_y ) - USBMouse_Changed |= USBMouseChangeState_Relative; -} - // ----- Functions ----- @@ -615,19 +522,11 @@ inline void Output_setup() // USB Data Send inline void Output_send() { - // USB status checks - // Non-standard USB state manipulation, usually does nothing - usb_device_check(); - // Boot Mode Only, unset stale keys if ( USBKeys_Protocol == 0 ) for ( uint8_t c = USBKeys_Sent; c < USB_BOOT_MAX_KEYS; c++ ) USBKeys_Keys[c] = 0; - // Process mouse actions - while ( USBMouse_Changed ) - usb_mouse_send(); - // Send keypresses while there are pending changes while ( USBKeys_Changed ) usb_keyboard_send(); @@ -702,72 +601,6 @@ inline void Output_softReset() } -// Update USB current (mA) -// Triggers power change event -void Output_update_usb_current( unsigned int current ) -{ - // Only signal if changed - if ( current == Output_USBCurrent_Available ) - return; - - // Update USB current - Output_USBCurrent_Available = current; - - unsigned int total_current = Output_current_available(); - info_msg("USB Available Current Changed. Total Available: "); - printInt32( total_current ); - print(" mA" NL); - - // Send new total current to the Scan Modules - Scan_currentChange( Output_current_available() ); -} - - -// Update external current (mA) -// Triggers power change event -void Output_update_external_current( unsigned int current ) -{ - // Only signal if changed - if ( current == Output_ExtCurrent_Available ) - return; - - // Update external current - Output_ExtCurrent_Available = current; - - unsigned int total_current = Output_current_available(); - info_msg("External Available Current Changed. Total Available: "); - printInt32( total_current ); - print(" mA" NL); - - // Send new total current to the Scan Modules - Scan_currentChange( Output_current_available() ); -} - - -// Power/Current Available -unsigned int Output_current_available() -{ - unsigned int total_current = 0; - - // Check for USB current source - total_current += Output_USBCurrent_Available; - - // Check for external current source - total_current += Output_ExtCurrent_Available; - - // XXX If the total available current is still 0 - // Set to 100 mA, which is generally a safe assumption at startup - // before we've been able to determine actual available current - if ( total_current == 0 ) - { - total_current = 100; - } - - return total_current; -} - - - // ----- CLI Command Functions ----- void cliFunc_kbdProtocol( char* args ) diff --git a/Output/pjrcUSB/output_com.h b/Output/pjrcUSB/output_com.h index 36369eb..0462c20 100644 --- a/Output/pjrcUSB/output_com.h +++ b/Output/pjrcUSB/output_com.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013-2016 by Jacob Alexander +/* Copyright (C) 2013-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 @@ -56,14 +56,6 @@ typedef enum USBKeyChangeState { USBKeyChangeState_All = 0x7F, } USBKeyChangeState; -// Allows for selective USB descriptor pushes -// However, in most cases everything is updated for each packet push -typedef enum USBMouseChangeState { - USBMouseChangeState_None = 0x00, - USBMouseChangeState_Buttons = 0x01, - USBMouseChangeState_Relative = 0x02, -} USBMouseChangeState; - // ----- Variables ----- @@ -80,22 +72,29 @@ extern uint16_t USBKeys_ConsCtrl; // 1KRO container for Consumer Contro extern volatile uint8_t USBKeys_Protocol; // 0 - Boot Mode, 1 - NKRO Mode -extern volatile uint16_t USBMouse_Buttons; // Bitmask for mouse buttons -extern volatile uint16_t USBMouse_Relative_x; -extern volatile uint16_t USBMouse_Relative_y; - // Misc variables (XXX Some are only properly utilized using AVR) extern uint8_t USBKeys_Idle_Config; extern uint8_t USBKeys_Idle_Count; -extern USBKeyChangeState USBKeys_Changed; -extern USBMouseChangeState USBMouse_Changed; +extern USBKeyChangeState USBKeys_Changed; extern volatile uint8_t Output_Available; // 0 - Output module not fully functional, 1 - Output module working extern uint8_t Output_DebugMode; // 0 - Debug disabled, 1 - Debug enabled -extern uint16_t Output_ExtCurrent_Available; // mA - Set by outside module if not using USB (i.e. Interconnect) + + +// ----- Capabilities ----- + +// Output capabilities +void Output_consCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ); +void Output_noneSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ); +void Output_sysCtrlSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ); +void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ); + +// Configuration capabilities +void Output_kbdProtocolBoot_capability( uint8_t state, uint8_t stateType, uint8_t *args ); +void Output_kbdProtocolNKRO_capability( uint8_t state, uint8_t stateType, uint8_t *args ); @@ -112,12 +111,6 @@ void Output_softReset(); // Relies on USB serial module unsigned int Output_availablechar(); -// Returns the total mA available (total, if used in a chain, each device will have to use a slice of it) -unsigned int Output_current_available(); - -void Output_update_external_current( unsigned int current ); -void Output_update_usb_current( unsigned int current ); - int Output_getchar(); int Output_putchar( char c ); int Output_putstr( char* str ); diff --git a/Output/pjrcUSB/setup.cmake b/Output/pjrcUSB/setup.cmake index 7e7a874..519c4a8 100644 --- a/Output/pjrcUSB/setup.cmake +++ b/Output/pjrcUSB/setup.cmake @@ -26,10 +26,8 @@ elseif ( ${COMPILER_FAMILY} MATCHES "arm" ) output_com.c arm/usb_desc.c arm/usb_dev.c - arm/usb_joystick.c arm/usb_keyboard.c arm/usb_mem.c - arm/usb_mouse.c arm/usb_serial.c ) diff --git a/Output/uartOut/arm/uart_serial.c b/Output/uartOut/arm/uart_serial.c index d06f2f5..db7a3aa 100644 --- a/Output/uartOut/arm/uart_serial.c +++ b/Output/uartOut/arm/uart_serial.c @@ -27,8 +27,6 @@ // Project Includes #include #include -#include -#include // Local Includes #include "uart_serial.h" @@ -327,48 +325,6 @@ void uart_serial_flush_output() void uart_device_reload() { - if ( flashModeEnabled_define == 0 ) - { - print( NL ); - warn_print("flashModeEnabled not set, cancelling firmware reload..."); - info_msg("Set flashModeEnabled to 1 in your kll configuration."); - return; - } - -// MCHCK -#if defined(_mk20dx128vlf5_) - - // MCHCK Kiibohd Variant - // Check to see if PTA3 (has a pull-up) is connected to GND (usually via jumper) - // Only allow reload if the jumper is present (security) - GPIOA_PDDR &= ~(1<<3); // Input - PORTA_PCR3 = PORT_PCR_PFE | PORT_PCR_MUX(1); // Internal pull-up - - // Check for jumper - if ( GPIOA_PDIR & (1<<3) && flashModeEnabled_define != 0 ) - { - print( NL ); - warn_print("Security jumper not present, cancelling firmware reload..."); - info_msg("Replace jumper on middle 2 pins, or manually press the firmware reload button."); - } - else - { - // Copies variable into the VBAT register, must be identical to the variable in the bootloader to jump to the bootloader flash mode - for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ ) - (&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ]; - SOFTWARE_RESET(); - } - -// Kiibohd mk20dx256vlh7 -#elif defined(_mk20dx256vlh7_) - // Copies variable into the VBAT register, must be identical to the variable in the bootloader to jump to the bootloader flash mode - for ( int pos = 0; pos < sizeof(sys_reset_to_loader_magic); pos++ ) - (&VBAT)[ pos ] = sys_reset_to_loader_magic[ pos ]; - SOFTWARE_RESET(); - -// Teensy 3.0 and 3.1 -#else asm volatile("bkpt"); -#endif } diff --git a/Output/uartOut/capabilities.kll b/Output/uartOut/capabilities.kll index 663c034..d45e181 100644 --- a/Output/uartOut/capabilities.kll +++ b/Output/uartOut/capabilities.kll @@ -1,21 +1,12 @@ Name = uartOutCapabilities; -Version = 0.2; +Version = 0.1; Author = "HaaTa (Jacob Alexander) 2014"; KLL = 0.3; # Modified Date -Date = 2014-08-21; +Date = 2014-09-27; # Capabilties available to the uartOut output module usbKeyOut => Output_usbCodeSend_capability( usbCode : 1 ); -# Bootloader Mode capability -# XXX -# By default this is disabled on purpose -# It is a large security hazard -flashModeEnabled => flashModeEnabled_define; -flashModeEnabled = 0; - -flashMode => Output_flashMode_capability(); - diff --git a/Output/uartOut/output_com.c b/Output/uartOut/output_com.c index a45193b..8558fc1 100644 --- a/Output/uartOut/output_com.c +++ b/Output/uartOut/output_com.c @@ -129,19 +129,6 @@ void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *a } } -void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("Output_flashMode(usbCode)"); - return; - } - - // Start flash mode - Output_firmwareReload(); -} - // ----- Functions ----- diff --git a/Output/usbMuxUart/output_com.c b/Output/usbMuxUart/output_com.c index 55c9553..3fa26c9 100644 --- a/Output/usbMuxUart/output_com.c +++ b/Output/usbMuxUart/output_com.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* 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 @@ -143,14 +143,6 @@ volatile uint8_t Output_Available = 0; // 1 - Debug enabled uint8_t Output_DebugMode = 0; -// mA - Set by outside module if not using USB (i.e. Interconnect) -// Generally set to 100 mA (low power) or 500 mA (high power) -uint16_t Output_ExtCurrent_Available = 0; - -// mA - Set by USB module (if exists) -// Initially 100 mA, but may be negotiated higher (e.g. 500 mA) -uint16_t Output_USBCurrent_Available = 0; - // ----- Capabilities ----- @@ -498,19 +490,6 @@ void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *a } } -void Output_flashMode_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("Output_flashMode()"); - return; - } - - // Start flash mode - Output_firmwareReload(); -} - // ----- Functions ----- @@ -552,10 +531,6 @@ inline void Output_setup() // USB Data Send inline void Output_send() { - // USB status checks - // Non-standard USB state manipulation, usually does nothing - usb_device_check(); - // Boot Mode Only, unset stale keys if ( USBKeys_Protocol == 0 ) for ( uint8_t c = USBKeys_Sent; c < USB_BOOT_MAX_KEYS; c++ ) @@ -653,72 +628,6 @@ inline void Output_softReset() } -// Update USB current (mA) -// Triggers power change event -void Output_update_usb_current( unsigned int current ) -{ - // Only signal if changed - if ( current == Output_USBCurrent_Available ) - return; - - // Update USB current - Output_USBCurrent_Available = current; - - unsigned int total_current = Output_current_available(); - info_msg("USB Available Current Changed. Total Available: "); - printInt32( total_current ); - print(" mA" NL); - - // Send new total current to the Scan Modules - Scan_currentChange( Output_current_available() ); -} - - -// Update external current (mA) -// Triggers power change event -void Output_update_external_current( unsigned int current ) -{ - // Only signal if changed - if ( current == Output_ExtCurrent_Available ) - return; - - // Update external current - Output_ExtCurrent_Available = current; - - unsigned int total_current = Output_current_available(); - info_msg("External Available Current Changed. Total Available: "); - printInt32( total_current ); - print(" mA" NL); - - // Send new total current to the Scan Modules - Scan_currentChange( Output_current_available() ); -} - - -// Power/Current Available -unsigned int Output_current_available() -{ - unsigned int total_current = 0; - - // Check for USB current source - total_current += Output_USBCurrent_Available; - - // Check for external current source - total_current += Output_ExtCurrent_Available; - - // XXX If the total available current is still 0 - // Set to 100 mA, which is generally a safe assumption at startup - // before we've been able to determine actual available current - if ( total_current == 0 ) - { - total_current = 100; - } - - return total_current; -} - - - // ----- CLI Command Functions ----- void cliFunc_kbdProtocol( char* args ) diff --git a/README.markdown b/README.markdown index a7802f9..90e44aa 100644 --- a/README.markdown +++ b/README.markdown @@ -12,9 +12,7 @@ Please refer to the [KLL](https://github.com/kiibohd/kll) repo or [kiibohd.com]( Official Keyboards ------------------ -* MD1 (Infinity Keyboard/IC60 2014/10/15) -* MDErgo1 (Infinity Ergodox /ICED 2015/03/31) -* WhiteFox (Soon to be released?) +* MD1 (Infinity Keyboard 2014/10/15) The Kiibohd firmware supports a lot of other keyboards, but these are more obscure/custom/lesser known. @@ -38,8 +36,8 @@ Supported Microcontrollers * Teensy 2.0 (Partial) * Teensy 2.0++ -* Teensy 3.0 -* Teensy 3.1/3.2 +* Teesny 3.0 +* Teensy 3.1 * mk20dx128vlf5 * mk20dx256vlh7 @@ -84,7 +82,6 @@ Contact If you really need to get a hold of HaaTa, email is best: `haata@kiibohd.com` IRC is likely faster though. -`#input.club@irc.freenode.net` `#geekhack@irc.freenode.net` `#deskthority@irc.freenode.net` diff --git a/Scan/CK3/defaultMap.kll b/Scan/CK3/defaultMap.kll deleted file mode 100644 index 30de5d0..0000000 --- a/Scan/CK3/defaultMap.kll +++ /dev/null @@ -1,132 +0,0 @@ -Name = CK3; -Version = 0.3; -Author = "Crystal Hammer 2016"; -KLL = 0.3d; - -# Modified Date -Date = 2016-03-01; - -# this is nearly the default map - -S0x0F : U"Esc"; -S0x8C : U"F1"; -S0x8B : U"F2"; -S0x67 : U"F3"; -S0x0D : U"F4"; -S0x6E : U"F5"; -S0x06 : U"F6"; -S0x5F : U"F7"; -S0x83 : U"F8"; -S0x7F : U"F9"; -S0x6D : U"F10"; -S0x01 : U"F11"; -S0x13 : U"F12"; -S0x6F : U"PrintScreen"; -S0x4B : U"ScrollLock"; -S0x4A : U"Pause"; -S0x39 : U"F16"; - -S0x8D : U"BackTick"; -S0x7B : U"1"; -S0x7A : U"2"; -S0x79 : U"3"; -S0x74 : U"4"; -S0x86 : U"5"; -S0x85 : U"6"; -S0x73 : U"7"; -S0x72 : U"8"; -S0x71 : U"9"; -S0x6C : U"0"; -S0x7E : U"-"; -S0x84 : U"="; -S0x5B : U"Backspace"; - - -S0x69 : U"Tab"; -S0x57 : U"Q"; -S0x56 : U"W"; -S0x55 : U"E"; -S0x50 : U"R"; -S0x62 : U"T"; -S0x61 : U"Y"; -S0x4F : U"U"; -S0x4E : U"I"; -S0x4D : U"O"; -S0x48 : U"P"; -S0x5A : U"["; -S0x60 : U"]"; -S0x37 : U"\"; - -S0x68 : U"CapsLock"; -S0x45 : U"A"; -S0x44 : U"S"; -S0x43 : U"D"; -S0x3E : U"F"; -S0x08 : U"G"; -S0x07 : U"H"; -S0x3D : U"J"; -S0x3C : U"K"; -S0x3B : U"L"; -S0x36 : U";"; -S0x00 : U"'"; -S0x25 : U"Enter"; - -S0x5E : U"LShift"; -S0x33 : U"Z"; -S0x32 : U"X"; -S0x31 : U"C"; -S0x2C : U"V"; -S0x1A : U"B"; -S0x19 : U"N"; -S0x2B : U"M"; -S0x2A : U","; -S0x29 : U"."; -S0x12 : U"/"; -S0x3A : U"RShift"; - -# bottom -S0x80 : U"LCtrl"; -S0x6A : U"LGui"; -S0x0E : U"LAlt"; -S0x03 : U"LAlt"; -S0x09 : U"Space"; -S0x15 : U"RAlt"; -S0x17 : U"RGui"; -S0x88 : U"RCtrl"; -S0x87 : U"RCtrl"; - -# middle right column, custom -S0x8A : U"Esc"; -S0x89 : U"Backspace"; -S0x77 : U"Enter"; -S0x78 : U"RShift"; - -# arrows -S0x1E : U"Left"; -S0x0C : U"Up"; -S0x1B : U"Down"; -S0x1C : U"Right"; -# S0x1C : U"RCtrl"; - -# numpad -S0x2D : U"NumLock"; -S0x2E : U"P/"; -S0x2F : U"P*"; -S0x1D : U"P-"; - -S0x51 : U"P7"; -S0x52 : U"P8"; -S0x53 : U"P9"; -S0x54 : U"P+"; - -S0x63 : U"P4"; -S0x64 : U"P5"; -S0x65 : U"P6"; - -S0x3F : U"P1"; -S0x40 : U"P2"; -S0x41 : U"P3"; -S0x42 : U"PEnter"; - -S0x0A : U"P0"; -S0x0B : U"P."; diff --git a/Scan/CK3/matrix.h b/Scan/CK3/matrix.h deleted file mode 100644 index 7f6632d..0000000 --- a/Scan/CK3/matrix.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander, Crystal Hammer - * - * 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 ----- -// CK3 -// Columns (Strobe) 18 -// Rows (Sense) 8 - -// This is the default map of just A4Tech KX-100 matrix -// scan codes for keys are defined in defaultMap.kll -/* - 1| 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 - - - 1 Mcmp Bstp Esc \ F4 Up Del Ins Spc G H F6 == Vol- AltL xx F11 ' - 2 Calc ExA4 ExC2 ExE2 ExE1 <- Sub -> Dn B N ExC1 Apps Mnxt AltR xx F12 / - 3 Mstp Bbck Z X C Mpau Mul Div NumL V M , . Vol+ xx CtrR Ent \ - 4 GuiR Bfwd A S D Ent PgDn Dn End F J K L ShiR xx == \ ; - 5 xx Mail Q W E Add PgUp Up Home R U I O xx ScrL Paus ExE3 P - 6 ExB1 GuiL Tab Caps F3 RB~ -> Del <- T Y ] F7 ShiL == Pwr Back [ - 7 xx Bsch 1 2 3 End PgDn xx Pwr 4 7 8 9 Msel Ptr F5 F10 0 - 8 Bhom Vmut `~ F1 F2 Home PgUp Ins Del 5 6 = F8 Mprv == CtrL F9 - - - rows - columns | - 1 3 5 7 1 3 5 7 9 11 13 15 17 - 2 4 6 8 2 4 6 8 10 12 14 16 18 connectors, PCB view -*/ -GPIO_Pin Matrix_cols[] = { - gpio(B,16), gpio(B,17), gpio(D,0), gpio(A,12), gpio(A,13), gpio(D,7), gpio(D,4), gpio(D,2), gpio(D,3), - gpio(C,2), gpio(C,1), gpio(D,6), gpio(D,5), gpio(B,2), gpio(B,3), gpio(B,1), gpio(B,0), gpio(C,0) }; -GPIO_Pin Matrix_rows[] = { - gpio(C,10), gpio(C,11), gpio(B,18), gpio(A,4), gpio(A,5), gpio(B,19), gpio(C,9), gpio(C,8) }; - -// Define type of scan matrix -Config Matrix_type = Config_Pullup; - - -// Define this if your matrix has ghosting (i.e. regular keyboard without diodes) -// this will enable the anti-ghosting code -#define GHOSTING_MATRIX - -// delay in microseconds before and after each strobe change during matrix scan -#define STROBE_DELAY 10 diff --git a/Scan/CK3/scan_loop.c b/Scan/CK3/scan_loop.c deleted file mode 100644 index b4c8c99..0000000 --- a/Scan/CK3/scan_loop.c +++ /dev/null @@ -1,213 +0,0 @@ -/* Copyright (C) 2014 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 - -// Local Includes -#include "scan_loop.h" - - - -// ----- Function Declarations ----- - -// CLI Functions -void cliFunc_echo( char* args ); - - - -// ----- Variables ----- - -// Scan Module command dictionary -CLIDict_Entry( echo, "Example command, echos the arguments." ); - -CLIDict_Def( scanCLIDict, "Scan Module Commands" ) = { - CLIDict_Item( echo ), - { 0, 0, 0 } // Null entry for dictionary end -}; - -// Number of scans since the last USB send -uint16_t Scan_scanCount = 0; - - - -// ----- Functions ----- - -// Setup -inline void Scan_setup() -{ - // Register Scan CLI dictionary - CLI_registerDictionary( scanCLIDict, scanCLIDictName ); - - // Setup GPIO pins for matrix 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; -} - - - -// ----- Capabilities ----- - -// Custom capability examples -// Refer to kll.h in Macros/PartialMap for state and stateType information -void CustomAction_action1_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - // XXX This is required for debug cli to give you a list of capabilities - if ( stateType == 0xFF && state == 0xFF ) - { - print("CustomAction_action1_capability()"); - return; - } - - // Prints Action1 info message to the debug cli - info_print("Action1"); -} - -uint8_t CustomAction_blockHold_storage = 0; -void CustomAction_blockHold_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("CustomAction_blockHold_capability(usbCode)"); - return; - } - - // Retrieve 8-bit argument - uint8_t key = args[0]; - - // We only care about normal keys - if ( stateType == 0x00 ) - { - // Block given key if we're in the "Press" or "Hold" state - if ( ( state == 0x01 || state == 0x02 ) - && CustomAction_blockHold_storage == 0 ) - { - CustomAction_blockHold_storage = key; - info_msg("Blocking Key: "); - printHex( key ); - print( NL ); - } - // Release if in the "Off" or "Release" state and we're blocking - else if ( ( state == 0x00 || state == 0x03 ) - && key == CustomAction_blockHold_storage ) - { - info_msg("Unblocking Key: "); - printHex( CustomAction_blockHold_storage ); - print( NL ); - CustomAction_blockHold_storage = 0; - } - } -} - -void CustomAction_blockKey_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("CustomAction_blockKey_capability(usbCode)"); - return; - } - - // Retrieve 8-bit argument - uint8_t key = args[0]; - - // If key is not blocked, process - if ( key != CustomAction_blockHold_storage ) - { - extern void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ); - Output_usbCodeSend_capability( state, stateType, &key ); - } -} - - -// 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 ); -} - - - -// ----- CLI Command Functions ----- - -// XXX Just an example command showing how to parse arguments (more complex than generally needed) -void cliFunc_echo( char* args ) -{ - char* curArgs; - char* arg1Ptr; - char* arg2Ptr = args; - - // Parse args until a \0 is found - while ( 1 ) - { - print( NL ); // No \r\n by default after the command is entered - - curArgs = arg2Ptr; // Use the previous 2nd arg pointer to separate the next arg from the list - CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr ); - - // Stop processing args if no more are found - if ( *arg1Ptr == '\0' ) - break; - - // Print out the arg - dPrint( arg1Ptr ); - } -} - diff --git a/Scan/CK3/scan_loop.h b/Scan/CK3/scan_loop.h deleted file mode 100644 index 3c543ea..0000000 --- a/Scan/CK3/scan_loop.h +++ /dev/null @@ -1,50 +0,0 @@ -/* 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 - -void Scan_currentChange( unsigned int current ); // Called by Output Module - - -// ----- Capabilities ----- - -// Example capabilities -void CustomAction_action1_capability( uint8_t state, uint8_t stateType, uint8_t *args ); -void CustomAction_blockHold_capability( uint8_t state, uint8_t stateType, uint8_t *args ); -void CustomAction_blockKey_capability( uint8_t state, uint8_t stateType, uint8_t *args ); - diff --git a/Scan/CK3/setup.cmake b/Scan/CK3/setup.cmake deleted file mode 100644 index d40a338..0000000 --- a/Scan/CK3/setup.cmake +++ /dev/null @@ -1,32 +0,0 @@ -###| CMake Kiibohd Controller Scan Module |### -# -# Written by Jacob Alexander in 2014 for the Kiibohd Controller -# -# Released into the Public Domain -# -### - - -### -# Required Submodules -# - -AddModule ( Scan MatrixARM ) - - -### -# Module C files -# - -set ( Module_SRCS - scan_loop.c -) - - -### -# Compiler Family Compatibility -# -set ( ModuleCompatibility - arm -) - diff --git a/Scan/DPH/scan_loop.c b/Scan/DPH/scan_loop.c index 5d8d832..1a0176c 100644 --- a/Scan/DPH/scan_loop.c +++ b/Scan/DPH/scan_loop.c @@ -1,23 +1,18 @@ -/* Copyright (C) 2011-2013 by Joseph Makuch (jmakuch+f@gmail.com) - * Additions by Jacob Alexander (2013-2014) (haata@kiibohd.com) +/* Copyright (C) 2011-2013 by Joseph Makuch + * Additions by Jacob Alexander (2013-2014) * - * 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: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * This library 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 + * Lesser General Public License for more details. * - * 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. + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . */ // ----- Includes ----- diff --git a/Scan/DPH/scan_loop.h b/Scan/DPH/scan_loop.h index 234b959..83a9a1b 100644 --- a/Scan/DPH/scan_loop.h +++ b/Scan/DPH/scan_loop.h @@ -1,22 +1,17 @@ /* Copyright (C) 2013-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: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. + * This library 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 + * Lesser General Public License for more details. * - * 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. + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . */ #pragma once diff --git a/Scan/ISSILed/capabilities.kll b/Scan/ISSILed/capabilities.kll index 6ecd4f6..2c0a32c 100644 --- a/Scan/ISSILed/capabilities.kll +++ b/Scan/ISSILed/capabilities.kll @@ -1,26 +1,10 @@ Name = ISSILedCapabilities; -Version = 0.2; +Version = 0.1; Author = "HaaTa (Jacob Alexander) 2015"; KLL = 0.3c; # Modified Date -Date = 2015-10-09; - -# Basic ISSI Capabilities -# Modes -# 0: Decrease single led brightness -# 1: Increase single led brightness -# 2: Set single led brightness -# 3: Decrease brightness of all leds -# 4: Increase brightness of all leds -# 5: Set brightness of all leds -# Amount -> 0 -> 255 -# Index: -# Depends on keyboard. At least from from 0 -> 143 (single chip). -# Remember, it may be possible that all leds on a single chip are connected. -# So it may be possible that you may have index gaps. -# i.e. 23 then 144 -ledControl => LED_control_capability( mode : 1, amount : 1, index : 2 ); +Date = 2015-08-02; # Defines available to the ISSILed sub-module diff --git a/Scan/ISSILed/exampleAPI.bash b/Scan/ISSILed/exampleAPI.bash deleted file mode 100755 index 7993c38..0000000 --- a/Scan/ISSILed/exampleAPI.bash +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -# ISSILed -# Virtual Serial Port API Example -# Jacob Alexander 2015 - -if [ $# -eq 0 ]; then - echo "You must specify your virtual serialport. (/dev/ttyACM0 on linux, /dev/cu.usbmodemXXXX on OSX)" - echo " ex: $0 /dev/ttyACM0" - exit 1 -fi -# XXX Set this to match your virtual serialport -# TODO Show examples for Cygwin/Windows -# For Mac OSX it will be something like /dev/cu.usbmodem1413 (number may differ) -SERIALPORT=$1 - -# NOTE: Make sure you don't write too quickly to the serial port, it can get overwhelmed by a modern computer -# Generally this just means commands will get ignored -# I'm using 100 ms sleeps here, but much smaller are probably sufficient - -# Clear out cli buffer -printf "\r" > $SERIALPORT - -# Write to ISSI Page -# Arguments -# - page -# - starting address -# - data (usually brightness) (8 bits) -# -# For brightness control, set the starting address to 0x24 -# By default only page 0x00 is used -# There are 8 pages of memory (these can be cycled through for animiations) -# 144 led channels -# Page 0x0A is used for configuration -# See the datasheet for full details http://www.issi.com/WW/pdf/31FL3731C.pdf -sleep 0.1 -printf "ledWPage 0x00 0x24 0x10 0x20 0x30 0x40 0x50\r" > $SERIALPORT - diff --git a/Scan/ISSILed/led_scan.c b/Scan/ISSILed/led_scan.c index a091b86..33073ab 100644 --- a/Scan/ISSILed/led_scan.c +++ b/Scan/ISSILed/led_scan.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* Copyright (C) 2014-2015 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 @@ -25,11 +25,6 @@ #include #include -// Interconnect module if compiled in -#if defined(ConnectEnabled_define) -#include -#endif - // Local Includes #include "led_scan.h" @@ -42,10 +37,6 @@ #define LED_BufferLength 144 -// TODO Needs to be defined per keyboard -#define LED_TotalChannels 144 - - // ----- Structs ----- @@ -58,8 +49,6 @@ typedef struct I2C_Buffer { } I2C_Buffer; typedef struct LED_Buffer { - uint8_t i2c_addr; - uint8_t reg_addr; uint8_t buffer[LED_BufferLength]; } LED_Buffer; @@ -70,7 +59,6 @@ typedef struct LED_Buffer { // CLI Functions void cliFunc_i2cRecv ( char* args ); void cliFunc_i2cSend ( char* args ); -void cliFunc_ledCtrl ( char* args ); void cliFunc_ledRPage( char* args ); void cliFunc_ledStart( char* args ); void cliFunc_ledTest ( char* args ); @@ -89,7 +77,6 @@ uint8_t I2C_Send( uint8_t *data, uint8_t sendLen, uint8_t recvLen ); // Scan Module command dictionary CLIDict_Entry( i2cRecv, "Send I2C sequence of bytes and expect a reply of 1 byte on the last sequence." NL "\t\tUse |'s to split sequences with a stop." ); CLIDict_Entry( i2cSend, "Send I2C sequence of bytes. Use |'s to split sequences with a stop." ); -CLIDict_Entry( ledCtrl, "Basic LED control. Args: []" ); CLIDict_Entry( ledRPage, "Read the given register page." ); CLIDict_Entry( ledStart, "Disable software shutdown." ); CLIDict_Entry( ledTest, "Test out the led pages." ); @@ -99,7 +86,6 @@ CLIDict_Entry( ledZero, "Zero out LED register pages (non-configuration)." ) CLIDict_Def( ledCLIDict, "ISSI LED Module Commands" ) = { CLIDict_Item( i2cRecv ), CLIDict_Item( i2cSend ), - CLIDict_Item( ledCtrl ), CLIDict_Item( ledRPage ), CLIDict_Item( ledStart ), CLIDict_Item( ledTest ), @@ -192,9 +178,7 @@ void i2c0_isr() } else { - dbug_msg("Attempting to read byte - "); - printHex( I2C_RxBuffer.sequencePos ); - print( NL ); + dbug_print("Attempting to read byte"); I2C0_C1 = I2C_RxBuffer.sequencePos == 1 ? I2C_C1_IICEN | I2C_C1_IICIE | I2C_C1_MST | I2C_C1_TXAK // Single byte read : I2C_C1_IICEN | I2C_C1_IICIE | I2C_C1_MST; // Multi-byte read @@ -325,6 +309,34 @@ void LED_sendPage( uint8_t *buffer, uint8_t len, uint8_t page ) } +void LED_readPage( uint8_t len, uint8_t page ) +{ + // Page Setup + uint8_t pageSetup[] = { 0xE8, 0xFD, page }; + + // Setup page + while ( I2C_Send( pageSetup, sizeof( pageSetup ), 0 ) == 0 ) + delay(1); + + // Register Setup + uint8_t regSetup[] = { 0xE8, 0x00 }; + + // Setup starting register + while ( I2C_Send( regSetup, sizeof( regSetup ), 0 ) == 0 ) + delay(1); + + // Register Read Command + uint8_t regReadCmd[] = { 0xE9 }; + + // Read each register in the page + for ( uint8_t reg = 0; reg < len; reg++ ) + { + // Request register data + while ( I2C_Send( regReadCmd, sizeof( regReadCmd ), 0 ) == 0 ) + delay(1); + } +} + void LED_writeReg( uint8_t reg, uint8_t val, uint8_t page ) { // Page Setup @@ -341,44 +353,6 @@ void LED_writeReg( uint8_t reg, uint8_t val, uint8_t page ) delay(1); } -void LED_readPage( uint8_t len, uint8_t page ) -{ - // Software shutdown must be enabled to read registers - LED_writeReg( 0x0A, 0x00, 0x0B ); - - // Page Setup - uint8_t pageSetup[] = { 0xE8, 0xFD, page }; - - // Setup page - while ( I2C_Send( pageSetup, sizeof( pageSetup ), 0 ) == 0 ) - delay(1); - - // Register Setup - uint8_t regSetup[] = { 0xE8, 0x00 }; - - // Read each register in the page - for ( uint8_t reg = 0; reg < len; reg++ ) - { - // Update register to read - regSetup[1] = reg; - - // Configure register - while ( I2C_Send( regSetup, sizeof( regSetup ), 0 ) == 0 ) - delay(1); - - // Register Read Command - uint8_t regReadCmd[] = { 0xE9 }; - - // Request single register byte - while ( I2C_Send( regReadCmd, sizeof( regReadCmd ), 1 ) == 0 ) - delay(1); - dbug_print("NEXT"); - } - - // Disable software shutdown - LED_writeReg( 0x0A, 0x01, 0x0B ); -} - // Setup inline void LED_setup() { @@ -406,14 +380,8 @@ inline void LED_setup() // Set default brightness LED_sendPage( (uint8_t*)LED_defaultBrightness1, sizeof( LED_defaultBrightness1 ), 0 ); - // Do not disable software shutdown of ISSI chip unless current is high enough - // Require at least 150 mA - // May be enabled/disabled at a later time - if ( Output_current_available() >= 150 ) - { - // Disable Software shutdown of ISSI chip - LED_writeReg( 0x0A, 0x01, 0x0B ); - } + // Disable Software shutdown of ISSI chip + LED_writeReg( 0x0A, 0x01, 0x0B ); } @@ -639,219 +607,20 @@ uint8_t I2C_Send( uint8_t *data, uint8_t sendLen, uint8_t recvLen ) // LED State processing loop -unsigned int LED_currentEvent = 0; inline uint8_t LED_scan() { - // Check for current change event - if ( LED_currentEvent ) - { - // TODO dim LEDs in low power mode instead of shutting off - if ( LED_currentEvent < 150 ) - { - // Enable Software shutdown of ISSI chip - LED_writeReg( 0x0A, 0x00, 0x0B ); - } - else - { - // Disable Software shutdown of ISSI chip - LED_writeReg( 0x0A, 0x01, 0x0B ); - } - LED_currentEvent = 0; - } + // I2C Busy + // S & I2C_S_BUSY + //I2C_S_BUSY return 0; } -// Called by parent Scan Module whenver the available current has changed -// current - mA -void LED_currentChange( unsigned int current ) -{ - // Delay action till next LED scan loop (as this callback sometimes occurs during interrupt requests) - LED_currentEvent = current; -} - - - -// ----- Capabilities ----- - -// Basic LED Control Capability -typedef enum LedControlMode { - // Single LED Modes - LedControlMode_brightness_decrease, - LedControlMode_brightness_increase, - LedControlMode_brightness_set, - // Set all LEDs (index argument not required) - LedControlMode_brightness_decrease_all, - LedControlMode_brightness_increase_all, - LedControlMode_brightness_set_all, -} LedControlMode; - -typedef struct LedControl { - LedControlMode mode; // XXX Make sure to adjust the .kll capability if this variable is larger than 8 bits - uint8_t amount; - uint16_t index; -} LedControl; - -void LED_control( LedControl *control ) -{ - // Only send if we've completed all other transactions - /* - if ( I2C_TxBuffer.sequencePos > 0 ) - return; - */ - - // Configure based upon the given mode - // TODO Perhaps do gamma adjustment? - switch ( control->mode ) - { - case LedControlMode_brightness_decrease: - // Don't worry about rolling over, the cycle is quick - LED_pageBuffer.buffer[ control->index ] -= control->amount; - break; - - case LedControlMode_brightness_increase: - // Don't worry about rolling over, the cycle is quick - LED_pageBuffer.buffer[ control->index ] += control->amount; - break; - - case LedControlMode_brightness_set: - LED_pageBuffer.buffer[ control->index ] = control->amount; - break; - - case LedControlMode_brightness_decrease_all: - for ( uint8_t channel = 0; channel < LED_TotalChannels; channel++ ) - { - // Don't worry about rolling over, the cycle is quick - LED_pageBuffer.buffer[ channel ] -= control->amount; - } - break; - - case LedControlMode_brightness_increase_all: - for ( uint8_t channel = 0; channel < LED_TotalChannels; channel++ ) - { - // Don't worry about rolling over, the cycle is quick - LED_pageBuffer.buffer[ channel ] += control->amount; - } - break; - - case LedControlMode_brightness_set_all: - for ( uint8_t channel = 0; channel < LED_TotalChannels; channel++ ) - { - LED_pageBuffer.buffer[ channel ] = control->amount; - } - break; - } - - // Sync LED buffer with ISSI chip buffer - // TODO Support multiple frames - LED_pageBuffer.i2c_addr = 0xE8; // Chip 1 - LED_pageBuffer.reg_addr = 0x24; // Brightness section - LED_sendPage( (uint8_t*)&LED_pageBuffer, sizeof( LED_Buffer ), 0 ); -} - -uint8_t LED_control_timer = 0; -void LED_control_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("LED_control_capability(mode,amount,index)"); - return; - } - - // Only use capability on press - // TODO Analog - if ( stateType == 0x00 && state == 0x03 ) // Not on release - return; - - // XXX - // ISSI Chip locks up if we spam updates too quickly (might be an I2C bug on this side too -HaaTa) - // Make sure we only send an update every 30 milliseconds at most - // It may be possible to optimize speed even further, but will likely require serious time with a logic analyzer - - uint8_t currentTime = (uint8_t)systick_millis_count; - int8_t compare = (int8_t)(currentTime - LED_control_timer) & 0x7F; - if ( compare < 30 ) - { - return; - } - LED_control_timer = currentTime; - - // Set the input structure - LedControl *control = (LedControl*)args; - - // Interconnect broadcasting -#if defined(ConnectEnabled_define) - uint8_t send_packet = 0; - uint8_t ignore_node = 0; - - // By default send to the *next* node, which will determine where to go next - extern uint8_t Connect_id; // connect_scan.c - uint8_t addr = Connect_id + 1; - - switch ( control->mode ) - { - // Calculate the led address to send - // If greater than the Total hannels - // Set address - Total channels - // Otherwise, ignore - case LedControlMode_brightness_decrease: - case LedControlMode_brightness_increase: - case LedControlMode_brightness_set: - // Ignore if led is on this node - if ( control->index < LED_TotalChannels ) - break; - - // Calculate new led index - control->index -= LED_TotalChannels; - - ignore_node = 1; - send_packet = 1; - break; - - // Broadcast to all nodes - // XXX Do not set broadcasting address - // Will send command twice - case LedControlMode_brightness_decrease_all: - case LedControlMode_brightness_increase_all: - case LedControlMode_brightness_set_all: - send_packet = 1; - break; - } - - // Only send interconnect remote capability packet if necessary - if ( send_packet ) - { - // generatedKeymap.h - extern const Capability CapabilitiesList[]; - - // Broadcast layerStackExact remote capability (0xFF is the broadcast id) - Connect_send_RemoteCapability( - addr, - LED_control_capability_index, - state, - stateType, - CapabilitiesList[ LED_control_capability_index ].argCount, - args - ); - } - - // If there is nothing to do on this node, ignore - if ( ignore_node ) - return; -#endif - - // Modify led state of this node - LED_control( control ); -} - - // ----- CLI Command Functions ----- -// TODO Currently not working correctly void cliFunc_i2cSend( char* args ) { char* curArgs; @@ -948,7 +717,6 @@ void cliFunc_i2cRecv( char* args ) I2C_Send( buffer, bufferLen, 1 ); // Only 1 byte is ever read at a time with the ISSI chip } -// TODO Currently not working correctly void cliFunc_ledRPage( char* args ) { // Parse number from argument @@ -962,14 +730,13 @@ void cliFunc_ledRPage( char* args ) if ( arg1Ptr[0] != '\0' ) { - page = (uint8_t)numToInt( arg1Ptr ); + page = (uint8_t)numToInt( arg1Ptr ); } // No \r\n by default after the command is entered print( NL ); - LED_readPage( 0x1, page ); - //LED_readPage( 0xB4, page ); + LED_readPage( 0xB4, page ); } void cliFunc_ledWPage( char* args ) @@ -1042,40 +809,3 @@ void cliFunc_ledZero( char* args ) LED_zeroPages( 0x00, 8, 0x24, 0xB4 ); // Only PWMs } -void cliFunc_ledCtrl( char* args ) -{ - char* curArgs; - char* arg1Ptr; - char* arg2Ptr = args; - LedControl control; - - // First process mode - curArgs = arg2Ptr; - CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr ); - - // Stop processing args if no more are found - if ( *arg1Ptr == '\0' ) - return; - control.mode = numToInt( arg1Ptr ); - - - // Next process amount - curArgs = arg2Ptr; - CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr ); - - // Stop processing args if no more are found - if ( *arg1Ptr == '\0' ) - return; - control.amount = numToInt( arg1Ptr ); - - - // Finally process led index, if it exists - // Default to 0 - curArgs = arg2Ptr; - CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr ); - control.index = *arg1Ptr == '\0' ? 0 : numToInt( arg1Ptr ); - - // Process request - LED_control( &control ); -} - diff --git a/Scan/ISSILed/led_scan.h b/Scan/ISSILed/led_scan.h index 545b8b9..71d8e80 100644 --- a/Scan/ISSILed/led_scan.h +++ b/Scan/ISSILed/led_scan.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* Copyright (C) 2014-2015 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 @@ -28,5 +28,3 @@ void LED_setup(); uint8_t LED_scan(); -void LED_currentChange( unsigned int current ); - diff --git a/Scan/KType/defaultMap.kll b/Scan/KType/defaultMap.kll deleted file mode 100644 index 3f9c632..0000000 --- a/Scan/KType/defaultMap.kll +++ /dev/null @@ -1,97 +0,0 @@ -Name = KType; -Version = 0.1; -Author = "HaaTa (Jacob Alexander) 2015"; -KLL = 0.3c; - -# Modified Date -Date = 2015-09-29; - - -S0x00 : U"Esc"; -S0x01 : U"F1"; -S0x02 : U"F2"; -S0x03 : U"F3"; -S0x04 : U"F4"; -S0x05 : U"F5"; -S0x06 : U"F6"; -S0x07 : U"F7"; -S0x08 : U"F8"; -S0x09 : U"F9"; -S0x0A : U"F10"; -S0x0B : U"F11"; -S0x0C : U"F12"; -S0x0D : U"PrintScreen"; -S0x0E : U"ScrollLock"; -S0x0F : U"Pause"; -S0x10 : U"Backtick"; -S0x11 : U"1"; -S0x12 : U"2"; -S0x13 : U"3"; -S0x14 : U"4"; -S0x15 : U"5"; -S0x16 : U"6"; -S0x17 : U"7"; -S0x18 : U"8"; -S0x19 : U"9"; -S0x1A : U"0"; -S0x1B : U"Minus"; -S0x1C : U"Equals"; -S0x1D : U"Backspace"; -S0x1E : U"Insert"; -S0x1F : U"Home"; -S0x20 : U"PageUp"; -S0x21 : U"Tab"; -S0x22 : U"Q"; -S0x23 : U"W"; -S0x24 : U"E"; -S0x25 : U"R"; -S0x26 : U"T"; -S0x27 : U"Y"; -S0x28 : U"U"; -S0x29 : U"I"; -S0x2A : U"O"; -S0x2B : U"P"; -S0x2C : U"LBrace"; -S0x2D : U"RBrace"; -S0x2E : U"Backslash"; -S0x2F : U"Delete"; -S0x30 : U"End"; -S0x31 : U"PageDown"; -S0x32 : U"CapsLock"; -S0x33 : U"A"; -S0x34 : U"S"; -S0x35 : U"D"; -S0x36 : U"F"; -S0x37 : U"G"; -S0x38 : U"H"; -S0x39 : U"J"; -S0x3A : U"K"; -S0x3B : U"L"; -S0x3C : U"Semicolon"; -S0x3D : U"Quote"; -S0x3E : U"Enter"; -S0x3F : U"LShift"; -S0x40 : U"Z"; -S0x41 : U"X"; -S0x42 : U"C"; -S0x43 : U"V"; -S0x44 : U"B"; -S0x45 : U"N"; -S0x46 : U"M"; -S0x47 : U"Comma"; -S0x48 : U"Period"; -S0x49 : U"Slash"; -S0x4A : U"RShift"; -S0x4B : U"Up"; -S0x4C : U"LCtrl"; -S0x4D : U"LGui"; -S0x4E : U"LAlt"; -S0x4F : U"Space"; -S0x50 : U"RAlt"; -S0x51 : U"RGui"; -S0x52 : U"Menu"; -S0x53 : U"RCtrl"; -S0x54 : U"Left"; -S0x55 : U"Down"; -S0x56 : U"Right"; - diff --git a/Scan/KType/matrix.h b/Scan/KType/matrix.h deleted file mode 100644 index 912a700..0000000 --- a/Scan/KType/matrix.h +++ /dev/null @@ -1,57 +0,0 @@ -/* 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) -// TODO -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/KType/scan_loop.c b/Scan/KType/scan_loop.c deleted file mode 100644 index 4e52706..0000000 --- a/Scan/KType/scan_loop.c +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (C) 2014-2016 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 -#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 UART Connect, if Output_Available, this is the master node - Connect_setup( Output_Available ); - - // 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 interconnect commands - Connect_scan(); - - // 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; -} - - -// 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 - Connect_currentChange( current ); - Matrix_currentChange( current ); - LED_currentChange( current ); -} - diff --git a/Scan/KType/scan_loop.h b/Scan/KType/scan_loop.h deleted file mode 100644 index b18a0ca..0000000 --- a/Scan/KType/scan_loop.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2014-2016 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(); -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 - diff --git a/Scan/KType/setup.cmake b/Scan/KType/setup.cmake deleted file mode 100644 index 50aef79..0000000 --- a/Scan/KType/setup.cmake +++ /dev/null @@ -1,32 +0,0 @@ -###| CMake Kiibohd Controller Scan Module |### -# -# Written by Jacob Alexander in 2015 for the Kiibohd Controller -# -# Released into the Public Domain -# -### - - -### -# Required Sub-modules -# -AddModule ( Scan ISSILed ) -AddModule ( Scan MatrixARM ) -AddModule ( Scan UARTConnect ) - - -### -# Module C files -# -set ( Module_SRCS - scan_loop.c -) - - -### -# Compiler Family Compatibility -# -set ( ModuleCompatibility - arm -) - diff --git a/Scan/MD1.1/defaultMap.kll b/Scan/MD1.1/defaultMap.kll deleted file mode 100644 index f60a4ed..0000000 --- a/Scan/MD1.1/defaultMap.kll +++ /dev/null @@ -1,134 +0,0 @@ -Name = MD1.1; -Version = 0.3d; -Author = "HaaTa (Jacob Alexander) 2014-2016"; -KLL = 0.3c; - -# Modified Date -Date = 2016-02-06; - - -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 - - -# Custom Action Examples - -# Example capability, prints to cli -action1 => CustomAction_action1_capability(); # No arguments - -# Blocks given USB Code, must be used with blockLink -# Simple example, supports only blocking a single key at a time -# Keys must be specified using numbers see Macro/PartialMap/usb_hid.h -blockHold => CustomAction_blockHold_capability( usbCode : 1 ); # Single 8-bit argument -blockKey => CustomAction_blockKey_capability( usbCode : 1 ); - - - -# Defines available to the MD1_1 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 */ - 0x7F, 0x00, /* C8-1 -> C8-16 */ - 0x00, 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, 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 */ -"; - diff --git a/Scan/MD1.1/matrix.h b/Scan/MD1.1/matrix.h deleted file mode 100644 index ca33a52..0000000 --- a/Scan/MD1.1/matrix.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2014-2016 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 - -// MD1 -// -// Columns (Strobe) -// PTB0..3,16,17 -// PTC4,5 -// PTD0 -// -// Rows (Sense) -// PTD1..7 - -// Define Rows (Sense) and Columns (Strobes) -GPIO_Pin Matrix_cols[] = { gpio(C,0), gpio(C,1), gpio(C,2), gpio(C,3), gpio(C,4), gpio(C,5), gpio(C,6), gpio(C,7), gpio(D,0) }; -GPIO_Pin Matrix_rows[] = { gpio(D,1), gpio(D,2), gpio(D,3), gpio(D,4), gpio(D,5), gpio(D,6), gpio(D,7) }; - -// Define type of scan matrix -Config Matrix_type = Config_Pulldown; - diff --git a/Scan/MD1.1/pinout b/Scan/MD1.1/pinout deleted file mode 100644 index 4b40fe9..0000000 --- a/Scan/MD1.1/pinout +++ /dev/null @@ -1,93 +0,0 @@ -Pin Usage -========= - -mk20dx128vlf5 - - ---- -|Keys| - ---- - -* Strobe (Columns) - -TODO - - -* Sense (Rows) - -PTD1 -PTD2 -PTD3 -PTD4 -PTD5 -PTD6 -PTD7 - - - --- -|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) - - - ----- -|Debug| - ----- - -* SWD - -PTA0 (Pull-down) -PTA3 (Pull-up) - -* LEDs - -PTA19 (LED only for PCB, not McHCK) (XTAL) - -* UARTs - -PTA1 - RX0 -PTA2 - TX0 - -* Tag Connect - -1 - Vdd +5 -2 - PTA3 / SWD_IO -3 - Vss / Gnd -4 - PTA0 / SWD_CLK -5 - +5V -6 - PTA2 / TRACE_SWO -7 - N/C -8 - PTA1 / JTAG_TDI -9 - N/C -10 - Reset_b - - - ------ -|Unused| - ------ - -* GPIO - -PTA1 (Not broken out on PCB, available on McHCK) (Pull-up) -PTA2 (") -PTA4 (Pull-up) -PTA18 (EXTAL) - -PTC0 -PTC1 -PTC2 -PTC3 -PTC6 -PTC7 - -* Analog - -ADC0_DP0 -ADC0_DM0 - - diff --git a/Scan/MD1.1/scan_loop.c b/Scan/MD1.1/scan_loop.c deleted file mode 100644 index 3b2bad1..0000000 --- a/Scan/MD1.1/scan_loop.c +++ /dev/null @@ -1,178 +0,0 @@ -/* Copyright (C) 2014-2016 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() -{ - 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; -} - - -// 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 ); - LED_currentChange( current ); -} - - - -// ----- Capabilities ----- - -// Custom capability examples -// Refer to kll.h in Macros/PartialMap for state and stateType information -void CustomAction_action1_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - // XXX This is required for debug cli to give you a list of capabilities - if ( stateType == 0xFF && state == 0xFF ) - { - print("CustomAction_action1_capability()"); - return; - } - - // Prints Action1 info message to the debug cli - info_print("Action1"); -} - -uint8_t CustomAction_blockHold_storage = 0; -void CustomAction_blockHold_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("CustomAction_blockHold_capability(usbCode)"); - return; - } - - // Retrieve 8-bit argument - uint8_t key = args[0]; - - // We only care about normal keys - if ( stateType == 0x00 ) - { - // Block given key if we're in the "Press" or "Hold" state - if ( ( state == 0x01 || state == 0x02 ) - && CustomAction_blockHold_storage == 0 ) - { - CustomAction_blockHold_storage = key; - info_msg("Blocking Key: "); - printHex( key ); - print( NL ); - } - // Release if in the "Off" or "Release" state and we're blocking - else if ( ( state == 0x00 || state == 0x03 ) - && key == CustomAction_blockHold_storage ) - { - info_msg("Unblocking Key: "); - printHex( CustomAction_blockHold_storage ); - print( NL ); - CustomAction_blockHold_storage = 0; - } - } -} - -void CustomAction_blockKey_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("CustomAction_blockKey_capability(usbCode)"); - return; - } - - // Retrieve 8-bit argument - uint8_t key = args[0]; - - // If key is not blocked, process - if ( key != CustomAction_blockHold_storage ) - { - extern void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ); - Output_usbCodeSend_capability( state, stateType, &key ); - } -} - diff --git a/Scan/MD1.1/scan_loop.h b/Scan/MD1.1/scan_loop.h deleted file mode 100644 index 339ede5..0000000 --- a/Scan/MD1.1/scan_loop.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2014-2016 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 - -void Scan_currentChange( unsigned int current ); // Called by Output Module - - -// ----- Capabilities ----- - -// Example capabilities -void CustomAction_action1_capability( uint8_t state, uint8_t stateType, uint8_t *args ); -void CustomAction_blockHold_capability( uint8_t state, uint8_t stateType, uint8_t *args ); -void CustomAction_blockKey_capability( uint8_t state, uint8_t stateType, uint8_t *args ); - diff --git a/Scan/MD1.1/setup.cmake b/Scan/MD1.1/setup.cmake deleted file mode 100644 index 5ca7607..0000000 --- a/Scan/MD1.1/setup.cmake +++ /dev/null @@ -1,33 +0,0 @@ -###| CMake Kiibohd Controller Scan Module |### -# -# Written by Jacob Alexander in 2014,2016 for the Kiibohd Controller -# -# Released into the Public Domain -# -### - - -### -# Required Submodules -# - -AddModule ( Scan ISSILed ) -AddModule ( Scan MatrixARM ) - - -### -# Module C files -# - -set ( Module_SRCS - scan_loop.c -) - - -### -# Compiler Family Compatibility -# -set ( ModuleCompatibility - arm -) - diff --git a/Scan/MD1/defaultMap.kll b/Scan/MD1/defaultMap.kll index b2eb8e5..c53aeac 100644 --- a/Scan/MD1/defaultMap.kll +++ b/Scan/MD1/defaultMap.kll @@ -1,10 +1,10 @@ Name = MD1; -Version = 0.3; -Author = "HaaTa (Jacob Alexander) 2014-2015"; -KLL = 0.3c; +Version = 0.2; +Author = "HaaTa (Jacob Alexander) 2014"; +KLL = 0.3; # Modified Date -Date = 2015-08-16; +Date = 2014-09-14; S0x00 : U"Esc"; @@ -71,15 +71,3 @@ S0x3C : U"RAlt"; S0x3D : U"Function3"; # Right Blank Key 1 S0x3E : U"Function4"; # Right Blank Key 2 - -# Custom Action Examples - -# Example capability, prints to cli -action1 => CustomAction_action1_capability(); # No arguments - -# Blocks given USB Code, must be used with blockLink -# Simple example, supports only blocking a single key at a time -# Keys must be specified using numbers see Macro/PartialMap/usb_hid.h -blockHold => CustomAction_blockHold_capability( usbCode : 1 ); # Single 8-bit argument -blockKey => CustomAction_blockKey_capability( usbCode : 1 ); - diff --git a/Scan/MD1/scan_loop.c b/Scan/MD1/scan_loop.c index d9348e1..f908f39 100644 --- a/Scan/MD1/scan_loop.c +++ b/Scan/MD1/scan_loop.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* Copyright (C) 2014 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 @@ -98,93 +98,6 @@ inline void Scan_finishedWithOutput( uint8_t sentKeys ) } - -// ----- Capabilities ----- - -// Custom capability examples -// Refer to kll.h in Macros/PartialMap for state and stateType information -void CustomAction_action1_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - // XXX This is required for debug cli to give you a list of capabilities - if ( stateType == 0xFF && state == 0xFF ) - { - print("CustomAction_action1_capability()"); - return; - } - - // Prints Action1 info message to the debug cli - info_print("Action1"); -} - -uint8_t CustomAction_blockHold_storage = 0; -void CustomAction_blockHold_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("CustomAction_blockHold_capability(usbCode)"); - return; - } - - // Retrieve 8-bit argument - uint8_t key = args[0]; - - // We only care about normal keys - if ( stateType == 0x00 ) - { - // Block given key if we're in the "Press" or "Hold" state - if ( ( state == 0x01 || state == 0x02 ) - && CustomAction_blockHold_storage == 0 ) - { - CustomAction_blockHold_storage = key; - info_msg("Blocking Key: "); - printHex( key ); - print( NL ); - } - // Release if in the "Off" or "Release" state and we're blocking - else if ( ( state == 0x00 || state == 0x03 ) - && key == CustomAction_blockHold_storage ) - { - info_msg("Unblocking Key: "); - printHex( CustomAction_blockHold_storage ); - print( NL ); - CustomAction_blockHold_storage = 0; - } - } -} - -void CustomAction_blockKey_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("CustomAction_blockKey_capability(usbCode)"); - return; - } - - // Retrieve 8-bit argument - uint8_t key = args[0]; - - // If key is not blocked, process - if ( key != CustomAction_blockHold_storage ) - { - extern void Output_usbCodeSend_capability( uint8_t state, uint8_t stateType, uint8_t *args ); - Output_usbCodeSend_capability( state, stateType, &key ); - } -} - - -// 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 ); -} - - - // ----- CLI Command Functions ----- // XXX Just an example command showing how to parse arguments (more complex than generally needed) diff --git a/Scan/MD1/scan_loop.h b/Scan/MD1/scan_loop.h index 339ede5..17a06fc 100644 --- a/Scan/MD1/scan_loop.h +++ b/Scan/MD1/scan_loop.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* 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 @@ -38,13 +38,3 @@ uint8_t Scan_loop( void ); 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 ----- - -// Example capabilities -void CustomAction_action1_capability( uint8_t state, uint8_t stateType, uint8_t *args ); -void CustomAction_blockHold_capability( uint8_t state, uint8_t stateType, uint8_t *args ); -void CustomAction_blockKey_capability( uint8_t state, uint8_t stateType, uint8_t *args ); - diff --git a/Scan/MDErgo1/leftHand.kll b/Scan/MDErgo1/leftHand.kll index a2b3a36..c814c55 100644 --- a/Scan/MDErgo1/leftHand.kll +++ b/Scan/MDErgo1/leftHand.kll @@ -1,4 +1,4 @@ -Name = MDErgo1 Left Hand; +Name = MDErgo1 Right Hand; Version = 0.1; Author = "HaaTa (Jacob Alexander) 2015"; KLL = 0.3c; @@ -8,22 +8,22 @@ Date = 2015-08-06; # Top Row -S0x02 : U"Esc"; +S0x02 : U"6"; S0x03 : U"5"; S0x04 : U"4"; S0x05 : U"3"; S0x06 : U"2"; S0x07 : U"1"; -S0x08 : U"Equals"; +S0x08 : U"Esc"; # Top-Middle Row -S0x0B : U"Function1"; +S0x0B : U"F4"; S0x0C : U"T"; S0x0D : U"R"; S0x0E : U"E"; S0x0F : U"W"; S0x10 : U"Q"; -S0x11 : U"Backslash"; +S0x11 : U"Tab"; # Middle Row S0x15 : U"G"; @@ -31,14 +31,14 @@ S0x16 : U"F"; S0x17 : U"D"; S0x18 : U"S"; S0x19 : U"A"; -S0x1A : U"Tab"; +S0x1A : U"Function1"; # Top Thumb Cluster -S0x1B : U"LAlt"; -S0x1C : U"LCtrl"; +S0x1B : U"Home"; +S0x1C : U"End"; # Bottom-Middle Row -S0x1D : U"Function2"; +S0x1D : U"F5"; S0x1E : U"B"; S0x1F : U"V"; S0x20 : U"C"; @@ -47,15 +47,15 @@ S0x22 : U"Z"; S0x23 : U"Left Shift"; # Bottom Thumb Cluster -S0x24 : U"Home"; -S0x25 : U"End"; +S0x24 : U"Left Alt"; +S0x25 : U"Left Ctrl"; S0x26 : U"Delete"; -S0x27 : U"Backspace"; +S0x27 : U"Space"; # Bottom Row S0x28 : U"Function5"; -S0x29 : U"Function4"; -S0x2A : U"Function3"; -S0x2B : U"Backtick"; -S0x2C : U"LGui"; +S0x29 : U"Backtick"; +S0x2A : U"Right Brace"; +S0x2B : U"Left Brace"; +S0x2C : U"Function3"; diff --git a/Scan/MDErgo1/leftThenRight.kll b/Scan/MDErgo1/leftThenRight.kll deleted file mode 100644 index baa3bed..0000000 --- a/Scan/MDErgo1/leftThenRight.kll +++ /dev/null @@ -1,117 +0,0 @@ -Name = MDErgo1 Left then Right; -Version = 0.1; -Author = "HaaTa (Jacob Alexander) 2015"; -KLL = 0.3c; - -# Modified Date -Date = 2015-09-12; - - -# Top Row -S0x02 : U"Esc"; -S0x03 : U"5"; -S0x04 : U"4"; -S0x05 : U"3"; -S0x06 : U"2"; -S0x07 : U"1"; -S0x08 : U"Equals"; - -# Top-Middle Row -S0x0B : U"Function1"; -S0x0C : U"T"; -S0x0D : U"R"; -S0x0E : U"E"; -S0x0F : U"W"; -S0x10 : U"Q"; -S0x11 : U"Backslash"; - -# Middle Row -S0x15 : U"G"; -S0x16 : U"F"; -S0x17 : U"D"; -S0x18 : U"S"; -S0x19 : U"A"; -S0x1A : U"Tab"; - -# Top Thumb Cluster -S0x1B : U"LAlt"; -S0x1C : U"LCtrl"; - -# Bottom-Middle Row -S0x1D : U"Function2"; -S0x1E : U"B"; -S0x1F : U"V"; -S0x20 : U"C"; -S0x21 : U"X"; -S0x22 : U"Z"; -S0x23 : U"LShift"; - -# Bottom Thumb Cluster -S0x24 : U"Home"; -S0x25 : U"End"; -S0x26 : U"Delete"; -S0x27 : U"Backspace"; - -# Bottom Row -S0x28 : U"Function5"; -S0x29 : U"Function4"; -S0x2A : U"Function3"; -S0x2B : U"Backtick"; -S0x2C : U"LGui"; - - -# Sets all future Scan Code definitions to be applied to the first slave node -ConnectId = 1; - -# Top Row -S0x02 : U"Function6"; -S0x03 : U"6"; -S0x04 : U"7"; -S0x05 : U"8"; -S0x06 : U"9"; -S0x07 : U"0"; -S0x08 : U"Minus"; - -# Top-Middle Row -S0x0B : U"LBrace"; -S0x0C : U"Y"; -S0x0D : U"U"; -S0x0E : U"I"; -S0x0F : U"O"; -S0x10 : U"P"; -S0x11 : U"RBrace"; - -# Middle Row -S0x15 : U"H"; -S0x16 : U"J"; -S0x17 : U"K"; -S0x18 : U"L"; -S0x19 : U"Semicolon"; -S0x1A : U"Quote"; - -# Top Thumb Cluster -S0x1B : U"RAlt"; -S0x1C : U"RCtrl"; - -# Bottom-Middle Row -S0x1D : U"Function7"; -S0x1E : U"N"; -S0x1F : U"M"; -S0x20 : U"Comma"; -S0x21 : U"Period"; -S0x22 : U"Slash"; -S0x23 : U"RShift"; - -# Bottom Thumb Cluster -S0x24 : U"PageUp"; -S0x25 : U"PageDown"; -S0x26 : U"Enter"; -S0x27 : U"Space"; - -# Bottom Row -S0x28 : U"Left"; -S0x29 : U"Down"; -S0x2A : U"Up"; -S0x2B : U"Right"; -S0x2C : U"RGui"; - diff --git a/Scan/MDErgo1/rightHand.kll b/Scan/MDErgo1/rightHand.kll index d31000e..840b696 100644 --- a/Scan/MDErgo1/rightHand.kll +++ b/Scan/MDErgo1/rightHand.kll @@ -8,22 +8,22 @@ Date = 2015-08-06; # Top Row -S0x02 : U"Function6"; -S0x03 : U"6"; -S0x04 : U"7"; -S0x05 : U"8"; -S0x06 : U"9"; -S0x07 : U"0"; -S0x08 : U"Minus"; +S0x02 : U"7"; +S0x03 : U"8"; +S0x04 : U"9"; +S0x05 : U"0"; +S0x06 : U"Minus"; +S0x07 : U"Equal"; +S0x08 : U"Backspace"; # Top-Middle Row -S0x0B : U"Left Brace"; +S0x0B : U"PageUp"; S0x0C : U"Y"; S0x0D : U"U"; S0x0E : U"I"; S0x0F : U"O"; S0x10 : U"P"; -S0x11 : U"Right Brace"; +S0x11 : U"BackSlash"; # Middle Row S0x15 : U"H"; @@ -34,11 +34,11 @@ S0x19 : U"Semicolon"; S0x1A : U"Quote"; # Top Thumb Cluster -S0x1B : U"RAlt"; -S0x1C : U"RCtrl"; +S0x1B : U"PrintScreen"; +S0x1C : U"Insert"; # Bottom-Middle Row -S0x1D : U"Function7"; +S0x1D : U"PageDown"; S0x1E : U"N"; S0x1F : U"M"; S0x20 : U"Comma"; @@ -47,15 +47,16 @@ S0x22 : U"Slash"; S0x23 : U"Right Shift"; # Bottom Thumb Cluster -S0x24 : U"PageUp"; -S0x25 : U"PageDown"; +S0x24 : U"Right Alt"; +S0x25 : U"Right Ctrl"; S0x26 : U"Enter"; -S0x27 : U"Space"; +S0x27 : U"Function2"; # Bottom Row S0x28 : U"Left"; S0x29 : U"Down"; S0x2A : U"Up"; S0x2B : U"Right"; -S0x2C : U"RGui"; +S0x2C : U"Function4"; + diff --git a/Scan/MDErgo1/scan_loop.c b/Scan/MDErgo1/scan_loop.c index e80119b..d5e97e5 100644 --- a/Scan/MDErgo1/scan_loop.c +++ b/Scan/MDErgo1/scan_loop.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* 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 @@ -102,15 +102,3 @@ inline void Scan_finishedWithOutput( uint8_t sentKeys ) 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 - Connect_currentChange( current ); - Matrix_currentChange( current ); - LED_currentChange( current ); - LCD_currentChange( current ); -} - diff --git a/Scan/MDErgo1/scan_loop.h b/Scan/MDErgo1/scan_loop.h index b18a0ca..17a06fc 100644 --- a/Scan/MDErgo1/scan_loop.h +++ b/Scan/MDErgo1/scan_loop.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* 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 @@ -31,12 +31,10 @@ // ----- Functions ----- // Functions to be called by main.c -void Scan_setup(); -uint8_t Scan_loop(); +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 -void Scan_currentChange( unsigned int current ); // Called by Output Module - diff --git a/Scan/MatrixARM/matrix_scan.c b/Scan/MatrixARM/matrix_scan.c index 7d8897b..8463b26 100644 --- a/Scan/MatrixARM/matrix_scan.c +++ b/Scan/MatrixARM/matrix_scan.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* 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 @@ -30,7 +30,6 @@ #include #include #include -#include // Local Includes #include "matrix_scan.h" @@ -52,7 +51,6 @@ nat_ptr_t Matrix_divCounter = 0; // CLI Functions void cliFunc_matrixDebug( char* args ); -void cliFunc_matrixInfo( char* args ); void cliFunc_matrixState( char* args ); @@ -61,12 +59,10 @@ void cliFunc_matrixState( char* args ); // 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 }; @@ -74,15 +70,6 @@ CLIDict_Def( matrixCLIDict, "Matrix Module Commands" ) = { // Debounce Array KeyState Matrix_scanArray[ Matrix_colsNum * Matrix_rowsNum ]; -// Ghost Arrays -#ifdef GHOSTING_MATRIX -KeyGhost Matrix_ghostArray[ Matrix_colsNum * Matrix_rowsNum ]; - -uint8_t col_use[Matrix_colsNum], row_use[Matrix_rowsNum]; // used count -uint8_t col_ghost[Matrix_colsNum], row_ghost[Matrix_rowsNum]; // marked as having ghost if 1 -#endif - - // Matrix debug flag - If set to 1, for each keypress the scan code is displayed in hex // If set to 2, for each key state change, the scan code is displayed along with the state uint8_t matrixDebugMode = 0; @@ -114,9 +101,7 @@ uint8_t Matrix_pin( GPIO_Pin gpio, Type type ) // Assumes 0x40 between GPIO Port registers and 0x1000 between PORT pin registers // See Lib/mk20dx.h volatile unsigned int *GPIO_PDDR = (unsigned int*)(&GPIOA_PDDR) + gpio_offset; - #ifndef GHOSTING_MATRIX volatile unsigned int *GPIO_PSOR = (unsigned int*)(&GPIOA_PSOR) + gpio_offset; - #endif volatile unsigned int *GPIO_PCOR = (unsigned int*)(&GPIOA_PCOR) + gpio_offset; volatile unsigned int *GPIO_PDIR = (unsigned int*)(&GPIOA_PDIR) + gpio_offset; volatile unsigned int *PORT_PCR = (unsigned int*)(&PORTA_PCR0) + port_offset; @@ -125,30 +110,16 @@ uint8_t Matrix_pin( GPIO_Pin gpio, Type type ) switch ( type ) { case Type_StrobeOn: - #ifdef GHOSTING_MATRIX - *GPIO_PCOR |= (1 << gpio.pin); - *GPIO_PDDR |= (1 << gpio.pin); // output, low - #else *GPIO_PSOR |= (1 << gpio.pin); - #endif break; case Type_StrobeOff: - #ifdef GHOSTING_MATRIX - // Ghosting martix needs to put not used (off) strobes in high impedance state - *GPIO_PDDR &= ~(1 << gpio.pin); // input, high Z state - #endif *GPIO_PCOR |= (1 << gpio.pin); break; case Type_StrobeSetup: - #ifdef GHOSTING_MATRIX - *GPIO_PDDR &= ~(1 << gpio.pin); // input, high Z state - *GPIO_PCOR |= (1 << gpio.pin); - #else // Set as output pin *GPIO_PDDR |= (1 << gpio.pin); - #endif // Configure pin with slow slew, high drive strength and GPIO mux *PORT_PCR = PORT_PCR_SRE | PORT_PCR_DSE | PORT_PCR_MUX(1); @@ -167,11 +138,7 @@ uint8_t Matrix_pin( GPIO_Pin gpio, Type type ) break; case Type_Sense: - #ifdef GHOSTING_MATRIX // inverted - return *GPIO_PDIR & (1 << gpio.pin) ? 0 : 1; - #else return *GPIO_PDIR & (1 << gpio.pin) ? 1 : 0; - #endif case Type_SenseSetup: // Set as input pin @@ -207,18 +174,29 @@ void Matrix_setup() // Register Matrix CLI dictionary CLI_registerDictionary( matrixCLIDict, matrixCLIDictName ); + info_msg("Columns: "); + printHex( Matrix_colsNum ); + // Setup Strobe Pins for ( uint8_t pin = 0; pin < Matrix_colsNum; pin++ ) { Matrix_pin( Matrix_cols[ pin ], Type_StrobeSetup ); } + print( NL ); + info_msg("Rows: "); + printHex( Matrix_rowsNum ); + // Setup Sense Pins for ( uint8_t pin = 0; pin < Matrix_rowsNum; pin++ ) { Matrix_pin( Matrix_rows[ pin ], Type_SenseSetup ); } + print( NL ); + info_msg("Max Keys: "); + printHex( Matrix_maxKeys ); + // Clear out Debounce Array for ( uint8_t item = 0; item < Matrix_maxKeys; item++ ) { @@ -227,11 +205,6 @@ void Matrix_setup() Matrix_scanArray[ item ].activeCount = 0; Matrix_scanArray[ item ].inactiveCount = DebounceDivThreshold_define; // Start at 'off' steady state Matrix_scanArray[ item ].prevDecisionTime = 0; - #ifdef GHOSTING_MATRIX - Matrix_ghostArray[ item ].prev = KeyState_Off; - Matrix_ghostArray[ item ].cur = KeyState_Off; - Matrix_ghostArray[ item ].saved = KeyState_Off; - #endif } // Clear scan stats counters @@ -299,19 +272,9 @@ void Matrix_scan( uint16_t scanNum ) // For each strobe, scan each of the sense pins for ( uint8_t strobe = 0; strobe < Matrix_colsNum; strobe++ ) { - #ifdef STROBE_DELAY - uint32_t start = micros(); - while ((micros() - start) < STROBE_DELAY); - #endif - // Strobe Pin Matrix_pin( Matrix_cols[ strobe ], Type_StrobeOn ); - #ifdef STROBE_DELAY - start = micros(); - while ((micros() - start) < STROBE_DELAY); - #endif - // Scan each of the sense pins for ( uint8_t sense = 0; sense < Matrix_rowsNum; sense++ ) { @@ -413,9 +376,7 @@ void Matrix_scan( uint16_t scanNum ) state->prevDecisionTime = currentTime; // Send keystate to macro module - #ifndef GHOSTING_MATRIX Macro_keyState( key, state->curState ); - #endif // Matrix Debug, only if there is a state change if ( matrixDebugMode && state->curState != state->prevState ) @@ -441,97 +402,6 @@ void Matrix_scan( uint16_t scanNum ) Matrix_pin( Matrix_cols[ strobe ], Type_StrobeOff ); } - - // Matrix ghosting check and elimination - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -#ifdef GHOSTING_MATRIX - // strobe = column, sense = row - - // Count (rows) use for columns - //print("C "); - for ( uint8_t col = 0; col < Matrix_colsNum; col++ ) - { - uint8_t used = 0; - for ( uint8_t row = 0; row < Matrix_rowsNum; row++ ) - { - uint8_t key = Matrix_colsNum * row + col; - KeyState *state = &Matrix_scanArray[ key ]; - if ( keyOn(state->curState) ) - used++; - } - //printInt8(used); - col_use[col] = used; - col_ghost[col] = 0; // clear - } - - // Count (columns) use for rows - //print(" R "); - for ( uint8_t row = 0; row < Matrix_rowsNum; row++ ) - { - uint8_t used = 0; - for ( uint8_t col = 0; col < Matrix_colsNum; col++ ) - { - uint8_t key = Matrix_colsNum * row + col; - KeyState *state = &Matrix_scanArray[ key ]; - if ( keyOn(state->curState) ) - used++; - } - //printInt8(used); - row_use[row] = used; - row_ghost[row] = 0; // clear - } - - // Check if matrix has ghost - // Happens when key is pressed and some other key is pressed in same row and another in same column - //print(" G "); - for ( uint8_t col = 0; col < Matrix_colsNum; col++ ) - { - for ( uint8_t row = 0; row < Matrix_rowsNum; row++ ) - { - uint8_t key = Matrix_colsNum * row + col; - KeyState *state = &Matrix_scanArray[ key ]; - if ( keyOn(state->curState) && col_use[col] >= 2 && row_use[row] >= 2 ) - { - // mark col and row as having ghost - col_ghost[col] = 1; - row_ghost[row] = 1; - //print(" "); printInt8(col); print(","); printInt8(row); - } - } - } - //print( NL ); - - // Send keys - for ( uint8_t col = 0; col < Matrix_colsNum; col++ ) - { - for ( uint8_t row = 0; row < Matrix_rowsNum; row++ ) - { - uint8_t key = Matrix_colsNum * row + col; - KeyState *state = &Matrix_scanArray[ key ]; - KeyGhost *st = &Matrix_ghostArray[ key ]; - - // col or row is ghosting (crossed) - uint8_t ghost = (col_ghost[col] > 0 || row_ghost[row] > 0) ? 1 : 0; - - st->prev = st->cur; // previous - // save state if no ghost or outside ghosted area - if ( ghost == 0 ) - st->saved = state->curState; // save state if no ghost - // final - // use saved state if ghosting, or current if not - st->cur = ghost > 0 ? st->saved : state->curState; - - // Send keystate to macro module - KeyPosition k = !st->cur - ? (!st->prev ? KeyState_Off : KeyState_Release) - : ( st->prev ? KeyState_Hold : KeyState_Press); - Macro_keyState( key, k ); - } - } -#endif - // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - - // State Table Output Debug if ( matrixDebugStateCounter > 0 ) { @@ -578,33 +448,9 @@ 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 ) -{ - print( NL ); - info_msg("Columns: "); - printHex( Matrix_colsNum ); - - print( NL ); - info_msg("Rows: "); - printHex( Matrix_rowsNum ); - - print( NL ); - info_msg("Max Keys: "); - printHex( Matrix_maxKeys ); -} - -void cliFunc_matrixDebug( char* args ) +void cliFunc_matrixDebug ( char* args ) { // Parse number from argument // NOTE: Only first argument is used @@ -638,7 +484,7 @@ void cliFunc_matrixDebug( char* args ) printInt8( matrixDebugMode ); } -void cliFunc_matrixState( char* args ) +void cliFunc_matrixState ( char* args ) { // Parse number from argument // NOTE: Only first argument is used diff --git a/Scan/MatrixARM/matrix_scan.h b/Scan/MatrixARM/matrix_scan.h index 3a8f0e2..810e6d9 100644 --- a/Scan/MatrixARM/matrix_scan.h +++ b/Scan/MatrixARM/matrix_scan.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* 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 @@ -139,18 +139,6 @@ typedef struct KeyState { uint8_t prevDecisionTime; } __attribute__((packed)) KeyState; -// Ghost Element, after ghost detection/cancelation -typedef struct KeyGhost { - KeyPosition prev; - KeyPosition cur; - KeyPosition saved; // state before ghosting -} __attribute__((packed)) KeyGhost; - -// utility -inline uint8_t keyOn(/*KeyPosition*/uint8_t st) -{ - return (st == KeyState_Press || st == KeyState_Hold) ? 1 : 0; -} // ----- Functions ----- @@ -158,5 +146,3 @@ inline uint8_t keyOn(/*KeyPosition*/uint8_t st) void Matrix_setup(); void Matrix_scan( uint16_t scanNum ); -void Matrix_currentChange( unsigned int current ); - diff --git a/Scan/STLcd/bitmap2Struct.py b/Scan/STLcd/bitmap2Struct.py index 6f2cbf1..dcf30c6 100755 --- a/Scan/STLcd/bitmap2Struct.py +++ b/Scan/STLcd/bitmap2Struct.py @@ -19,7 +19,7 @@ import sys from array import * -from PIL import Image # Use pillow instead of PIL, it works with Python 3 +from PIL import Image # Convenience class to deal with converting images to a C array @@ -110,10 +110,7 @@ class STLcdGraphic: return display -filename = sys.argv[1] -if filename is None: - print( "You must specify a bitmap filename. Try './bitmap2Struct.py ic_logo_lcd.bmp'" ) - sys.exit( 1 ) +filename = "ic_logo_lcd.bmp" max_height = 32 max_width = 128 x_offset = 0 diff --git a/Scan/STLcd/capabilities.kll b/Scan/STLcd/capabilities.kll index d5daaea..49319d2 100644 --- a/Scan/STLcd/capabilities.kll +++ b/Scan/STLcd/capabilities.kll @@ -63,15 +63,3 @@ STLcdDefaultImage = " 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, "; - -# Layer Status Display - -LCDLayerDisplay => LCD_layerStack_capability(); -LCDLayerDisplayExact => LCD_layerStackExact_capability( display : 1, stack1 : 2, stack2 : 2, stack3 : 2, stack4 : 2 ); - - -# LCD Module Enabled - -LCDEnabled => LCDEnabled_define; -LCDEnabled = 1; - diff --git a/Scan/STLcd/exampleAPI.bash b/Scan/STLcd/exampleAPI.bash deleted file mode 100755 index ae470b3..0000000 --- a/Scan/STLcd/exampleAPI.bash +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -# STLcd -# Virtual Serial Port API Example -# Jacob Alexander 2015 - -if [ $# -eq 0 ]; then - echo "You must specify your virtual serialport. (/dev/ttyACM0 on linux, /dev/cu.usbmodemXXXX on OSX)" - echo " ex: $0 /dev/ttyACM0" - exit 1 -fi -# XXX Set this to match your virtual serialport -# TODO Show example for Cygwin/Windows -# For Mac OSX it will be something like /dev/cu.usbmodem1413 (number may differ) -SERIALPORT=$1 - -# NOTE: Make sure you don't write too quickly to the serial port, it can get overwhelmed by a modern computer -# Generally this just means commands will get ignored -# I'm using 100 ms sleeps here, but much smaller are probably sufficient - -# Clear out cli buffer -printf "\r" > $SERIALPORT - -# Change backlight color -# 3 16-bit numbers (hex or decimal) Red, Green and Blue -sleep 0.1 -printf "lcdColor 0x100 0x2000 0x4000\r" > $SERIALPORT # Light blue - -# Change the lcd image -# Arguments: -# - page -# - starting address -# - pixels (1 bit per pixel) -# -# There are 9 total pages of display memory, but only 4 are visable at time (it is possible to scroll though) -# Each page is 128 bits wide (16 bytes) -# See the datasheet for full details http://www.newhavendisplay.com/specs/NHD-C12832A1Z-FSRGB-FBW-3V.pdf -sleep 0.1 -printf "lcdDisp 0x0 0x0 0xFF 0x13 0xFF 0x11 0xFF\r" > $SERIALPORT -sleep 0.1 -printf "lcdDisp 0x1 0x10 0xFF 0x13 0xFF 0x11 0xFF 0x44\r" > $SERIALPORT -sleep 0.1 -printf "lcdDisp 0x2 0x20 0xFF 0x13 0xFF 0x11 0xFF\r" > $SERIALPORT -sleep 0.1 -printf "lcdDisp 0x3 0x30 0xFF 0x13 0xFF 0x11 0xFF\r" > $SERIALPORT - -# Send command directly to the lcd -# See the datasheet for full details http://www.newhavendisplay.com/specs/NHD-C12832A1Z-FSRGB-FBW-3V.pdf -sleep 0.1 -printf "lcdCmd 0xA7\r" > $SERIALPORT # Reverse display (0xA6 is Normal) - diff --git a/Scan/STLcd/lcd_scan.c b/Scan/STLcd/lcd_scan.c index 1dd9126..a7d7d44 100644 --- a/Scan/STLcd/lcd_scan.c +++ b/Scan/STLcd/lcd_scan.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2015-2016 by Jacob Alexander +/* Copyright (C) 2015 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 @@ -25,11 +25,6 @@ #include #include -// Interconnect module if compiled in -#if defined(ConnectEnabled_define) -#include -#endif - // Local Includes #include "lcd_scan.h" @@ -346,186 +341,6 @@ inline uint8_t LCD_scan() } -// Signal from parent Scan Module that available current has changed -// current - mA -void LCD_currentChange( unsigned int current ) -{ - // TODO - Power savings? -} - - - -// ----- Capabilities ----- - -// Takes 1 8 bit length and 4 16 bit arguments, each corresponding to a layer index -// Ordered from top to bottom -// The first argument indicates how many numbers to display (max 4), set to 0 to load default image -uint16_t LCD_layerStackExact[4]; -uint8_t LCD_layerStackExact_size = 0; -typedef struct LCD_layerStackExact_args { - uint8_t numArgs; - uint16_t layers[4]; -} LCD_layerStackExact_args; -void LCD_layerStackExact_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("LCD_layerStackExact_capability(num,layer1,layer2,layer3,layer4)"); - return; - } - - // Read arguments - LCD_layerStackExact_args *stack_args = (LCD_layerStackExact_args*)args; - - // Number data for LCD - const uint8_t numbers[10][128] = { - { STLcdNumber0_define }, - { STLcdNumber1_define }, - { STLcdNumber2_define }, - { STLcdNumber3_define }, - { STLcdNumber4_define }, - { STLcdNumber5_define }, - { STLcdNumber6_define }, - { STLcdNumber7_define }, - { STLcdNumber8_define }, - { STLcdNumber9_define }, - }; - - // Color data for numbers - const uint16_t colors[10][3] = { - { STLcdNumber0Color_define }, - { STLcdNumber1Color_define }, - { STLcdNumber2Color_define }, - { STLcdNumber3Color_define }, - { STLcdNumber4Color_define }, - { STLcdNumber5Color_define }, - { STLcdNumber6Color_define }, - { STLcdNumber7Color_define }, - { STLcdNumber8Color_define }, - { STLcdNumber9Color_define }, - }; - - // Only display if there are layers active - if ( stack_args->numArgs > 0 ) - { - // Set the color according to the "top-of-stack" layer - uint16_t layerIndex = stack_args->layers[0]; - FTM0_C0V = colors[ layerIndex ][0]; - FTM0_C1V = colors[ layerIndex ][1]; - FTM0_C2V = colors[ layerIndex ][2]; - - // Iterate through each of the pages - // XXX Many of the values here are hard-coded - // Eventually a proper font rendering engine should take care of things like this... -HaaTa - for ( uint8_t page = 0; page < LCD_TOTAL_VISIBLE_PAGES; page++ ) - { - // Set the register page - LCD_writeControlReg( 0xB0 | ( 0x0F & page ) ); - - // Set starting address - LCD_writeControlReg( 0x10 ); - LCD_writeControlReg( 0x00 ); - - // Write data - for ( uint16_t layer = 0; layer < stack_args->numArgs; layer++ ) - { - layerIndex = stack_args->layers[ layer ]; - - // Default to 0, if over 9 - if ( layerIndex > 9 ) - { - layerIndex = 0; - } - - // Write page of number to display - SPI_write( (uint8_t*)&numbers[ layerIndex ][ page * 32 ], 32 ); - } - - // Blank out rest of display - uint8_t data = 0; - for ( uint8_t c = 0; c < 4 - stack_args->numArgs; c++ ) - { - for ( uint8_t byte = 0; byte < 32; byte++ ) - { - SPI_write( &data, 1 ); - } - } - } - } - else - { - // Set default backlight - FTM0_C0V = STLcdBacklightRed_define; - FTM0_C1V = STLcdBacklightGreen_define; - FTM0_C2V = STLcdBacklightBlue_define; - - // Write default image - for ( uint8_t page = 0; page < LCD_TOTAL_VISIBLE_PAGES; page++ ) - LCD_writeDisplayReg( page, (uint8_t *)&STLcdDefaultImage[page * LCD_PAGE_LEN], LCD_PAGE_LEN ); - } -} - -// Determines the current layer stack, and sets the LCD output accordingly -// Will only work on a master node when using the interconnect (use LCD_layerStackExact_capability instead) -uint16_t LCD_layerStack_prevSize = 0; -uint16_t LCD_layerStack_prevTop = 0; -void LCD_layerStack_capability( uint8_t state, uint8_t stateType, uint8_t *args ) -{ - // Display capability name - if ( stateType == 0xFF && state == 0xFF ) - { - print("LCD_layerStack_capability()"); - return; - } - - // Parse the layer stack, top to bottom - extern uint16_t macroLayerIndexStack[]; - extern uint16_t macroLayerIndexStackSize; - - // Ignore if the stack size hasn't changed and the top of the stack is the same - if ( macroLayerIndexStackSize == LCD_layerStack_prevSize - && macroLayerIndexStack[macroLayerIndexStackSize - 1] == LCD_layerStack_prevTop ) - { - return; - } - LCD_layerStack_prevSize = macroLayerIndexStackSize; - LCD_layerStack_prevTop = macroLayerIndexStack[macroLayerIndexStackSize - 1]; - - LCD_layerStackExact_args stack_args; - memset( stack_args.layers, 0, sizeof( stack_args.layers ) ); - - // Use the LCD_layerStackExact_capability to set the LCD using the determined stack - // Construct argument set for capability - stack_args.numArgs = macroLayerIndexStackSize; - for ( uint16_t layer = 1; layer <= macroLayerIndexStackSize; layer++ ) - { - stack_args.layers[ layer - 1 ] = macroLayerIndexStack[ macroLayerIndexStackSize - layer ]; - } - - // Only deal with the interconnect if it has been compiled in -#if defined(ConnectEnabled_define) - if ( Connect_master ) - { - // generatedKeymap.h - extern const Capability CapabilitiesList[]; - - // Broadcast layerStackExact remote capability (0xFF is the broadcast id) - Connect_send_RemoteCapability( - 0xFF, - LCD_layerStackExact_capability_index, - state, - stateType, - CapabilitiesList[ LCD_layerStackExact_capability_index ].argCount, - (uint8_t*)&stack_args - ); - } -#endif - // Call LCD_layerStackExact directly - LCD_layerStackExact_capability( state, stateType, (uint8_t*)&stack_args ); -} - - // ----- CLI Command Functions ----- diff --git a/Scan/STLcd/lcd_scan.h b/Scan/STLcd/lcd_scan.h index 096107b..36884a2 100644 --- a/Scan/STLcd/lcd_scan.h +++ b/Scan/STLcd/lcd_scan.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015-2016 by Jacob Alexander +/* Copyright (C) 2015 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 @@ -28,5 +28,3 @@ void LCD_setup(); uint8_t LCD_scan(); -void LCD_currentChange( unsigned int current ); - diff --git a/Scan/STLcd/numbers/0.bmp b/Scan/STLcd/numbers/0.bmp deleted file mode 100644 index 9eb7e67..0000000 Binary files a/Scan/STLcd/numbers/0.bmp and /dev/null differ diff --git a/Scan/STLcd/numbers/1.bmp b/Scan/STLcd/numbers/1.bmp deleted file mode 100644 index c203d1a..0000000 Binary files a/Scan/STLcd/numbers/1.bmp and /dev/null differ diff --git a/Scan/STLcd/numbers/2.bmp b/Scan/STLcd/numbers/2.bmp deleted file mode 100644 index 07b5e85..0000000 Binary files a/Scan/STLcd/numbers/2.bmp and /dev/null differ diff --git a/Scan/STLcd/numbers/3.bmp b/Scan/STLcd/numbers/3.bmp deleted file mode 100644 index 7ec47ce..0000000 Binary files a/Scan/STLcd/numbers/3.bmp and /dev/null differ diff --git a/Scan/STLcd/numbers/4.bmp b/Scan/STLcd/numbers/4.bmp deleted file mode 100644 index bd3bc5f..0000000 Binary files a/Scan/STLcd/numbers/4.bmp and /dev/null differ diff --git a/Scan/STLcd/numbers/5.bmp b/Scan/STLcd/numbers/5.bmp deleted file mode 100644 index 545747f..0000000 Binary files a/Scan/STLcd/numbers/5.bmp and /dev/null differ diff --git a/Scan/STLcd/numbers/6.bmp b/Scan/STLcd/numbers/6.bmp deleted file mode 100644 index 5f7a3c1..0000000 Binary files a/Scan/STLcd/numbers/6.bmp and /dev/null differ diff --git a/Scan/STLcd/numbers/7.bmp b/Scan/STLcd/numbers/7.bmp deleted file mode 100644 index 24d5597..0000000 Binary files a/Scan/STLcd/numbers/7.bmp and /dev/null differ diff --git a/Scan/STLcd/numbers/8.bmp b/Scan/STLcd/numbers/8.bmp deleted file mode 100644 index eaf2c52..0000000 Binary files a/Scan/STLcd/numbers/8.bmp and /dev/null differ diff --git a/Scan/STLcd/numbers/9.bmp b/Scan/STLcd/numbers/9.bmp deleted file mode 100644 index 1a0bcdc..0000000 Binary files a/Scan/STLcd/numbers/9.bmp and /dev/null differ diff --git a/Scan/UARTConnect/capabilities.kll b/Scan/UARTConnect/capabilities.kll index bab1b61..b907221 100644 --- a/Scan/UARTConnect/capabilities.kll +++ b/Scan/UARTConnect/capabilities.kll @@ -26,11 +26,9 @@ UARTConnectBaudFine => UARTConnectBaudFine_define; # Thus baud setting = 26 # NOTE: If finer baud adjustment is needed see UARTx_C4 -> BRFA in the datasheet # Baud fine setting = 0x02 -UARTConnectBaud = 1; # 4.5 Mbpsa @ 72 MHz +UARTConnectBaud = 1; # 4.5 Mbps @ 72 MHz UARTConnectBaudFine = 0x0; -#UARTConnectBaud = 39; # 115385 bps @ 72 MHz (close to 115200) - # Cable Check Command Length # This defines the length of the cable command # 0xD2 11010010 is used for each check byte diff --git a/Scan/UARTConnect/connect_scan.c b/Scan/UARTConnect/connect_scan.c index 4c56c3c..8b647ac 100644 --- a/Scan/UARTConnect/connect_scan.c +++ b/Scan/UARTConnect/connect_scan.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* Copyright (C) 2014-2015 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 @@ -31,16 +31,44 @@ -// ----- Defines ----- +// ----- Macros ----- -#define UART_Num_Interfaces 2 #define UART_Master 1 #define UART_Slave 0 -#define UART_Buffer_Size UARTConnectBufSize_define +#define uart_lock_m( uartNum ) uart##uartNum##_lock +#define uart_buffer_items_m( uartNum ) uart##uartNum##_buffer_items +#define uart_buffer_m( uartNum ) uart##uartNum##_buffer +#define uart_buffer_head_m( uartNum ) uart##uartNum##_buffer_head +#define uart_buffer_tail_m( uartNum ) uart##uartNum##_buffer_tail +#define uart_tx_status_m( uartNum ) uart##uartNum##_tx_status - - -// ----- Macros ----- +// Macro for adding to each uart Tx ring buffer +#define uart_addTxBuffer( uartNum ) \ +case uartNum: \ + /* Delay UART copy until there's some space left */ \ + while ( uart_buffer_items_m( uartNum ) + count > uart_buffer_size ) \ + { \ + warn_msg("Too much data to send on UART0, waiting..."); \ + delay( 1 ); \ + } \ + /* Append data to ring buffer */ \ + for ( uint8_t c = 0; c < count; c++ ) \ + { \ + if ( Connect_debug ) \ + { \ + printHex( buffer[ c ] ); \ + print( " +" #uartNum NL ); \ + } \ + uart_buffer_m( uartNum )[ uart_buffer_tail_m( uartNum )++ ] = buffer[ c ]; \ + uart_buffer_items_m( uartNum )++; \ + if ( uart_buffer_tail_m( uartNum ) >= uart_buffer_size ) \ + uart_buffer_tail_m( uartNum ) = 0; \ + if ( uart_buffer_head_m( uartNum ) == uart_buffer_tail_m( uartNum ) ) \ + uart_buffer_head_m( uartNum )++; \ + if ( uart_buffer_head_m( uartNum ) >= uart_buffer_size ) \ + uart_buffer_head_m( uartNum ) = 0; \ + } \ + break // Macro for popping from Tx ring buffer #define uart_fillTxFifo( uartNum ) \ @@ -55,7 +83,7 @@ print("/"); \ printHex( UART##uartNum##_TCFIFO ); \ print("/"); \ - printHex( uart_tx_buf[ uartNum ].items ); \ + printHex( uart##uartNum##_buffer_items ); \ print( NL ); \ } \ /* XXX Doesn't work well */ \ @@ -64,12 +92,138 @@ fifoSize -= UART##uartNum##_TCFIFO; \ while ( fifoSize-- != 0 ) \ { \ - if ( uart_tx_buf[ uartNum ].items == 0 ) \ + if ( uart##uartNum##_buffer_items == 0 ) \ break; \ - UART##uartNum##_D = uart_tx_buf[ uartNum ].buffer[ uart_tx_buf[ uartNum ].head++ ]; \ - uart_tx_buf[ uartNum ].items--; \ - if ( uart_tx_buf[ uartNum ].head >= UART_Buffer_Size ) \ - uart_tx_buf[ uartNum ].head = 0; \ + UART##uartNum##_D = uart##uartNum##_buffer[ uart##uartNum##_buffer_head++ ]; \ + uart##uartNum##_buffer_items--; \ + if ( uart##uartNum##_buffer_head >= uart_buffer_size ) \ + uart##uartNum##_buffer_head = 0; \ + } \ +} + +// Macro for processing UART Rx +#define uart_processRx( uartNum ) \ +{ \ + if ( !( UART##uartNum##_S1 & UART_S1_RDRF ) ) \ + return; \ + uint8_t available = UART##uartNum##_RCFIFO; \ + if ( available == 0 ) \ + { \ + available = UART##uartNum##_D; \ + UART##uartNum##_CFIFO = UART_CFIFO_RXFLUSH; \ + return; \ + } \ + /* Process each byte in the UART buffer */ \ + while ( available-- > 0 ) \ + { \ + /* First check if there was noise or Parity issues with current byte */ \ + uint8_t err_status = UART##uartNum##_ED; \ + /* Read byte from Rx FIFO */ \ + uint8_t byteRead = UART##uartNum##_D; \ + if ( Connect_debug ) \ + { \ + printHex( byteRead ); \ + print("("); \ + printInt8( available ); \ + print(") <-"); \ + } \ + /* Check error status */ \ + if ( err_status & 0x80 ) \ + { \ + print(" NOISY "); \ + } \ + if ( err_status & 0x40 ) \ + { \ + print(" PARITY ERR "); \ + } \ + /* Ignore current byte if there was an error */ \ + if ( err_status ) \ + { \ + uart##uartNum##_rx_status = UARTStatus_Wait; \ + if ( Connect_debug ) \ + { \ + print( NL ); \ + } \ + continue; \ + } \ + switch ( uart##uartNum##_rx_status ) \ + { \ + case UARTStatus_Wait: \ + if ( Connect_debug ) \ + { \ + print(" Wait "); \ + } \ + uart##uartNum##_rx_status = byteRead == 0x16 ? UARTStatus_SYN : UARTStatus_Wait; \ + break; \ + case UARTStatus_SYN: \ + if ( Connect_debug ) \ + { \ + print(" SYN "); \ + } \ + uart##uartNum##_rx_status = byteRead == 0x01 ? UARTStatus_SOH : UARTStatus_Wait; \ + break; \ + case UARTStatus_SOH: \ + { \ + if ( Connect_debug ) \ + { \ + print(" SOH "); \ + } \ + /* Check if this is actually a reserved CMD 0x16 */ \ + if ( byteRead == Command_SYN ) \ + { \ + uart##uartNum##_rx_status = UARTStatus_SYN; \ + break; \ + } \ + /* Otherwise process the command */ \ + uint8_t byte = byteRead; \ + if ( byte < Command_TOP ) \ + { \ + uart##uartNum##_rx_status = UARTStatus_Command; \ + uart##uartNum##_rx_command = byte; \ + uart##uartNum##_rx_bytes_waiting = 0xFFFF; \ + } \ + else \ + { \ + uart##uartNum##_rx_status = UARTStatus_Wait; \ + } \ + switch ( uart##uartNum##_rx_command ) \ + { \ + case IdRequest: \ + Connect_receive_IdRequest( 0, (uint16_t*)&uart##uartNum##_rx_bytes_waiting, uartNum ); \ + uart##uartNum##_rx_status = UARTStatus_Wait; \ + break; \ + default: \ + if ( Connect_debug ) \ + { \ + print(" ### "); \ + printHex( uart##uartNum##_rx_command ); \ + } \ + break; \ + } \ + break; \ + } \ + case UARTStatus_Command: \ + { \ + if ( Connect_debug ) \ + { \ + print(" CMD "); \ + } \ + /* Call specific UARTConnect command receive function */ \ + uint8_t (*rcvFunc)(uint8_t, uint16_t(*), uint8_t) = (uint8_t(*)(uint8_t, uint16_t(*), uint8_t))(Connect_receiveFunctions[ uart##uartNum##_rx_command ]); \ + if ( rcvFunc( byteRead, (uint16_t*)&uart##uartNum##_rx_bytes_waiting, uartNum ) ) \ + uart##uartNum##_rx_status = UARTStatus_Wait; \ + break; \ + } \ + default: \ + erro_msg("Invalid UARTStatus..."); \ + uart##uartNum##_rx_status = UARTStatus_Wait; \ + available++; \ + continue; \ + } \ + if ( Connect_debug ) \ + { \ + print( NL ); \ + } \ } \ } @@ -77,31 +231,31 @@ #define uart_lockTx( uartNum ) \ { \ /* First, secure place in line for the resource */ \ - while ( uart_tx_status[ uartNum ].lock ); \ - uart_tx_status[ uartNum ].lock = 1; \ + while ( uart_lock_m( uartNum ) ); \ + uart_lock_m( uartNum ) = 1; \ /* Next, wait unit the UART is ready */ \ - while ( uart_tx_status[ uartNum ].status != UARTStatus_Ready ); \ - uart_tx_status[ uartNum ].status = UARTStatus_Wait; \ + while ( uart_tx_status_m( uartNum ) != UARTStatus_Ready ); \ + uart_tx_status_m( uartNum ) = UARTStatus_Wait; \ } #define uart_lockBothTx( uartNum1, uartNum2 ) \ { \ /* First, secure place in line for the resource */ \ - while ( uart_tx_status[ uartNum1 ].lock || uart_tx_status[ uartNum2 ].lock ); \ - uart_tx_status[ uartNum1 ].lock = 1; \ - uart_tx_status[ uartNum2 ].lock = 1; \ + while ( uart_lock_m( uartNum1 ) || uart_lock_m( uartNum2 ) ); \ + uart_lock_m( uartNum1 ) = 1; \ + uart_lock_m( uartNum2 ) = 1; \ /* Next, wait unit the UARTs are ready */ \ - while ( uart_tx_status[ uartNum1 ].status != UARTStatus_Ready || uart_tx_status[ uartNum2 ].status != UARTStatus_Ready ); \ - uart_tx_status[ uartNum1 ].status = UARTStatus_Wait; \ - uart_tx_status[ uartNum2 ].status = UARTStatus_Wait; \ + while ( uart_tx_status_m( uartNum1 ) != UARTStatus_Ready || uart_tx_status_m( uartNum2 ) != UARTStatus_Ready ); \ + uart_tx_status_m( uartNum1 ) = UARTStatus_Wait; \ + uart_tx_status_m( uartNum2 ) = UARTStatus_Wait; \ } #define uart_unlockTx( uartNum ) \ { \ /* Ready the UART */ \ - uart_tx_status[ uartNum ].status = UARTStatus_Ready; \ + uart_tx_status_m( uartNum ) = UARTStatus_Ready; \ /* Unlock the resource */ \ - uart_tx_status[ uartNum ].lock = 0; \ + uart_lock_m( uartNum ) = 0; \ } @@ -119,33 +273,6 @@ void cliFunc_connectSts ( char *args ); -// ----- Structs ----- - -typedef struct UARTRingBuf { - uint8_t head; - uint8_t tail; - uint8_t items; - uint8_t buffer[UART_Buffer_Size]; -} UARTRingBuf; - -typedef struct UARTDMABuf { - uint8_t buffer[UART_Buffer_Size]; - uint16_t last_read; -} UARTDMABuf; - -typedef struct UARTStatusRx { - UARTStatus status; - Command command; - uint16_t bytes_waiting; -} UARTStatusRx; - -typedef struct UARTStatusTx { - UARTStatus status; - uint8_t lock; -} UARTStatusTx; - - - // ----- Variables ----- // Connect Module command dictionary @@ -179,67 +306,59 @@ uint32_t Connect_lastCheck = 0; // Cable Check scheduler uint8_t Connect_debug = 0; // Set 1 for debug uint8_t Connect_override = 0; // Prevents master from automatically being set + +// -- Rx Status Variables -- + +volatile UARTStatus uart0_rx_status; +volatile UARTStatus uart1_rx_status; +volatile uint16_t uart0_rx_bytes_waiting; +volatile uint16_t uart1_rx_bytes_waiting; +volatile Command uart0_rx_command; +volatile Command uart1_rx_command; +volatile uint8_t uart0_lock; +volatile uint8_t uart1_lock; + + +// -- Tx Status Variables -- + +volatile UARTStatus uart0_tx_status; +volatile UARTStatus uart1_tx_status; + + +// -- Ring Buffer Variables -- + +#define uart_buffer_size UARTConnectBufSize_define +volatile uint8_t uart0_buffer_head; +volatile uint8_t uart0_buffer_tail; +volatile uint8_t uart0_buffer_items; +volatile uint8_t uart0_buffer[uart_buffer_size]; +volatile uint8_t uart1_buffer_head; +volatile uint8_t uart1_buffer_tail; +volatile uint8_t uart1_buffer_items; +volatile uint8_t uart1_buffer[uart_buffer_size]; + volatile uint8_t uarts_configured = 0; -// -- Rx Variables -- - -volatile UARTDMABuf uart_rx_buf[UART_Num_Interfaces]; -volatile UARTStatusRx uart_rx_status[UART_Num_Interfaces]; - - -// -- Tx Variables -- - -UARTRingBuf uart_tx_buf [UART_Num_Interfaces]; -UARTStatusTx uart_tx_status[UART_Num_Interfaces]; - - // -- Ring Buffer Convenience Functions -- void Connect_addBytes( uint8_t *buffer, uint8_t count, uint8_t uart ) { // Too big to fit into buffer - if ( count > UART_Buffer_Size ) + if ( count > uart_buffer_size ) { erro_msg("Too big of a command to fit into the buffer..."); return; } - // Invalid UART - if ( uart >= UART_Num_Interfaces ) + // Choose the uart + switch ( uart ) { - erro_print("Invalid UART to send from..."); - return; - } - - // Delay UART copy until there's some space left - while ( uart_tx_buf[ uart ].items + count > UART_Buffer_Size ) - { - warn_msg("Too much data to send on UART"); - printInt8( uart ); - print( ", waiting..." NL ); - delay( 1 ); - } - - // Append data to ring buffer - for ( uint8_t c = 0; c < count; c++ ) - { - if ( Connect_debug ) - { - printHex( buffer[ c ] ); - print(" +"); - printInt8( uart ); - print( NL ); - } - - uart_tx_buf[ uart ].buffer[ uart_tx_buf[ uart ].tail++ ] = buffer[ c ]; - uart_tx_buf[ uart ].items++; - if ( uart_tx_buf[ uart ].tail >= UART_Buffer_Size ) - uart_tx_buf[ uart ].tail = 0; - if ( uart_tx_buf[ uart ].head == uart_tx_buf[ uart ].tail ) - uart_tx_buf[ uart ].head++; - if ( uart_tx_buf[ uart ].head >= UART_Buffer_Size ) - uart_tx_buf[ uart ].head = 0; + uart_addTxBuffer( UART_Master ); + uart_addTxBuffer( UART_Slave ); + default: + erro_msg("Invalid UART to send from..."); + break; } } @@ -361,51 +480,6 @@ void Connect_send_Animation( uint8_t id, uint8_t *paramList, uint8_t numParams ) uart_unlockTx( UART_Slave ); } -// Send a remote capability command using capability index -// This may not be what's expected (especially if the firmware is not the same on each node) -// To broadcast to all slave nodes, set id to 255 instead of a specific id -void Connect_send_RemoteCapability( uint8_t id, uint8_t capabilityIndex, uint8_t state, uint8_t stateType, uint8_t numArgs, uint8_t *args ) -{ - // Prepare header - uint8_t header[] = { 0x16, 0x01, RemoteCapability, id, capabilityIndex, state, stateType, numArgs }; - - // Ignore current id - if ( id == Connect_id ) - return; - - // Send towards slave node - if ( id > Connect_id ) - { - // Lock slave bound Tx - uart_lockTx( UART_Slave ); - - // Send header - Connect_addBytes( header, sizeof( header ), UART_Slave ); - - // Send arguments - Connect_addBytes( args, numArgs, UART_Slave ); - - // Unlock Tx - uart_unlockTx( UART_Slave ); - } - - // Send towards master node - if ( id < Connect_id || id == 255 ) - { - // Lock slave bound Tx - uart_lockTx( UART_Master ); - - // Send header - Connect_addBytes( header, sizeof( header ), UART_Master ); - - // Send arguments - Connect_addBytes( args, numArgs, UART_Master ); - - // Unlock Tx - uart_unlockTx( UART_Master ); - } -} - void Connect_send_Idle( uint8_t num ) { // Wait until the Tx buffers are ready, then lock them @@ -470,14 +544,6 @@ uint8_t Connect_receive_CableCheck( uint8_t byte, uint16_t *pending_bytes, uint8 } else { - // Lower current requirement during errors - // USB minimum - // Only if this is not the master node - if ( Connect_id != 0 ) - { - Output_update_external_current( 100 ); - } - Connect_cableFaultsMaster++; Connect_cableOkMaster = 0; print(" Master "); @@ -497,12 +563,6 @@ uint8_t Connect_receive_CableCheck( uint8_t byte, uint16_t *pending_bytes, uint8 } else { - // If we already have an Id, then set max current again - if ( Connect_id != 255 && Connect_id != 0 ) - { - // TODO reset to original negotiated current - Output_update_external_current( 500 ); - } Connect_cableChecksMaster++; } } @@ -574,14 +634,6 @@ uint8_t Connect_receive_IdEnumeration( uint8_t id, uint16_t *pending_bytes, uint // Send reponse back to master Connect_send_IdReport( id ); - // Node now enumerated, set external power to USB Max - // Only set if this is not the master node - // TODO Determine power slice for each node as part of protocol - if ( Connect_id != 0 ) - { - Output_update_external_current( 500 ); - } - // Propogate next Id if the connection is ok if ( Connect_cableOkSlave ) { @@ -693,8 +745,6 @@ uint8_t Connect_receive_ScanCode( uint8_t byte, uint16_t *pending_bytes, uint8_t break; } // Propagate ScanCode packet - // XXX It would be safer to buffer the scancodes first, before transmitting the packet -Jacob - // The current method is the more efficient/aggressive, but could cause issues if there were errors during transmission else switch ( (*pending_bytes)-- ) { // Byte count always starts at 0xFFFF @@ -738,103 +788,6 @@ uint8_t Connect_receive_Animation( uint8_t byte, uint16_t *pending_bytes, uint8_ return 1; } -// - Remote Capability Variables - -#define Connect_receive_RemoteCapabilityMaxArgs 25 // XXX Calculate the max using kll -RemoteCapabilityCommand Connect_receive_RemoteCapabilityBuffer; -uint8_t Connect_receive_RemoteCapabilityArgs[Connect_receive_RemoteCapabilityMaxArgs]; - -uint8_t Connect_receive_RemoteCapability( uint8_t byte, uint16_t *pending_bytes, uint8_t uart_num ) -{ - // Check which byte in the packet we are at - switch ( (*pending_bytes)-- ) - { - // Byte count always starts at 0xFFFF - case 0xFFFF: // Device Id - Connect_receive_RemoteCapabilityBuffer.id = byte; - break; - - case 0xFFFE: // Capability Index - Connect_receive_RemoteCapabilityBuffer.capabilityIndex = byte; - break; - - case 0xFFFD: // State - Connect_receive_RemoteCapabilityBuffer.state = byte; - break; - - case 0xFFFC: // StateType - Connect_receive_RemoteCapabilityBuffer.stateType = byte; - break; - - case 0xFFFB: // Number of args - Connect_receive_RemoteCapabilityBuffer.numArgs = byte; - *pending_bytes = byte; - break; - - default: // Args (# defined by previous byte) - Connect_receive_RemoteCapabilityArgs[ - Connect_receive_RemoteCapabilityBuffer.numArgs - *pending_bytes + 1 - ] = byte; - - // If entire packet has been fully received - if ( *pending_bytes == 0 ) - { - // Determine if this is the node to run the capability on - // Conditions: Matches or broadcast (0xFF) - if ( Connect_receive_RemoteCapabilityBuffer.id == 0xFF - || Connect_receive_RemoteCapabilityBuffer.id == Connect_id ) - { - extern const Capability CapabilitiesList[]; // See generatedKeymap.h - void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))( - CapabilitiesList[ Connect_receive_RemoteCapabilityBuffer.capabilityIndex ].func - ); - capability( - Connect_receive_RemoteCapabilityBuffer.state, - Connect_receive_RemoteCapabilityBuffer.stateType, - &Connect_receive_RemoteCapabilityArgs[2] - ); - } - - // If this is not the correct node, keep sending it in the same direction (doesn't matter if more nodes exist) - // or if this is a broadcast - if ( Connect_receive_RemoteCapabilityBuffer.id == 0xFF - || Connect_receive_RemoteCapabilityBuffer.id != Connect_id ) - { - // Prepare outgoing packet - Connect_receive_RemoteCapabilityBuffer.command = RemoteCapability; - - // Send to the other UART (not the one receiving the packet from - uint8_t uart_direction = uart_num == UART_Master ? UART_Slave : UART_Master; - - // Lock Tx UART - switch ( uart_direction ) - { - case UART_Master: uart_lockTx( UART_Master ); break; - case UART_Slave: uart_lockTx( UART_Slave ); break; - } - - // Send header - uint8_t header[] = { 0x16, 0x01 }; - Connect_addBytes( header, sizeof( header ), uart_direction ); - - // Send Remote Capability and arguments - Connect_addBytes( (uint8_t*)&Connect_receive_RemoteCapabilityBuffer, sizeof( RemoteCapabilityCommand ), uart_direction ); - Connect_addBytes( Connect_receive_RemoteCapabilityArgs, Connect_receive_RemoteCapabilityBuffer.numArgs, uart_direction ); - - // Unlock Tx UART - switch ( uart_direction ) - { - case UART_Master: uart_unlockTx( UART_Master ); break; - case UART_Slave: uart_unlockTx( UART_Slave ); break; - } - } - } - break; - } - - // Check whether the scan codes have finished sending - return *pending_bytes == 0 ? 1 : 0; -} - // Baud Rate // NOTE: If finer baud adjustment is needed see UARTx_C4 -> BRFA in the datasheet @@ -849,29 +802,52 @@ void *Connect_receiveFunctions[] = { Connect_receive_IdReport, Connect_receive_ScanCode, Connect_receive_Animation, - Connect_receive_RemoteCapability, }; +// ----- Interrupt Functions ----- + +// Master / UART0 ISR +void uart0_status_isr() +{ + // Process Rx buffer + uart_processRx( 0 ); +} + +// Slave / UART1 ISR +void uart1_status_isr() +{ + // Process Rx buffer + uart_processRx( 1 ); +} + + + // ----- Functions ----- // Resets the state of the UART buffers and state variables void Connect_reset() { - // Reset Rx - memset( (void*)uart_rx_status, 0, sizeof( UARTStatusRx ) * UART_Num_Interfaces ); + // Rx Status Variables + uart0_rx_status = UARTStatus_Wait; + uart1_rx_status = UARTStatus_Wait; + uart0_rx_bytes_waiting = 0; + uart1_rx_bytes_waiting = 0; + uart0_lock = 0; + uart1_lock = 0; - // Reset Tx - memset( (void*)uart_tx_buf, 0, sizeof( UARTRingBuf ) * UART_Num_Interfaces ); - memset( (void*)uart_tx_status, 0, sizeof( UARTStatusTx ) * UART_Num_Interfaces ); + // Tx Status Variables + uart0_tx_status = UARTStatus_Ready; + uart1_tx_status = UARTStatus_Ready; - // Set Rx/Tx buffers as ready - for ( uint8_t inter = 0; inter < UART_Num_Interfaces; inter++ ) - { - uart_tx_status[ inter ].status = UARTStatus_Ready; - uart_rx_buf[ inter ].last_read = UART_Buffer_Size; - } + // Ring Buffer Variables + uart0_buffer_head = 0; + uart0_buffer_tail = 0; + uart0_buffer_items = 0; + uart1_buffer_head = 0; + uart1_buffer_tail = 0; + uart1_buffer_items = 0; } @@ -892,8 +868,8 @@ void Connect_setup( uint8_t master ) if ( Connect_master ) Connect_id = 0; // 0x00 is always the master Id - // UART0 setup - // UART1 setup + // Master / UART0 setup + // Slave / UART1 setup // Setup the the UART interface for keyboard data input SIM_SCGC4 |= SIM_SCGC4_UART0; // Disable clock gating SIM_SCGC4 |= SIM_SCGC4_UART1; // Disable clock gating @@ -919,81 +895,30 @@ void Connect_setup( uint8_t master ) UART0_C1 = UART_C1_M | UART_C1_PE | UART_C1_ILT; UART1_C1 = UART_C1_M | UART_C1_PE | UART_C1_ILT; - // Only using Tx Fifos - UART0_PFIFO = UART_PFIFO_TXFE; - UART1_PFIFO = UART_PFIFO_TXFE; + // Number of bytes in FIFO before TX Interrupt + UART0_TWFIFO = 1; + UART1_TWFIFO = 1; - // Setup DMA clocks - SIM_SCGC6 |= SIM_SCGC6_DMAMUX; - SIM_SCGC7 |= SIM_SCGC7_DMA; + // Number of bytes in FIFO before RX Interrupt + UART0_RWFIFO = 1; + UART1_RWFIFO = 1; - // Start with channels disabled first - DMAMUX0_CHCFG0 = 0; - DMAMUX0_CHCFG1 = 0; + // Enable TX and RX FIFOs + UART0_PFIFO = UART_PFIFO_TXFE | UART_PFIFO_RXFE; + UART1_PFIFO = UART_PFIFO_TXFE | UART_PFIFO_RXFE; - // Configure DMA channels - //DMA_DSR_BCR0 |= DMA_DSR_BCR_DONE_MASK; // TODO What's this? - DMA_TCD0_CSR = 0; - DMA_TCD1_CSR = 0; + // Reciever Inversion Disabled, LSBF + // UART_S2_RXINV UART_S2_MSBF + UART0_S2 |= 0x00; + UART1_S2 |= 0x00; - // Default control register - DMA_CR = 0; - - // DMA Priority - DMA_DCHPRI0 = 0; // Ch 0, priority 0 - DMA_DCHPRI1 = 1; // ch 1, priority 1 - - // Clear error interrupts - DMA_EEI = 0; - - // Setup TCD - DMA_TCD0_SADDR = (uint32_t*)&UART0_D; - DMA_TCD1_SADDR = (uint32_t*)&UART1_D; - DMA_TCD0_SOFF = 0; - DMA_TCD1_SOFF = 0; - - // No modulo, 8-bit transfer size - DMA_TCD0_ATTR = DMA_TCD_ATTR_SMOD(0) | DMA_TCD_ATTR_SSIZE(0) | DMA_TCD_ATTR_DMOD(0) | DMA_TCD_ATTR_DSIZE(0); - DMA_TCD1_ATTR = DMA_TCD_ATTR_SMOD(0) | DMA_TCD_ATTR_SSIZE(0) | DMA_TCD_ATTR_DMOD(0) | DMA_TCD_ATTR_DSIZE(0); - - // One byte transferred at a time - DMA_TCD0_NBYTES_MLNO = 1; - DMA_TCD1_NBYTES_MLNO = 1; - - // Source address does not change - DMA_TCD0_SLAST = 0; - DMA_TCD1_SLAST = 0; - - // Destination buffer - DMA_TCD0_DADDR = (uint32_t*)uart_rx_buf[0].buffer; - DMA_TCD1_DADDR = (uint32_t*)uart_rx_buf[1].buffer; - - // Incoming byte, increment by 1 in the rx buffer - DMA_TCD0_DOFF = 1; - DMA_TCD1_DOFF = 1; - - // Single major loop, must be the same value - DMA_TCD0_CITER_ELINKNO = UART_Buffer_Size; - DMA_TCD1_CITER_ELINKNO = UART_Buffer_Size; - DMA_TCD0_BITER_ELINKNO = UART_Buffer_Size; - DMA_TCD1_BITER_ELINKNO = UART_Buffer_Size; - - // Reset buffer when full - DMA_TCD0_DLASTSGA = -( UART_Buffer_Size ); - DMA_TCD1_DLASTSGA = -( UART_Buffer_Size ); - - // Enable DMA channels - DMA_ERQ |= DMA_ERQ_ERQ0 | DMA_ERQ_ERQ1; - - // Setup DMA channel routing - DMAMUX0_CHCFG0 = DMAMUX_ENABLE | DMAMUX_SOURCE_UART0_RX; - DMAMUX0_CHCFG1 = DMAMUX_ENABLE | DMAMUX_SOURCE_UART1_RX; - - // Enable DMA requests (requires Rx interrupts) - UART0_C5 = UART_C5_RDMAS; - UART1_C5 = UART_C5_RDMAS; + // Transmit Inversion Disabled + // UART_C3_TXINV + UART0_C3 |= 0x00; + UART1_C3 |= 0x00; // TX Enabled, RX Enabled, RX Interrupt Enabled + // UART_C2_TE UART_C2_RE UART_C2_RIE UART0_C2 = UART_C2_TE | UART_C2_RE | UART_C2_RIE; UART1_C2 = UART_C2_TE | UART_C2_RE | UART_C2_RIE; @@ -1009,143 +934,6 @@ void Connect_setup( uint8_t master ) } -#define DMA_BUF_POS( x, pos ) \ - case x: \ - pos = DMA_TCD##x##_CITER_ELINKNO; \ - break -void Connect_rx_process( uint8_t uartNum ) -{ - // Determine current position to read until - uint16_t bufpos = 0; - switch ( uartNum ) - { - DMA_BUF_POS( 0, bufpos ); - DMA_BUF_POS( 1, bufpos ); - } - - // Process each of the new bytes - // Even if we receive more bytes during processing, wait until the next check so we don't starve other tasks - while ( bufpos != uart_rx_buf[ uartNum ].last_read ) - { - // If the last_read byte is at the buffer edge, roll back to beginning - if ( uart_rx_buf[ uartNum ].last_read == 0 ) - { - uart_rx_buf[ uartNum ].last_read = UART_Buffer_Size; - - // Check to see if we're at the boundary - if ( bufpos == UART_Buffer_Size ) - break; - } - - // Read the byte out of Rx DMA buffer - uint8_t byte = uart_rx_buf[ uartNum ].buffer[ UART_Buffer_Size - uart_rx_buf[ uartNum ].last_read-- ]; - - if ( Connect_debug ) - { - printHex( byte ); - print(" "); - } - - // Process UART byte - switch ( uart_rx_status[ uartNum ].status ) - { - // Every packet must start with a SYN / 0x16 - case UARTStatus_Wait: - if ( Connect_debug ) - { - print(" Wait "); - } - uart_rx_status[ uartNum ].status = byte == 0x16 ? UARTStatus_SYN : UARTStatus_Wait; - break; - - // After a SYN, there must be a SOH / 0x01 - case UARTStatus_SYN: - if ( Connect_debug ) - { - print(" SYN "); - } - uart_rx_status[ uartNum ].status = byte == 0x01 ? UARTStatus_SOH : UARTStatus_Wait; - break; - - // After a SOH the packet structure may diverge a bit - // This is the packet type field (refer to the Command enum) - // For very small packets (e.g. IdRequest) this is all that's required to take action - case UARTStatus_SOH: - { - if ( Connect_debug ) - { - print(" SOH "); - } - - // Check if this is actually a reserved CMD 0x16 (Error condition) - if ( byte == Command_SYN ) - { - uart_rx_status[ uartNum ].status = UARTStatus_SYN; - break; - } - - // Otherwise process the command - if ( byte < Command_TOP ) - { - uart_rx_status[ uartNum ].status = UARTStatus_Command; - uart_rx_status[ uartNum ].command = byte; - uart_rx_status[ uartNum ].bytes_waiting = 0xFFFF; - } - // Invalid packet type, ignore - else - { - uart_rx_status[ uartNum ].status = UARTStatus_Wait; - } - - // Check if this is a very short packet - switch ( uart_rx_status[ uartNum ].command ) - { - case IdRequest: - Connect_receive_IdRequest( 0, (uint16_t*)&uart_rx_status[ uartNum ].bytes_waiting, uartNum ); - uart_rx_status[ uartNum ].status = UARTStatus_Wait; - break; - - default: - if ( Connect_debug ) - { - print(" ### "); - printHex( uart_rx_status[ uartNum ].command ); - } - break; - } - break; - } - - // After the packet type has been deciphered do Command specific processing - // Until the Command has received all the bytes it requires the UART buffer stays in this state - case UARTStatus_Command: - { - if ( Connect_debug ) - { - print(" CMD "); - } - /* Call specific UARTConnect command receive function */ - uint8_t (*rcvFunc)(uint8_t, uint16_t(*), uint8_t) = (uint8_t(*)(uint8_t, uint16_t(*), uint8_t))(Connect_receiveFunctions[ uart_rx_status[ uartNum ].command ]); - if ( rcvFunc( byte, (uint16_t*)&uart_rx_status[ uartNum ].bytes_waiting, uartNum ) ) - uart_rx_status[ uartNum ].status = UARTStatus_Wait; - break; - } - - // Unknown status, should never get here - default: - erro_msg("Invalid UARTStatus..."); - uart_rx_status[ uartNum ].status = UARTStatus_Wait; - continue; - } - - if ( Connect_debug ) - { - print( NL ); - } - } -} - - // Scan for updates in the master/slave // - Interrupts will deal with most input functions // - Used to send queries @@ -1161,7 +949,6 @@ void Connect_scan() } // Limit how often we do cable checks - //uint32_t time_compare = 0x007; // Used for debugging cables -HaaTa uint32_t time_compare = 0x7FF; // Must be all 1's, 0x3FF is valid, 0x4FF is not uint32_t current_time = systick_millis_count; if ( Connect_lastCheck != current_time @@ -1187,25 +974,14 @@ void Connect_scan() { // Check if Tx Buffers are empty and the Tx Ring buffers have data to send // This happens if there was previously nothing to send - if ( uart_tx_buf[ 0 ].items > 0 && UART0_TCFIFO == 0 ) + if ( uart0_buffer_items > 0 && UART0_TCFIFO == 0 ) uart_fillTxFifo( 0 ); - if ( uart_tx_buf[ 1 ].items > 0 && UART1_TCFIFO == 0 ) + if ( uart1_buffer_items > 0 && UART1_TCFIFO == 0 ) uart_fillTxFifo( 1 ); - - // Process Rx Buffers - Connect_rx_process( 0 ); - Connect_rx_process( 1 ); } } -// Called by parent Scan module whenever the available current changes -void Connect_currentChange( unsigned int current ) -{ - // TODO - Any potential power saving here? -} - - // ----- CLI Command Functions ----- @@ -1377,9 +1153,9 @@ void cliFunc_connectSts( char* args ) print("/"); printHex32( Connect_cableChecksMaster ); print( NL "\tRx:\t"); - printHex( uart_rx_status[UART_Master].status ); + printHex( uart1_rx_status ); print( NL "\tTx:\t"); - printHex( uart_tx_status[UART_Master].status ); + printHex( uart1_tx_status ); print( NL "Slave <=" NL "\tStatus:\t"); printHex( Connect_cableOkSlave ); print( NL "\tFaults:\t"); @@ -1387,8 +1163,8 @@ void cliFunc_connectSts( char* args ) print("/"); printHex32( Connect_cableChecksSlave ); print( NL "\tRx:\t"); - printHex( uart_rx_status[UART_Slave].status ); + printHex( uart0_rx_status ); print( NL "\tTx:\t"); - printHex( uart_tx_status[UART_Slave].status ); + printHex( uart0_tx_status ); } diff --git a/Scan/UARTConnect/connect_scan.h b/Scan/UARTConnect/connect_scan.h index 1d87dfd..bb50610 100644 --- a/Scan/UARTConnect/connect_scan.h +++ b/Scan/UARTConnect/connect_scan.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2014-2016 by Jacob Alexander +/* Copyright (C) 2014-2015 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 @@ -119,14 +119,11 @@ typedef struct AnimationCommand { // Remote Capability Command // Initiated by the master to trigger a capability on a given node // RemoteOutput is enabled while capability is activated -// Set id to 255 if command should be sent in all directions typedef struct RemoteCapabilityCommand { Command command; uint8_t id; - uint8_t capabilityIndex; - uint8_t state; - uint8_t stateType; - uint8_t numArgs; // # of bytes, args may be larger than 1 byte + Capability capability; + uint8_t numArgs; uint8_t firstArg[0]; } RemoteCapabilityCommand; @@ -165,7 +162,4 @@ void Connect_setup( uint8_t master ); void Connect_scan(); void Connect_send_ScanCode( uint8_t id, TriggerGuide *scanCodeStateList, uint8_t numScanCodes ); -void Connect_send_RemoteCapability( uint8_t id, uint8_t capabilityIndex, uint8_t state, uint8_t stateType, uint8_t numArgs, uint8_t *args ); - -void Connect_currentChange( unsigned int current ); diff --git a/Scan/WhiteFox/defaultMap.kll b/Scan/WhiteFox/defaultMap.kll deleted file mode 100644 index 037319b..0000000 --- a/Scan/WhiteFox/defaultMap.kll +++ /dev/null @@ -1,129 +0,0 @@ -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/"; -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 */ - 0xFF, 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, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* C9-1 -> C9-16 */ -"; - diff --git a/Scan/WhiteFox/matrix.h b/Scan/WhiteFox/matrix.h deleted file mode 100644 index f2037e0..0000000 --- a/Scan/WhiteFox/matrix.h +++ /dev/null @@ -1,56 +0,0 @@ -/* 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 deleted file mode 100644 index cb2f687..0000000 --- a/Scan/WhiteFox/pinout +++ /dev/null @@ -1,112 +0,0 @@ -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 deleted file mode 100644 index 56fa995..0000000 --- a/Scan/WhiteFox/scan_loop.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (C) 2014-2016 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; -} - - -// 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 ); - LED_currentChange( current ); -} - diff --git a/Scan/WhiteFox/scan_loop.h b/Scan/WhiteFox/scan_loop.h deleted file mode 100644 index 9e9a8f1..0000000 --- a/Scan/WhiteFox/scan_loop.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2014-2016 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 - -void Scan_currentChange( unsigned int current ); // Called by Output Module - diff --git a/Scan/WhiteFox/setup.cmake b/Scan/WhiteFox/setup.cmake deleted file mode 100644 index 9860b1a..0000000 --- a/Scan/WhiteFox/setup.cmake +++ /dev/null @@ -1,31 +0,0 @@ -###| 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 -) - diff --git a/buildall.bash b/buildall.bash index a8c393b..dd3a7cc 100755 --- a/buildall.bash +++ b/buildall.bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash ###| Builder Script |### # # Builds all permutations of modules @@ -31,8 +31,7 @@ main() { # Create permutation directories # Then run cmake, and run each build permutation # Keeping track of how many builds failed/passed - for mod in $scanModules; do - module=$(tr -dc "[:print:]" <<< "$mod") + for module in $scanModules; do # Create directory, but do not error if it exists already mkdir -p build/$module cd build/$module