Weiter kommentiert

This commit is contained in:
Patrick Hangl
2026-01-08 16:38:51 +01:00
parent 1546b56f24
commit 5412c354c0
2 changed files with 35 additions and 41 deletions

56
main.c
View File

@@ -54,7 +54,6 @@ static int16_t chess_storage(DMB) outputPort[BLOCK_LEN]; // chess_storage(DMB:OU
extern "C" void isr0() property (isr) {
actionRequired = 1;
}
#ifdef __chess__
extern "C"
#endif
@@ -62,32 +61,27 @@ extern "C"
int main(void) {
// Enum, welcher den Ausgabemodus definiert - wird in calc()-Funktion verwendet
static OutputMode mode = OUTPUT_MODE_FIR_LMS;
// Initialize the signal path
// Initialize the csensor signal subpath
// Instanciate the signal path state structs
// Deactivate preemphasis filter by initializing with coefficients {1., 0., 0., 0., 0.}
// biquad filter coefficients - off
// Biquad Filter für C-Sensor und Acc-Sensor anlegen
// Alle 0 bis auf b[0] -> einfacher Gain auf 0,75
double b0[5]={0.75, 0., 0., 0., 0.};
double b1[5]={0.75, 0., 0., 0., 0.};
int N_lms_fir_coeffs = MAX_FIR_COEFFS; // always test with max coeffs
int N_lms_fir_coeffs = MAX_FIR_COEFFS; // 64 Koeffizienten für ANR
//init-Funktion aufrufen
// Signale initialisieren, oben angelegte Structs mit Parametern füllen
init(
&cSensorSignal, &accSensorSignal,
//&ptr_fir_lms_delay_line, &ptr_fir_lms_coeffs,
b0,
b1,
2, // sample delayS
2,
0.9, // weight
0.9,
0.01, // lms learning rate
N_lms_fir_coeffs // Numer of lms fir coefficients
&cSensorSignal, &accSensorSignal, //Signal-Structs
b0, // Biqquad Koeffizienten C-Sensor
b1, // Biqquad Koeffizienten Acc-Sensor
2, // Sample Delay C-Sensor
2, // Sample Delay Acc-Sensor
0.9, //Gewichtung C-Sensor
0.9, //Gewichtung Acc-Sensor
0.01, // Mu
N_lms_fir_coeffs // Anzahl Filterkoeffizienten
);
if (mode == OUTPUT_MODE_FIR){ //FIR filter mit fixen coeffizienten wenn nicht adaptiv
// Fixer Filter wenn nicht adaptiv
if (mode == OUTPUT_MODE_FIR){
for (int i=0; i<N_lms_fir_coeffs; i++){
#ifdef LPDSP16
ptr_fir_lms_coeffs.ptr_start[i] = ((pow(2, 15)-1) /N_lms_fir_coeffs);
@@ -97,7 +91,8 @@ int main(void) {
}
}
#ifdef SIMULATE // use the simulator with file I/O
//Simulationsmodus mit File I/O
#ifdef SIMULATE
FILE *fp1 = fopen("./test/testdata/input/chirp_disturber.txt", "r");
FILE *fp2 = fopen("./test/testdata/input/disturber.txt", "r");
FILE *fp3 = fopen("./test/testdata/output/out_simulated.txt", "w");
@@ -105,14 +100,12 @@ int main(void) {
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);
intputPort[i] = (int16_t) d0;
intputPort[i+1] = (int16_t) d1;
}
calc(
&cSensorSignal, &accSensorSignal,
//&ptr_fir_lms_delay_line, &ptr_fir_lms_coeffs,
@@ -121,7 +114,6 @@ int main(void) {
&intputPort[1],
outputPort
);
for (int i=0; i<BLOCK_LEN; i++){
fprintf(fp3, "%d\n", outputPort[i]);
}
@@ -130,19 +122,19 @@ int main(void) {
fclose(fp2);
fclose(fp3);
#else // how its done in hw
// enable the interrupts
enable_interrupts();
outPtr = &outputPort[1]; // start with second half of buffer
// Hardwaremodus mit Interrupts
#else
enable_interrupts(); //Interrupts aktivieren
outPtr = &outputPort[1]; // Zweite Hälfte des Ausgangspuffers zuerst füllen - warum 1 statt 2?
sample_ptr = &sample;
/*Signalprocessing, called by an interrupt*/
//Endlosschleife für Interrupt-gesteuerte Verarbeitung
actionRequired = 0;
while (1){
CssCmdGen = CSS_CMD_1; // indicate going to sleep to the cm3
CssCmdGen = CSS_CMD_1; // Interrupt Bit setzen um ARM zu signalisieren, dass der DSP abschaltet
core_halt();
if (actionRequired == 1) {
CssCmdGen = CSS_CMD_0; // indicate wakeup to the cm3
CssCmdGen = CSS_CMD_0; // Interrupt Bit setzen um ARM zu signalisieren, dass der DSP arbeitet
actionRequired = 0;
outPtr = cyclic_add(outPtr, 2, outputPort, 4);