⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demodmappermindist.c

📁 OFDMA 物理层开发的matlab 源码.飞思卡尔提供.对物理层开发的工程师有帮助!
💻 C
字号:
/* ============================================================================
   Property of Freescale
   Freescale Confidential Proprietary
   Freescale Copyright (C) 2005 All rights reserved
   ----------------------------------------------------------------------------
   $RCSfile: DemodMapperMinDist.c.rca $
   Tag $Name:  $
   $Revision: 1.1 $
   $Date: Fri Jan 26 13:05:43 2007 $
   Target Processor: Matlab
============================================================================ */

#include <stdlib.h>
#include <math.h>
#include "mex.h"
#include "SBX_FPULSPK_DemodMapperMinDist.c"
#undef _ENTERPRISE_C_
#include "prototype.c"
#include "math_funcs.c"

// Input Arguments (not all might be used)
#define	X1_IN	prhs[0]
#define	X2_IN	prhs[1]
#define	X3_IN	prhs[2]
#define	X4_IN	prhs[3]
#define	X5_IN	prhs[4]

// Output Arguments (not all might be used)
#define	Y1_OUT	plhs[0]
#define	Y2_OUT	plhs[1]
//#define	Y3_OUT	plhs[2]
//#define	Y4_OUT	plhs[3]
//#define	Y5_OUT	plhs[4]

/* mDemodMapperMinDist(In,Channel,BlkSize,mode,shift)
 in : 1x48 double complex
 Channel : 1x48 double complex
 BlkSize : 1x1 double
 mode : 1x1 double
 shift : 1x1 double 
 
unsigned long int SBX_FPULSPK_DemodMapperMinDist
    signed short int   *psiIn,\
    signed long int    *pliChEst,\
    signed char        *pcOut,\
    unsigned short int  usiBitShift,\
    unsigned long int   uliInLen,\
    unsigned char       ucModType)*/

