1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests/sys/frac-config
2023-05-10 12:02:58 +02:00
..
main.c tests: move sys related applications to tests/sys/ subdirectory 2023-05-10 12:02:58 +02:00
Makefile tests: move sys related applications to tests/sys/ subdirectory 2023-05-10 12:02:58 +02:00
README.md tests: move sys related applications to tests/sys/ subdirectory 2023-05-10 12:02:58 +02:00

This is a helper program to generate frac_t static initializers, to avoid the runtime overhead of calling frac_init during initialization.

When using the precomputed values it is possible to declare const frac_t in ROM, which is not possible with runtime computation.

Example static configuration:

static const frac_t myfrac = {
    .num = 512,
    .den = 15625,
    .div = { .magic = 0x8637bd05af6c69b6ull, .more = 0x0d },
};

you can use myfrac as usual:

scaled_number = frac_scale(&myfrac, unscaled_number);