Header-only utility library for bare-metal embedded systems (C99/C11/C++).
Single file. Zero dependencies. No allocation. No RTOS required.
- Register manipulation (
EU_REG_SET,EU_REG_CLR,EU_REG_MODIFY_CRITICAL) - Bit operations (
EU_BIT,EU_BIT_MASK,EU_BIT_FIELD_GET/SET) - Type-safe
MIN/MAX/SWAP/CLAMP(single evaluation on GCC/Clang) - Saturation arithmetic (signed & unsigned, 16/32-bit)
- Byte swap and endianness helpers (
EU_HTONS/L,EU_NTOHS/L) - Bit counting (
EU_CLZ,EU_CTZ,EU_POPCOUNT) - Memory barriers for ARM Cortex-M (
EU_DMB/DSB/ISB) - Timeout loop helper (
EU_WAIT_WHILE) - Compiler attributes (
EU_PACKED,EU_ALIGNED,EU_WEAK, ...) - Terse fixed-width type aliases (
u8/s32/vu32/vcu32p/...)
/* Optional: configure critical section for your platform */
#define EU_ENTER_CRITICAL() __disable_irq()
#define EU_EXIT_CRITICAL() __enable_irq()
/* Optional: set your application version */
#define APP_VERSION_MAJOR 1
#define APP_VERSION_MINOR 0
#define APP_VERSION_PATCH 0
#include "emb_utils.h"
/* Register manipulation */
EU_REG_MODIFY_CRITICAL(GPIOA->MODER, EU_BIT_MASK(7, 6), EU_BIT(6));
/* Bit field extract */
uint32_t val = EU_BIT_FIELD_GET(spi->DR, 15, 8);
/* Saturated addition */
int32_t result = eu_sat_add_s32(INT32_MAX, 100); /* INT32_MAX */| Compiler | Status |
|---|---|
| GCC (arm-none-eabi) | Full support |
| Clang | Full support |
| MSVC | Core macros work, type-safe features fallback |
BSD-3-Clause. See LICENSE file.