Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (C) 2010-2011 University of Texas at Austin
- *
- * Author: Dan Zhang <dan.zhang@mail.utexas.edu>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation
- * version 2.1 of the License.
- *
- * Copyright (C) 2009-2010 Felipe Contreras
- * Copyright (C) 2009-2010 Nokia Corporation
- * Copyright (C) 2009 Igalia S.L
- *
- * Author: Felipe Contreras <felipe.contreras@nokia.com>
- *
- * This file may be used under the terms of the GNU Lesser General Public
- * License version 2.1, a copy of which is found in LICENSE included in the
- * packaging of this file.
- */
- #include <stdlib.h>
- #include <string.h>
- #include <stdbool.h>
- #include <signal.h>
- #include <stdio.h>
- #include "dmm_buffer.h"
- #include "dsp_bridge.h"
- #include "log.h"
- #include "dummy_dsp.h"
- #include "dummy_arm.h"
- #define BUFFER_SIZE_SINGLE_CH FFT_SIZE
- int main(int argc, const char *argv[])
- {
- int i;
- struct dsp_node *node;
- struct dsp_msg msg, replyMsg;
- printf("Setting up dsp\n");
- node = setup_dsp();
- setup_dmm_buffers(node, MAX_SEND_SIZE, MAX_RECEIVE_SIZE);
- // Create the impulse function
- printf("Testing DSP FFT...\nInput\n");
- for(i = 0; i < BUFFER_SIZE_SINGLE_CH; i++)
- {
- if(i == 0)
- ((int16_t *) input_buffer->data)[2*i] = 1;
- else
- ((int16_t *) input_buffer->data)[2*i] = 0;
- ((int16_t *) input_buffer->data)[2*i+1] = 0;
- if(i!=0 && i%8==0)
- printf("\n");
- printf("(%i + j%i) ", ((int16_t *) input_buffer->data)[2*i], ((int16_t *) input_buffer->data)[2*i+1]);
- }
- printf("\n");
- // Create/send the message to DSP
- msg.cmd = 1;
- msg.arg_1 = BUFFER_SIZE_SINGLE_CH;
- msg.arg_2 = 0; // Unused
- dsp_send(node, msg);
- // Receive the message from DSP
- while( !dsp_irecv(node, &replyMsg) );
- // Print the output
- printf("Done!\nOutput\n");
- for(i = 0; i < BUFFER_SIZE_SINGLE_CH; i++)
- {
- if(i!=0 && i%8==0)
- printf("\n");
- printf("(%f + j%f) ", ((int16_t *) output_buffer->data)[2*i]/((float) BUFFER_SIZE_SINGLE_CH*1.0f), ((int16_t *) output_buffer->data)[2*i+1]/((float) BUFFER_SIZE_SINGLE_CH*1.0f));
- }
- printf("\n");
- dsp_finish(node); // run at end of program
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement