Skip to content
/ modm Public
forked from modm-io/modm

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

License

Notifications You must be signed in to change notification settings

CWndpkj/modm

 
 

Repository files navigation

modm: a barebone embedded library generator

modm (pronounced like dial-up "modem") is a toolbox for building custom C++23 libraries tailored to your embedded device. modm generates startup code, HALs and their implementations, communication protocols, drivers for external devices, and BSPs 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++23 API.
  • Support for thousands of AVR and ARM Cortex-M microcontrollers from Microchip, STMicroelectronics and Raspberry Pi.
  • Build system agnostic: Choose SCons, CMake, Makefile or use your own.
  • Modular, data-driven, target-specific HAL generation using the lbuild code generator.
  • 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.
  • Cooperative, stackless protothreads and resumable functions.
  • Cooperative, stackful fibers and scheduler.
  • 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 3779 devices of these vendors:

  • STMicroelectronics STM32: 2974 devices.
  • Microchip SAM: 416 devices.
  • Microchip AVR: 388 devices.
  • Raspberry Pi: 1 device.

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.

STM32 SAM RP AT
Peripheral F0 F1 F2 F3 F4 F7 G0 G4 H7 L0 L1 L4 L5 U5 D1x
D2x
DAx
D5x
E5x
E7x
S7x
V7x
G5x 20 90 Mega Tiny
ADC
CAN
Comparator
DAC
DMA
Ethernet
External Interrupt
External Memory
GPIO
I2C
Internal Flash
IWDG
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 a discussion to ask if your specific device is supported out-of-the-box and how you can add it otherwise.

Boards

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

AL-AVREB-CAN Arduino NANO Arduino UNO Black Pill F103
Black Pill F401 Black Pill F411 Blue Pill F103 DEVEBOX-STM32F4XX
DEVEBOX-STM32H750VB DISCO-F051R8 DISCO-F072RB DISCO-F100RB
DISCO-F303VC DISCO-F401VC DISCO-F407VG DISCO-F411VE
DISCO-F429ZI DISCO-F469NI DISCO-F746NG DISCO-F769NI
DISCO-L152RC DISCO-L476VG FEATHER-M0 FEATHER-M4
FEATHER-RP2040 MEGA-2560-PRO NUCLEO-F031K6 NUCLEO-F042K6
NUCLEO-F072RB NUCLEO-F091RC NUCLEO-F103RB NUCLEO-F303K8
NUCLEO-F303RE NUCLEO-F334R8 NUCLEO-F401RE NUCLEO-F411RE
NUCLEO-F429ZI NUCLEO-F439ZI NUCLEO-F446RE NUCLEO-F446ZE
NUCLEO-F746ZG NUCLEO-F767ZI NUCLEO-G070RB NUCLEO-G071RB
NUCLEO-G431KB NUCLEO-G431RB NUCLEO-G474RE NUCLEO-H723ZG
NUCLEO-H743ZI NUCLEO-L031K6 NUCLEO-L053R8 NUCLEO-L152RE
NUCLEO-L432KC NUCLEO-L452RE NUCLEO-L476RG NUCLEO-L496ZG-P
NUCLEO-L552ZE-Q NUCLEO-U575ZI-Q OLIMEXINO-STM32 Raspberry Pi Pico
SAMD21-MINI SAMD21-XPLAINED-PRO SAME54-XPLAINED-PRO SAME70-XPLAINED
SAMG55-XPLAINED-PRO SAMV71-XPLAINED-ULTRA Smart Response XE STM32-F4VE
STM32F030-DEMO THINGPLUS-RP2040

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 your specific needs.

AD7280A AD7928 ADIS16470 ADNS9800 ADS101X ADS7828
ADS7843 ADS816x AMS5915 APA102 AS5047 AS5600
AT24MAC402 SPI Flash BME280 BMI088 BMP085 BNO055
CAT24AA CYCLE-COUNTER DRV832X DS1302 DS1631 DS18B20
EA-DOG Encoder Input Encoder Input BitBang Encoder Output BitBang FT245 FT6x06
Gpio Sampler HCLAx HD44780 HMC58x HMC6343 HX711
I2C-EEPROM ILI9341 IS31FL3733 ITG3200 IXM42XXX L3GD20
LAN8720A LAWICEL LIS302DL LIS3DSH LIS3MDL LM75
LP503x LSM303A LSM6DS33 LSM6DSO LTC2984 MAX31855
MAX31865 MAX6966 MAX7219 MCP23x17 MCP2515 MCP3008
MCP7941x MCP990X MMC5603 MS5611 MS5837 NOKIA5110
NRF24 TFT-DISPLAY PAT9125EL PCA8574 PCA9535 PCA9548A
PCA9685 QMC5883L SH1106 SIEMENS-S65 SIEMENS-S75 SK6812
SK9822 SSD1306 ST7586S ST7789 STTS22H STUSB4500
SX1276 SX128X TCS3414 TCS3472 TLC594x TMP102
TMP12x TMP175 TOUCH2046 VL53L0 VL6180 WS2812

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), Raphael Lehmann (@rleh), and Christopher Durand (@chris-durand) 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), 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++23 library generator for AVR and ARM Cortex-M devices

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 74.5%
  • Python 20.0%
  • Java 1.8%
  • C 1.7%
  • Smarty 1.3%
  • CSS 0.3%
  • Other 0.4%