Skip to content

Repository files navigation

modm: a barebone embedded library generator

modm (pronounced like dial-up "modem") is a toolbox for building custom C++20 libraries tailored to your embedded device. modm generates startup code, HALs and their implementations, communication protocols, drivers for external devices, BSPs, etc… in a modular, customizable process that you can fine-tune to your needs.

This project also has a forum for discussions and a technical blog to document larger design concepts.

modm is optimized for the harsh requirements of the Eurobot competition, where our robots need to run reliably and completely autonomously for the game's 100 second duration. Our robots contain a lot of different microcontrollers, some without a lot of resources, so modm needs to fulfill a diverse set of objectives, like small code size with small memory consumption, predictable program flow, extreme portability.

The library source code is licensed as MPLv2 with any external source code under compatible licenses (BSD, Apache2, MIT). So feel free to fork this project and adapt it to your needs. The only thing we ask of you is to contribute your changes back so everyone can benefit.

Please clone modm recursively, you need all the submodules:

git clone --recurse-submodules --jobs 8 https://github.com/modm-io/modm.git

Features

  • Efficient and fast object-oriented C++20 API.
  • Support for hundreds of AVR and ARM Cortex-M microcontrollers from Atmel and ST.
  • Build system agnostic: Choose SCons, CMake, Makefile or use your own.
  • Data-driven, target-specific HAL generation using the lbuild engine.
  • No memory allocations in HAL with very low overall RAM consumption.
  • Highly configurable modules with sensible defaults and lots of documentation.
  • Cross-platform peripheral interfaces incl. bit banging:
    • GPIO, External Interrupt and IO expanders.
    • ADC, DAC and Comparators.
    • UART, I2C, SPI, CAN and Ethernet.
  • Interfaces and drivers for many external I2C and SPI sensors and devices.
  • Debug/logging system with IOStream and printf interface.
  • Lightweight, stackless threads and resumable functions using cooperative multitasking.
  • Functional (partial) libstdc++ implementation for AVRs.
  • Useful filter, interpolation and geometric algorithms.
  • Lightweight unit testing system (suitable for AVRs).
  • Hundreds of tests to ensure correct functionality.
  • Integration of useful third-party software:

Microcontrollers

modm can create a HAL for 3195 devices of these vendors:

  • STMicroelectronics STM32: 2621 devices.
  • Microchip SAM: 186 devices.
  • Microchip AVR: 388 devices.

Here is a table with all device families and the peripheral drivers they support:

  • ✅ Implemented as a software driver in modm.
  • ○ Available in hardware but missing a software driver in modm.
  • ✕ Unavailable in hardware or device with that peripheral not supported by modm.

Note that this is a summary overview and your specific device may not have all the peripherals in this table. Please discover modm's peripheral drivers for your specific device.

STM32SAMAT
PeripheralF0F1F2F3F4F7G0G4H7L0L1L4D21G55V7090MegaTiny
ADC
CAN
Comparator
DAC
DMA
Ethernet
External Interrupt
External Memory
GPIO
I2C
Internal Flash
Random Generator
SPI
System Clock
Timer
UART
Unique ID
USB

We are only a small team of developers and are limited in the amount of devices we can support and test in hardware. Open an issue to ask if your specific device is supported out-of-the-box and what you can do if it is not.

Boards

We have out-of-box support for many development boards including documentation.

AL-AVREB-CANArduino NANOArduino UNOBlack Pill F103
Black Pill F401Black Pill F411Blue Pill F103DEVEBOX-STM32F4XX
DEVEBOX-STM32H750VBDISCO-F051R8DISCO-F072RBDISCO-F100RB
DISCO-F303VCDISCO-F407VGDISCO-F429ZIDISCO-F469NI
DISCO-F746NGDISCO-F769NIDISCO-L152RCDISCO-L476VG
FEATHER-M0MEGA-2560-PRONUCLEO-F031K6NUCLEO-F042K6
NUCLEO-F072RBNUCLEO-F091RCNUCLEO-F103RBNUCLEO-F303K8
NUCLEO-F303RENUCLEO-F334R8NUCLEO-F401RENUCLEO-F411RE
NUCLEO-F429ZINUCLEO-F439ZINUCLEO-F446RENUCLEO-F446ZE
NUCLEO-F746ZGNUCLEO-F767ZINUCLEO-G071RBNUCLEO-G431KB
NUCLEO-G431RBNUCLEO-G474RENUCLEO-H723ZGNUCLEO-H743ZI
NUCLEO-L031K6NUCLEO-L053R8NUCLEO-L152RENUCLEO-L432KC
NUCLEO-L452RENUCLEO-L476RGNUCLEO-L496ZG-POLIMEXINO-STM32
Raspberry PiSAMD21-MINISAMG55-XPLAINED-PROSTM32-F4VE
STM32F030-DEMOSmart Response XE

Drivers

We also have a number of completely target-independent drivers for external devices connected via I2C, SPI, UART, BitBang, etc. Most of these also give you access to the entire device so you can easily configure them for you specific needs.

AD7280AAD7928ADNS9800ADS7843AMS5915APA102
SPI-FLASHBME280BMP085BNO055CAT24AADRV832X
DS1302DS1631DS18B20EA-DOGENCODER-INPUT-BITBANGENCODER-OUTPUT-BITBANG
FT245FT6X06GPIO-SAMPLERHCLAxHD44780HMC58x
HMC6343HX711I2C-EEPROMILI9341IS31FL3733ITG3200
L3GD20LAN8720ALAWICELLIS302DLLIS3DSHLIS3MDL
LM75LP503XLSM303ALSM6DS33LTC2984MAX6966
MAX7219MCP23X17MCP2515MMC5603NOKIA5110NRF24
TFT-DISPLAYPAT9125ELPCA8574PCA9535PCA9548APCA9685
SH1106SIEMENS-S65SIEMENS-S75SK6812SK9822SSD1306
ST7586SSTTS22HSTUSB4500SX1276TCS3414TCS3472
TLC594XTMP102TMP12XTMP175TOUCH2046VL53L0
VL6180WS2812

Please see our examples for a complete list of tested targets and drivers.

How can I contribute?

The easiest way for you and the best way for us to see if something is unclear or missing, is if you use the library and give us some feedback by filing a bug report or if you have a fix already opening a pull request.

See CONTRIBUTING.md for our contribution guidelines.

The modm project is maintained by Niklas Hauser (@salkinium) and Raphael Lehmann (@rleh) with significant contributions from Sascha Schade (@strongly-typed), Fabian Greif (@dergraaf), Kevin Läufer (@ekiwi), Martin Rosekeit (@thundernail), Daniel Krebs (@daniel-k), Georgi Grinshpun (@georgi-g), Christopher Durand (@chris-durand) David Hebbeker (@dhebbeker), Thorsten Lajewski (@TheTh0r), Mike Wolfram (@mikewolfram) and many more contributors.

Folder structure

examples
Example projects that show the usage of parts of the modm library. These projects are always up to date and are tested to compile by our CI.
src
This folder contains the actual source code of modm grouped into several modules.
test
Contains hundreds of tests for making sure modm works the way we expect it to.
docs
General documentation about this library and how to use it.
ext
Third-party code used in this library.
tools
Support tools, scripts and files.

About

modm: a C++17 library generator for AVR and ARM Cortex-M devices

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages