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

Francisco notifications at github.com
Mon Jul 22 16:03:50 CEST 2019


fjmolinas commented on this pull request.

I tested on nucleo-l073rz + sx1272 mbed shield. I like the latest version where the pins mode is defined per driver and not per board. 

I applied this diff to `examples/lorawan` and was getting 12uA consumption when in stop mode mode (I also added `CFLAGS=-DDISABLE_LORAMAC_DUTYCYCLE` since the timers are not running in sleep mode):

```
diff --git a/examples/lorawan/Makefile b/examples/lorawan/Makefile
index 8265c73ee..23d40c6a9 100644
--- a/examples/lorawan/Makefile
+++ b/examples/lorawan/Makefile
@@ -25,6 +25,7 @@ USEPKG += semtech-loramac
 USEMODULE += $(DRIVER)
 USEMODULE += fmt
 FEATURES_REQUIRED += periph_rtc
+FEATURES_OPTIONAL += periph_eeprom
 
 CFLAGS += -DDEVEUI=\"$(DEVEUI)\" -DAPPEUI=\"$(APPEUI)\" -DAPPKEY=\"$(APPKEY)\"
 
diff --git a/examples/lorawan/main.c b/examples/lorawan/main.c
index 20cc066f3..a73ecaceb 100644
--- a/examples/lorawan/main.c
+++ b/examples/lorawan/main.c
@@ -26,6 +26,7 @@
 #include "msg.h"
 #include "thread.h"
 #include "fmt.h"
+#include "periph/pm.h"
 
 #include "periph/rtc.h"
 
@@ -52,6 +53,7 @@ static void rtc_cb(void *arg)
     (void) arg;
     msg_t msg;
     msg_send(&msg, sender_pid);
+    pm_block(1);
 }
 
 static void _prepare_next_alarm(void)
@@ -62,6 +64,8 @@ static void _prepare_next_alarm(void)
     time.tm_sec += PERIOD;
     mktime(&time);
     rtc_set_alarm(&time, rtc_cb, NULL);
+    semtech_loramac_save_config(&loramac);
+    pm_unblock(1);
 }
 
 static void _send_message(void)
@@ -122,7 +126,8 @@ int main(void)
      * keys.
      */
     puts("Starting join procedure");
-    if (semtech_loramac_join(&loramac, LORAMAC_JOIN_OTAA) != SEMTECH_LORAMAC_JOIN_SUCCEEDED) {
+    uint8_t ret = semtech_loramac_join(&loramac, LORAMAC_JOIN_OTAA);
+    if ((ret != SEMTECH_LORAMAC_JOIN_SUCCEEDED) && (ret != SEMTECH_LORAMAC_ALREADY_JOINED)) {
         puts("Join procedure failed");
         return 1;
     }

```

IMO this is a good change and although I would like more feedback on the api change this has been going for a while so lets not stall this any longer. I think something like this is necessary for proper low-power.

I would move for now the definition of `spi_init_with_gpio_mode` to `stm32_common/include/periph_cpu_common`, and make sure it shows up in doxygen. Once this is done please squash, there are some commits that override each other.




-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11542#pullrequestreview-264836728
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190722/159a987e/attachment-0001.htm>


More information about the notifications mailing list