1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/sx127x: let sx127x driver manage spi pins GPIO modes

This commit is contained in:
Alexandre Abadie 2019-05-20 18:01:19 +02:00
parent cb25ed7b05
commit 340c8e8236
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
2 changed files with 10 additions and 0 deletions

View File

@ -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

View File

@ -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);