Skip to content

Commit 84720c5

Browse files
moyamartinRobertGalatNordic
authored andcommitted
config: LR1110 chip-select is hardcoded to arduino_spi
this commit attempts to fix that by using the spi bus of the lr1110 semtech node Signed-off-by: Martin Moya <[email protected]>
1 parent 1819791 commit 84720c5

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

subsys/config/common/src/app_subGHz_config_lr11xx.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <zephyr/kernel.h>
1717
#include <zephyr/devicetree.h>
1818
#include <zephyr/drivers/gpio.h>
19+
#include <zephyr/drivers/spi.h>
1920

2021
#include <sid_pal_serial_bus_ifc.h>
2122
#include <sid_pal_serial_bus_spi_config.h>
@@ -53,6 +54,7 @@
5354
}
5455
#define INVALID_DT_GPIO NULL_STRUCT_INITIALIZER
5556
#define SPI_FREQUENCY_DEFAULT (8UL*1000*1000)
57+
#define LORA_DT DT_NODELABEL(lora_semtech_lr11xxmb1xxs)
5658

5759
/* Default values for optional DTS properties */
5860
#define LR1110_DEFAULT_TX_POWER_OFFSET 0
@@ -124,34 +126,34 @@ static const radio_lr1110_regional_param_t radio_lr1110_regional_param[] = {
124126
};
125127

126128
static radio_lr1110_device_config_t radio_lr1110_cfg = {
127-
.regulator_mode = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), reg_mode, LR1110_SYSTEM_REG_MODE_DCDC),
128-
.rx_boost = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), rx_boosted, LR1110_DEFAULT_RX_BOOSTED),
129+
.regulator_mode = DT_PROP_OR(LORA_DT, reg_mode, LR1110_SYSTEM_REG_MODE_DCDC),
130+
.rx_boost = DT_PROP_OR(LORA_DT, rx_boosted, LR1110_DEFAULT_RX_BOOSTED),
129131
.lna_gain = RADIO_RX_LNA_GAIN,
130132
.bus_factory = &radio_spi_factory,
131133

132-
.lfclock_cfg = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), lf_clk, LR1110_SYSTEM_LFCLK_XTAL),
134+
.lfclock_cfg = DT_PROP_OR(LORA_DT, lf_clk, LR1110_SYSTEM_LFCLK_XTAL),
133135

134136
.wakeup_delay_us = LR1110_DEFAULT_WAKEUP_DELAY_US,
135137
.pa_cfg_callback = radio_lr1110_pa_cfg,
136138
.tcxo_config =
137139
{
138-
.ctrl = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), tcxo_wakeup_time, 0) > 0 ?
140+
.ctrl = DT_PROP_OR(LORA_DT, tcxo_wakeup_time, 0) > 0 ?
139141
LR1110_TCXO_CTRL_DIO3 : LR1110_TCXO_CTRL_NONE,
140-
.tune = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), tcxo_voltage, LR1110_SYSTEM_TCXO_CTRL_1_8V),
142+
.tune = DT_PROP_OR(LORA_DT, tcxo_voltage, LR1110_SYSTEM_TCXO_CTRL_1_8V),
141143
// Convert ms to 30.25 us ticks (1 ms = 33.06 ticks)
142-
.timeout = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), tcxo_wakeup_time, 0),
144+
.timeout = DT_PROP_OR(LORA_DT, tcxo_wakeup_time, 0),
143145
},
144146

