<?xml-stylesheet type="text/xsl" href="https://community.element14.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/"><channel><title>OO Library to handle Pico PIO relative interrupts: intro</title><link>/products/raspberry-pi/b/blog/posts/oo-library-to-handle-pico-pio-relative-interrupts-intro</link><description>Object Oriented library to design C++ classes that support PIO interrupts. Goal: make a PIO state machine call the very C++ object that&amp;#39;s managing (or watching) it.




When I designed a Pico library to manage stepper motors with the PIO co-cont...</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: OO Library to handle Pico PIO relative interrupts: intro</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/oo-library-to-handle-pico-pio-relative-interrupts-intro</link><pubDate>Wed, 27 Aug 2025 13:41:04 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:429fb33d-833f-44e3-97df-b933c7aeb59f</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;span&gt;How to use the library, with example:&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;a class="ui-contentpeek internal-link" href="/products/raspberry-pi/b/blog/posts/oo-library-to-handle-pico-pio-relative-interrupts" data-contentid="0da272cbebad486b9805aeff96f7425d" data-contenttypeid="f7d226abd59f475c9d224a79e3f0ec07" data-e14adj="t"&gt;OO Library to handle Pico PIO relative interrupts: usage and example&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;img alt="image" height="428" src="/resized-image/__size/998x856/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-429fb33d-833f-44e3-97df-b933c7aeb59f/2025_5F00_08_5F00_27-14_5F00_57-Office-Lens.jpg" width="499" /&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29159&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: OO Library to handle Pico PIO relative interrupts: intro</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/oo-library-to-handle-pico-pio-relative-interrupts-intro</link><pubDate>Tue, 26 Aug 2025 19:00:12 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:429fb33d-833f-44e3-97df-b933c7aeb59f</guid><dc:creator>DAB</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Great solution to the problem Jan.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29159&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: OO Library to handle Pico PIO relative interrupts: intro</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/oo-library-to-handle-pico-pio-relative-interrupts-intro</link><pubDate>Mon, 25 Aug 2025 19:51:42 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:429fb33d-833f-44e3-97df-b933c7aeb59f</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;All 12 available PIO state machines on a Pico2 having all their PIO relative interrupts managed by&amp;nbsp;their own&amp;nbsp;object:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="349" src="/resized-image/__size/498x698/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-429fb33d-833f-44e3-97df-b933c7aeb59f/pastedimage1756151494792v1.png" width="249" /&gt;&lt;/p&gt;
&lt;p&gt;This is captured on&amp;nbsp;a RISCV core. It works the same on the ARMs&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29159&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: OO Library to handle Pico PIO relative interrupts: intro</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/oo-library-to-handle-pico-pio-relative-interrupts-intro</link><pubDate>Mon, 25 Aug 2025 15:26:00 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:429fb33d-833f-44e3-97df-b933c7aeb59f</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Early results:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="340" src="/resized-image/__size/950x680/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-429fb33d-833f-44e3-97df-b933c7aeb59f/pastedimage1756134757531v1.png" width="475" /&gt;&lt;/p&gt;
&lt;p&gt;The mechanism works. A&amp;nbsp;single class with 2 public methods supports the mechanism.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " height="138" src="/resized-image/__size/992x276/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-429fb33d-833f-44e3-97df-b933c7aeb59f/2025_5F00_08_5F00_25-17_5F00_21-Office-Lens.jpg" width="496" /&gt;&lt;/p&gt;
&lt;p&gt;One to tell that we&amp;#39;re interested in managing an interrupt. The other to register the object that will handle the interrupt.&lt;/p&gt;
&lt;p&gt;The screen capture shows a minimal handler, that just prints a message and counts how many times it&amp;#39;s been invoked.&amp;nbsp;&lt;br /&gt;The only requirement for a handler class is that it has line 15. All other implementation parts are for demo use.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29159&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: OO Library to handle Pico PIO relative interrupts: intro</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/oo-library-to-handle-pico-pio-relative-interrupts-intro</link><pubDate>Sun, 24 Aug 2025 19:58:25 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:429fb33d-833f-44e3-97df-b933c7aeb59f</guid><dc:creator>Jan Cumps</dc:creator><slash:comments>1</slash:comments><description>&lt;p&gt;C++ has a mechanism to enforce that a class has to provide particular operations. This allows to only accept classes and objects that&amp;nbsp;can do a particular thing, without the need for a base class. And without inheritance.&lt;/p&gt;
&lt;p&gt;In the lib that I&amp;#39;m writing, it&amp;#39;s expected that the objects you pass to it for interrupt handling, can actually be executed. They need to provide the &lt;strong&gt;()&lt;/strong&gt; operator.&lt;/p&gt;
&lt;p&gt;C++ has concepts. Guards that you can use to investigate capabilities at compile time. There are standard ones, and you can define your own checks.&lt;/p&gt;
&lt;p&gt;In this case, I&amp;#39;m lucky, because there is a standard concept to check if a template type can be executed:&amp;nbsp;&lt;strong&gt;std::&lt;/strong&gt;&lt;span&gt;&lt;strong&gt;invocable&lt;/strong&gt;. If I set that as a requirement for a template parameter, the code will not compile if you use the template class with a type that doesn&amp;#39;t have the &lt;strong&gt;()&lt;/strong&gt; operator:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:35c030e2-a539-48b3-98e6-664149393e90:type=csharp&amp;text=%2F%2F%20guard%20that%20E%20has%20to%20support%20%28%29%20operator.%0D%0Atemplate%20%3Cstd%3A%3Ainvocable%20E%2C%20uint32_t%20interrupt_number%3E%20class%20pio_irq%20%7B]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This is a help to the user of the library. They get a clear message that they are using the library with objects that aren&amp;#39;t fit to handle the interrupts.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " height="53" src="/resized-image/__size/1414x106/__key/commentfiles/f7d226abd59f475c9d224a79e3f0ec07-429fb33d-833f-44e3-97df-b933c7aeb59f/pastedimage1756065465801v1.png" width="707" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The nice thing is that E can actually be a simple function pointer. Doesn&amp;#39;t need to be a class with &lt;strong&gt;()&lt;/strong&gt; operator.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Another nice thing is that the runtime cost is zero.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29159&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item><item><title>RE: OO Library to handle Pico PIO relative interrupts: intro</title><link>https://community.element14.com/products/raspberry-pi/b/blog/posts/oo-library-to-handle-pico-pio-relative-interrupts-intro</link><pubDate>Sun, 24 Aug 2025 12:28:36 GMT</pubDate><guid isPermaLink="false">93d5dcb4-84c2-446f-b2cb-99731719e767:429fb33d-833f-44e3-97df-b933c7aeb59f</guid><dc:creator>shabaz</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Looking forward to this! And it&amp;#39;s becoming more relevant since number of PIO are increasing in each RPxxxx chip generation it seems. It will remove a bit of the &amp;#39;wild west&amp;#39; when it comes to developing with them, when there are decent libraries to help with these common tasks.&lt;/p&gt;&lt;img src="https://community.element14.com/aggbug?PostID=29159&amp;AppID=86&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</description></item></channel></rss>