---
title: "Hardware spinlock"
canonical_url: https://developer.repebble.com/pebbleos/docs/drivers/hwspinlock/
last_updated: 2026-11-27
sdk_version: 4.44
---
# Hardware spinlock

Source: https://developer.repebble.com/pebbleos/docs/drivers/hwspinlock/

A hardware spinlock serializes processors that share registers or memory, where an interrupt lock only serializes the code of one. A consumer takes its lock from a devicetree `hwlocks` entry and holds it, with interrupts locked, around the accesses it shares. Without an entry, taking it only locks interrupts. Locks work before their controller is initialized, as for the pins of an early console.

| 

 | 

 |
| --- | --- |
| 

Directory

 | 

`drivers/hwspinlock`

 |
| 

Header

 | 

`pbl/drivers/hwspinlock.h`

 |
| 

Kconfig

 | 

`CONFIG_HWSPINLOCK`, selected by the drivers and code that use it

 |
| 

API

 | 

[API reference](https://developer.repebble.com/pebbleos/apidoc/d7/d31/group __drivers__ hwspinlock.html)

 |

A holder keeps a lock for a few register accesses. A processor waiting for longer than `CONFIG_HWSPINLOCK_TIMEOUT_US` gives up with `-ETIMEDOUT`: the holder stopped with it.

## Drivers

| 

Driver

 | 

Compatible

 | 

Kconfig

 |
| --- | --- | --- |
| 

STM32H7 hardware semaphores

 | 

`st,stm32-hwspinlock`

 | 

`CONFIG_HWSPINLOCK_STM32_HSEM`

 |

## Users

| 

Driver

 | 

Shares

 |
| --- | --- |
| 

STM32 pin controller and GPIO

 | 

Port registers, between the cores of an STM32H747

 |
| 

STM32 GPIO and RTC

 | 

EXTI triggers and their routing in the SYSCFG, between the cores of an STM32H747

 |

Generated from PebbleOS [013613c8a](https://github.com/coredevices/pebbleos/commit/013613c8a001fe075e5e247c4a6fe8db8f920099). This page is maintained in the pebbleos repository: [docs/drivers/hwspinlock.md](https://github.com/coredevices/pebbleos/blob/013613c8a001fe075e5e247c4a6fe8db8f920099/docs/drivers/hwspinlock.md).
