This commit is contained in:
Retic1337 2021-11-14 15:34:24 -08:00
parent 28cce575fa
commit e528263ebc
16 changed files with 422 additions and 50 deletions

Binary file not shown.

View file

@ -0,0 +1,8 @@
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py
-c
-b 0x00026000
-f 0xADA52840
-o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2
${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin
)

View file

@ -0,0 +1,7 @@
# nRF52840-KEYBOARD board configuration
config BOARD_ENABLE_DCDC
bool "Enable DCDC mode"
select SOC_DCDC_NRF52X
default y
depends on BOARD_RETIC1337_BTCTRL

View file

@ -0,0 +1,5 @@
# nRF52840-KEYBOARD board configuration
config BOARD_RETIC1337_BTCTRL
bool "Retic1337_btctrl"
depends on SOC_NRF52840_QIAA

View file

@ -0,0 +1,30 @@
# Retic1337_BTCTRL board configuration
if BOARD_RETIC1337_BTCTRL
config BOARD
default "BTCTRL"
config ZMK_KEYBOARD_NAME
default "REtic1337_BTCTRL"
if USB
config USB_NRFX
default y
config USB_DEVICE_STACK
default y
endif # USB
config BT_CTLR
default BT
config ZMK_BLE
default y
config ZMK_USB
default y
endif # BOARD_RETIC1337_BTCTRL

View file

@ -0,0 +1,208 @@
/*
* Cameron Banna 2020
*/
/dts-v1/;
#include <nordic/nrf52840_qiaa.dtsi>
/ {
model = "Retic1337_btctrl";
compatible = "nice,nano";
chosen {
zephyr,i2c0 = &i2c0;
zephyr,i2c_0 = &i2c0;
zephyr,i2c1 = &i2c1;
zephyr,i2c_1 = &i2c1;
zephyr,code-partition = &code_partition;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zmk,kscan = &kscan0;
};
kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
row-gpios
= <&gpio1 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&gpio1 12 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&gpio1 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&gpio1 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&gpio1 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&gpio1 11 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
;
col-gpios
= <&gpio1 6 (GPIO_ACTIVE_LOW)>
, <&gpio0 5 (GPIO_ACTIVE_LOW)>
, <&gpio0 4 (GPIO_ACTIVE_LOW)>
, <&gpio0 29 (GPIO_ACTIVE_LOW)>
, <&gpio0 28 (GPIO_ACTIVE_LOW)>
, <&gpio0 7 (GPIO_ACTIVE_LOW)>
, <&gpio1 8 (GPIO_ACTIVE_LOW)>
, <&gpio0 15 (GPIO_ACTIVE_LOW)>
, <&gpio1 2 (GPIO_ACTIVE_LOW)>
, <&gpio0 8 (GPIO_ACTIVE_LOW)>
, <&gpio0 6 (GPIO_ACTIVE_LOW)>
, <&gpio0 31 (GPIO_ACTIVE_LOW)>
, <&gpio0 30 (GPIO_ACTIVE_LOW)>
, <&gpio1 3 (GPIO_ACTIVE_LOW)>
, <&gpio1 4 (GPIO_ACTIVE_LOW)>
, <&gpio0 25 (GPIO_ACTIVE_LOW)>
;
};
left_encoder: encoder_left {
compatible = "alps,ec11";
label = "LEFT_ENCODER";
a-gpios = <&gpio0 17 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&gpio0 22 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
resolution = <4>;
};
sensors {
compatible = "zmk,keymap-sensors";
sensors = <&left_encoder>;
};
ext-power {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
control-gpios = <&gpio0 3 (GPIO_ACTIVE_LOW | GPIO_PULL_DOWN)>;
};
leds {
compatible = "gpio-leds";
led0_blue: led_0 {
gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
label = "Blue LED 0";
};
};
pwmleds {
compatible = "pwm-leds";
pwm_led0_blue: pwm_led_0 {
pwms = <&pwm0 23>;
label = "Blue PWM LED 0";
};
};
/* These aliases are provided for compatibility with samples */
aliases {
led0 = &led0_blue;
led0-blue = &led0_blue;
pwm-led0 = &pwm_led0_blue;
blue-pwm-led = &pwm_led0_blue;
i2c0 = &i2c0;
i2c1 = &i2c1;
};
};
&adc {
status = "okay";
};
&gpiote {
status = "okay";
};
&gpio0 {
status = "okay";
};
&gpio1 {
status = "okay";
};
&i2c0 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <10>;
scl-pin = <9>;
clock-frequency = < I2C_BITRATE_FAST >;
is31fl3733a: is31fl3733@50 {
compatible = "issi,is31fl3733";
label = "IS31FL3733A";
reg = <0x50>;
};
is31fl3733b: is31fl3733@53 {
compatible = "issi,is31fl3733";
label = "IS31FL3733B";
reg = <0x53>;
};
};
&i2c1 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <33>;
scl-pin = <37>;
clock-frequency = < I2C_BITRATE_STANDARD >;
bq27441@55 {
compatible = "ti,bq274xx";
label = "BATTERY";
reg = <0x55>;
design-voltage = <3700>;
design-capacity = <450>;
taper-current = <45>;
terminate-voltage = <3000>;
};
};
&uart0 {
compatible = "nordic,nrf-uarte";
status = "okay";
current-speed = <115200>;
tx-pin = <19>;
rx-pin = <21>;
};
&pwm0 {
status = "okay";
ch0-pin = <41>;
ch0-inverted;
};
&flash0 {
/*
* For more information, see:
* http://docs.zephyrproject.org/latest/devices/dts/flash_partitions.html
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
sd_partition: partition@0 {
label = "softdevice";
reg = <0x00000000 0x00026000>;
};
code_partition: partition@26000 {
label = "code_partition";
reg = <0x00026000 0x000c6000>;
};
/*
* The flash starting at 0x000ec000 and ending at
* 0x000f3fff is reserved for use by the application.
*/
/*
* Storage partition will be used by FCB/LittleFS/NVS
* if enabled.
*/
storage_partition: partition@ec000 {
label = "storage";
reg = <0x000ec000 0x00008000>;
};
boot_partition: partition@f4000 {
label = "adafruit_boot";
reg = <0x000f4000 0x0000c000>;
};
};
};
&usbd {
compatible = "nordic,nrf-usbd";
status = "okay";
};

