First pass at a build for the spacecadet that compiles

jesse/space-cadet
Jesse Vincent 3 years ago
parent 6b8355a7ba
commit 621ebf7978
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

@ -0,0 +1,48 @@
# This makefile for a Kaleidoscope sketch pulls in all the targets
# required to build the example
ifneq ($(KALEIDOSCOPE_DIR),)
search_path += $(KALEIDOSCOPE_DIR)
endif
ifneq ($(ARDUINO_DIRECTORIES_USER),)
search_path += $(ARDUINO_DIRECTORIES_USER)/hardware/keyboardio/avr/libraries/Kaleidoscope
endif
ifeq ($(shell uname -s),Darwin)
search_path += $(HOME)/Documents/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
else
search_path += $(HOME)/Arduino/hardware/keyboardio/avr/libraries/Kaleidoscope
endif
sketch_makefile := etc/makefiles/sketch.mk
$(foreach candidate, $(search_path), $(if $(wildcard $(candidate)/$(sketch_makefile)), $(eval ks_dir ?= $(candidate))))
ifneq ($(ks_dir),)
$(info Using Kaleidoscope from $(ks_dir))
export KALEIDOSCOPE_DIR := $(ks_dir)
include $(ks_dir)/$(sketch_makefile)
else
$(info I can't find your Kaleidoscope installation.)
$(info )
$(info I tried looking in:)
$(info )
$(foreach candidate, $(search_path), $(info $(candidate)))
$(info )
$(info The easiest way to fix this is to set the 'KALEIDOSCOPE_DIR' environment)
$(info variable to the location of your Kaleidoscope directory.)
endif
null-target:
$(info You should never see this message)
@:

@ -60,9 +60,11 @@ enum {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
KEYMAPS( KEYMAPS(
[QWERTY] = KEYMAP_STACKED [QWERTY] = KEYMAP(
( Key_Q ,Key_W ,Key_E ,Key_R ,Key_T ,Key_Y ,Key_U ,Key_I ,Key_O ,Key_P
Key_Q ,Key_W ,Key_E ,Key_R ,Key_T ,Key_A ,Key_S ,Key_D ,Key_F ,Key_G ,Key_H ,Key_J ,Key_K ,Key_L ,Key_Semicolon
,Key_Z ,Key_X ,Key_C ,Key_V ,Key_B, Key_Backtick ,Key_Backslash,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_Slash
,Key_Esc ,Key_Tab ,Key_LeftGui ,Key_LeftShift ,Key_Backspace ,Key_LeftControl ,Key_LeftAlt ,Key_Space ,MO(FUN) ,Key_Minus ,Key_Quote ,Key_Enter, Key_Q ,Key_W ,Key_E ,Key_R ,Key_T
,Key_A ,Key_S ,Key_D ,Key_F ,Key_G ,Key_A ,Key_S ,Key_D ,Key_F ,Key_G
,Key_Z ,Key_X ,Key_C ,Key_V ,Key_B, Key_Backtick ,Key_Z ,Key_X ,Key_C ,Key_V ,Key_B, Key_Backtick
,Key_Esc ,Key_Tab ,Key_LeftGui ,Key_LeftShift ,Key_Backspace ,Key_LeftControl ,Key_Esc ,Key_Tab ,Key_LeftGui ,Key_LeftShift ,Key_Backspace ,Key_LeftControl
@ -71,33 +73,10 @@ KEYMAPS(
,Key_H ,Key_J ,Key_K ,Key_L ,Key_Semicolon ,Key_H ,Key_J ,Key_K ,Key_L ,Key_Semicolon
,Key_Backslash,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_Slash ,Key_Backslash,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_Slash
,Key_LeftAlt ,Key_Space ,MO(FUN) ,Key_Minus ,Key_Quote ,Key_Enter ,Key_LeftAlt ,Key_Space ,MO(FUN) ,Key_Minus ,Key_Quote ,Key_Enter
), ,Key_H ,Key_J ,Key_K ,Key_L ,Key_Semicolon
,Key_Backslash,Key_N ,Key_M ,Key_Comma ,Key_Period ,Key_Slash, XXX, XXX
[FUN] = KEYMAP_STACKED )
(
Key_Exclamation ,Key_At ,Key_UpArrow ,Key_Dollar ,Key_Percent
,Key_LeftParen ,Key_LeftArrow ,Key_DownArrow ,Key_RightArrow ,Key_RightParen
,Key_LeftBracket ,Key_RightBracket ,Key_Hash ,Key_LeftCurlyBracket ,Key_RightCurlyBracket ,Key_Caret
,TG(UPPER) ,Key_Insert ,Key_LeftGui ,Key_LeftShift ,Key_Delete ,Key_LeftControl
,Key_PageUp ,Key_7 ,Key_8 ,Key_9 ,Key_Backspace
,Key_PageDown ,Key_4 ,Key_5 ,Key_6 ,___
,Key_And ,Key_Star ,Key_1 ,Key_2 ,Key_3 ,Key_Plus
,Key_LeftAlt ,Key_Space ,___ ,Key_Period ,Key_0 ,Key_Equals
),
[UPPER] = KEYMAP_STACKED
(
Key_Insert ,Key_Home ,Key_UpArrow ,Key_End ,Key_PageUp
,Key_Delete ,Key_LeftArrow ,Key_DownArrow ,Key_RightArrow ,Key_PageDown
,M(MACRO_VERSION_INFO) ,Consumer_VolumeIncrement ,XXX ,XXX ,___ ,___
,MoveToLayer(QWERTY) ,Consumer_VolumeDecrement ,___ ,___ ,___ ,___
,Key_UpArrow ,Key_F7 ,Key_F8 ,Key_F9 ,Key_F10
,Key_DownArrow ,Key_F4 ,Key_F5 ,Key_F6 ,Key_F11
,___ ,XXX ,Key_F1 ,Key_F2 ,Key_F3 ,Key_F12
,___ ,___ ,MoveToLayer(QWERTY) ,Key_PrintScreen ,Key_ScrollLock ,Consumer_PlaySlashPause
)
) )
/* *INDENT-ON* */ /* *INDENT-ON* */

@ -0,0 +1,6 @@
{
"cpu": {
"fqbn": "keyboardio:gd32:keyboardio_spacecadet",
"port": ""
}
}

@ -16,4 +16,4 @@
#pragma once #pragma once
#include "kaleidoscope/device/keyboardio/Spaceadet.h" #include "kaleidoscope/device/keyboardio/Spacecadet.h"

@ -30,7 +30,6 @@ namespace keyscanner {
struct GD32Props: kaleidoscope::driver::keyscanner::BaseProps { struct GD32Props: kaleidoscope::driver::keyscanner::BaseProps {
static const uint16_t keyscan_interval = 1500; static const uint16_t keyscan_interval = 1500;
static const uint16_t next_scan_after = 0;
typedef uint32_t RowState; typedef uint32_t RowState;
/* /*
@ -46,6 +45,7 @@ template <typename _KeyScannerProps>
class GD32: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> { class GD32: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> {
private: private:
typedef GD32<_KeyScannerProps> ThisType; typedef GD32<_KeyScannerProps> ThisType;
uint16_t next_scan_after_ ;
public: public:
void setup() { void setup() {
@ -59,7 +59,7 @@ class GD32: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> {
); );
for (uint8_t i = 0; i < _KeyScannerProps::matrix_columns; i++) { for (uint8_t i = 0; i < _KeyScannerProps::matrix_columns; i++) {
pinmode(_KeyScannerProps::matrix_col_pins[i], INPUT_PULLUP); pinMode(_KeyScannerProps::matrix_col_pins[i], INPUT_PULLUP);
} }
for (uint8_t i = 0; i < _KeyScannerProps::matrix_rows; i++) { for (uint8_t i = 0; i < _KeyScannerProps::matrix_rows; i++) {
@ -68,6 +68,7 @@ class GD32: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> {
} }
setScanCycleTime(_KeyScannerProps::keyscan_interval); setScanCycleTime(_KeyScannerProps::keyscan_interval);
next_scan_after_ = 0;
} }
@ -77,14 +78,6 @@ class GD32: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> {
*/ */
void setScanCycleTime(uint16_t c) { void setScanCycleTime(uint16_t c) {
TCCR1B = _BV(WGM13);
TCCR1A = 0;
const uint32_t cycles = (F_CPU / 2000000) * c;
ICR1 = cycles;
TCCR1B = _BV(WGM13) | _BV(CS10);
TIMSK1 = _BV(TOIE1);
} }
__attribute__((optimize(3))) __attribute__((optimize(3)))
@ -108,8 +101,8 @@ class GD32: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> {
} }
void scanMatrix() { void scanMatrix() {
if (micros() > _KeyScannerProps::next_scan_after || micros < _KeyScannerProps::keyscan_interval) { if (micros() > next_scan_after_ || micros() < _KeyScannerProps::keyscan_interval) {
_KeyScannerProps::next_scan_after = micros() + _KeyScannerProps::keyscan_interval; next_scan_after_ = micros() + _KeyScannerProps::keyscan_interval;
readMatrix(); readMatrix();
} }
actOnMatrixScan(); actOnMatrixScan();
@ -197,7 +190,7 @@ class GD32: public kaleidoscope::driver::keyscanner::Base<_KeyScannerProps> {
for (uint8_t i = 0; i < _KeyScannerProps::matrix_columns; i++) { for (uint8_t i = 0; i < _KeyScannerProps::matrix_columns; i++) {
// TODO - do we need this on gd32? // TODO - do we need this on gd32?
asm("NOP"); // We need to pause a beat before reading or we may read before the pin is hot asm("NOP"); // We need to pause a beat before reading or we may read before the pin is hot
hot_pins |= (!READ_PIN(_KeyScannerProps::matrix_col_pins[i]) << i); hot_pins |= (!digitalRead(_KeyScannerProps::matrix_col_pins[i]) << i);
} }
return hot_pins; return hot_pins;

@ -1,5 +1,5 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Hardware-Spacecadet -- Keyboardio Model 100 hardware support for Kaleidoscope * Kaleidoscope-Hardware-Spacecadet -- Keyboardio Spacecadet hardware support for Kaleidoscope
* Copyright (C) 2021 Keyboard.io, Inc * Copyright (C) 2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -29,8 +29,8 @@
// Here, we set up aliases to the device's KeyScanner and KeyScannerProps // Here, we set up aliases to the device's KeyScanner and KeyScannerProps
// in the global namespace within the scope of this file. We'll use these // in the global namespace within the scope of this file. We'll use these
// aliases to simplify some template initialization code below. // aliases to simplify some template initialization code below.
using KeyScannerProps = typename kaleidoscope::device::keyboardio::AtreusProps::KeyScannerProps; using KeyScannerProps = typename kaleidoscope::device::keyboardio::SpacecadetProps::KeyScannerProps;
using KeyScanner = typename kaleidoscope::device::keyboardio::AtreusProps::KeyScanner; using KeyScanner = typename kaleidoscope::device::keyboardio::SpacecadetProps::KeyScanner;
@ -52,29 +52,6 @@ constexpr uint8_t KeyScannerProps::matrix_col_pins[matrix_columns];
// `KeyScannerProps` case above. // `KeyScannerProps` case above.
template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {}; template<> KeyScanner::row_state_t KeyScanner::matrix_state_[KeyScannerProps::matrix_rows] = {};
// We set up the TIMER1 interrupt vector here. Due to dependency reasons, this
// cannot be in a header-only driver, and must be placed here.
//
// Timer1 is responsible for setting a property on the KeyScanner, which will
// tell it to do a scan. We use this to make sure that scans happen at roughly
// the intervals we want. We do the scan outside of the interrupt scope for
// practical reasons: guarding every codepath against interrupts that can be
// reached from the scan is far too tedious, for very little gain.
ISR(TIMER1_OVF_vect) {
Runtime.device().keyScanner().do_scan_ = true;
}
/********* Hardware plugin *********/
void Spacecadet::setup() {
SpacecadetKeyScanner::setup();
kaleidoscope::device::Base<SpacecadetProps>::setup();
}
} }

@ -1,5 +1,5 @@
/* -*- mode: c++ -*- /* -*- mode: c++ -*-
* Kaleidoscope-Hardware-Model100 -- Keyboardio Model100 hardware support for Kaleidoscope * Kaleidoscope-Hardware-Spacecadet -- Keyboardio Spacecadet hardware support for Kaleidoscope
* Copyright (C) 2017-2021 Keyboard.io, Inc * Copyright (C) 2017-2021 Keyboard.io, Inc
* *
* This program is free software: you can redistribute it and/or modify it under * This program is free software: you can redistribute it and/or modify it under
@ -28,24 +28,22 @@
#include "kaleidoscope/driver/keyscanner/Base.h" #include "kaleidoscope/driver/keyscanner/Base.h"
#include "kaleidoscope/driver/storage/GD32Flash.h" #include "kaleidoscope/driver/storage/GD32Flash.h"
#include "kaleidoscope/driver/keyboardio/Model100Side.h"
#include "kaleidoscope/driver/led/Base.h"
#include "kaleidoscope/device/Base.h" #include "kaleidoscope/device/Base.h"
#include "kaleidoscope/driver/hid/Keyboardio.h" #include "kaleidoscope/driver/hid/Keyboardio.h"
#include "kaleidoscope/driver/bootloader/gd32/Base.h" #include "kaleidoscope/driver/bootloader/gd32/Base.h"
#include "kaleidoscope/device/keyboardio/GD32Keyscanner.h"
namespace kaleidoscope { namespace kaleidoscope {
namespace device { namespace device {
namespace keyboardio { namespace keyboardio {
struct Model100StorageProps: public kaleidoscope::driver::storage::GD32FlashProps { struct SpacecadetStorageProps: public kaleidoscope::driver::storage::GD32FlashProps {
static constexpr uint16_t length = EEPROM_EMULATION_SIZE; static constexpr uint16_t length = EEPROM_EMULATION_SIZE;
}; };
class Model100LEDDriver;
struct Model100Props : public kaleidoscope::device::BaseProps { struct SpacecadetProps : public kaleidoscope::device::BaseProps {
typedef kaleidoscope::driver::hid::KeyboardioProps HIDProps; typedef kaleidoscope::driver::hid::KeyboardioProps HIDProps;
typedef kaleidoscope::driver::hid::Keyboardio<HIDProps> HID; typedef kaleidoscope::driver::hid::Keyboardio<HIDProps> HID;
@ -56,14 +54,14 @@ struct Model100Props : public kaleidoscope::device::BaseProps {
static constexpr uint8_t matrix_columns = 21; static constexpr uint8_t matrix_columns = 21;
typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr; typedef MatrixAddr<matrix_rows, matrix_columns> KeyAddr;
static constexpr uint8_t matrix_row_pins[matrix_rows] = {PB15, PB14, PB13, PB12, PB11, PB10}; static constexpr uint8_t matrix_row_pins[matrix_rows] = {PB15, PB14, PB13, PB12, PB11, PB10};
static constexpr uint8_t matrix_col_pins[matrix_columns] = {PB1, PB0,PA7,PA6,PA5,PA4,PA3,PA2,PA1,PA0,PD1,PD0,PC15,PC14,PC13, PA9,PA10, PB8, PB7, PB6,PB5, PB9}; static constexpr uint8_t matrix_col_pins[matrix_columns] = {PB1, PB0,PA7,PA6,PA5,PA4,PA3,PA2,PA1,PA0,PD1,PD0,PC15,PC14,PC13, PA9,PA10, PB8, PB7, PB6,PB5};
}; };
typedef kaleidoscope::driver::keyscanner::GD32<KeyScannerProps> KeyScanner; typedef kaleidoscope::driver::keyscanner::GD32<KeyScannerProps> KeyScanner;
typedef Model100StorageProps StorageProps; typedef SpacecadetStorageProps StorageProps;
typedef kaleidoscope::driver::storage::GD32Flash<StorageProps> Storage; typedef kaleidoscope::driver::storage::GD32Flash<StorageProps> Storage;
typedef kaleidoscope::driver::bootloader::gd32::Base BootLoader; typedef kaleidoscope::driver::bootloader::gd32::Base BootLoader;
@ -71,18 +69,15 @@ struct Model100Props : public kaleidoscope::device::BaseProps {
}; };
class Model100 : public kaleidoscope::device::Base<Model100Props> { class Spacecadet : public kaleidoscope::device::Base<SpacecadetProps> {
public: public:
void setup();
static void enableHardwareTestMode();
}; };
} // namespace keyboardio } // namespace keyboardio
} // namespace device } // namespace device
EXPORT_DEVICE(kaleidoscope::device::keyboardio::Model100) EXPORT_DEVICE(kaleidoscope::device::keyboardio::Spacecadet)
} }
@ -96,11 +91,11 @@ EXPORT_DEVICE(kaleidoscope::device::keyboardio::Model100)
r5c0, r5c1, r5c2, r5c3, r5c9, r5c15, r5c17, r5c18, r5c19, ...) \ r5c0, r5c1, r5c2, r5c3, r5c9, r5c15, r5c17, r5c18, r5c19, ...) \
\ \
\ \
r0c0, xxx, r0c2, r0c3, xxx, r0c5, xxx, r0c7, xxx, r0c9, xxx, r0c11, xxx, r0c13, xxx, r0c15, xxx, r0c17, r0c18, r0c19, xxx, \ r0c0, XXX, r0c2, r0c3, XXX, r0c5, XXX, r0c7, XXX, r0c9, XXX, r0c11, XXX, r0c13, XXX, r0c15, XXX, r0c17, r0c18, r0c19, XXX, \
r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, r1c7, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, r1c16, r1c17, r1c18, r1c19, r1c20, \ r1c0, r1c1, r1c2, r1c3, r1c4, r1c5, r1c6, r1c7, r1c8, r1c9, r1c10, r1c11, r1c12, r1c13, r1c14, r1c15, r1c16, r1c17, r1c18, r1c19, r1c20, \
r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, r2c6, r2c7, r2c8, r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15, r2c16, r2c17, r2c18, r2c19, xxx, \ r2c0, r2c1, r2c2, r2c3, r2c4, r2c5, r2c6, r2c7, r2c8, r2c9, r2c10, r2c11, r2c12, r2c13, r2c14, r2c15, r2c16, r2c17, r2c18, r2c19, XXX, \
r3c0, xxx, r3c2, r3c3, r3c4, r3c5, r3c6, r3c7, r3c8, r3c9, r3c10, r3c11, r3c12, r3c13, r3c14, r3c15, xxx, r3c17, r3c18, xxx, r3c20, \ r3c0, XXX, r3c2, r3c3, r3c4, r3c5, r3c6, r3c7, r3c8, r3c9, r3c10, r3c11, r3c12, r3c13, r3c14, r3c15, XXX, r3c17, r3c18, XXX, r3c20, \
r4c0, r4c1, r4c2, r4c3, xxx, r4c5, r4c6, r4c7, r4c8, r4c9, r4c10, r4c11, r4c12, r4c13, r4c14, r4c15, xxx, r4c17, r4c18, r4c19, r4c20, \ r4c0, r4c1, r4c2, r4c3, XXX, r4c5, r4c6, r4c7, r4c8, r4c9, r4c10, r4c11, r4c12, r4c13, r4c14, r4c15, XXX, r4c17, r4c18, r4c19, r4c20, \
r5c0, r5c1, r5c2, r5c3, xxx, xxx, xxx, xxx, xxx, r5c9, xxx, xxx, xxx, xxx, xxx, xxx, r5c15, xxx, r5c17, r5c18, RESTRICT_ARGS_COUNT((r5c19), 99, KEYMAP, ##__VA_ARGS__) r5c0, r5c1, r5c2, r5c3, XXX, XXX, XXX, XXX, XXX, r5c9, XXX, XXX, XXX, XXX, XXX, XXX, r5c15, XXX, r5c17, r5c18, r5c19
#endif #endif

Loading…
Cancel
Save