Elektronikprojekt Grupp 13 / Mbed OS test_fft_grp13

Dependencies:   mbed-dsp

Fork of mbed-os-example-blinky by Elektronikprojekt Grupp 13

main.cpp

Committer:
KlaraBengtsson
Date:
2017-04-10
Revision:
66:866bf1606317
Parent:
64:92745a08320c
Child:
67:8de1eb1c4974

File content as of revision 66:866bf1606317:

#include "mbed.h"
#include "arm_math.h"
#include "arm_const_structs.h"


q15 testData1[] = {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};
q15 testData2[] = {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};
q31 finalData[];
int len1 = length(testData1);
int len2 = length(testData2);
q15 *p1 = &testData1(0);
q15 *p2 = &testData2(0);
q15 *p3 = &finalData(0);

arm_correlate_q15(pi,len1,p2,len2,p3);


/*
const int FFT_SIZE = 32;
int sampleCounter;
float samples[FFT_SIZE*2];
float magnitudes[FFT_SIZE];
const static arm_cfft_instance_f32 *S;

//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();
        }

    }
} 
*/