Internal Interface Wrap
API reference
Loading...
Searching...
No Matches
Classes | Functions
SoftChipSelectGuard.h File Reference

RAII soft chip-select (assert on construct, deassert on destroy). More...

#include <utility>
Include dependency graph for SoftChipSelectGuard.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  SoftChipSelectGuard< AssertFn, DeassertFn >
 RAII soft-CS: runs assert_fn on construction and deassert_fn on destruction (including early return / error paths). More...
 

Functions

template<typename AssertFn , typename DeassertFn >
SoftChipSelectGuard< AssertFn, DeassertFn > MakeSoftChipSelectGuard (AssertFn assert_fn, DeassertFn deassert_fn) noexcept
 Deduce guard type from assert/deassert callables.
 

Detailed Description

RAII soft chip-select (assert on construct, deassert on destroy).

Use around a single SPI frame (or an intentional multi-byte burst that must stay under one CS assertion). Pair with a bus mutex held for the whole mode + FIFO + transfer window — this guard only owns the CS pin edges.

Note
Does not replace bus locking. Callers must already own the SPI bus mutex so peers cannot change CPOL/CPHA or steal the peripheral.

Function Documentation

◆ MakeSoftChipSelectGuard()

SoftChipSelectGuard< AssertFn, DeassertFn > MakeSoftChipSelectGuard ( AssertFn  assert_fn,
DeassertFn  deassert_fn 
)
noexcept

Deduce guard type from assert/deassert callables.