Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-dsp
Fork of mbed-os-example-blinky by
main.cpp
- Committer:
- KlaraBengtsson
- Date:
- 2017-04-10
- Revision:
- 62:1e5508bb8f16
- Parent:
- 61:35a973447ae6
- Child:
- 63:f2972bba6f01
File content as of revision 62:1e5508bb8f16:
#include "mbed.h" #include "arm_math.h" #include "arm_const_structs.h" const int FFT_SIZE = 32; int sampleCounter; float samples[FFT_SIZE*2]; float magnitudes[FFT_SIZE]; //int SAMPLE_RATE_HZ = 10000; float testData[] = {10, 20, 30, 40, 50, 60, 70, 80, 10, 20, 30, 40, 50, 60, 70, 80,10, 20, 30, 40, 50, 60, 70, 80, 10, 20, 30, 40, 50, 60, 70, 80}; void samplingBegin(){ sampleCounter = 0; //sätt hårdvaru inställningar här om det behövs } void samplingCallback() { //läs data samples[sampleCounter] = testData[sampleCounter]; // sätter imaginär till 0 samples[sampleCounter + 1] = 0.0; sampleCounter += 2; if (sampleCounter >= FFT_SIZE *2 ) { //här är sampling klar, buffert är full //skriv hårdvaru kod här } bool samplingIsDone() { return (sampleCounter >= FFT_SIZE*2); } // main() runs in its own thread in the OS int main() { samplingBegin(); S = & arm_cfft_sR_f32_len32; while(1) { if(samplingIsDone()){ arm_cfft_f32(S,samples,0,1); arm_cmplx_mag_f32(samples,magnitudes,FFT_SIZE); samplingBegin(); } }