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
Frederik Haxel 5ed0bafc92 examples, tests: Changes for the native64 board
- Adapted build system and test checks for the native boards to include native64
- Added `native64` to the same tests as `native`
2024-02-05 22:02:14 +01:00
..
main.c tests: move sys related applications to tests/sys/ subdirectory 2023-05-10 12:02:58 +02:00
Makefile examples, tests: Changes for the native64 board 2024-02-05 22:02:14 +01: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);