[riot-notifications] [RIOT-OS/RIOT] stm32-common/spi: allow custom pin modes on spi to minimize power consumption (#11542)

Francisco notifications at github.com
Thu May 23 15:56:22 CEST 2019

fjmolinas requested changes on this pull request.

I tested it on nucleo-l073rz + mbed sx1272 shield but it doesn't work :(. Setting the SPI settings after initializing the the GPIO's functions breaks the AF initialization somehow. But if you re-initiliaze the AF settings after the GPIO's modes it works! Consumption goes from ~90uA to ~10ua for the while system.

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

For this to work you need to also do:    

    gpio_init_af(spi_config[bus].mosi_pin, spi_config[bus].af);
    gpio_init_af(spi_config[bus].miso_pin, spi_config[bus].af);
    gpio_init_af(spi_config[bus].sclk_pin, spi_config[bus].af);

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190523/5291e694/attachment.html>

More information about the notifications mailing list