|
18 | 18 | }; |
19 | 19 |
|
20 | 20 |
|
| 21 | + |
| 22 | + |
| 23 | + |
| 24 | +// trackball bus |
| 25 | +&pinctrl { |
| 26 | + spi0_default: spi0_default { |
| 27 | + group1 { |
| 28 | + psels = <NRF_PSEL(SPIM_SCK, 0, 17)>, |
| 29 | + <NRF_PSEL(SPIM_MOSI, 0, 20)>, |
| 30 | + <NRF_PSEL(SPIM_MISO, 0, 20)>; |
| 31 | + }; |
| 32 | + }; |
| 33 | + |
| 34 | + spi0_sleep: spi0_sleep { |
| 35 | + group1 { |
| 36 | + psels = <NRF_PSEL(SPIM_SCK, 0, 17)>, |
| 37 | + <NRF_PSEL(SPIM_MOSI, 0, 20)>, |
| 38 | + <NRF_PSEL(SPIM_MISO, 0, 20)>; |
| 39 | + low-power-enable; |
| 40 | + }; |
| 41 | + }; |
| 42 | +}; |
| 43 | + |
| 44 | +#include <zephyr/dt-bindings/input/input-event-codes.h> |
| 45 | + |
| 46 | +&spi0 { |
| 47 | + status = "okay"; |
| 48 | + compatible = "nordic,nrf-spim"; |
| 49 | + pinctrl-0 = <&spi0_default>; |
| 50 | + pinctrl-1 = <&spi0_sleep>; |
| 51 | + pinctrl-names = "default", "sleep"; |
| 52 | + cs-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>; |
| 53 | + |
| 54 | + trackball: trackball@0 { |
| 55 | + status = "okay"; |
| 56 | + compatible = "pixart,pmw3610"; |
| 57 | + reg = <0>; |
| 58 | + spi-max-frequency = <2000000>; |
| 59 | + irq-gpios = <&gpio0 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; |
| 60 | + cpi = <600>; |
| 61 | + // swap-xy; /* optional */ |
| 62 | + // invert-x; /* optional */ |
| 63 | + // invert-y; /* optional */ |
| 64 | + evt-type = <INPUT_EV_REL>; |
| 65 | + x-input-code = <INPUT_REL_X>; |
| 66 | + y-input-code = <INPUT_REL_Y>; |
| 67 | + |
| 68 | + force-awake; |
| 69 | + /* keep the sensor awake while ZMK activity state is ACTIVE, |
| 70 | + fallback to normal downshift mode after ZMK goes into IDLE / SLEEP mode. |
| 71 | + thus, the sensor would be a `wakeup-source` */ |
| 72 | + |
| 73 | + force-awake-4ms-mode; |
| 74 | + /* while force-awake is acitvated, enable this mode to force sampling per |
| 75 | + 4ms, where the default sampling rate is 8ms. */ |
| 76 | + /* NOTE: apply this mode if you need 250Hz with direct USB connection. */ |
| 77 | + }; |
| 78 | +}; |
| 79 | + |
| 80 | +/ { |
| 81 | + trackball_listener { |
| 82 | + compatible = "zmk,input-listener"; |
| 83 | + device = <&trackball>; |
| 84 | + }; |
| 85 | +}; |
| 86 | + |
0 commit comments