|
16 | 16 | #include <zephyr/kernel.h> |
17 | 17 | #include <zephyr/devicetree.h> |
18 | 18 | #include <zephyr/drivers/gpio.h> |
| 19 | +#include <zephyr/drivers/spi.h> |
19 | 20 |
|
20 | 21 | #include <sid_pal_serial_bus_ifc.h> |
21 | 22 | #include <sid_pal_serial_bus_spi_config.h> |
|
53 | 54 | } |
54 | 55 | #define INVALID_DT_GPIO NULL_STRUCT_INITIALIZER |
55 | 56 | #define SPI_FREQUENCY_DEFAULT (8UL*1000*1000) |
| 57 | +#define LORA_DT DT_NODELABEL(lora_semtech_lr11xxmb1xxs) |
56 | 58 |
|
57 | 59 | /* Default values for optional DTS properties */ |
58 | 60 | #define LR1110_DEFAULT_TX_POWER_OFFSET 0 |
@@ -124,34 +126,34 @@ static const radio_lr1110_regional_param_t radio_lr1110_regional_param[] = { |
124 | 126 | }; |
125 | 127 |
|
126 | 128 | 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), |
129 | 131 | .lna_gain = RADIO_RX_LNA_GAIN, |
130 | 132 | .bus_factory = &radio_spi_factory, |
131 | 133 |
|
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), |
133 | 135 |
|
134 | 136 | .wakeup_delay_us = LR1110_DEFAULT_WAKEUP_DELAY_US, |
135 | 137 | .pa_cfg_callback = radio_lr1110_pa_cfg, |
136 | 138 | .tcxo_config = |
137 | 139 | { |
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 ? |
139 | 141 | 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), |
141 | 143 | // 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), |
143 | 145 | }, |
144 | 146 |
|
145 | 147 | .rfswitch = |
146 | 148 | { |
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), |
155 | 157 | }, |
156 | 158 |
|
157 | 159 | .rssi_no_signal_offset = LR1110_DEFAULT_RSSI_NO_SIGNAL_OFFSET, |
@@ -201,23 +203,22 @@ const void *get_radio_cfg(void) |
201 | 203 | { |
202 | 204 | radio_lr1110_cfg.gpios.power = |
203 | 205 | 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)); |
205 | 207 | radio_lr1110_cfg.gpios.int1 = |
206 | 208 | 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)); |
208 | 210 | radio_lr1110_cfg.gpios.radio_busy = |
209 | 211 | 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)); |
211 | 213 | radio_lr1110_cfg.gpios.rf_sw_ena = GPIO_UNUSED_PIN; |
212 | 214 | radio_lr1110_cfg.gpios.tx_bypass = GPIO_UNUSED_PIN; |
213 | 215 | radio_lr1110_cfg.gpios.txrx = GPIO_UNUSED_PIN; |
214 | 216 | radio_lr1110_cfg.gpios.power_cb = NULL; |
215 | 217 | radio_lr1110_cfg.gpios.arg = NULL; |
216 | 218 | 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)); |
219 | 220 | 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); |
221 | 222 |
|
222 | 223 | __ASSERT(radio_lr1110_cfg.gpios.power < GPIO_UNUSED_PIN, "gpio_power invalid GPIO"); |
223 | 224 | __ASSERT(radio_lr1110_cfg.gpios.int1 < GPIO_UNUSED_PIN, "gpio_int1 invalid GPIO"); |
|
0 commit comments