Skip to content

Commit d7f314d

Browse files
committed
Host-Side KLL implementation
TODO, not complete - Python interface script - Updated CMake and compiler setup - Moved PressReleaseCache option into PartialMap - Added Host-Side API calls for Scan, main.c, Output - Fixed inlin'ing issues with various functions
1 parent a9639de commit d7f314d

41 files changed

Lines changed: 2472 additions & 54 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ set( CHIP
2525
"mk20dx128vlf5" # McHCK mk20dx128vlf5
2626
# "mk20dx256" # Teensy 3.1,3.2 (arm)
2727
# "mk20dx256vlh7" # Kiibohd-dfu mk20dx256vlh7
28+
# "host" # System compiler test environment
2829
CACHE STRING "Microcontroller Chip"
2930
)
3031

@@ -147,6 +148,10 @@ set( TARGET kiibohd )
147148
#| General Settings
148149
cmake_minimum_required( VERSION 2.8 )
149150

151+
#| Compiler Version (only available after project() command)
152+
message( STATUS "Full Compiler:" )
153+
message( "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_VERSION}" )
154+
150155

151156

152157
###

Debug/cli/cli.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,7 @@ void cliFunc_version( char* args )
596596
printHex32_op( SIM_UIDML, 8 );
597597
printHex32_op( SIM_UIDL, 8 );
598598
#elif defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
599+
#elif defined(_host_)
599600
#else
600601
#error "No unique id defined."
601602
#endif