View file

@ -0,0 +1,46 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
/ {
ledmap {
compatible = "zmk,ledmap";
num_of_led = <108>;
ledmap = <1 0 3 5 7 9 11 13 15 65 0 67 69 71 73 75 77 79
17 20 22 24 26 28 30 80 81 82 83 84 85 0 86 87 88 90
19 21 23 25 27 29 31 96 98 100 102 104 106 0 108 109 110 92
34 36 38 40 42 44 46 97 99 101 103 105 0 0 107 0 0 0
35 0 37 39 41 43 45 47 112 113 114 115 0 0 119 0 111 0
49 51 53 0 0 0 0 57 0 0 0 62 116 118 121 123 125 127>;
};
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&kp ESC &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp PRSC &bt BT_CLR &kp C_PLAY_PAUSE
&kp TILDE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp EQUAL &kp BSPC &kp INS &kp HOME
&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH &kp DELETE &kp END
&kp CLCK &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT &kp RET &none &kp PG_UP &none
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &none &kp RSHFT &none &kp UP &kp PG_DN
&kp LCTRL &kp LGUI &kp LALT &none &none &kp SPACE &none &none &none &kp RALT &none &kp RGUI &kp RCTRL &kp LEFT &kp DOWN &kp RIGHT
>;
sensor-bindings = <&inc_dec_kp C_VOL_DN C_VOL_UP >;
};
};
};

View file

@ -0,0 +1,16 @@
identifier: RETIC1337_BTCTRL
name: Retic1337_BTCTRL
type: keyboard
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- adc
- usb_device
- ble
- ieee802154
- pwm
- watchdog

View file

@ -0,0 +1,9 @@
file_format: "1"
id: Retic1337_BTCTRL
name: Retic1337_BTCTRL
type: board
arch: arm
outputs:
- usb
- ble
url: https://nicekeyboards.com/nice-nano

View file

@ -0,0 +1,48 @@
CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52840_QIAA=y
CONFIG_BOARD_RETIC1337_BTCTRL=y
# Enable MPU
CONFIG_ARM_MPU=y
# enable GPIO
CONFIG_GPIO=y
CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_NVS=y
CONFIG_SETTINGS_NVS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
# Turn on logging, and set ZMK logging to debug output
CONFIG_LOG=y
CONFIG_ZMK_LOG_LEVEL_DBG=y
CONFIG_ZMK_USB_LOGGING=y
# additional board options
CONFIG_GPIO_AS_PINRESET=y
CONFIG_EC11=y
CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y
#I2C
CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_I2C_0=y
CONFIG_I2C_1=y
CONFIG_I2C_INIT_PRIORITY=60
CONFIG_IS31FL3733=y
CONFIG_SENSOR=y
CONFIG_BQ274XX=y
CONFIG_ZMK_IDLE_TIMEOUT=3000
CONFIG_ZMK_SLEEP=y
CONFIG_PM_DEVICE=y
CONFIG_ZMK_IDLE_SLEEP_TIMEOUT=10000
CONFIG_ZMK_EXT_POWER=y
CONFIG_DEVICE_POWER_MANAGEMENT=y
CONFIG_BT_CTLR_TX_PWR_PLUS_8=y

