mirror of
				https://github.com/mfulz/qmk_firmware.git
				synced 2025-11-04 07:12:33 +01:00 
			
		
		
		
	Merge branch 'master' of https://github.com/jackhumbert/qmk_firmware
This commit is contained in:
		
						commit
						97dfbd1afc
					
				
							
								
								
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							@ -4,3 +4,6 @@
 | 
			
		||||
[submodule "lib/chibios-contrib"]
 | 
			
		||||
	path = lib/chibios-contrib
 | 
			
		||||
	url = https://github.com/ChibiOS/ChibiOS-Contrib.git
 | 
			
		||||
[submodule "lib/ugfx"]
 | 
			
		||||
	path = lib/ugfx
 | 
			
		||||
	url = https://bitbucket.org/Tectu/ugfx
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										23
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								Makefile
									
									
									
									
									
								
							@ -59,6 +59,12 @@ ifndef KEYBOARD
 | 
			
		||||
	KEYBOARD=planck
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
MASTER ?= left
 | 
			
		||||
ifdef master
 | 
			
		||||
	MASTER = $(master)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# converts things to keyboards/subproject
 | 
			
		||||
ifneq (,$(findstring /,$(KEYBOARD)))
 | 
			
		||||
	TEMP:=$(KEYBOARD)
 | 
			
		||||
