Merge pull request #539 from keyboardio/hardware/kbdfans-kbd4x
Initial support for KBDFans KBD4xpull/540/head
commit
9f0d85500a
@ -0,0 +1 @@
|
|||||||
|
output/
|
@ -0,0 +1,26 @@
|
|||||||
|
flash_over_usb() {
|
||||||
|
sleep 1s
|
||||||
|
|
||||||
|
dfu-programmer ${MCU} erase
|
||||||
|
dfu-programmer ${MCU} flash "${HEX_FILE_PATH}"
|
||||||
|
dfu-programmer ${MCU} start
|
||||||
|
}
|
||||||
|
|
||||||
|
flash () {
|
||||||
|
prepare_to_flash
|
||||||
|
|
||||||
|
# This is defined in the (optional) user config.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
${preFlash_HOOKS}
|
||||||
|
|
||||||
|
flash_over_usb || flash_over_usb
|
||||||
|
|
||||||
|
# This is defined in the (optional) user config.
|
||||||
|
# shellcheck disable=SC2154
|
||||||
|
${postFlash_HOOKS}
|
||||||
|
}
|
||||||
|
|
||||||
|
NO_RESET=1
|
||||||
|
|
||||||
|
DEFAULT_SKETCH="KBD4x"
|
||||||
|
BOARD="kbd4x"
|
@ -0,0 +1,96 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* KBD4x -- A very basic Kaleidoscope example for the KBDFans KBD4x keyboard
|
||||||
|
* Copyright (C) 2019 Keyboard.io, Inc
|
||||||
|
*
|
||||||
|
* 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, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Kaleidoscope.h"
|
||||||
|
#include "Kaleidoscope-Macros.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
_QWERTY,
|
||||||
|
_FN
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
RESET
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MO(n) ShiftToLayer(n)
|
||||||
|
|
||||||
|
/* *INDENT-OFF* */
|
||||||
|
KEYMAPS(
|
||||||
|
|
||||||
|
/* Qwerty
|
||||||
|
* ,-------------------------------------------------------------------------.
|
||||||
|
* | Esc | Q | W | E | R | T | Y | U | I | O | P | Bksp |
|
||||||
|
* |------+-----+-----+-----+-----+-----------+-----+-----+-----+-----+------|
|
||||||
|
* | Tab | A | S | D | F | G | H | J | K | L | ; | " |
|
||||||
|
* |------+-----+-----+-----+-----+-----|-----+-----+-----+-----+-----+------|
|
||||||
|
* | Shift| Z | X | C | V | B | N | M | , | . | Up |Enter |
|
||||||
|
* |------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+------|
|
||||||
|
* | Ctrl | GUI | 1 | 2 | 3 | Space | FN | / | Lft | Dn |Right |
|
||||||
|
* `-------------------------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
|
||||||
|
[_QWERTY] = KEYMAP(
|
||||||
|
Key_Escape ,Key_Q ,Key_W ,Key_E ,Key_R ,Key_T ,Key_Y ,Key_U ,Key_I ,Key_O ,Key_P ,Key_Backspace
|
||||||
|
,Key_Tab ,Key_A ,Key_S ,Key_D ,Key_F ,Key_G ,Key_H ,Key_J ,Key_K ,Key_L ,Key_Semicolon ,Key_Quote
|
||||||
|
,Key_LeftShift ,Key_Z ,Key_X ,Key_C ,Key_V ,Key_B ,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_UpArrow ,Key_Enter
|
||||||
|
,Key_LeftControl ,Key_LeftGui ,Key_1 ,Key_2 ,Key_3 ,Key_Space ,MO(_FN) ,Key_Slash ,Key_LeftArrow ,Key_DownArrow ,Key_RightArrow
|
||||||
|
),
|
||||||
|
|
||||||
|
/* Fn
|
||||||
|
* ,-----------------------------------------------------------------------------------.
|
||||||
|
* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | |
|
||||||
|
* |------+------+------+------+------+-------------+------+------+------+------+------|
|
||||||
|
* | | | | | | | | | | | | RST |
|
||||||
|
* |------+------+------+------+------+------|------+------+------+------+------+------|
|
||||||
|
* | | | | | | | | | | | | |
|
||||||
|
* |------+------+------+------+------+------+------+------+------+------+------+------|
|
||||||
|
* | | | | | | | | | | | |
|
||||||
|
* `-----------------------------------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
[_FN] = KEYMAP(
|
||||||
|
Key_Backtick ,Key_1 ,Key_2 ,Key_3 ,Key_4 ,Key_5 ,Key_6 ,Key_7 ,Key_8 ,Key_9 ,Key_0 ,___
|
||||||
|
,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,M(RESET)
|
||||||
|
,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___
|
||||||
|
,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___ ,___
|
||||||
|
)
|
||||||
|
);
|
||||||
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
KALEIDOSCOPE_INIT_PLUGINS(Macros);
|
||||||
|
|
||||||
|
const macro_t *macroAction(uint8_t macroIndex, uint8_t keyState) {
|
||||||
|
switch (macroIndex) {
|
||||||
|
case RESET:
|
||||||
|
KBD4x.resetDevice();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MACRO_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Kaleidoscope.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Kaleidoscope.loop();
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
# This stub makefile for a Kaleidoscope example pulls in all the targets
|
||||||
|
# required to build the example
|
||||||
|
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
SKETCHBOOK_DIR ?= $(HOME)/Documents/Arduino
|
||||||
|
PACKAGE_DIR ?= $(HOME)/Library/Arduino15
|
||||||
|
else
|
||||||
|
SKETCHBOOK_DIR ?= $(HOME)/Arduino
|
||||||
|
PACKAGE_DIR ?= $(HOME)/.arduino15
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
ARDUINO_INSTALLED_ENV=$(shell ls -dt $(PACKAGE_DIR)/packages/keyboardio/hardware/avr 2>/dev/null |head -n 1)
|
||||||
|
MANUALLY_INSTALLED_ENV=$(shell ls -dt $(SKETCHBOOK_DIR)/hardware/keyboardio/avr 2>/dev/null |head -n 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifneq ("$(wildcard $(ARDUINO_INSTALLED_ENV)/boards.txt)","")
|
||||||
|
|
||||||
|
ifneq ("$(wildcard $(MANUALLY_INSTALLED_ENV)/boards.txt)","")
|
||||||
|
|
||||||
|
$(info ***************************************************************************)
|
||||||
|
$(info It appears that you have installed two copies of Kaleidoscope. One copy was)
|
||||||
|
$(info installed using Arduino's "Board Manager", while the other was installed by)
|
||||||
|
$(info hand, probably using "git".)
|
||||||
|
$(info )
|
||||||
|
$(info This will likely cause some trouble as you try to build keyboard firmware)
|
||||||
|
$(info using Kaleidoscope. You may want to remove either: )
|
||||||
|
$(info )
|
||||||
|
$(info $(PACKAGE_DIR)/packages/keyboardio/ which was installed using Arduino)
|
||||||
|
$(info )
|
||||||
|
$(info or)
|
||||||
|
$(info )
|
||||||
|
$(info $(SKETCHBOOK_DIR)/hardware/keyboardio/ which was installed by hand.)
|
||||||
|
$(info )
|
||||||
|
$(info ***************************************************************************)
|
||||||
|
$(info )
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
BOARD_HARDWARE_PATH = $(ARDUINO_INSTALLED_ENV)
|
||||||
|
KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= build-tools/makefiles/
|
||||||
|
KALEIDOSCOPE_BUILDER_DIR ?= $(ARDUINO_INSTALLED_ENV)/libraries/Kaleidoscope/bin/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
BOARD_HARDWARE_PATH ?= $(SKETCHBOOK_DIR)/hardware
|
||||||
|
KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= keyboardio/avr/build-tools/makefiles/
|
||||||
|
|
||||||
|
include $(BOARD_HARDWARE_PATH)/$(KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR)/rules.mk
|
@ -0,0 +1,23 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope-Hardware-KBDFans-KBD4x -- KBD4x hardware support for Kaleidoscope
|
||||||
|
* Copyright (C) 2019 Keyboard.io, Inc
|
||||||
|
*
|
||||||
|
* 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 3 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define KALEIDOSCOPE_WITH_ATMEGA_KEYBOARD 1
|
||||||
|
|
||||||
|
#include "kaleidoscope/hardware/kbdfans/KBD4x.h"
|
@ -0,0 +1,62 @@
|
|||||||
|
/* -*- mode: c++ -*-
|
||||||
|
* Kaleidoscope-Hardware-KBDFans-KBD4x -- KBD4x hardware support for Kaleidoscope
|
||||||
|
* Copyright (C) 2019 Keyboard.io, Inc
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of version 3 of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef ARDUINO_AVR_KBD4X
|
||||||
|
|
||||||
|
#include <Kaleidoscope.h>
|
||||||
|
#include <avr/wdt.h>
|
||||||
|
#include <avr/boot.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace kaleidoscope {
|
||||||
|
namespace hardware {
|
||||||
|
namespace kbdfans {
|
||||||
|
|
||||||
|
ATMEGA_KEYBOARD_DATA(KBD4x);
|
||||||
|
constexpr int8_t KBD4x::led_count;
|
||||||
|
|
||||||
|
#define BOOTLOADER_RESET_KEY 0xB007B007
|
||||||
|
uint32_t reset_key __attribute__ ((section (".noinit")));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function runs before main(), and jumps to the bootloader after a reset
|
||||||
|
* initiated by .resetDevice().
|
||||||
|
*/
|
||||||
|
void _bootloader_jump_after_watchdog_reset()
|
||||||
|
__attribute__((used, naked, section(".init3")));
|
||||||
|
void _bootloader_jump_after_watchdog_reset() {
|
||||||
|
if ((MCUSR & (1<<WDRF)) && reset_key == BOOTLOADER_RESET_KEY) {
|
||||||
|
reset_key = 0;
|
||||||
|
|
||||||
|
((void (*)(void))(((FLASHEND + 1L) - 4096) >> 1))();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KBD4x::resetDevice() {
|
||||||
|
reset_key = BOOTLOADER_RESET_KEY;
|
||||||
|
wdt_enable(WDTO_250MS);
|
||||||
|
for (;;);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HARDWARE_IMPLEMENTATION KeyboardHardware;
|
||||||
|
kaleidoscope::hardware::kbdfans::KBD4x &KBD4x = KeyboardHardware;
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in new issue