[riot-notifications] [RIOT-OS/RIOT] cpu/stm32l1: optimize power consumption (#11359)

Alexandre Abadie notifications at github.com
Mon Apr 8 21:37:55 CEST 2019


aabadie commented on this pull request.

Is it possible to avoid hard coded values ?

> @@ -49,6 +50,44 @@ void cpu_init(void)
     periph_clk_en(APB1, BIT_APB_PWREN);
     /* initialize the system clock as configured in the periph_conf.h */
     stmclk_init_sysclk();
+
+#if defined(CPU_FAM_STM32L1)
+    uint32_t ahb_gpio_clocks;
+    GPIO_TypeDef *port;
+
+    /* enable GPIO clock and save GPIO clock configuration */
+    ahb_gpio_clocks = RCC->AHBENR & 0xFF;

Is there a define for `0xff` in the cmsis header file ? Maybe use it instead of hard coded values.

> @@ -49,6 +50,44 @@ void cpu_init(void)
     periph_clk_en(APB1, BIT_APB_PWREN);
     /* initialize the system clock as configured in the periph_conf.h */
     stmclk_init_sysclk();
+
+#if defined(CPU_FAM_STM32L1)
+    uint32_t ahb_gpio_clocks;
+    GPIO_TypeDef *port;
+
+    /* enable GPIO clock and save GPIO clock configuration */
+    ahb_gpio_clocks = RCC->AHBENR & 0xFF;
+    periph_clk_en(AHB, 0xFF);
+
+    /* switch all GPIOs to AIN mode to minimize power consumption */
+    /* can't be more than 12 ports on STM32L1 */
+    for (int i = 0; i < 12; i++) {

Why 12 ? It seems to me that there are 8 ports on stm32l1. Do you have any reference for this ?

> +                /* preserve JTAG pins on PORTA and PORTB */
+                case 0:
+                    port->MODER = 0xABFFFFFF;
+                    break;
+                case 1:
+                    port->MODER = 0xFFFFFEBF;
+                    break;
+                default:
+                    port->MODER = 0xFFFFFFFF;
+                    break;
+            }
+#else
+            port->MODER = 0xFFFFFFFF;
+#endif
+        }
+        else {

This else should at the end of the line above.

-- 
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/11359#pullrequestreview-224042373
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190408/5f7e9965/attachment.html>


More information about the notifications mailing list