Skip to content

Commit da4d5ce

Browse files
committed
Resolve some compile-warnings:
Refactor GPIO signal compatibility and update device tree bindings
1 parent d13873f commit da4d5ce

10 files changed

Lines changed: 72 additions & 51 deletions

File tree

fw/nRF/us_probe/boards/nrf52dk_nrf52832.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
};
2626

2727
spi_ss_pin: spi_ss_pin {
28-
compatible = "wulpus,spi-ss";
28+
compatible = "wulpus,gpio-signal";
2929
gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
3030
label = "SPI SS Pin";
3131
};

fw/nRF/us_probe/boards/nrf54l15dk_nrf54l15_cpuapp.overlay

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/ {
22
aliases {
3-
led0 = &led_nrf54;
43
data-ready = &data_ready_pin;
54
ble-cnfg-ready = &ble_cnfg_ready_pin;
65
spi-conn = &spi20;
@@ -18,17 +17,10 @@
1817
nordic,nus-uart = &uart30;
1918
};
2019

21-
leds {
22-
compatible = "gpio-leds";
23-
led_nrf54: led_nrf54 {
24-
gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
25-
label = "NRF54 LED";
26-
};
27-
28-
ble_cnfg_ready_pin: ble_cnfg_ready_pin {
29-
gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
30-
label = "BLE Configuration Ready Pin";
31-
};
20+
ble_cnfg_ready_pin: ble_cnfg_ready_pin {
21+
compatible = "wulpus,gpio-signal";
22+
gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
23+
label = "BLE Configuration Ready Pin";
3224
};
3325

3426
buttons {
@@ -37,18 +29,10 @@
3729
gpios = <&gpio1 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
3830
label = "Data Ready Pin";
3931
};
40-
dbg_button_2: dbg_button_2 {
41-
gpios = <&gpio1 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
42-
label = "Debug Button 2";
43-
};
44-
dbg_button_3: dbg_button_3 {
45-
gpios = <&gpio0 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
46-
label = "Debug Button 3";
47-
};
4832
};
4933

5034
spi_ss_pin: spi_ss_pin {
51-
compatible = "wulpus,spi-ss";
35+
compatible = "wulpus,gpio-signal";
5236
gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
5337
label = "SPI SS Pin";
5438
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Devicetree binding for simple GPIO signals used by the Wulpus probe firmware
2+
3+
compatible: "wulpus,gpio-signal"
4+
5+
description: |
6+
Helper node used by the Wulpus probe firmware to locate a GPIO signal via
7+
devicetree aliases.
8+
9+
properties:
10+
gpios:
11+
type: phandle-array
12+
required: true
13+
description: GPIO specifier for the signal.
14+
15+
label:
16+
type: string
17+
required: false

fw/nRF/us_probe/dts/bindings/wulpus,spi-ss.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

fw/nRF/us_probe/include/helper.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1+
#ifndef HELPER_H
2+
#define HELPER_H
3+
14
#include <bluetooth/mesh/models.h>
5+
#include <stdint.h>
6+
7+
bool own_message(const struct bt_mesh_model *model,
8+
const struct bt_mesh_msg_ctx *ctx);
9+
void apply_config(const uint8_t *data, uint16_t len);
210

3-
bool own_message(const struct bt_mesh_model *model, const struct bt_mesh_msg_ctx *ctx);
4-
void apply_config(uint8_t *const data, uint16_t len);
11+
#endif // HELPER_H

fw/nRF/us_probe/include/main.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#define LED_NODE DT_ALIAS(led0)
1212
#define DATA_READY_NODE DT_ALIAS(data_ready)
1313
#define BLE_CNFG_READY_NODE DT_ALIAS(ble_cnfg_ready)
14-
#define DEBUG_LED_NODE DT_ALIAS(debug_led)
15-
#define DBG_BUTTON_2_NODE DT_NODELABEL(dbg_button_2)
16-
#define DBG_BUTTON_3_NODE DT_NODELABEL(dbg_button_3)
14+
#define DEBUG_LED_NODE DT_ALIAS(led1)
15+
#define DBG_BUTTON_2_NODE DT_ALIAS(sw2)
16+
#define DBG_BUTTON_3_NODE DT_ALIAS(sw3)
1717

1818
// --- Bluetooth Definitions --------------------
1919
#define DEVICE_NAME_BASE "WULPUS_PROBE"

fw/nRF/us_probe/include/mesh.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define MESH_H
33

44
#include "ble.h"
5+
#include <stdint.h>
56
#include <bluetooth/mesh/models.h>
67
#include <zephyr/bluetooth/mesh.h>
78
#include <zephyr/kernel.h>
@@ -83,4 +84,6 @@ uint32_t mesh_get_network_timestamp(void);
8384
extern const struct bt_mesh_comp comp;
8485
extern uint8_t dev_uuid[16];
8586

87+
uint16_t bt_mesh_primary_addr(void);
88+
8689
#endif // MESH_H

fw/nRF/us_probe/src/helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bool own_message(const struct bt_mesh_model *model, const struct bt_mesh_msg_ctx
1414
return elem->rt->addr == ctx->addr;
1515
}
1616

17-
void apply_config(uint8_t *const data, uint16_t len)
17+
void apply_config(const uint8_t *data, uint16_t len)
1818
{
1919
LOG_INF("Applying new configuration. Len: %d", len);
2020

fw/nRF/us_probe/src/main.c

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,31 @@
1919

2020
LOG_MODULE_REGISTER(main);
2121

22+
#define HAS_DBG_BUTTON_2 DT_NODE_EXISTS(DBG_BUTTON_2_NODE)
23+
#define HAS_DBG_BUTTON_3 DT_NODE_EXISTS(DBG_BUTTON_3_NODE)
24+
2225
// --- GPIOs ---
2326
const struct gpio_dt_spec ble_cnfg_ready =
2427
GPIO_DT_SPEC_GET(BLE_CNFG_READY_NODE, gpios);
2528
const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED_NODE, gpios);
2629
const struct gpio_dt_spec data_ready = GPIO_DT_SPEC_GET(DATA_READY_NODE, gpios);
30+
#if HAS_DBG_BUTTON_2
2731
const struct gpio_dt_spec dbg_button_2 =
2832
GPIO_DT_SPEC_GET(DBG_BUTTON_2_NODE, gpios);
33+
#endif
34+
#if HAS_DBG_BUTTON_3
2935
const struct gpio_dt_spec dbg_button_3 =
3036
GPIO_DT_SPEC_GET(DBG_BUTTON_3_NODE, gpios);
37+
#endif
3138

3239
// callback for data-ready GPIO interrupt, triggering SPIM transfer
3340
struct gpio_callback data_ready_cb;
41+
#if HAS_DBG_BUTTON_2
3442
struct gpio_callback dbg_button_2_cb;
43+
#endif
44+
#if HAS_DBG_BUTTON_3
3545
struct gpio_callback dbg_button_3_cb;
46+
#endif
3647

3748
int64_t last_gpio_interrupt_time = 0;
3849
static void gpio_interrupt_handler(const struct device *dev,
@@ -120,17 +131,28 @@ int main(void)
120131

121132
LOG_INF("Initializing GPIOs...");
122133
if (!gpio_is_ready_dt(&led) || !gpio_is_ready_dt(&data_ready) ||
123-
!gpio_is_ready_dt(&ble_cnfg_ready) || !gpio_is_ready_dt(&dbg_button_2) ||
124-
!gpio_is_ready_dt(&dbg_button_3))
134+
!gpio_is_ready_dt(&ble_cnfg_ready)
135+
#if HAS_DBG_BUTTON_2
136+
|| !gpio_is_ready_dt(&dbg_button_2)
137+
#endif
138+
#if HAS_DBG_BUTTON_3
139+
|| !gpio_is_ready_dt(&dbg_button_3)
140+
#endif
141+
)
125142
{
126143
LOG_ERR("GPIO devices not ready.");
127144
return 0;
128145
}
129146
err = gpio_pin_configure_dt(&led, GPIO_OUTPUT_LOW) |
130147
gpio_pin_configure_dt(&ble_cnfg_ready, GPIO_OUTPUT_LOW) |
131-
gpio_pin_configure_dt(&data_ready, GPIO_INPUT) |
132-
gpio_pin_configure_dt(&dbg_button_2, GPIO_INPUT) |
133-
gpio_pin_configure_dt(&dbg_button_3, GPIO_INPUT);
148+
gpio_pin_configure_dt(&data_ready, GPIO_INPUT)
149+
#if HAS_DBG_BUTTON_2
150+
| gpio_pin_configure_dt(&dbg_button_2, GPIO_INPUT)
151+
#endif
152+
#if HAS_DBG_BUTTON_3
153+
| gpio_pin_configure_dt(&dbg_button_3, GPIO_INPUT)
154+
#endif
155+
;
134156
if (err < 0)
135157
{
136158
LOG_ERR("Error configuring GPIO pins");
@@ -149,15 +171,19 @@ int main(void)
149171
return err;
150172
}
151173

174+
#if HAS_DBG_BUTTON_2
152175
gpio_init_callback(&dbg_button_2_cb, dbg_button_2_handler,
153176
BIT(dbg_button_2.pin));
154177
gpio_add_callback_dt(&dbg_button_2, &dbg_button_2_cb);
155178
gpio_pin_interrupt_configure_dt(&dbg_button_2, GPIO_INT_EDGE_TO_ACTIVE);
179+
#endif
156180

181+
#if HAS_DBG_BUTTON_3
157182
gpio_init_callback(&dbg_button_3_cb, dbg_button_3_handler,
158183
BIT(dbg_button_3.pin));
159184
gpio_add_callback_dt(&dbg_button_3, &dbg_button_3_cb);
160185
gpio_pin_interrupt_configure_dt(&dbg_button_3, GPIO_INT_EDGE_TO_ACTIVE);
186+
#endif
161187

162188
LOG_INF("Initializing settings subsystem");
163189
err = settings_subsys_init();

fw/nRF/us_probe/src/spi.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ static uint32_t get_spim_ss_pin(void)
5555
return NRF_GPIO_PIN_MAP(0, spi_ss_gpio.pin);
5656
}
5757

58+
#if DT_NODE_EXISTS(DT_NODELABEL(gpio1))
5859
if (spi_ss_gpio.port == DEVICE_DT_GET(DT_NODELABEL(gpio1)))
5960
{
6061
return NRF_GPIO_PIN_MAP(1, spi_ss_gpio.pin);
6162
}
63+
#endif
6264

6365
#if DT_NODE_EXISTS(DT_NODELABEL(gpio2))
6466
if (spi_ss_gpio.port == DEVICE_DT_GET(DT_NODELABEL(gpio2)))

0 commit comments

Comments
 (0)