D-RAL - Device Register Access Layer
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.
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:
using namespace dral::stm32f411;
Tim2Group::Cr1Register::dirField::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
Usage: dral [OPTIONS] INPUT_FILE
D-RAL - Device Register Access Layer
Generate D-RAL files from INPUT-FILE.
INPUT-FILE - path to device description file.
Options:
-O, --output-path PATH Output directory. Path where files will be
generated. Default is current directory.
-l, --language [cpp|html] Specify the programming language for which
you want to generate files. [default: cpp]
-t, --access-type [direct|indirect]
Specify the access template. Applys only for
C++ model. [default: direct]
-T, --template-path PATH Specify path to template files used to
generate files.
-s, --skip-groups-detection Skip automatic registers groups detection.
-f, --skip-output-formatting Skip output formatting with auto format
tools.
-w, --white-list PATH Paripherals and Registers white list.
-b, --black-list PATH Peripherals and Registers black list.
--version Show the version and exit.
--help Show this message and exit.
Other Programming Languages
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.
Metadata
Release files for dral 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dral-0.6.0.tar.gz | 229.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dral-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 452.2 kB
Release files / dral-0.6.0.tar.gz
| Download URL | dral-0.6.0.tar.gz |
|---|---|
| Size | 229.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99ffb6eaf346dffe1127210d4a843d3b6debd70e185112af3a6164d485bdbff3
|
|
BLAKE2b-256 checksum How to use checksums |
c3015f1f4c909d1fb778a15f1bf35d4e75f5378066fc40af744d16d238c7d36c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / dral-0.6.0-py3-none-any.whl
| Download URL | dral-0.6.0-py3-none-any.whl |
|---|---|
| Size | 222.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0cfb4878a2b1fe545857f3c9bba332ea84e0ce2dce3cfce3c13a13c982bf3fe
|
|
BLAKE2b-256 checksum How to use checksums |
7147045dbacab9e91796af9700752bb24edaf84fecf2f3fc7e3088ed4ff2e830
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|