-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d976f29
commit 5f5a3de
Showing
13 changed files
with
380 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ jobs: | |
- nrf52dk/nrf52832 | ||
- paw_pogo | ||
- paw_testboard | ||
- ploopy_mouse_nrf | ||
- pmw_testboard | ||
- zalpakka | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
zephyr_library() | ||
zephyr_library_sources(pmw_power.c) | ||
zephyr_library_sources(board.c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
if BOARD_PLOOPY_MOUSE_NRF | ||
|
||
config BT_CTLR | ||
default BT | ||
|
||
endif |
2 changes: 2 additions & 0 deletions
2
firmware/boards/balto/ploopy_mouse_nrf/Kconfig.ploopy_mouse_nrf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
config BOARD_PLOOPY_MOUSE_NRF | ||
select SOC_NRF52833_QDAA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <zephyr/init.h> | ||
#include <hal/nrf_power.h> | ||
|
||
static int board_regulator_init(void) | ||
{ | ||
if ((nrf_power_mainregstatus_get(NRF_POWER) == NRF_POWER_MAINREGSTATUS_HIGH) && | ||
(NRF_UICR->REGOUT0 & UICR_REGOUT0_VOUT_Msk) == (UICR_REGOUT0_VOUT_DEFAULT << UICR_REGOUT0_VOUT_Pos)) { | ||
|
||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; | ||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { | ||
; | ||
} | ||
|
||
NRF_UICR->REGOUT0 = (NRF_UICR->REGOUT0 & ~((uint32_t)UICR_REGOUT0_VOUT_Msk)) | | ||
(UICR_REGOUT0_VOUT_3V3 << UICR_REGOUT0_VOUT_Pos); | ||
|
||
NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; | ||
while (NRF_NVMC->READY == NVMC_READY_READY_Busy) { | ||
; | ||
} | ||
|
||
NVIC_SystemReset(); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
SYS_INIT(board_regulator_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
board_runner_args(nrfjprog "--softreset") | ||
board_runner_args(jlink "--device=nRF52833_xxAA" "--speed=4000") | ||
|
||
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) | ||
include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake) | ||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
board: | ||
name: ploopy_mouse_nrf | ||
vendor: balto | ||
socs: | ||
- name: nrf52833 |
33 changes: 33 additions & 0 deletions
33
firmware/boards/balto/ploopy_mouse_nrf/ploopy_mouse_nrf-pinctrl.dtsi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
&pinctrl { | ||
i2c0_default: i2c0_default { | ||
group1 { | ||
psels = <NRF_PSEL(TWIM_SCL, 0, 11)>, | ||
<NRF_PSEL(TWIM_SDA, 0, 5)>; | ||
}; | ||
}; | ||
|
||
i2c0_sleep: i2c0_sleep { | ||
group1 { | ||
psels = <NRF_PSEL(TWIM_SCL, 0, 11)>, | ||
<NRF_PSEL(TWIM_SDA, 0, 5)>; | ||
low-power-enable; | ||
}; | ||
}; | ||
|
||
spi1_default: spi1_default { | ||
group1 { | ||
psels = <NRF_PSEL(SPIM_SCK, 0, 28)>, | ||
<NRF_PSEL(SPIM_MISO, 0, 29)>, | ||
<NRF_PSEL(SPIM_MOSI, 0, 30)>; | ||
}; | ||
}; | ||
|
||
spi1_sleep: spi1_sleep { | ||
group1 { | ||
psels = <NRF_PSEL(SPIM_SCK, 0, 28)>, | ||
<NRF_PSEL(SPIM_MISO, 0, 29)>, | ||
<NRF_PSEL(SPIM_MOSI, 0, 30)>; | ||
low-power-enable; | ||
}; | ||
}; | ||
}; |
243 changes: 243 additions & 0 deletions
243
firmware/boards/balto/ploopy_mouse_nrf/ploopy_mouse_nrf.dts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,243 @@ | ||
/dts-v1/; | ||
#include <nordic/nrf52833_qdaa.dtsi> | ||
#include "ploopy_mouse_nrf-pinctrl.dtsi" | ||
#include <zephyr/dt-bindings/battery/battery.h> | ||
#include <zephyr/dt-bindings/input/input-event-codes.h> | ||
#include <dt-bindings/hid.h> | ||
|
||
/ { | ||
model = "Ploopy Mouse nRF"; | ||
compatible = "balto,ploopy-mouse-nrf"; | ||
|
||
chosen { | ||
zephyr,sram = &sram0; | ||
zephyr,flash = &flash0; | ||
zephyr,code-partition = &slot0_partition; | ||
}; | ||
|
||
leds { | ||
compatible = "gpio-leds"; | ||
led_status: led_a { | ||
gpios = <&pcal6408a 3 GPIO_ACTIVE_HIGH>; | ||
}; | ||
led_input_activity: led_b { | ||
gpios = <&pcal6408a 2 GPIO_ACTIVE_HIGH>; | ||
}; | ||
}; | ||
|
||
buttons: buttons { | ||
compatible = "gpio-keys"; | ||
debounce-interval-ms = <3>; | ||
|
||
sw_0 { | ||
gpios = <&pcal6408a 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
zephyr,code = <INPUT_BTN_SIDE>; | ||
}; | ||
sw_1 { | ||
gpios = <&pcal6408a 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
zephyr,code = <INPUT_BTN_FORWARD>; | ||
}; | ||
sw_2 { | ||
gpios = <&gpio0 31 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
zephyr,code = <INPUT_BTN_LEFT>; | ||
}; | ||
sw_3 { | ||
gpios = <&pcal6408a 1 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
zephyr,code = <INPUT_BTN_TASK>; | ||
}; | ||
sw_4 { | ||
gpios = <&gpio0 18 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
zephyr,code = <INPUT_BTN_RIGHT>; | ||
}; | ||
sw_5 { | ||
gpios = <&pcal6408a 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
zephyr,code = <INPUT_BTN_BACK>; | ||
}; | ||
sw_6 { | ||
gpios = <&pcal6408a 4 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
zephyr,code = <INPUT_BTN_MIDDLE>; | ||
}; | ||
sw_7 { | ||
gpios = <&pcal6408a 5 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
zephyr,code = <INPUT_BTN_EXTRA>; | ||
}; | ||
}; | ||
|
||
gpio_qdec: qdec { | ||
compatible = "gpio-qdec"; | ||
gpios = <&gpio0 17 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH)>, | ||
<&gpio0 20 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH)>; | ||
steps-per-period = <2>; | ||
zephyr,axis = <INPUT_REL_WHEEL>; | ||
sample-time-us = <2000>; | ||
idle-timeout-ms = <200>; | ||
}; | ||
|
||
|
||
vbatt: vbatt { | ||
compatible = "voltage-divider"; | ||
io-channels = <&adc 0>; | ||
output-ohms = <(560 * 1000)>; | ||
full-ohms = <(560 * 1000 * 2)>; | ||
}; | ||
|
||
fuel_gauge: fuel_gauge_composite { | ||
compatible = "zephyr,fuel-gauge-composite"; | ||
battery-voltage = <&vbatt>; | ||
device-chemistry = "lithium-ion-polymer"; | ||
ocv-capacity-table-0 = <BATTERY_OCV_CURVE_LITHIUM_ION_POLYMER_DEFAULT>; | ||
}; | ||
|
||
reg_1v8: reg_1v8{ | ||
compatible = "regulator-fixed"; | ||
regulator-name = "reg_1v8"; | ||
enable-gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>; | ||
regulator-boot-on; | ||
}; | ||
|
||
hid { | ||
compatible = "hid"; | ||
input { | ||
hid-mouse { | ||
compatible = "hid-mouse"; | ||
input = <&pmw &gpio_qdec &buttons>; | ||
input-id = <1>; | ||
report = <HID_MOUSE_REPORT(1)>; | ||
}; | ||
}; | ||
output { | ||
hid-hog { | ||
compatible = "hid-hog"; | ||
}; | ||
usb-hid { | ||
compatible = "usb-hid"; | ||
usb-hid-dev = <&hid_dev_0>; | ||
}; | ||
}; | ||
}; | ||
|
||
hid_dev_0: hid_dev_0 { | ||
compatible = "zephyr,hid-device"; | ||
interface-name = "HID0"; | ||
in-report-size = <16>; | ||
in-polling-period-us = <1000>; | ||
}; | ||
|
||
ble-unpair { | ||
input = <&buttons>; | ||
compatible = "ble-unpair"; | ||
key-a = <INPUT_BTN_LEFT>; | ||
key-b = <INPUT_BTN_RIGHT>; | ||
}; | ||
}; | ||
|
||
&uicr { | ||
nfct-pins-as-gpios; | ||
}; | ||
|
||
®1 { | ||
regulator-initial-mode = <NRF5X_REG_MODE_DCDC>; | ||
}; | ||
|
||
&adc { | ||
status = "okay"; | ||
#address-cells = <1>; | ||
#size-cells = <0>; | ||
|
||
channel@0 { | ||
reg = <0>; | ||
zephyr,gain = "ADC_GAIN_1_6"; | ||
zephyr,reference = "ADC_REF_INTERNAL"; | ||
zephyr,acquisition-time = <ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40)>; | ||
zephyr,input-positive = <NRF_SAADC_AIN2>; | ||
zephyr,resolution = <10>; | ||
}; | ||
}; | ||
|
||
&gpiote { | ||
status = "okay"; | ||
}; | ||
|
||
&gpio0 { | ||
status = "okay"; | ||
}; | ||
|
||
&gpio1 { | ||
status = "okay"; | ||
}; | ||
|
||
&i2c0 { | ||
compatible = "nordic,nrf-twi"; | ||
status = "okay"; | ||
pinctrl-0 = <&i2c0_default>; | ||
pinctrl-1 = <&i2c0_sleep>; | ||
pinctrl-names = "default", "sleep"; | ||
|
||
pcal6408a: pcal6408a@20 { | ||
compatible = "nxp,pcal6408a"; | ||
status = "okay"; | ||
reg = <0x20>; | ||
gpio-controller; | ||
#gpio-cells = <2>; | ||
ngpios = <8>; | ||
reset-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; | ||
int-gpios = <&gpio1 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; | ||
}; | ||
|
||
charger: bq25180@6a { | ||
compatible = "ti,bq25180"; | ||
reg = <0x6a>; | ||
constant-charge-current-max-microamp = <500000>; | ||
}; | ||
}; | ||
|
||
&spi1 { | ||
compatible = "nordic,nrf-spi"; | ||
status = "okay"; | ||
pinctrl-0 = <&spi1_default>; | ||
pinctrl-1 = <&spi1_sleep>; | ||
pinctrl-names = "default", "sleep"; | ||
|
||
cs-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; | ||
|
||
sensor: pmw: pmw3610@0 { | ||
compatible = "pixart,pmw3610"; | ||
reg = <0>; | ||
spi-max-frequency = <DT_FREQ_M(2)>; | ||
motion-gpios = <&gpio0 3 GPIO_ACTIVE_LOW>; | ||
zephyr,axis-x = <INPUT_REL_X>; | ||
zephyr,axis-y = <INPUT_REL_Y>; | ||
res-cpi = <800>; | ||
invert-y; | ||
}; | ||
}; | ||
|
||
&flash0 { | ||
partitions { | ||
compatible = "fixed-partitions"; | ||
#address-cells = <1>; | ||
#size-cells = <1>; | ||
|
||
boot_partition: partition@0 { | ||
label = "mcuboot"; | ||
reg = <0x00000000 0xC000>; | ||
}; | ||
slot0_partition: partition@c000 { | ||
label = "image-0"; | ||
reg = <0x0000C000 0x37000>; | ||
}; | ||
slot1_partition: partition@43000 { | ||
label = "image-1"; | ||
reg = <0x00043000 0x37000>; | ||
}; | ||
storage_partition: partition@7a000 { | ||
label = "storage"; | ||
reg = <0x0007A000 0x00006000>; | ||
}; | ||
}; | ||
}; | ||
|
||
zephyr_udc0: &usbd { | ||
compatible = "nordic,nrf-usbd"; | ||
status = "okay"; | ||
}; |
5 changes: 5 additions & 0 deletions
5
firmware/boards/balto/ploopy_mouse_nrf/ploopy_mouse_nrf_defconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CONFIG_ARM_MPU=y | ||
CONFIG_HW_STACK_PROTECTION=y | ||
CONFIG_USE_SEGGER_RTT=y | ||
CONFIG_GPIO=y | ||
CONFIG_CONSOLE=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <zephyr/input/input.h> | ||
#include <zephyr/input/input_pmw3610.h> | ||
#include <zephyr/kernel.h> | ||
#include <zephyr/logging/log.h> | ||
|
||
LOG_MODULE_REGISTER(pmw_power, LOG_LEVEL_INF); | ||
|
||
#define PMW_NODE DT_NODELABEL(pmw) | ||
|
||
#define FORCE_AWAKE_TIMEOUT_S 30 | ||
|
||
static const struct device *const pmw = DEVICE_DT_GET(PMW_NODE); | ||
|
||
static bool force_awake; | ||
|
||
static void sleep_handler(struct k_work *work) | ||
{ | ||
pmw3610_force_awake(pmw, false); | ||
force_awake = false; | ||
|
||
LOG_DBG("sleep"); | ||
} | ||
|
||
K_WORK_DELAYABLE_DEFINE(sleep_dwork, sleep_handler); | ||
|
||
static void pmw_cb(struct input_event *evt, void *user_data) | ||
{ | ||
if (!force_awake) { | ||
pmw3610_force_awake(pmw, true); | ||
force_awake = true; | ||
LOG_DBG("awake"); | ||
} | ||
|
||
k_work_reschedule(&sleep_dwork, K_SECONDS(FORCE_AWAKE_TIMEOUT_S)); | ||
} | ||
INPUT_CALLBACK_DEFINE(pmw, pmw_cb, NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CONFIG_SHELL_BACKEND_RTT=y | ||
CONFIG_SHELL_TAB=y | ||
CONFIG_SHELL_VT100_COMMANDS=y | ||
CONFIG_CONSOLE=y | ||
CONFIG_REGULATOR=y | ||
|
||
CONFIG_APP_DEVICE_NAME="Ploopy Mouse nRF" | ||
|
||
CONFIG_BT=y | ||
CONFIG_USB_DEVICE_STACK=n | ||
CONFIG_USB_DEVICE_STACK_NEXT=y |