Skip to main content

A Python package for parsing IOC files and generating C++ code.

Project description


License GitHub Repo Documentation GitHub Issues CI/CD - Python Package

libxr is a Python package that automates embedded system development by parsing .ioc files and generating C++ code. It significantly reduces manual effort in STM32CubeMX-based projects.

🌟 Features

  • 🧠 Hardware-Aware Codegen: Automatically generates device drivers and application scaffolding.
  • ⚙️ Modular Architecture: Supports multiple backends; STM32 is the default.
  • 🔌 Peripheral Aliasing: Supports multi-alias registration and lookup.
  • 📦 Optional XRobot2.0 Glue: Enables integration with the XRobot application framework.

📥 Installation

Install via pip

pip install libxr

Install from source

git clone https://github.com/Jiu-xiao/LibXR_CppCodeGenerator.git
cd LibXR_CppCodeGenerator
pip install -e .

🔧 General (Cross-Platform)

These commands work across platforms (STM32 and others):

xr_parse

xr_parse -i config.yaml

Parses a generic YAML hardware configuration and extracts peripheral definitions.

xr_gen_code

xr_gen_code -i config.yaml [--xrobot]

Generates platform-agnostic C++ hardware abstraction code from YAML.


STM32 Project Tools

xr_cubemx_cfg

usage: xr_cubemx_cfg [-h] -d DIRECTORY [-t TERMINAL] [-c] [--xrobot]

Automatically configures an STM32CubeMX project by parsing .ioc, generating YAML and C++ code, modifying interrupt handlers, and initializing project files.

Required

  • -d, --directory <DIRECTORY>: Path to the STM32CubeMX project.

Optional

  • -t, --terminal <TERMINAL>: Terminal device name.
  • -c, --clang: Enable Clang support.
  • --xrobot: Enable XRobot glue code.

Outputs

  • .config.yaml, C++ drivers, app_main.cpp
  • Modified interrupt handlers
  • CMakeLists.txt, .gitignore
  • Initialized Git repo with LibXR submodule

xr_parse_ioc

usage: xr_parse_ioc [-h] -d DIRECTORY

Parses .ioc and creates a .config.yaml.


xr_gen_code_stm32

usage: xr_gen_code_stm32 [-h] -i INPUT -o OUTPUT [--xrobot] [--libxr-config LIBXR_CONFIG]

Generates STM32 application code from YAML.

Required

  • -i: Path to .config.yaml
  • -o: Output directory

Optional

  • --xrobot: Enable XRobot glue
  • --libxr-config: Path to runtime config YAML

Outputs

  • app_main.cpp, libxr_config.yaml

xr_stm32_it

usage: xr_stm32_it [-h] input_dir

Modifies STM32 interrupt handlers to support LibXR.


xr_stm32_clang

usage: xr_stm32_clang [-h] input_dir

Creates Clang-compatible toolchain file.


xr_stm32_cmake

usage: xr_stm32_cmake [-h] input_dir

Creates LibXR.CMake for CMake builds.


.IOC Requirements

  • Must be from STM32CubeMX
  • CMake-based project
  • DMA must be enabled for UART/SPI/I2C

After Code Generation

You must manually add:

#include "app_main.h"

And call app_main(); appropriately:

  • Bare metal: at the end of main()
  • FreeRTOS: inside the thread entry

🛠️ Contributing

We welcome your contributions! See CONTRIBUTING.md.

You can:

  • 📝 Submit pull requests
  • 🔍 Review others' code
  • 🐛 Report bugs
  • 📖 Write docs
  • 🎨 Design assets

📄 License

Licensed under Apache-2.0. See LICENSE.


🔗 Resources

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libxr-0.2.1.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libxr-0.2.1-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file libxr-0.2.1.tar.gz.

File metadata

  • Download URL: libxr-0.2.1.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for libxr-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7d044769212ba932626eacdca105a3200a8b14f18e441cc383194eec059c7374
MD5 3142b46a9e8fcef5ac18a34976b3a07b
BLAKE2b-256 4fc63827f5c9c21bbd9b538ff58f7648809728546c7de9b45eecd90cab94ef16

See more details on using hashes here.

Provenance

The following attestation bundles were made for libxr-0.2.1.tar.gz:

Publisher: python-publish.yml on Jiu-xiao/LibXR_CppCodeGenerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file libxr-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: libxr-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for libxr-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81714d971e313d50f4970451fc67c1c896213d6f011d73621058fae9865b01c8
MD5 56ab397b3b34ef91ec21364a56b6996f
BLAKE2b-256 f2c5cc6a36badbe02ca4642d237685324eb4a380086921ecd16de61a4ce5915a

See more details on using hashes here.

Provenance

The following attestation bundles were made for libxr-0.2.1-py3-none-any.whl:

Publisher: python-publish.yml on Jiu-xiao/LibXR_CppCodeGenerator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page