/gpio-baremetal
Bare-metal GPIO skill for pin configuration and interrupts. Use when configuring GPIO modes, alternate functions, pull resistors, or EXTI interrupts on STM32/nRF/ESP32-class MCUs. Activates on queries about GPIO MODER, alternate function, pin interrupt, or LED/button bare-metal
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill gpio-baremetal --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/gpio-baremetal
Context preview
The summary Claude sees to decide when to auto-load this skill.
Bare-metal GPIO skill for pin configuration and interrupts. Use when configuring GPIO modes, alternate functions, pull resistors, or EXTI interrupts on STM32/nRF/ESP32-class MCUs. Activates on queries about GPIO MODER, alternate function, pin interrupt, or LED/button bare-metal
SKILL.md
gpio-baremetal.SKILL.mdname: gpio-baremetal
description: Bare-metal GPIO skill for pin configuration and interrupts. Use when configuring GPIO modes, alternate functions, pull resistors, or EXTI interrupts on STM32/nRF/ESP32-class MCUs. Activates on queries about GPIO MODER, alternate function, pin interrupt, or LED/button bare-metal setup.
GPIO (Bare-Metal)
Purpose
Configure and use GPIO without HAL: input/output modes, alternate function mapping, pull-up/down, speed/slew, and pin-change interrupts for LEDs, buttons, and peripheral pin mux.
When to Use
- Blink LED or read button before bringing up UART/SPI
- Mux pins to USART/SPI alternate functions
- EXTI line interrupts on pin edges
- Porting GPIO code between vendors
Workflow
1. STM32 GPIO pattern
/* Enable GPIOA clock */
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
/* PA5 output — MODER[11:10] = 01 */
GPIOA->MODER &= ~(3U << (5 * 2));
GPIOA->MODER |= (1U << (5 * 2));
/* Toggle via BSRR — atomic set/reset */
GPIOA->BSRR = (1U << 5); /* set */
GPIOA->BSRR = (1U << (5+16)); /* reset */
Alternate function (e.g., USART2 TX on PA2):
GPIOA->MODER &= ~(3U << (2*2));
GPIOA->MODER |= (2U << (2*2)); /* AF mode */
GPIOA->AFR[0] &= ~(0xFU << (2*4));
GPIOA->AFR[0] |= (7U << (2*4)); /* AF7 = USART2 */
2. Input with pull-up
/* PC13 input, pull-up */
GPIOC->MODER &= ~(3U << (13*2)); /* input mode 00 */
GPIOC->PUPDR &= ~(3U << (13*2));
GPIOC->PUPDR |= (1U << (13*2)); /* pull-up */
int pressed = !(GPIOC->IDR & (1U << 13)); /* active low */
3. EXTI interrupt (STM32)
/* SYSCFG: map EXTI13 to PC13 */
SYSCFG->EXTICR[3] = (SYSCFG->EXTICR[3] & ~0xFU) | 0x2; /* port C */
EXTI->IMR |= (1U << 13);
EXTI->FTSR |= (1U << 13); /* falling edge */
NVIC_EnableIRQ(EXTI15_10_IRQn);
ISR: check `EXTI->PR`, clear with write-1.
4. nRF52 / ESP32 notes
| Platform | Pattern | |----------|---------| | nRF52 | `NRF_P0->PIN_CNF[n]` — direction, pull, drive | | ESP32 | `GPIO.out_w1ts`, `GPIO.enable`; IO_MUX for function |
Always enable peripheral clock / power domain before pin config.
5. Agent usage
/gpio-baremetal Configure PA2 as USART2 TX alternate function on STM32F4
Common Problems
| Symptom | Cause | Fix | |---------|-------|-----| | Pin stuck | Wrong MODER / not AF | Re-read RM pin table | | EXTI storm | No debounce / floating input | Enable pull; debounce in software | | AF mismatch | Wrong AFR nibble | Pin-specific AF table in RM | | No toggle visible | Wrong port bit / LED active low | Check schematic |
Related Skills
- `skills/baremetal/mmio-and-bit-manipulation` — BSRR/MODER masks
- `skills/baremetal/peripherals-from-datasheet` — RM pinout tables
- `skills/baremetal/uart-serial-baremetal` — AF mux for serial
Read more
name: gpio-baremetal description: Bare-metal GPIO skill for pin configuration and interrupts. Use when configuring GPIO modes, alternate functions, pull resistors, or EXTI interrupts on STM32/nRF/ESP32-class MCUs. Activates on queries about GPIO MODER, alternate function, pin interrupt, or LED/button bare-metal setup.
GPIO (Bare-Metal)
Purpose
Configure and use GPIO without HAL: input/output modes, alternate function mapping, pull-up/down, speed/slew, and pin-change interrupts for LEDs, buttons, and peripheral pin mux.
When to Use
- Blink LED or read button before bringing up UART/SPI
- Mux pins to USART/SPI alternate functions
- EXTI line interrupts on pin edges
- Porting GPIO code between vendors
Workflow
1. STM32 GPIO pattern
/* Enable GPIOA clock */ RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; /* PA5 output — MODER[11:10] = 01 */ GPIOA->MODER &= ~(3U << (5 * 2)); GPIOA->MODER |= (1U << (5 * 2)); /* Toggle via BSRR — atomic set/reset */ GPIOA->BSRR = (1U << 5); /* set */ GPIOA->BSRR = (1U << (5+16)); /* reset */
Alternate function (e.g., USART2 TX on PA2):
GPIOA->MODER &= ~(3U << (2*2)); GPIOA->MODER |= (2U << (2*2)); /* AF mode */ GPIOA->AFR[0] &= ~(0xFU << (2*4)); GPIOA->AFR[0] |= (7U << (2*4)); /* AF7 = USART2 */
2. Input with pull-up
/* PC13 input, pull-up */ GPIOC->MODER &= ~(3U << (13*2)); /* input mode 00 */ GPIOC->PUPDR &= ~(3U << (13*2)); GPIOC->PUPDR |= (1U << (13*2)); /* pull-up */ int pressed = !(GPIOC->IDR & (1U << 13)); /* active low */
3. EXTI interrupt (STM32)
/* SYSCFG: map EXTI13 to PC13 */ SYSCFG->EXTICR[3] = (SYSCFG->EXTICR[3] & ~0xFU) | 0x2; /* port C */ EXTI->IMR |= (1U << 13); EXTI->FTSR |= (1U << 13); /* falling edge */ NVIC_EnableIRQ(EXTI15_10_IRQn);
ISR: check `EXTI->PR`, clear with write-1.
4. nRF52 / ESP32 notes
| Platform | Pattern | |----------|---------| | nRF52 | `NRF_P0->PIN_CNF[n]` — direction, pull, drive | | ESP32 | `GPIO.out_w1ts`, `GPIO.enable`; IO_MUX for function |
Always enable peripheral clock / power domain before pin config.
5. Agent usage
/gpio-baremetal Configure PA2 as USART2 TX alternate function on STM32F4
Common Problems
| Symptom | Cause | Fix | |---------|-------|-----| | Pin stuck | Wrong MODER / not AF | Re-read RM pin table | | EXTI storm | No debounce / floating input | Enable pull; debounce in software | | AF mismatch | Wrong AFR nibble | Pin-specific AF table in RM | | No toggle visible | Wrong port bit / LED active low | Check schematic |
Related Skills
- `skills/baremetal/mmio-and-bit-manipulation` — BSRR/MODER masks
- `skills/baremetal/peripherals-from-datasheet` — RM pinout tables
- `skills/baremetal/uart-serial-baremetal` — AF mux for serial
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

