Spectre = RTOS + HAL + IO + COMSTACK + CI + C++
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Spectre = RTOS + HAL + IO + COMSTACK + CI + C++

GPLv3 License Build Status Coverage Status

What ?

Spectre consists of a Real Time Operating System + a Hardware Abstraction Layer + IO driver support for various sensors, actuators and communication controllers + industrial communication stacks written mostly in C++. The codebase can be simultaneously compiled for both host and desired target platform which enables the user to run and verify the complete firmware within the host pc without the need for target hardware. Furthermore unit tests are run and code quality metrics are gathered automatically upon commit in order to ensure code quality and functionality.

Why #1?

The application of OO principles such as SOLID leads to a clean code base and minimizes coupling between modules. This enables the application of Test Driven Development which gives developers instantenous feedback on their code therefore eliminating tedious integration and bug fixing sessions typical for Debug-Later-Programming.

Why #2?

In his book "Refactoring: Improving the Design of Existing Code" Martin Fowler frankly states that “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” This project aims to do just that for the embedded domain. You are kindly invited to browse the code and form your own opinion about how well the code is adhering to our claim.


Work in progress ...

Hardware Abstraction Layers


AT90CAN32 avr at90can32
AT90CAN64 ... at90can64
AT90CAN128 ... at90can128 Olimex AVR-CAN, AL-ERAM128 V2.0
ATMega640 ... atmega640
ATMega1280 ... atmega1280
ATMega2560 ... atmega2560 Arduino Mega
ATMega164P ... atmega164p
ATMega324P ... atmega324p
ATMega644P ... atmega644p
ATMega1284P ... atmega1284p Moteino Mega USB
ATMega328P ... atmega328p Arduino Uno
ATMega16U4 ... atmega16u4
ATMega32U4 ... atmega32u4 Arduino Leonardo

Host (Test Build)

Host (Test Build) host host

I/O Device Drivers

/driver/can Examples

/driver/glcd Examples

  • RA6963 (GLCD Controller)

/driver/haptic Examples

  • DRV2605L (Haptic Driver for LRA and ERM)

/driver/ioexpander Examples

  • MCP23017 (16-Bit I/O Expander)
  • PCA9547 (8-channel I2C-Bus multiplexer)

/driver/lora Examples

/driver/memory Examples

  • AT45DBx (SPI Data Flash)
  • PCF8570 (256 × 8-Bit Static Low-Voltage RAM)

/driver/sensor Examples

  • AD7151 (1-channel capacitance converter for proximity sensing)
  • AS5600 (12-Bit programmable contactless potentiometer)
  • BMG160 (3-axis digital output MEMS gyroscope)
  • INA220 (Low- or high-side, bidirectional, I2C current monitor)
  • L3GD20 (3-axis digital output MEMS gyroscope)
  • LIS2DSH (3-axis digital output MEMS accelerometer)
  • LIS3DSH (3-axis digital output MEMS accelerometer)
  • LIS3MDL (3-axis digital output MEMS magnetometer)

/driver/serial Examples

  • UART (Serial UART Driver)

/driver/stepper Examples


  • HD44780 (Dot Matrix LCD Controller/Driver)

Communication Stacks

  • CANOpen ( Work in progress ... )

Getting started

Install toolchain

  • ALL
sudo apt-get install cmake
  • AVR
sudo apt-get install avr-libc binutils-avr gcc-avr avrdude

Clone repository

git clone https://github.com/lxrobotics/spectre.git
cd spectre

Copy and edit configuration

cp config/atmega328p-default.cmake config.cmake
vim config.cmake


mkdir build && cd build
cmake ..
sudo make install
(sudo make uninstall)

Build Example

Build Library

cp examples/debug/debug-serial-atmega328p-uart0/config.cmake config.cmake
mkdir build
cd build
cmake ..
sudo make install

Build Executable

cd examples/debug/debug-serial-atmega328p-uart0
mkdir build && cd build
cmake ..

Further Reading


Spectre is open source and licensed under version 3 of the GNU GPL. Spectre is free under this license and can be freely used and distributed under its terms.

The freedom that this GNU GPL license offers, comes with responsibilities and side effects that are not always desirable. This is especially the case if you want to integrate Spectre in your closed source product and/or don’t want your customers to know that your product contains Spectre.

As an alternative, Spectre can be made available under a commercial license. Under the commercial license, Spectre does not contain any references to the GNU GPL. Refer to the following license comparison matrix to determine the Spectre license your product requires.

Question GNU GPL version 3 Commercial License
Is Spectre free? yes no
Do I have the right to change the Spectre source code? yes yes
Can I use Spectre in my closed source product? no yes
Do I have to open my source code? yes no
Do I have to open source my changes to Spectre? yes no
Do I have to offer the Spectre source code to users of my product? yes no
Do I have to document that my product uses Spectre? yes no
Can I redistribute Spectre in source code format? yes no
Can I receive professional technical support on a commercial basis? no yes

Contact Alexander Entinger / LXRobotics GmbH (consulting@lxrobotics.com) to request additional information, customisation and/or a quote for a commercial license for the whole library or parts of it.