View file

@ -0,0 +1,3 @@
board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset")
include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake)
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)

View file

@ -0,0 +1,14 @@
# [Makerdiary M60](https://wiki.makerdiary.com/m60)
A 60% ANSI keyboard designed and manufactured by Makerdiary.
http://makerdiary.com
## Features
- Per key RGB LED.
- Uses makerdiary M.2 nRF52840 module
- Matrix wiring
## Hardware Notes
https://wiki.makerdiary.com/m60/developer_guide/hardware/

View file

@ -20,7 +20,7 @@
leds { leds {
compatible = "gpio-leds"; compatible = "gpio-leds";
blue_led: led_0 { blue_led: led_0 {
gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>; gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;
label = "Blue LED"; label = "Blue LED";
}; };
}; };

View file

@ -7,7 +7,7 @@
/ { / {
model = "retic1337_tkl"; model = "retic1337_tkl";
compatible = "nordic,pca10056-dk"; compatible = "nice,nano";
chosen { chosen {
zephyr,console = &uart0; zephyr,console = &uart0;
@ -55,23 +55,11 @@
, <&gpio1 7 GPIO_ACTIVE_HIGH> , <&gpio1 7 GPIO_ACTIVE_HIGH>
, <&gpio0 23 GPIO_ACTIVE_HIGH> , <&gpio0 23 GPIO_ACTIVE_HIGH>
; ;
};
encoder: encoder {
compatible = "alps,ec11";
label = "ENCODER";
a-gpios = <&gpio0 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&gpio0 17 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
resolution = <2>;
status = "disabled";
}; };
ext-power { ext-power {
compatible = "zmk,ext-power-generic"; compatible = "zmk,ext-power-generic";
label = "EXT_POWER"; label = "EXT_POWER";
control-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; control-gpios = <&gpio1 4 (GPIO_ACTIVE_HIGH)>;
};
sensors {
compatible = "zmk,keymap-sensors";
sensors = <&encoder>;
}; };
leds { leds {
compatible = "gpio-leds"; compatible = "gpio-leds";
@ -134,6 +122,24 @@
sda-pin = <21>; sda-pin = <21>;
scl-pin = <19>; scl-pin = <19>;
clock-frequency = < I2C_BITRATE_STANDARD >; clock-frequency = < I2C_BITRATE_STANDARD >;
bq27441@55 {
compatible = "ti,bq274xx";
label = "BATTERY";
reg = <0x55>;
design-voltage = <3700>;
design-capacity = <450>;
taper-current = <45>;
terminate-voltage = <3000>;
};
};
&i2c1 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <15>;
scl-pin = <17>;
clock-frequency = < I2C_BITRATE_STANDARD >;
is31fl3733a: is31fl3733@50 { is31fl3733a: is31fl3733@50 {
compatible = "issi,is31fl3733"; compatible = "issi,is31fl3733";
label = "IS31FL3733A"; label = "IS31FL3733A";
@ -144,22 +150,6 @@
label = "IS31FL3733B"; label = "IS31FL3733B";
reg = <0x53>; reg = <0x53>;
}; };
bq27441@55 {
compatible = "ti,bq274xx";
label = "BATTERY";
reg = <0x55>;
design-voltage = <3700>;
design-capacity = <900>;
taper-current = <45>;
terminate-voltage = <3000>;
};
};
&i2c1 {
compatible = "nordic,nrf-twi";
status = "okay";
sda-pin = <30>;
scl-pin = <31>;
}; };
&pwm0 { &pwm0 {

View file

@ -31,8 +31,6 @@ CONFIG_I2C_INIT_PRIORITY=60
CONFIG_IS31FL3733=y CONFIG_IS31FL3733=y
CONFIG_SENSOR=y CONFIG_SENSOR=y
CONFIG_BQ274XX=y CONFIG_BQ274XX=y
CONFIG_EC11=y
CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y
CONFIG_ZMK_EXT_POWER=y CONFIG_ZMK_EXT_POWER=y
CONFIG_ZMK_IDLE_SLEEP_TIMEOUT=60000 CONFIG_ZMK_IDLE_SLEEP_TIMEOUT=60000
CONFIG_DEVICE_POWER_MANAGEMENT=y CONFIG_DEVICE_POWER_MANAGEMENT=y

View file

@ -16,10 +16,10 @@ const uint8_t GRB = 2;
#define ZMK_KSCAN_EVENT_STATE_PRESSED 0 #define ZMK_KSCAN_EVENT_STATE_PRESSED 0
#define ZMK_KSCAN_EVENT_STATE_RELEASED 1 #define ZMK_KSCAN_EVENT_STATE_RELEASED 1
#define BASE_RED 255 #define BASE_RED 255
#define BASE_GREEN 255 #define BASE_GREEN 222
#define BASE_BLUE 255 #define BASE_BLUE 0
uint8_t led_base_color[3] = {BASE_RED, BASE_GREEN, BASE_BLUE}; uint8_t led_base_color[3] = {BASE_RED, BASE_GREEN, BASE_BLUE};
#define PRESSED_RED 250 #define PRESSED_RED 25
#define PRESSED_GREEN 0 #define PRESSED_GREEN 0
#define PRESSED_BLUE 0 #define PRESSED_BLUE 0
uint8_t pressed_color[3] = {PRESSED_RED, PRESSED_GREEN, PRESSED_BLUE}; uint8_t pressed_color[3] = {PRESSED_RED, PRESSED_GREEN, PRESSED_BLUE};
@ -45,27 +45,16 @@ static void zmk_kscan_callback_led(const struct device *dev, uint32_t row, uint3
k_work_submit(&led_processor.work); k_work_submit(&led_processor.work);
} }
uint8_t led_type_matrix[128] = { GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, uint8_t led_lookup_matrix[96] = { 1, 3, 5, 6, 8, 10, 12, 13, 15, 65, 67, 68, 70, 72, 74, 75,
RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, GRB, GRB, RGB, RGB, RGB, RGB, RGB, RGB, 77, 79,
RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, RGB, GRB,
GRB, GRB, RGB, GRB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB,
RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, GRB, RGB, GRB, RGB, GRB, GRB, GRB, RGB, RGB, RGB, RGB,
RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB, RGB,
GRB, RGB, GRB, RGB, GRB, RGB, GRB, RGB};
uint8_t led_lookup_matrix[108] = { 1, 0, 3, 5, 7, 9, 11, 13, 15, 65, 0, 67, 69, 71, 73, 75, 77, 79,
17, 20, 22, 24, 26, 28, 30, 80, 81, 82, 83, 84, 85, 0, 86, 87, 88, 90, 17, 20, 22, 24, 26, 28, 30, 80, 81, 82, 83, 84, 85, 0, 86, 87, 88, 90,
19, 21, 23, 25, 27, 29, 31, 96, 98, 100, 102, 104, 106, 0, 108, 109, 110, 92, 19, 21, 23, 25, 27, 29, 31, 96, 98, 100, 102, 104, 106, 0, 108, 109, 110, 92,
34, 36, 38, 40, 42, 44, 46, 97, 99, 101, 103, 105, 0, 0, 107, 0, 0, 0, 34, 36, 38, 40, 42, 44, 46, 97, 99, 101, 103, 105, 0, 0, 107, 0, 0, 0,
35, 0, 37, 39, 41, 43, 45, 47, 112, 113, 114, 115, 0, 0, 119, 0, 111, 0, 35, 0, 37, 39, 41, 43, 45, 47, 112, 113, 114, 115, 0, 0, 119, 0, 111, 0,
49, 51, 53, 0, 0, 0, 55, 57, 0, 0, 0, 62, 116, 118, 121, 123, 125, 127}; 49, 51, 53, 0, 0, 0,};
void led_set_color_rgb(struct device *dev, uint8_t led,uint8_t qty, uint8_t *rgb, uint8_t type){ void led_set_color_rgb(struct device *dev, uint8_t led,uint8_t qty, uint8_t *rgb, uint8_t type){
if (led_type_matrix[led] == RGB)
led_set_color(dev, led, qty, rgb); led_set_color(dev, led, qty, rgb);
else if (led_type_matrix[led] == GRB){
uint8_t color[3] = {rgb[1], rgb[0], rgb[2]};
led_set_color(dev, led, qty, color);
}
} }
void set_led_rgb(uint8_t led, uint8_t *rgb){ void set_led_rgb(uint8_t led, uint8_t *rgb){
struct device *dev = NULL; struct device *dev = NULL;
@ -113,6 +102,7 @@ void set_all_rgb(const struct device *dev, uint8_t *rgb){
} }
} }
int led_perkey_init(char *name) { int led_perkey_init(char *name) {
k_busy_wait(1000);
LOG_INF("ZMK_PER_KEY_LED INIT\n"); LOG_INF("ZMK_PER_KEY_LED INIT\n");
const struct device *dev_a = device_get_binding("IS31FL3733A"); const struct device *dev_a = device_get_binding("IS31FL3733A");
if (!dev_a) { if (!dev_a) {