<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GPIO Patterns That Scale on Embedded Systems Development</title><link>https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/</link><description>Recent content in GPIO Patterns That Scale on Embedded Systems Development</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/index.xml" rel="self" type="application/rss+xml"/><item><title>Pin Configuration Across HALs</title><link>https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/pin-configuration-across-hals/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/pin-configuration-across-hals/</guid><description>&lt;h1 id="pin-configuration-across-hals"&gt;Pin Configuration Across HALs&lt;a class="anchor" href="#pin-configuration-across-hals"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Every GPIO pin on every MCU needs at least three decisions before it does anything useful: direction (input or output), output type (push-pull or open-drain), and pull resistor state (up, down, or none). Some families add speed class and alternate function mapping. The register layouts differ wildly across vendors, and the HAL abstractions differ even more. Understanding what each layer actually configures — and what it silently defaults — prevents the class of bugs where a pin &amp;ldquo;should work&amp;rdquo; but the mode register is wrong.&lt;/p&gt;</description></item><item><title>Atomic Port Access &amp; Bit-Banding</title><link>https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/atomic-port-access/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/atomic-port-access/</guid><description>&lt;h1 id="atomic-port-access--bit-banding"&gt;Atomic Port Access &amp;amp; Bit-Banding&lt;a class="anchor" href="#atomic-port-access--bit-banding"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;Setting or clearing a GPIO pin seems trivial — until an interrupt fires between the read and the write. The read-modify-write pattern that every C programmer reaches for (&lt;code&gt;GPIOA-&amp;gt;ODR |= (1 &amp;lt;&amp;lt; 5)&lt;/code&gt;) is a concurrency hazard on any system where interrupts can touch the same port. ARM Cortex-M provides two hardware mechanisms to eliminate this: set/clear registers (BSRR) and bit-banding. Understanding when each applies — and what replaces them on newer cores — prevents race conditions that produce intermittent glitches no debugger can catch.&lt;/p&gt;</description></item><item><title>GPIO Abstraction Layers</title><link>https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/gpio-abstraction-layers/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/gpio-abstraction-layers/</guid><description>&lt;h1 id="gpio-abstraction-layers"&gt;GPIO Abstraction Layers&lt;a class="anchor" href="#gpio-abstraction-layers"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;A project with four GPIO pins rarely needs abstraction. A project with forty — spread across status LEDs, relay outputs, button inputs, chip selects, and enable lines — needs a system. Without one, pin assignments scatter across the codebase, active-low logic inverts in some places but not others, and a board revision that swaps two pins requires changes in a dozen files. A thin GPIO abstraction layer, built around a pin descriptor table and a handful of wrapper functions, contains all hardware-specific detail in one place and makes the rest of the firmware pin-agnostic.&lt;/p&gt;</description></item><item><title>Debouncing in Firmware</title><link>https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/debouncing-in-firmware/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://applied-ee.github.io/embedded/docs/digital-interfaces/gpio-patterns/debouncing-in-firmware/</guid><description>&lt;h1 id="debouncing-in-firmware"&gt;Debouncing in Firmware&lt;a class="anchor" href="#debouncing-in-firmware"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;A mechanical switch does not produce a clean digital transition. When the contacts close, they bounce — making and breaking contact multiple times over a period of 1-20 ms (some switches bounce for 50 ms or more). A single button press can produce 5-50 edge transitions before settling. Without debounce logic, a single press registers as multiple presses, a rotary encoder skips counts, and an interrupt-driven input floods the system with spurious events. Firmware debouncing filters this mechanical noise using time-domain analysis — waiting for the signal to remain stable before accepting the new state.&lt;/p&gt;</description></item></channel></rss>