<h3>Contribution description</h3>

<p>This PR is based on previous work in <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="430559729" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/11359" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/11359/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/11359">#11359</a>, where STM32L1 has been cut from the PR.</p>
<p>On start-up it configures all GPIO's as AIN. On other boards of the STM32 family (L0 & L4) this is done by default. There for this is only done for STM32F0-7~.</p>
<p>As stated in this <a href="https://comm.eefocus.com/media/download/index/id-1013834" rel="nofollow">AN</a>, doing this saves the consumption of the input Schmitt trigger. The only case where this shouldn't be done is when the pin is connected to an external driver that has a pull-up or pull-down setting, this should be handled by pertinent drivers.</p>
<h3>Testing procedure</h3>

<p>Supply voltage for all the below measurement was 3.3V. Al pin headers where disconnected where disconnected, supply was measured directly threw the IDD pin either with a multi meter or NUCLEO-LPM01A power measurement extension.</p>
<p>As of know when entering STOP mode consumption on stm32f7 is around 1.24mA, with this PR it drops to <strong>350uA</strong> (270uA typ f746zg). To test run:</p>
<p><code>make BOARD=nucleo-f746zg -C tests/periph_pm/ flash</code></p>
<p>As of know when entering STOP mode consumption on stm32f4 is around 500uA, with this PR it drops to <strong>120uA</strong> (datasheet 120uA typ for f446re). To test run:</p>
<p><code>make BOARD=nucleo-f446re -C tests/periph_pm/ flash</code></p>
<p>As of know when entering STOP mode consumption on stm32f3 is around 1mA, with this PR it drops to <strong>15.3uA</strong> (datasheet 7.4uA typ for f303re). To test run:</p>
<p><code>make BOARD=nucleo-f303re -C tests/periph_pm/ flash</code></p>
<p>As of know when entering STOP mode consumption on stm32f2 is around 1.27mA, with this PR it drops to <strong>200uA</strong> (datasheet 200uA typ for f207zg). To test run:</p>
<p><code>make BOARD=nucleo-f207zg -C tests/periph_pm/ flash</code></p>
<p>As of know when entering STOP mode consumption on stm32f1 is around 100uA, with this PR it drops to <strong>11uA</strong> (13.5uA typ f103rb). Tested on nucleo-f103rb:</p>
<p><code>make BOARD=nucleo-f103rb -C tests/periph_pm/ flash</code></p>
<p>As of know when entering STOP mode consumption on stm32f0 is around 507uA, with this PR it drops to <strong>10.7uA</strong> (3.5uA typ f072rb). To test run:</p>
<p><code>make BOARD=nucleo-f072rb -C tests/periph_pm/ flash</code></p>
<p>NOTE: on nucleo boards if power is measured directly after programming there will be around 200uA of current consumption coming from the stlink. The stlink must start without being connected to the board or power the board externally.</p>
<h3>Issues/PRs references</h3>

<p>Based on work from <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="290576812" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/8403" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/8403/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/8403">#8403</a> & <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="364102014" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/10052" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/10052/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/10052">#10052</a>. Taken from <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="430559729" data-permission-text="Issue title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/11359" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/11359/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/11359">#11359</a>.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/RIOT-OS/RIOT/pull/11758'>https://github.com/RIOT-OS/RIOT/pull/11758</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>cpu/stm32_common: minimize consumption for STM32F0/2/3/4/7</li>
  <li>cpu/stm32_common: minimize consumption for STM32F1</li>
  <li>cpu/stm32_common: refactor gpio_pm_init_ain</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11758/files#diff-0">cpu/stm32_common/cpu_init.c</a>
    (5)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11758/files#diff-1">cpu/stm32_common/include/periph_cpu_common.h</a>
    (15)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11758/files#diff-2">cpu/stm32_common/periph/gpio.c</a>
    (80)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/11758.patch'>https://github.com/RIOT-OS/RIOT/pull/11758.patch</a></li>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/11758.diff'>https://github.com/RIOT-OS/RIOT/pull/11758.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/11758?email_source=notifications&email_token=ABE7WYCBGNIKEE7HHH5PI6DP4XEHPA5CNFSM4H4DJ4D2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4ILWYQ">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABE7WYCSXFCNBGORRYVF4VLP4XEHPANCNFSM4H4DJ4DQ">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABE7WYBTFAOV334JEPQZ7OTP4XEHPA5CNFSM4H4DJ4D2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4ILWYQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/11758?email_source=notifications\u0026email_token=ABE7WYCBGNIKEE7HHH5PI6DP4XEHPA5CNFSM4H4DJ4D2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4ILWYQ",
"url": "https://github.com/RIOT-OS/RIOT/pull/11758?email_source=notifications\u0026email_token=ABE7WYCBGNIKEE7HHH5PI6DP4XEHPA5CNFSM4H4DJ4D2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G4ILWYQ",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>