Skip to content

Commit

Permalink
Refactor devicetree
Browse files Browse the repository at this point in the history
  • Loading branch information
ziteh committed Feb 3, 2024
1 parent 136b88a commit 5709c81
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 102 deletions.
114 changes: 23 additions & 91 deletions mitosis-like/central/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -3,128 +3,60 @@
// 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;
};
};

&i2c0 {
status = "disabled";
};

&qspi {
status = "disabled";
};

&pwm0 {
status = "disabled";
};

&spi3 {
status = "disabled";
};

&uart1 {
current-speed = <57600>;
};

&uart1_default {
group2 {
psels = <NRF_PSEL(UART_TX, 1, 9)>;
};

group1 {
psels = <NRF_PSEL(UART_RX, 0, 5)>;
};
};

&uart0_default {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 6)>, <NRF_PSEL(UART_RTS, 0, 1)>;
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 8)>,
<NRF_PSEL(UART_CTS, 0, 7)>,
<NRF_PSEL(UART_RTS, 0, 1)>;
};
};

&uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 6)>, <NRF_PSEL(UART_RX, 0, 8)>, <NRF_PSEL(UART_CTS, 0, 7)>;
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 8)>,
<NRF_PSEL(UART_CTS, 0, 7)>,
<NRF_PSEL(UART_RTS, 0, 1)>;
};
};

&uart1_sleep {
&uart1_default {
group1 {
psels = <NRF_PSEL(UART_RX, 1, 1)>;
psels = <NRF_PSEL(UART_RX, 0, 5)>,
<NRF_PSEL(UART_TX, 1, 9)>;
};
};

&uart1_sleep {
group1 {
psels = <NRF_PSEL(UART_RX, 1, 1)>, <NRF_PSEL(UART_TX, 0, 9)>;
/delete-property/ low-power-enable;
psels = <NRF_PSEL(UART_RX, 0, 5)>,
<NRF_PSEL(UART_TX, 1, 9)>;
};
};

&uart1_sleep {
group1 {
psels = <NRF_PSEL(UART_RX, 1, 1)>, <NRF_PSEL(UART_TX, 1, 9)>;
};
&i2c0 {
status = "disabled";
};

&uart1_sleep {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 5)>, <NRF_PSEL(UART_TX, 1, 9)>;
};
&qspi {
status = "disabled";
};

&uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 8)>,
<NRF_PSEL(UART_CTS, 0, 7)>,
<NRF_PSEL(UART_RTS, 0, 1)>;
/delete-property/ low-power-enable;
};
&pwm0 {
status = "disabled";
};

&spi3 {
status = "disabled";
};
2 changes: 1 addition & 1 deletion mitosis-like/central/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define EOT (0xFE)
#define ACK (0xF6)

/* UART. */
/* UART */
static const struct device *qmk_uart_device = DEVICE_DT_GET(DT_NODELABEL(uart1));

/* queue to store up to 10 messages (aligned to 4-byte boundary) */
Expand Down
6 changes: 0 additions & 6 deletions mitosis-like/mitosis-like.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,5 @@
"${workspaceFolder:central}",
"${workspaceFolder:peripheral}",
],
"files.associations": {
"kernel.h": "c",
"main.h": "c",
"nrf_gzll.h": "c",
"gzll_glue.h": "c"
},
}
}
6 changes: 4 additions & 2 deletions mitosis-like/peripheral/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
compatible = "pixart,pmw3360";
reg = <0>;
irq-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
spi-max-frequency = <600000>;
spi-max-frequency = <1400000>; // 2MHz max for PMW3360
label = "pmw3360";
};
};
Expand All @@ -148,7 +148,9 @@

&uart0_default {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 6)>;
psels = <NRF_PSEL(UART_TX, 0, 6)>,
<NRF_PSEL(UART_RX, 0, 8)>,
<NRF_PSEL(UART_CTS, 0, 7)>;
};
};

Expand Down
4 changes: 2 additions & 2 deletions mitosis-like/peripheral/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define MAX_TX_ATTEMPTS (100) /* Maximum number of transmission attempts */

// #ifdef PMW3360_ENABLE
#ifdef RIGHT
#ifdef RIGHT
#define TX_PAYLOAD_LENGTH (ROW_COUNT + 6 + 1)
#else
#define TX_PAYLOAD_LENGTH (ROW_COUNT + 1)
Expand Down Expand Up @@ -309,7 +309,7 @@ static void gzll_tx_result_handler(struct gzll_tx_result *tx_result)
memcpy(data_payload, raw_keymatrix, ROW_COUNT);

// #ifdef PMW3360_ENABLE
#ifdef RIGHT
#ifdef RIGHT
data_payload[ROW_COUNT] = mouse_x >> 8; // Mouse-X High
data_payload[ROW_COUNT + 1] = mouse_x & 0xFF; // Mouse-X Low
data_payload[ROW_COUNT + 2] = mouse_y >> 8; // Mouse-Y High
Expand Down

0 comments on commit 5709c81

Please sign in to comment.