I am making real-time functional security-critical applications in C for life at the moment. I am constantly trying to expand my library with the good modules that are commonly used. At the moment, I have a library consisting of:
- General / miscellaneous. (short macros, semahpore'd enable / disable IRQ, etc.).
- Timer lib with API for time and resolution time ms and ΞΌs ("stopwatch")
- Buffer Ring, I am using a modified version of Adam Dunkel from Contiki-OS
- CRC32, select any implementation from the Internet (preferably using word-size processing instead of bytes) and check it against something!
- AES128 / 192/256, I have an implementation of CBC + ECB mode in Github that supports code size in speed, I feel free to use it.
- Bit array module
- Data routing and final data processing ala .NET BitConverter class, for example. read U32 from a pointer
- Filtering / Debugging
- Validation / logging module, nice for setting breakpoints and detecting runtime errors during debugging
Most of the material in my library has now been contributed by my colleagues, so I cannot release it because I am not asking anyone.
I have not used trigonometric functionality yet, but there is a ton of code that makes a quick approximation using polynomials obtained through the Chebyshev approximation or the Remez algorithm (here's a blog about this) . Avoid implementations using the Taylor series. One of the reasons is that it is believed that it converges more slowly than the methods mentioned above, and there are also problems of accuracy. CORDIC can also be fast. Depends a little on HW.
Here is a trigger library with various speed / accuracy options, shamelessly stolen from the Ganssle group: http://www.ganssle.com/approx/sincos.cpp - It compiles as C code with minor modifications.
If you have room for it, you can consider lookup tables and interpolation (for example, 1-3 iterations of the Newton-Raphson method).
In addition, many built-in objects have an HW circuit for calculating CRC, etc. Most HW-CRC32 peripherals implement an "Ethernet" / IEEE polynomial, usually among others.
source share