@ -202,6 +208,16 @@ ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
 | 
			
		||||
	SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(strip $(SERIAL_LINK_ENABLE)), yes)
 | 
			
		||||
	SERIAL_DIR = $(QUANTUM_DIR)/serial_link
 | 
			
		||||
	SERIAL_PATH = $(QUANTUM_PATH)/serial_link
 | 
			
		||||
	SERIAL_SRC = $(wildcard $(SERIAL_PATH)/protocol/*.c)
 | 
			
		||||
	SERIAL_SRC += $(wildcard $(SERIAL_PATH)/system/*.c)
 | 
			
		||||
	SRC += $(patsubst $(QUANTUM_PATH)/%,%,$(SERIAL_SRC))
 | 
			
		||||
	OPT_DEFS += -DSERIAL_LINK_ENABLE
 | 
			
		||||
	VAPTH += $(SERIAL_PATH)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
# Optimize size but this may cause error "relocation truncated to fit"
 | 
			
		||||
#EXTRALDFLAGS = -Wl,--relax
 | 
			
		||||
 | 
			
		||||
@ -233,10 +249,17 @@ ifeq ($(PLATFORM),AVR)
 | 
			
		||||
else ifeq ($(PLATFORM),CHIBIOS)
 | 
			
		||||
	include $(TMK_PATH)/protocol/chibios.mk
 | 
			
		||||
	include $(TMK_PATH)/chibios.mk
 | 
			
		||||
	OPT_OS = chibios
 | 
			
		||||
else
 | 
			
		||||
	$(error Unknown platform)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(strip $(VISUALIZER_ENABLE)), yes)
 | 
			
		||||
	VISUALIZER_DIR = $(QUANTUM_DIR)/visualizer
 | 
			
		||||
	VISUALIZER_PATH = $(QUANTUM_PATH)/visualizer
 | 
			
		||||
	include $(VISUALIZER_PATH)/visualizer.mk
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
include $(TMK_PATH)/rules.mk
 | 
			
		||||
 | 
			
		||||
GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags 2>/dev/null || date +"%Y-%m-%d-%H:%M:%S")
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@ ifdef TEENSY2
 | 
			
		||||
    ATRUES_UPLOAD_COMMAND = teensy_loader_cli -w -mmcu=$(MCU) $(TARGET).hex
 | 
			
		||||
else
 | 
			
		||||
    OPT_DEFS += -DATREUS_ASTAR
 | 
			
		||||
    OPT_DEFS += -DCATERINA_BOOTLOADER
 | 
			
		||||
    ATRUES_UPLOAD_COMMAND = while [ ! -r $(USB) ]; do sleep 1; done; \
 | 
			
		||||
                            avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								keyboards/chibios_test/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								keyboards/chibios_test/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
SUBPROJECT_DEFAULT = stm32_f072_onekey
 | 
			
		||||
 | 
			
		||||
#BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration
 | 
			
		||||
MOUSEKEY_ENABLE ?= yes	# Mouse keys
 | 
			
		||||
EXTRAKEY_ENABLE ?= yes	# Audio control and System control
 | 
			
		||||
CONSOLE_ENABLE ?= yes	# Console for debug
 | 
			
		||||
COMMAND_ENABLE ?= yes    # Commands for debug and configuration
 | 
			
		||||
SLEEP_LED_ENABLE ?= yes  # Breathing sleep LED during USB suspend
 | 
			
		||||
NKRO_ENABLE ?= yes	    # USB Nkey Rollover
 | 
			
		||||
CUSTOM_MATRIX ?= yes # Custom matrix file
 | 
			
		||||
 | 
			
		||||
ifndef QUANTUM_DIR
 | 
			
		||||
	include ../../Makefile
 | 
			
		||||
endif
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 159 KiB After Width: | Height: | Size: 159 KiB  | 
| 
		 Before Width: | Height: | Size: 232 KiB After Width: | Height: | Size: 232 KiB  | 
							
								
								
									
										1
									
								
								keyboards/chibios_test/chibios_test.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								keyboards/chibios_test/chibios_test.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
#include "chibios_test.h"
 | 
			
		||||
							
								
								
									
										6
									
								
								keyboards/chibios_test/chibios_test.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								keyboards/chibios_test/chibios_test.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
#ifndef KEYBOARDS_CHIBIOS_TEST_CHIBIOS_TEST_H_
 | 
			
		||||
#define KEYBOARDS_CHIBIOS_TEST_CHIBIOS_TEST_H_
 | 
			
		||||
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
 | 
			
		||||
#endif /* KEYBOARDS_CHIBIOS_TEST_CHIBIOS_TEST_H_ */
 | 
			
		||||
@ -18,18 +18,17 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#ifndef CONFIG_H
 | 
			
		||||
#define CONFIG_H
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* USB Device descriptor parameter */
 | 
			
		||||
#define VENDOR_ID       0xFEED
 | 
			
		||||
#define PRODUCT_ID      0x6464
 | 
			
		||||
#define DEVICE_VER      0x0001
 | 
			
		||||
/* in python2: list(u"whatever".encode('utf-16-le')) */
 | 
			
		||||
/*   at most 32 characters or the ugly hack in usb_main.c borks */
 | 
			
		||||
#define MANUFACTURER "TMK"
 | 
			
		||||
#define MANUFACTURER "QMK"
 | 
			
		||||
#define USBSTR_MANUFACTURER    'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', '\xc6', '\x00'
 | 
			
		||||
#define PRODUCT "ChibiOS TMK test"
 | 
			
		||||
#define USBSTR_PRODUCT         'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
 | 
			
		||||
#define DESCRIPTION "TMK keyboard firmware over ChibiOS"
 | 
			
		||||
#define PRODUCT "ChibiOS QMK test"
 | 
			
		||||
#define USBSTR_PRODUCT         'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'Q', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
 | 
			
		||||
#define DESCRIPTION "QMK keyboard firmware test for ChibiOS"
 | 
			
		||||
 | 
			
		||||
/* key matrix size */
 | 
			
		||||
#define MATRIX_ROWS 1
 | 
			
		||||
@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "stm32_f103_onekey.h"
 | 
			
		||||
#include "chibios_test.h"
 | 
			
		||||
 | 
			
		||||
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
    {{KC_CAPS}}, // test with KC_CAPS, KC_A, KC_BTLD
 | 
			
		||||
@ -36,15 +36,6 @@ ARMV = 6
 | 
			
		||||
# Build Options
 | 
			
		||||
#   comment out to disable the options.
 | 
			
		||||
#
 | 
			
		||||
#BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration
 | 
			
		||||
MOUSEKEY_ENABLE ?= yes	# Mouse keys
 | 
			
		||||
EXTRAKEY_ENABLE ?= yes	# Audio control and System control
 | 
			
		||||
CONSOLE_ENABLE ?= yes	# Console for debug
 | 
			
		||||
COMMAND_ENABLE ?= yes    # Commands for debug and configuration
 | 
			
		||||
SLEEP_LED_ENABLE ?= yes  # Breathing sleep LED during USB suspend
 | 
			
		||||
NKRO_ENABLE ?= yes	    # USB Nkey Rollover
 | 
			
		||||
CUSTOM_MATRIX ?= yes # Custom matrix file
 | 
			
		||||
 | 
			
		||||
ifndef QUANTUM_DIR
 | 
			
		||||
	include ../../Makefile
 | 
			
		||||
	include ../../../Makefile
 | 
			
		||||
endif
 | 
			
		||||
							
								
								
									
										7
									
								
								keyboards/chibios_test/stm32_f072_onekey/config.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								keyboards/chibios_test/stm32_f072_onekey/config.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
#ifndef KEYBOARDS_CHIBIOS_TEST_STM32_F072_ONEKEY_CONFIG_H_
 | 
			
		||||
#define KEYBOARDS_CHIBIOS_TEST_STM32_F072_ONEKEY_CONFIG_H_
 | 
			
		||||
 | 
			
		||||
#include "../config.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* KEYBOARDS_CHIBIOS_TEST_STM32_F072_ONEKEY_CONFIG_H_ */
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
#ifndef STM32_F072_ONEKEY_H
 | 
			
		||||
#define STM32_F072_ONEKEY_H
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
#include "chibios_test.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -46,19 +46,7 @@ ARMV = 7
 | 
			
		||||
#   <tmk_dir>/tmk_core/tool/chibios/ch-bootloader-jump.patch
 | 
			
		||||
#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800
 | 
			
		||||
 | 
			
		||||
# Build Options
 | 
			
		||||
#   comment out to disable the options.
 | 
			
		||||
#
 | 
			
		||||
#BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration
 | 
			
		||||
## BOOTMAGIC is not supported on STM32 chips yet.
 | 
			
		||||
MOUSEKEY_ENABLE ?= yes	# Mouse keys
 | 
			
		||||
EXTRAKEY_ENABLE ?= yes	# Audio control and System control
 | 
			
		||||
# CONSOLE_ENABLE ?= yes	# Console for debug
 | 
			
		||||
COMMAND_ENABLE ?= yes    # Commands for debug and configuration
 | 
			
		||||
SLEEP_LED_ENABLE ?= no   # Breathing sleep LED during USB suspend
 | 
			
		||||
NKRO_ENABLE ?= yes	    # USB Nkey Rollover
 | 
			
		||||
CUSTOM_MATRIX ?= yes # Custom matrix file
 | 
			
		||||
 | 
			
		||||
ifndef QUANTUM_DIR
 | 
			
		||||
	include ../../Makefile
 | 
			
		||||
	include ../../../Makefile
 | 
			
		||||
endif
 | 
			
		||||
							
								
								
									
										6
									
								
								keyboards/chibios_test/stm32_f103_onekey/config.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								keyboards/chibios_test/stm32_f103_onekey/config.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
#ifndef KEYBOARDS_CHIBIOS_TEST_STM32_F103_ONEKEY_CONFIG_H_
 | 
			
		||||
#define KEYBOARDS_CHIBIOS_TEST_STM32_F103_ONEKEY_CONFIG_H_
 | 
			
		||||
 | 
			
		||||
#include "../config.h"
 | 
			
		||||
 | 
			
		||||
#endif /* KEYBOARDS_CHIBIOS_TEST_STM32_F103_ONEKEY_CONFIG_H_ */
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
#ifndef STM32_F103_ONEKEY_H
 | 
			
		||||
#define STM32_F103_ONEKEY_H
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
#include "chibios_test.h"
 | 
			
		||||
#endif
 | 
			
		||||
@ -44,19 +44,6 @@ MCU  = cortex-m0plus
 | 
			
		||||
# I.e. 6 for Teensy LC; 7 for Teensy 3.x
 | 
			
		||||
ARMV = 6
 | 
			
		||||
 | 
			
		||||
# Build Options
 | 
			
		||||
#   comment out to disable the options.
 | 
			
		||||
#
 | 
			
		||||
BOOTMAGIC_ENABLE ?= yes	# Virtual DIP switch configuration
 | 
			
		||||
## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.)
 | 
			
		||||
MOUSEKEY_ENABLE ?= yes	# Mouse keys
 | 
			
		||||
EXTRAKEY_ENABLE ?= yes	# Audio control and System control
 | 
			
		||||
CONSOLE_ENABLE ?= yes	# Console for debug
 | 
			
		||||
COMMAND_ENABLE ?= yes    # Commands for debug and configuration
 | 
			
		||||
SLEEP_LED_ENABLE ?= yes  # Breathing sleep LED during USB suspend
 | 
			
		||||
NKRO_ENABLE ?= yes	    # USB Nkey Rollover
 | 
			
		||||
CUSTOM_MATRIX ?= yes # Custom matrix file
 | 
			
		||||
 | 
			
		||||
ifndef QUANTUM_DIR
 | 
			
		||||
	include ../../Makefile
 | 
			
		||||
	include ../../../Makefile
 | 
			
		||||
endif
 | 
			
		||||
							
								
								
									
										6
									
								
								keyboards/chibios_test/teensy_lc_onekey/config.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								keyboards/chibios_test/teensy_lc_onekey/config.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
#ifndef KEYBOARDS_CHIBIOS_TEST_TEENSY_LC_ONEKEY_CONFIG_H_
 | 
			
		||||
#define KEYBOARDS_CHIBIOS_TEST_TEENSY_LC_ONEKEY_CONFIG_H_
 | 
			
		||||
 | 
			
		||||
#include "../config.h"
 | 
			
		||||
 | 
			
		||||
#endif /* KEYBOARDS_CHIBIOS_TEST_TEENSY_LC_ONEKEY_CONFIG_H_ */
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
#ifndef TEENSY_LC_ONEKEY_H
 | 
			
		||||
#define TEENSY_LC_ONEKEY_H
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
#include "chibios_test.h"
 | 
			
		||||
#endif
 | 
			
		||||
@ -39,6 +39,17 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#include  "timer.h"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * This constant define not debouncing time in msecs, but amount of matrix
 | 
			
		||||
 * scan loops which should be made to get stable debounced results.
 | 
			
		||||
 *
 | 
			
		||||
 * On Ergodox matrix scan rate is relatively low, because of slow I2C.
 | 
			
		||||
 * Now it's only 317 scans/second, or about 3.15 msec/scan.
 | 
			
		||||
 * According to Cherry specs, debouncing time is 5 msec.
 | 
			
		||||
 *
 | 
			
		||||
 * And so, there is no sense to have DEBOUNCE higher than 2.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef DEBOUNCE
 | 
			
		||||
#   define DEBOUNCE	5
 | 
			
		||||
#endif
 | 
			
		||||
@ -181,6 +192,7 @@ uint8_t matrix_scan(void)
 | 
			
		||||
    if (debouncing) {
 | 
			
		||||
        if (--debouncing) {
 | 
			
		||||
            wait_us(1);
 | 
			
		||||
            // this should be wait_ms(1) but has been left as-is at EZ's request
 | 
			
		||||
        } else {
 | 
			
		||||
            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
 | 
			
		||||
                matrix[i] = matrix_debouncing[i];
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										385
									
								
								keyboards/infinity_ergodox/MEMO.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										385
									
								
								keyboards/infinity_ergodox/MEMO.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,385 @@
 | 
			
		||||
flabbergast's TMK/ChibiOS port
 | 
			
		||||
==============================
 | 
			
		||||
2015/10/16
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Build
 | 
			
		||||
-----
 | 
			
		||||
$ git clone -b chibios https://github.com/flabbergast/tmk_keyboard.git
 | 
			
		||||
 | 
			
		||||
$ cd tmk_keyboard
 | 
			
		||||
$ git submodule add -f -b kinetis https://github.com/flabbergast/ChibiOS.git tmk_core/tool/chibios/chibios
 | 
			
		||||
or
 | 
			
		||||
$ cd tmk_keyboard/tmk_core/tool/chibios
 | 
			
		||||
$ git clone -b kinetis https://github.com/flabbergast/ChibiOS.git tmk_core/tool/chibios/chibios
 | 
			
		||||
 | 
			
		||||
$ cd tmk_keyboard/keyboard/infinity_chibios
 | 
			
		||||
$ make
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Chibios Configuration
 | 
			
		||||
---------------------
 | 
			
		||||
halconf.h: for HAL configuration
 | 
			
		||||
    placed in project directory
 | 
			
		||||
    read in chibios/os/hal/hal.mk
 | 
			
		||||
    included in chibios/os/hal/include/hal.h
 | 
			
		||||
mcuconf.h: for MCU configuration
 | 
			
		||||
    placed in project directory
 | 
			
		||||
    included in halconf.h
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Chibios Term
 | 
			
		||||
------------
 | 
			
		||||
PAL = Port Abstraction Layer
 | 
			
		||||
    palWritePad
 | 
			
		||||
    palReadPad
 | 
			
		||||
    palSetPad
 | 
			
		||||
    chibios/os/hal/include/pal.h
 | 
			
		||||
 | 
			
		||||
LLD = Low Level Driver
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Makefile
 | 
			
		||||
--------
 | 
			
		||||
    #   <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
 | 
			
		||||
    MCU_FAMILY = KINETIS
 | 
			
		||||
    MCU_SERIES = KL2x
 | 
			
		||||
 | 
			
		||||
    # - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
 | 
			
		||||
    #   or <this_dir>/ld/
 | 
			
		||||
    MCU_LDSCRIPT = MKL26Z64
 | 
			
		||||
 | 
			
		||||
    #  - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
 | 
			
		||||
    MCU_STARTUP = kl2x
 | 
			
		||||
 | 
			
		||||
    # Board: it should exist either in <chibios>/os/hal/boards/
 | 
			
		||||
    #  or <this_dir>/boards
 | 
			
		||||
    BOARD = PJRC_TEENSY_LC
 | 
			
		||||
 | 
			
		||||
    MCU  = cortex-m0
 | 
			
		||||
 | 
			
		||||
    # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
 | 
			
		||||
    ARMV = 6
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
halconf.h
 | 
			
		||||
---------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
mcuconf.h
 | 
			
		||||
---------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
chconf.h
 | 
			
		||||
--------
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
ld script
 | 
			
		||||
---------
 | 
			
		||||
--- ../../tmk_core/tool/chibios/chibios/os/common/ports/ARMCMx/compilers/GCC/ld/MKL26Z64.ld     2015-10-15 09:08:58.732904304 +0900
 | 
			
		||||
+++ ld/MKL26Z64.ld      2015-10-15 08:48:06.430215496 +0900
 | 
			
		||||
@@ -27,7 +27,8 @@
 | 
			
		||||
 {
 | 
			
		||||
   flash0   :  org = 0x00000000,  len = 0xc0
 | 
			
		||||
   flashcfg :  org = 0x00000400,  len = 0x10
 | 
			
		||||
-  flash    :  org = 0x00000410,  len = 64k - 0x410
 | 
			
		||||
+  flash    :  org = 0x00000410,  len = 62k - 0x410
 | 
			
		||||
+  eeprom_emu : org = 0x0000F800, len = 2k
 | 
			
		||||
   ram      :  org = 0x1FFFF800,  len = 8k
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
@@ -35,6 +36,10 @@
 | 
			
		||||
 __ram_size__            = LENGTH(ram);
 | 
			
		||||
 __ram_end__             = __ram_start__ + __ram_size__;
 | 
			
		||||
 | 
			
		||||
+__eeprom_workarea_start__ = ORIGIN(eeprom_emu);
 | 
			
		||||
+__eeprom_workarea_size__  = LENGTH(eeprom_emu);
 | 
			
		||||
+__eeprom_workarea_end__   = __eeprom_workarea_start__ + __eeprom_workarea_size__;
 | 
			
		||||
+
 | 
			
		||||
 SECTIONS
 | 
			
		||||
 {
 | 
			
		||||
   . = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Configuration/Startup for Infinity 60%
 | 
			
		||||
--------------------------------------
 | 
			
		||||
Configuration:
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Clock:
 | 
			
		||||
Inifinity   
 | 
			
		||||
    FEI(FLL Engaged Internal) mode with core clock:48MHz, bus clock:48MHz, flash clock:24MHz
 | 
			
		||||
    Clock dividor:
 | 
			
		||||
    SIM_CLKDIV1[OUTDIV1] = 0 divide-by-1 for core clock
 | 
			
		||||
    SIM_CLKDIV1[OUTDIV2] = 0 divide-by-1 for bus clock
 | 
			
		||||
    SIM_CLKDIV1[OUTDIV4] = 1 divide-by-2 for flash clock
 | 
			
		||||
    Internal reference clock:
 | 
			
		||||
    MCG_C1[IREFS] = 1 Internal Reference Select for clock source for FLL
 | 
			
		||||
    MCG_C1[IRCLKEN] = 1 Internal Reference Clock Enable
 | 
			
		||||
    FLL multipilication:
 | 
			
		||||
    MCG_C4[DMX32] = 1
 | 
			
		||||
    MCG_C4[DRST_DRS] = 01   FLL factor 1464 * 32.768kHz = 48MHz
 | 
			
		||||
 | 
			
		||||
chibios/os/hal/ports/KINETIS/K20x/hal_lld.c
 | 
			
		||||
    k20x_clock_init(): called in __early_init() defined in board.c
 | 
			
		||||
        disable watchdog and configure clock
 | 
			
		||||
 | 
			
		||||
        configurable macros:
 | 
			
		||||
        KINETIS_NO_INIT: whether init or not
 | 
			
		||||
        KINETIS_MCG_MODE: clock mode   
 | 
			
		||||
            KINETIS_MCG_MODE_FEI
 | 
			
		||||
            KINETIS_MCG_MODE_PEE
 | 
			
		||||
                hal/ports/KINETIS/K20x/hal_lld.h
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
chibios/os/hal/boards/FREESCALE_FREEDOM_K20D50M/board.h
 | 
			
		||||
    PALConfig pal_default_config
 | 
			
		||||
    boardInit()
 | 
			
		||||
    __early_init()
 | 
			
		||||
    macro definitions for board infos, freq and mcu type
 | 
			
		||||
 | 
			
		||||
chibios/os/hal/boards/FREESCALE_FREEDOM_K20D50M/board.c
 | 
			
		||||
 | 
			
		||||
USB
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Startup
 | 
			
		||||
-------
 | 
			
		||||
    common/ports/ARMCMx/GCC/crt0_v[67]m.s
 | 
			
		||||
        Reset_Handler: startup code
 | 
			
		||||
    common/ports/ARMCMx/GCC/crt1.c
 | 
			
		||||
        __core_init(): weak
 | 
			
		||||
        __early_init(): weak
 | 
			
		||||
        __late_init(): weak
 | 
			
		||||
        __default_exit(): weak
 | 
			
		||||
            called from Reset_Handler of crt0
 | 
			
		||||
    common/ports/ARMCMx/GCC/vector.c
 | 
			
		||||
    common/ports/ARMCMx/GCC/ld/*.ld
 | 
			
		||||
 | 
			
		||||
chibios/os/common/ports/ARMCMx/compilers/GCC/
 | 
			
		||||
├── crt0_v6m.s
 | 
			
		||||
├── crt0_v7m.s
 | 
			
		||||
├── crt1.c
 | 
			
		||||
├── ld
 | 
			
		||||
│   ├── MK20DX128BLDR3.ld
 | 
			
		||||
│   ├── MK20DX128BLDR4.ld
 | 
			
		||||
│   ├── MK20DX128.ld
 | 
			
		||||
│   ├── MK20DX256.ld
 | 
			
		||||
│   ├── MKL25Z128.ld
 | 
			
		||||
│   ├── MKL26Z128.ld
 | 
			
		||||
│   ├── MKL26Z64.ld
 | 
			
		||||
│   └── STM32L476xG.ld
 | 
			
		||||
├── mk
 | 
			
		||||
│   ├── startup_k20x5.mk
 | 
			
		||||
│   ├── startup_k20x7.mk
 | 
			
		||||
│   ├── startup_k20x.mk
 | 
			
		||||
│   ├── startup_kl2x.mk
 | 
			
		||||
│   └── startup_stm32l4xx.mk
 | 
			
		||||
├── rules.ld
 | 
			
		||||
├── rules.mk
 | 
			
		||||
└── vectors.c
 | 
			
		||||
 | 
			
		||||
chibios/os/hal/
 | 
			
		||||
├── boards
 | 
			
		||||
│   ├── FREESCALE_FREEDOM_K20D50M
 | 
			
		||||
│   │   ├── board.c
 | 
			
		||||
│   │   ├── board.h
 | 
			
		||||
│   │   └── board.mk
 | 
			
		||||
│   ├── MCHCK_K20
 | 
			
		||||
│   │   ├── board.c
 | 
			
		||||
│   │   ├── board.h
 | 
			
		||||
│   │   └── board.mk
 | 
			
		||||
│   ├── PJRC_TEENSY_3
 | 
			
		||||
│   │   ├── board.c
 | 
			
		||||
│   │   ├── board.h
 | 
			
		||||
│   │   └── board.mk
 | 
			
		||||
│   ├── PJRC_TEENSY_3_1
 | 
			
		||||
│   │   ├── board.c
 | 
			
		||||
│   │   ├── board.h
 | 
			
		||||
│   │   └── board.mk
 | 
			
		||||
│   ├── PJRC_TEENSY_LC
 | 
			
		||||
│   │   ├── board.c
 | 
			
		||||
│   │   ├── board.h
 | 
			
		||||
│   │   └── board.mk
 | 
			
		||||
│   ├── readme.txt
 | 
			
		||||
│   ├── simulator
 | 
			
		||||
│   │   ├── board.c
 | 
			
		||||
│   │   ├── board.h
 | 
			
		||||
│   │   └── board.mk
 | 
			
		||||
│   ├── ST_NUCLEO_F030R8
 | 
			
		||||
│   │   ├── board.c
 | 
			
		||||
│   │   ├── board.h
 | 
			
		||||
│   │   ├── board.mk
 | 
			
		||||
│   │   └── cfg
 | 
			
		||||
│   │       └── board.chcfg
 | 
			
		||||
├── hal.mk
 | 
			
		||||
├── include
 | 
			
		||||
│   ├── adc.h
 | 
			
		||||
│   ├── can.h
 | 
			
		||||
│   ├── dac.h
 | 
			
		||||
│   ├── ext.h
 | 
			
		||||
│   ├── gpt.h
 | 
			
		||||
│   ├── hal_channels.h
 | 
			
		||||
│   ├── hal_files.h
 | 
			
		||||
│   ├── hal.h
 | 
			
		||||
│   ├── hal_ioblock.h
 | 
			
		||||
│   ├── hal_mmcsd.h
 | 
			
		||||
│   ├── hal_queues.h
 | 
			
		||||
│   ├── hal_streams.h
 | 
			
		||||
│   ├── i2c.h
 | 
			
		||||
│   ├── i2s.h
 | 
			
		||||
│   ├── icu.h
 | 
			
		||||
│   ├── mac.h
 | 
			
		||||
│   ├── mii.h
 | 
			
		||||
│   ├── mmc_spi.h
 | 
			
		||||
│   ├── pal.h
 | 
			
		||||
│   ├── pwm.h
 | 
			
		||||
│   ├── rtc.h
 | 
			
		||||
│   ├── sdc.h
 | 
			
		||||
│   ├── serial.h
 | 
			
		||||
│   ├── serial_usb.h
 | 
			
		||||
│   ├── spi.h
 | 
			
		||||
│   ├── st.h
 | 
			
		||||
│   ├── uart.h
 | 
			
		||||
│   └── usb.h
 | 
			
		||||
├── lib
 | 
			
		||||
│   └── streams
 | 
			
		||||
│       ├── chprintf.c
 | 
			
		||||
│       ├── chprintf.h
 | 
			
		||||
│       ├── memstreams.c
 | 
			
		||||
│       ├── memstreams.h
 | 
			
		||||
│       ├── nullstreams.c
 | 
			
		||||
│       └── nullstreams.h
 | 
			
		||||
├── osal
 | 
			
		||||
│   ├── nil
 | 
			
		||||
│   │   ├── osal.c
 | 
			
		||||
│   │   ├── osal.h
 | 
			
		||||
│   │   └── osal.mk
 | 
			
		||||
│   ├── os-less
 | 
			
		||||
│   │   └── ARMCMx
 | 
			
		||||
│   │       ├── osal.c
 | 
			
		||||
│   │       ├── osal.h
 | 
			
		||||
│   │       └── osal.mk
 | 
			
		||||
│   └── rt
 | 
			
		||||
│       ├── osal.c
 | 
			
		||||
│       ├── osal.h
 | 
			
		||||
│       └── osal.mk
 | 
			
		||||
├── ports
 | 
			
		||||
│   ├── AVR
 | 
			
		||||
│   ├── common
 | 
			
		||||
│   │   └── ARMCMx
 | 
			
		||||
│   │       ├── mpu.h
 | 
			
		||||
│   │       ├── nvic.c
 | 
			
		||||
│   │       └── nvic.h
 | 
			
		||||
│   ├── KINETIS
 | 
			
		||||
│   │   ├── K20x
 | 
			
		||||
│   │   │   ├── hal_lld.c
 | 
			
		||||
│   │   │   ├── hal_lld.h
 | 
			
		||||
│   │   │   ├── kinetis_registry.h
 | 
			
		||||
│   │   │   ├── platform.dox
 | 
			
		||||
│   │   │   ├── platform.mk
 | 
			
		||||
│   │   │   ├── pwm_lld.c
 | 
			
		||||
│   │   │   ├── pwm_lld.h
 | 
			
		||||
│   │   │   ├── spi_lld.c
 | 
			
		||||
│   │   │   └── spi_lld.h
 | 
			
		||||
│   │   ├── KL2x
 | 
			
		||||
│   │   │   ├── hal_lld.c
 | 
			
		||||
│   │   │   ├── hal_lld.h
 | 
			
		||||
│   │   │   ├── kinetis_registry.h
 | 
			
		||||
│   │   │   ├── platform.mk
 | 
			
		||||
│   │   │   ├── pwm_lld.c
 | 
			
		||||
│   │   │   └── pwm_lld.h
 | 
			
		||||
│   │   ├── LLD
 | 
			
		||||
│   │   │   ├── adc_lld.c
 | 
			
		||||
│   │   │   ├── adc_lld.h
 | 
			
		||||
│   │   │   ├── ext_lld.c
 | 
			
		||||
│   │   │   ├── ext_lld.h
 | 
			
		||||
│   │   │   ├── gpt_lld.c
 | 
			
		||||
│   │   │   ├── gpt_lld.h
 | 
			
		||||
│   │   │   ├── i2c_lld.c
 | 
			
		||||
│   │   │   ├── i2c_lld.h
 | 
			
		||||
│   │   │   ├── pal_lld.c
 | 
			
		||||
│   │   │   ├── pal_lld.h
 | 
			
		||||
│   │   │   ├── serial_lld.c
 | 
			
		||||
│   │   │   ├── serial_lld.h
 | 
			
		||||
│   │   │   ├── st_lld.c
 | 
			
		||||
│   │   │   ├── st_lld.h
 | 
			
		||||
│   │   │   ├── usb_lld.c
 | 
			
		||||
│   │   │   └── usb_lld.h
 | 
			
		||||
│   │   └── README.md
 | 
			
		||||
│   ├── LPC
 | 
			
		||||
│   ├── simulator
 | 
			
		||||
│   └── STM32
 | 
			
		||||
├── src
 | 
			
		||||
│   ├── adc.c
 | 
			
		||||
│   ├── can.c
 | 
			
		||||
│   ├── dac.c
 | 
			
		||||
│   ├── ext.c
 | 
			
		||||
│   ├── gpt.c
 | 
			
		||||
│   ├── hal.c
 | 
			
		||||
│   ├── hal_mmcsd.c
 | 
			
		||||
│   ├── hal_queues.c
 | 
			
		||||
│   ├── i2c.c
 | 
			
		||||
│   ├── i2s.c
 | 
			
		||||
│   ├── icu.c
 | 
			
		||||
│   ├── mac.c
 | 
			
		||||
│   ├── mmc_spi.c
 | 
			
		||||
│   ├── pal.c
 | 
			
		||||
│   ├── pwm.c
 | 
			
		||||
│   ├── rtc.c
 | 
			
		||||
│   ├── sdc.c
 | 
			
		||||
│   ├── serial.c
 | 
			
		||||
│   ├── serial_usb.c
 | 
			
		||||
│   ├── spi.c
 | 
			
		||||
│   ├── st.c
 | 
			
		||||
│   ├── uart.c
 | 
			
		||||
│   └── usb.c
 | 
			
		||||
└── templates
 | 
			
		||||
    ├── adc_lld.c
 | 
			
		||||
    ├── adc_lld.h
 | 
			
		||||
    ├── can_lld.c
 | 
			
		||||
    ├── can_lld.h
 | 
			
		||||
    ├── dac_lld.c
 | 
			
		||||
    ├── dac_lld.h
 | 
			
		||||
    ├── ext_lld.c
 | 
			
		||||
    ├── ext_lld.h
 | 
			
		||||
    ├── gpt_lld.c
 | 
			
		||||
    ├── gpt_lld.h
 | 
			
		||||
    ├── halconf.h
 | 
			
		||||
    ├── hal_lld.c
 | 
			
		||||
    ├── hal_lld.h
 | 
			
		||||
    ├── i2c_lld.c
 | 
			
		||||
    ├── i2c_lld.h
 | 
			
		||||
    ├── i2s_lld.c
 | 
			
		||||
    ├── i2s_lld.h
 | 
			
		||||
    ├── icu_lld.c
 | 
			
		||||
    ├── icu_lld.h
 | 
			
		||||
    ├── mac_lld.c
 | 
			
		||||
    ├── mac_lld.h
 | 
			
		||||
    ├── mcuconf.h
 | 
			
		||||
    ├── osal
 | 
			
		||||
    │   ├── osal.c
 | 
			
		||||
    │   ├── osal.h
 | 
			
		||||
    │   └── osal.mk
 | 
			
		||||
    ├── pal_lld.c
 | 
			
		||||
    ├── pal_lld.h
 | 
			
		||||
    ├── platform.mk
 | 
			
		||||
    ├── pwm_lld.c
 | 
			
		||||
    ├── pwm_lld.h
 | 
			
		||||
    ├── rtc_lld.c
 | 
			
		||||
    ├── rtc_lld.h
 | 
			
		||||
    ├── sdc_lld.c
 | 
			
		||||
    ├── sdc_lld.h
 | 
			
		||||
    ├── serial_lld.c
 | 
			
		||||
    ├── serial_lld.h
 | 
			
		||||
    ├── spi_lld.c
 | 
			
		||||
    ├── spi_lld.h
 | 
			
		||||
    ├── st_lld.c
 | 
			
		||||
    ├── st_lld.h
 | 
			
		||||
    ├── uart_lld.c
 | 
			
		||||
    ├── uart_lld.h
 | 
			
		||||
    ├── usb_lld.c
 | 
			
		||||
    └── usb_lld.h
 | 
			
		||||
							
								
								
									
										85
									
								
								keyboards/infinity_ergodox/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								keyboards/infinity_ergodox/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,85 @@
 | 
			
		||||
# project specific files
 | 
			
		||||
SRC =	matrix.c \
 | 
			
		||||
	led.c
 | 
			
		||||
 | 
			
		||||
## chip/board settings
 | 
			
		||||
# - the next two should match the directories in
 | 
			
		||||
#   <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
 | 
			
		||||
# - For Teensies, FAMILY = KINETIS and SERIES is either
 | 
			
		||||
#   KL2x (LC) or K20x (3.0,3.1,3.2).
 | 
			
		||||
# - For Infinity KB, SERIES = K20x
 | 
			
		||||
MCU_FAMILY = KINETIS
 | 
			
		||||
MCU_SERIES = K20x
 | 
			
		||||
 | 
			
		||||
# Linker script to use
 | 
			
		||||
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
 | 
			
		||||
#   or <this_dir>/ld/
 | 
			
		||||
# - NOTE: a custom ld script is needed for EEPROM on Teensy LC
 | 
			
		||||
# - LDSCRIPT =
 | 
			
		||||
#   - MKL26Z64 for Teensy LC
 | 
			
		||||
#   - MK20DX128 for Teensy 3.0
 | 
			
		||||
#   - MK20DX256 for Teensy 3.1 and 3.2
 | 
			
		||||
#   - MK20DX128BLDR4 for Infinity 60% with Kiibohd bootloader
 | 
			
		||||
#   - MK20DX256BLDR8 for Infinity ErgoDox with Kiibohd bootloader
 | 
			
		||||
MCU_LDSCRIPT = MK20DX256BLDR8
 | 
			
		||||
 | 
			
		||||
# Startup code to use
 | 
			
		||||
#  - it should exist in <chibios>/os/common/ports/ARMCMx/compilers/GCC/mk/
 | 
			
		||||
# - STARTUP =
 | 
			
		||||
#   - kl2x for Teensy LC
 | 
			
		||||
#   - k20x5 for Teensy 3.0 and Infinity 60%
 | 
			
		||||
#   - k20x7 for Teensy 3.1, 3.2 and Infinity ErgoDox
 | 
			
		||||
MCU_STARTUP = k20x7
 | 
			
		||||
 | 
			
		||||
# Board: it should exist either in <chibios>/os/hal/boards/
 | 
			
		||||
#  or <this_dir>/boards
 | 
			
		||||
# - BOARD =
 | 
			
		||||
#   - PJRC_TEENSY_LC for Teensy LC
 | 
			
		||||
#   - PJRC_TEENSY_3 for Teensy 3.0
 | 
			
		||||
#   - PJRC_TEENSY_3_1 for Teensy 3.1 or 3.2
 | 
			
		||||
#   - MCHCK_K20 for Infinity KB
 | 
			
		||||
#BOARD = MCHCK_K20
 | 
			
		||||
BOARD = PJRC_TEENSY_3_1
 | 
			
		||||
 | 
			
		||||
# Cortex version
 | 
			
		||||
# Teensy LC is cortex-m0; Teensy 3.x are cortex-m4
 | 
			
		||||
MCU  = cortex-m4
 | 
			
		||||
 | 
			
		||||
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
 | 
			
		||||
# I.e. 6 for Teensy LC; 7 for Teensy 3.x
 | 
			
		||||
ARMV = 7
 | 
			
		||||
 | 
			
		||||
# Vector table for application
 | 
			
		||||
# 0x00000000-0x00001000 area is occupied by bootlaoder.*/
 | 
			
		||||
# The CORTEX_VTOR... is needed only for MCHCK/Infinity KB
 | 
			
		||||
OPT_DEFS = -DCORTEX_VTOR_INIT=0x00002000
 | 
			
		||||
 | 
			
		||||
# Build Options
 | 
			
		||||
#   comment out to disable the options.
 | 
			
		||||
#
 | 
			
		||||
BOOTMAGIC_ENABLE ?= yes	# Virtual DIP switch configuration
 | 
			
		||||
## (Note that for BOOTMAGIC on Teensy LC you have to use a custom .ld script.)
 | 
			
		||||
MOUSEKEY_ENABLE ?= yes	# Mouse keys
 | 
			
		||||
EXTRAKEY_ENABLE ?= yes	# Audio control and System control
 | 
			
		||||
CONSOLE_ENABLE ?= yes	# Console for debug
 | 
			
		||||
COMMAND_ENABLE ?= yes    # Commands for debug and configuration
 | 
			
		||||
SLEEP_LED_ENABLE ?= yes  # Breathing sleep LED during USB suspend
 | 
			
		||||
NKRO_ENABLE ?= yes	    # USB Nkey Rollover
 | 
			
		||||
CUSTOM_MATRIX ?= yes # Custom matrix file
 | 
			
		||||
SERIAL_LINK_ENABLE = yes
 | 
			
		||||
VISUALIZER_ENABLE ?= yes
 | 
			
		||||
LCD_ENABLE ?= yes
 | 
			
		||||
LED_ENABLE ?= yes
 | 
			
		||||
LCD_BACKLIGHT_ENABLE ?= yes
 | 
			
		||||
 | 
			
		||||
ifdef LCD_ENABLE
 | 
			
		||||
include drivers/gdisp/st7565ergodox/driver.mk
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifdef LED_ENABLE
 | 
			
		||||
include drivers/gdisp/IS31FL3731C/driver.mk
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifndef QUANTUM_DIR
 | 
			
		||||
	include ../../Makefile
 | 
			
		||||
endif
 | 
			
		||||
							
								
								
									
										1
									
								
								keyboards/infinity_ergodox/bootloader_defs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								keyboards/infinity_ergodox/bootloader_defs.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
#define KIIBOHD_BOOTLOADER
 | 
			
		||||
							
								
								
									
										524
									
								
								keyboards/infinity_ergodox/chconf.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										524
									
								
								keyboards/infinity_ergodox/chconf.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,524 @@
 | 
			
		||||
/*
 | 
			
		||||
    ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
 | 
			
		||||
 | 
			
		||||
    Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
    you may not use this file except in compliance with the License.
 | 
			
		||||
    You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
        http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
    Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
    distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
    See the License for the specific language governing permissions and
 | 
			
		||||
    limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file    templates/chconf.h
 | 
			
		||||
 * @brief   Configuration file template.
 | 
			
		||||
 * @details A copy of this file must be placed in each project directory, it
 | 
			
		||||
 *          contains the application specific kernel settings.
 | 
			
		||||
 *
 | 
			
		||||
 * @addtogroup config
 | 
			
		||||
 * @details Kernel related settings and hooks.
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _CHCONF_H_
 | 
			
		||||
#define _CHCONF_H_
 | 
			
		||||
 | 
			
		||||
#define _CHIBIOS_RT_CONF_
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/**
 | 
			
		||||
 * @name System timers settings
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   System time counter resolution.
 | 
			
		||||
 * @note    Allowed values are 16 or 32 bits.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_ST_RESOLUTION                32
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   System tick frequency.
 | 
			
		||||
 * @details Frequency of the system timer that drives the system ticks. This
 | 
			
		||||
 *          setting also defines the system tick time unit.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_ST_FREQUENCY                 100000
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Time delta constant for the tick-less mode.
 | 
			
		||||
 * @note    If this value is zero then the system uses the classic
 | 
			
		||||
 *          periodic tick. This value represents the minimum number
 | 
			
		||||
 *          of ticks that is safe to specify in a timeout directive.
 | 
			
		||||
 *          The value one is not valid, timeouts are rounded up to
 | 
			
		||||
 *          this value.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_ST_TIMEDELTA                 0
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/**
 | 
			
		||||
 * @name Kernel parameters and options
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Round robin interval.
 | 
			
		||||
 * @details This constant is the number of system ticks allowed for the
 | 
			
		||||
 *          threads before preemption occurs. Setting this value to zero
 | 
			
		||||
 *          disables the preemption for threads with equal priority and the
 | 
			
		||||
 *          round robin becomes cooperative. Note that higher priority
 | 
			
		||||
 *          threads can still preempt, the kernel is always preemptive.
 | 
			
		||||
 * @note    Disabling the round robin preemption makes the kernel more compact
 | 
			
		||||
 *          and generally faster.
 | 
			
		||||
 * @note    The round robin preemption is not supported in tickless mode and
 | 
			
		||||
 *          must be set to zero in that case.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_TIME_QUANTUM                 20
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Managed RAM size.
 | 
			
		||||
 * @details Size of the RAM area to be managed by the OS. If set to zero
 | 
			
		||||
 *          then the whole available RAM is used. The core memory is made
 | 
			
		||||
 *          available to the heap allocator and/or can be used directly through
 | 
			
		||||
 *          the simplified core memory allocator.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    In order to let the OS manage the whole RAM the linker script must
 | 
			
		||||
 *          provide the @p __heap_base__ and @p __heap_end__ symbols.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_MEMCORE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_MEMCORE_SIZE                 0
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Idle thread automatic spawn suppression.
 | 
			
		||||
 * @details When this option is activated the function @p chSysInit()
 | 
			
		||||
 *          does not spawn the idle thread. The application @p main()
 | 
			
		||||
 *          function becomes the idle thread and must implement an
 | 
			
		||||
 *          infinite loop.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_NO_IDLE_THREAD               FALSE
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/**
 | 
			
		||||
 * @name Performance options
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   OS optimization.
 | 
			
		||||
 * @details If enabled then time efficient rather than space efficient code
 | 
			
		||||
 *          is used when two possible implementations exist.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    This is not related to the compiler optimization options.
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_OPTIMIZE_SPEED               TRUE
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/**
 | 
			
		||||
 * @name Subsystem options
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Time Measurement APIs.
 | 
			
		||||
 * @details If enabled then the time measurement APIs are included in
 | 
			
		||||
 *          the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_TM                       FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Threads registry APIs.
 | 
			
		||||
 * @details If enabled then the registry APIs are included in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_REGISTRY                 TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Threads synchronization APIs.
 | 
			
		||||
 * @details If enabled then the @p chThdWait() function is included in
 | 
			
		||||
 *          the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_WAITEXIT                 TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Semaphores APIs.
 | 
			
		||||
 * @details If enabled then the Semaphores APIs are included in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_SEMAPHORES               TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Semaphores queuing mode.
 | 
			
		||||
 * @details If enabled then the threads are enqueued on semaphores by
 | 
			
		||||
 *          priority rather than in FIFO order.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE. Enable this if you have special
 | 
			
		||||
 *          requirements.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_SEMAPHORES.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_SEMAPHORES_PRIORITY      FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Mutexes APIs.
 | 
			
		||||
 * @details If enabled then the mutexes APIs are included in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_MUTEXES                  TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables recursive behavior on mutexes.
 | 
			
		||||
 * @note    Recursive mutexes are heavier and have an increased
 | 
			
		||||
 *          memory footprint.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_MUTEXES.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_MUTEXES_RECURSIVE        FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Conditional Variables APIs.
 | 
			
		||||
 * @details If enabled then the conditional variables APIs are included
 | 
			
		||||
 *          in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_MUTEXES.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_CONDVARS                 TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Conditional Variables APIs with timeout.
 | 
			
		||||
 * @details If enabled then the conditional variables APIs with timeout
 | 
			
		||||
 *          specification are included in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_CONDVARS.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_CONDVARS_TIMEOUT         TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Events Flags APIs.
 | 
			
		||||
 * @details If enabled then the event flags APIs are included in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_EVENTS                   TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Events Flags APIs with timeout.
 | 
			
		||||
 * @details If enabled then the events APIs with timeout specification
 | 
			
		||||
 *          are included in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_EVENTS.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_EVENTS_TIMEOUT           TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Synchronous Messages APIs.
 | 
			
		||||
 * @details If enabled then the synchronous messages APIs are included
 | 
			
		||||
 *          in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_MESSAGES                 TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Synchronous Messages queuing mode.
 | 
			
		||||
 * @details If enabled then messages are served by priority rather than in
 | 
			
		||||
 *          FIFO order.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE. Enable this if you have special
 | 
			
		||||
 *          requirements.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_MESSAGES.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_MESSAGES_PRIORITY        FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Mailboxes APIs.
 | 
			
		||||
 * @details If enabled then the asynchronous messages (mailboxes) APIs are
 | 
			
		||||
 *          included in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_SEMAPHORES.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_MAILBOXES                TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   I/O Queues APIs.
 | 
			
		||||
 * @details If enabled then the I/O queues APIs are included in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_QUEUES                   TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Core Memory Manager APIs.
 | 
			
		||||
 * @details If enabled then the core memory manager APIs are included
 | 
			
		||||
 *          in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_MEMCORE                  TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Heap Allocator APIs.
 | 
			
		||||
 * @details If enabled then the memory heap allocator APIs are included
 | 
			
		||||
 *          in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
 | 
			
		||||
 *          @p CH_CFG_USE_SEMAPHORES.
 | 
			
		||||
 * @note    Mutexes are recommended.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_HEAP                     TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Memory Pools Allocator APIs.
 | 
			
		||||
 * @details If enabled then the memory pools allocator APIs are included
 | 
			
		||||
 *          in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_MEMPOOLS                 TRUE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Dynamic Threads APIs.
 | 
			
		||||
 * @details If enabled then the dynamic threads creation APIs are included
 | 
			
		||||
 *          in the kernel.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p TRUE.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_WAITEXIT.
 | 
			
		||||
 * @note    Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_USE_DYNAMIC                  TRUE
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/**
 | 
			
		||||
 * @name Debug options
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Debug option, kernel statistics.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_DBG_STATISTICS                   FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Debug option, system state check.
 | 
			
		||||
 * @details If enabled the correct call protocol for system APIs is checked
 | 
			
		||||
 *          at runtime.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_DBG_SYSTEM_STATE_CHECK           FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Debug option, parameters checks.
 | 
			
		||||
 * @details If enabled then the checks on the API functions input
 | 
			
		||||
 *          parameters are activated.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_DBG_ENABLE_CHECKS                FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Debug option, consistency checks.
 | 
			
		||||
 * @details If enabled then all the assertions in the kernel code are
 | 
			
		||||
 *          activated. This includes consistency checks inside the kernel,
 | 
			
		||||
 *          runtime anomalies and port-defined checks.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_DBG_ENABLE_ASSERTS               FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Debug option, trace buffer.
 | 
			
		||||
 * @details If enabled then the context switch circular trace buffer is
 | 
			
		||||
 *          activated.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_DBG_ENABLE_TRACE                 FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Debug option, stack checks.
 | 
			
		||||
 * @details If enabled then a runtime stack check is performed.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE.
 | 
			
		||||
 * @note    The stack check is performed in a architecture/port dependent way.
 | 
			
		||||
 *          It may not be implemented or some ports.
 | 
			
		||||
 * @note    The default failure mode is to halt the system with the global
 | 
			
		||||
 *          @p panic_msg variable set to @p NULL.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_DBG_ENABLE_STACK_CHECK           FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Debug option, stacks initialization.
 | 
			
		||||
 * @details If enabled then the threads working area is filled with a byte
 | 
			
		||||
 *          value when a thread is created. This can be useful for the
 | 
			
		||||
 *          runtime measurement of the used stack.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_DBG_FILL_THREADS                 FALSE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Debug option, threads profiling.
 | 
			
		||||
 * @details If enabled then a field is added to the @p thread_t structure that
 | 
			
		||||
 *          counts the system ticks occurred while executing the thread.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    The default is @p FALSE.
 | 
			
		||||
 * @note    This debug option is not currently compatible with the
 | 
			
		||||
 *          tickless mode.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_DBG_THREADS_PROFILING            FALSE
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/**
 | 
			
		||||
 * @name Kernel hooks
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Threads descriptor structure extension.
 | 
			
		||||
 * @details User fields added to the end of the @p thread_t structure.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_THREAD_EXTRA_FIELDS                                          \
 | 
			
		||||
  /* Add threads custom fields here.*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Threads initialization hook.
 | 
			
		||||
 * @details User initialization code added to the @p chThdInit() API.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    It is invoked from within @p chThdInit() and implicitly from all
 | 
			
		||||
 *          the threads creation APIs.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_THREAD_INIT_HOOK(tp) {                                       \
 | 
			
		||||
  /* Add threads initialization code here.*/                                \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Threads finalization hook.
 | 
			
		||||
 * @details User finalization code added to the @p chThdExit() API.
 | 
			
		||||
 *
 | 
			
		||||
 * @note    It is inserted into lock zone.
 | 
			
		||||
 * @note    It is also invoked when the threads simply return in order to
 | 
			
		||||
 *          terminate.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_THREAD_EXIT_HOOK(tp) {                                       \
 | 
			
		||||
  /* Add threads finalization code here.*/                                  \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Context switch hook.
 | 
			
		||||
 * @details This hook is invoked just before switching between threads.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) {                              \
 | 
			
		||||
  /* Context switch code here.*/                                            \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   ISR enter hook.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_IRQ_PROLOGUE_HOOK() {                                        \
 | 
			
		||||
  /* IRQ prologue code here.*/                                              \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   ISR exit hook.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_IRQ_EPILOGUE_HOOK() {                                        \
 | 
			
		||||
  /* IRQ epilogue code here.*/                                              \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Idle thread enter hook.
 | 
			
		||||
 * @note    This hook is invoked within a critical zone, no OS functions
 | 
			
		||||
 *          should be invoked from here.
 | 
			
		||||
 * @note    This macro can be used to activate a power saving mode.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_IDLE_ENTER_HOOK() {                                          \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Idle thread leave hook.
 | 
			
		||||
 * @note    This hook is invoked within a critical zone, no OS functions
 | 
			
		||||
 *          should be invoked from here.
 | 
			
		||||
 * @note    This macro can be used to deactivate a power saving mode.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_IDLE_LEAVE_HOOK() {                                          \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Idle Loop hook.
 | 
			
		||||
 * @details This hook is continuously invoked by the idle thread loop.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_IDLE_LOOP_HOOK() {                                           \
 | 
			
		||||
  /* Idle loop code here.*/                                                 \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   System tick event hook.
 | 
			
		||||
 * @details This hook is invoked in the system tick handler immediately
 | 
			
		||||
 *          after processing the virtual timers queue.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_SYSTEM_TICK_HOOK() {                                         \
 | 
			
		||||
  /* System tick event code here.*/                                         \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   System halt hook.
 | 
			
		||||
 * @details This hook is invoked in case to a system halting error before
 | 
			
		||||
 *          the system is halted.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_SYSTEM_HALT_HOOK(reason) {                                   \
 | 
			
		||||
  /* System halt code here.*/                                               \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Trace hook.
 | 
			
		||||
 * @details This hook is invoked each time a new record is written in the
 | 
			
		||||
 *          trace buffer.
 | 
			
		||||
 */
 | 
			
		||||
#define CH_CFG_TRACE_HOOK(tep) {                                            \
 | 
			
		||||
  /* Trace code here.*/                                                     \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Port-specific settings (override port settings defaulted in chcore.h).    */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
#endif  /* _CHCONF_H_ */
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
@ -18,7 +18,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#ifndef CONFIG_H
 | 
			
		||||
#define CONFIG_H
 | 
			
		||||
 | 
			
		||||
#include "config_common.h"
 | 
			
		||||
 | 
			
		||||
/* USB Device descriptor parameter */
 | 
			
		||||
#define VENDOR_ID       0xFEED
 | 
			
		||||
@ -27,15 +26,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
/* in python2: list(u"whatever".encode('utf-16-le')) */
 | 
			
		||||
/*   at most 32 characters or the ugly hack in usb_main.c borks */
 | 
			
		||||
#define MANUFACTURER "TMK"
 | 
			
		||||
#define USBSTR_MANUFACTURER    'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', '\xc6', '\x00'
 | 
			
		||||
#define PRODUCT "ChibiOS TMK test"
 | 
			
		||||
#define USBSTR_PRODUCT         'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
 | 
			
		||||
#define DESCRIPTION "TMK keyboard firmware over ChibiOS"
 | 
			
		||||
#define USBSTR_MANUFACTURER    'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00'
 | 
			
		||||
#define PRODUCT "Infinity keyboard/TMK"
 | 
			
		||||
#define USBSTR_PRODUCT         'I', '\x00', 'n', '\x00', 'f', '\x00', 'i', '\x00', 'n', '\x00', 'i', '\x00', 't', '\x00', 'y', '\x00', ' ', '\x00', 'k', '\x00', 'e', '\x00', 'y', '\x00', 'b', '\x00', 'o', '\x00', 'a', '\x00', 'r', '\x00', 'd', '\x00', '/', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00'
 | 
			
		||||
 | 
			
		||||
/* key matrix size */
 | 
			
		||||
#define MATRIX_ROWS 1
 | 
			
		||||
#define MATRIX_COLS 1
 | 
			
		||||
#define DIODE_DIRECTION COL2ROW
 | 
			
		||||
#define MATRIX_ROWS 18
 | 
			
		||||
#define MATRIX_COLS 5
 | 
			
		||||
#define LOCAL_MATRIX_ROWS 9
 | 
			
		||||
 | 
			
		||||
/* define if matrix has ghost */
 | 
			
		||||
//#define MATRIX_HAS_GHOST
 | 
			
		||||
@ -44,16 +42,22 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#define DEBOUNCE    5
 | 
			
		||||
 | 
			
		||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
 | 
			
		||||
#define LOCKING_SUPPORT_ENABLE
 | 
			
		||||
//#define LOCKING_SUPPORT_ENABLE
 | 
			
		||||
/* Locking resynchronize hack */
 | 
			
		||||
#define LOCKING_RESYNC_ENABLE
 | 
			
		||||
//#define LOCKING_RESYNC_ENABLE
 | 
			
		||||
 | 
			
		||||
/* key combination for command */
 | 
			
		||||
#define IS_COMMAND() ( \
 | 
			
		||||
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
/* Keymap for Infiity prototype */
 | 
			
		||||
#define INFINITY_PROTOTYPE
 | 
			
		||||
 | 
			
		||||
#define SERIAL_LINK_BAUD 562500
 | 
			
		||||
#define SERIAL_LINK_THREAD_PRIORITY (NORMALPRIO - 1)
 | 
			
		||||
// The visualizer needs gfx thread priorities
 | 
			
		||||
#define VISUALIZER_THREAD_PRIORITY (NORMAL_PRIORITY - 2)
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Feature disable options
 | 
			
		||||
@ -0,0 +1,113 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef _GDISP_LLD_BOARD_H
 | 
			
		||||
#define _GDISP_LLD_BOARD_H
 | 
			
		||||
 | 
			
		||||
static const I2CConfig i2ccfg = {
 | 
			
		||||
  400000 // clock speed (Hz); 400kHz max for IS31
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define GDISP_SCREEN_WIDTH  7
 | 
			
		||||
#define GDISP_SCREEN_HEIGHT 7
 | 
			
		||||
 | 
			
		||||
static const uint8_t led_mask[] = {
 | 
			
		||||
	0xFF, 0x00, /* C1-1 -> C1-16 */
 | 
			
		||||
	0xFF, 0x00, /* C2-1 -> C2-16 */
 | 
			
		||||
	0xFF, 0x00, /* C3-1 -> C3-16 */
 | 
			
		||||
	0xFF, 0x00, /* C4-1 -> C4-16 */
 | 
			
		||||
	0x3F, 0x00, /* C5-1 -> C5-16 */
 | 
			
		||||
	0x00, 0x00, /* C6-1 -> C6-16 */
 | 
			
		||||
	0x00, 0x00, /* C7-1 -> C7-16 */
 | 
			
		||||
	0x00, 0x00, /* C8-1 -> C8-16 */
 | 
			
		||||
	0x00, 0x00, /* C9-1 -> C9-16 */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// The address of the LED
 | 
			
		||||
#define LA(c, r) (c + r * 16 )
 | 
			
		||||
// Need to be an address that is not mapped, but inside the range of the controller matrix
 | 
			
		||||
#define NA LA(8, 8)
 | 
			
		||||
 | 
			
		||||
// The numbers in the comments are the led numbers DXX on the PCB
 | 
			
		||||
// The mapping is taken from the schematic of left hand side
 | 
			
		||||
static const uint8_t led_mapping[GDISP_SCREEN_HEIGHT][GDISP_SCREEN_WIDTH] = {
 | 
			
		||||
//   45        44        43        42        41        40        39
 | 
			
		||||
   { LA(1, 1), LA(1, 0), LA(0, 4), LA(0, 3), LA(0, 2), LA(0, 1), LA(0, 0)},
 | 
			
		||||
//   52        51        50        49        48        47        46
 | 
			
		||||
   { LA(2, 3), LA(2, 2), LA(2, 1), LA(2, 0), LA(1, 4), LA(1, 3), LA(1, 2) },
 | 
			
		||||
//   58        57        56        55        54        53        N/A
 | 
			
		||||
   { LA(3, 4), LA(3, 3), LA(3, 2), LA(3, 1), LA(3, 0), LA(2, 4), NA },
 | 
			
		||||
//   67        66        65        64        63        62        61
 | 
			
		||||
   { LA(5, 3), LA(5, 2), LA(5, 1), LA(5, 0), LA(4, 4), LA(4, 3), LA(4, 2) },
 | 
			
		||||
//   76        75        74        73        72        60        59
 | 
			
		||||
   { LA(7, 3), LA(7, 2), LA(7, 1), LA(7, 0), LA(6, 3), LA(4, 1), LA(4, 0) },
 | 
			
		||||
//   N/A       N/A       N/A       N/A       N/A       N/A       68
 | 
			
		||||
   { NA,       NA,       NA,       NA,       NA,       NA,       LA(5, 4) },
 | 
			
		||||
//   N/A       N/A       N/A       N/A       71        70        69
 | 
			
		||||
   { NA,       NA,       NA,       NA,       LA(6, 2), LA(6, 1), LA(6, 0) },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define IS31_ADDR_DEFAULT 0x74 // AD connected to GND
 | 
			
		||||
#define IS31_TIMEOUT 5000
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void init_board(GDisplay *g) {
 | 
			
		||||
    (void) g;
 | 
			
		||||
    /* I2C pins */
 | 
			
		||||
    palSetPadMode(GPIOB, 0, PAL_MODE_ALTERNATIVE_2); // PTB0/I2C0/SCL
 | 
			
		||||
    palSetPadMode(GPIOB, 1, PAL_MODE_ALTERNATIVE_2); // PTB1/I2C0/SDA
 | 
			
		||||
    palSetPadMode(GPIOB, 16, PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palClearPad(GPIOB, 16);
 | 
			
		||||
    /* start I2C */
 | 
			
		||||
    i2cStart(&I2CD1, &i2ccfg);
 | 
			
		||||
    // try high drive (from kiibohd)
 | 
			
		||||
    I2CD1.i2c->C2 |= I2Cx_C2_HDRS;
 | 
			
		||||
    // try glitch fixing (from kiibohd)
 | 
			
		||||
    I2CD1.i2c->FLT = 4;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void post_init_board(GDisplay *g) {
 | 
			
		||||
	(void) g;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE const uint8_t* get_led_mask(GDisplay* g) {
 | 
			
		||||
    (void) g;
 | 
			
		||||
    return led_mask;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE uint8_t get_led_address(GDisplay* g, uint16_t x, uint16_t y)
 | 
			
		||||
{
 | 
			
		||||
    (void) g;
 | 
			
		||||
    return led_mapping[y][x];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void set_hardware_shutdown(GDisplay* g, bool shutdown) {
 | 
			
		||||
    (void) g;
 | 
			
		||||
    if(!shutdown) {
 | 
			
		||||
        palSetPad(GPIOB, 16);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        palClearPad(GPIOB, 16);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
 | 
			
		||||
	(void) g;
 | 
			
		||||
	i2cMasterTransmitTimeout(&I2CD1, IS31_ADDR_DEFAULT, data, length, 0, 0, US2ST(IS31_TIMEOUT));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* _GDISP_LLD_BOARD_H */
 | 
			
		||||
@ -0,0 +1,2 @@
 | 
			
		||||
GFXINC += drivers/gdisp/IS31FL3731C
 | 
			
		||||
GFXSRC += drivers/gdisp/IS31FL3731C/gdisp_IS31FL3731C.c
 | 
			
		||||
@ -0,0 +1,333 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "gfx.h"
 | 
			
		||||
 | 
			
		||||
#if GFX_USE_GDISP
 | 
			
		||||
 | 
			
		||||
#define GDISP_DRIVER_VMT			GDISPVMT_IS31FL3731C_ERGODOX
 | 
			
		||||
#include "drivers/gdisp/IS31FL3731C/gdisp_lld_config.h"
 | 
			
		||||
#include "src/gdisp/gdisp_driver.h"
 | 
			
		||||
 | 
			
		||||
#include "board_IS31FL3731C.h"
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Driver local definitions.                                                 */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
#ifndef GDISP_SCREEN_HEIGHT
 | 
			
		||||
	#define GDISP_SCREEN_HEIGHT		9
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_SCREEN_WIDTH
 | 
			
		||||
	#define GDISP_SCREEN_WIDTH		16
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_INITIAL_CONTRAST
 | 
			
		||||
	#define GDISP_INITIAL_CONTRAST	0
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_INITIAL_BACKLIGHT
 | 
			
		||||
	#define GDISP_INITIAL_BACKLIGHT	100
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define GDISP_FLG_NEEDFLUSH			(GDISP_FLG_DRIVER<<0)
 | 
			
		||||
 | 
			
		||||
#define IS31_ADDR_DEFAULT 0x74
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_CONFIG  0x00
 | 
			
		||||
// bits in reg
 | 
			
		||||
#define IS31_REG_CONFIG_PICTUREMODE 0x00
 | 
			
		||||
#define IS31_REG_CONFIG_AUTOPLAYMODE 0x08
 | 
			
		||||
#define IS31_REG_CONFIG_AUDIOPLAYMODE 0x18
 | 
			
		||||
// D2:D0 bits are starting frame for autoplay mode
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_PICTDISP 0x01 // D2:D0 frame select for picture mode
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_AUTOPLAYCTRL1 0x02
 | 
			
		||||
// D6:D4 number of loops (000=infty)
 | 
			
		||||
// D2:D0 number of frames to be used
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_AUTOPLAYCTRL2 0x03 // D5:D0 delay time (*11ms)
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_DISPLAYOPT 0x05
 | 
			
		||||
#define IS31_REG_DISPLAYOPT_INTENSITY_SAME 0x20 // same intensity for all frames
 | 
			
		||||
#define IS31_REG_DISPLAYOPT_BLINK_ENABLE 0x8
 | 
			
		||||
// D2:D0 bits blink period time (*0.27s)
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_AUDIOSYNC 0x06
 | 
			
		||||
#define IS31_REG_AUDIOSYNC_ENABLE 0x1
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_FRAMESTATE 0x07
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_BREATHCTRL1 0x08
 | 
			
		||||
// D6:D4 fade out time (26ms*2^i)
 | 
			
		||||
// D2:D0 fade in time (26ms*2^i)
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_BREATHCTRL2 0x09
 | 
			
		||||
#define IS31_REG_BREATHCTRL2_ENABLE 0x10
 | 
			
		||||
// D2:D0 extinguish time (3.5ms*2^i)
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_SHUTDOWN 0x0A
 | 
			
		||||
#define IS31_REG_SHUTDOWN_OFF 0x0
 | 
			
		||||
#define IS31_REG_SHUTDOWN_ON 0x1
 | 
			
		||||
 | 
			
		||||
#define IS31_REG_AGCCTRL 0x0B
 | 
			
		||||
#define IS31_REG_ADCRATE 0x0C
 | 
			
		||||
 | 
			
		||||
#define IS31_COMMANDREGISTER 0xFD
 | 
			
		||||
#define IS31_FUNCTIONREG 0x0B    // helpfully called 'page nine'
 | 
			
		||||
#define IS31_FUNCTIONREG_SIZE 0xD
 | 
			
		||||
 | 
			
		||||
#define IS31_FRAME_SIZE 0xB4
 | 
			
		||||
 | 
			
		||||
#define IS31_PWM_REG 0x24
 | 
			
		||||
#define IS31_PWM_SIZE 0x90
 | 
			
		||||
 | 
			
		||||
#define IS31_LED_MASK_SIZE 0x12
 | 
			
		||||
#define IS31_SCREEN_WIDTH 16
 | 
			
		||||
 | 
			
		||||
#define IS31
 | 
			
		||||
 | 
			
		||||
//Generated by http://jared.geek.nz/2013/feb/linear-led-pwm
 | 
			
		||||
const unsigned char cie[256] = {
 | 
			
		||||
    0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
 | 
			
		||||
    1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
 | 
			
		||||
    2, 2, 2, 3, 3, 3, 3, 3, 3, 3,
 | 
			
		||||
    3, 4, 4, 4, 4, 4, 4, 5, 5, 5,
 | 
			
		||||
    5, 5, 6, 6, 6, 6, 6, 7, 7, 7,
 | 
			
		||||
    7, 8, 8, 8, 8, 9, 9, 9, 10, 10,
 | 
			
		||||
    10, 10, 11, 11, 11, 12, 12, 12, 13, 13,
 | 
			
		||||
    13, 14, 14, 15, 15, 15, 16, 16, 17, 17,
 | 
			
		||||
    17, 18, 18, 19, 19, 20, 20, 21, 21, 22,
 | 
			
		||||
    22, 23, 23, 24, 24, 25, 25, 26, 26, 27,
 | 
			
		||||
    28, 28, 29, 29, 30, 31, 31, 32, 32, 33,
 | 
			
		||||
    34, 34, 35, 36, 37, 37, 38, 39, 39, 40,
 | 
			
		||||
    41, 42, 43, 43, 44, 45, 46, 47, 47, 48,
 | 
			
		||||
    49, 50, 51, 52, 53, 54, 54, 55, 56, 57,
 | 
			
		||||
    58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
 | 
			
		||||
    68, 70, 71, 72, 73, 74, 75, 76, 77, 79,
 | 
			
		||||
    80, 81, 82, 83, 85, 86, 87, 88, 90, 91,
 | 
			
		||||
    92, 94, 95, 96, 98, 99, 100, 102, 103, 105,
 | 
			
		||||
    106, 108, 109, 110, 112, 113, 115, 116, 118, 120,
 | 
			
		||||
    121, 123, 124, 126, 128, 129, 131, 132, 134, 136,
 | 
			
		||||
    138, 139, 141, 143, 145, 146, 148, 150, 152, 154,
 | 
			
		||||
    155, 157, 159, 161, 163, 165, 167, 169, 171, 173,
 | 
			
		||||
    175, 177, 179, 181, 183, 185, 187, 189, 191, 193,
 | 
			
		||||
    196, 198, 200, 202, 204, 207, 209, 211, 214, 216,
 | 
			
		||||
    218, 220, 223, 225, 228, 230, 232, 235, 237, 240,
 | 
			
		||||
    242, 245, 247, 250, 252, 255,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Driver local functions.                                                   */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
typedef struct{
 | 
			
		||||
    uint8_t write_buffer_offset;
 | 
			
		||||
    uint8_t write_buffer[IS31_FRAME_SIZE];
 | 
			
		||||
    uint8_t frame_buffer[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH];
 | 
			
		||||
    uint8_t page;
 | 
			
		||||
}__attribute__((__packed__)) PrivData;
 | 
			
		||||
 | 
			
		||||
// Some common routines and macros
 | 
			
		||||
#define PRIV(g)                         ((PrivData*)g->priv)
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Driver exported functions.                                                */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void write_page(GDisplay* g, uint8_t page) {
 | 
			
		||||
    uint8_t tx[2] __attribute__((aligned(2)));
 | 
			
		||||
    tx[0] = IS31_COMMANDREGISTER;
 | 
			
		||||
    tx[1] = page;
 | 
			
		||||
    write_data(g, tx, 2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void write_register(GDisplay* g, uint8_t page, uint8_t reg, uint8_t data) {
 | 
			
		||||
    uint8_t tx[2] __attribute__((aligned(2)));
 | 
			
		||||
    tx[0] = reg;
 | 
			
		||||
    tx[1] = data;
 | 
			
		||||
    write_page(g, page);
 | 
			
		||||
    write_data(g, tx, 2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void write_ram(GDisplay *g, uint8_t page, uint16_t offset, uint16_t length) {
 | 
			
		||||
    PRIV(g)->write_buffer_offset = offset;
 | 
			
		||||
    write_page(g, page);
 | 
			
		||||
    write_data(g, (uint8_t*)PRIV(g), length + 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
 | 
			
		||||
	// The private area is the display surface.
 | 
			
		||||
	g->priv = gfxAlloc(sizeof(PrivData));
 | 
			
		||||
    __builtin_memset(PRIV(g), 0, sizeof(PrivData));
 | 
			
		||||
	PRIV(g)->page = 0;
 | 
			
		||||
 | 
			
		||||
	// Initialise the board interface
 | 
			
		||||
	init_board(g);
 | 
			
		||||
	gfxSleepMilliseconds(10);
 | 
			
		||||
 | 
			
		||||
    // zero function page, all registers (assuming full_page is all zeroes)
 | 
			
		||||
    write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE);
 | 
			
		||||
    set_hardware_shutdown(g, false);
 | 
			
		||||
    gfxSleepMilliseconds(10);
 | 
			
		||||
    // software shutdown
 | 
			
		||||
    write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
 | 
			
		||||
    gfxSleepMilliseconds(10);
 | 
			
		||||
    // zero function page, all registers
 | 
			
		||||
    write_ram(g, IS31_FUNCTIONREG, 0, IS31_FUNCTIONREG_SIZE);
 | 
			
		||||
    gfxSleepMilliseconds(10);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    // zero all LED registers on all 8 pages, and enable the mask
 | 
			
		||||
    __builtin_memcpy(PRIV(g)->write_buffer, get_led_mask(g), IS31_LED_MASK_SIZE);
 | 
			
		||||
    for(uint8_t i=0; i<8; i++) {
 | 
			
		||||
        write_ram(g, i, 0, IS31_FRAME_SIZE);
 | 
			
		||||
        gfxSleepMilliseconds(1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // software shutdown disable (i.e. turn stuff on)
 | 
			
		||||
    write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
 | 
			
		||||
    gfxSleepMilliseconds(10);
 | 
			
		||||
 | 
			
		||||
    // Finish Init
 | 
			
		||||
    post_init_board(g);
 | 
			
		||||
 | 
			
		||||
	/* Initialise the GDISP structure */
 | 
			
		||||
	g->g.Width = GDISP_SCREEN_WIDTH;
 | 
			
		||||
	g->g.Height = GDISP_SCREEN_HEIGHT;
 | 
			
		||||
	g->g.Orientation = GDISP_ROTATE_0;
 | 
			
		||||
	g->g.Powermode = powerOn;
 | 
			
		||||
	g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
 | 
			
		||||
	g->g.Contrast = GDISP_INITIAL_CONTRAST;
 | 
			
		||||
	return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if GDISP_HARDWARE_FLUSH
 | 
			
		||||
	LLDSPEC void gdisp_lld_flush(GDisplay *g) {
 | 
			
		||||
		// Don't flush if we don't need it.
 | 
			
		||||
		if (!(g->flags & GDISP_FLG_NEEDFLUSH))
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		PRIV(g)->page++;
 | 
			
		||||
		PRIV(g)->page %= 2;
 | 
			
		||||
		// TODO: some smarter algorithm for this
 | 
			
		||||
		// We should run only one physical page at a time
 | 
			
		||||
		// This way we don't need to send so much data, and
 | 
			
		||||
		// we could use slightly less memory
 | 
			
		||||
		uint8_t* src = PRIV(g)->frame_buffer;
 | 
			
		||||
		for (int y=0;y<GDISP_SCREEN_HEIGHT;y++) {
 | 
			
		||||
		    for (int x=0;x<GDISP_SCREEN_WIDTH;x++) {
 | 
			
		||||
		        PRIV(g)->write_buffer[get_led_address(g, x, y)]=cie[*src];
 | 
			
		||||
		        ++src;
 | 
			
		||||
		    }
 | 
			
		||||
		}
 | 
			
		||||
        write_ram(g, PRIV(g)->page, IS31_PWM_REG, IS31_PWM_SIZE);
 | 
			
		||||
        gfxSleepMilliseconds(1);
 | 
			
		||||
        write_register(g, IS31_FUNCTIONREG, IS31_REG_PICTDISP, PRIV(g)->page);
 | 
			
		||||
 | 
			
		||||
		g->flags &= ~GDISP_FLG_NEEDFLUSH;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if GDISP_HARDWARE_DRAWPIXEL
 | 
			
		||||
	LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
 | 
			
		||||
		coord_t		x, y;
 | 
			
		||||
 | 
			
		||||
		switch(g->g.Orientation) {
 | 
			
		||||
		default:
 | 
			
		||||
		case GDISP_ROTATE_0:
 | 
			
		||||
			x = g->p.x;
 | 
			
		||||
			y = g->p.y;
 | 
			
		||||
			break;
 | 
			
		||||
		case GDISP_ROTATE_180:
 | 
			
		||||
			x = GDISP_SCREEN_WIDTH-1 - g->p.x;
 | 
			
		||||
			y = g->p.y;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x] = gdispColor2Native(g->p.color);
 | 
			
		||||
		g->flags |= GDISP_FLG_NEEDFLUSH;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if GDISP_HARDWARE_PIXELREAD
 | 
			
		||||
	LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
 | 
			
		||||
		coord_t		x, y;
 | 
			
		||||
 | 
			
		||||
		switch(g->g.Orientation) {
 | 
			
		||||
		default:
 | 
			
		||||
		case GDISP_ROTATE_0:
 | 
			
		||||
			x = g->p.x;
 | 
			
		||||
			y = g->p.y;
 | 
			
		||||
			break;
 | 
			
		||||
		case GDISP_ROTATE_180:
 | 
			
		||||
			x = GDISP_SCREEN_WIDTH-1 - g->p.x;
 | 
			
		||||
			y = g->p.y;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		return gdispNative2Color(PRIV(g)->frame_buffer[y * GDISP_SCREEN_WIDTH + x]);
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
 | 
			
		||||
	LLDSPEC void gdisp_lld_control(GDisplay *g) {
 | 
			
		||||
		switch(g->p.x) {
 | 
			
		||||
		case GDISP_CONTROL_POWER:
 | 
			
		||||
			if (g->g.Powermode == (powermode_t)g->p.ptr)
 | 
			
		||||
				return;
 | 
			
		||||
			switch((powermode_t)g->p.ptr) {
 | 
			
		||||
			case powerOff:
 | 
			
		||||
			case powerSleep:
 | 
			
		||||
			case powerDeepSleep:
 | 
			
		||||
                write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_OFF);
 | 
			
		||||
				break;
 | 
			
		||||
			case powerOn:
 | 
			
		||||
                write_register(g, IS31_FUNCTIONREG, IS31_REG_SHUTDOWN, IS31_REG_SHUTDOWN_ON);
 | 
			
		||||
				break;
 | 
			
		||||
			default:
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			g->g.Powermode = (powermode_t)g->p.ptr;
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		case GDISP_CONTROL_ORIENTATION:
 | 
			
		||||
			if (g->g.Orientation == (orientation_t)g->p.ptr)
 | 
			
		||||
				return;
 | 
			
		||||
			switch((orientation_t)g->p.ptr) {
 | 
			
		||||
			/* Rotation is handled by the drawing routines */
 | 
			
		||||
			case GDISP_ROTATE_0:
 | 
			
		||||
			case GDISP_ROTATE_180:
 | 
			
		||||
				g->g.Height = GDISP_SCREEN_HEIGHT;
 | 
			
		||||
				g->g.Width = GDISP_SCREEN_WIDTH;
 | 
			
		||||
				break;
 | 
			
		||||
			case GDISP_ROTATE_90:
 | 
			
		||||
			case GDISP_ROTATE_270:
 | 
			
		||||
				g->g.Height = GDISP_SCREEN_WIDTH;
 | 
			
		||||
				g->g.Width = GDISP_SCREEN_HEIGHT;
 | 
			
		||||
				break;
 | 
			
		||||
			default:
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			g->g.Orientation = (orientation_t)g->p.ptr;
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		case GDISP_CONTROL_CONTRAST:
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
#endif // GDISP_NEED_CONTROL
 | 
			
		||||
 | 
			
		||||
#endif // GFX_USE_GDISP
 | 
			
		||||
@ -0,0 +1,36 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef _GDISP_LLD_CONFIG_H
 | 
			
		||||
#define _GDISP_LLD_CONFIG_H
 | 
			
		||||
 | 
			
		||||
#if GFX_USE_GDISP
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Driver hardware support.                                                  */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
#define GDISP_HARDWARE_FLUSH			TRUE		// This controller requires flushing
 | 
			
		||||
#define GDISP_HARDWARE_DRAWPIXEL		TRUE
 | 
			
		||||
#define GDISP_HARDWARE_PIXELREAD		TRUE
 | 
			
		||||
#define GDISP_HARDWARE_CONTROL			TRUE
 | 
			
		||||
 | 
			
		||||
#define GDISP_LLD_PIXELFORMAT			GDISP_PIXELFORMAT_GRAY256
 | 
			
		||||
 | 
			
		||||
#endif	/* GFX_USE_GDISP */
 | 
			
		||||
 | 
			
		||||
#endif	/* _GDISP_LLD_CONFIG_H */
 | 
			
		||||
@ -0,0 +1,2 @@
 | 
			
		||||
GFXINC += drivers/gdisp/emulator_lcd
 | 
			
		||||
GFXSRC += drivers/gdisp/emulator_lcd/emulator_lcd.c
 | 
			
		||||
@ -0,0 +1,10 @@
 | 
			
		||||
#define GDISP_DRIVER_VMT		    	GDISPVMT_EMULATOR_LCD_ERGODOX
 | 
			
		||||
#define GDISP_HARDWARE_DRAWPIXEL		TRUE
 | 
			
		||||
#define GDISP_HARDWARE_PIXELREAD		TRUE
 | 
			
		||||
#define GDISP_HARDWARE_CONTROL			TRUE
 | 
			
		||||
#define GDISP_LLD_PIXELFORMAT			GDISP_PIXELFORMAT_MONO
 | 
			
		||||
#define GDISP_SCREEN_WIDTH		        128
 | 
			
		||||
#define GDISP_SCREEN_HEIGHT		        32
 | 
			
		||||
#define ROTATE_180_IS_FLIP
 | 
			
		||||
 | 
			
		||||
#include "emulator/emulator_driver_impl.h"
 | 
			
		||||
@ -0,0 +1,2 @@
 | 
			
		||||
GFXINC += drivers/gdisp/emulator_led
 | 
			
		||||
GFXSRC += drivers/gdisp/emulator_led/emulator_led.c
 | 
			
		||||
@ -0,0 +1,10 @@
 | 
			
		||||
#define GDISP_DRIVER_VMT			    GDISPVMT_EMULATOR_LED_ERGODOX
 | 
			
		||||
#define GDISP_HARDWARE_DRAWPIXEL		TRUE
 | 
			
		||||
#define GDISP_HARDWARE_PIXELREAD		TRUE
 | 
			
		||||
#define GDISP_HARDWARE_CONTROL			TRUE
 | 
			
		||||
#define GDISP_LLD_PIXELFORMAT			GDISP_PIXELFORMAT_MONO
 | 
			
		||||
#define GDISP_SCREEN_WIDTH		        7
 | 
			
		||||
#define GDISP_SCREEN_HEIGHT		        7
 | 
			
		||||
#define ROTATE_180_IS_FLIP
 | 
			
		||||
 | 
			
		||||
#include "emulator/emulator_driver_impl.h"
 | 
			
		||||
@ -0,0 +1,127 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is subject to the terms of the GFX License. If a copy of
 | 
			
		||||
 * the license was not distributed with this file, you can obtain one at:
 | 
			
		||||
 *
 | 
			
		||||
 *              http://ugfx.org/license.html
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _GDISP_LLD_BOARD_H
 | 
			
		||||
#define _GDISP_LLD_BOARD_H
 | 
			
		||||
 | 
			
		||||
#include "print.h"
 | 
			
		||||
 | 
			
		||||
#define ST7565_LCD_BIAS         ST7565_LCD_BIAS_9 // actually 6
 | 
			
		||||
#define ST7565_ADC              ST7565_ADC_NORMAL
 | 
			
		||||
#define ST7565_COM_SCAN         ST7565_COM_SCAN_DEC
 | 
			
		||||
#define ST7565_PAGE_ORDER       0,1,2,3
 | 
			
		||||
/*
 | 
			
		||||
 * Custom page order for several LCD boards, e.g. HEM12864-99
 | 
			
		||||
 * #define ST7565_PAGE_ORDER       4,5,6,7,0,1,2,3
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define ST7565_GPIOPORT GPIOC
 | 
			
		||||
#define ST7565_PORT PORTC
 | 
			
		||||
#define ST7565_A0_PIN 7
 | 
			
		||||
#define ST7565_RST_PIN 8
 | 
			
		||||
#define ST7565_MOSI_PIN 6
 | 
			
		||||
#define ST7565_SLCK_PIN 5
 | 
			
		||||
#define ST7565_SS_PIN 4
 | 
			
		||||
 | 
			
		||||
#define palSetPadModeRaw(portname, bits) \
 | 
			
		||||
    ST7565_PORT->PCR[ST7565_##portname##_PIN] = bits
 | 
			
		||||
 | 
			
		||||
#define palSetPadModeNamed(portname, portmode) \
 | 
			
		||||
    palSetPadMode(ST7565_GPIOPORT, ST7565_##portname##_PIN, portmode)
 | 
			
		||||
 | 
			
		||||
#define ST7565_SPI_MODE PORTx_PCRn_DSE | PORTx_PCRn_MUX(2)
 | 
			
		||||
// DSPI Clock and Transfer Attributes
 | 
			
		||||
// Frame Size: 8 bits
 | 
			
		||||
// MSB First
 | 
			
		||||
// CLK Low by default
 | 
			
		||||
static const SPIConfig spi1config = {
 | 
			
		||||
	NULL,
 | 
			
		||||
	/* HW dependent part.*/
 | 
			
		||||
	ST7565_GPIOPORT,
 | 
			
		||||
    ST7565_SS_PIN,
 | 
			
		||||
    SPIx_CTARn_FMSZ(7)
 | 
			
		||||
    | SPIx_CTARn_ASC(7)
 | 
			
		||||
    | SPIx_CTARn_DT(7)
 | 
			
		||||
    | SPIx_CTARn_CSSCK(7)
 | 
			
		||||
    | SPIx_CTARn_PBR(0)
 | 
			
		||||
    | SPIx_CTARn_BR(7)
 | 
			
		||||
	//SPI_CR1_BR_0
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static bool_t st7565_is_data_mode = 1;
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void init_board(GDisplay *g) {
 | 
			
		||||
    (void) g;
 | 
			
		||||
    palSetPadModeNamed(A0, PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN);
 | 
			
		||||
    st7565_is_data_mode = 1;
 | 
			
		||||
    palSetPadModeNamed(RST, PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN);
 | 
			
		||||
    palSetPadModeRaw(MOSI, ST7565_SPI_MODE);
 | 
			
		||||
    palSetPadModeRaw(SLCK, ST7565_SPI_MODE);
 | 
			
		||||
    palSetPadModeRaw(SS, ST7565_SPI_MODE);
 | 
			
		||||
 | 
			
		||||
    spiInit();
 | 
			
		||||
    spiStart(&SPID1, &spi1config);
 | 
			
		||||
    spiSelect(&SPID1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void post_init_board(GDisplay *g) {
 | 
			
		||||
	(void) g;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
 | 
			
		||||
    (void) g;
 | 
			
		||||
    if (state) {
 | 
			
		||||
        palClearPad(ST7565_GPIOPORT, ST7565_RST_PIN);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void acquire_bus(GDisplay *g) {
 | 
			
		||||
    (void) g;
 | 
			
		||||
    // Only the LCD is using the SPI bus, so no need to acquire
 | 
			
		||||
    // spiAcquireBus(&SPID1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void release_bus(GDisplay *g) {
 | 
			
		||||
    (void) g;
 | 
			
		||||
    // Only the LCD is using the SPI bus, so no need to release
 | 
			
		||||
    //spiReleaseBus(&SPID1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void write_cmd(GDisplay *g, uint8_t cmd) {
 | 
			
		||||
	(void) g;
 | 
			
		||||
	if (st7565_is_data_mode) {
 | 
			
		||||
	    // The sleeps need to be at lest 10 vs 25 ns respectively
 | 
			
		||||
	    // So let's sleep two ticks, one tick might not be enough
 | 
			
		||||
	    // if we are at the end of the tick
 | 
			
		||||
	    chThdSleep(2);
 | 
			
		||||
        palClearPad(ST7565_GPIOPORT, ST7565_A0_PIN);
 | 
			
		||||
        chThdSleep(2);
 | 
			
		||||
        st7565_is_data_mode = 0;
 | 
			
		||||
	}
 | 
			
		||||
	spiSend(&SPID1, 1, &cmd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static GFXINLINE void write_data(GDisplay *g, uint8_t* data, uint16_t length) {
 | 
			
		||||
	(void) g;
 | 
			
		||||
	if (!st7565_is_data_mode) {
 | 
			
		||||
	    // The sleeps need to be at lest 10 vs 25 ns respectively
 | 
			
		||||
	    // So let's sleep two ticks, one tick might not be enough
 | 
			
		||||
	    // if we are at the end of the tick
 | 
			
		||||
	    chThdSleep(2);
 | 
			
		||||
        palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN);
 | 
			
		||||
	    chThdSleep(2);
 | 
			
		||||
        st7565_is_data_mode = 1;
 | 
			
		||||
	}
 | 
			
		||||
	spiSend(&SPID1, length, data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* _GDISP_LLD_BOARD_H */
 | 
			
		||||
@ -0,0 +1,2 @@
 | 
			
		||||
GFXINC += drivers/gdisp/st7565ergodox
 | 
			
		||||
GFXSRC += drivers/gdisp/st7565ergodox/gdisp_lld_ST7565.c
 | 
			
		||||
@ -0,0 +1,292 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is subject to the terms of the GFX License. If a copy of
 | 
			
		||||
 * the license was not distributed with this file, you can obtain one at:
 | 
			
		||||
 *
 | 
			
		||||
 *              http://ugfx.org/license.html
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "gfx.h"
 | 
			
		||||
 | 
			
		||||
#if GFX_USE_GDISP
 | 
			
		||||
 | 
			
		||||
#define GDISP_DRIVER_VMT			GDISPVMT_ST7565_ERGODOX
 | 
			
		||||
#include "drivers/gdisp/st7565ergodox/gdisp_lld_config.h"
 | 
			
		||||
#include "src/gdisp/gdisp_driver.h"
 | 
			
		||||
 | 
			
		||||
#include "board_ST7565.h"
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Driver local definitions.                                                 */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
#ifndef GDISP_SCREEN_HEIGHT
 | 
			
		||||
	#define GDISP_SCREEN_HEIGHT		32
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_SCREEN_WIDTH
 | 
			
		||||
	#define GDISP_SCREEN_WIDTH		128
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_INITIAL_CONTRAST
 | 
			
		||||
	#define GDISP_INITIAL_CONTRAST	0
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef GDISP_INITIAL_BACKLIGHT
 | 
			
		||||
	#define GDISP_INITIAL_BACKLIGHT	100
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define GDISP_FLG_NEEDFLUSH			(GDISP_FLG_DRIVER<<0)
 | 
			
		||||
 | 
			
		||||
#include "drivers/gdisp/st7565ergodox/st7565.h"
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Driver config defaults for backward compatibility.               	     */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
#ifndef ST7565_LCD_BIAS
 | 
			
		||||
  #define ST7565_LCD_BIAS         ST7565_LCD_BIAS_7
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef ST7565_ADC
 | 
			
		||||
  #define ST7565_ADC              ST7565_ADC_NORMAL
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef ST7565_COM_SCAN
 | 
			
		||||
  #define ST7565_COM_SCAN         ST7565_COM_SCAN_INC
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef ST7565_PAGE_ORDER
 | 
			
		||||
  #define ST7565_PAGE_ORDER       0,1,2,3
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Driver local functions.                                                   */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
typedef struct{
 | 
			
		||||
    bool_t buffer2;
 | 
			
		||||
    uint8_t ram[GDISP_SCREEN_HEIGHT * GDISP_SCREEN_WIDTH / 8];
 | 
			
		||||
}PrivData;
 | 
			
		||||
 | 
			
		||||
// Some common routines and macros
 | 
			
		||||
#define PRIV(g)                         ((PrivData*)g->priv)
 | 
			
		||||
#define RAM(g)							(PRIV(g)->ram)
 | 
			
		||||
#define write_cmd2(g, cmd1, cmd2)		{ write_cmd(g, cmd1); write_cmd(g, cmd2); }
 | 
			
		||||
#define write_cmd3(g, cmd1, cmd2, cmd3)	{ write_cmd(g, cmd1); write_cmd(g, cmd2); write_cmd(g, cmd3); }
 | 
			
		||||
 | 
			
		||||
// Some common routines and macros
 | 
			
		||||
#define delay(us)			gfxSleepMicroseconds(us)
 | 
			
		||||
#define delay_ms(ms)		gfxSleepMilliseconds(ms)
 | 
			
		||||
 | 
			
		||||
#define xyaddr(x, y)		((x) + ((y)>>3)*GDISP_SCREEN_WIDTH)
 | 
			
		||||
#define xybit(y)			(1<<((y)&7))
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Driver exported functions.                                                */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * As this controller can't update on a pixel boundary we need to maintain the
 | 
			
		||||
 * the entire display surface in memory so that we can do the necessary bit
 | 
			
		||||
 * operations. Fortunately it is a small display in monochrome.
 | 
			
		||||
 * 64 * 128 / 8 = 1024 bytes.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
LLDSPEC bool_t gdisp_lld_init(GDisplay *g) {
 | 
			
		||||
	// The private area is the display surface.
 | 
			
		||||
	g->priv = gfxAlloc(sizeof(PrivData));
 | 
			
		||||
	PRIV(g)->buffer2 = false;
 | 
			
		||||
 | 
			
		||||
	// Initialise the board interface
 | 
			
		||||
	init_board(g);
 | 
			
		||||
 | 
			
		||||
	// Hardware reset
 | 
			
		||||
	setpin_reset(g, TRUE);
 | 
			
		||||
	gfxSleepMilliseconds(20);
 | 
			
		||||
	setpin_reset(g, FALSE);
 | 
			
		||||
	gfxSleepMilliseconds(20);
 | 
			
		||||
 | 
			
		||||
	acquire_bus(g);
 | 
			
		||||
    write_cmd(g, ST7565_DISPLAY_OFF);
 | 
			
		||||
	write_cmd(g, ST7565_LCD_BIAS);
 | 
			
		||||
    write_cmd(g, ST7565_ADC);
 | 
			
		||||
    write_cmd(g, ST7565_COM_SCAN);
 | 
			
		||||
    
 | 
			
		||||
    write_cmd(g, ST7565_START_LINE | 0);
 | 
			
		||||
 | 
			
		||||
	write_cmd(g, ST7565_RESISTOR_RATIO | 0x6);
 | 
			
		||||
 | 
			
		||||
	// turn on voltage converter (VC=1, VR=0, VF=0)
 | 
			
		||||
	write_cmd(g, ST7565_POWER_CONTROL | 0x04);
 | 
			
		||||
	delay_ms(50);
 | 
			
		||||
 | 
			
		||||
	// turn on voltage regulator (VC=1, VR=1, VF=0)
 | 
			
		||||
	write_cmd(g, ST7565_POWER_CONTROL | 0x06);
 | 
			
		||||
	delay_ms(50);
 | 
			
		||||
 | 
			
		||||
	// turn on voltage follower (VC=1, VR=1, VF=1)
 | 
			
		||||
	write_cmd(g, ST7565_POWER_CONTROL | 0x07);
 | 
			
		||||
	delay_ms(50);
 | 
			
		||||
 | 
			
		||||
	write_cmd(g, 0xE2);
 | 
			
		||||
    write_cmd(g, ST7565_COM_SCAN);
 | 
			
		||||
	write_cmd2(g, ST7565_CONTRAST, GDISP_INITIAL_CONTRAST*64/101);
 | 
			
		||||
	//write_cmd2(g, ST7565_CONTRAST, 0);
 | 
			
		||||
	write_cmd(g, ST7565_DISPLAY_ON);
 | 
			
		||||
	write_cmd(g, ST7565_ALLON_NORMAL);
 | 
			
		||||
	write_cmd(g, ST7565_INVERT_DISPLAY);
 | 
			
		||||
 | 
			
		||||
	write_cmd(g, ST7565_RMW);
 | 
			
		||||
 | 
			
		||||
    // Finish Init
 | 
			
		||||
    post_init_board(g);
 | 
			
		||||
 | 
			
		||||
 	// Release the bus
 | 
			
		||||
	release_bus(g);
 | 
			
		||||
 | 
			
		||||
	/* Initialise the GDISP structure */
 | 
			
		||||
	g->g.Width = GDISP_SCREEN_WIDTH;
 | 
			
		||||
	g->g.Height = GDISP_SCREEN_HEIGHT;
 | 
			
		||||
	g->g.Orientation = GDISP_ROTATE_0;
 | 
			
		||||
	g->g.Powermode = powerOn;
 | 
			
		||||
	g->g.Backlight = GDISP_INITIAL_BACKLIGHT;
 | 
			
		||||
	g->g.Contrast = GDISP_INITIAL_CONTRAST;
 | 
			
		||||
	return TRUE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if GDISP_HARDWARE_FLUSH
 | 
			
		||||
	LLDSPEC void gdisp_lld_flush(GDisplay *g) {
 | 
			
		||||
		unsigned	p;
 | 
			
		||||
 | 
			
		||||
		// Don't flush if we don't need it.
 | 
			
		||||
		if (!(g->flags & GDISP_FLG_NEEDFLUSH))
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		acquire_bus(g);
 | 
			
		||||
		unsigned dstOffset = (PRIV(g)->buffer2 ? 4 : 0);
 | 
			
		||||
		for (p = 0; p < 4; p++) {
 | 
			
		||||
			write_cmd(g, ST7565_PAGE | (p + dstOffset));
 | 
			
		||||
			write_cmd(g, ST7565_COLUMN_MSB | 0);
 | 
			
		||||
			write_cmd(g, ST7565_COLUMN_LSB | 0);
 | 
			
		||||
			write_cmd(g, ST7565_RMW);
 | 
			
		||||
			write_data(g, RAM(g) + (p*GDISP_SCREEN_WIDTH), GDISP_SCREEN_WIDTH);
 | 
			
		||||
		}
 | 
			
		||||
		unsigned line = (PRIV(g)->buffer2 ? 32 : 0);
 | 
			
		||||
        write_cmd(g, ST7565_START_LINE | line);
 | 
			
		||||
        PRIV(g)->buffer2 = !PRIV(g)->buffer2;
 | 
			
		||||
		release_bus(g);
 | 
			
		||||
 | 
			
		||||
		g->flags &= ~GDISP_FLG_NEEDFLUSH;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if GDISP_HARDWARE_DRAWPIXEL
 | 
			
		||||
	LLDSPEC void gdisp_lld_draw_pixel(GDisplay *g) {
 | 
			
		||||
		coord_t		x, y;
 | 
			
		||||
 | 
			
		||||
		switch(g->g.Orientation) {
 | 
			
		||||
		default:
 | 
			
		||||
		case GDISP_ROTATE_0:
 | 
			
		||||
			x = g->p.x;
 | 
			
		||||
			y = g->p.y;
 | 
			
		||||
			break;
 | 
			
		||||
		case GDISP_ROTATE_90:
 | 
			
		||||
			x = g->p.y;
 | 
			
		||||
			y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
 | 
			
		||||
			break;
 | 
			
		||||
		case GDISP_ROTATE_180:
 | 
			
		||||
			x = GDISP_SCREEN_WIDTH-1 - g->p.x;
 | 
			
		||||
			y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
 | 
			
		||||
			break;
 | 
			
		||||
		case GDISP_ROTATE_270:
 | 
			
		||||
			x = GDISP_SCREEN_HEIGHT-1 - g->p.y;
 | 
			
		||||
			y = g->p.x;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		if (gdispColor2Native(g->p.color) != Black)
 | 
			
		||||
			RAM(g)[xyaddr(x, y)] |= xybit(y);
 | 
			
		||||
		else
 | 
			
		||||
			RAM(g)[xyaddr(x, y)] &= ~xybit(y);
 | 
			
		||||
		g->flags |= GDISP_FLG_NEEDFLUSH;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if GDISP_HARDWARE_PIXELREAD
 | 
			
		||||
	LLDSPEC color_t gdisp_lld_get_pixel_color(GDisplay *g) {
 | 
			
		||||
		coord_t		x, y;
 | 
			
		||||
 | 
			
		||||
		switch(g->g.Orientation) {
 | 
			
		||||
		default:
 | 
			
		||||
		case GDISP_ROTATE_0:
 | 
			
		||||
			x = g->p.x;
 | 
			
		||||
			y = g->p.y;
 | 
			
		||||
			break;
 | 
			
		||||
		case GDISP_ROTATE_90:
 | 
			
		||||
			x = g->p.y;
 | 
			
		||||
			y = GDISP_SCREEN_HEIGHT-1 - g->p.x;
 | 
			
		||||
			break;
 | 
			
		||||
		case GDISP_ROTATE_180:
 | 
			
		||||
			x = GDISP_SCREEN_WIDTH-1 - g->p.x;
 | 
			
		||||
			y = GDISP_SCREEN_HEIGHT-1 - g->p.y;
 | 
			
		||||
			break;
 | 
			
		||||
		case GDISP_ROTATE_270:
 | 
			
		||||
			x = GDISP_SCREEN_HEIGHT-1 - g->p.y;
 | 
			
		||||
			y = g->p.x;
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
		return (RAM(g)[xyaddr(x, y)] & xybit(y)) ? White : Black;
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL
 | 
			
		||||
	LLDSPEC void gdisp_lld_control(GDisplay *g) {
 | 
			
		||||
		switch(g->p.x) {
 | 
			
		||||
		case GDISP_CONTROL_POWER:
 | 
			
		||||
			if (g->g.Powermode == (powermode_t)g->p.ptr)
 | 
			
		||||
				return;
 | 
			
		||||
			switch((powermode_t)g->p.ptr) {
 | 
			
		||||
			case powerOff:
 | 
			
		||||
			case powerSleep:
 | 
			
		||||
			case powerDeepSleep:
 | 
			
		||||
				acquire_bus(g);
 | 
			
		||||
				write_cmd(g, ST7565_DISPLAY_OFF);
 | 
			
		||||
				release_bus(g);
 | 
			
		||||
				break;
 | 
			
		||||
			case powerOn:
 | 
			
		||||
				acquire_bus(g);
 | 
			
		||||
				write_cmd(g, ST7565_DISPLAY_ON);
 | 
			
		||||
				release_bus(g);
 | 
			
		||||
				break;
 | 
			
		||||
			default:
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			g->g.Powermode = (powermode_t)g->p.ptr;
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		case GDISP_CONTROL_ORIENTATION:
 | 
			
		||||
			if (g->g.Orientation == (orientation_t)g->p.ptr)
 | 
			
		||||
				return;
 | 
			
		||||
			switch((orientation_t)g->p.ptr) {
 | 
			
		||||
			/* Rotation is handled by the drawing routines */
 | 
			
		||||
			case GDISP_ROTATE_0:
 | 
			
		||||
			case GDISP_ROTATE_180:
 | 
			
		||||
				g->g.Height = GDISP_SCREEN_HEIGHT;
 | 
			
		||||
				g->g.Width = GDISP_SCREEN_WIDTH;
 | 
			
		||||
				break;
 | 
			
		||||
			case GDISP_ROTATE_90:
 | 
			
		||||
			case GDISP_ROTATE_270:
 | 
			
		||||
				g->g.Height = GDISP_SCREEN_WIDTH;
 | 
			
		||||
				g->g.Width = GDISP_SCREEN_HEIGHT;
 | 
			
		||||
				break;
 | 
			
		||||
			default:
 | 
			
		||||
				return;
 | 
			
		||||
			}
 | 
			
		||||
			g->g.Orientation = (orientation_t)g->p.ptr;
 | 
			
		||||
			return;
 | 
			
		||||
 | 
			
		||||
		case GDISP_CONTROL_CONTRAST:
 | 
			
		||||
            if ((unsigned)g->p.ptr > 100)
 | 
			
		||||
            	g->p.ptr = (void *)100;
 | 
			
		||||
			acquire_bus(g);
 | 
			
		||||
			write_cmd2(g, ST7565_CONTRAST, ((((unsigned)g->p.ptr)<<6)/101) & 0x3F);
 | 
			
		||||
			release_bus(g);
 | 
			
		||||
            g->g.Contrast = (unsigned)g->p.ptr;
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
#endif // GDISP_NEED_CONTROL
 | 
			
		||||
 | 
			
		||||
#endif // GFX_USE_GDISP
 | 
			
		||||
@ -0,0 +1,26 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is subject to the terms of the GFX License. If a copy of
 | 
			
		||||
 * the license was not distributed with this file, you can obtain one at:
 | 
			
		||||
 *
 | 
			
		||||
 *              http://ugfx.org/license.html
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _GDISP_LLD_CONFIG_H
 | 
			
		||||
#define _GDISP_LLD_CONFIG_H
 | 
			
		||||
 | 
			
		||||
#if GFX_USE_GDISP
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* Driver hardware support.                                                  */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
#define GDISP_HARDWARE_FLUSH			TRUE		// This controller requires flushing
 | 
			
		||||
#define GDISP_HARDWARE_DRAWPIXEL		TRUE
 | 
			
		||||
#define GDISP_HARDWARE_PIXELREAD		TRUE
 | 
			
		||||
#define GDISP_HARDWARE_CONTROL			TRUE
 | 
			
		||||
 | 
			
		||||
#define GDISP_LLD_PIXELFORMAT			GDISP_PIXELFORMAT_MONO
 | 
			
		||||
 | 
			
		||||
#endif	/* GFX_USE_GDISP */
 | 
			
		||||
 | 
			
		||||
#endif	/* _GDISP_LLD_CONFIG_H */
 | 
			
		||||
@ -0,0 +1,37 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is subject to the terms of the GFX License. If a copy of
 | 
			
		||||
 * the license was not distributed with this file, you can obtain one at:
 | 
			
		||||
 *
 | 
			
		||||
 *              http://ugfx.org/license.html
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _ST7565_H
 | 
			
		||||
#define _ST7565_H
 | 
			
		||||
 | 
			
		||||
#define ST7565_CONTRAST             0x81
 | 
			
		||||
#define ST7565_ALLON_NORMAL         0xA4
 | 
			
		||||
#define ST7565_ALLON                0xA5
 | 
			
		||||
#define ST7565_POSITIVE_DISPLAY     0xA6
 | 
			
		||||
#define ST7565_INVERT_DISPLAY       0xA7
 | 
			
		||||
#define ST7565_DISPLAY_OFF          0xAE
 | 
			
		||||
#define ST7565_DISPLAY_ON           0xAF
 | 
			
		||||
 | 
			
		||||
#define ST7565_LCD_BIAS_7           0xA3
 | 
			
		||||
#define ST7565_LCD_BIAS_9           0xA2
 | 
			
		||||
 | 
			
		||||
#define ST7565_ADC_NORMAL           0xA0
 | 
			
		||||
#define ST7565_ADC_REVERSE          0xA1
 | 
			
		||||
 | 
			
		||||
#define ST7565_COM_SCAN_INC         0xC0
 | 
			
		||||
#define ST7565_COM_SCAN_DEC         0xC8
 | 
			
		||||
 | 
			
		||||
#define ST7565_START_LINE           0x40
 | 
			
		||||
#define ST7565_PAGE                 0xB0
 | 
			
		||||
#define ST7565_COLUMN_MSB           0x10
 | 
			
		||||
#define ST7565_COLUMN_LSB           0x00
 | 
			
		||||
#define ST7565_RMW                  0xE0
 | 
			
		||||
 | 
			
		||||
#define ST7565_RESISTOR_RATIO       0x20
 | 
			
		||||
#define ST7565_POWER_CONTROL        0x28
 | 
			
		||||
 | 
			
		||||
#endif /* _ST7565_H */
 | 
			
		||||
							
								
								
									
										331
									
								
								keyboards/infinity_ergodox/gfxconf.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										331
									
								
								keyboards/infinity_ergodox/gfxconf.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,331 @@
 | 
			
		||||
/**
 | 
			
		||||
 * This file has a different license to the rest of the uGFX system.
 | 
			
		||||
 * You can copy, modify and distribute this file as you see fit.
 | 
			
		||||
 * You do not need to publish your source modifications to this file.
 | 
			
		||||
 * The only thing you are not permitted to do is to relicense it
 | 
			
		||||
 * under a different license.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Copy this file into your project directory and rename it as gfxconf.h
 | 
			
		||||
 * Edit your copy to turn on the uGFX features you want to use.
 | 
			
		||||
 * The values below are the defaults.
 | 
			
		||||
 *
 | 
			
		||||
 * Only remove the comments from lines where you want to change the
 | 
			
		||||
 * default value. This allows definitions to be included from
 | 
			
		||||
 * driver makefiles when required and provides the best future
 | 
			
		||||
 * compatibility for your project.
 | 
			
		||||
 *
 | 
			
		||||
 * Please use spaces instead of tabs in this file.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _GFXCONF_H
 | 
			
		||||
#define _GFXCONF_H
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GOS - One of these must be defined, preferably in your Makefile       //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//#define GFX_USE_OS_CHIBIOS                           TRUE
 | 
			
		||||
//#define GFX_USE_OS_FREERTOS                          FALSE
 | 
			
		||||
//    #define GFX_FREERTOS_USE_TRACE                   FALSE
 | 
			
		||||
//#define GFX_USE_OS_WIN32                             FALSE
 | 
			
		||||
//#define GFX_USE_OS_LINUX                             FALSE
 | 
			
		||||
//#define GFX_USE_OS_OSX                               FALSE
 | 
			
		||||
//#define GFX_USE_OS_ECOS                              FALSE
 | 
			
		||||
//#define GFX_USE_OS_RAWRTOS                           FALSE
 | 
			
		||||
//#define GFX_USE_OS_ARDUINO                           FALSE
 | 
			
		||||
//#define GFX_USE_OS_KEIL                              FALSE
 | 
			
		||||
//#define GFX_USE_OS_CMSIS                             FALSE
 | 
			
		||||
//#define GFX_USE_OS_RAW32                             FALSE
 | 
			
		||||
//    #define INTERRUPTS_OFF()                         optional_code
 | 
			
		||||
//    #define INTERRUPTS_ON()                          optional_code
 | 
			
		||||
// These are not defined by default for some reason
 | 
			
		||||
#define GOS_NEED_X_THREADS	FALSE
 | 
			
		||||
#define GOS_NEED_X_HEAP		FALSE
 | 
			
		||||
 | 
			
		||||
// Options that (should where relevant) apply to all operating systems
 | 
			
		||||
    #define GFX_NO_INLINE                            FALSE
 | 
			
		||||
//    #define GFX_COMPILER                             GFX_COMPILER_UNKNOWN
 | 
			
		||||
//    #define GFX_CPU                                  GFX_CPU_UNKNOWN
 | 
			
		||||
//    #define GFX_OS_HEAP_SIZE                         0
 | 
			
		||||
//    #define GFX_OS_NO_INIT                           FALSE
 | 
			
		||||
//    #define GFX_OS_INIT_NO_WARNING                   FALSE
 | 
			
		||||
//    #define GFX_OS_PRE_INIT_FUNCTION                 myHardwareInitRoutine
 | 
			
		||||
//    #define GFX_OS_EXTRA_INIT_FUNCTION               myOSInitRoutine
 | 
			
		||||
//    #define GFX_OS_EXTRA_DEINIT_FUNCTION             myOSDeInitRoutine
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GDISP                                                                 //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GDISP                                TRUE
 | 
			
		||||
 | 
			
		||||
//#define GDISP_NEED_AUTOFLUSH                         FALSE
 | 
			
		||||
//#define GDISP_NEED_TIMERFLUSH                        FALSE
 | 
			
		||||
//#define GDISP_NEED_VALIDATION                        TRUE
 | 
			
		||||
//#define GDISP_NEED_CLIP                              TRUE
 | 
			
		||||
#define GDISP_NEED_CIRCLE                            TRUE
 | 
			
		||||
#define GDISP_NEED_ELLIPSE                           TRUE
 | 
			
		||||
#define GDISP_NEED_ARC                               TRUE
 | 
			
		||||
#define GDISP_NEED_ARCSECTORS                        TRUE
 | 
			
		||||
#define GDISP_NEED_CONVEX_POLYGON                    TRUE
 | 
			
		||||
//#define GDISP_NEED_SCROLL                            FALSE
 | 
			
		||||
#define GDISP_NEED_PIXELREAD                         TRUE
 | 
			
		||||
#define GDISP_NEED_CONTROL                           TRUE
 | 
			
		||||
//#define GDISP_NEED_QUERY                             FALSE
 | 
			
		||||
//#define GDISP_NEED_MULTITHREAD                       FALSE
 | 
			
		||||
//#define GDISP_NEED_STREAMING                         FALSE
 | 
			
		||||
#define GDISP_NEED_TEXT                              TRUE
 | 
			
		||||
//    #define GDISP_NEED_TEXT_WORDWRAP                 FALSE
 | 
			
		||||
//    #define GDISP_NEED_ANTIALIAS                     FALSE
 | 
			
		||||
//    #define GDISP_NEED_UTF8                          FALSE
 | 
			
		||||
    #define GDISP_NEED_TEXT_KERNING                  TRUE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_UI1                   FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_UI2                   FALSE		// The smallest preferred font.
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_LARGENUMBERS          FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS10          FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS12          FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS16          FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS20          FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS24          FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS32          FALSE
 | 
			
		||||
    #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12      TRUE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_FIXED_10X20           FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_FIXED_7X14            FALSE
 | 
			
		||||
    #define GDISP_INCLUDE_FONT_FIXED_5X8             TRUE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA       FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA       FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS20_AA       FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS24_AA       FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANS32_AA       FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA   FALSE
 | 
			
		||||
//    #define GDISP_INCLUDE_USER_FONTS                 FALSE
 | 
			
		||||
 | 
			
		||||
//#define GDISP_NEED_IMAGE                             FALSE
 | 
			
		||||
//    #define GDISP_NEED_IMAGE_NATIVE                  FALSE
 | 
			
		||||
//    #define GDISP_NEED_IMAGE_GIF                     FALSE
 | 
			
		||||
//    #define GDISP_NEED_IMAGE_BMP                     FALSE
 | 
			
		||||
//        #define GDISP_NEED_IMAGE_BMP_1               FALSE
 | 
			
		||||
//        #define GDISP_NEED_IMAGE_BMP_4               FALSE
 | 
			
		||||
//        #define GDISP_NEED_IMAGE_BMP_4_RLE           FALSE
 | 
			
		||||
//        #define GDISP_NEED_IMAGE_BMP_8               FALSE
 | 
			
		||||
//        #define GDISP_NEED_IMAGE_BMP_8_RLE           FALSE
 | 
			
		||||
//        #define GDISP_NEED_IMAGE_BMP_16              FALSE
 | 
			
		||||
//        #define GDISP_NEED_IMAGE_BMP_24              FALSE
 | 
			
		||||
//        #define GDISP_NEED_IMAGE_BMP_32              FALSE
 | 
			
		||||
//    #define GDISP_NEED_IMAGE_JPG                     FALSE
 | 
			
		||||
//    #define GDISP_NEED_IMAGE_PNG                     FALSE
 | 
			
		||||
//    #define GDISP_NEED_IMAGE_ACCOUNTING              FALSE
 | 
			
		||||
#ifdef EMULATOR
 | 
			
		||||
#define GDISP_NEED_PIXMAP                            TRUE
 | 
			
		||||
#endif
 | 
			
		||||
//    #define GDISP_NEED_PIXMAP_IMAGE                  FALSE
 | 
			
		||||
 | 
			
		||||
//#define GDISP_DEFAULT_ORIENTATION                    GDISP_ROTATE_LANDSCAPE    // If not defined the native hardware orientation is used.
 | 
			
		||||
//#define GDISP_LINEBUF_SIZE                           128
 | 
			
		||||
//#define GDISP_STARTUP_COLOR                          Black
 | 
			
		||||
#define GDISP_NEED_STARTUP_LOGO                      FALSE
 | 
			
		||||
 | 
			
		||||
//#define GDISP_TOTAL_DISPLAYS		                 2
 | 
			
		||||
 | 
			
		||||
#ifndef EMULATOR
 | 
			
		||||
#define GDISP_DRIVER_LIST                            GDISPVMT_ST7565_ERGODOX, GDISPVMT_IS31FL3731C_ERGODOX
 | 
			
		||||
#else
 | 
			
		||||
#define GDISP_DRIVER_LIST                            GDISPVMT_EMULATOR_LCD_ERGODOX, GDISPVMT_EMULATOR_LED_ERGODOX
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    #ifdef GDISP_DRIVER_LIST
 | 
			
		||||
        // For code and speed optimization define as TRUE or FALSE if all controllers have the same capability
 | 
			
		||||
        #define GDISP_HARDWARE_STREAM_WRITE          FALSE
 | 
			
		||||
        #define GDISP_HARDWARE_STREAM_READ           FALSE
 | 
			
		||||
        #define GDISP_HARDWARE_STREAM_POS            FALSE
 | 
			
		||||
        #define GDISP_HARDWARE_DRAWPIXEL             TRUE
 | 
			
		||||
        #define GDISP_HARDWARE_CLEARS                FALSE
 | 
			
		||||
        #define GDISP_HARDWARE_FILLS                 FALSE
 | 
			
		||||
        #define GDISP_HARDWARE_BITFILLS              FALSE
 | 
			
		||||
        #define GDISP_HARDWARE_SCROLL                FALSE
 | 
			
		||||
        #define GDISP_HARDWARE_PIXELREAD             TRUE
 | 
			
		||||
        #define GDISP_HARDWARE_CONTROL               TRUE
 | 
			
		||||
        #define GDISP_HARDWARE_QUERY                 FALSE
 | 
			
		||||
        #define GDISP_HARDWARE_CLIP                  FALSE
 | 
			
		||||
 | 
			
		||||
        #define GDISP_PIXELFORMAT                    GDISP_PIXELFORMAT_RGB888
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
// The custom format is not defined for some reason, so define it as error
 | 
			
		||||
// so we don't get compiler warnings
 | 
			
		||||
#define GDISP_PIXELFORMAT_CUSTOM GDISP_PIXELFORMAT_ERROR
 | 
			
		||||
 | 
			
		||||
#define GDISP_USE_GFXNET                             FALSE
 | 
			
		||||
//    #define GDISP_GFXNET_PORT                        13001
 | 
			
		||||
//    #define GDISP_GFXNET_CUSTOM_LWIP_STARTUP         FALSE
 | 
			
		||||
//    #define GDISP_DONT_WAIT_FOR_NET_DISPLAY          FALSE
 | 
			
		||||
//    #define GDISP_GFXNET_UNSAFE_SOCKETS              FALSE
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GWIN                                                                  //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GWIN                                 FALSE
 | 
			
		||||
 | 
			
		||||
//#define GWIN_NEED_WINDOWMANAGER                      FALSE
 | 
			
		||||
//    #define GWIN_REDRAW_IMMEDIATE                    FALSE
 | 
			
		||||
//    #define GWIN_REDRAW_SINGLEOP                     FALSE
 | 
			
		||||
//    #define GWIN_NEED_FLASHING                       FALSE
 | 
			
		||||
//        #define GWIN_FLASHING_PERIOD                 250
 | 
			
		||||
 | 
			
		||||
//#define GWIN_NEED_CONSOLE                            FALSE
 | 
			
		||||
//    #define GWIN_CONSOLE_USE_HISTORY                 FALSE
 | 
			
		||||
//        #define GWIN_CONSOLE_HISTORY_AVERAGING       FALSE
 | 
			
		||||
//        #define GWIN_CONSOLE_HISTORY_ATCREATE        FALSE
 | 
			
		||||
//    #define GWIN_CONSOLE_ESCSEQ                      FALSE
 | 
			
		||||
//    #define GWIN_CONSOLE_USE_BASESTREAM              FALSE
 | 
			
		||||
//    #define GWIN_CONSOLE_USE_FLOAT                   FALSE
 | 
			
		||||
//#define GWIN_NEED_GRAPH                              FALSE
 | 
			
		||||
//#define GWIN_NEED_GL3D                               FALSE
 | 
			
		||||
 | 
			
		||||
//#define GWIN_NEED_WIDGET                             FALSE
 | 
			
		||||
//#define GWIN_FOCUS_HIGHLIGHT_WIDTH                   1
 | 
			
		||||
//    #define GWIN_NEED_LABEL                          FALSE
 | 
			
		||||
//        #define GWIN_LABEL_ATTRIBUTE                 FALSE
 | 
			
		||||
//    #define GWIN_NEED_BUTTON                         FALSE
 | 
			
		||||
//        #define GWIN_BUTTON_LAZY_RELEASE             FALSE
 | 
			
		||||
//    #define GWIN_NEED_SLIDER                         FALSE
 | 
			
		||||
//        #define GWIN_SLIDER_NOSNAP                   FALSE
 | 
			
		||||
//        #define GWIN_SLIDER_DEAD_BAND                5
 | 
			
		||||
//        #define GWIN_SLIDER_TOGGLE_INC               20
 | 
			
		||||
//    #define GWIN_NEED_CHECKBOX                       FALSE
 | 
			
		||||
//    #define GWIN_NEED_IMAGE                          FALSE
 | 
			
		||||
//        #define GWIN_NEED_IMAGE_ANIMATION            FALSE
 | 
			
		||||
//    #define GWIN_NEED_RADIO                          FALSE
 | 
			
		||||
//    #define GWIN_NEED_LIST                           FALSE
 | 
			
		||||
//        #define GWIN_NEED_LIST_IMAGES                FALSE
 | 
			
		||||
//    #define GWIN_NEED_PROGRESSBAR                    FALSE
 | 
			
		||||
//        #define GWIN_PROGRESSBAR_AUTO                FALSE
 | 
			
		||||
//    #define GWIN_NEED_KEYBOARD                       FALSE
 | 
			
		||||
//        #define GWIN_KEYBOARD_DEFAULT_LAYOUT         VirtualKeyboard_English1
 | 
			
		||||
//        #define GWIN_NEED_KEYBOARD_ENGLISH1          TRUE
 | 
			
		||||
//    #define GWIN_NEED_TEXTEDIT                       FALSE
 | 
			
		||||
//    #define GWIN_FLAT_STYLING                        FALSE
 | 
			
		||||
//    #define GWIN_WIDGET_TAGS                         FALSE
 | 
			
		||||
 | 
			
		||||
//#define GWIN_NEED_CONTAINERS                         FALSE
 | 
			
		||||
//    #define GWIN_NEED_CONTAINER                      FALSE
 | 
			
		||||
//    #define GWIN_NEED_FRAME                          FALSE
 | 
			
		||||
//    #define GWIN_NEED_TABSET                         FALSE
 | 
			
		||||
//        #define GWIN_TABSET_TABHEIGHT                18
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GEVENT                                                                //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GEVENT                               TRUE
 | 
			
		||||
 | 
			
		||||
//#define GEVENT_ASSERT_NO_RESOURCE                    FALSE
 | 
			
		||||
//#define GEVENT_MAXIMUM_SIZE                          32
 | 
			
		||||
//#define GEVENT_MAX_SOURCE_LISTENERS                  32
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GTIMER                                                                //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GTIMER                               FALSE
 | 
			
		||||
 | 
			
		||||
//#define GTIMER_THREAD_PRIORITY                       HIGH_PRIORITY
 | 
			
		||||
//#define GTIMER_THREAD_WORKAREA_SIZE                  2048
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GQUEUE                                                                //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GQUEUE                               FALSE
 | 
			
		||||
 | 
			
		||||
//#define GQUEUE_NEED_ASYNC                            FALSE
 | 
			
		||||
//#define GQUEUE_NEED_GSYNC                            FALSE
 | 
			
		||||
//#define GQUEUE_NEED_FSYNC                            FALSE
 | 
			
		||||
//#define GQUEUE_NEED_BUFFERS                          FALSE
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GINPUT                                                                //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GINPUT                               FALSE
 | 
			
		||||
 | 
			
		||||
//#define GINPUT_NEED_MOUSE                            FALSE
 | 
			
		||||
//    #define GINPUT_TOUCH_STARTRAW                    FALSE
 | 
			
		||||
//    #define GINPUT_TOUCH_NOTOUCH                     FALSE
 | 
			
		||||
//    #define GINPUT_TOUCH_NOCALIBRATE                 FALSE
 | 
			
		||||
//    #define GINPUT_TOUCH_NOCALIBRATE_GUI             FALSE
 | 
			
		||||
//    #define GINPUT_MOUSE_POLL_PERIOD                 25
 | 
			
		||||
//    #define GINPUT_MOUSE_CLICK_TIME                  300
 | 
			
		||||
//    #define GINPUT_TOUCH_CXTCLICK_TIME               700
 | 
			
		||||
//    #define GINPUT_TOUCH_USER_CALIBRATION_LOAD       FALSE
 | 
			
		||||
//    #define GINPUT_TOUCH_USER_CALIBRATION_SAVE       FALSE
 | 
			
		||||
//    #define GMOUSE_DRIVER_LIST                       GMOUSEVMT_Win32, GMOUSEVMT_Win32
 | 
			
		||||
//#define GINPUT_NEED_KEYBOARD                         FALSE
 | 
			
		||||
//    #define GINPUT_KEYBOARD_POLL_PERIOD              200
 | 
			
		||||
//    #define GKEYBOARD_DRIVER_LIST                    GKEYBOARDVMT_Win32, GKEYBOARDVMT_Win32
 | 
			
		||||
//    #define GKEYBOARD_LAYOUT_OFF                     FALSE
 | 
			
		||||
//        #define GKEYBOARD_LAYOUT_SCANCODE2_US        FALSE
 | 
			
		||||
//#define GINPUT_NEED_TOGGLE                           FALSE
 | 
			
		||||
//#define GINPUT_NEED_DIAL                             FALSE
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GFILE                                                                 //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GFILE                                FALSE
 | 
			
		||||
 | 
			
		||||
//#define GFILE_NEED_PRINTG                            FALSE
 | 
			
		||||
//#define GFILE_NEED_SCANG                             FALSE
 | 
			
		||||
//#define GFILE_NEED_STRINGS                           FALSE
 | 
			
		||||
//#define GFILE_NEED_FILELISTS                         FALSE
 | 
			
		||||
//#define GFILE_NEED_STDIO                             FALSE
 | 
			
		||||
//#define GFILE_NEED_NOAUTOMOUNT                       FALSE
 | 
			
		||||
//#define GFILE_NEED_NOAUTOSYNC                        FALSE
 | 
			
		||||
 | 
			
		||||
//#define GFILE_NEED_MEMFS                             FALSE
 | 
			
		||||
//#define GFILE_NEED_ROMFS                             FALSE
 | 
			
		||||
//#define GFILE_NEED_RAMFS                             FALSE
 | 
			
		||||
//#define GFILE_NEED_FATFS                             FALSE
 | 
			
		||||
//#define GFILE_NEED_NATIVEFS                          FALSE
 | 
			
		||||
//#define GFILE_NEED_CHBIOSFS                          FALSE
 | 
			
		||||
 | 
			
		||||
//#define GFILE_ALLOW_FLOATS                           FALSE
 | 
			
		||||
//#define GFILE_ALLOW_DEVICESPECIFIC                   FALSE
 | 
			
		||||
//#define GFILE_MAX_GFILES                             3
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GADC                                                                  //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GADC                                 FALSE
 | 
			
		||||
 | 
			
		||||
//#define GADC_MAX_LOWSPEED_DEVICES                    4
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GAUDIO                                                                //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GAUDIO                               FALSE
 | 
			
		||||
// There seems to be a bug in the ugfx code, the wrong define is used
 | 
			
		||||
// So define it in order to avoid warnings
 | 
			
		||||
#define GFX_USE_GAUDIN                               GFX_USE_GAUDIO
 | 
			
		||||
//    #define GAUDIO_NEED_PLAY                         FALSE
 | 
			
		||||
//    #define GAUDIO_NEED_RECORD                       FALSE
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// GMISC                                                                 //
 | 
			
		||||
///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
#define GFX_USE_GMISC                                TRUE
 | 
			
		||||
 | 
			
		||||
//#define GMISC_NEED_ARRAYOPS                          FALSE
 | 
			
		||||
//#define GMISC_NEED_FASTTRIG                          FALSE
 | 
			
		||||
//#define GMISC_NEED_FIXEDTRIG                         FALSE
 | 
			
		||||
//#define GMISC_NEED_INVSQRT                           FALSE
 | 
			
		||||
//    #define GMISC_INVSQRT_MIXED_ENDIAN               FALSE
 | 
			
		||||
//    #define GMISC_INVSQRT_REAL_SLOW                  FALSE
 | 
			
		||||
#define GMISC_NEED_MATRIXFLOAT2D                     TRUE
 | 
			
		||||
#define GMISC_NEED_MATRIXFIXED2D                     FALSE
 | 
			
		||||
 | 
			
		||||
#endif /* _GFXCONF_H */
 | 
			
		||||
							
								
								
									
										353
									
								
								keyboards/infinity_ergodox/halconf.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										353
									
								
								keyboards/infinity_ergodox/halconf.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,353 @@
 | 
			
		||||
/*
 | 
			
		||||
    ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
 | 
			
		||||
 | 
			
		||||
    Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
    you may not use this file except in compliance with the License.
 | 
			
		||||
    You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
        http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
    Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
    distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
    See the License for the specific language governing permissions and
 | 
			
		||||
    limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @file    templates/halconf.h
 | 
			
		||||
 * @brief   HAL configuration header.
 | 
			
		||||
 * @details HAL configuration file, this file allows to enable or disable the
 | 
			
		||||
 *          various device drivers from your application. You may also use
 | 
			
		||||
 *          this file in order to override the device drivers default settings.
 | 
			
		||||
 *
 | 
			
		||||
 * @addtogroup HAL_CONF
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef _HALCONF_H_
 | 
			
		||||
#define _HALCONF_H_
 | 
			
		||||
 | 
			
		||||
#include "mcuconf.h"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the PAL subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_PAL                 TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the ADC subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_ADC                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the CAN subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_CAN                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the DAC subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_DAC                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the EXT subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_EXT                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the GPT subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_GPT                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the I2C subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_I2C                 TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the I2S subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_I2S                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the ICU subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_ICU                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the MAC subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_MAC                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the MMC_SPI subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_MMC_SPI             FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the PWM subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_PWM                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the RTC subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_RTC                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the SDC subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_SDC                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the SERIAL subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_SERIAL              TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the SERIAL over USB subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_SERIAL_USB          TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the SPI subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_SPI                 TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the UART subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_UART) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_UART                FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the USB subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_USB) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_USB                 TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the WDG subsystem.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
 | 
			
		||||
#define HAL_USE_WDG                 FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* ADC driver related settings.                                              */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables synchronous APIs.
 | 
			
		||||
 * @note    Disabling this option saves both code and data space.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__)
 | 
			
		||||
#define ADC_USE_WAIT                TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs.
 | 
			
		||||
 * @note    Disabling this option saves both code and data space.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
 | 
			
		||||
#define ADC_USE_MUTUAL_EXCLUSION    TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* CAN driver related settings.                                              */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Sleep mode related APIs inclusion switch.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__)
 | 
			
		||||
#define CAN_USE_SLEEP_MODE          TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* I2C driver related settings.                                              */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the mutual exclusion APIs on the I2C bus.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
 | 
			
		||||
#define I2C_USE_MUTUAL_EXCLUSION    TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* MAC driver related settings.                                              */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables an event sources for incoming packets.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__)
 | 
			
		||||
#define MAC_USE_ZERO_COPY           FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables an event sources for incoming packets.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__)
 | 
			
		||||
#define MAC_USE_EVENTS              TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* MMC_SPI driver related settings.                                          */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Delays insertions.
 | 
			
		||||
 * @details If enabled this options inserts delays into the MMC waiting
 | 
			
		||||
 *          routines releasing some extra CPU time for the threads with
 | 
			
		||||
 *          lower priority, this may slow down the driver a bit however.
 | 
			
		||||
 *          This option is recommended also if the SPI driver does not
 | 
			
		||||
 *          use a DMA channel and heavily loads the CPU.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__)
 | 
			
		||||
#define MMC_NICE_WAITING            TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* SDC driver related settings.                                              */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Number of initialization attempts before rejecting the card.
 | 
			
		||||
 * @note    Attempts are performed at 10mS intervals.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__)
 | 
			
		||||
#define SDC_INIT_RETRY              100
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Include support for MMC cards.
 | 
			
		||||
 * @note    MMC support is not yet implemented so this option must be kept
 | 
			
		||||
 *          at @p FALSE.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__)
 | 
			
		||||
#define SDC_MMC_SUPPORT             FALSE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Delays insertions.
 | 
			
		||||
 * @details If enabled this options inserts delays into the MMC waiting
 | 
			
		||||
 *          routines releasing some extra CPU time for the threads with
 | 
			
		||||
 *          lower priority, this may slow down the driver a bit however.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__)
 | 
			
		||||
#define SDC_NICE_WAITING            TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* SERIAL driver related settings.                                           */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Default bit rate.
 | 
			
		||||
 * @details Configuration parameter, this is the baud rate selected for the
 | 
			
		||||
 *          default configuration.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__)
 | 
			
		||||
#define SERIAL_DEFAULT_BITRATE      38400
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Serial buffers size.
 | 
			
		||||
 * @details Configuration parameter, you can change the depth of the queue
 | 
			
		||||
 *          buffers depending on the requirements of your application.
 | 
			
		||||
 * @note    The default is 64 bytes for both the transmission and receive
 | 
			
		||||
 *          buffers.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
 | 
			
		||||
#define SERIAL_BUFFERS_SIZE         128
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* SERIAL_USB driver related setting.                                        */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Serial over USB buffers size.
 | 
			
		||||
 * @details Configuration parameter, the buffer size must be a multiple of
 | 
			
		||||
 *          the USB data endpoint maximum packet size.
 | 
			
		||||
 * @note    The default is 64 bytes for both the transmission and receive
 | 
			
		||||
 *          buffers.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
 | 
			
		||||
#define SERIAL_USB_BUFFERS_SIZE     256
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* SPI driver related settings.                                              */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables synchronous APIs.
 | 
			
		||||
 * @note    Disabling this option saves both code and data space.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__)
 | 
			
		||||
#define SPI_USE_WAIT                TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs.
 | 
			
		||||
 * @note    Disabling this option saves both code and data space.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__)
 | 
			
		||||
#define SPI_USE_MUTUAL_EXCLUSION    TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
/* USB driver related settings.                                              */
 | 
			
		||||
/*===========================================================================*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief   Enables synchronous APIs.
 | 
			
		||||
 * @note    Disabling this option saves both code and data space.
 | 
			
		||||
 */
 | 
			
		||||
#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__)
 | 
			
		||||
#define USB_USE_WAIT                TRUE
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* _HALCONF_H_ */
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
							
								
								
									
										76
									
								
								keyboards/infinity_ergodox/infinity_ergodox.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								keyboards/infinity_ergodox/infinity_ergodox.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,76 @@
 | 
			
		||||
#include "infinity_ergodox.h"
 | 
			
		||||
#include "ch.h"
 | 
			
		||||
#include "hal.h"
 | 
			
		||||
#include "serial_link/system/serial_link.h"
 | 
			
		||||
#include "lcd_backlight.h"
 | 
			
		||||
 | 
			
		||||
void init_serial_link_hal(void) {
 | 
			
		||||
    PORTA->PCR[1] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(2);
 | 
			
		||||
    PORTA->PCR[2] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(2);
 | 
			
		||||
    PORTE->PCR[0] = PORTx_PCRn_PE | PORTx_PCRn_PS | PORTx_PCRn_PFE | PORTx_PCRn_MUX(3);
 | 
			
		||||
    PORTE->PCR[1] = PORTx_PCRn_DSE | PORTx_PCRn_SRE | PORTx_PCRn_MUX(3);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define RED_PIN 1
 | 
			
		||||
#define GREEN_PIN 2
 | 
			
		||||
#define BLUE_PIN 3
 | 
			
		||||
#define CHANNEL_RED FTM0->CHANNEL[0]
 | 
			
		||||
#define CHANNEL_GREEN FTM0->CHANNEL[1]
 | 
			
		||||
#define CHANNEL_BLUE FTM0->CHANNEL[2]
 | 
			
		||||
 | 
			
		||||
#define RGB_PORT PORTC
 | 
			
		||||
#define RGB_PORT_GPIO GPIOC
 | 
			
		||||
 | 
			
		||||
// Base FTM clock selection (72 MHz system clock)
 | 
			
		||||
// @ 0xFFFF period, 72 MHz / (0xFFFF * 2) = Actual period
 | 
			
		||||
// Higher pre-scalar will use the most power (also look the best)
 | 
			
		||||
// Pre-scalar calculations
 | 
			
		||||
// 0 -      72 MHz -> 549 Hz
 | 
			
		||||
// 1 -      36 MHz -> 275 Hz
 | 
			
		||||
// 2 -      18 MHz -> 137 Hz
 | 
			
		||||
// 3 -       9 MHz ->  69 Hz (Slightly visible flicker)
 | 
			
		||||
// 4 -   4 500 kHz ->  34 Hz (Visible flickering)
 | 
			
		||||
// 5 -   2 250 kHz ->  17 Hz
 | 
			
		||||
// 6 -   1 125 kHz ->   9 Hz
 | 
			
		||||
// 7 - 562 500  Hz ->   4 Hz
 | 
			
		||||
// Using a higher pre-scalar without flicker is possible but FTM0_MOD will need to be reduced
 | 
			
		||||
// Which will reduce the brightness range
 | 
			
		||||
#define PRESCALAR_DEFINE 0
 | 
			
		||||
 | 
			
		||||
void lcd_backlight_hal_init(void) {
 | 
			
		||||
	// Setup Backlight
 | 
			
		||||
    SIM->SCGC6 |= SIM_SCGC6_FTM0;
 | 
			
		||||
    FTM0->CNT = 0; // Reset counter
 | 
			
		||||
 | 
			
		||||
	// PWM Period
 | 
			
		||||
	// 16-bit maximum
 | 
			
		||||
	FTM0->MOD = 0xFFFF;
 | 
			
		||||
 | 
			
		||||
	// Set FTM to PWM output - Edge Aligned, Low-true pulses
 | 
			
		||||
#define CNSC_MODE FTM_SC_CPWMS | FTM_SC_PS(4) | FTM_SC_CLKS(0)
 | 
			
		||||
	CHANNEL_RED.CnSC = CNSC_MODE;
 | 
			
		||||
	CHANNEL_GREEN.CnSC = CNSC_MODE;
 | 
			
		||||
	CHANNEL_BLUE.CnSC = CNSC_MODE;
 | 
			
		||||
 | 
			
		||||
	// System clock, /w prescalar setting
 | 
			
		||||
	FTM0->SC = FTM_SC_CLKS(1) | FTM_SC_PS(PRESCALAR_DEFINE);
 | 
			
		||||
 | 
			
		||||
	CHANNEL_RED.CnV = 0;
 | 
			
		||||
	CHANNEL_GREEN.CnV = 0;
 | 
			
		||||
	CHANNEL_BLUE.CnV = 0;
 | 
			
		||||
 | 
			
		||||
	RGB_PORT_GPIO->PDDR |= (1 << RED_PIN);
 | 
			
		||||
	RGB_PORT_GPIO->PDDR |= (1 << GREEN_PIN);
 | 
			
		||||
	RGB_PORT_GPIO->PDDR |= (1 << BLUE_PIN);
 | 
			
		||||
 | 
			
		||||
#define RGB_MODE PORTx_PCRn_SRE | PORTx_PCRn_DSE | PORTx_PCRn_MUX(4)
 | 
			
		||||
    RGB_PORT->PCR[RED_PIN] = RGB_MODE;
 | 
			
		||||
    RGB_PORT->PCR[GREEN_PIN] = RGB_MODE;
 | 
			
		||||
    RGB_PORT->PCR[BLUE_PIN] = RGB_MODE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void lcd_backlight_hal_color(uint16_t r, uint16_t g, uint16_t b) {
 | 
			
		||||
	CHANNEL_RED.CnV = r;
 | 
			
		||||
	CHANNEL_GREEN.CnV = g;
 | 
			
		||||
	CHANNEL_BLUE.CnV = b;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										44
									
								
								keyboards/infinity_ergodox/infinity_ergodox.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								keyboards/infinity_ergodox/infinity_ergodox.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,44 @@
 | 
			
		||||
#ifndef KEYBOARDS_INFINITY_ERGODOX_INFINITY_ERGODOX_H_
 | 
			
		||||
#define KEYBOARDS_INFINITY_ERGODOX_INFINITY_ERGODOX_H_
 | 
			
		||||
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
 | 
			
		||||
#define KEYMAP( \
 | 
			
		||||
    A80, A70, A60, A50, A40, A30, A20,  \
 | 
			
		||||
    A81, A71, A61, A51, A41, A31, A21,  \
 | 
			
		||||
    A82, A72, A62, A52, A42, A32,       \
 | 
			
		||||
    A83, A73, A63, A53, A43, A33, A23,  \
 | 
			
		||||
    A84, A74, A64, A54, A44,            \
 | 
			
		||||
                                  A13, A03, \
 | 
			
		||||
                                       A04, \
 | 
			
		||||
                             A34, A24, A14, \
 | 
			
		||||
         B20, B30, B40, B50, B60, B70, B80, \
 | 
			
		||||
         B21, B31, B41, B51, B61, B71, B81, \
 | 
			
		||||
              B32, B42, B52, B62, B72, B82, \
 | 
			
		||||
         B23, B33, B43, B53, B63, B73, B83, \
 | 
			
		||||
                   B44, B54, B64, B74, B84, \
 | 
			
		||||
    B03, B13,     \
 | 
			
		||||
    B04,          \
 | 
			
		||||
    B14, B24, B34 \
 | 
			
		||||
) { \
 | 
			
		||||
    { KC_NO,    KC_NO,    KC_NO,    KC_##A03, KC_##A04 }, \
 | 
			
		||||
    { KC_NO,    KC_NO,    KC_NO,    KC_##A13, KC_##A14 }, \
 | 
			
		||||
    { KC_##A20, KC_##A21, KC_NO,    KC_##A23, KC_##A24 }, \
 | 
			
		||||
    { KC_##A30, KC_##A31, KC_##A32, KC_##A33, KC_##A34 }, \
 | 
			
		||||
    { KC_##A40, KC_##A41, KC_##A42, KC_##A43, KC_##A44 }, \
 | 
			
		||||
    { KC_##A50, KC_##A51, KC_##A52, KC_##A53, KC_##A54 }, \
 | 
			
		||||
    { KC_##A60, KC_##A61, KC_##A62, KC_##A63, KC_##A64 }, \
 | 
			
		||||
    { KC_##A70, KC_##A71, KC_##A72, KC_##A73, KC_##A74 }, \
 | 
			
		||||
    { KC_##A80, KC_##A81, KC_##A82, KC_##A83, KC_##A84 }, \
 | 
			
		||||
    { KC_NO,    KC_NO,    KC_NO,    KC_##B03, KC_##B04 }, \
 | 
			
		||||
    { KC_NO,    KC_NO,    KC_NO,    KC_##B13, KC_##B14 }, \
 | 
			
		||||
    { KC_##B20, KC_##B21, KC_NO,    KC_##B23, KC_##B24 }, \
 | 
			
		||||
    { KC_##B30, KC_##B31, KC_##B32, KC_##B33, KC_##B34 }, \
 | 
			
		||||
    { KC_##B40, KC_##B41, KC_##B42, KC_##B43, KC_##B44 }, \
 | 
			
		||||
    { KC_##B50, KC_##B51, KC_##B52, KC_##B53, KC_##B54 }, \
 | 
			
		||||
    { KC_##B60, KC_##B61, KC_##B62, KC_##B63, KC_##B64 }, \
 | 
			
		||||
    { KC_##B70, KC_##B71, KC_##B72, KC_##B73, KC_##B74 }, \
 | 
			
		||||
    { KC_##B80, KC_##B81, KC_##B82, KC_##B83, KC_##B84 }  \
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif /* KEYBOARDS_INFINITY_ERGODOX_INFINITY_ERGODOX_H_ */
 | 
			
		||||
							
								
								
									
										111
									
								
								keyboards/infinity_ergodox/keymaps/default/keymap.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										111
									
								
								keyboards/infinity_ergodox/keymaps/default/keymap.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,111 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
 | 
			
		||||
Jun Wako <wakojun@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "infinity_ergodox.h"
 | 
			
		||||
 | 
			
		||||
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
    KEYMAP(  // layer 0 : default
 | 
			
		||||
        // left hand
 | 
			
		||||
        EQL, 1,   2,   3,   4,   5,   ESC,
 | 
			
		||||
        BSLS,Q,   W,   E,   R,   T,   FN1,
 | 
			
		||||
        TAB, A,   S,   D,   F,   G,
 | 
			
		||||
        LSFT,Z,   X,   C,   V,   B,   FN0,
 | 
			
		||||
        LGUI,GRV, BSLS,LEFT,RGHT,
 | 
			
		||||
                                      LCTL,LALT,
 | 
			
		||||
                                           HOME,
 | 
			
		||||
                                 BSPC,DEL, END,
 | 
			
		||||
        // right hand
 | 
			
		||||
             FN2, 6,   7,   8,   9,   0,   MINS,
 | 
			
		||||
             LBRC,Y,   U,   I,   O,   P,   RBRC,
 | 
			
		||||
                  H,   J,   K,   L,   SCLN,QUOT,
 | 
			
		||||
             FN0, N,   M,   COMM,DOT, SLSH,RSFT,
 | 
			
		||||
                       LEFT,DOWN,UP,  RGHT,RGUI,
 | 
			
		||||
        RALT,RCTL,
 | 
			
		||||
        PGUP,
 | 
			
		||||
        PGDN,ENT, SPC
 | 
			
		||||
    ),
 | 
			
		||||
 | 
			
		||||
    KEYMAP(  // layer 1 : function and symbol keys
 | 
			
		||||
        // left hand
 | 
			
		||||
        TRNS,F1,  F2,  F3,  F4,  F5,  F11,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,FN3,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
                                      TRNS,TRNS,
 | 
			
		||||
                                           TRNS,
 | 
			
		||||
                                 TRNS,TRNS,TRNS,
 | 
			
		||||
        // right hand
 | 
			
		||||
             F12, F6,  F7,  F8,  F9,  F10, TRNS,
 | 
			
		||||
             TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
                  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
             TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
                       TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,
 | 
			
		||||
        TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS
 | 
			
		||||
    ),
 | 
			
		||||
 | 
			
		||||
    KEYMAP(  // layer 2 : keyboard functions
 | 
			
		||||
        // left hand
 | 
			
		||||
        BTLD,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, FN3,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
                                      TRNS,TRNS,
 | 
			
		||||
                                           TRNS,
 | 
			
		||||
                                 TRNS,TRNS,TRNS,
 | 
			
		||||
        // right hand
 | 
			
		||||
             TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
             TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
                  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
             TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
                       TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,
 | 
			
		||||
        TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS
 | 
			
		||||
    ),
 | 
			
		||||
 | 
			
		||||
    KEYMAP(  // layer 3: numpad
 | 
			
		||||
        // left hand
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS,TRNS,TRNS,
 | 
			
		||||
                                      TRNS,TRNS,
 | 
			
		||||
                                           TRNS,
 | 
			
		||||
                                 TRNS,TRNS,TRNS,
 | 
			
		||||
        // right hand
 | 
			
		||||
             TRNS,NLCK,PSLS,PAST,PAST,PMNS,BSPC,
 | 
			
		||||
             TRNS,NO,  P7,  P8,  P9,  PMNS,BSPC,
 | 
			
		||||
                  NO,  P4,  P5,  P6,  PPLS,PENT,
 | 
			
		||||
             TRNS,NO,  P1,  P2,  P3,  PPLS,PENT,
 | 
			
		||||
                       P0,  PDOT,SLSH,PENT,PENT,
 | 
			
		||||
        TRNS,TRNS,
 | 
			
		||||
        TRNS,
 | 
			
		||||
        TRNS,TRNS,TRNS
 | 
			
		||||
    ),
 | 
			
		||||
};
 | 
			
		||||
const uint16_t fn_actions[] = {
 | 
			
		||||
    ACTION_LAYER_MOMENTARY(1),                      // FN0 - switch to Layer1
 | 
			
		||||
    ACTION_LAYER_SET(2, ON_PRESS),                  // FN1 - set Layer2
 | 
			
		||||
    ACTION_LAYER_TOGGLE(3),                         // FN2 - toggle Layer3 aka Numpad layer
 | 
			
		||||
    ACTION_LAYER_SET(0, ON_PRESS),                  // FN3 - set Layer0
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										168
									
								
								keyboards/infinity_ergodox/keymaps/default/visualizer.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										168
									
								
								keyboards/infinity_ergodox/keymaps/default/visualizer.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,168 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
// Currently we are assuming that both the backlight and LCD are enabled
 | 
			
		||||
// But it's entirely possible to write a custom visualizer that use only
 | 
			
		||||
// one of them
 | 
			
		||||
#ifndef LCD_BACKLIGHT_ENABLE
 | 
			
		||||
#error This visualizer needs that LCD backlight is enabled
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef LCD_ENABLE
 | 
			
		||||
#error This visualizer needs that LCD is enabled
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "visualizer.h"
 | 
			
		||||
#include "led_test.h"
 | 
			
		||||
 | 
			
		||||
static const char* welcome_text[] = {"TMK", "Infinity Ergodox"};
 | 
			
		||||
 | 
			
		||||
// Just an example how to write custom keyframe functions, we could have moved
 | 
			
		||||
// all this into the init function
 | 
			
		||||
bool display_welcome(keyframe_animation_t* animation, visualizer_state_t* state) {
 | 
			
		||||
    (void)animation;
 | 
			
		||||
    // Read the uGFX documentation for information how to use the displays
 | 
			
		||||
    // http://wiki.ugfx.org/index.php/Main_Page
 | 
			
		||||
    gdispClear(White);
 | 
			
		||||
    // You can use static variables for things that can't be found in the animation
 | 
			
		||||
    // or state structs
 | 
			
		||||
    gdispDrawString(0, 3, welcome_text[0], state->font_dejavusansbold12, Black);
 | 
			
		||||
    gdispDrawString(0, 15, welcome_text[1], state->font_dejavusansbold12, Black);
 | 
			
		||||
    // Always remember to flush the display
 | 
			
		||||
    gdispFlush();
 | 
			
		||||
    // you could set the backlight color as well, but we won't do it here, since
 | 
			
		||||
    // it's part of the following animation
 | 
			
		||||
    // lcd_backlight_color(hue, saturation, intensity);
 | 
			
		||||
    // We don't need constant updates, just drawing the screen once is enough
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Feel free to modify the animations below, or even add new ones if needed
 | 
			
		||||
 | 
			
		||||
// Don't worry, if the startup animation is long, you can use the keyboard like normal
 | 
			
		||||
// during that time
 | 
			
		||||
static keyframe_animation_t startup_animation = {
 | 
			
		||||
    .num_frames = 4,
 | 
			
		||||
    .loop = false,
 | 
			
		||||
    .frame_lengths = {0, gfxMillisecondsToTicks(1000), gfxMillisecondsToTicks(5000), 0},
 | 
			
		||||
    .frame_functions = {
 | 
			
		||||
            display_welcome,
 | 
			
		||||
            keyframe_animate_backlight_color,
 | 
			
		||||
            keyframe_no_operation,
 | 
			
		||||
            enable_visualization
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// The color animation animates the LCD color when you change layers
 | 
			
		||||
static keyframe_animation_t color_animation = {
 | 
			
		||||
    .num_frames = 2,
 | 
			
		||||
    .loop = false,
 | 
			
		||||
    // Note that there's a 200 ms no-operation frame,
 | 
			
		||||
    // this prevents the color from changing when activating the layer
 | 
			
		||||
    // momentarily
 | 
			
		||||
    .frame_lengths = {gfxMillisecondsToTicks(200), gfxMillisecondsToTicks(500)},
 | 
			
		||||
    .frame_functions = {keyframe_no_operation, keyframe_animate_backlight_color},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// The LCD animation alternates between the layer name display and a
 | 
			
		||||
// bitmap that displays all active layers
 | 
			
		||||
static keyframe_animation_t lcd_animation = {
 | 
			
		||||
    .num_frames = 2,
 | 
			
		||||
    .loop = true,
 | 
			
		||||
    .frame_lengths = {gfxMillisecondsToTicks(2000), gfxMillisecondsToTicks(2000)},
 | 
			
		||||
    .frame_functions = {keyframe_display_layer_text, keyframe_display_layer_bitmap},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static keyframe_animation_t suspend_animation = {
 | 
			
		||||
    .num_frames = 3,
 | 
			
		||||
    .loop = false,
 | 
			
		||||
    .frame_lengths = {0, gfxMillisecondsToTicks(1000), 0},
 | 
			
		||||
    .frame_functions = {
 | 
			
		||||
            keyframe_display_layer_text,
 | 
			
		||||
            keyframe_animate_backlight_color,
 | 
			
		||||
            keyframe_disable_lcd_and_backlight,
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static keyframe_animation_t resume_animation = {
 | 
			
		||||
    .num_frames = 5,
 | 
			
		||||
    .loop = false,
 | 
			
		||||
    .frame_lengths = {0, 0, gfxMillisecondsToTicks(1000), gfxMillisecondsToTicks(5000), 0},
 | 
			
		||||
    .frame_functions = {
 | 
			
		||||
            keyframe_enable_lcd_and_backlight,
 | 
			
		||||
            display_welcome,
 | 
			
		||||
            keyframe_animate_backlight_color,
 | 
			
		||||
            keyframe_no_operation,
 | 
			
		||||
            enable_visualization,
 | 
			
		||||
    },
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void initialize_user_visualizer(visualizer_state_t* state) {
 | 
			
		||||
    // The brightness will be dynamically adjustable in the future
 | 
			
		||||
    // But for now, change it here.
 | 
			
		||||
    lcd_backlight_brightness(0x50);
 | 
			
		||||
    state->current_lcd_color = LCD_COLOR(0x00, 0x00, 0xFF);
 | 
			
		||||
    state->target_lcd_color = LCD_COLOR(0x10, 0xFF, 0xFF);
 | 
			
		||||
    start_keyframe_animation(&startup_animation);
 | 
			
		||||
    start_keyframe_animation(&led_test_animation);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void update_user_visualizer_state(visualizer_state_t* state) {
 | 
			
		||||
    // Add more tests, change the colors and layer texts here
 | 
			
		||||
    // Usually you want to check the high bits (higher layers first)
 | 
			
		||||
    // because that's the order layers are processed for keypresses
 | 
			
		||||
    // You can for check for example:
 | 
			
		||||
    // state->status.layer
 | 
			
		||||
    // state->status.default_layer
 | 
			
		||||
    // state->status.leds (see led.h for available statuses)
 | 
			
		||||
    if (state->status.layer & 0x8) {
 | 
			
		||||
        state->target_lcd_color = LCD_COLOR(0xC0, 0xB0, 0xFF);
 | 
			
		||||
        state->layer_text = "Numpad";
 | 
			
		||||
    }
 | 
			
		||||
    else if (state->status.layer & 0x4) {
 | 
			
		||||
        state->target_lcd_color = LCD_COLOR(0, 0xB0, 0xFF);
 | 
			
		||||
        state->layer_text = "KBD functions";
 | 
			
		||||
    }
 | 
			
		||||
    else if (state->status.layer & 0x2) {
 | 
			
		||||
        state->target_lcd_color = LCD_COLOR(0x80, 0xB0, 0xFF);
 | 
			
		||||
        state->layer_text = "Function keys";
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        state->target_lcd_color = LCD_COLOR(0x40, 0xB0, 0xFF);
 | 
			
		||||
        state->layer_text = "Default";
 | 
			
		||||
    }
 | 
			
		||||
    // You can also stop existing animations, and start your custom ones here
 | 
			
		||||
    // remember that you should normally have only one animation for the LCD
 | 
			
		||||
    // and one for the background. But you can also combine them if you want.
 | 
			
		||||
    start_keyframe_animation(&lcd_animation);
 | 
			
		||||
    start_keyframe_animation(&color_animation);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void user_visualizer_suspend(visualizer_state_t* state) {
 | 
			
		||||
    state->layer_text = "Suspending...";
 | 
			
		||||
    uint8_t hue = LCD_HUE(state->current_lcd_color);
 | 
			
		||||
    uint8_t sat = LCD_SAT(state->current_lcd_color);
 | 
			
		||||
    state->target_lcd_color = LCD_COLOR(hue, sat, 0);
 | 
			
		||||
    start_keyframe_animation(&suspend_animation);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void user_visualizer_resume(visualizer_state_t* state) {
 | 
			
		||||
    state->current_lcd_color = LCD_COLOR(0x00, 0x00, 0x00);
 | 
			
		||||
    state->target_lcd_color = LCD_COLOR(0x10, 0xFF, 0xFF);
 | 
			
		||||
    start_keyframe_animation(&resume_animation);
 | 
			
		||||
    start_keyframe_animation(&led_test_animation);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										49
									
								
								keyboards/infinity_ergodox/led.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								keyboards/infinity_ergodox/led.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,49 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "hal.h"
 | 
			
		||||
 | 
			
		||||
#include "led.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void led_set(uint8_t usb_led) {
 | 
			
		||||
// The LCD backlight functionality conflicts with this simple
 | 
			
		||||
// red backlight
 | 
			
		||||
#if !defined(LCD_BACKLIGHT_ENABLE) && defined(STATUS_LED_ENABLE)
 | 
			
		||||
    // PTC1: LCD Backlight Red(0:on/1:off)
 | 
			
		||||
    GPIOC->PDDR |= (1<<1);
 | 
			
		||||
    PORTC->PCR[1] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
 | 
			
		||||
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
 | 
			
		||||
        GPIOC->PCOR |= (1<<1);
 | 
			
		||||
    } else {
 | 
			
		||||
        GPIOC->PSOR |= (1<<1);
 | 
			
		||||
    }
 | 
			
		||||
#elif !defined(LCD_BACKLIGHT_ENABLE)
 | 
			
		||||
    (void)usb_led;
 | 
			
		||||
    GPIOC->PDDR |= (1<<1);
 | 
			
		||||
    PORTC->PCR[1] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
 | 
			
		||||
    GPIOC->PSOR |= (1<<1);
 | 
			
		||||
    GPIOC->PDDR |= (1<<2);
 | 
			
		||||
    PORTC->PCR[2] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
 | 
			
		||||
    GPIOC->PSOR |= (1<<2);
 | 
			
		||||
    GPIOC->PDDR |= (1<<3);
 | 
			
		||||
    PORTC->PCR[3] |= PORTx_PCRn_DSE | PORTx_PCRn_MUX(1);
 | 
			
		||||
    GPIOC->PSOR |= (1<<3);
 | 
			
		||||
#else
 | 
			
		||||
    (void)usb_led;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										169
									
								
								keyboards/infinity_ergodox/matrix.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										169
									
								
								keyboards/infinity_ergodox/matrix.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,169 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 Fred Sundvik <fsundvik@gmail.com>
 | 
			
		||||
Jun Wako <wakojun@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include "hal.h"
 | 
			
		||||
#include "timer.h"
 | 
			
		||||
#include "wait.h"
 | 
			
		||||
#include "print.h"
 | 
			
		||||
#include "debug.h"
 | 
			
		||||
#include "matrix.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Infinity ErgoDox Pinusage:
 | 
			
		||||
 * Column pins are input with internal pull-down. Row pins are output and strobe with high.
 | 
			
		||||
 * Key is high or 1 when it turns on.
 | 
			
		||||
 *
 | 
			
		||||
 *     col: { PTD1, PTD4, PTD5, PTD6, PTD7 }
 | 
			
		||||
 *     row: { PTB2, PTB3, PTB18, PTB19, PTC0, PTC9, PTC10, PTC11, PTD0 }
 | 
			
		||||
 */
 | 
			
		||||
/* matrix state(1:on, 0:off) */
 | 
			
		||||
static matrix_row_t matrix[MATRIX_ROWS];
 | 
			
		||||
static matrix_row_t matrix_debouncing[LOCAL_MATRIX_ROWS];
 | 
			
		||||
static bool debouncing = false;
 | 
			
		||||
static uint16_t debouncing_time = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void matrix_init(void)
 | 
			
		||||
{
 | 
			
		||||
    /* Column(sense) */
 | 
			
		||||
    palSetPadMode(GPIOD, 1,  PAL_MODE_INPUT_PULLDOWN);
 | 
			
		||||
    palSetPadMode(GPIOD, 4,  PAL_MODE_INPUT_PULLDOWN);
 | 
			
		||||
    palSetPadMode(GPIOD, 5,  PAL_MODE_INPUT_PULLDOWN);
 | 
			
		||||
    palSetPadMode(GPIOD, 6,  PAL_MODE_INPUT_PULLDOWN);
 | 
			
		||||
    palSetPadMode(GPIOD, 7,  PAL_MODE_INPUT_PULLDOWN);
 | 
			
		||||
 | 
			
		||||
    /* Row(strobe) */
 | 
			
		||||
    palSetPadMode(GPIOB, 2,  PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPadMode(GPIOB, 3,  PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPadMode(GPIOB, 18, PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPadMode(GPIOB, 19, PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPadMode(GPIOC, 0,  PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPadMode(GPIOC, 9,  PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPadMode(GPIOC, 10, PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPadMode(GPIOC, 11, PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
    palSetPadMode(GPIOD, 0,  PAL_MODE_OUTPUT_PUSHPULL);
 | 
			
		||||
 | 
			
		||||
    memset(matrix, 0, MATRIX_ROWS);
 | 
			
		||||
    memset(matrix_debouncing, 0, LOCAL_MATRIX_ROWS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t matrix_scan(void)
 | 
			
		||||
{
 | 
			
		||||
    for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) {
 | 
			
		||||
        matrix_row_t data = 0;
 | 
			
		||||
 | 
			
		||||
        // strobe row
 | 
			
		||||
        switch (row) {
 | 
			
		||||
            case 0: palSetPad(GPIOB, 2);    break;
 | 
			
		||||
            case 1: palSetPad(GPIOB, 3);    break;
 | 
			
		||||
            case 2: palSetPad(GPIOB, 18);   break;
 | 
			
		||||
            case 3: palSetPad(GPIOB, 19);   break;
 | 
			
		||||
            case 4: palSetPad(GPIOC, 0);    break;
 | 
			
		||||
            case 5: palSetPad(GPIOC, 9);    break;
 | 
			
		||||
            case 6: palSetPad(GPIOC, 10);   break;
 | 
			
		||||
            case 7: palSetPad(GPIOC, 11);   break;
 | 
			
		||||
            case 8: palSetPad(GPIOD, 0);    break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // need wait to settle pin state
 | 
			
		||||
        // if you wait too short, or have a too high update rate
 | 
			
		||||
        // the keyboard might freeze, or there might not be enough
 | 
			
		||||
        // processing power to update the LCD screen properly.
 | 
			
		||||
        // 20us, or two ticks at 100000Hz seems to be OK
 | 
			
		||||
        wait_us(20);
 | 
			
		||||
 | 
			
		||||
        // read col data: { PTD1, PTD4, PTD5, PTD6, PTD7 }
 | 
			
		||||
        data = ((palReadPort(GPIOD) & 0xF0) >> 3) |
 | 
			
		||||
               ((palReadPort(GPIOD) & 0x02) >> 1);
 | 
			
		||||
 | 
			
		||||
        // un-strobe row
 | 
			
		||||
        switch (row) {
 | 
			
		||||
            case 0: palClearPad(GPIOB, 2);  break;
 | 
			
		||||
            case 1: palClearPad(GPIOB, 3);  break;
 | 
			
		||||
            case 2: palClearPad(GPIOB, 18); break;
 | 
			
		||||
            case 3: palClearPad(GPIOB, 19); break;
 | 
			
		||||
            case 4: palClearPad(GPIOC, 0);  break;
 | 
			
		||||
            case 5: palClearPad(GPIOC, 9);  break;
 | 
			
		||||
            case 6: palClearPad(GPIOC, 10); break;
 | 
			
		||||
            case 7: palClearPad(GPIOC, 11); break;
 | 
			
		||||
            case 8: palClearPad(GPIOD, 0);  break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (matrix_debouncing[row] != data) {
 | 
			
		||||
            matrix_debouncing[row] = data;
 | 
			
		||||
            debouncing = true;
 | 
			
		||||
            debouncing_time = timer_read();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    uint8_t offset = 0;
 | 
			
		||||
#ifdef MASTER_IS_ON_RIGHT
 | 
			
		||||
    if (is_serial_link_master()) {
 | 
			
		||||
        offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
 | 
			
		||||
        for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) {
 | 
			
		||||
            matrix[offset + row] = matrix_debouncing[row];
 | 
			
		||||
        }
 | 
			
		||||
        debouncing = false;
 | 
			
		||||
    }
 | 
			
		||||
    return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool matrix_is_on(uint8_t row, uint8_t col)
 | 
			
		||||
{
 | 
			
		||||
    return (matrix[row] & (1<<col));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
matrix_row_t matrix_get_row(uint8_t row)
 | 
			
		||||
{
 | 
			
		||||
    return matrix[row];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void matrix_print(void)
 | 
			
		||||
{
 | 
			
		||||
    xprintf("\nr/c 01234567\n");
 | 
			
		||||
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
 | 
			
		||||
        xprintf("%X0: ", row);
 | 
			
		||||
        matrix_row_t data = matrix_get_row(row);
 | 
			
		||||
        for (int col = 0; col < MATRIX_COLS; col++) {
 | 
			
		||||
            if (data & (1<<col))
 | 
			
		||||
                xprintf("1");
 | 
			
		||||
            else
 | 
			
		||||
                xprintf("0");
 | 
			
		||||
        }
 | 
			
		||||
        xprintf("\n");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void matrix_set_remote(matrix_row_t* rows, uint8_t index) {
 | 
			
		||||
    uint8_t offset = 0;
 | 
			
		||||
#ifdef MASTER_IS_ON_RIGHT
 | 
			
		||||
    offset = MATRIX_ROWS - LOCAL_MATRIX_ROWS * (index + 2);
 | 
			
		||||
#else
 | 
			
		||||
    offset = LOCAL_MATRIX_ROWS * (index + 1);
 | 
			
		||||
#endif
 | 
			
		||||
    for (int row = 0; row < LOCAL_MATRIX_ROWS; row++) {
 | 
			
		||||
        matrix[offset + row] = rows[row];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										74
									
								
								keyboards/infinity_ergodox/mcuconf.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								keyboards/infinity_ergodox/mcuconf.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,74 @@
 | 
			
		||||
/*
 | 
			
		||||
    ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
 | 
			
		||||
 | 
			
		||||
    Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
    you may not use this file except in compliance with the License.
 | 
			
		||||
    You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
        http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
    Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
    distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
    See the License for the specific language governing permissions and
 | 
			
		||||
    limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef _MCUCONF_H_
 | 
			
		||||
#define _MCUCONF_H_
 | 
			
		||||
 | 
			
		||||
#define K20x_MCUCONF
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * HAL driver system settings.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#define K20x7
 | 
			
		||||
 | 
			
		||||
/* Select the MCU clocking mode below by enabling the appropriate block. */
 | 
			
		||||
 | 
			
		||||
#define KINETIS_NO_INIT             FALSE
 | 
			
		||||
 | 
			
		||||
/* PEE mode - 48MHz system clock driven by external crystal. */
 | 
			
		||||
#define KINETIS_MCG_MODE            KINETIS_MCG_MODE_PEE
 | 
			
		||||
#define KINETIS_PLLCLK_FREQUENCY    72000000UL
 | 
			
		||||
#define KINETIS_SYSCLK_FREQUENCY    72000000UL
 | 
			
		||||
#define KINETIS_BUSCLK_FREQUENCY    36000000UL
 | 
			
		||||
#define KINETIS_FLASHCLK_FREQUENCY  24000000UL
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
/* FEI mode - 48 MHz with internal 32.768 kHz crystal */
 | 
			
		||||
#define KINETIS_MCG_MODE            KINETIS_MCG_MODE_FEI
 | 
			
		||||
#define KINETIS_MCG_FLL_DMX32       1           /* Fine-tune for 32.768 kHz */
 | 
			
		||||
#define KINETIS_MCG_FLL_DRS         1           /* 1464x FLL factor */
 | 
			
		||||
#define KINETIS_SYSCLK_FREQUENCY    47972352UL  /* 32.768 kHz * 1464 (~48 MHz) */
 | 
			
		||||
#define KINETIS_CLKDIV1_OUTDIV1     1
 | 
			
		||||
#define KINETIS_CLKDIV1_OUTDIV2     1
 | 
			
		||||
#define KINETIS_CLKDIV1_OUTDIV4     2
 | 
			
		||||
#define KINETIS_BUSCLK_FREQUENCY    KINETIS_SYSCLK_FREQUENCY
 | 
			
		||||
#define KINETIS_FLASHCLK_FREQUENCY  KINETIS_SYSCLK_FREQUENCY/2
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * SERIAL driver system settings.
 | 
			
		||||
 */
 | 
			
		||||
#define KINETIS_SERIAL_USE_UART0            TRUE
 | 
			
		||||
#define KINETIS_SERIAL_USE_UART1            TRUE
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * USB driver settings
 | 
			
		||||
 */
 | 
			
		||||
#define KINETIS_USB_USE_USB0                TRUE
 | 
			
		||||
/* Need to redefine this, since the default is for K20x */
 | 
			
		||||
/* This is for Teensy LC; you should comment it out (or change to 5)
 | 
			
		||||
 * for Teensy 3.x */
 | 
			
		||||
#define KINETIS_USB_USB0_IRQ_PRIORITY       2
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * SPI driver system settings.
 | 
			
		||||
 */
 | 
			
		||||
#define KINETIS_SPI_USE_SPI0                TRUE
 | 
			
		||||
 | 
			
		||||
#define KINETIS_I2C_USE_I2C0                TRUE
 | 
			
		||||
 | 
			
		||||
#endif /* _MCUCONF_H_ */
 | 
			
		||||
							
								
								
									
										78
									
								
								keyboards/lets_split/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								keyboards/lets_split/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,78 @@
 | 
			
		||||
SRC += matrix.c \
 | 
			
		||||
	   i2c.c \
 | 
			
		||||
	   split_util.c \
 | 
			
		||||
	   serial.c
 | 
			
		||||
 | 
			
		||||
# MCU name
 | 
			
		||||
#MCU = at90usb1287
 | 
			
		||||
MCU = atmega32u4
 | 
			
		||||
 | 
			
		||||
# Processor frequency.
 | 
			
		||||
#     This will define a symbol, F_CPU, in all source code files equal to the
 | 
			
		||||
#     processor frequency in Hz. You can then use this symbol in your source code to
 | 
			
		||||
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
 | 
			
		||||
#     automatically to create a 32-bit value in your source code.
 | 
			
		||||
#
 | 
			
		||||
#     This will be an integer division of F_USB below, as it is sourced by
 | 
			
		||||
#     F_USB after it has run through any CPU prescalers. Note that this value
 | 
			
		||||
#     does not *change* the processor frequency - it should merely be updated to
 | 
			
		||||
#     reflect the processor speed set externally so that the code can use accurate
 | 
			
		||||
#     software delays.
 | 
			
		||||
F_CPU = 16000000
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# LUFA specific
 | 
			
		||||
#
 | 
			
		||||
# Target architecture (see library "Board Types" documentation).
 | 
			
		||||
ARCH = AVR8
 | 
			
		||||
 | 
			
		||||
# Input clock frequency.
 | 
			
		||||
#     This will define a symbol, F_USB, in all source code files equal to the
 | 
			
		||||
#     input clock frequency (before any prescaling is performed) in Hz. This value may
 | 
			
		||||
#     differ from F_CPU if prescaling is used on the latter, and is required as the
 | 
			
		||||
#     raw input clock is fed directly to the PLL sections of the AVR for high speed
 | 
			
		||||
#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
 | 
			
		||||
#     at the end, this will be done automatically to create a 32-bit value in your
 | 
			
		||||
#     source code.
 | 
			
		||||
#
 | 
			
		||||
#     If no clock division is performed on the input clock inside the AVR (via the
 | 
			
		||||
#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
 | 
			
		||||
F_USB = $(F_CPU)
 | 
			
		||||
 | 
			
		||||
# Interrupt driven control endpoint task(+60)
 | 
			
		||||
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Boot Section Size in *bytes*
 | 
			
		||||
#   Teensy halfKay   512
 | 
			
		||||
#   Teensy++ halfKay 1024
 | 
			
		||||
#   Atmel DFU loader 4096
 | 
			
		||||
#   LUFA bootloader  4096
 | 
			
		||||
#   USBaspLoader     2048
 | 
			
		||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
 | 
			
		||||
 | 
			
		||||
# Build Options
 | 
			
		||||
#   change to "no" to disable the options, or define them in the Makefile in 
 | 
			
		||||
#   the appropriate keymap folder that will get included automatically
 | 
			
		||||
#
 | 
			
		||||
BOOTMAGIC_ENABLE ?= no       # Virtual DIP switch configuration(+1000)
 | 
			
		||||
MOUSEKEY_ENABLE ?= yes       # Mouse keys(+4700)
 | 
			
		||||
EXTRAKEY_ENABLE ?= yes       # Audio control and System control(+450)
 | 
			
		||||
CONSOLE_ENABLE ?= no         # Console for debug(+400)
 | 
			
		||||
COMMAND_ENABLE ?= yes        # Commands for debug and configuration
 | 
			
		||||
NKRO_ENABLE ?= no            # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
 | 
			
		||||
BACKLIGHT_ENABLE ?= no      # Enable keyboard backlight functionality
 | 
			
		||||
MIDI_ENABLE ?= no            # MIDI controls
 | 
			
		||||
AUDIO_ENABLE ?= yes           # Audio output on port C6
 | 
			
		||||
UNICODE_ENABLE ?= no         # Unicode
 | 
			
		||||
BLUETOOTH_ENABLE ?= no       # Enable Bluetooth with the Adafruit EZ-Key HID
 | 
			
		||||
RGBLIGHT_ENABLE ?= no        # Enable WS2812 RGB underlight.  Do not enable this with audio at the same time.
 | 
			
		||||
 | 
			
		||||
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
 | 
			
		||||
SLEEP_LED_ENABLE ?= no    # Breathing sleep LED during USB suspend
 | 
			
		||||
 | 
			
		||||
CUSTOM_MATRIX = yes
 | 
			
		||||
 | 
			
		||||
ifndef QUANTUM_DIR
 | 
			
		||||
	include ../../Makefile
 | 
			
		||||
endif
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2015 Jun Wako <wakojun@gmail.com>
 | 
			
		||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
@ -18,29 +18,45 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#ifndef CONFIG_H
 | 
			
		||||
#define CONFIG_H
 | 
			
		||||
 | 
			
		||||
#include "config_common.h"
 | 
			
		||||
 | 
			
		||||
/* USB Device descriptor parameter */
 | 
			
		||||
#define VENDOR_ID       0xFEED
 | 
			
		||||
#define PRODUCT_ID      0x6464
 | 
			
		||||
#define PRODUCT_ID      0x3060
 | 
			
		||||
#define DEVICE_VER      0x0001
 | 
			
		||||
/* in python2: list(u"whatever".encode('utf-16-le')) */
 | 
			
		||||
/*   at most 32 characters or the ugly hack in usb_main.c borks */
 | 
			
		||||
#define MANUFACTURER "TMK"
 | 
			
		||||
#define USBSTR_MANUFACTURER    'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', '\xc6', '\x00'
 | 
			
		||||
#define PRODUCT "ChibiOS TMK test"
 | 
			
		||||
#define USBSTR_PRODUCT         'C', '\x00', 'h', '\x00', 'i', '\x00', 'b', '\x00', 'i', '\x00', 'O', '\x00', 'S', '\x00', ' ', '\x00', 'T', '\x00', 'M', '\x00', 'K', '\x00', ' ', '\x00', 't', '\x00', 'e', '\x00', 's', '\x00', 't', '\x00'
 | 
			
		||||
#define DESCRIPTION "TMK keyboard firmware over ChibiOS"
 | 
			
		||||
#define MANUFACTURER    Wootpatoot
 | 
			
		||||
#define PRODUCT         Lets Split
 | 
			
		||||
#define DESCRIPTION     A split keyboard for the cheap makers
 | 
			
		||||
 | 
			
		||||
/* key matrix size */
 | 
			
		||||
#define MATRIX_ROWS 1
 | 
			
		||||
#define MATRIX_COLS 1
 | 
			
		||||
// Rows are doubled-up
 | 
			
		||||
#define MATRIX_ROWS 8
 | 
			
		||||
#define MATRIX_COLS 6
 | 
			
		||||
 | 
			
		||||
// wiring of each half
 | 
			
		||||
#define MATRIX_ROW_PINS { B5, B4, E6, D7 }
 | 
			
		||||
#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3 }
 | 
			
		||||
 | 
			
		||||
#define CATERINA_BOOTLOADER
 | 
			
		||||
 | 
			
		||||
// #define USE_I2C
 | 
			
		||||
 | 
			
		||||
// #define EE_HANDS
 | 
			
		||||
 | 
			
		||||
#define I2C_MASTER_LEFT
 | 
			
		||||
// #define I2C_MASTER_RIGHT
 | 
			
		||||
 | 
			
		||||
/* COL2ROW or ROW2COL */
 | 
			
		||||
#define DIODE_DIRECTION COL2ROW
 | 
			
		||||
 | 
			
		||||
/* define if matrix has ghost */
 | 
			
		||||
//#define MATRIX_HAS_GHOST
 | 
			
		||||
 | 
			
		||||
/* number of backlight levels */
 | 
			
		||||
// #define BACKLIGHT_LEVELS 3
 | 
			
		||||
 | 
			
		||||
/* Set 0 if debouncing isn't needed */
 | 
			
		||||
#define DEBOUNCE    5
 | 
			
		||||
#define DEBOUNCING_DELAY 5
 | 
			
		||||
 | 
			
		||||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
 | 
			
		||||
#define LOCKING_SUPPORT_ENABLE
 | 
			
		||||
@ -52,7 +68,14 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* ws2812 RGB LED */
 | 
			
		||||
#define ws2812_PORTREG  PORTD
 | 
			
		||||
#define ws2812_DDRREG   DDRD
 | 
			
		||||
#define ws2812_pin PD1
 | 
			
		||||
#define RGBLED_NUM 28     // Number of LEDs
 | 
			
		||||
#define RGBLIGHT_HUE_STEP 10
 | 
			
		||||
#define RGBLIGHT_SAT_STEP 17
 | 
			
		||||
#define RGBLIGHT_VAL_STEP 17
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Feature disable options
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								keyboards/lets_split/eeprom-lefthand.eep
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								keyboards/lets_split/eeprom-lefthand.eep
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								keyboards/lets_split/eeprom-righthand.eep
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								keyboards/lets_split/eeprom-righthand.eep
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										159
									
								
								keyboards/lets_split/i2c.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										159
									
								
								keyboards/lets_split/i2c.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,159 @@
 | 
			
		||||
#include <util/twi.h>
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <avr/interrupt.h>
 | 
			
		||||
#include <util/twi.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include "i2c.h"
 | 
			
		||||
 | 
			
		||||
// Limits the amount of we wait for any one i2c transaction.
 | 
			
		||||
// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
 | 
			
		||||
// 9 bits, a single transaction will take around 90μs to complete.
 | 
			
		||||
//
 | 
			
		||||
// (F_CPU/SCL_CLOCK)  =>  # of μC cycles to transfer a bit
 | 
			
		||||
// poll loop takes at least 8 clock cycles to execute
 | 
			
		||||
#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8
 | 
			
		||||
 | 
			
		||||
#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE)
 | 
			
		||||
 | 
			
		||||
volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
 | 
			
		||||
 | 
			
		||||
static volatile uint8_t slave_buffer_pos;
 | 
			
		||||
static volatile bool slave_has_register_set = false;
 | 
			
		||||
 | 
			
		||||
// Wait for an i2c operation to finish
 | 
			
		||||
inline static
 | 
			
		||||
void i2c_delay(void) {
 | 
			
		||||
  uint16_t lim = 0;
 | 
			
		||||
  while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT)
 | 
			
		||||
    lim++;
 | 
			
		||||
 | 
			
		||||
  // easier way, but will wait slightly longer
 | 
			
		||||
  // _delay_us(100);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Setup twi to run at 100kHz
 | 
			
		||||
void i2c_master_init(void) {
 | 
			
		||||
  // no prescaler
 | 
			
		||||
  TWSR = 0;
 | 
			
		||||
  // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10.
 | 
			
		||||
  // Check datasheets for more info.
 | 
			
		||||
  TWBR = ((F_CPU/SCL_CLOCK)-16)/2;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Start a transaction with the given i2c slave address. The direction of the
 | 
			
		||||
// transfer is set with I2C_READ and I2C_WRITE.
 | 
			
		||||
// returns: 0 => success
 | 
			
		||||
//          1 => error
 | 
			
		||||
uint8_t i2c_master_start(uint8_t address) {
 | 
			
		||||
  TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA);
 | 
			
		||||
 | 
			
		||||
  i2c_delay();
 | 
			
		||||
 | 
			
		||||
  // check that we started successfully
 | 
			
		||||
  if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))
 | 
			
		||||
    return 1;
 | 
			
		||||
 | 
			
		||||
  TWDR = address;
 | 
			
		||||
  TWCR = (1<<TWINT) | (1<<TWEN);
 | 
			
		||||
 | 
			
		||||
  i2c_delay();
 | 
			
		||||
 | 
			
		||||
  if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )
 | 
			
		||||
    return 1; // slave did not acknowledge
 | 
			
		||||
  else
 | 
			
		||||
    return 0; // success
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Finish the i2c transaction.
 | 
			
		||||
void i2c_master_stop(void) {
 | 
			
		||||
  TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
 | 
			
		||||
 | 
			
		||||
  uint16_t lim = 0;
 | 
			
		||||
  while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)
 | 
			
		||||
    lim++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Write one byte to the i2c slave.
 | 
			
		||||
// returns 0 => slave ACK
 | 
			
		||||
//         1 => slave NACK
 | 
			
		||||
uint8_t i2c_master_write(uint8_t data) {
 | 
			
		||||
  TWDR = data;
 | 
			
		||||
  TWCR = (1<<TWINT) | (1<<TWEN);
 | 
			
		||||
 | 
			
		||||
  i2c_delay();
 | 
			
		||||
 | 
			
		||||
  // check if the slave acknowledged us
 | 
			
		||||
  return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,
 | 
			
		||||
// if ack=0 the acknowledge bit is not set.
 | 
			
		||||
// returns: byte read from i2c device
 | 
			
		||||
uint8_t i2c_master_read(int ack) {
 | 
			
		||||
  TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);
 | 
			
		||||
 | 
			
		||||
  i2c_delay();
 | 
			
		||||
  return TWDR;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void i2c_reset_state(void) {
 | 
			
		||||
  TWCR = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void i2c_slave_init(uint8_t address) {
 | 
			
		||||
  TWAR = address << 0; // slave i2c address
 | 
			
		||||
  // TWEN  - twi enable
 | 
			
		||||
  // TWEA  - enable address acknowledgement
 | 
			
		||||
  // TWINT - twi interrupt flag
 | 
			
		||||
  // TWIE  - enable the twi interrupt
 | 
			
		||||
  TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ISR(TWI_vect);
 | 
			
		||||
 | 
			
		||||
ISR(TWI_vect) {
 | 
			
		||||
  uint8_t ack = 1;
 | 
			
		||||
  switch(TW_STATUS) {
 | 
			
		||||
    case TW_SR_SLA_ACK:
 | 
			
		||||
      // this device has been addressed as a slave receiver
 | 
			
		||||
      slave_has_register_set = false;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case TW_SR_DATA_ACK:
 | 
			
		||||
      // this device has received data as a slave receiver
 | 
			
		||||
      // The first byte that we receive in this transaction sets the location
 | 
			
		||||
      // of the read/write location of the slaves memory that it exposes over
 | 
			
		||||
      // i2c.  After that, bytes will be written at slave_buffer_pos, incrementing
 | 
			
		||||
      // slave_buffer_pos after each write.
 | 
			
		||||
      if(!slave_has_register_set) {
 | 
			
		||||
        slave_buffer_pos = TWDR;
 | 
			
		||||
        // don't acknowledge the master if this memory loctaion is out of bounds
 | 
			
		||||
        if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) {
 | 
			
		||||
          ack = 0;
 | 
			
		||||
          slave_buffer_pos = 0;
 | 
			
		||||
        }
 | 
			
		||||
        slave_has_register_set = true;
 | 
			
		||||
      } else {
 | 
			
		||||
        i2c_slave_buffer[slave_buffer_pos] = TWDR;
 | 
			
		||||
        BUFFER_POS_INC();
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case TW_ST_SLA_ACK:
 | 
			
		||||
    case TW_ST_DATA_ACK:
 | 
			
		||||
      // master has addressed this device as a slave transmitter and is
 | 
			
		||||
      // requesting data.
 | 
			
		||||
      TWDR = i2c_slave_buffer[slave_buffer_pos];
 | 
			
		||||
      BUFFER_POS_INC();
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case TW_BUS_ERROR: // something went wrong, reset twi state
 | 
			
		||||
      TWCR = 0;
 | 
			
		||||
    default:
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  // Reset everything, so we are ready for the next TWI interrupt
 | 
			
		||||
  TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										31
									
								
								keyboards/lets_split/i2c.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								keyboards/lets_split/i2c.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,31 @@
 | 
			
		||||
#ifndef I2C_H
 | 
			
		||||
#define I2C_H
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#ifndef F_CPU
 | 
			
		||||
#define F_CPU 16000000UL
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define I2C_READ 1
 | 
			
		||||
#define I2C_WRITE 0
 | 
			
		||||
 | 
			
		||||
#define I2C_ACK 1
 | 
			
		||||
#define I2C_NACK 0
 | 
			
		||||
 | 
			
		||||
#define SLAVE_BUFFER_SIZE 0x10
 | 
			
		||||
 | 
			
		||||
// i2c SCL clock frequency
 | 
			
		||||
#define SCL_CLOCK  100000L
 | 
			
		||||
 | 
			
		||||
extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
 | 
			
		||||
 | 
			
		||||
void i2c_master_init(void);
 | 
			
		||||
uint8_t i2c_master_start(uint8_t address);
 | 
			
		||||
void i2c_master_stop(void);
 | 
			
		||||
uint8_t i2c_master_write(uint8_t data);
 | 
			
		||||
uint8_t i2c_master_read(int);
 | 
			
		||||
void i2c_reset_state(void);
 | 
			
		||||
void i2c_slave_init(uint8_t address);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								keyboards/lets_split/imgs/split-keyboard-i2c-schematic.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								keyboards/lets_split/imgs/split-keyboard-i2c-schematic.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 26 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								keyboards/lets_split/imgs/split-keyboard-serial-schematic.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								keyboards/lets_split/imgs/split-keyboard-serial-schematic.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 19 KiB  | 
							
								
								
									
										214
									
								
								keyboards/lets_split/keymaps/default/keymap.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										214
									
								
								keyboards/lets_split/keymaps/default/keymap.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,214 @@
 | 
			
		||||
#include "lets_split.h"
 | 
			
		||||
#include "action_layer.h"
 | 
			
		||||
#include "eeconfig.h"
 | 
			
		||||
 | 
			
		||||
extern keymap_config_t keymap_config;
 | 
			
		||||
 | 
			
		||||
// Each layer gets a name for readability, which is then used in the keymap matrix below.
 | 
			
		||||
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
 | 
			
		||||
// Layer names don't all need to be of the same length, obviously, and you can also skip them
 | 
			
		||||
// entirely and just use numbers.
 | 
			
		||||
#define _QWERTY 0
 | 
			
		||||
#define _COLEMAK 1
 | 
			
		||||
#define _DVORAK 2
 | 
			
		||||
#define _LOWER 3
 | 
			
		||||
#define _RAISE 4
 | 
			
		||||
#define _ADJUST 16
 | 
			
		||||
 | 
			
		||||
enum custom_keycodes {
 | 
			
		||||
  QWERTY = SAFE_RANGE,
 | 
			
		||||
  COLEMAK,
 | 
			
		||||
  DVORAK,
 | 
			
		||||
  LOWER,
 | 
			
		||||
  RAISE,
 | 
			
		||||
  ADJUST,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Fillers to make layering more clear
 | 
			
		||||
#define _______ KC_TRNS
 | 
			
		||||
#define XXXXXXX KC_NO
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
 | 
			
		||||
/* Qwerty
 | 
			
		||||
 * ,-----------------------------------------------------------------------------------.
 | 
			
		||||
 * | Tab  |   Q  |   W  |   E  |   R  |   T  |   Y  |   U  |   I  |   O  |   P  | Bksp |
 | 
			
		||||
 * |------+------+------+------+------+-------------+------+------+------+------+------|
 | 
			
		||||
 * | Esc  |   A  |   S  |   D  |   F  |   G  |   H  |   J  |   K  |   L  |   ;  |  "   |
 | 
			
		||||
 * |------+------+------+------+------+------|------+------+------+------+------+------|
 | 
			
		||||
 * | Shift|   Z  |   X  |   C  |   V  |   B  |   N  |   M  |   ,  |   .  |   /  |Enter |
 | 
			
		||||
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 | 
			
		||||
 * |Adjust| Ctrl | Alt  | GUI  |Lower |Space |Space |Raise | Left | Down |  Up  |Right |
 | 
			
		||||
 * `-----------------------------------------------------------------------------------'
 | 
			
		||||
 */
 | 
			
		||||
[_QWERTY] = KEYMAP( \
 | 
			
		||||
  KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC, \
 | 
			
		||||
  KC_ESC,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT, \
 | 
			
		||||
  KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT , \
 | 
			
		||||
  ADJUST,  KC_LCTL, KC_LALT, KC_LGUI, LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT \
 | 
			
		||||
),
 | 
			
		||||
 | 
			
		||||
/* Colemak
 | 
			
		||||
 * ,-----------------------------------------------------------------------------------.
 | 
			
		||||
 * | Tab  |   Q  |   W  |   F  |   P  |   G  |   J  |   L  |   U  |   Y  |   ;  | Bksp |
 | 
			
		||||
 * |------+------+------+------+------+-------------+------+------+------+------+------|
 | 
			
		||||
 * | Esc  |   A  |   R  |   S  |   T  |   D  |   H  |   N  |   E  |   I  |   O  |  "   |
 | 
			
		||||
 * |------+------+------+------+------+------|------+------+------+------+------+------|
 | 
			
		||||
 * | Shift|   Z  |   X  |   C  |   V  |   B  |   K  |   M  |   ,  |   .  |   /  |Enter |
 | 
			
		||||
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 | 
			
		||||
 * |Adjust| Ctrl | Alt  | GUI  |Lower |Space |Space |Raise | Left | Down |  Up  |Right |
 | 
			
		||||
 * `-----------------------------------------------------------------------------------'
 | 
			
		||||
 */
 | 
			
		||||
[_COLEMAK] = KEYMAP( \
 | 
			
		||||
  KC_TAB,  KC_Q,    KC_W,    KC_F,    KC_P,    KC_G,    KC_J,    KC_L,    KC_U,    KC_Y,    KC_SCLN, KC_BSPC, \
 | 
			
		||||
  KC_ESC,  KC_A,    KC_R,    KC_S,    KC_T,    KC_D,    KC_H,    KC_N,    KC_E,    KC_I,    KC_O,    KC_QUOT, \
 | 
			
		||||
  KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_K,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT , \
 | 
			
		||||
  ADJUST,  KC_LCTL, KC_LALT, KC_LGUI, LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT \
 | 
			
		||||
),
 | 
			
		||||
 | 
			
		||||
/* Dvorak
 | 
			
		||||
 * ,-----------------------------------------------------------------------------------.
 | 
			
		||||
 * | Tab  |   "  |   ,  |   .  |   P  |   Y  |   F  |   G  |   C  |   R  |   L  | Bksp |
 | 
			
		||||
 * |------+------+------+------+------+-------------+------+------+------+------+------|
 | 
			
		||||
 * | Esc  |   A  |   O  |   E  |   U  |   I  |   D  |   H  |   T  |   N  |   S  |  /   |
 | 
			
		||||
 * |------+------+------+------+------+------|------+------+------+------+------+------|
 | 
			
		||||
 * | Shift|   ;  |   Q  |   J  |   K  |   X  |   B  |   M  |   W  |   V  |   Z  |Enter |
 | 
			
		||||
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 | 
			
		||||
 * |Adjust| Ctrl | Alt  | GUI  |Lower |Space |Space |Raise | Left | Down |  Up  |Right |
 | 
			
		||||
 * `-----------------------------------------------------------------------------------'
 | 
			
		||||
 */
 | 
			
		||||
[_DVORAK] = KEYMAP( \
 | 
			
		||||
  KC_TAB,  KC_QUOT, KC_COMM, KC_DOT,  KC_P,    KC_Y,    KC_F,    KC_G,    KC_C,    KC_R,    KC_L,    KC_BSPC, \
 | 
			
		||||
  KC_ESC,  KC_A,    KC_O,    KC_E,    KC_U,    KC_I,    KC_D,    KC_H,    KC_T,    KC_N,    KC_S,    KC_SLSH, \
 | 
			
		||||
  KC_LSFT, KC_SCLN, KC_Q,    KC_J,    KC_K,    KC_X,    KC_B,    KC_M,    KC_W,    KC_V,    KC_Z,    KC_ENT , \
 | 
			
		||||
  ADJUST,  KC_LCTL, KC_LALT, KC_LGUI, LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT \
 | 
			
		||||
),
 | 
			
		||||
 | 
			
		||||
/* Lower
 | 
			
		||||
 * ,-----------------------------------------------------------------------------------.
 | 
			
		||||
 * |   ~  |   !  |   @  |   #  |   $  |   %  |   ^  |   &  |   *  |   (  |   )  | Bksp |
 | 
			
		||||
 * |------+------+------+------+------+-------------+------+------+------+------+------|
 | 
			
		||||
 * | Del  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |   _  |   +  |     |    \  |  |   |
 | 
			
		||||
 * |------+------+------+------+------+------|------+------+------+------+------+------|
 | 
			
		||||
 * |      |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |ISO ~ |ISO | |      |      |Enter |
 | 
			
		||||
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 | 
			
		||||
 * |      |      |      |      |      |             |      | Next | Vol- | Vol+ | Play |
 | 
			
		||||
 * `-----------------------------------------------------------------------------------'
 | 
			
		||||
 */
 | 
			
		||||
[_LOWER] = KEYMAP( \
 | 
			
		||||
  KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
 | 
			
		||||
  KC_DEL,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
 | 
			
		||||
  _______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
 | 
			
		||||
  _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
 | 
			
		||||
),
 | 
			
		||||
 | 
			
		||||
/* Raise
 | 
			
		||||
 * ,-----------------------------------------------------------------------------------.
 | 
			
		||||
 * |   `  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  | Bksp |
 | 
			
		||||
 * |------+------+------+------+------+-------------+------+------+------+------+------|
 | 
			
		||||
 * | Del  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |   -  |   =  |   [  |   ]  |  \   |
 | 
			
		||||
 * |------+------+------+------+------+------|------+------+------+------+------+------|
 | 
			
		||||
 * |      |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |ISO # |ISO / |      |      |Enter |
 | 
			
		||||
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 | 
			
		||||
 * |      |      |      |      |      |             |      | Next | Vol- | Vol+ | Play |
 | 
			
		||||
 * `-----------------------------------------------------------------------------------'
 | 
			
		||||
 */
 | 
			
		||||
[_RAISE] = KEYMAP( \
 | 
			
		||||
  KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC, \
 | 
			
		||||
  KC_DEL,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_BSLS, \
 | 
			
		||||
  _______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_NUHS, KC_NUBS, _______, _______, _______, \
 | 
			
		||||
  _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
 | 
			
		||||
),
 | 
			
		||||
 | 
			
		||||
/* Adjust (Lower + Raise)
 | 
			
		||||
 * ,-----------------------------------------------------------------------------------.
 | 
			
		||||
 * |      | Reset|      |      |      |      |      |      |      |      |      |  Del |
 | 
			
		||||
 * |------+------+------+------+------+-------------+------+------+------+------+------|
 | 
			
		||||
 * |      |      |      |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|      |      |
 | 
			
		||||
 * |------+------+------+------+------+------|------+------+------+------+------+------|
 | 
			
		||||
 * |      |      |      |      |      |      |      |      |      |      |      |      |
 | 
			
		||||
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 | 
			
		||||
 * |      |      |      |      |      |             |      |      |      |      |      |
 | 
			
		||||
 * `-----------------------------------------------------------------------------------'
 | 
			
		||||
 */
 | 
			
		||||
[_ADJUST] =  KEYMAP( \
 | 
			
		||||
  _______, RESET,   _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
 | 
			
		||||
  _______, _______, _______, AU_ON,   AU_OFF,  AG_NORM, AG_SWAP, QWERTY,  COLEMAK, DVORAK,  _______, _______, \
 | 
			
		||||
  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
 | 
			
		||||
  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#ifdef AUDIO_ENABLE
 | 
			
		||||
float tone_qwerty[][2]     = SONG(QWERTY_SOUND);
 | 
			
		||||
float tone_dvorak[][2]     = SONG(DVORAK_SOUND);
 | 
			
		||||
float tone_colemak[][2]    = SONG(COLEMAK_SOUND);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void persistant_default_layer_set(uint16_t default_layer) {
 | 
			
		||||
  eeconfig_update_default_layer(default_layer);
 | 
			
		||||
  default_layer_set(default_layer);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
  switch (keycode) {
 | 
			
		||||
    case QWERTY:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        #ifdef AUDIO_ENABLE
 | 
			
		||||
          PLAY_NOTE_ARRAY(tone_qwerty, false, 0);
 | 
			
		||||
        #endif
 | 
			
		||||
        persistant_default_layer_set(1UL<<_QWERTY);
 | 
			
		||||
      }
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case COLEMAK:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        #ifdef AUDIO_ENABLE
 | 
			
		||||
          PLAY_NOTE_ARRAY(tone_colemak, false, 0);
 | 
			
		||||
        #endif
 | 
			
		||||
        persistant_default_layer_set(1UL<<_COLEMAK);
 | 
			
		||||
      }
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case DVORAK:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        #ifdef AUDIO_ENABLE
 | 
			
		||||
          PLAY_NOTE_ARRAY(tone_dvorak, false, 0);
 | 
			
		||||
        #endif
 | 
			
		||||
        persistant_default_layer_set(1UL<<_DVORAK);
 | 
			
		||||
      }
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case LOWER:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        layer_on(_LOWER);
 | 
			
		||||
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
 | 
			
		||||
      } else {
 | 
			
		||||
        layer_off(_LOWER);
 | 
			
		||||
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
 | 
			
		||||
      }
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case RAISE:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        layer_on(_RAISE);
 | 
			
		||||
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
 | 
			
		||||
      } else {
 | 
			
		||||
        layer_off(_RAISE);
 | 
			
		||||
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
 | 
			
		||||
      }
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case ADJUST:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        layer_on(_ADJUST);
 | 
			
		||||
      } else {
 | 
			
		||||
        layer_off(_ADJUST);
 | 
			
		||||
      }
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										30
									
								
								keyboards/lets_split/lets_split.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								keyboards/lets_split/lets_split.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,30 @@
 | 
			
		||||
#include "lets_split.h"
 | 
			
		||||
 | 
			
		||||
#ifdef AUDIO_ENABLE
 | 
			
		||||
    float tone_startup[][2] = SONG(STARTUP_SOUND);
 | 
			
		||||
    float tone_goodbye[][2] = SONG(GOODBYE_SOUND);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void matrix_init_kb(void) {
 | 
			
		||||
 | 
			
		||||
    #ifdef AUDIO_ENABLE
 | 
			
		||||
        _delay_ms(20); // gets rid of tick
 | 
			
		||||
        PLAY_NOTE_ARRAY(tone_startup, false, 0);
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
    // // green led on
 | 
			
		||||
    // DDRD |= (1<<5);
 | 
			
		||||
    // PORTD &= ~(1<<5);
 | 
			
		||||
 | 
			
		||||
    // // orange led on
 | 
			
		||||
    // DDRB |= (1<<0);
 | 
			
		||||
    // PORTB &= ~(1<<0);
 | 
			
		||||
 | 
			
		||||
	matrix_init_user();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void shutdown_user(void) {
 | 
			
		||||
    PLAY_NOTE_ARRAY(tone_goodbye, false, 0);
 | 
			
		||||
    _delay_ms(150);
 | 
			
		||||
    stop_all_notes();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										25
									
								
								keyboards/lets_split/lets_split.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								keyboards/lets_split/lets_split.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
			
		||||
#ifndef LETS_SPLIT_H
 | 
			
		||||
#define LETS_SPLIT_H
 | 
			
		||||
 | 
			
		||||
#include "quantum.h"
 | 
			
		||||
 | 
			
		||||
void promicro_bootloader_jmp(bool program);
 | 
			
		||||
 | 
			
		||||
#define KEYMAP( \
 | 
			
		||||
	k00, k01, k02, k03, k04, k05, k40, k41, k42, k43, k44, k45, \
 | 
			
		||||
	k10, k11, k12, k13, k14, k15, k50, k51, k52, k53, k54, k55, \
 | 
			
		||||
	k20, k21, k22, k23, k24, k25, k60, k61, k62, k63, k64, k65, \
 | 
			
		||||
	k30, k31, k32, k33, k34, k35, k70, k71, k72, k73, k74, k75 \
 | 
			
		||||
	) \
 | 
			
		||||
	{ \
 | 
			
		||||
		{ k00, k01, k02, k03, k04, k05 }, \
 | 
			
		||||
		{ k10, k11, k12, k13, k14, k15 }, \
 | 
			
		||||
		{ k20, k21, k22, k23, k24, k25 }, \
 | 
			
		||||
		{ k30, k31, k32, k33, k34, k35 }, \
 | 
			
		||||
		{ k40, k41, k42, k43, k44, k45 }, \
 | 
			
		||||
		{ k50, k51, k52, k53, k54, k55 }, \
 | 
			
		||||
		{ k60, k61, k62, k63, k64, k65 }, \
 | 
			
		||||
		{ k70, k71, k72, k73, k74, k75 } \
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										311
									
								
								keyboards/lets_split/matrix.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										311
									
								
								keyboards/lets_split/matrix.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,311 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2012 Jun Wako <wakojun@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * scan matrix
 | 
			
		||||
 */
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
#include <avr/wdt.h>
 | 
			
		||||
#include <avr/interrupt.h>
 | 
			
		||||
#include <util/delay.h>
 | 
			
		||||
#include "print.h"
 | 
			
		||||
#include "debug.h"
 | 
			
		||||
#include "util.h"
 | 
			
		||||
#include "matrix.h"
 | 
			
		||||
#include "i2c.h"
 | 
			
		||||
#include "serial.h"
 | 
			
		||||
#include "split_util.h"
 | 
			
		||||
#include "pro_micro.h"
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
#ifndef DEBOUNCE
 | 
			
		||||
#   define DEBOUNCE	5
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define ERROR_DISCONNECT_COUNT 5
 | 
			
		||||
 | 
			
		||||
static uint8_t debouncing = DEBOUNCE;
 | 
			
		||||
static const int ROWS_PER_HAND = MATRIX_ROWS/2;
 | 
			
		||||
static uint8_t error_count = 0;
 | 
			
		||||
 | 
			
		||||
static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
 | 
			
		||||
static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
 | 
			
		||||
 | 
			
		||||
/* matrix state(1:on, 0:off) */
 | 
			
		||||
static matrix_row_t matrix[MATRIX_ROWS];
 | 
			
		||||
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
 | 
			
		||||
 | 
			
		||||
static matrix_row_t read_cols(void);
 | 
			
		||||
static void init_cols(void);
 | 
			
		||||
static void unselect_rows(void);
 | 
			
		||||
static void select_row(uint8_t row);
 | 
			
		||||
 | 
			
		||||
__attribute__ ((weak))
 | 
			
		||||
void matrix_init_quantum(void) {
 | 
			
		||||
    matrix_init_kb();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__ ((weak))
 | 
			
		||||
void matrix_scan_quantum(void) {
 | 
			
		||||
    matrix_scan_kb();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__ ((weak))
 | 
			
		||||
void matrix_init_kb(void) {
 | 
			
		||||
    matrix_init_user();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__ ((weak))
 | 
			
		||||
void matrix_scan_kb(void) {
 | 
			
		||||
    matrix_scan_user();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__ ((weak))
 | 
			
		||||
void matrix_init_user(void) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
__attribute__ ((weak))
 | 
			
		||||
void matrix_scan_user(void) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline
 | 
			
		||||
uint8_t matrix_rows(void)
 | 
			
		||||
{
 | 
			
		||||
    return MATRIX_ROWS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline
 | 
			
		||||
uint8_t matrix_cols(void)
 | 
			
		||||
{
 | 
			
		||||
    return MATRIX_COLS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void matrix_init(void)
 | 
			
		||||
{
 | 
			
		||||
    debug_enable = true;
 | 
			
		||||
    debug_matrix = true;
 | 
			
		||||
    debug_mouse = true;
 | 
			
		||||
    // initialize row and col
 | 
			
		||||
    unselect_rows();
 | 
			
		||||
    init_cols();
 | 
			
		||||
 | 
			
		||||
    TX_RX_LED_INIT;
 | 
			
		||||
 | 
			
		||||
    // initialize matrix state: all keys off
 | 
			
		||||
    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
 | 
			
		||||
        matrix[i] = 0;
 | 
			
		||||
        matrix_debouncing[i] = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    matrix_init_quantum();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t _matrix_scan(void)
 | 
			
		||||
{
 | 
			
		||||
    // Right hand is stored after the left in the matirx so, we need to offset it
 | 
			
		||||
    int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
 | 
			
		||||
 | 
			
		||||
    for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
 | 
			
		||||
        select_row(i);
 | 
			
		||||
        _delay_us(30);  // without this wait read unstable value.
 | 
			
		||||
        matrix_row_t cols = read_cols();
 | 
			
		||||
        if (matrix_debouncing[i+offset] != cols) {
 | 
			
		||||
            matrix_debouncing[i+offset] = cols;
 | 
			
		||||
            debouncing = DEBOUNCE;
 | 
			
		||||
        }
 | 
			
		||||
        unselect_rows();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (debouncing) {
 | 
			
		||||
        if (--debouncing) {
 | 
			
		||||
            _delay_ms(1);
 | 
			
		||||
        } else {
 | 
			
		||||
            for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
 | 
			
		||||
                matrix[i+offset] = matrix_debouncing[i+offset];
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Get rows from other half over i2c
 | 
			
		||||
int i2c_transaction(void) {
 | 
			
		||||
    int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
 | 
			
		||||
 | 
			
		||||
    int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
 | 
			
		||||
    if (err) goto i2c_error;
 | 
			
		||||
 | 
			
		||||
    // start of matrix stored at 0x00
 | 
			
		||||
    err = i2c_master_write(0x00);
 | 
			
		||||
    if (err) goto i2c_error;
 | 
			
		||||
 | 
			
		||||
    // Start read
 | 
			
		||||
    err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
 | 
			
		||||
    if (err) goto i2c_error;
 | 
			
		||||
 | 
			
		||||
    if (!err) {
 | 
			
		||||
        int i;
 | 
			
		||||
        for (i = 0; i < ROWS_PER_HAND-1; ++i) {
 | 
			
		||||
            matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
 | 
			
		||||
        }
 | 
			
		||||
        matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
 | 
			
		||||
        i2c_master_stop();
 | 
			
		||||
    } else {
 | 
			
		||||
i2c_error: // the cable is disconnceted, or something else went wrong
 | 
			
		||||
        i2c_reset_state();
 | 
			
		||||
        return err;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef USE_I2C
 | 
			
		||||
int serial_transaction(void) {
 | 
			
		||||
    int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
 | 
			
		||||
 | 
			
		||||
    if (serial_update_buffers()) {
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < ROWS_PER_HAND; ++i) {
 | 
			
		||||
        matrix[slaveOffset+i] = serial_slave_buffer[i];
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
uint8_t matrix_scan(void)
 | 
			
		||||
{
 | 
			
		||||
    int ret = _matrix_scan();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef USE_I2C
 | 
			
		||||
    if( i2c_transaction() ) {
 | 
			
		||||
#else
 | 
			
		||||
    if( serial_transaction() ) {
 | 
			
		||||
#endif
 | 
			
		||||
        // turn on the indicator led when halves are disconnected
 | 
			
		||||
        TXLED1;
 | 
			
		||||
 | 
			
		||||
        error_count++;
 | 
			
		||||
 | 
			
		||||
        if (error_count > ERROR_DISCONNECT_COUNT) {
 | 
			
		||||
            // reset other half if disconnected
 | 
			
		||||
            int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
 | 
			
		||||
            for (int i = 0; i < ROWS_PER_HAND; ++i) {
 | 
			
		||||
                matrix[slaveOffset+i] = 0;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        // turn off the indicator led on no error
 | 
			
		||||
        TXLED0;
 | 
			
		||||
        error_count = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    matrix_scan_quantum();
 | 
			
		||||
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void matrix_slave_scan(void) {
 | 
			
		||||
    _matrix_scan();
 | 
			
		||||
 | 
			
		||||
    int offset = (isLeftHand) ? 0 : (MATRIX_ROWS / 2);
 | 
			
		||||
 | 
			
		||||
#ifdef USE_I2C
 | 
			
		||||
    for (int i = 0; i < ROWS_PER_HAND; ++i) {
 | 
			
		||||
        /* i2c_slave_buffer[i] = matrix[offset+i]; */
 | 
			
		||||
        i2c_slave_buffer[i] = matrix[offset+i];
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    for (int i = 0; i < ROWS_PER_HAND; ++i) {
 | 
			
		||||
        serial_slave_buffer[i] = matrix[offset+i];
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool matrix_is_modified(void)
 | 
			
		||||
{
 | 
			
		||||
    if (debouncing) return false;
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline
 | 
			
		||||
bool matrix_is_on(uint8_t row, uint8_t col)
 | 
			
		||||
{
 | 
			
		||||
    return (matrix[row] & ((matrix_row_t)1<<col));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline
 | 
			
		||||
matrix_row_t matrix_get_row(uint8_t row)
 | 
			
		||||
{
 | 
			
		||||
    return matrix[row];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void matrix_print(void)
 | 
			
		||||
{
 | 
			
		||||
    print("\nr/c 0123456789ABCDEF\n");
 | 
			
		||||
    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
 | 
			
		||||
        phex(row); print(": ");
 | 
			
		||||
        pbin_reverse16(matrix_get_row(row));
 | 
			
		||||
        print("\n");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t matrix_key_count(void)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t count = 0;
 | 
			
		||||
    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
 | 
			
		||||
        count += bitpop16(matrix[i]);
 | 
			
		||||
    }
 | 
			
		||||
    return count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void  init_cols(void)
 | 
			
		||||
{
 | 
			
		||||
    for(int x = 0; x < MATRIX_COLS; x++) {
 | 
			
		||||
        _SFR_IO8((col_pins[x] >> 4) + 1) &=  ~_BV(col_pins[x] & 0xF);
 | 
			
		||||
        _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static matrix_row_t read_cols(void)
 | 
			
		||||
{
 | 
			
		||||
    matrix_row_t result = 0;
 | 
			
		||||
    for(int x = 0; x < MATRIX_COLS; x++) {     
 | 
			
		||||
        result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
 | 
			
		||||
    }
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void unselect_rows(void)
 | 
			
		||||
{
 | 
			
		||||
    for(int x = 0; x < ROWS_PER_HAND; x++) { 
 | 
			
		||||
        _SFR_IO8((row_pins[x] >> 4) + 1) &=  ~_BV(row_pins[x] & 0xF);
 | 
			
		||||
        _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void select_row(uint8_t row)
 | 
			
		||||
{
 | 
			
		||||
    _SFR_IO8((row_pins[row] >> 4) + 1) |=  _BV(row_pins[row] & 0xF);
 | 
			
		||||
    _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										362
									
								
								keyboards/lets_split/pro_micro.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										362
									
								
								keyboards/lets_split/pro_micro.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,362 @@
 | 
			
		||||
/*
 | 
			
		||||
  pins_arduino.h - Pin definition functions for Arduino
 | 
			
		||||
  Part of Arduino - http://www.arduino.cc/
 | 
			
		||||
 | 
			
		||||
  Copyright (c) 2007 David A. Mellis
 | 
			
		||||
 | 
			
		||||
  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 2.1 of the License, or (at your option) any later version.
 | 
			
		||||
 | 
			
		||||
  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.
 | 
			
		||||
 | 
			
		||||
  You should have received a copy of the GNU Lesser General
 | 
			
		||||
  Public License along with this library; if not, write to the
 | 
			
		||||
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 | 
			
		||||
  Boston, MA  02111-1307  USA
 | 
			
		||||
 | 
			
		||||
  $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef Pins_Arduino_h
 | 
			
		||||
#define Pins_Arduino_h
 | 
			
		||||
 | 
			
		||||
#include <avr/pgmspace.h>
 | 
			
		||||
 | 
			
		||||
// Workaround for wrong definitions in "iom32u4.h".
 | 
			
		||||
// This should be fixed in the AVR toolchain.
 | 
			
		||||
#undef UHCON
 | 
			
		||||
#undef UHINT
 | 
			
		||||
#undef UHIEN
 | 
			
		||||
#undef UHADDR
 | 
			
		||||
#undef UHFNUM
 | 
			
		||||
#undef UHFNUML
 | 
			
		||||
#undef UHFNUMH
 | 
			
		||||
#undef UHFLEN
 | 
			
		||||
#undef UPINRQX
 | 
			
		||||
#undef UPINTX
 | 
			
		||||
#undef UPNUM
 | 
			
		||||
#undef UPRST
 | 
			
		||||
#undef UPCONX
 | 
			
		||||
#undef UPCFG0X
 | 
			
		||||
#undef UPCFG1X
 | 
			
		||||
#undef UPSTAX
 | 
			
		||||
#undef UPCFG2X
 | 
			
		||||
#undef UPIENX
 | 
			
		||||
#undef UPDATX
 | 
			
		||||
#undef TCCR2A
 | 
			
		||||
#undef WGM20
 | 
			
		||||
#undef WGM21
 | 
			
		||||
#undef COM2B0
 | 
			
		||||
#undef COM2B1
 | 
			
		||||
#undef COM2A0
 | 
			
		||||
#undef COM2A1
 | 
			
		||||
#undef TCCR2B
 | 
			
		||||
#undef CS20
 | 
			
		||||
#undef CS21
 | 
			
		||||
#undef CS22
 | 
			
		||||
#undef WGM22
 | 
			
		||||
#undef FOC2B
 | 
			
		||||
#undef FOC2A
 | 
			
		||||
#undef TCNT2
 | 
			
		||||
#undef TCNT2_0
 | 
			
		||||
#undef TCNT2_1
 | 
			
		||||
#undef TCNT2_2
 | 
			
		||||
#undef TCNT2_3
 | 
			
		||||
#undef TCNT2_4
 | 
			
		||||
#undef TCNT2_5
 | 
			
		||||
#undef TCNT2_6
 | 
			
		||||
#undef TCNT2_7
 | 
			
		||||
#undef OCR2A
 | 
			
		||||
#undef OCR2_0
 | 
			
		||||
#undef OCR2_1
 | 
			
		||||
#undef OCR2_2
 | 
			
		||||
#undef OCR2_3
 | 
			
		||||
#undef OCR2_4
 | 
			
		||||
#undef OCR2_5
 | 
			
		||||
#undef OCR2_6
 | 
			
		||||
#undef OCR2_7
 | 
			
		||||
#undef OCR2B
 | 
			
		||||
#undef OCR2_0
 | 
			
		||||
#undef OCR2_1
 | 
			
		||||
#undef OCR2_2
 | 
			
		||||
#undef OCR2_3
 | 
			
		||||
#undef OCR2_4
 | 
			
		||||
#undef OCR2_5
 | 
			
		||||
#undef OCR2_6
 | 
			
		||||
#undef OCR2_7
 | 
			
		||||
 | 
			
		||||
#define NUM_DIGITAL_PINS  30
 | 
			
		||||
#define NUM_ANALOG_INPUTS 12
 | 
			
		||||
 | 
			
		||||
#define TX_RX_LED_INIT  DDRD |= (1<<5), DDRB |= (1<<0)
 | 
			
		||||
#define TXLED0          PORTD |= (1<<5)
 | 
			
		||||
#define TXLED1          PORTD &= ~(1<<5)
 | 
			
		||||
#define RXLED0          PORTB |= (1<<0)
 | 
			
		||||
#define RXLED1          PORTB &= ~(1<<0)
 | 
			
		||||
 | 
			
		||||
static const uint8_t SDA = 2;
 | 
			
		||||
static const uint8_t SCL = 3;
 | 
			
		||||
#define LED_BUILTIN 13
 | 
			
		||||
 | 
			
		||||
// Map SPI port to 'new' pins D14..D17
 | 
			
		||||
static const uint8_t SS   = 17;
 | 
			
		||||
static const uint8_t MOSI = 16;
 | 
			
		||||
static const uint8_t MISO = 14;
 | 
			
		||||
static const uint8_t SCK  = 15;
 | 
			
		||||
 | 
			
		||||
// Mapping of analog pins as digital I/O
 | 
			
		||||
// A6-A11 share with digital pins
 | 
			
		||||
static const uint8_t A0 = 18;
 | 
			
		||||
static const uint8_t A1 = 19;
 | 
			
		||||
static const uint8_t A2 = 20;
 | 
			
		||||
static const uint8_t A3 = 21;
 | 
			
		||||
static const uint8_t A4 = 22;
 | 
			
		||||
static const uint8_t A5 = 23;
 | 
			
		||||
static const uint8_t A6 = 24;   // D4
 | 
			
		||||
static const uint8_t A7 = 25;   // D6
 | 
			
		||||
static const uint8_t A8 = 26;   // D8
 | 
			
		||||
static const uint8_t A9 = 27;   // D9
 | 
			
		||||
static const uint8_t A10 = 28;  // D10
 | 
			
		||||
static const uint8_t A11 = 29;  // D12
 | 
			
		||||
 | 
			
		||||
#define digitalPinToPCICR(p)    ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
 | 
			
		||||
#define digitalPinToPCICRbit(p) 0
 | 
			
		||||
#define digitalPinToPCMSK(p)    ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
 | 
			
		||||
#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
 | 
			
		||||
 | 
			
		||||
//  __AVR_ATmega32U4__ has an unusual mapping of pins to channels
 | 
			
		||||
extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
 | 
			
		||||
#define analogPinToChannel(P)  ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
 | 
			
		||||
 | 
			
		||||
#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
 | 
			
		||||
 | 
			
		||||
#ifdef ARDUINO_MAIN
 | 
			
		||||
 | 
			
		||||
// On the Arduino board, digital pins are also used
 | 
			
		||||
// for the analog output (software PWM).  Analog input
 | 
			
		||||
// pins are a separate set.
 | 
			
		||||
 | 
			
		||||
// ATMEL ATMEGA32U4 / ARDUINO LEONARDO
 | 
			
		||||
//
 | 
			
		||||
// D0               PD2                 RXD1/INT2
 | 
			
		||||
// D1               PD3                 TXD1/INT3
 | 
			
		||||
// D2               PD1     SDA         SDA/INT1
 | 
			
		||||
// D3#              PD0     PWM8/SCL    OC0B/SCL/INT0
 | 
			
		||||
// D4       A6      PD4                 ADC8
 | 
			
		||||
// D5#              PC6     ???         OC3A/#OC4A
 | 
			
		||||
// D6#      A7      PD7     FastPWM     #OC4D/ADC10
 | 
			
		||||
// D7               PE6                 INT6/AIN0
 | 
			
		||||
//
 | 
			
		||||
// D8       A8      PB4                 ADC11/PCINT4
 | 
			
		||||
// D9#      A9      PB5     PWM16       OC1A/#OC4B/ADC12/PCINT5
 | 
			
		||||
// D10#     A10     PB6     PWM16       OC1B/0c4B/ADC13/PCINT6
 | 
			
		||||
// D11#             PB7     PWM8/16     0C0A/OC1C/#RTS/PCINT7
 | 
			
		||||
// D12      A11     PD6                 T1/#OC4D/ADC9
 | 
			
		||||
// D13#             PC7     PWM10       CLK0/OC4A
 | 
			
		||||
//
 | 
			
		||||
// A0       D18     PF7                 ADC7
 | 
			
		||||
// A1       D19     PF6                 ADC6
 | 
			
		||||
// A2       D20     PF5                 ADC5
 | 
			
		||||
// A3       D21     PF4                 ADC4
 | 
			
		||||
// A4       D22     PF1                 ADC1
 | 
			
		||||
// A5       D23     PF0                 ADC0
 | 
			
		||||
//
 | 
			
		||||
// New pins D14..D17 to map SPI port to digital pins
 | 
			
		||||
//
 | 
			
		||||
// MISO     D14     PB3                 MISO,PCINT3
 | 
			
		||||
// SCK      D15     PB1                 SCK,PCINT1
 | 
			
		||||
// MOSI     D16     PB2                 MOSI,PCINT2
 | 
			
		||||
// SS       D17     PB0                 RXLED,SS/PCINT0
 | 
			
		||||
//
 | 
			
		||||
// Connected LEDs on board for TX and RX
 | 
			
		||||
// TXLED    D24     PD5                 XCK1
 | 
			
		||||
// RXLED    D17     PB0
 | 
			
		||||
// HWB              PE2                 HWB
 | 
			
		||||
 | 
			
		||||
// these arrays map port names (e.g. port B) to the
 | 
			
		||||
// appropriate addresses for various functions (e.g. reading
 | 
			
		||||
// and writing)
 | 
			
		||||
const uint16_t PROGMEM port_to_mode_PGM[] = {
 | 
			
		||||
    NOT_A_PORT,
 | 
			
		||||
    NOT_A_PORT,
 | 
			
		||||
    (uint16_t) &DDRB,
 | 
			
		||||
    (uint16_t) &DDRC,
 | 
			
		||||
    (uint16_t) &DDRD,
 | 
			
		||||
    (uint16_t) &DDRE,
 | 
			
		||||
    (uint16_t) &DDRF,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM port_to_output_PGM[] = {
 | 
			
		||||
    NOT_A_PORT,
 | 
			
		||||
    NOT_A_PORT,
 | 
			
		||||
    (uint16_t) &PORTB,
 | 
			
		||||
    (uint16_t) &PORTC,
 | 
			
		||||
    (uint16_t) &PORTD,
 | 
			
		||||
    (uint16_t) &PORTE,
 | 
			
		||||
    (uint16_t) &PORTF,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint16_t PROGMEM port_to_input_PGM[] = {
 | 
			
		||||
    NOT_A_PORT,
 | 
			
		||||
    NOT_A_PORT,
 | 
			
		||||
    (uint16_t) &PINB,
 | 
			
		||||
    (uint16_t) &PINC,
 | 
			
		||||
    (uint16_t) &PIND,
 | 
			
		||||
    (uint16_t) &PINE,
 | 
			
		||||
    (uint16_t) &PINF,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
 | 
			
		||||
    PD, // D0 - PD2
 | 
			
		||||
    PD, // D1 - PD3
 | 
			
		||||
    PD, // D2 - PD1
 | 
			
		||||
    PD, // D3 - PD0
 | 
			
		||||
    PD, // D4 - PD4
 | 
			
		||||
    PC, // D5 - PC6
 | 
			
		||||
    PD, // D6 - PD7
 | 
			
		||||
    PE, // D7 - PE6
 | 
			
		||||
    
 | 
			
		||||
    PB, // D8 - PB4
 | 
			
		||||
    PB, // D9 - PB5
 | 
			
		||||
    PB, // D10 - PB6
 | 
			
		||||
    PB, // D11 - PB7
 | 
			
		||||
    PD, // D12 - PD6
 | 
			
		||||
    PC, // D13 - PC7
 | 
			
		||||
    
 | 
			
		||||
    PB, // D14 - MISO - PB3
 | 
			
		||||
    PB, // D15 - SCK - PB1
 | 
			
		||||
    PB, // D16 - MOSI - PB2
 | 
			
		||||
    PB, // D17 - SS - PB0
 | 
			
		||||
    
 | 
			
		||||
    PF, // D18 - A0 - PF7
 | 
			
		||||
    PF, // D19 - A1 - PF6
 | 
			
		||||
    PF, // D20 - A2 - PF5
 | 
			
		||||
    PF, // D21 - A3 - PF4
 | 
			
		||||
    PF, // D22 - A4 - PF1
 | 
			
		||||
    PF, // D23 - A5 - PF0
 | 
			
		||||
    
 | 
			
		||||
    PD, // D24 - PD5
 | 
			
		||||
    PD, // D25 / D6 - A7 - PD7
 | 
			
		||||
    PB, // D26 / D8 - A8 - PB4
 | 
			
		||||
    PB, // D27 / D9 - A9 - PB5
 | 
			
		||||
    PB, // D28 / D10 - A10 - PB6
 | 
			
		||||
    PD, // D29 / D12 - A11 - PD6
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
 | 
			
		||||
    _BV(2), // D0 - PD2
 | 
			
		||||
    _BV(3), // D1 - PD3
 | 
			
		||||
    _BV(1), // D2 - PD1
 | 
			
		||||
    _BV(0), // D3 - PD0
 | 
			
		||||
    _BV(4), // D4 - PD4
 | 
			
		||||
    _BV(6), // D5 - PC6
 | 
			
		||||
    _BV(7), // D6 - PD7
 | 
			
		||||
    _BV(6), // D7 - PE6
 | 
			
		||||
    
 | 
			
		||||
    _BV(4), // D8 - PB4
 | 
			
		||||
    _BV(5), // D9 - PB5
 | 
			
		||||
    _BV(6), // D10 - PB6
 | 
			
		||||
    _BV(7), // D11 - PB7
 | 
			
		||||
    _BV(6), // D12 - PD6
 | 
			
		||||
    _BV(7), // D13 - PC7
 | 
			
		||||
    
 | 
			
		||||
    _BV(3), // D14 - MISO - PB3
 | 
			
		||||
    _BV(1), // D15 - SCK - PB1
 | 
			
		||||
    _BV(2), // D16 - MOSI - PB2
 | 
			
		||||
    _BV(0), // D17 - SS - PB0
 | 
			
		||||
    
 | 
			
		||||
    _BV(7), // D18 - A0 - PF7
 | 
			
		||||
    _BV(6), // D19 - A1 - PF6
 | 
			
		||||
    _BV(5), // D20 - A2 - PF5
 | 
			
		||||
    _BV(4), // D21 - A3 - PF4
 | 
			
		||||
    _BV(1), // D22 - A4 - PF1
 | 
			
		||||
    _BV(0), // D23 - A5 - PF0
 | 
			
		||||
    
 | 
			
		||||
    _BV(5), // D24 - PD5
 | 
			
		||||
    _BV(7), // D25 / D6 - A7 - PD7
 | 
			
		||||
    _BV(4), // D26 / D8 - A8 - PB4
 | 
			
		||||
    _BV(5), // D27 / D9 - A9 - PB5
 | 
			
		||||
    _BV(6), // D28 / D10 - A10 - PB6
 | 
			
		||||
    _BV(6), // D29 / D12 - A11 - PD6
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
 | 
			
		||||
    NOT_ON_TIMER,   
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    TIMER0B,        /* 3 */
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    TIMER3A,        /* 5 */
 | 
			
		||||
    TIMER4D,        /* 6 */
 | 
			
		||||
    NOT_ON_TIMER,   
 | 
			
		||||
    
 | 
			
		||||
    NOT_ON_TIMER,   
 | 
			
		||||
    TIMER1A,        /* 9 */
 | 
			
		||||
    TIMER1B,        /* 10 */
 | 
			
		||||
    TIMER0A,        /* 11 */
 | 
			
		||||
    
 | 
			
		||||
    NOT_ON_TIMER,   
 | 
			
		||||
    TIMER4A,        /* 13 */
 | 
			
		||||
    
 | 
			
		||||
    NOT_ON_TIMER,   
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
    NOT_ON_TIMER,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
 | 
			
		||||
    7,  // A0               PF7                 ADC7
 | 
			
		||||
    6,  // A1               PF6                 ADC6    
 | 
			
		||||
    5,  // A2               PF5                 ADC5    
 | 
			
		||||
    4,  // A3               PF4                 ADC4
 | 
			
		||||
    1,  // A4               PF1                 ADC1    
 | 
			
		||||
    0,  // A5               PF0                 ADC0    
 | 
			
		||||
    8,  // A6       D4      PD4                 ADC8
 | 
			
		||||
    10, // A7       D6      PD7                 ADC10
 | 
			
		||||
    11, // A8       D8      PB4                 ADC11
 | 
			
		||||
    12, // A9       D9      PB5                 ADC12
 | 
			
		||||
    13, // A10      D10     PB6                 ADC13
 | 
			
		||||
    9   // A11      D12     PD6                 ADC9
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif /* ARDUINO_MAIN */
 | 
			
		||||
 | 
			
		||||
// These serial port names are intended to allow libraries and architecture-neutral
 | 
			
		||||
// sketches to automatically default to the correct port name for a particular type
 | 
			
		||||
// of use.  For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
 | 
			
		||||
// the first hardware serial port whose RX/TX pins are not dedicated to another use.
 | 
			
		||||
//
 | 
			
		||||
// SERIAL_PORT_MONITOR        Port which normally prints to the Arduino Serial Monitor
 | 
			
		||||
//
 | 
			
		||||
// SERIAL_PORT_USBVIRTUAL     Port which is USB virtual serial
 | 
			
		||||
//
 | 
			
		||||
// SERIAL_PORT_LINUXBRIDGE    Port which connects to a Linux system via Bridge library
 | 
			
		||||
//
 | 
			
		||||
// SERIAL_PORT_HARDWARE       Hardware serial port, physical RX & TX pins.
 | 
			
		||||
//
 | 
			
		||||
// SERIAL_PORT_HARDWARE_OPEN  Hardware serial ports which are open for use.  Their RX & TX
 | 
			
		||||
//                            pins are NOT connected to anything by default.
 | 
			
		||||
#define SERIAL_PORT_MONITOR        Serial
 | 
			
		||||
#define SERIAL_PORT_USBVIRTUAL     Serial
 | 
			
		||||
#define SERIAL_PORT_HARDWARE       Serial1
 | 
			
		||||
#define SERIAL_PORT_HARDWARE_OPEN  Serial1
 | 
			
		||||
 | 
			
		||||
#endif /* Pins_Arduino_h */
 | 
			
		||||
							
								
								
									
										102
									
								
								keyboards/lets_split/readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								keyboards/lets_split/readme.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,102 @@
 | 
			
		||||
Let's Split
 | 
			
		||||
======
 | 
			
		||||
 | 
			
		||||
This readme and most of the code are from https://github.com/ahtn/tmk_keyboard/
 | 
			
		||||
 | 
			
		||||
Split keyboard firmware for Arduino Pro Micro or other ATmega32u4
 | 
			
		||||
based boards.
 | 
			
		||||
 | 
			
		||||
Features
 | 
			
		||||
--------
 | 
			
		||||
 | 
			
		||||
Some features supported by the firmware:
 | 
			
		||||
 | 
			
		||||
* Either half can connect to the computer via USB, or both halves can be used
 | 
			
		||||
  independently.
 | 
			
		||||
* You only need 3 wires to connect the two halves. Two for VCC and GND and one
 | 
			
		||||
  for serial communication.
 | 
			
		||||
* Optional support for I2C connection between the two halves if for some
 | 
			
		||||
  reason you require a faster connection between the two halves. Note this
 | 
			
		||||
  requires an extra wire between halves and pull-up resistors on the data lines.
 | 
			
		||||
 | 
			
		||||
Required Hardware
 | 
			
		||||
-----------------
 | 
			
		||||
 | 
			
		||||
Apart from diodes and key switches for the keyboard matrix in each half, you
 | 
			
		||||
will need:
 | 
			
		||||
 | 
			
		||||
* 2 Arduino Pro Micro's. You can find theses on aliexpress for ≈3.50USD each.
 | 
			
		||||
* 2 TRS sockets
 | 
			
		||||
* 1 TRS cable.
 | 
			
		||||
 | 
			
		||||
Alternatively, you can use any sort of cable and socket that has at least 3
 | 
			
		||||
wires. If you want to use I2C to communicate between halves, you will need a
 | 
			
		||||
cable with at least 4 wires and 2x 4.7kΩ pull-up resistors
 | 
			
		||||
 | 
			
		||||
Optional Hardware
 | 
			
		||||
-----------------
 | 
			
		||||
 | 
			
		||||
A speaker can be hooked-up to either side to the `5` (`C6`) pin and `GND`, and turned on via `AUDIO_ENABLE`.
 | 
			
		||||
 | 
			
		||||
Wiring
 | 
			
		||||
------
 | 
			
		||||
 | 
			
		||||
The 3 wires of the TRS cable need to connect GND, VCC, and digital pin 3 (i.e.
 | 
			
		||||
PD0 on the ATmega32u4) between the two Pro Micros.
 | 
			
		||||
 | 
			
		||||
Then wire your key matrix to any of the remaining 17 IO pins of the pro micro
 | 
			
		||||
and modify the `matrix.c` accordingly.
 | 
			
		||||
 | 
			
		||||
The wiring for serial:
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
The wiring for i2c:
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
The pull-up resistors may be placed on either half. It is also possible
 | 
			
		||||
to use 4 resistors and have the pull-ups in both halves, but this is
 | 
			
		||||
unnecessary in simple use cases.
 | 
			
		||||
 | 
			
		||||
Notes on Software Configuration
 | 
			
		||||
-------------------------------
 | 
			
		||||
 | 
			
		||||
Configuring the firmware is similar to any other TMK project. One thing
 | 
			
		||||
to note is that `MATIX_ROWS` in `config.h` is the total number of rows between
 | 
			
		||||
the two halves, i.e. if your split keyboard has 4 rows in each half, then
 | 
			
		||||
`MATRIX_ROWS=8`.
 | 
			
		||||
 | 
			
		||||
Also the current implementation assumes a maximum of 8 columns, but it would
 | 
			
		||||
not be very difficult to adapt it to support more if required.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Flashing
 | 
			
		||||
--------
 | 
			
		||||
 | 
			
		||||
If you define `EE_HANDS` in your `config.h`, you will need to set the
 | 
			
		||||
EEPROM for the left and right halves. The EEPROM is used to store whether the
 | 
			
		||||
half is left handed or right handed. This makes it so that the same firmware
 | 
			
		||||
file will run on both hands instead of having to flash left and right handed
 | 
			
		||||
versions of the firmware to each half. To flash the EEPROM file for the left
 | 
			
		||||
half run:
 | 
			
		||||
```
 | 
			
		||||
make eeprom-left
 | 
			
		||||
```
 | 
			
		||||
and similarly for right half
 | 
			
		||||
```
 | 
			
		||||
make eeprom-right
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
After you have flashed the EEPROM for the first time, you then need to program
 | 
			
		||||
the flash memory:
 | 
			
		||||
```
 | 
			
		||||
make program
 | 
			
		||||
```
 | 
			
		||||
Note that you need to program both halves, but you have the option of using
 | 
			
		||||
different keymaps for each half. You could program the left half with a QWERTY
 | 
			
		||||
layout and the right half with a Colemak layout. Then if you connect the left
 | 
			
		||||
half to a computer by USB the keyboard will use QWERTY and Colemak when the
 | 
			
		||||
right half is connected.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										225
									
								
								keyboards/lets_split/serial.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										225
									
								
								keyboards/lets_split/serial.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,225 @@
 | 
			
		||||
/*
 | 
			
		||||
 * WARNING: be careful changing this code, it is very timing dependent
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef F_CPU
 | 
			
		||||
#define F_CPU 16000000
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
#include <avr/interrupt.h>
 | 
			
		||||
#include <util/delay.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
#include "serial.h"
 | 
			
		||||
 | 
			
		||||
// Serial pulse period in microseconds. Its probably a bad idea to lower this
 | 
			
		||||
// value.
 | 
			
		||||
#define SERIAL_DELAY 24
 | 
			
		||||
 | 
			
		||||
uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
 | 
			
		||||
uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
 | 
			
		||||
 | 
			
		||||
#define SLAVE_DATA_CORRUPT (1<<0)
 | 
			
		||||
volatile uint8_t status = 0;
 | 
			
		||||
 | 
			
		||||
inline static
 | 
			
		||||
void serial_delay(void) {
 | 
			
		||||
  _delay_us(SERIAL_DELAY);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline static
 | 
			
		||||
void serial_output(void) {
 | 
			
		||||
  SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// make the serial pin an input with pull-up resistor
 | 
			
		||||
inline static
 | 
			
		||||
void serial_input(void) {
 | 
			
		||||
  SERIAL_PIN_DDR  &= ~SERIAL_PIN_MASK;
 | 
			
		||||
  SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline static
 | 
			
		||||
uint8_t serial_read_pin(void) {
 | 
			
		||||
  return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline static
 | 
			
		||||
void serial_low(void) {
 | 
			
		||||
  SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline static
 | 
			
		||||
void serial_high(void) {
 | 
			
		||||
  SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void serial_master_init(void) {
 | 
			
		||||
  serial_output();
 | 
			
		||||
  serial_high();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void serial_slave_init(void) {
 | 
			
		||||
  serial_input();
 | 
			
		||||
 | 
			
		||||
  // Enable INT0
 | 
			
		||||
  EIMSK |= _BV(INT0);
 | 
			
		||||
  // Trigger on falling edge of INT0
 | 
			
		||||
  EICRA &= ~(_BV(ISC00) | _BV(ISC01));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Used by the master to synchronize timing with the slave.
 | 
			
		||||
static
 | 
			
		||||
void sync_recv(void) {
 | 
			
		||||
  serial_input();
 | 
			
		||||
  // This shouldn't hang if the slave disconnects because the
 | 
			
		||||
  // serial line will float to high if the slave does disconnect.
 | 
			
		||||
  while (!serial_read_pin());
 | 
			
		||||
  serial_delay();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Used by the slave to send a synchronization signal to the master.
 | 
			
		||||
static
 | 
			
		||||
void sync_send(void) {
 | 
			
		||||
  serial_output();
 | 
			
		||||
 | 
			
		||||
  serial_low();
 | 
			
		||||
  serial_delay();
 | 
			
		||||
 | 
			
		||||
  serial_high();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Reads a byte from the serial line
 | 
			
		||||
static
 | 
			
		||||
uint8_t serial_read_byte(void) {
 | 
			
		||||
  uint8_t byte = 0;
 | 
			
		||||
  serial_input();
 | 
			
		||||
  for ( uint8_t i = 0; i < 8; ++i) {
 | 
			
		||||
    byte = (byte << 1) | serial_read_pin();
 | 
			
		||||
    serial_delay();
 | 
			
		||||
    _delay_us(1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return byte;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Sends a byte with MSB ordering
 | 
			
		||||
static
 | 
			
		||||
void serial_write_byte(uint8_t data) {
 | 
			
		||||
  uint8_t b = 8;
 | 
			
		||||
  serial_output();
 | 
			
		||||
  while( b-- ) {
 | 
			
		||||
    if(data & (1 << b)) {
 | 
			
		||||
      serial_high();
 | 
			
		||||
    } else {
 | 
			
		||||
      serial_low();
 | 
			
		||||
    }
 | 
			
		||||
    serial_delay();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// interrupt handle to be used by the slave device
 | 
			
		||||
ISR(SERIAL_PIN_INTERRUPT) {
 | 
			
		||||
  sync_send();
 | 
			
		||||
 | 
			
		||||
  uint8_t checksum = 0;
 | 
			
		||||
  for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
 | 
			
		||||
    serial_write_byte(serial_slave_buffer[i]);
 | 
			
		||||
    sync_send();
 | 
			
		||||
    checksum += serial_slave_buffer[i];
 | 
			
		||||
  }
 | 
			
		||||
  serial_write_byte(checksum);
 | 
			
		||||
  sync_send();
 | 
			
		||||
 | 
			
		||||
  // wait for the sync to finish sending
 | 
			
		||||
  serial_delay();
 | 
			
		||||
 | 
			
		||||
  // read the middle of pulses
 | 
			
		||||
  _delay_us(SERIAL_DELAY/2);
 | 
			
		||||
 | 
			
		||||
  uint8_t checksum_computed = 0;
 | 
			
		||||
  for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
 | 
			
		||||
    serial_master_buffer[i] = serial_read_byte();
 | 
			
		||||
    sync_send();
 | 
			
		||||
    checksum_computed += serial_master_buffer[i];
 | 
			
		||||
  }
 | 
			
		||||
  uint8_t checksum_received = serial_read_byte();
 | 
			
		||||
  sync_send();
 | 
			
		||||
 | 
			
		||||
  serial_input(); // end transaction
 | 
			
		||||
 | 
			
		||||
  if ( checksum_computed != checksum_received ) {
 | 
			
		||||
    status |= SLAVE_DATA_CORRUPT;
 | 
			
		||||
  } else {
 | 
			
		||||
    status &= ~SLAVE_DATA_CORRUPT;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
inline
 | 
			
		||||
bool serial_slave_DATA_CORRUPT(void) {
 | 
			
		||||
  return status & SLAVE_DATA_CORRUPT;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Copies the serial_slave_buffer to the master and sends the
 | 
			
		||||
// serial_master_buffer to the slave.
 | 
			
		||||
//
 | 
			
		||||
// Returns:
 | 
			
		||||
// 0 => no error
 | 
			
		||||
// 1 => slave did not respond
 | 
			
		||||
int serial_update_buffers(void) {
 | 
			
		||||
  // this code is very time dependent, so we need to disable interrupts
 | 
			
		||||
  cli();
 | 
			
		||||
 | 
			
		||||
  // signal to the slave that we want to start a transaction
 | 
			
		||||
  serial_output();
 | 
			
		||||
  serial_low();
 | 
			
		||||
  _delay_us(1);
 | 
			
		||||
 | 
			
		||||
  // wait for the slaves response
 | 
			
		||||
  serial_input();
 | 
			
		||||
  serial_high();
 | 
			
		||||
  _delay_us(SERIAL_DELAY);
 | 
			
		||||
 | 
			
		||||
  // check if the slave is present
 | 
			
		||||
  if (serial_read_pin()) {
 | 
			
		||||
    // slave failed to pull the line low, assume not present
 | 
			
		||||
    sei();
 | 
			
		||||
    return 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // if the slave is present syncronize with it
 | 
			
		||||
  sync_recv();
 | 
			
		||||
 | 
			
		||||
  uint8_t checksum_computed = 0;
 | 
			
		||||
  // receive data from the slave
 | 
			
		||||
  for (int i = 0; i < SERIAL_SLAVE_BUFFER_LENGTH; ++i) {
 | 
			
		||||
    serial_slave_buffer[i] = serial_read_byte();
 | 
			
		||||
    sync_recv();
 | 
			
		||||
    checksum_computed += serial_slave_buffer[i];
 | 
			
		||||
  }
 | 
			
		||||
  uint8_t checksum_received = serial_read_byte();
 | 
			
		||||
  sync_recv();
 | 
			
		||||
 | 
			
		||||
  if (checksum_computed != checksum_received) {
 | 
			
		||||
    sei();
 | 
			
		||||
    return 1;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  uint8_t checksum = 0;
 | 
			
		||||
  // send data to the slave
 | 
			
		||||
  for (int i = 0; i < SERIAL_MASTER_BUFFER_LENGTH; ++i) {
 | 
			
		||||
    serial_write_byte(serial_master_buffer[i]);
 | 
			
		||||
    sync_recv();
 | 
			
		||||
    checksum += serial_master_buffer[i];
 | 
			
		||||
  }
 | 
			
		||||
  serial_write_byte(checksum);
 | 
			
		||||
  sync_recv();
 | 
			
		||||
 | 
			
		||||
  // always, release the line when not in use
 | 
			
		||||
  serial_output();
 | 
			
		||||
  serial_high();
 | 
			
		||||
 | 
			
		||||
  sei();
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								keyboards/lets_split/serial.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								keyboards/lets_split/serial.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
			
		||||
#ifndef MY_SERIAL_H
 | 
			
		||||
#define MY_SERIAL_H
 | 
			
		||||
 | 
			
		||||
#include "config.h"
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
/* TODO:  some defines for interrupt setup */
 | 
			
		||||
#define SERIAL_PIN_DDR DDRD
 | 
			
		||||
#define SERIAL_PIN_PORT PORTD
 | 
			
		||||
#define SERIAL_PIN_INPUT PIND
 | 
			
		||||
#define SERIAL_PIN_MASK _BV(PD0)
 | 
			
		||||
#define SERIAL_PIN_INTERRUPT INT0_vect
 | 
			
		||||
 | 
			
		||||
#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
 | 
			
		||||
#define SERIAL_MASTER_BUFFER_LENGTH 1
 | 
			
		||||
 | 
			
		||||
// Buffers for master - slave communication
 | 
			
		||||
extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
 | 
			
		||||
extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
 | 
			
		||||
 | 
			
		||||
void serial_master_init(void);
 | 
			
		||||
void serial_slave_init(void);
 | 
			
		||||
int serial_update_buffers(void);
 | 
			
		||||
bool serial_slave_data_corrupt(void);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										76
									
								
								keyboards/lets_split/split_util.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								keyboards/lets_split/split_util.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,76 @@
 | 
			
		||||
#include <avr/io.h>
 | 
			
		||||
#include <avr/wdt.h>
 | 
			
		||||
#include <avr/power.h>
 | 
			
		||||
#include <avr/interrupt.h>
 | 
			
		||||
#include <util/delay.h>
 | 
			
		||||
#include <avr/eeprom.h>
 | 
			
		||||
#include "split_util.h"
 | 
			
		||||
#include "matrix.h"
 | 
			
		||||
#include "i2c.h"
 | 
			
		||||
#include "serial.h"
 | 
			
		||||
#include "keyboard.h"
 | 
			
		||||
#include "config.h"
 | 
			
		||||
 | 
			
		||||
volatile bool isLeftHand = true;
 | 
			
		||||
 | 
			
		||||
static void setup_handedness(void) {
 | 
			
		||||
  #ifdef EE_HANDS
 | 
			
		||||
    isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
 | 
			
		||||
  #else
 | 
			
		||||
    #ifdef I2C_MASTER_RIGHT
 | 
			
		||||
      isLeftHand = !has_usb();
 | 
			
		||||
    #else
 | 
			
		||||
      isLeftHand = has_usb();
 | 
			
		||||
    #endif
 | 
			
		||||
  #endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void keyboard_master_setup(void) {
 | 
			
		||||
#ifdef USE_I2C
 | 
			
		||||
    i2c_master_init();
 | 
			
		||||
#else
 | 
			
		||||
    serial_master_init();
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void keyboard_slave_setup(void) {
 | 
			
		||||
#ifdef USE_I2C
 | 
			
		||||
    i2c_slave_init(SLAVE_I2C_ADDRESS);
 | 
			
		||||
#else
 | 
			
		||||
    serial_slave_init();
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool has_usb(void) {
 | 
			
		||||
   USBCON |= (1 << OTGPADE); //enables VBUS pad
 | 
			
		||||
   _delay_us(5);
 | 
			
		||||
   return (USBSTA & (1<<VBUS));  //checks state of VBUS
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void split_keyboard_setup(void) {
 | 
			
		||||
   setup_handedness();
 | 
			
		||||
 | 
			
		||||
   if (has_usb()) {
 | 
			
		||||
      keyboard_master_setup();
 | 
			
		||||
   } else {
 | 
			
		||||
      keyboard_slave_setup();
 | 
			
		||||
   }
 | 
			
		||||
   sei();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void keyboard_slave_loop(void) {
 | 
			
		||||
   matrix_init();
 | 
			
		||||
 | 
			
		||||
   while (1) {
 | 
			
		||||
      matrix_slave_scan();
 | 
			
		||||
   }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// this code runs before the usb and keyboard is initialized
 | 
			
		||||
void matrix_setup(void) {
 | 
			
		||||
    split_keyboard_setup();
 | 
			
		||||
 | 
			
		||||
    if (!has_usb()) {
 | 
			
		||||
        keyboard_slave_loop();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								keyboards/lets_split/split_util.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								keyboards/lets_split/split_util.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
#ifndef SPLIT_KEYBOARD_UTIL_H
 | 
			
		||||
#define SPLIT_KEYBOARD_UTIL_H
 | 
			
		||||
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
#ifdef EE_HANDS
 | 
			
		||||
	#define EECONFIG_BOOTMAGIC_END      (uint8_t *)10
 | 
			
		||||
	#define EECONFIG_HANDEDNESS         EECONFIG_BOOTMAGIC_END
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define SLAVE_I2C_ADDRESS           0x32
 | 
			
		||||
 | 
			
		||||
extern volatile bool isLeftHand;
 | 
			
		||||
 | 
			
		||||
// slave version of matix scan, defined in matrix.c
 | 
			
		||||
void matrix_slave_scan(void);
 | 
			
		||||
 | 
			
		||||
void split_keyboard_setup(void);
 | 
			
		||||
bool has_usb(void);
 | 
			
		||||
void keyboard_slave_loop(void);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@ -197,8 +197,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
        #endif
 | 
			
		||||
        persistant_default_layer_set(1UL<<_QWERTY);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case COLEMAK:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        #ifdef AUDIO_ENABLE
 | 
			
		||||
@ -206,8 +206,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
        #endif
 | 
			
		||||
        persistant_default_layer_set(1UL<<_COLEMAK);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case DVORAK:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        #ifdef AUDIO_ENABLE
 | 
			
		||||
@ -215,8 +215,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
        #endif
 | 
			
		||||
        persistant_default_layer_set(1UL<<_DVORAK);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case LOWER:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        layer_on(_LOWER);
 | 
			
		||||
@ -225,8 +225,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
        layer_off(_LOWER);
 | 
			
		||||
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case RAISE:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        layer_on(_RAISE);
 | 
			
		||||
@ -235,8 +235,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
        layer_off(_RAISE);
 | 
			
		||||
        update_tri_layer(_LOWER, _RAISE, _ADJUST);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case BACKLIT:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        register_code(KC_RSFT);
 | 
			
		||||
@ -246,8 +246,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
      } else {
 | 
			
		||||
        unregister_code(KC_RSFT);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case PLOVER:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        #ifdef AUDIO_ENABLE
 | 
			
		||||
@ -265,8 +265,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
        keymap_config.nkro = 1;
 | 
			
		||||
        eeconfig_update_keymap(keymap_config.raw);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
    case EXT_PLV:
 | 
			
		||||
      if (record->event.pressed) {
 | 
			
		||||
        #ifdef AUDIO_ENABLE
 | 
			
		||||
@ -274,8 +274,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
        #endif
 | 
			
		||||
        layer_off(_PLOVER);
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
      return false;
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -191,8 +191,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
            #endif
 | 
			
		||||
            persistant_default_layer_set(1UL<<_QWERTY);
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
          return false;
 | 
			
		||||
          break;
 | 
			
		||||
        case COLEMAK:
 | 
			
		||||
          if (record->event.pressed) {
 | 
			
		||||
            #ifdef AUDIO_ENABLE
 | 
			
		||||
@ -200,8 +200,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
            #endif
 | 
			
		||||
            persistant_default_layer_set(1UL<<_COLEMAK);
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
          return false;
 | 
			
		||||
          break;
 | 
			
		||||
        case DVORAK:
 | 
			
		||||
          if (record->event.pressed) {
 | 
			
		||||
            #ifdef AUDIO_ENABLE
 | 
			
		||||
@ -209,8 +209,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
            #endif
 | 
			
		||||
            persistant_default_layer_set(1UL<<_DVORAK);
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
          return false;
 | 
			
		||||
          break;
 | 
			
		||||
        case LOWER:
 | 
			
		||||
          if (record->event.pressed) {
 | 
			
		||||
            layer_on(_LOWER);
 | 
			
		||||
@ -219,8 +219,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
            layer_off(_LOWER);
 | 
			
		||||
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
          return false;
 | 
			
		||||
          break;
 | 
			
		||||
        case RAISE:
 | 
			
		||||
          if (record->event.pressed) {
 | 
			
		||||
            layer_on(_RAISE);
 | 
			
		||||
@ -229,8 +229,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
            layer_off(_RAISE);
 | 
			
		||||
            update_tri_layer(_LOWER, _RAISE, _ADJUST);
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
          return false;
 | 
			
		||||
          break;
 | 
			
		||||
        case BACKLIT:
 | 
			
		||||
          if (record->event.pressed) {
 | 
			
		||||
            register_code(KC_RSFT);
 | 
			
		||||
@ -240,8 +240,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
 | 
			
		||||
          } else {
 | 
			
		||||
            unregister_code(KC_RSFT);
 | 
			
		||||
          }
 | 
			
		||||
          break;
 | 
			
		||||
          return false;
 | 
			
		||||
          break;
 | 
			
		||||
      }
 | 
			
		||||
    return true;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1,25 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "stm32_f072_onekey.h"
 | 
			
		||||
 | 
			
		||||
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
    {{KC_CAPS}}, // test with KC_CAPS, KC_A, KC_BTLD
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const uint16_t fn_actions[] = {
 | 
			
		||||
};
 | 
			
		||||
@ -1,32 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
the Free Software Foundation, either version 2 of the License, or
 | 
			
		||||
(at your option) any later version.
 | 
			
		||||
 | 
			
		||||
This program is distributed in the hope that it will be useful,
 | 
			
		||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
GNU General Public License for more details.
 | 
			
		||||
 | 
			
		||||
You should have received a copy of the GNU General Public License
 | 
			
		||||
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#include "keycode.h"
 | 
			
		||||
#include "action.h"
 | 
			
		||||
#include "action_macro.h"
 | 
			
		||||
#include "report.h"
 | 
			
		||||
#include "host.h"
 | 
			
		||||
#include "print.h"
 | 
			
		||||
#include "debug.h"
 | 
			
		||||
#include "keymap.h"
 | 
			
		||||
 | 
			
		||||
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 | 
			
		||||
    {{KC_A}},
 | 
			
		||||
};  // to test: KC_CAPS, KT_BTLD, KC_A
 | 
			
		||||
 | 
			
		||||
const uint16_t fn_actions[] = {
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										1
									
								
								lib/ugfx
									
									
									
									
									
										Submodule
									
								
							
							
								
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								lib/ugfx
									
									
									
									
									
										Submodule
									
								
							@ -0,0 +1 @@
 | 
			
		||||
Subproject commit 13e084ae6231857cd0d472c529f34be07d93c08b
 | 
			
		||||
@ -49,7 +49,7 @@
 | 
			
		||||
#define ES_PIPE	ALGR(KC_1)
 | 
			
		||||
#define ES_AT 	ALGR(KC_2)
 | 
			
		||||
#define ES_HASH	ALGR(KC_3)
 | 
			
		||||
#define ES_TILD	ALGR(KC_4)
 | 
			
		||||
#define ES_TILD	ALGR(ES_NTIL)
 | 
			
		||||
#define ES_EURO	ALGR(KC_5)
 | 
			
		||||
#define ES_NOT	ALGR(KC_6)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user