diff --git a/drivers/Makefile.dep b/drivers/Makefile.dep index a328eb2b499f..3d893f6017e1 100644 --- a/drivers/Makefile.dep +++ b/drivers/Makefile.dep @@ -489,6 +489,7 @@ ifneq (,$(filter sx127%,$(USEMODULE))) FEATURES_REQUIRED += periph_gpio FEATURES_REQUIRED += periph_gpio_irq FEATURES_REQUIRED += periph_spi + FEATURES_OPTIONAL += periph_spi_gpio_mode USEMODULE += iolist USEMODULE += xtimer USEMODULE += sx127x diff --git a/drivers/sx127x/sx127x.c b/drivers/sx127x/sx127x.c index 5532bb7aa623..11f7c8935beb 100644 --- a/drivers/sx127x/sx127x.c +++ b/drivers/sx127x/sx127x.c @@ -344,6 +344,15 @@ static int _init_spi(sx127x_t *dev) /* Setup SPI for SX127X */ res = spi_init_cs(dev->params.spi, dev->params.nss_pin); +#ifdef MODULE_PERIPH_SPI_GPIO_MODE + spi_gpio_mode_t gpio_modes = { + .mosi = (GPIO_OUT | SX127X_DIO_PULL_MODE), + .miso = (SX127X_DIO_PULL_MODE), + .sclk = (GPIO_OUT | SX127X_DIO_PULL_MODE), + }; + res += spi_init_with_gpio_mode(dev->params.spi, gpio_modes); +#endif + if (res != SPI_OK) { DEBUG("[sx127x] error: failed to initialize SPI_%i device (code %i)\n", dev->params.spi, res);