78 lines
3.7 KiB
C
78 lines
3.7 KiB
C
// BLOCK LEN 1 und MAX_FIR_COEFFS 64 werden vom Compiler mitgegeben
|
|
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include "signal_processing/include/signal_path.h"
|
|
|
|
// Register und Bitmasken für Interrupts zwischen ARM und LPDSP Prozessor
|
|
#define CSS_CMD 0xC00004
|
|
#define CSS_CMD_0 (1<<0)
|
|
#define CSS_CMD_1 (1<<1)
|
|
|
|
// Shared Memory von ARM und DSP definieren
|
|
#define INPUT_PORT0_ADD 0x800000 // Feste Adressen für Eingangsdaten im Shared Memory
|
|
#define OUTPUT_PORT_ADD (INPUT_PORT0_ADD + 16) // Feste Adressen für Ausgangsdatensdaten im Shared Memory, 16 Byte von Eingangsadresse Weg
|
|
|
|
// Structs anlegen f�r die Signalpfade - hier werden Konfigurationen abgelegt(signal_path.h)
|
|
static SingleSignalPath c_sensor_signal_t;
|
|
static SingleSignalPath acc_sensor_signal_t;
|
|
|
|
static volatile int16_t chess_storage(DMB:INPUT_PORT0_ADD) input_port[4]; //Array mit 4x16 Bit Einträgen auf 2x32 Bit Registern - nur die ersten 2 werden genutzt
|
|
static volatile int16_t chess_storage(DMB:OUTPUT_PORT_ADD) output_port[4]; //Array mit 4x16 Bit Einträgen auf 2x32 Bit Registern - alle werden genutzt
|
|
static volatile int16_t chess_storage(DMB) *input_pointer_0;
|
|
static volatile int16_t chess_storage(DMB) *input_pointer_1;
|
|
static volatile int16_t chess_storage(DMB) *output_pointer;
|
|
static volatile int16_t chess_storage(DMB) *sample_pointer;
|
|
static volatile int16_t chess_storage(DMB) sample; //Speicherplatz für Ergebnis der calculate_output()-Funktion
|
|
|
|
int main(void) {
|
|
// Biquad Filter für C-Sensor und Acc-Sensor anlegen
|
|
// Alle 0 bis auf b[0] -> einfacher Gain auf 0,75 wenn erster Eintrag 0.75, bei Eintrag 1. ist Filter
|
|
double b0[5]={1., 0., 0., 0., 0.};
|
|
double b1[5]={1., 0., 0., 0., 0.};
|
|
int coefficients = MAX_FIR_COEFFS; // 64 Koeffizienten für ANR
|
|
|
|
// Signale initialisieren: oben angelegte Structs mit Parametern füllen
|
|
// Buffer für Delay-Line und Koeffizienten initialisieren
|
|
initialize_signal(
|
|
&c_sensor_signal_t, &acc_sensor_signal_t, //Signal-Structs
|
|
b0, // Biqquad Koeffizienten C-Sensor
|
|
b1, // Biqquad Koeffizienten Acc-Sensor
|
|
2, // Sample Delay C-Sensor
|
|
2, // Sample Delay Acc-Sensor
|
|
1, //Gewichtung C-Sensor
|
|
1, //Gewichtung Acc-Sensor
|
|
0.01, // Mu
|
|
coefficients // Anzahl Filterkoeffizienten
|
|
);
|
|
|
|
// FILE *fp1 = fopen("../../04_Python_Simulation/simulation_data/simple_dsp_corrupted_signal.txt", "r");
|
|
// FILE *fp2 = fopen("../../04_Python_Simulation/simulation_data/simple_dsp_noise_signal_vpu.txt", "r");
|
|
// FILE *fp3 = fopen("../../04_Python_Simulation/filter_output/simple_dsp_output.txt", "w");
|
|
// FILE *fp = fopen("../../04_Python_Simulation/filter_output/simple_dsp_filter_coefficients.txt", "w");
|
|
|
|
FILE *fp1 = fopen("../../04_Python_Simulation/simulation_data/complex_dsp_corrupted_signal.txt", "r");
|
|
FILE *fp2 = fopen("../../04_Python_Simulation/simulation_data/complex_dsp_noise_signal_vpu.txt", "r");
|
|
FILE *fp3 = fopen("../../04_Python_Simulation/filter_output/complex_dsp_output.txt", "w");
|
|
FILE *fp = fopen("../../04_Python_Simulation/filter_output/complex_dsp_filter_coefficients.txt", "w");
|
|
|
|
int d0, d1;
|
|
|
|
while (!(feof(fp1) || feof(fp2))){
|
|
for (int i=0; i<BLOCK_LEN; i++){
|
|
fscanf(fp1, "%d", &d0); //load blocks
|
|
fscanf(fp2, "%d", &d1);
|
|
input_port[i] = (int16_t) d0;
|
|
input_port[i+1] = (int16_t) d1;
|
|
}
|
|
calculate_output(
|
|
fp, &c_sensor_signal_t, &acc_sensor_signal_t, &input_port[0], &input_port[1], output_port);
|
|
for (int i=0; i<BLOCK_LEN; i++){
|
|
fprintf(fp3, "%d\n", output_port[i]);
|
|
}
|
|
}
|
|
fclose(fp1);
|
|
fclose(fp2);
|
|
fclose(fp3);
|
|
}
|