#arm #processing #math #low-level #processor #bindings #cmsis-dsp

sys cmsis_dsp_sys_pregenerated

Low-level interfaces to the ARM CMSIS-DSP library

1 unstable release

0.1.0 Jan 28, 2021

#1633 in Algorithms

Download history 15/week @ 2024-03-13 45/week @ 2024-03-20 42/week @ 2024-03-27 46/week @ 2024-04-03 87/week @ 2024-04-10 158/week @ 2024-04-17 28/week @ 2024-04-24 14/week @ 2024-05-01 14/week @ 2024-05-08 12/week @ 2024-05-15 1/week @ 2024-05-22 62/week @ 2024-05-29 152/week @ 2024-06-05 101/week @ 2024-06-12 167/week @ 2024-06-19 92/week @ 2024-06-26

526 downloads per month
Used in cmsis_dsp

0BSD license

460KB
10K SLoC

CMSIS-DSP bindings

The CMSIS-DSP library provides "a suite of common signal processing functions for use on Cortex-M and Cortex-A processor based devices."

This package provides Rust bindings to CMSIS-DSP for Cortex-M0, M0+, M3, M4, M7, M23, and M33 devices.

Supported features

High-level bindings are currently provided for basic functions and fast Fourier transforms. The CMSIS-DSP library also has other functionality, but nobody has written Rust bindings for it yet.

Limitations

Inline functions

Some CMSIS-DSP functions, like arm_sqrt_f32, are defined inline in the header files and are missing from the compiled libraries. This package currently does not provide those functions.

Basic C math functions

Some CMSIS-DSP functions depend on math functions from the C standard library, like sqrtf. These C standard library math functions are not included in the CMSIS-DSP libraries. This may cause linker errors like this:

  = note: rust-lld: error: undefined symbol: sqrtf
          >>> referenced by arm_math.h:6841 (../../Include/arm_math.h:6841)
          >>>               arm_cmplx_mag_f32.o:(arm_cmplx_mag_f32) in archive /path/cmsis_dsp_sys/ARM.CMSIS.5.7.0/CMSIS/DSP/Lib/GCC/libarm_cortexM4lf_math.a
          >>> referenced by arm_math.h:6841 (../../Include/arm_math.h:6841)
          >>>               arm_cmplx_mag_f32.o:(arm_cmplx_mag_f32) in archive /path/cmsis_dsp_sys/ARM.CMSIS.5.7.0/CMSIS/DSP/Lib/GCC/libarm_cortexM4lf_math.a
          >>> referenced by arm_math.h:6841 (../../Include/arm_math.h:6841)
          >>>               arm_cmplx_mag_f32.o:(arm_cmplx_mag_f32) in archive /path/cmsis_dsp_sys/ARM.CMSIS.5.7.0/CMSIS/DSP/Lib/GCC/libarm_cortexM4lf_math.a
          >>> referenced 4 more times

The easiest way to fix this is to enable the libm or micromath feature on the cmsis_dsp package. This will add a dependency on libm or micromath and implement some of the C standard library math functions.

The libm library implements more functions than micromath. Its implementations may be more precise but take up more code space.

If both libm and micromath features are enabled, the libm implementations will be used.

Alternatively, you can implement only the functions you need with an implementation of your choice, for example:

#[no_mangle]
pub extern "C" fn sqrtf(value: f32) -> f32 {
    // Implementation goes here
}

Configuring the bindings

Different versions of the library will be linked depending on the type of processor the code will run on. You may need to enable some Cargo features depending on the target:

  • Cortex-M7: Enable the feature cortex-m7. Also, if the processor has a double-precision floating point unit, enable the double-precision-fpu feature.
  • Cortex-M33 (target thumbv8m.main-none-eabi or thumbv8m.main-none-eabihf): If the processor supports DSP instructions, enable the dsp-instructions feature

All other options will be configured automatically based on the target passed to cargo. If you forget to enable a feature, everything should still work but it may be slower.

Licensing

ARM provides the CMSIS-DSP library under the Apache license 2.0. This package of bindings (cmsis_dsp and cmsis_dsp_sys_pregenerated) is released under the 0-clause BSD license, which is extremely permissive and does not require attribution. This means that using CMSIS-DSP in Rust does not require any more license compliance work than using CMSIS-DSP in C.


lib.rs:

CMSIS-DSP low-level bindings

Configuring and using the bindings

Different versions of the library will be linked depending on the type of processor the code will run on. You may need to enable some Cargo features depending on the target:

  • Cortex-M7: Enable the feature cortex-m7. Also, if the processor has a double-precision floating point unit, enable the double-precision-fpu feature.
  • Cortex-M33 (target thumbv8m.main-none-eabi or thumbv8m.main-none-eabihf): If the processor supports DSP instructions, enable the dsp-instructions feature.

All other targets will be configured automatically based on the target passed to cargo. If you forget to enable a feature, everything should still work but it may be slower.

Dependencies