<h3>Contribution description</h3>
<p>I stumbled upon a bug in our <code>nimBLE</code> port, where I need to find out, if global interrupts are currently enabled (so far miss-use of <code>irq_is_in()</code>). So I noticed that this functionality was never included in our <code>core/irq.h</code> interface. This PR adds this function as <code>irq_is_enabled()</code> to RIOT.</p>
<p>Aside from my rather specific use case, this new function is also very useful for hardening code by including <code>assert(irq_is_enabled())</code> statements at certain critical points in the code...</p>
<p>Status of this PR:</p>
<ul>
<li>added the new function to the core interface</li>
<li>added some simple test cases to the <code>tests/irq</code> test application</li>
<li>implemented for
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> cortexm_common (verified)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> native (verified)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> msp430 (untested)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> avr8 (untested)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> esp32</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> esp8266</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> mips32</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> riscv</li>
<li>...</li>
</ul>
</li>
</ul>
<p>If we want to go on with this PR, help for the remaining architectures would be highly appreciated! So please lets decide for the concept first, and only if we agree move to further implementations and testing...</p>
<h3>Testing procedure</h3>
<p>run <code>tests/irq</code> on the target hardware</p>
<h3>Issues/PRs references</h3>
<p>none</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/11117'>https://github.com/RIOT-OS/RIOT/pull/11117</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>core/irq.h: add irq_is_enabled() function</li>
  <li>tests/irq: add enable/disable/restore sequence</li>
  <li>cpu/cortexm_common: implement irq_is_enabled()</li>
  <li>cpu/msp430: implement irq_is_enabled()</li>
  <li>cpu/native: implement irq_is_enabled()</li>
  <li>cpu/atmega_common: implement irq_is_enabled()</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11117/files#diff-0">core/include/irq.h</a>
    (11)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11117/files#diff-1">cpu/atmega_common/irq_arch.c</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11117/files#diff-2">cpu/cortexm_common/irq_arch.c</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11117/files#diff-3">cpu/msp430_common/irq.c</a>
    (19)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11117/files#diff-4">cpu/native/irq_cpu.c</a>
    (5)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/11117/files#diff-5">tests/irq/main.c</a>
    (43)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/11117.patch'>https://github.com/RIOT-OS/RIOT/pull/11117.patch</a></li>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/11117.diff'>https://github.com/RIOT-OS/RIOT/pull/11117.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/11117">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AEn7YP4jq_0SlYNJM9_p0m0AQAXFUNHSks5vT_dsgaJpZM4bhZUb">mute the thread</a>.<img src="https://github.com/notifications/beacon/AEn7YI-HEA-3MULsqVir4rHqTYj-_ztXks5vT_dsgaJpZM4bhZUb.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/RIOT-OS/RIOT","title":"RIOT-OS/RIOT","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/RIOT-OS/RIOT"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"core: add irq_is_enabled() function to irq interface (#11117)"}],"action":{"name":"View Pull Request","url":"https://github.com/RIOT-OS/RIOT/pull/11117"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/11117",
"url": "https://github.com/RIOT-OS/RIOT/pull/11117",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>