Advertisement
Donny3000

dummy_dsp.c

Jan 26th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.06 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2008-2009 Nokia Corporation.
  3.  *
  4.  * Author: Felipe Contreras <felipe.contreras@nokia.com>
  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.  * This library is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14.  * Lesser General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU Lesser General Public
  17.  * License along with this library; if not, write to the Free Software
  18.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  19.  *
  20.  */
  21.  
  22. #include <math.h>
  23. #include <stddef.h>
  24. #include <ti/dsplib/dsplib.h>
  25. #include "node.h"
  26. #include "dummy_dsp.h"
  27. #include "twiddle_32_le.h"
  28.  
  29. #pragma DATA_ALIGN(x_16x16, 8)
  30. static short x_16x16[2*FFT_SIZE];
  31. #pragma DATA_ALIGN(y_16x16, 8)
  32. static short y_16x16[2*FFT_SIZE];
  33.  
  34. // Function specified by message command
  35. void compute_fft(struct dsp_global_t* global, void* in, void* out, uint32_t size, uint32_t unused)
  36. {
  37.     int i;
  38.  
  39.     // Copy the input data to the data_align input buffer
  40.     #pragma UNROLL(32)
  41.     for(i = 0; i < 2*size; i++)
  42.         x_16x16[i] = ((short *) in)[i];
  43.  
  44.     DSP_fft16x16r(size, x_16x16, w, y_16x16, 2, 0, size);
  45.  
  46.     #pragma UNROLL(32)
  47.     for(i = 0; i < 2*size; i++)
  48.         ((short *) out)[i] = y_16x16[i];
  49. }
  50.  
  51. unsigned int
  52. dummy_create(void)
  53. {
  54.   return 0x8000;
  55. }
  56.  
  57. unsigned int
  58. dummy_delete(void)
  59. {
  60.   return 0x8000;
  61. }
  62.  
  63. unsigned int
  64. dummy_execute(void *env)
  65. {
  66.   dsp_msg_t msg;
  67.   void *input;
  68.   void *output;
  69.   unsigned char done = 0;
  70.   unsigned short status;
  71.   struct dsp_global_t global;
  72.  
  73.   // Function pointer array
  74.   void (*dsp_func[NUM_DSP_FUNC+1]) (struct dsp_global_t*, void*, void*, uint32_t, uint32_t);
  75.  
  76.   init_dsp_func( dsp_func );
  77.  
  78.   // Initialize global variables in dummy_dsp.h
  79.   dsp_init_vars( &global );
  80.  
  81.  
  82.   while ( !done ) {
  83.  
  84.  
  85.     status = NODE_getMsg(env, &msg, 0); //(unsigned) -1);
  86.  
  87.     if(status != 1) {
  88. #ifdef DSP_IDLE_FUNC_EN
  89.     // Call idle function (runs when no message)
  90.     dsp_idle_func( &global );
  91. #endif
  92.       continue;
  93.     }
  94.  
  95.     switch (msg.cmd)
  96.     {
  97.         case 0:
  98.             input = (void *) (msg.arg_1);
  99.             output = (void *) (msg.arg_2);
  100.             break;
  101.  
  102.         case 0x80000000:
  103.             done = 1;
  104.             break;
  105.  
  106.         default:
  107.         {
  108.             uint32_t arg1;
  109.             uint32_t arg2;
  110.                
  111.             // Size is in BYTES
  112.             arg1 = msg.arg_1;
  113.             arg2 = msg.arg_2;
  114.  
  115.             /*
  116.              Cache coherence: invalidate the old
  117.              input buffer in the cache and fetch
  118.              the new input buffer from mem
  119.             */
  120.             BCACHE_inv(input, MAX_SEND_SIZE, 1);
  121.  
  122.             // Main program body
  123.             dsp_func[msg.cmd](&global, input, output, arg1, arg2);
  124.  
  125.             /*
  126.              Cache coherence: write the output
  127.              buffer from cache to main memory
  128.             */    
  129.             BCACHE_wb(output, MAX_RECEIVE_SIZE, 1);
  130.  
  131.             NODE_putMsg(env, NULL, &msg, 0);
  132.             break;
  133.         }
  134.     }
  135.   }
  136.  
  137.   return 0x8000;
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement