![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
fghfgh
Dependencies: mbed CMSIS_DSP_5 TextLCD
main.cpp@8:05a125e4eee0, 2019-11-21 (annotated)
- Committer:
- jvicente
- Date:
- Thu Nov 21 18:15:20 2019 +0000
- Revision:
- 8:05a125e4eee0
- Parent:
- 7:4dd3ef163f65
hg
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
javiervicente | 0:0d5a524c7d25 | 1 | #include "mbed.h" |
jvicente | 6:1e45b5f30b87 | 2 | #include "arm_math.h" |
jvicente | 6:1e45b5f30b87 | 3 | #include <stdio.h> |
jvicente | 6:1e45b5f30b87 | 4 | #include <string.h> |
javiervicente | 0:0d5a524c7d25 | 5 | #include "datos.h" |
jvicente | 7:4dd3ef163f65 | 6 | |
jvicente | 7:4dd3ef163f65 | 7 | #define NUM_TAPS 15 |
jvicente | 7:4dd3ef163f65 | 8 | #define NUM_STAGES 3 |
jvicente | 7:4dd3ef163f65 | 9 | float inDataFloat[frameLength]; |
jvicente | 7:4dd3ef163f65 | 10 | float outDataFloat[frameLength]; |
jvicente | 7:4dd3ef163f65 | 11 | float valorRMSFloat; |
jvicente | 7:4dd3ef163f65 | 12 | float valorRMSSinFiltro; |
jvicente | 7:4dd3ef163f65 | 13 | float valorRMSSinFiltroConvertido; |
jvicente | 7:4dd3ef163f65 | 14 | float valorRMSConvertido; |
jvicente | 7:4dd3ef163f65 | 15 | float meanSinFiltro; |
jvicente | 7:4dd3ef163f65 | 16 | float meanTrasFiltro; |
jvicente | 7:4dd3ef163f65 | 17 | |
jvicente | 8:05a125e4eee0 | 18 | Serial pc(USBTX, USBRX); // tx, rx |
jvicente | 7:4dd3ef163f65 | 19 | |
jvicente | 7:4dd3ef163f65 | 20 | float salida[frameLength]; |
jvicente | 7:4dd3ef163f65 | 21 | |
jvicente | 8:05a125e4eee0 | 22 | const float32_t iirCoeffs32[NUM_TAPS] = {0.04475,-2.2348e-08,-0.044751,1.8954,-0.91178,0.04475,0.089501,0.04475,1.9116,-0.94211,0.04475,-0.089501,0.04475,1.9588,-0.96799 }; |
javiervicente | 2:69827542e976 | 23 | |
javiervicente | 0:0d5a524c7d25 | 24 | |
jvicente | 7:4dd3ef163f65 | 25 | static float32_t iirStateF32[4*NUM_STAGES]; |
jvicente | 6:1e45b5f30b87 | 26 | |
jvicente | 7:4dd3ef163f65 | 27 | arm_biquad_casd_df1_inst_f32 S; |
jvicente | 7:4dd3ef163f65 | 28 | |
jvicente | 7:4dd3ef163f65 | 29 | /// Tocar funciones de abajo |
jvicente | 7:4dd3ef163f65 | 30 | |
jvicente | 7:4dd3ef163f65 | 31 | void init_procesado() |
jvicente | 7:4dd3ef163f65 | 32 | { |
jvicente | 7:4dd3ef163f65 | 33 | arm_biquad_cascade_df1_init_f32(&S, NUM_STAGES, (float32_t *)&iirCoeffs32[0], &iirStateF32[0]); |
jvicente | 7:4dd3ef163f65 | 34 | } |
jvicente | 6:1e45b5f30b87 | 35 | |
jvicente | 7:4dd3ef163f65 | 36 | void procesarfloat(float *inData,float *outData,int32_t length) |
jvicente | 7:4dd3ef163f65 | 37 | { |
jvicente | 7:4dd3ef163f65 | 38 | arm_mean_f32(inData, length, &meanSinFiltro); |
jvicente | 7:4dd3ef163f65 | 39 | arm_rms_f32(inData, length, &valorRMSSinFiltro); |
jvicente | 7:4dd3ef163f65 | 40 | valorRMSSinFiltroConvertido = valorRMSSinFiltro*3.3f; |
jvicente | 7:4dd3ef163f65 | 41 | |
jvicente | 7:4dd3ef163f65 | 42 | arm_biquad_cascade_df1_f32(&S, inData, outData, length); |
jvicente | 7:4dd3ef163f65 | 43 | |
jvicente | 7:4dd3ef163f65 | 44 | arm_rms_f32(outData, length, &valorRMSFloat); |
jvicente | 7:4dd3ef163f65 | 45 | valorRMSConvertido = valorRMSFloat*3.3f; |
jvicente | 7:4dd3ef163f65 | 46 | arm_mean_f32(outData, length, &meanTrasFiltro); |
jvicente | 7:4dd3ef163f65 | 47 | } |
jvicente | 6:1e45b5f30b87 | 48 | |
jvicente | 6:1e45b5f30b87 | 49 | // PROGRAMA PRINCIPAL |
javiervicente | 0:0d5a524c7d25 | 50 | int main() |
javiervicente | 0:0d5a524c7d25 | 51 | { |
jvicente | 8:05a125e4eee0 | 52 | pc.baud(115200); |
jvicente | 7:4dd3ef163f65 | 53 | init_procesado(); |
jvicente | 7:4dd3ef163f65 | 54 | procesarfloat(datos,salida,frameLength); |
jvicente | 8:05a125e4eee0 | 55 | pc.printf("*******************************entrada\n"); |
jvicente | 7:4dd3ef163f65 | 56 | for (int n=0; n<frameLength; n++) { |
jvicente | 8:05a125e4eee0 | 57 | pc.printf("%f\n",datos[n]); |
jvicente | 7:4dd3ef163f65 | 58 | } |
jvicente | 8:05a125e4eee0 | 59 | pc.printf("********************************salida\n"); |
jvicente | 7:4dd3ef163f65 | 60 | for (int n=0; n<frameLength; n++) { |
jvicente | 8:05a125e4eee0 | 61 | pc.printf("%f\n",salida[n]); |
jvicente | 7:4dd3ef163f65 | 62 | } |
jvicente | 7:4dd3ef163f65 | 63 | while(1) { |
jvicente | 7:4dd3ef163f65 | 64 | wait(1000); |
jvicente | 7:4dd3ef163f65 | 65 | } |
jvicente | 7:4dd3ef163f65 | 66 | |
jvicente | 7:4dd3ef163f65 | 67 | |
javiervicente | 1:bdbd76df2103 | 68 | } |
javiervicente | 1:bdbd76df2103 | 69 | |
jvicente | 6:1e45b5f30b87 | 70 | |
jvicente | 6:1e45b5f30b87 | 71 | |
jvicente | 6:1e45b5f30b87 | 72 | |
jvicente | 6:1e45b5f30b87 | 73 | |
jvicente | 6:1e45b5f30b87 | 74 | |
javiervicente | 1:bdbd76df2103 | 75 | |
jvicente | 6:1e45b5f30b87 | 76 | |
jvicente | 6:1e45b5f30b87 | 77 | |
jvicente | 6:1e45b5f30b87 | 78 | |
jvicente | 6:1e45b5f30b87 | 79 | |
jvicente | 6:1e45b5f30b87 | 80 | |
jvicente | 6:1e45b5f30b87 | 81 |