145147
.rfswitch =
146148
{
147-
.enable = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), rf_sw_enable, 0),
148-
.standby = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), rf_sw_standby_mode, 0),
149-
.rx = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), rf_sw_rx_mode, 0),
150-
.tx = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), rf_sw_tx_mode, 0),
151-
.tx_hp = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), rf_sw_tx_hp_mode, 0),
152-
.tx_hf = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), rf_sw_tx_hf_mode, 0),
153-
.gnss = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), rf_sw_gnss_mode, 0),
154-
.wifi = DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), rf_sw_wifi_mode, 0),
149+
.enable = DT_PROP_OR(LORA_DT, rf_sw_enable, 0),
150+
.standby = DT_PROP_OR(LORA_DT, rf_sw_standby_mode, 0),
151+
.rx = DT_PROP_OR(LORA_DT, rf_sw_rx_mode, 0),
152+
.tx = DT_PROP_OR(LORA_DT, rf_sw_tx_mode, 0),
153+
.tx_hp = DT_PROP_OR(LORA_DT, rf_sw_tx_hp_mode, 0),
154+
.tx_hf = DT_PROP_OR(LORA_DT, rf_sw_tx_hf_mode, 0),
155+
.gnss = DT_PROP_OR(LORA_DT, rf_sw_gnss_mode, 0),
156+
.wifi = DT_PROP_OR(LORA_DT, rf_sw_wifi_mode, 0),
155157
},
156158

157159
.rssi_no_signal_offset = LR1110_DEFAULT_RSSI_NO_SIGNAL_OFFSET,
@@ -201,23 +203,22 @@ const void *get_radio_cfg(void)
201203
{
202204
radio_lr1110_cfg.gpios.power =
203205
sid_gpio_utils_register_gpio((struct gpio_dt_spec)GPIO_DT_SPEC_GET_OR(
204-
DT_NODELABEL(lora_semtech_lr11xxmb1xxs), reset_gpios, INVALID_DT_GPIO));
206+
LORA_DT, reset_gpios, INVALID_DT_GPIO));
205207
radio_lr1110_cfg.gpios.int1 =
206208
sid_gpio_utils_register_gpio((struct gpio_dt_spec)GPIO_DT_SPEC_GET_OR(
207-
DT_NODELABEL(lora_semtech_lr11xxmb1xxs), event_gpios, INVALID_DT_GPIO));
209+
LORA_DT, event_gpios, INVALID_DT_GPIO));
208210
radio_lr1110_cfg.gpios.radio_busy =
209211
sid_gpio_utils_register_gpio((struct gpio_dt_spec)GPIO_DT_SPEC_GET_OR(
210-
DT_NODELABEL(lora_semtech_lr11xxmb1xxs), busy_gpios, INVALID_DT_GPIO));
212+
LORA_DT, busy_gpios, INVALID_DT_GPIO));
211213
radio_lr1110_cfg.gpios.rf_sw_ena = GPIO_UNUSED_PIN;
212214
radio_lr1110_cfg.gpios.tx_bypass = GPIO_UNUSED_PIN;
213215
radio_lr1110_cfg.gpios.txrx = GPIO_UNUSED_PIN;
214216
radio_lr1110_cfg.gpios.power_cb = NULL;
215217
radio_lr1110_cfg.gpios.arg = NULL;
216218
radio_lr1110_cfg.bus_selector.client_selector =
217-
sid_gpio_utils_register_gpio(
218-
(struct gpio_dt_spec)GPIO_DT_SPEC_GET_OR(DT_NODELABEL(arduino_spi), cs_gpios, INVALID_DT_GPIO));
219+
sid_gpio_utils_register_gpio((struct gpio_dt_spec)SPI_CS_GPIOS_DT_SPEC_GET(LORA_DT));
219220
radio_lr1110_cfg.bus_selector.speed_hz =
220-
DT_PROP_OR(DT_NODELABEL(lora_semtech_lr11xxmb1xxs), spi_max_frequency, SPI_FREQUENCY_DEFAULT);
221+
DT_PROP_OR(LORA_DT, spi_max_frequency, SPI_FREQUENCY_DEFAULT);
221222

222223
__ASSERT(radio_lr1110_cfg.gpios.power < GPIO_UNUSED_PIN, "gpio_power invalid GPIO");
223224
__ASSERT(radio_lr1110_cfg.gpios.int1 < GPIO_UNUSED_PIN, "gpio_int1 invalid GPIO");

0 commit comments

Comments
 (0)