Debug/cli/cli.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2014-2015 by Jacob Alexander
1+
/* Copyright (C) 2014-2016 by Jacob Alexander
22
*
33
* Permission is hereby granted, free of charge, to any person obtaining a copy
44
* of this software and associated documentation files (the "Software"), to deal
@@ -53,8 +53,8 @@
5353
#define CLIDict_Entry(name,description) \
5454
const PROGMEM char name##CLIDict_DescEntry[] = description;
5555

56-
// ARM is easy :P
57-
#elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_) // ARM
56+
// ARM like nearly everything else is easy :P
57+
#else
5858
#define CLIDict_Def(name,description) \
5959
const char name##Name[] = description; \
6060
const CLIDictItem name[]
@@ -64,6 +64,7 @@
6464

6565
#define CLIDict_Entry(name,description) \
6666
const char name##CLIDict_DescEntry[] = description;
67+
6768
#endif
6869

6970
#define RING_PREV(i) CLI_wrap(i - 1, 0, CLIMaxHistorySize - 1)

Debug/cli/setup.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###| CMake Kiibohd Controller Debug Module |###
22
#
3-
# Written by Jacob Alexander in 2014-2015 for the Kiibohd Controller
3+
# Written by Jacob Alexander in 2014-2016 for the Kiibohd Controller
44
#
55
# Released into the Public Domain
66
#
@@ -22,5 +22,6 @@ set ( Module_SRCS
2222
set ( ModuleCompatibility
2323
arm
2424
avr
25+
host
2526
)
2627

Debug/full/setup.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###| CMake Kiibohd Controller Debug Module |###
22
#
3-
# Written by Jacob Alexander in 2011-2015 for the Kiibohd Controller
3+
# Written by Jacob Alexander in 2011-2016 for the Kiibohd Controller
44
#
55
# Released into the Public Domain
66
#
@@ -22,5 +22,6 @@ AddModule ( Debug print )
2222
set ( ModuleCompatibility
2323
arm
2424
avr
25+
host
2526
)
2627

Debug/led/setup.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###| CMake Kiibohd Controller Debug Module |###
22
#
3-
# Written by Jacob Alexander in 2011-2015 for the Kiibohd Controller
3+
# Written by Jacob Alexander in 2011-2016 for the Kiibohd Controller
44
#
55
# Released into the Public Domain
66
#
@@ -22,5 +22,6 @@ set ( Module_SRCS
2222
set ( ModuleCompatibility
2323
arm
2424
avr
25+
host
2526
)
2627

Debug/print/print.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ void _print( const char* s )
6666
}
6767
#elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_) // ARM
6868
Output_putstr( (char*)s );
69+
#elif defined(_host_) // Host
70+
Output_putstr( (char*)s );
6971
#endif
7072
}
7173

Debug/print/setup.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
###| CMake Kiibohd Controller Debug Module |###
22
#
3-
# Written by Jacob Alexander in 2011-2015 for the Kiibohd Controller
3+
# Written by Jacob Alexander in 2011-2016 for the Kiibohd Controller
44
#
55
# Released into the Public Domain
66
#
@@ -22,5 +22,6 @@ set ( Module_SRCS
2222
set ( ModuleCompatibility
2323
arm
2424
avr
25+
host
2526
)
2627

Keyboards/Testing/macrotest.bash

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/usr/bin/env bash
2+
# This is a build and test script used to test KLL functionality
3+
# It runs on the host system and doesn't require a device to flash onto
4+
# Jacob Alexander 2016
5+
6+
7+
8+
#################
9+
# Configuration #
10+
#################
11+
12+
# Feel free to change the variables in this section to configure your keyboard
13+
14+
BuildPath="macrotest"
15+
16+
## KLL Configuration ##
17+
18+
# Generally shouldn't be changed, this will affect every layer
19+
BaseMap="scancode_map"
20+
21+
# This is the default layer of the keyboard
22+
# NOTE: To combine kll files into a single layout, separate them by spaces
23+
# e.g. DefaultMap="mylayout mylayoutmod"
24+
DefaultMap="stdFuncMap"
25+
26+
# This is where you set the additional layers
27+
# NOTE: Indexing starts at 1
28+
# NOTE: Each new layer is another array entry
29+
# e.g. PartialMaps[1]="layer1 layer1mod"
30+
# PartialMaps[2]="layer2"
31+
# PartialMaps[3]="layer3"
32+
PartialMaps[1]="hhkbpro2"
33+
PartialMaps[2]="colemak"
34+
35+
36+
37+
##########################
38+
# Advanced Configuration #
39+
##########################
40+
41+
# Don't change the variables in this section unless you know what you're doing
42+
# These are useful for completely custom keyboards
43+
# NOTE: Changing any of these variables will require a force build to compile correctly
44+
45+
# Keyboard Module Configuration
46+
ScanModule="TestIn"
47+
MacroModule="PartialMap"
48+
OutputModule="TestOut"
49+
DebugModule="full"
50+
51+
# Microcontroller
52+
Chip="host"
53+
54+
# Compiler Selection
55+
Compiler="gcc"
56+
57+
58+
59+
########################
60+
# Bash Library Include #
61+
########################
62+
63+
# Shouldn't need to touch this section
64+
65+
# Check if the library can be found
66+
if [ ! -f ../cmake.bash ]; then
67+
echo "ERROR: Cannot find 'cmake.bash'"
68+
exit 1
69+
fi
70+
71+
# Override CMakeLists path
72+
CMakeListsPath="../../.."
73+
74+
# Load the library
75+
source "../cmake.bash"
76+

Lib/CMake/build.cmake

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,30 @@ endif ()
2323
#
2424

2525
#| Create the .ELF file
26-
set( TARGET_ELF ${TARGET}.elf )
27-
add_executable( ${TARGET_ELF} ${SRCS} generatedKeymap.h )
26+
if ( NOT HOST )
27+
set ( TARGET_OUT ${TARGET}.elf )
2828

29+
# .ELF Binary
30+
add_executable ( ${TARGET} ${SRCS} generatedKeymap.h )
2931

30-
#| .ELF Properties
31-
set_target_properties( ${TARGET_ELF} PROPERTIES
32-
LINK_FLAGS ${LINKER_FLAGS}
33-
SUFFIX "" # XXX Force Windows to keep the .exe off
34-
)
32+
# .ELF Properties
33+
set_target_properties ( ${TARGET} PROPERTIES
34+
LINK_FLAGS ${LINKER_FLAGS}
35+
SUFFIX ".elf"
36+
)
37+
38+
#| Create host library
39+
else ()
40+
set ( TARGET_OUT ${CMAKE_SHARED_LIBRARY_PREFIX}${TARGET}${CMAKE_SHARED_LIBRARY_SUFFIX} )
41+
42+
# Shared Library
43+
add_library ( ${TARGET} SHARED ${SRCS} generatedKeymap.h )
44+
45+
# Shared Library Properties
46+
set_target_properties ( ${TARGET} PROPERTIES
47+
LINK_FLAGS ${LINKER_FLAGS}
48+
)
49+
endif ()
3550

3651
#| llvm-clang does not have an objcopy equivalent
3752
if ( "${COMPILER}" MATCHES "clang" )
@@ -53,15 +68,15 @@ if ( DEFINED DFU )
5368

5469
set( TARGET_BIN ${TARGET}.dfu.bin )
5570
if ( DFU_SUFFIX_FOUND )
56-
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
57-
COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
71+
add_custom_command( TARGET ${TARGET} POST_BUILD
72+
COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_OUT} ${TARGET_BIN}
5873
COMMAND ${DFU_SUFFIX_EXECUTABLE} --add ${TARGET_BIN} --vid ${BOOT_VENDOR_ID} --pid ${BOOT_PRODUCT_ID} 1> /dev/null
5974
COMMENT "Create and sign dfu bin file: ${TARGET_BIN}"
6075
)
6176
else ()
6277
message ( WARNING "DFU Binary has not been signed, requires dfu-suffix..." )
63-
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
64-
COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
78+
add_custom_command( TARGET ${TARGET} POST_BUILD
79+
COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_OUT} ${TARGET_BIN}
6580
COMMENT "Creating dfu binary file: ${TARGET_BIN}"
6681
)
6782
endif ()
@@ -71,31 +86,31 @@ endif ()
7186
#| Convert the .ELF into a .HEX to load onto the Teensy
7287
if ( DEFINED TEENSY )
7388
set( TARGET_HEX ${TARGET}.teensy.hex )
74-
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
75-
COMMAND ${OBJ_COPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
89+
add_custom_command( TARGET ${TARGET} POST_BUILD
90+
COMMAND ${OBJ_COPY} ${HEX_FLAGS} ${TARGET_OUT} ${TARGET_HEX}
7691
COMMENT "Creating iHex file to load: ${TARGET_HEX}"
7792
)
7893
endif()
7994

8095

8196
#| Generate the Extended .LSS
8297
set( TARGET_LSS ${TARGET}.lss )
83-
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
84-
COMMAND ${CMAKE_OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
98+
add_custom_command( TARGET ${TARGET} POST_BUILD
99+
COMMAND ${CMAKE_OBJDUMP} ${LSS_FLAGS} ${TARGET_OUT} > ${TARGET_LSS}
85100
COMMENT "Creating Extended Listing: ${TARGET_LSS}"
86101
)
87102

88103

89104
#| Generate the Symbol Table .SYM
90105
set( TARGET_SYM ${TARGET}.sym )
91-
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
92-
COMMAND ${CMAKE_NM} -n ${TARGET_ELF} > ${TARGET_SYM}
106+
add_custom_command( TARGET ${TARGET} POST_BUILD
107+
COMMAND ${CMAKE_NM} -n ${TARGET_OUT} > ${TARGET_SYM}
93108
COMMENT "Creating Symbol Table: ${TARGET_SYM}"
94109
)
95110

96111

97112
#| Compiler Selection Record
98-
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
113+
add_custom_command( TARGET ${TARGET} POST_BUILD
99114
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/writer compiler ${COMPILER_FAMILY}
100115
)
101116

@@ -105,13 +120,15 @@ add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
105120
# Size Information
106121
#
107122

108-
#| After Changes Size Information
109-
add_custom_target( SizeAfter ALL
110-
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} ram ${TARGET_ELF} ${SIZE_RAM} " SRAM"
111-
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} flash ${TARGET_ELF} ${SIZE_FLASH} "Flash"
112-
DEPENDS ${TARGET_ELF}
113-
COMMENT "Chip usage for ${CHIP}"
114-
)
123+
if ( NOT DEFINED HOST )
124+
#| After Changes Size Information
125+
add_custom_target( SizeAfter ALL
126+
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} ram ${TARGET_OUT} ${SIZE_RAM} " SRAM"
127+
COMMAND ${CMAKE_SOURCE_DIR}/Lib/CMake/sizeCalculator ${CMAKE_SIZE} flash ${TARGET_OUT} ${SIZE_FLASH} "Flash"
128+
DEPENDS ${TARGET}
129+
COMMENT "Chip usage for ${CHIP}"
130+
)
131+
endif ()
115132

116133

117134

@@ -150,7 +167,7 @@ if ( UNIX AND NOT DEFINED CONFIGURATOR )
150167
execute_process ( COMMAND ln -sfn ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/. )
151168

152169
# Also update before each build
153-
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
170+
add_custom_command( TARGET ${TARGET} POST_BUILD
154171
COMMAND ln -sfn ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/.
155172
)
156173
endif ()

0 commit comments

Comments
 (0)