//#define SIMULATE #ifdef SIMULATE #include #endif #define BLOCK_LEN 1 // define block length for processing - currently only 1 is supported #include #include "signalProcessing/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 INPUT_PORT1_ADD INPUT_PORT0_ADD + 2 //DMB - warum auskommentiert? #define OUTPUT_PORT_ADD (INPUT_PORT0_ADD + 16) // Feste Adressen für Ausgangsdatensdaten im Shared Memory, 16 Byte von Eingangsadresse Weg (PS: 2* for 2 channels) //Chess Compiler spezifisch: Interrupt-Register festlegen um ARM zu kontaktieren nach fertiger Berechnung (PS: Define the interrupt register to notify the ARM of a completed operation) volatile static unsigned char chess_storage(DMIO:CSS_CMD) CssCmdGen; // Interrupt-Flag, welche von ARM gesetzt wird, wenn eine Berechnung gewünscht ist static volatile int actionRequired; // Structs anlegen für die Signalpfade - hier werden Konfigurationen abgelegt(signal_path.h) static SingleSignalPath cSensorSignal; static SingleSignalPath accSensorSignal; // Umschaltung zwischen sampleweiser und blockweiser Verarbeitung // Sampleweise Verarbeitung: Adresse aus Shared Memory wird direkt verwendet // Blockweise Verarbeitung: Blöcke kopiert und verarbeitet? Offensichtlicch nicht genutzt bisher #if BLOCK_LEN == 1 static volatile int16_t chess_storage(DMB:INPUT_PORT0_ADD) intputPort[4]; //TODO: if BLOCK_LEN >1 is used, the data is interleaved: ch0ch1, ch0ch1 .... chess_storage(DMA % alignof(int)) ? //static volatile int16_t chess_storage(DMB:INPUT_PORT1_ADD) intputPort1[BLOCK_LEN]; static volatile int16_t chess_storage(DMB:OUTPUT_PORT_ADD) outputPort[4]; static volatile int16_t chess_storage(DMB) *inPtr0; static volatile int16_t chess_storage(DMB) *inPtr1; static volatile int16_t chess_storage(DMB) *outPtr; static volatile int16_t chess_storage(DMB) sample; static volatile int16_t chess_storage(DMB) *sample_ptr; #else // Int-Array für Blockverarbeitung im Shared Memory DMA anlegen (Eingabe) static int16_t chess_storage(DMA) intputPort[BLOCK_LEN]; //chess_storage(DMA:INPUT_PORT_ADD) TODO: volatile? chess_storage(DMA % alignof(int)) //static int16_t chess_storage(DMA) intputPort1[BLOCK_LEN]; //chess_storage(DMA:INPUT_PORT_ADD) // Int-Array für Blockverarbeitung im Shared Memory DMA anlegen (Ausgabe) static int16_t chess_storage(DMB) outputPort[BLOCK_LEN]; // chess_storage(DMB:OUTPUT_PORT_ADD) TODO: determine output port add #endif //void isr0() ist eine Interrupt Service Routine Funktion, welche als C Funktion deklariert wird // property (isr) ist Chess Compiler spezifisch und kennzeichnet eine Funktion als Interrupt Service Routine //wird Interrupt getriggert, wird actionRequired auf 1 gesetzt - etwas muss dannpassieren extern "C" void isr0() property (isr) { actionRequired = 1; } #ifdef __chess__ extern "C" #endif 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 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 //init-Funktion aufrufen init( &cSensorSignal, &accSensorSignal, //&ptr_fir_lms_delay_line, &ptr_fir_lms_coeffs, b0, b1, 2, // sample delay 2, 0.9, // weight 0.9, 0.01, // lms learning rate N_lms_fir_coeffs // Numer of lms fir coefficients ); if (mode == OUTPUT_MODE_FIR){ //FIR filter mit fixen coeffizienten wenn nicht adaptiv for (int i=0; i