diff --git a/keyboards/claw44_ble/board/custom_board.h b/keyboards/claw44_ble/board/custom_board.h new file mode 100644 index 000000000000..e79d0d0a32ea --- /dev/null +++ b/keyboards/claw44_ble/board/custom_board.h @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2014 - 2017, Nordic Semiconductor ASA + * Copyright (c) 2018, Sekigon + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form, except as embedded into a Nordic + * Semiconductor ASA integrated circuit in a product or a software update for + * such product, must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * 3. Neither the name of Nordic Semiconductor ASA nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * 4. This software, with or without modification, must only be used with a + * Nordic Semiconductor ASA integrated circuit. + * + * 5. Any software provided in binary form under this license must not be reverse + * engineered, decompiled, modified and/or disassembled. + * + * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef CUSTOM_BOARD_H +#define CUSTOM_BOARD_H + +#ifdef __cplusplus +extern "C" { +#endif + +//#include "nrf_gpio.h" + +#define GPIO(port, pin) ((port << 6) | pin) +#define PIN1 GPIO(0,8) +#define PIN2 GPIO(0,11) +#define PIN5 GPIO(0,18) +#define PIN6 GPIO(0,16) +#define PIN7 GPIO(0,19) +#define PIN8 GPIO(0,20) +#define PIN9 GPIO(0,22) +#define PIN10 GPIO(0,23) +#define PIN11 GPIO(1,0) +#define PIN12 GPIO(1,3) + +#define PIN13 GPIO(0,9) +#define PIN14 GPIO(0,10) +#define PIN15 GPIO(1,15) +#define PIN16 GPIO(1,14) +#define PIN17 GPIO(0,3) +#define PIN18 GPIO(0,30) +#define PIN19 GPIO(0,0) +#define PIN20 GPIO(0,5) +//#define NRF_LOG_ENABLED 0 +//#define NRF_LOG_BACKEND_SERIAL_USES_UART 0 +//#define NRF_LOG_BACKEND_SERIAL_UART_TX_PIN 5 +#define NRF_LOG_BACKEND_UART_TX_PIN 8 +//#define DEBUG +// Low frequency clock source to be used by the SoftDevice +#ifdef S210 +// #define NRF_CLOCK_LFCLKSRC NRF_CLOCK_LFCLKSRC_XTAL_20_PPM +#else +#define NRF_CLOCK_LFCLKSRC {.source = NRF_CLOCK_LF_SRC_RC, \ + .rc_ctiv = 16, \ + .rc_temp_ctiv = 2, \ + .xtal_accuracy = 0} +#endif + +#ifdef __cplusplus +} +#endif + +#endif // CUSTOM_BOARD_H diff --git a/keyboards/claw44_ble/claw44_ble.c b/keyboards/claw44_ble/claw44_ble.c new file mode 100644 index 000000000000..38708fd1f4d1 --- /dev/null +++ b/keyboards/claw44_ble/claw44_ble.c @@ -0,0 +1 @@ +#include "claw44_ble.h" diff --git a/keyboards/claw44_ble/claw44_ble.h b/keyboards/claw44_ble/claw44_ble.h new file mode 100644 index 000000000000..107130d7b70a --- /dev/null +++ b/keyboards/claw44_ble/claw44_ble.h @@ -0,0 +1,31 @@ +#include "quantum.h" + +#define LAYOUT( \ + L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ + L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ + L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ + L30, L31, L32, L33, R30, R31, R32, R33 \ + ) \ + { \ + { L00, L01, L02, L03, L04, L05 }, \ + { L10, L11, L12, L13, L14, L15 }, \ + { L20, L21, L22, L23, L24, L25 }, \ + { KC_NO, KC_NO, L30, L31, L32, L33 }, \ + { R05, R04, R03, R02, R01, R00 }, \ + { R15, R14, R13, R12, R11, R10 }, \ + { R25, R24, R23, R22, R21, R20 }, \ + { KC_NO, KC_NO, R33, R32, R31, R30 } \ + } + +#define LAYOUT_kc( \ + L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ + L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ + L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ + L30, L31, L32, L33, R30, R31, R32, R33 \ + ) \ + LAYOUT( \ + KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \ + KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ + KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ + KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##R30, KC_##R31, KC_##R32, KC_##R33 \ + ) diff --git a/keyboards/claw44_ble/config.h b/keyboards/claw44_ble/config.h new file mode 100644 index 000000000000..7713772d5b14 --- /dev/null +++ b/keyboards/claw44_ble/config.h @@ -0,0 +1,82 @@ +/* +Copyright 2012 Jun Wako +Copyright 2015 Jack Humbert +Copyright 2017 Biacco42 +Copyright 2018 Sekigon + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#define BLE_NUS_MIN_INTERVAL 30 +#define BLE_NUS_MAX_INTERVAL 70 + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFC51 +#define PRODUCT_ID 0x0058 +#define DEVICE_VER 0x0100 +#define MANUFACTURER @yfuku_ +#define PRODUCT Claw44 BLE +#define DESCRIPTION Claw44 is 6x3+4keys column-staggered split keyboard. + +/* key matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 6 + +#define DIODE_DIRECTION COL2ROW + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 1 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +#define TAPPING_TERM 180 +#define IGNORE_MOD_TAP_INTERRUPT + +//#define RGBLIGHT_ANIMATIONS +//#define RGB_DI_PIN 8 // The pin the LED strip is connected to +//#define RGBLED_NUM 5 // Number of LEDs in your strip + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboards/claw44_ble/keymaps/default/keymap.c b/keyboards/claw44_ble/keymaps/default/keymap.c new file mode 100644 index 000000000000..b1e368bdd663 --- /dev/null +++ b/keyboards/claw44_ble/keymaps/default/keymap.c @@ -0,0 +1,225 @@ +/* +Copyright 2018 Sekigon + +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 . +*/ + +#include QMK_KEYBOARD_H +#include "app_ble_func.h" + +enum custom_keycodes { + AD_WO_L = SAFE_RANGE, /* Start advertising without whitelist */ + BLE_DIS, /* Disable BLE HID sending */ + BLE_EN, /* Enable BLE HID sending */ + USB_DIS, /* Disable USB HID sending */ + USB_EN, /* Enable USB HID sending */ + DELBNDS, /* Delete all bonding */ + ADV_ID0, /* Start advertising to PeerID 0 */ + ADV_ID1, /* Start advertising to PeerID 1 */ + ADV_ID2, /* Start advertising to PeerID 2 */ + ADV_ID3, /* Start advertising to PeerID 3 */ + ADV_ID4, /* Start advertising to PeerID 4 */ + BATT_LV, /* Display battery level in milli volts */ + DEL_ID0, /* Delete bonding of PeerID 0 */ + DEL_ID1, /* Delete bonding of PeerID 1 */ + DEL_ID2, /* Delete bonding of PeerID 2 */ + DEL_ID3, /* Delete bonding of PeerID 3 */ + DEL_ID4, /* Delete bonding of PeerID 4 */ + ENT_DFU, /* Start bootloader */ + ENT_SLP, /* Deep sleep mode */ + QWERTY, + COLEMAK, + DVORAK, + LOWER, + RAISE, + ADJUST, + //BACKLIT, + //EISU, + //KANA, + //RGBRST +}; + + +extern keymap_config_t keymap_config; + +enum layer_number { + _QWERTY = 0, + _LOWER, + _RAISE, + _BLE, +}; + +#define _______ KC_TRNS +#define XXXXXXX KC_NO +#define KC_L_SPC LT(_LOWER, KC_SPC) // lower +#define KC_R_ENT LT(_RAISE, KC_ENT) // raise +#define KC_G_JA LGUI_T(KC_LANG1) // cmd or win +#define KC_G_EN LGUI_T(KC_LANG2) // cmd or win +#define KC_C_BS LCTL_T(KC_BSPC) // ctrl +#define KC_A_DEL ALT_T(KC_DEL) // alt +#define KC_B_DEL LT(_BLE, KC_DEL) // ble + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [_QWERTY] = LAYOUT( \ + //,--------+--------+---------+--------+---------+--------. ,--------+---------+--------+---------+--------+--------. + KC_ESC , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_MINS, + //|--------+--------+---------+--------+---------+--------| |--------+---------+--------+---------+--------+--------| + KC_TAB , 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_RSFT, + //`--------+--------+---------+--------+---------+--------/ \--------+---------+--------+---------+--------+--------' + KC_B_DEL, KC_G_EN, KC_L_SPC, KC_C_BS, KC_C_BS, KC_R_ENT, KC_G_JA, KC_A_DEL + // `----------+--------+---------+--------' `--------+---------+--------+---------' + ), + + [_RAISE] = LAYOUT( \ + //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------. + _______, KC_BSLS, KC_CIRC, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT , KC_EQL , KC_PLUS, KC_ASTR, KC_PERC, KC_MINS, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + KC_LPRN, KC_HASH, KC_DLR , KC_DQT , KC_QUOT, KC_TILD, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT, KC_GRV , KC_RPRN, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, KC_LCBR, KC_LBRC, KC_RBRC, KC_RCBR, _______, _______, _______, _______, + //`--------+--------+--------+--------+--------+--------/ \--------+--------+--------+--------+--------+--------' + _______, _______, _______, _______, _______, _______, _______, RESET + // `--------+--------+--------+--------' `--------+--------+--------+--------' + ), + + [_LOWER] = LAYOUT( \ + //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------. + KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , _______, KC_EQL , KC_PLUS, KC_ASTR, KC_PERC, KC_MINS, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , _______, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , _______, _______, KC_COMM, KC_DOT , KC_SLSH, _______, + //`--------+--------+--------+--------+--------+--------/ \--------+--------+--------+--------+--------+--------' + RESET , _______, _______, _______, _______, _______, _______, _______ + // `--------+--------+--------+--------' `--------+--------+--------+--------' + ), + + [_BLE] = LAYOUT( \ + //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------. + AD_WO_L ,ADV_ID1 ,ADV_ID2 ,ADV_ID3 ,ADV_ID4 ,XXXXXXX , _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + ENT_SLP ,ENT_DFU ,XXXXXXX ,XXXXXXX ,USB_DIS ,USB_EN , _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + BATT_LV ,DEL_ID1 ,XXXXXXX ,XXXXXXX ,BLE_DIS ,BLE_EN , _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______ + // `--------+--------+--------+--------' `--------+--------+--------+--------' + ) +}; + +size_t sizeof_keymaps() { + return sizeof(keymaps); +} + +// define variables for reactive RGB +bool TOG_STATUS = false; +int RGB_current_mode; +#ifdef RGBLIGHT_ENABLE +//Following line allows macro to read current RGB settings +extern rgblight_config_t rgblight_config; +#endif + +void persistent_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); + layer_state_set(default_layer); +} + +// Setting ADJUST layer RGB back to default +void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { + if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { + #ifdef RGBLIGHT_ENABLE + //rgblight_mode(RGB_current_mode); + #endif + layer_on(layer3); + } else { + layer_off(layer3); + } +} +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + char str[16]; + + if (record->event.pressed) { + switch (keycode) { + case DELBNDS: + delete_bonds(); + return false; + case AD_WO_L: + restart_advertising_wo_whitelist(); + return false; + case USB_EN: + set_usb_enabled(true); + return false; + break; + case USB_DIS: + set_usb_enabled(false); + return false; + break; + case BLE_EN: + set_ble_enabled(true); + return false; + break; + case BLE_DIS: + set_ble_enabled(false); + return false; + break; + case ADV_ID0: + restart_advertising_id(0); + return false; + case ADV_ID1: + restart_advertising_id(1); + return false; + case ADV_ID2: + restart_advertising_id(2); + return false; + case ADV_ID3: + restart_advertising_id(3); + return false; + case ADV_ID4: + restart_advertising_id(4); + return false; + case DEL_ID0: + delete_bond_id(0); + return false; + case DEL_ID1: + delete_bond_id(1); + return false; + case DEL_ID2: + delete_bond_id(2); + return false; + case DEL_ID3: + delete_bond_id(3); + return false; + case BATT_LV: + sprintf(str, "%4dmV", get_vcc()); + send_string(str); + return false; + case ENT_DFU: + bootloader_jump(); + return false; + } + } + else if (!record->event.pressed) { + switch (keycode) { + case ENT_SLP: + sleep_mode_enter(); + return false; + } + } + return true; +} +; diff --git a/keyboards/claw44_ble/keymaps/yfuku/keymap.c b/keyboards/claw44_ble/keymaps/yfuku/keymap.c new file mode 100644 index 000000000000..347f7b03922f --- /dev/null +++ b/keyboards/claw44_ble/keymaps/yfuku/keymap.c @@ -0,0 +1,279 @@ +/* +Copyright 2018 Sekigon + +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 . +*/ + +#include QMK_KEYBOARD_H +#include "app_ble_func.h" + +enum custom_keycodes { + AD_WO_L = SAFE_RANGE, /* Start advertising without whitelist */ + BLE_DIS, /* Disable BLE HID sending */ + BLE_EN, /* Enable BLE HID sending */ + USB_DIS, /* Disable USB HID sending */ + USB_EN, /* Enable USB HID sending */ + DELBNDS, /* Delete all bonding */ + ADV_ID0, /* Start advertising to PeerID 0 */ + ADV_ID1, /* Start advertising to PeerID 1 */ + ADV_ID2, /* Start advertising to PeerID 2 */ + ADV_ID3, /* Start advertising to PeerID 3 */ + ADV_ID4, /* Start advertising to PeerID 4 */ + BATT_LV, /* Display battery level in milli volts */ + DEL_ID0, /* Delete bonding of PeerID 0 */ + DEL_ID1, /* Delete bonding of PeerID 1 */ + DEL_ID2, /* Delete bonding of PeerID 2 */ + DEL_ID3, /* Delete bonding of PeerID 3 */ + DEL_ID4, /* Delete bonding of PeerID 4 */ + ENT_DFU, /* Start bootloader */ + ENT_SLP, /* Deep sleep mode */ + QWERTY, + COLEMAK, + DVORAK, + LOWER, + RAISE, + ADJUST, + //BACKLIT, + //EISU, + //KANA, + //RGBRST +}; + + +extern keymap_config_t keymap_config; + +enum layer_number { + _QWERTY = 0, + _LOWER, + _RAISE, + _BLE, +}; + +// common +#define KC_ KC_TRNS +#define KC_XXXX KC_NO +#define KC_RST RESET +#define KC_VD KC__VOLDOWN +#define KC_VU KC__VOLUP + +// layer +#define KC_L_SPC LT(_LOWER, KC_SPC) +#define KC_R_ENT LT(_RAISE, KC_ENT) + +// shift_t +#define KC_S_TAB LSFT_T(KC_TAB) +#define KC_S_ESC LSFT_T(KC_ESC) +#define KC_S_JA LSFT_T(KC_LANG1) +#define KC_S_EN LSFT_T(KC_LANG2) + +// cmd_t +#define KC_M_F LCMD_T(KC_F) +#define KC_M_D LCMD_T(KC_D) +#define KC_M_J RCMD_T(KC_J) +#define KC_M_K RCMD_T(KC_K) + +// ctl_t +#define KC_C_G LCTL_T(KC_G) +#define KC_C_S LCTL_T(KC_S) +#define KC_C_L RCTL_T(KC_L) +#define KC_C_H RCTL_T(KC_H) +#define KC_C_BS LCTL_T(KC_BSPC) + +// alt_t +#define KC_A_D ALT_T(KC_D) +#define KC_A_K ALT_T(KC_K) +#define KC_A_Z ALT_T(KC_Z) +#define KC_A_SL ALT_T(KC_SLSH) +#define KC_A_DEL ALT_T(KC_DEL) + +// cmd+shift_t +#define KC_MS_Q SCMD_T(KC_Q) +#define KC_MS_A SCMD_T(KC_A) +#define KC_MS_S SCMD_T(KC_S) +#define KC_MS_SC SCMD_T(KC_SCLN) +#define KC_MS_ESC SCMD_T(KC_ESC) + +// ble +#define KC_BLE MO(_BLE) +#define KC_AD_WO_L AD_WO_L + +// +#define KC_MR RCMD(KC_R) +#define KC_MF RCMD(KC_F) +#define KC_MW RCMD(KC_W) +#define KC_MX RCMD(KC_X) +#define KC_MC RCMD(KC_C) +#define KC_MV RCMD(KC_V) +#define KC_MTAB RCMD(KC_TAB) +#define KC_MSF RCMD(RSFT(KC_F)) +#define KC_MSR RCMD(RSFT(KC_R)) +#define KC_MST RCMD(RSFT(KC_T)) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [_QWERTY] = LAYOUT_kc( \ + //,----+----+----+----+----+----. ,----+----+----+----+----+----. + , Q , W , E , R , T , Y , U , I , O , P ,MINS, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + TAB, A , S , D ,M_F ,C_G , C_H ,M_J , K , L ,SCLN,ESC , + //|----+----+----+----+----+----+ |----+----+----+----+----+----| + BLE, Z , X , C , V , B , N , M ,COMM,DOT ,SLSH, , + //`----+----+----+----+----+----/ \----+----+----+----+----+----' + A_DEL,S_EN,L_SPC,C_BS, C_BS,R_ENT,S_JA,A_DEL + // `----+----+----+----' `----+----+----+----' + ), + + // \ ! & | = + * ^ + // # ` " ' ~ ← ↓ ↑ → $ + // { [ ( ) ] } @ + + [_RAISE] = LAYOUT_kc( \ + //,----+----+----+----+----+----. ,----+----+----+----+----+----. + ,BSLS,EXLM,AMPR,PIPE,XXXX, XXXX,EQL ,PLUS,ASTR,CIRC, , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + ,HASH,GRV ,DQT ,QUOT,TILD, LEFT,DOWN, UP ,RGHT,DLR , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , ,LCBR,LBRC,LPRN, RPRN,RBRC,RCBR,AT ,PERC, , + //`----+----+----+----+----+----/ \----+----+----+----+----+----' + , ,BSPC, , , , ,RST + // `----+----+----+----' `----+----+----+----' + ), + + [_LOWER] = LAYOUT_kc( \ + //,----+----+----+----+----+----. ,----+----+----+----+----+----. + , , ,MSF ,MSR ,MST , ,EQL ,PLUS,ASTR, ,MINS, + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 , , + //|----+----+----+----+----+----| |----+----+----+----+----+----| + , , , , , , ,PERC,COMM,DOT ,SLSH, , + //`----+----+----+--+-+----+----/ \----+----+----+----+----+----' + RST , , , , ,DEL , , + // `----+----+----+----' `----+----+----+----' + ), + + [_BLE] = LAYOUT( \ + //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------. + AD_WO_L ,ADV_ID1 ,ADV_ID2 ,ADV_ID3 ,ADV_ID4 ,XXXXXXX , _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + ENT_SLP ,ENT_DFU ,KC_B ,XXXXXXX ,USB_DIS ,USB_EN , _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______,BATT_LV ,DEL_ID1 ,XXXXXXX ,BLE_DIS ,BLE_EN , _______, _______, _______, _______, _______, _______, + //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| + _______, _______, _______, _______, _______, _______, _______, _______ + // `--------+--------+--------+--------' `--------+--------+--------+--------' + ) +}; + +size_t sizeof_keymaps() { + return sizeof(keymaps); +} + +// define variables for reactive RGB +bool TOG_STATUS = false; +int RGB_current_mode; +#ifdef RGBLIGHT_ENABLE +//Following line allows macro to read current RGB settings +extern rgblight_config_t rgblight_config; +#endif + +void persistent_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); + layer_state_set(default_layer); +} + +// Setting ADJUST layer RGB back to default +void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { + if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { + #ifdef RGBLIGHT_ENABLE + //rgblight_mode(RGB_current_mode); + #endif + layer_on(layer3); + } else { + layer_off(layer3); + } +} +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + char str[16]; + + if (record->event.pressed) { + switch (keycode) { + case DELBNDS: + delete_bonds(); + return false; + case AD_WO_L: + restart_advertising_wo_whitelist(); + return false; + case USB_EN: + set_usb_enabled(true); + return false; + break; + case USB_DIS: + set_usb_enabled(false); + return false; + break; + case BLE_EN: + set_ble_enabled(true); + return false; + break; + case BLE_DIS: + set_ble_enabled(false); + return false; + break; + case ADV_ID0: + restart_advertising_id(0); + return false; + case ADV_ID1: + restart_advertising_id(1); + return false; + case ADV_ID2: + restart_advertising_id(2); + return false; + case ADV_ID3: + restart_advertising_id(3); + return false; + case ADV_ID4: + restart_advertising_id(4); + return false; + case DEL_ID0: + delete_bond_id(0); + return false; + case DEL_ID1: + delete_bond_id(1); + return false; + case DEL_ID2: + delete_bond_id(2); + return false; + case DEL_ID3: + delete_bond_id(3); + return false; + case BATT_LV: + sprintf(str, "%4dmV", get_vcc()); + send_string(str); + return false; + case ENT_DFU: + bootloader_jump(); + return false; + } + } + else if (!record->event.pressed) { + switch (keycode) { + case ENT_SLP: + sleep_mode_enter(); + return false; + } + } + return true; +} +; diff --git a/keyboards/claw44_ble/ld/nrf52832_master.ld b/keyboards/claw44_ble/ld/nrf52832_master.ld new file mode 100644 index 000000000000..7f249f652826 --- /dev/null +++ b/keyboards/claw44_ble/ld/nrf52832_master.ld @@ -0,0 +1,28 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 + RAM (rwx) : ORIGIN = 0x20002798, LENGTH = 0xd868 +} + +SECTIONS +{ + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(.pwr_mgmt_data)) + PROVIDE(__stop_pwr_mgmt_data = .); + } > RAM +} INSERT AFTER .data; + +INCLUDE "nrf5x_common.ld" \ No newline at end of file diff --git a/keyboards/claw44_ble/ld/nrf52832_slave.ld b/keyboards/claw44_ble/ld/nrf52832_slave.ld new file mode 100644 index 000000000000..176ca93d9157 --- /dev/null +++ b/keyboards/claw44_ble/ld/nrf52832_slave.ld @@ -0,0 +1,28 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 + RAM (rwx) : ORIGIN = 0x20002128, LENGTH = 0xded8 +} + +SECTIONS +{ + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(.pwr_mgmt_data)) + PROVIDE(__stop_pwr_mgmt_data = .); + } > RAM +} INSERT AFTER .data; + +INCLUDE "nrf5x_common.ld" \ No newline at end of file diff --git a/keyboards/claw44_ble/ld/nrf52840.ld b/keyboards/claw44_ble/ld/nrf52840.ld new file mode 100644 index 000000000000..f778e79be9c3 --- /dev/null +++ b/keyboards/claw44_ble/ld/nrf52840.ld @@ -0,0 +1,117 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x26000, LENGTH = 0xda000 + RAM (rwx) : ORIGIN = 0x2000BC70, LENGTH = 0x34390 +} + +SECTIONS +{ +} + +SECTIONS +{ + . = ALIGN(4); + .mem_section_dummy_ram : + { + } + .log_dynamic_data : + { + PROVIDE(__start_log_dynamic_data = .); + KEEP(*(SORT(.log_dynamic_data*))) + PROVIDE(__stop_log_dynamic_data = .); + } > RAM + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + .cli_sorted_cmd_ptrs : + { + PROVIDE(__start_cli_sorted_cmd_ptrs = .); + KEEP(*(.cli_sorted_cmd_ptrs)) + PROVIDE(__stop_cli_sorted_cmd_ptrs = .); + } > RAM + +} INSERT AFTER .data; + +SECTIONS +{ + .mem_section_dummy_rom : + { + } + .sdh_soc_observers : + { + PROVIDE(__start_sdh_soc_observers = .); + KEEP(*(SORT(.sdh_soc_observers*))) + PROVIDE(__stop_sdh_soc_observers = .); + } > FLASH + .sdh_ble_observers : + { + PROVIDE(__start_sdh_ble_observers = .); + KEEP(*(SORT(.sdh_ble_observers*))) + PROVIDE(__stop_sdh_ble_observers = .); + } > FLASH + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(SORT(.pwr_mgmt_data*))) + PROVIDE(__stop_pwr_mgmt_data = .); + } > FLASH + .log_const_data : + { + PROVIDE(__start_log_const_data = .); + KEEP(*(SORT(.log_const_data*))) + PROVIDE(__stop_log_const_data = .); + } > FLASH + .nrf_balloc : + { + PROVIDE(__start_nrf_balloc = .); + KEEP(*(.nrf_balloc)) + PROVIDE(__stop_nrf_balloc = .); + } > FLASH + .sdh_state_observers : + { + PROVIDE(__start_sdh_state_observers = .); + KEEP(*(SORT(.sdh_state_observers*))) + PROVIDE(__stop_sdh_state_observers = .); + } > FLASH + .sdh_stack_observers : + { + PROVIDE(__start_sdh_stack_observers = .); + KEEP(*(SORT(.sdh_stack_observers*))) + PROVIDE(__stop_sdh_stack_observers = .); + } > FLASH + .sdh_req_observers : + { + PROVIDE(__start_sdh_req_observers = .); + KEEP(*(SORT(.sdh_req_observers*))) + PROVIDE(__stop_sdh_req_observers = .); + } > FLASH + .nrf_queue : + { + PROVIDE(__start_nrf_queue = .); + KEEP(*(.nrf_queue)) + PROVIDE(__stop_nrf_queue = .); + } > FLASH + .cli_command : + { + PROVIDE(__start_cli_command = .); + KEEP(*(.cli_command)) + PROVIDE(__stop_cli_command = .); + } > FLASH + .crypto_data : + { + PROVIDE(__start_crypto_data = .); + KEEP(*(SORT(.crypto_data*))) + PROVIDE(__stop_crypto_data = .); + } > FLASH + +} INSERT AFTER .text + +INCLUDE "nrf_common.ld" \ No newline at end of file diff --git a/keyboards/claw44_ble/ld/nrf52840_master.ld b/keyboards/claw44_ble/ld/nrf52840_master.ld new file mode 100644 index 000000000000..7f249f652826 --- /dev/null +++ b/keyboards/claw44_ble/ld/nrf52840_master.ld @@ -0,0 +1,28 @@ +/* Linker script to configure memory regions. */ + +SEARCH_DIR(.) +GROUP(-lgcc -lc -lnosys) + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x1f000, LENGTH = 0x61000 + RAM (rwx) : ORIGIN = 0x20002798, LENGTH = 0xd868 +} + +SECTIONS +{ + .fs_data : + { + PROVIDE(__start_fs_data = .); + KEEP(*(.fs_data)) + PROVIDE(__stop_fs_data = .); + } > RAM + .pwr_mgmt_data : + { + PROVIDE(__start_pwr_mgmt_data = .); + KEEP(*(.pwr_mgmt_data)) + PROVIDE(__stop_pwr_mgmt_data = .); + } > RAM +} INSERT AFTER .data; + +INCLUDE "nrf5x_common.ld" \ No newline at end of file diff --git a/keyboards/claw44_ble/master/config.h b/keyboards/claw44_ble/master/config.h new file mode 100644 index 000000000000..b3a0a2377cf9 --- /dev/null +++ b/keyboards/claw44_ble/master/config.h @@ -0,0 +1,13 @@ +#ifndef MASTER_CONFIG_H_ +#define MASTER_CONFIG_H_ + +#include "custom_board.h" + +#define THIS_DEVICE_ROWS 4 +#define THIS_DEVICE_COLS 6 + +#define MATRIX_ROW_PINS { PIN7, PIN8, PIN9, PIN10 } +#define MATRIX_COL_PINS { PIN20, PIN19, PIN18, PIN17, PIN16, PIN15 } +#define IS_LEFT_HAND true + +#endif /* MASTER_CONFIG_H_ */ diff --git a/keyboards/claw44_ble/master/master.c b/keyboards/claw44_ble/master/master.c new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/keyboards/claw44_ble/master/master.h b/keyboards/claw44_ble/master/master.h new file mode 100644 index 000000000000..f175d34b0d11 --- /dev/null +++ b/keyboards/claw44_ble/master/master.h @@ -0,0 +1,5 @@ +#ifndef KEYBOARDS_CLAW44_BLE_MASTER_MASTER_H_ +#define KEYBOARDS_CLAW44_BLE_MASTER_MASTER_H_ + + +#endif /* KEYBOARDS_CLAW44_BLE_MASTER_MASTER_H_ */ diff --git a/keyboards/claw44_ble/master/rules.mk b/keyboards/claw44_ble/master/rules.mk new file mode 100644 index 000000000000..e68135da43af --- /dev/null +++ b/keyboards/claw44_ble/master/rules.mk @@ -0,0 +1,13 @@ + +RGBLIGHT_ENABLE = no + +# it should exist either in /ld/ +MCU_LDSCRIPT = nrf52840 +MCU_SERIES = NRF52840 +NRFSDK_ROOT := $(NRFSDK15_ROOT) #Path to nRF SDK v15.0.0 + +# project specific files +#SRC = matrix.c + +NRF_SEPARATE = master +#CFLAGS += -DNRF_XTAL_32MHZ diff --git a/keyboards/claw44_ble/rules.mk b/keyboards/claw44_ble/rules.mk new file mode 100644 index 000000000000..7b975f5a3afb --- /dev/null +++ b/keyboards/claw44_ble/rules.mk @@ -0,0 +1,35 @@ + +DEFAULT_FOLDER = claw44_ble/master + +NRF_DEBUG = no + +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 = no # USB Nkey Rollover +CUSTOM_MATRIX = yes # This flag should be on for nrf52 + +## chip/board settings +MCU_FAMILY = NRF52 +# linker script to use +# 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 +ARMV = 7 +# If you want to be able to jump to bootloader from firmware on STM32 MCUs, +# set the correct BOOTLOADER_ADDRESS. Either set it here, or define it in +# ./bootloader_defs.h or in ./boards//bootloader_defs.h (if you have +# a custom board definition that you plan to reuse). +# If you're not setting it here, leave it commented out. +# It is chip dependent, the correct number can be looked up here (page 175): +# http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf +# This also requires a patch to chibios: +# /tmk_core/tool/chibios/ch-bootloader-jump.patch +#STM32_BOOTLOADER_ADDRESS = 0x1FFFC800 + +# Build Options +# comment out to disable the options. +# diff --git a/keyboards/claw44_ble/slave/config.h b/keyboards/claw44_ble/slave/config.h new file mode 100644 index 000000000000..54ca2c40abb5 --- /dev/null +++ b/keyboards/claw44_ble/slave/config.h @@ -0,0 +1,13 @@ +#ifndef KEYBOARDS_NRF52_SEPARATE_TEST_ +#define KEYBOARDS_NRF52_SEPARATE_TEST_ + +#include "custom_board.h" + +#define THIS_DEVICE_ROWS 4 +#define THIS_DEVICE_COLS 6 + +#define MATRIX_ROW_PINS { PIN7, PIN8, PIN9, PIN10 } +#define MATRIX_COL_PINS { PIN20, PIN19, PIN18, PIN17, PIN16, PIN15 } +#define IS_LEFT_HAND false + +#endif /* KEYBOARDS_NRF52_SEPARATE_TEST_ */ diff --git a/keyboards/claw44_ble/slave/rules.mk b/keyboards/claw44_ble/slave/rules.mk new file mode 100644 index 000000000000..b9e3e62c662d --- /dev/null +++ b/keyboards/claw44_ble/slave/rules.mk @@ -0,0 +1,10 @@ + +# it should exist either in /ld/ +MCU_LDSCRIPT = nrf52840 +MCU_SERIES = NRF52840 +NRFSDK_ROOT := $(NRFSDK15_ROOT) #Path to nRF SDK v15.0.0 +#MCU_LDSCRIPT = nrf52832_slave + +# project specific files +#SRC = matrix.c +NRF_SEPARATE = slave \ No newline at end of file diff --git a/keyboards/claw44_ble/slave/slave.c b/keyboards/claw44_ble/slave/slave.c new file mode 100644 index 000000000000..91fb7963f3fa --- /dev/null +++ b/keyboards/claw44_ble/slave/slave.c @@ -0,0 +1,50 @@ +/* +Copyright 2018 Sekigon + +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 . +*/ + +#include "matrix.h" + +#include "wait.h" +#include "app_ble_func.h" +#include "bootloader.h" + +#include "nrf_power.h" +#include "nrf.h" + +void unselect_rows(void); +void select_row(uint8_t row); +matrix_row_t read_cols(void); + +static bool bootloader_flag = false; + +void matrix_init_user() { + select_row(0); + wait_us(50); + matrix_row_t row = read_cols(); + unselect_rows(); + if (row == 0b11100) { + delete_bonds(); + } else if (row == 0b10) { + bootloader_flag = true; + } +} + +void matrix_scan_user() { + static int cnt; + if (bootloader_flag && cnt++==500) { + bootloader_jump(); + } +} diff --git a/keyboards/claw44_ble/slave/slave.h b/keyboards/claw44_ble/slave/slave.h new file mode 100644 index 000000000000..0903a85003ef --- /dev/null +++ b/keyboards/claw44_ble/slave/slave.h @@ -0,0 +1,5 @@ +#ifndef KEYBOARDS_CLAW44_BLE_SLAVE_SLAVE_H_ +#define KEYBOARDS_CLAW44_BLE_SLAVE_SLAVE_H_ + + +#endif /* KEYBOARDS_CLAW44_BLE_SLAVE_SLAVE_H_ */