Skip to content

Commit

Permalink
drivers/sx127x: let sx127x driver manage spi pins GPIO modes
Browse files Browse the repository at this point in the history
  • Loading branch information
aabadie committed May 20, 2019
1 parent 3d2b16d commit 1dbc1e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,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
Expand Down
9 changes: 9 additions & 0 deletions drivers/sx127x/sx127x.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,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_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);
Expand Down

0 comments on commit 1dbc1e0

Please sign in to comment.