void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[] )
{
    /* Matlab input dimensions (not all might be used) */
    unsigned long mx1,nx1;
    unsigned long mx2,nx2;
    unsigned long mx3,nx3;
    unsigned long mx4,nx4;
    unsigned long mx5,nx5;
    
    /* Matlab output dimensions (not all might be used) */
    unsigned long my1,ny1;
    unsigned long my2,ny2;
    
    
    unsigned long   m,n;
    unsigned long   i;
    signed short   *pasiIn;
    double         *dp;
    unsigned short *ausiDist;
    unsigned short int  usiShift;
    
    //Others
    double *temp3,*temp6,*temp7;
    double *temp1,*temp2;
    double *temp11,*temp12;
    signed short int  *X1;
    signed long int *X2;
    unsigned long int X5;
    double *temp4,*temp14;
    unsigned char X4,X6;
    int status,buflen;
    signed char *Y1;
    double *Y2;
    unsigned long int *temp5;
    int temp10;
    
    //mexPrintf("test1\n");
    /* Check for proper number of arguments */
    if ( !nrhs==5 )
    {        mexErrMsgTxt("Error: 4 or 5 input arguments required."); }
    
    if (nlhs > 2)
    { mexErrMsgTxt("Error: Too many output arguments.");}
    
    /* Check the input format */
    if ( !mxIsDouble(X1_IN) || !mxIsComplex(X1_IN))
    { mexErrMsgTxt("Error: input 1 must be complex of class 'double'.");}
    if ( !mxIsDouble(X2_IN) || !mxIsComplex(X2_IN))
    { mexErrMsgTxt("Error: input 2 must be complex of class 'double'."); }
    
    if ( !mxIsDouble(X3_IN) || mxIsComplex(X3_IN))
    { mexErrMsgTxt("Error: input 3 must be real of class 'double'."); }
    
    if ( !mxIsDouble(X4_IN) || mxIsComplex(X4_IN))
    { mexErrMsgTxt("Error: input 4 must be real of class 'double'.");}
    
   if ( !mxIsDouble(X5_IN) || mxIsComplex(X5_IN))
     {  mexErrMsgTxt("Error: input 5 must be real of class 'double'.");  }
    
    
    /* get input dimensions (not all might be used) */
    mx1=mxGetM(X1_IN); nx1=mxGetN(X1_IN);
    mx2=mxGetM(X2_IN); nx2=mxGetN(X2_IN);
    mx3=mxGetM(X3_IN); nx3=mxGetN(X3_IN);
    mx4=mxGetM(X4_IN); nx4=mxGetN(X4_IN);
    mx5=mxGetM(X5_IN); nx5=mxGetN(X5_IN);
    
    /* collect data : X1*/
    X1 = mxMalloc(sizeof(signed short int*)*mx1*nx1*2);
    temp1   = (double*)mxGetPr(X1_IN);
    temp2   = (double*)mxGetPi(X1_IN);
    
    for(i=0;i<mx1*nx1;i++)
    {   X1[2*i] = (signed short int) temp1[i] ;
        X1[2*i+1] = (signed short int) temp2[i] ;
        //mexPrintf("X1[2*i]=%d   X1[2*i+1]=%d  \n",(int) X1[2*i],(int) X1[2*i+1]);
    } 
    
   /*   for(i=0;i<10;i++)
    {   mexPrintf("temp1[2*i]=%d   temp2[2*i+1]=%d  \n",(signed short int) temp1[i],(signed short int) temp2[i]);
      //  mexPrintf("temp1[2*i]=%f   temp2[2*i+1]=%x  \n", temp1[i],temp2[i]);
    mexPrintf("X1[2*i]=%d   X1[2*i+1]=%d  \n",(signed short int) X1[2*i],(signed short int) X1[2*i+1]);
        } */
    
    /* collect data : X2*/
    X2 = mxMalloc(sizeof(signed long int*)*mx2*nx2*2);
    temp11   = (double*)mxGetPr(X2_IN);
    temp12   = (double*)mxGetPi(X2_IN);
    
    for(i=0;i<mx1*nx1;i++)
    {   X2[2*i] = (signed long int) temp11[i] ;
        X2[2*i+1] = (signed long int) temp12[i] ;
        //mexPrintf("X2[2*i]=%d   X2[2*i+1]=%d  \n",(int) X2[2*i],(int) X2[2*i+1]);
    }
    
   /*     for(i=0;i<10;i++)
    {

        mexPrintf("temp11[2*i]=%d   temp12[2*i+1]=%d  \n",(signed long int) temp11[i],(signed long int) temp12[i]);
        mexPrintf("X2[2*i]=%d   X2[2*i+1]=%d  \n",(signed long int) X2[2*i],(signed long int) X2[2*i+1]);
    } */
    
    
    /* collect data : X5*/
    X5 = (unsigned long int) (mx1*nx1);
    //mexPrintf("X5 %d\n",(int) X5 );
    
    /* collect data : X4*/
    temp4 = (double*)mxGetPr(X5_IN);
    X4 = (unsigned short int) (temp4[0]);
    //mexPrintf("X4 %d\n",(int) X4 );
    
    /* collect data : X6*/
    temp14 = (double*)mxGetPr(X4_IN);
    X6 = (unsigned short int) (temp14[0]);
    //mexPrintf("X6 %d\n",(int) X6 );

    
    ny1=nx1*X6; 
    my1=mx1; 
    //mexPrintf("my1 %d\n",(int) my1 );
    //mexPrintf("ny1 %d\n",(int) ny1 );
    
    Y1 = mxMalloc(sizeof(char*)*my1*ny1*2);
    
    //mexPrintf("Before C function  \n");
    status=SBX_FPULSPK_DemodMapperMinDist((signed short int*)X1,(signed long int*)X2,Y1,X4,X5,X6);
    //mexPrintf("After C function  \n");
    
    // outputs collection
    Y1_OUT = mxCreateNumericMatrix(my1, ny1, mxDOUBLE_CLASS, mxREAL);
    temp7 = (double*)mxGetPr(Y1_OUT);
    
    if (X6==2) /* QPSK */
    for(i=0;i<(my1*ny1)/2;i++)
    {
        temp7[2*i]   = (double)  Y1[2*i+1];
        temp7[2*i+1] = (double)  Y1[2*i];
    }
    else if (X6==4) /* 16QAM */
    for(i=0;i<(my1*ny1)/4;i++)
    {
        temp7[4*i]   = (double)  Y1[4*i+3];
        temp7[4*i+1] = (double)  Y1[4*i+2];
        temp7[4*i+2] = (double)  Y1[4*i+1];
        temp7[4*i+3] = (double)  Y1[4*i];
    }
    else if (X6==6) /* 64QAM */
    for(i=0;i<(my1*ny1)/6;i++)
    {   temp7[6*i]   = (double)  Y1[6*i+0];
        temp7[6*i+1] = (double)  Y1[6*i+1];
        temp7[6*i+2] = (double)  Y1[6*i+2];
        temp7[6*i+3] = (double)  Y1[6*i+3];
        temp7[6*i+4] = (double)  Y1[6*i+4];
        temp7[6*i+5] = (double)  Y1[6*i+5];
    }
    
    
    
   /*  for(i=0;i<10;i++)
    {   mexPrintf("temp7[i]=%d  \n",(double) (signed short int) temp7[i]);
      mexPrintf(" Y1[i]=%d  \n",(signed short int) Y1[i]);
          } */
    
    Y2_OUT = mxCreateDoubleMatrix(1, 1, mxREAL);
    Y2 = mxGetPr(Y2_OUT);
    Y2[0] = (double)(my1*ny1);
    
    return;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -