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 <andreas@sandberg.pp.se>
This commit is contained in:
Andreas Sandberg 2020-07-05 21:44:27 +01:00 committed by Anas Nashif
commit 33d473d281

View file

@ -34,6 +34,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(semtech_sx1261) +
#define HAVE_GPIO_CS DT_INST_SPI_DEV_HAS_CS_GPIOS(0)
#define GPIO_CS_LABEL DT_INST_SPI_DEV_CS_GPIOS_LABEL(0)
#define GPIO_CS_PIN DT_INST_SPI_DEV_CS_GPIOS_PIN(0)
#define GPIO_CS_FLAGS DT_INST_SPI_DEV_CS_GPIOS_FLAGS(0)
#define GPIO_RESET_LABEL DT_INST_GPIO_LABEL(0, reset_gpios)
#define GPIO_RESET_PIN DT_INST_GPIO_PIN(0, reset_gpios)
@ -441,12 +442,15 @@ static int sx126x_lora_init(struct device *dev)
#if HAVE_GPIO_CS
dev_data.spi_cs.gpio_dev = device_get_binding(GPIO_CS_LABEL);
dev_data.spi_cs.gpio_pin = GPIO_CS_PIN;
if (!dev_data.spi_cs.gpio_dev) {
LOG_ERR("Cannot get pointer to %s device", GPIO_CS_LABEL);
return -EIO;
}
dev_data.spi_cs.gpio_pin = GPIO_CS_PIN;
dev_data.spi_cs.gpio_dt_flags = GPIO_CS_FLAGS;
dev_data.spi_cs.delay = 0U;
dev_data.spi_cfg.cs = &dev_data.spi_cs;
#endif
dev_data.spi_cfg.operation = SPI_WORD_SET(8) | SPI_TRANSFER_MSB;