Skip to content

Commit 33d473d

Browse files
andysannashif
authored andcommitted
drivers: lora: Add chip select flags to SX126x driver
Add chip select flags from the device tree to the spi_cs_control instance. Signed-off-by: Andreas Sandberg <[email protected]>
1 parent 667f1e6 commit 33d473d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/lora/sx126x.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(semtech_sx1261) +
3434
#define HAVE_GPIO_CS DT_INST_SPI_DEV_HAS_CS_GPIOS(0)
3535
#define GPIO_CS_LABEL DT_INST_SPI_DEV_CS_GPIOS_LABEL(0)
3636
#define GPIO_CS_PIN DT_INST_SPI_DEV_CS_GPIOS_PIN(0)
37+
#define GPIO_CS_FLAGS DT_INST_SPI_DEV_CS_GPIOS_FLAGS(0)
3738

3839
#define GPIO_RESET_LABEL DT_INST_GPIO_LABEL(0, reset_gpios)
3940
#define GPIO_RESET_PIN DT_INST_GPIO_PIN(0, reset_gpios)
@@ -441,12 +442,15 @@ static int sx126x_lora_init(struct device *dev)
441442

442443
#if HAVE_GPIO_CS
443444
dev_data.spi_cs.gpio_dev = device_get_binding(GPIO_CS_LABEL);
444-
dev_data.spi_cs.gpio_pin = GPIO_CS_PIN;
445445
if (!dev_data.spi_cs.gpio_dev) {
446446
LOG_ERR("Cannot get pointer to %s device", GPIO_CS_LABEL);
447447
return -EIO;
448448
}
449449

450+
dev_data.spi_cs.gpio_pin = GPIO_CS_PIN;
451+
dev_data.spi_cs.gpio_dt_flags = GPIO_CS_FLAGS;
452+
dev_data.spi_cs.delay = 0U;
453+
450454
dev_data.spi_cfg.cs = &dev_data.spi_cs;
451455
#endif
452456
dev_data.spi_cfg.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB;

0 commit comments

Comments
 (0)