Skip to content

A set of general utilities for embedded firmware projects

License

Notifications You must be signed in to change notification settings

embetech-official/embeutils

Repository files navigation

Embeutils - utilities for embedded firmware projects

Unit Tests GitHub Release GitHub License Codacy Badge Quality Gate Status

This is a small header-only library with some tools that are usefull for embedded firmware projects.
The tools include:

  • compiler_support.h which provides a set of macros controlling compiler-specific attributes
  • endianess.h which provides tools for manipulating the endianess
  • expect.h which provides a set of tools to organize error handling and make it more explicit

Quick start

1. Get the library

include(FetchContent)

# Remove FIND_PACKAGE_ARGS when using CMake < 3.24
FetchContent_Declare(embeutils https://github.com/embetech-official/embeutils/archive/refs/tags/v1.zip FIND_PACKAGE_ARGS)


# If you need to set configuration options, this is the last spot to do so

FetchContent_MakeAvailable(embeutils)

2. Link with your target

target_link_libraries(my_target PRIVATE embetech::utils)

3. All set to go

#include <embetech/expect.h>

void do_work(void* data) {
    EXPECT(data != NULL) OR_ABORT("data must be non-null");
}

Components

Endianness support

The component provides functions to convert data representation between little- and big-endian. When using C11 compliant compiler, there are Generic selection conversion macros.

Compiler support

Contracts

Configuration

  • EMBEUTILS_EXPECT_VERBOSE: Force enables verbose messages in EXPECT macros.

  • EMBEUTILS_EXTRA_CHECKS : Force enables additional runtime checks (executed via EXPECT_EXTRA macro)

Important

The default behaviour is to enable both EXPECT_EXTRA and verbose messages in DEBUG build configuration. If you wish to force disable the options, unset appropriate cache variables and set non-cache variables to OFF