Advertisement
Donny3000

dummy_arm.c

Jan 26th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.26 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2010-2011 University of Texas at Austin
  3.  *
  4.  * Author: Dan Zhang <dan.zhang@mail.utexas.edu>
  5.  *
  6.  * This library is free software; you can redistribute it and/or
  7.  * modify it under the terms of the GNU Lesser General Public
  8.  * License as published by the Free Software Foundation
  9.  * version 2.1 of the License.
  10.  *
  11.  * Copyright (C) 2009-2010 Felipe Contreras
  12.  * Copyright (C) 2009-2010 Nokia Corporation
  13.  * Copyright (C) 2009 Igalia S.L
  14.  *
  15.  * Author: Felipe Contreras <felipe.contreras@nokia.com>
  16.  *
  17.  * This file may be used under the terms of the GNU Lesser General Public
  18.  * License version 2.1, a copy of which is found in LICENSE included in the
  19.  * packaging of this file.
  20.  */
  21.  
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <stdbool.h>
  25. #include <signal.h>
  26. #include <stdio.h>
  27.  
  28. #include "dmm_buffer.h"
  29. #include "dsp_bridge.h"
  30. #include "log.h"
  31. #include "dummy_dsp.h"
  32. #include "dummy_arm.h"
  33.  
  34. #define BUFFER_SIZE_SINGLE_CH   FFT_SIZE
  35.  
  36. int main(int argc, const char *argv[])
  37. {
  38.     int i;
  39.     struct dsp_node *node;
  40.     struct dsp_msg msg, replyMsg;
  41.  
  42.     printf("Setting up dsp\n");
  43.     node = setup_dsp();
  44.     setup_dmm_buffers(node, MAX_SEND_SIZE, MAX_RECEIVE_SIZE);
  45.  
  46.     // Create the impulse function
  47.     printf("Testing DSP FFT...\nInput\n");
  48.     for(i = 0; i < BUFFER_SIZE_SINGLE_CH; i++)
  49.     {
  50.         if(i == 0)
  51.             ((int16_t *) input_buffer->data)[2*i] = 1;
  52.         else
  53.             ((int16_t *) input_buffer->data)[2*i] = 0;
  54.         ((int16_t *) input_buffer->data)[2*i+1]   = 0;
  55.  
  56.         if(i!=0 && i%8==0)
  57.             printf("\n");
  58.         printf("(%i + j%i) ", ((int16_t *) input_buffer->data)[2*i], ((int16_t *) input_buffer->data)[2*i+1]);
  59.     }
  60.     printf("\n");
  61.    
  62.     // Create/send the message to DSP
  63.     msg.cmd = 1;
  64.     msg.arg_1 = BUFFER_SIZE_SINGLE_CH;
  65.     msg.arg_2 = 0; // Unused
  66.     dsp_send(node, msg);
  67.  
  68.     // Receive the message from DSP
  69.     while( !dsp_irecv(node, &replyMsg) );
  70.  
  71.     // Print the output
  72.     printf("Done!\nOutput\n");
  73.     for(i = 0; i < BUFFER_SIZE_SINGLE_CH; i++)
  74.     {
  75.         if(i!=0 && i%8==0)
  76.             printf("\n");
  77.         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));
  78.     }
  79.     printf("\n");
  80.  
  81.     dsp_finish(node); // run at end of program
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement