Skip to content

Commit

Permalink
Add keymatrix feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ziteh committed Sep 22, 2023
1 parent 8c390db commit 812db05
Show file tree
Hide file tree
Showing 9 changed files with 489 additions and 159 deletions.
4 changes: 2 additions & 2 deletions central/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ CONFIG_GAZELL=y
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y

CONFIG_SPI_LOG_LEVEL_INF=y
CONFIG_PMW3360_LOG_LEVEL_DBG=y
CONFIG_SPI_LOG_LEVEL_INF=n
CONFIG_PMW3360_LOG_LEVEL_DBG=n

CONFIG_SPI=y
CONFIG_SENSOR=y
Expand Down
10 changes: 9 additions & 1 deletion central/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@ bool gzll_init(void)
return false;
}

ack_payload[0] = 0x00;
ret = nrf_gzll_add_packet_to_tx_fifo(PIPE_NUMBER, ack_payload, TX_PAYLOAD_LENGTH);
if (!ret)
{
LOG_ERR("Cannot add packet to Gazell TX FIFO");
return;
}

ret = nrf_gzll_enable();
if (!ret)
{
Expand Down Expand Up @@ -399,7 +407,7 @@ void gzll_rx_result_handler(struct gzll_rx_result *rx_result)
}
else if (data_payload_length > 0)
{
LOG_DBG("Gazell received");
LOG_DBG("Gazell received%d", data_payload[0]);
}

/* Send. */
Expand Down
4 changes: 4 additions & 0 deletions ncs-firmware.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
"${workspaceFolder:central}",
"${workspaceFolder:peripheral}",
],
"files.associations": {
"kernel.h": "c",
"main.h": "c"
},
}
}
2 changes: 1 addition & 1 deletion peripheral/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ menu "Gazell Link Layer sample: Device"

config GZLL_TX_STATISTICS
bool "Packet transaction statistics"
default y
default n
help
Turns on transmission statistics gathering.

Expand Down
16 changes: 16 additions & 0 deletions peripheral/dts/bindings/gpio-km.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

description: GPIO KEYS parent node

compatible: "gpio-km"

child-binding:
description: GPIO KEYS child node
properties:
gpios:
type: phandle-array
required: true
label:
required: true
type: string
description: Human readable string describing the device (used as device_get_binding() argument)
88 changes: 88 additions & 0 deletions peripheral/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

// For more help, browse the DeviceTree documentation at https: //docs.zephyrproject.org/latest/guides/dts/index.html
// You can also visit the nRF DeviceTree extension documentation at https: //nrfconnect.github.io/vscode-nrf-connect/devicetree/nrfdevicetree.html

/ {
km {
// compatible = "gpio-keys";
compatible = "gpio-km";
col0: column_0 {
gpios = <&gpio1 10 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 0";
};
col1: column_1 {
gpios = <&gpio1 11 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 1";
};
col2: column_2 {
gpios = <&gpio1 12 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Column 2";
};

row0: row_0 {
gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
label = "Row 0";
};
row1: row_1 {
gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
label = "Row 1";
};
row2: row_2 {
gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
label = "Row 2";
};
row3: row_3 {
gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
label = "Row 3";
};
};

aliases {
col0 = &col0;
col1 = &col1;
col2 = &col2;
row0 = &row0;
row1 = &row1;
row2 = &row2;
row3 = &row3;
};

chosen {
// zephyr,console = &uart1;
};
};

&pinctrl {
spi1_default_alt: spi1_default_alt{
group1{
psels = <NRF_PSEL(SPIM_SCK, 1, 5)>,
<NRF_PSEL(SPIM_MOSI, 1, 8)>,
<NRF_PSEL(SPIM_MISO, 1, 9)>;
};
};
spi1_sleep_alt: spi1_sleep_alt{
group1{
psels = <NRF_PSEL(SPIM_SCK, 1, 5)>,
<NRF_PSEL(SPIM_MOSI, 1, 8)>,
<NRF_PSEL(SPIM_MISO, 1, 9)>;
low-power-enable;
};
};
};

&spi1 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi1_default_alt>;
pinctrl-1 = <&spi1_sleep_alt>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;

pmw3360@0 {
compatible = "pixart,pmw3360";
reg = <0>;
irq-gpios = <&gpio0 31 GPIO_ACTIVE_LOW>;
spi-max-frequency = <1200000>;
label = "pmw3360";
};
};
21 changes: 17 additions & 4 deletions peripheral/prj.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_GPIO=y

CONFIG_GZLL=y
CONFIG_GAZELL=y

CONFIG_DK_LIBRARY=y

CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y

# CONFIG_SPI_LOG_LEVEL_INF=y
# CONFIG_PMW3360_LOG_LEVEL_DBG=y

# CONFIG_SPI=y
# CONFIG_SENSOR=y
# CONFIG_PMW3360=y
# CONFIG_PMW3360_ORIENTATION_0=y
# CONFIG_PMW3360_CPI=1600
# CONFIG_PMW3360_RUN_DOWNSHIFT_TIME_MS=500
# CONFIG_PMW3360_REST1_DOWNSHIFT_TIME_MS=500
# CONFIG_PMW3360_REST2_DOWNSHIFT_TIME_MS=500

CONFIG_CBPRINTF_FP_SUPPORT=y
Loading

0 comments on commit 812db05

Please sign in to comment.