/* * Copyright (c) 2024 Benjamin Cabé <[email protected]> * * SPDX-License-Identifier: Apache-2.0 */ #include <stdio.h> #include <zephyr/kernel.h> // #include "dsp/statistics_functions.h" #include "arm_math.h" #define NUM_TAPS 10 /* Number of taps in the FIR filter (length of the moving average window) */ #define BLOCK_SIZE 32 /* Number of samples processed per block */ /* * Filter coefficients are all equal for a moving average filter. Here, 1/NUM_TAPS = 0.1f. */ q31_t firCoeffs[NUM_TAPS] = {0x0CCCCCCD, 0x0CCCCCCD, 0x0CCCCCCD, 0x0CCCCCCD, 0x0CCCCCCD, 0x0CCCCCCD, 0x0CCCCCCD, 0x0CCCCCCD, 0x0CCCCCCD, 0x0CCCCCCD}; arm_fir_instance_q31 sFIR; q31_t firState[NUM_TAPS + BLOCK_SIZE - 1]; int main(void) { q31_t input[BLOCK_SIZE]; q31_t output[BLOCK_SIZE]; uint32_t start, end; /* Initialize input data with a ramp from 0 to 31 */ for (int i = 0; i < BLOCK_SIZE; i++) { input[i] = i << 24; /* Convert to Q31 format */ } /* Initialize the FIR filter */ arm_fir_init_q31(&sFIR, NUM_TAPS, firCoeffs, firState, BLOCK_SIZE); /* Apply the FIR filter to the input data and measure how many cycles this takes */ start = k_cycle_get_32(); arm_fir_fast_q31(&sFIR, input, output, BLOCK_SIZE); end = k_cycle_get_32(); //////////////////////////////////ERROR////////////////////////////////////////////// float32_t ambient_mean = 0.0f; float32_t ambient_channel[128] = {0.0f}; // Array to store ambient data arm_mean_f32(ambient_channel, 128, &ambient_mean); ///////////////////////////////////ERROR////////////////////////////////////////////////// printf("Time: %u us (%u cycles)\n", k_cyc_to_us_floor32(end - start), end - start); for (int i = 0; i < BLOCK_SIZE; i++) { printf("Input[%02d]: ", i); for (int j = NUM_TAPS - 1; j >= 0; j--) { if (j <= i) { printf("%2d ", (int)(input[i - j] >> 24)); } else { printf("%2d ", 0); } } printf("| Output[%02d]: %6.2f\n", i, (double)output[i] / (1 << 24)); } return 0; }
I used the DSP example code from the sample code
its moving average code to that if i add the arm_mean() function into this code I'm getting linker error
ERROR
c:/ncs/toolchains/b620d30767/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `main':
E:/sensio/testing/src/main.c:47: undefined reference to `arm_mean_f32'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\b620d30767\opt\bin\cmake.EXE' --build E:/sensio/testing/build/testing
CONFIG_REQUIRES_FULL_LIBC=y CONFIG_REQUIRES_FLOAT_PRINTF=y CONFIG_CMSIS_DSP=y CONFIG_CMSIS_DSP_FILTERING=y