Not able to compile the CMSIS library for Nordic nRF52 on the Arduino IDE


I am using a nordic nRF52 controller to send accelerometer data over BLE. I need to take an FFT of this data. I am not able to compile the CMSIS library on the arduino IDE. I am using the RedBear libraries for development on arduino IDE.

I have tried to follow this post for installing the library but I get the following errors:

In file included from /Users/priyanshi/Library/Arduino15/packages/RedBear/hardware/nRF52832/0.0.2/cores/RBL_nRF52832/Arduino.h:19:0,
from /var/folders/r9/g2gr1vv51t9958y67czsgfpr0000gn/T/arduino_build_913970/sketch/fft_trial.ino.cpp:1:
/Users/priyanshi/Library/Arduino15/packages/RedBear/hardware/nRF52832/0.0.2/variants/BLE_Nano2/pins_arduino.h:7:13: error: expected unqualified-id before numeric constant
#define D0 0

The complete file of errors is attached.

I am trying to run the example fit code in the CMSIS library.

#define ARM_MATH_CM4
#include <arm_math.h>


static float32_t testOutput[TEST_LENGTH_SAMPLES/2]; 

uint32_t M = 0;

/* ------------------------------------------------------------------ 
* Global variables for FFT Bin Example 
* ------------------------------------------------------------------- */ 
uint32_t fftSize = 1024; 
uint32_t ifftFlag = 0; 
uint32_t doBitReverse = 1; 

/* Reference index at which max energy of bin ocuurs */ 
uint32_t refIndex = 213, testIndex = 0; 

/* ----------------------------------------------------------------------
Test Input signal contains 10KHz signal + Uniformly distributed white noise
** ------------------------------------------------------------------- */

float32_t testInput_f32_10khz[2048] = 
-0.865129623056441,   0.000000000000000,  -2.655020678073846,   0.000000000000000,  0.600664612949661,  0.000000000000000,  0.080378093886515,  0.000000000000000,  
//... lots more numbers clipped away (see mentioned example dir, fft_bin example for full table ....
-2.899160484012034,   0.000000000000000,  2.563004262857762,  0.000000000000000,  3.078328403304206,  0.000000000000000,  0.105906778385130,  0.000000000000000,  

void setup() {
 Serial.println(" start program ");

void loop() {
      /** \example arm_fft_bin_example_f32.c 

  arm_status status; 
  arm_cfft_radix4_instance_f32 S; 
  float32_t maxValue; 
  status = ARM_MATH_SUCCESS; 
  /* Initialize the CFFT/CIFFT module */  
  status = arm_cfft_radix4_init_f32(&S, fftSize, ifftFlag, doBitReverse); 
  Serial.println("step 1"); 
  /* Process the data through the CFFT/CIFFT module */ 
  arm_cfft_radix4_f32(&S, testInput_f32_10khz); 
  Serial.println("step 2");  
  /* Process the data through the Complex Magnitude Module for  
  calculating the magnitude at each bin */ 
  arm_cmplx_mag_f32(testInput_f32_10khz, testOutput, fftSize);  
  Serial.println("step 3");  
  /* Calculates maxValue and returns corresponding BIN value */ 
  arm_max_f32(testOutput, fftSize, &maxValue, &testIndex); 
  Serial.println("step 4");  
   while(1);                             /* main function does not return */

How do I compile the CMSIS library on the Arduino IDE?

Error_Arduino.txt (53.6 KB)

To me it looks like the compiler doesn't like it, that you are trying to redefine a already reserved expression. If the nRF-code works anything like the ESP-code, then D0 is already a internal function to correctly address the Pin D0. You may try to name the #define D0 something else

Set up a separate file that contains the fft code, give it a .cpp extension instead of .ino, and do NOT include Arduino.h in the .cpp file (keep it pure math and do any Arduino io elsewhere.)