<?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>Declaring timers</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61233/declaring-timers</link><description>I want to include a timer within a structure and also within an array. However the SDK uses a macro to define the declaration of a timer. App_timer.h recommends not to define. 
 Is there a recommended method that can be used? 
 Eg. 
 typedef struct {</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 May 2020 14:27:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61233/declaring-timers" /><item><title>RE: Declaring timers</title><link>https://devzone.nordicsemi.com/thread/249231?ContentTypeID=1</link><pubDate>Mon, 11 May 2020 14:27:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:962140f7-5813-4944-909c-2f65b72510fa</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Malcolm,&lt;/p&gt;
&lt;p&gt;No, that should be good. And just to be clear, CONCAT_2 in turn, is just basic concatenation (##). So if the timer was &amp;quot;my_timer&amp;quot; then you would have &amp;quot;my_timer&amp;quot; and &amp;quot;my_timer_data&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Declaring timers</title><link>https://devzone.nordicsemi.com/thread/249226?ContentTypeID=1</link><pubDate>Mon, 11 May 2020 14:18:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:931e4259-68ec-433c-be6b-c82efb50fb5d</guid><dc:creator>Malcolm</dc:creator><description>&lt;p&gt;Thank you for a prompt response. I have basically followed your method (less CONCAT2). It is helpful to know I did not miss any alternative.&lt;/p&gt;
&lt;p&gt;Malcolm&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Declaring timers</title><link>https://devzone.nordicsemi.com/thread/249202?ContentTypeID=1</link><pubDate>Mon, 11 May 2020 13:06:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eda66bf7-892c-4499-a7f8-969b25f97e7f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is no recommended way (this is not recommended since it is easy to get things wrong). If you do, remember to look closely at the&amp;nbsp;_APP_TIMER_DEF implementation, or observe the preprocessor output to be sure that you did not miss anything. Assuming you use SDK 16 you are probably using app_timer2, and&amp;nbsp;then this is what you need:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define _APP_TIMER_DEF(timer_id)                                      \
    static app_timer_t CONCAT_2(timer_id,_data) = { {0} };           \
    static const app_timer_id_t timer_id = &amp;amp;CONCAT_2(timer_id,_data)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>