Sound Byte Libs 0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
control.hpp File Reference

ARM Cortex-M interrupt masking primitives. More...

Detailed Description

ARM Cortex-M interrupt masking primitives.

Two masks, two jobs:

  • BASEPRI raises the execution priority to a ceiling. Handlers above the ceiling keep running — the audio ISR is never delayed by a critical section anywhere in main or control code. ScopedControlCritical is the default critical section.
  • PRIMASK stops every configurable exception, audio included. It is for death paths (assert, fault) and nothing else.

The rule (research doc §4.3 item 10): nothing above the ceiling touches state that main or the control tick protect; nothing at or below it uses PRIMASK. Cortex-M7 r1p1 (the STM32H750) does not carry the r0p1 BASEPRI erratum 837070, so a plain MSR is correct.

On targets without BASEPRI (ARMv6-M) or on the host, the BASEPRI primitives are no-ops: the workbench has no interrupts to mask, and the bridge invariants are enforced by construction there (single control context, see FDP-073).

Definition in file control.hpp.

#include <cstdint>
#include <sbl/hw/hal/interrupts/types.hpp>

Go to the source code of this file.

Classes

class  sbl::hal::interrupts::ScopedControlCritical
 RAII critical section against the control tick and everything below. More...
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs code.
 
namespace  sbl::hal
 Hardware abstraction: handles and convenience layers over the drivers.
 
namespace  sbl::hal::interrupts
 Interrupt priorities and critical sections.
 

Functions

uint32_t sbl::hal::interrupts::get_basepri ()
 Read BASEPRI (0 = no ceiling).
 
void sbl::hal::interrupts::set_basepri (uint32_t encoded)
 Write BASEPRI unconditionally (used to restore a saved value).
 
void sbl::hal::interrupts::raise_basepri (uint32_t encoded)
 
uint32_t sbl::hal::interrupts::disable_and_save ()
 Disable all configurable exceptions and return the previous PRIMASK.
 
void sbl::hal::interrupts::restore (uint32_t saved_state)
 Restore PRIMASK from disable_and_save().
 
uint32_t sbl::hal::interrupts::get_state ()
 Current PRIMASK (0 = enabled, 1 = disabled).
 
bool sbl::hal::interrupts::are_enabled ()
 True if configurable exceptions are enabled (PRIMASK clear).