<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>How to determine the context of a callback</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59552/how-to-determine-the-context-of-a-callback</link><description>Hi, 
 I am encountering some difficulties to undertand the context in which my sdk modules call back are called. I am using the uart part of ble uart nus example, and thus the app_uart module. I was wondering if uart_event_handle was called from one interrupt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 30 Mar 2020 06:39:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59552/how-to-determine-the-context-of-a-callback" /><item><title>RE: How to determine the context of a callback</title><link>https://devzone.nordicsemi.com/thread/242286?ContentTypeID=1</link><pubDate>Mon, 30 Mar 2020 06:39:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ad7fe45-ec97-4c0c-a152-a99dffd0322f</guid><dc:creator>benjamin.forest</dc:creator><description>&lt;p&gt;Thanks a lot, I will use this solution nex time :). Have a nice day,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to determine the context of a callback</title><link>https://devzone.nordicsemi.com/thread/242057?ContentTypeID=1</link><pubDate>Fri, 27 Mar 2020 10:16:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:901bf384-1815-44f5-903e-eca0738fe4f1</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The app uart library does not include support for the app scheduler so the callback is reported in the UART interrupt context. Generally, I think the easiest way to find this out by debugging the application in an IDE. Below is a screenshot I took from&amp;nbsp; Segger Embedded studio when I have hit a breakpoint in the UART callback. As you can see from the call stack, the UART IRQ handler is called first followed by some event handling before notifying the app directly through the registered callback. The ISR number shown in the xPSR register on the right would have been zero if the callback was invoked in main context through the app scheduler, etc.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-d59d3e14215c4a878e10ca184a836656/debug.PNG" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It&amp;#39;s also possible to use the &lt;a title="current_int_priority_get" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__app__util__platform.html#gae0060efdc9642d12141449a3433aeb05"&gt;current_int_priority_get() &lt;/a&gt;&lt;/span&gt;&lt;span&gt;function in your code if you want to check if you are in an interrupt context or not programmatically. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>