Crates.io | cmsis_dsp |
lib.rs | cmsis_dsp |
version | 0.1.0 |
source | src |
created_at | 2021-01-28 23:45:48.801682 |
updated_at | 2021-01-28 23:45:48.801682 |
description | Bindings to the CMSIS DSP library for ARM Cortex-M processors |
homepage | |
repository | https://github.com/samcrow/cmsis_dsp.rs |
max_upload_size | |
id | 347814 |
size | 43,795 |
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.
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.
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.
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
}
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
. Also, if the processor has a double-precision floating point unit, enable
the double-precision-fpu
feature.thumbv8m.main-none-eabi
or thumbv8m.main-none-eabihf
): If the processor supports DSP
instructions, enable the dsp-instructions
featureAll 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.
ARM provides the CMSIS-DSP library under the Apache license 2.0. This package of bindings (cmsis_dsp_sys) 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.