Skip to main content

D-RAL - Device Register Access Layer

Project description

Logo

D-RAL - Device Register Access Layer

PyPI PyPI - License Supported Python Versions PyPI - Format PyPI - Wheel


What is it?

D-RAL is a register access code generator for any device, chip or embedded system. The goal is to provide a simple and consistent way to access the internal registers of the device. Every embedded project requires the programmer to manipulate registers. D-RAL is trying to address this and provide an easy way to access registers. The main motivation for creating this project was to design a register access layer for modern C++ programming language.

Main functionality

Main functionality is to generate a register access layer based on the device register description input for the C++ programming language. Currently, D-RAL only supports the SVD format as an input file with a description of the registers. SVD is an ARM-created format that formalizes the description of the system inside microcontrollers based on Arm Cortex-M processors, specifically the memory mapped registers of peripherals. It is a widely used format by many companies. It is also possible to use your own register description format in D-RAL by writing an adapter that translates it to know for the D-RAL form. More about this on the wiki page. D-RAL generates a set of header files that you can simply copy and paste into your existing project.

Example

Let's take the STM32F411 microcontroller and its general-purpose timers as an example. We want to configure the TIM2 timer as a countdown timer. To do this, we need to set the direction bit in one of the timer's control registers.

STM32F411 Tim2 Control Register

We can accomplish this in C++ by utilizing raw pointers:

constexpr uint32_t Tim2Cr1Address = 0x4000'0000;
constexpr uint32_t Tim2Cr1DirPos = 4;
constexpr uint32_t Tim2Cr1DirMask = 0x1;

volatile uint32_t* Tim2Cr1Reg = reinterpret_cast<volatile uint32_t*>(Tim2Cr1Address);
*Tim2Cr1Reg = (*Tim2Cr1Reg & ~(Tim2Cr1DirMask << Tim2Cr1DirPos)) | ((1 & Tim2Cr1DirMask) << Tim2Cr1DirPos);

Or we can use D-RAL:

dral::stm32f411::tim2::cr1::dir::write(1);

This is a brief example to demonstrate D-RAL's purpose. More information can be found on the Wiki page.

Main benefits of using D-RAL:

  • Simple and clean syntax,
  • Less code,
  • No need to warry about bit shifting and masking,
  • No run-time overhead

Installing

The easiest way to install D-RAL is with pipx.

pipx install dral

You can also install D-RAL with pip:

pip install dral

Whichever method you use, you should have a dral command on your path.

Usage

D-RAL is a CLI tool that takes two positional arguments

dral [OPTIONS] INPUT OUTPUT
  • INPUT - path to external device description file
  • OUTPUT - a path where D-RAL files will be generated.

Extra functionality

The D-RAL generator is flexible enough to be easily adapted to generate register access layers for other programming languages or for other use cases. More about it on the Wiki page.

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

dral-0.5.3.tar.gz (140.6 kB view details)

Uploaded Source

Built Distribution

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

dral-0.5.3-py3-none-any.whl (164.3 kB view details)

Uploaded Python 3

File details

Details for the file dral-0.5.3.tar.gz.

File metadata

  • Download URL: dral-0.5.3.tar.gz
  • Upload date:
  • Size: 140.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.2.0-1019-azure

File hashes

Hashes for dral-0.5.3.tar.gz
Algorithm Hash digest
SHA256 07fba942abf931a0ab412fa4e0e9c9de86d0d6c24c2b304efcae65dd8caa0c63
MD5 7358f3fe3e383c0e5b2b9b71ea5e40eb
BLAKE2b-256 c167af42cd3aec02fcee199454b3e45a5566284385970d43d2b465692d83d3c3

See more details on using hashes here.

File details

Details for the file dral-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: dral-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 164.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.2.0-1019-azure

File hashes

Hashes for dral-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2a46beb7b7183db54921c0e2b38866e33ab68856e3d006a1551490535ff90cd3
MD5 681788e66fc4bb9ab8fd03da2a681897
BLAKE2b-256 79554f31f29b9dca37952d3a42bb151a6e35a6d57156498ab346405b50d176b8

See more details on using hashes here.

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