<?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>Service event handler: IRQ callback or FreeRTOS task?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/36360/service-event-handler-irq-callback-or-freertos-task</link><description>I want to fully understand the use of RTOS in conjunction with the stack. As an example, I took an example ble_app_hrs_freertos (SDK v15.0). 
 
 Add a service, for example, BAS. Event handler for this service: 
 
 
 When start the project, a task is created</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Sep 2018 06:44:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/36360/service-event-handler-irq-callback-or-freertos-task" /><item><title>RE: Service event handler: IRQ callback or FreeRTOS task?</title><link>https://devzone.nordicsemi.com/thread/147924?ContentTypeID=1</link><pubDate>Mon, 10 Sep 2018 06:44:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:125c3484-149e-4031-a6be-85913c37b2b8</guid><dc:creator>CheMax</dc:creator><description>&lt;p&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span class=""&gt;My question was not connected with the periphery, but with callback functions for services.&lt;/span&gt; &lt;span class=""&gt;this is essentially part of the stack.&lt;/span&gt;&lt;/span&gt; And in my case, I do not use the library from NRF to work with peripherals.&lt;/span&gt; &lt;span class=""&gt;so I can not say exactly how it will be with interrupts.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=""&gt;I independently fully configure and control the periphery, including enabling and describing the interrupt vector.&lt;/span&gt; &lt;span class=""&gt;in this case I am forced to use the function _FromISR.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" lang="en"&gt;&lt;span class=""&gt;&lt;span class="" id="result_box" lang="en"&gt;I can assume that the callback functions you describe are not called in the context of the operating system. and therefore it is necessary to use the suffix _FromISR.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Service event handler: IRQ callback or FreeRTOS task?</title><link>https://devzone.nordicsemi.com/thread/147891?ContentTypeID=1</link><pubDate>Sat, 08 Sep 2018 23:12:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3731996c-eef0-4e3d-a70f-ce8c80653f7a</guid><dc:creator>secondbest</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/eyalasko"&gt;eyalasko&lt;/a&gt;&amp;nbsp;;&lt;/p&gt;
&lt;p&gt;Can you find any answer about this question? I got error during freertos and spi?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Service event handler: IRQ callback or FreeRTOS task?</title><link>https://devzone.nordicsemi.com/thread/146927?ContentTypeID=1</link><pubDate>Mon, 03 Sep 2018 09:21:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfa0037d-a0aa-41a5-a0be-320784d12585</guid><dc:creator>eyalasko</dc:creator><description>&lt;p&gt;Hello Aryan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m facing the same questions as &lt;a href="https://devzone.nordicsemi.com/members/chemax"&gt;CheMax&lt;/a&gt; - Do all interrupts captured by the softdevice and serviced by the application in the event handlers in a (freertos) task context ?&lt;/p&gt;
&lt;p&gt;Specifically I would like to verify that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GPIO interrupts - serviced in freertos task context in a callback registered by&amp;nbsp;nrf_drv_gpiote_in_init() ?&lt;/li&gt;
&lt;li&gt;UART interrupts - serviced in freertos task context in a callback registered by&amp;nbsp;NRF_SERIAL_CONFIG_DEF() macro ?&lt;/li&gt;
&lt;li&gt;TWI interrupts - serviced &lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;in freertos task context in a callback registered in&amp;nbsp;nrf_drv_twi_init() ?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;SPI interrupt -&amp;nbsp;serviced in freertos task context in a callback registered by&amp;nbsp;NRF_SPI_MNGR_TRANSACTION_SET_DEFAULT() macro ?&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;If this is indeed the case, in what scenario will callback run in a &amp;#39;true&amp;#39; interrupt context (ISR)with/without softdevice. On what conditions should I use freertos&amp;#39;&amp;nbsp; _fromISR() api ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Many thanks in advance&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Service event handler: IRQ callback or FreeRTOS task?</title><link>https://devzone.nordicsemi.com/thread/140147?ContentTypeID=1</link><pubDate>Mon, 16 Jul 2018 05:55:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c00ce1f-bd49-4e29-a720-dc4293a31153</guid><dc:creator>CheMax</dc:creator><description>&lt;p&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span&gt;Many thanks,&lt;/span&gt; &lt;span class="user-name"&gt; &lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/aryan"&gt; Aryan.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;In the near future, I may have new questions))).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;best regards,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" lang="en"&gt;&lt;span&gt;Max&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Service event handler: IRQ callback or FreeRTOS task?</title><link>https://devzone.nordicsemi.com/thread/140138?ContentTypeID=1</link><pubDate>Sun, 15 Jul 2018 19:38:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ceff841f-f236-4872-a62b-93ce5110530d</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;No, the event handler itself is not called from ISR context, it is called from the task context so you do not need FromISR postfix.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Service event handler: IRQ callback or FreeRTOS task?</title><link>https://devzone.nordicsemi.com/thread/140113?ContentTypeID=1</link><pubDate>Sat, 14 Jul 2018 08:08:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fd15e90-2e4f-4e9a-977a-bcaefaeca449</guid><dc:creator>CheMax</dc:creator><description>&lt;p&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span&gt;Thank &lt;span class="user-name"&gt; &lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/aryan"&gt; Aryan&lt;/a&gt;&lt;/span&gt;,&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=""&gt;I understand that if I want to pass the event of enabling a notification for this service to the task I need, I should use the api function for interrupts (&lt;span class="short_text" id="result_box" lang="en"&gt;with a suffix&lt;/span&gt; FromIsr).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=""&gt;For example, this:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" lang="en"&gt;&lt;span class=""&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void ads_cds_evt(cds_svc_t *cds_service, cds_svc_evt_t *p_evt)
{
  NRF_LOG_INFO(&amp;quot;Incoming event: %d&amp;quot;, p_evt-&amp;gt;evt_type);
  switch(p_evt-&amp;gt;evt_type)
  {
    case CDS_SVC_EVT_NOTIFICATION_ENABLED: 
     xEventGroupSetBitsFromISR(eAdsFlags, eAdsEvtNtfEnable, NULL);
    break;
    
    ...
  }
}&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" lang="en"&gt;&lt;span class=""&gt;&lt;span class="short_text" id="result_box" lang="en"&gt;Is not it?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Service event handler: IRQ callback or FreeRTOS task?</title><link>https://devzone.nordicsemi.com/thread/140094?ContentTypeID=1</link><pubDate>Fri, 13 Jul 2018 15:53:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3d46f82-5bd6-4197-87b1-6fe09ee7c057</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Very nice questions CheMax,&lt;/p&gt;
&lt;p&gt;1) You could have directly handled all the services from this IRQ like a non-RTOS standalone application, then you know, it doesn&amp;#39;t look neat to process so much in the interrupts when we can do that better in the RTOS tasks. To answer you question, services are handled in the task.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2) You have pasted the code snippet exactly where this happens. The event handling is done in the task that suspends itself until the SWI interrupt resumes it to process incoming events.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>