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

📄 commondef.h

📁 MIMO 2x2接收端选择全系统仿真代码
💻 H
字号:
/*****************************************************************************
  Module     : Common Definitions
******************************************************************************

  Function   : Common Definitions for the transmitter and receiver

  Procedures : none

  Old History: 2005-04-18	AS	created
  			   2005-04-27	AS	version 0.2, tx defs ok
  			   2005-05-04	AS	version 0.3, rx defs added
  			   2005-05-07	AS	version 0.4, moved to folder /common to make
  			   					it available for rx and tx.

  Author     : $Author: Maxime $

  Revision   : $Revision: 11 $

  Modified   : $Modtime: 22/05/05 20:34 $

  File       : $Workfile: commondef.h $

******************************************************************************
 KTH, Royal Institute of Technology, S3, Stockholm
******************************************************************************/

#ifndef MIMO_COMMON_DEF_H
#define  MIMO_COMMON_DEF_H

/*--- Include files --------------------------------------------------------*/

#include <csl_stdinc.h>

/*=== End of include files =================================================*/


/*--- Global defines -------------------------------------------------------*/

/* Mathematical constants */
#define PI 3.14159265358979323846f

/* Audio codec related */
#define SAMPFREQ		96000 // sampling frequency
#define QAMSCALING		10922 // scaling factor for QAM mapping
#define INTERFREQ		10000 // intermediate frequency

/* Transmission frame related defines */
/*
 Channel 1: Type SYNCHRONIZATION
 +---+---------+-----+---+-----+-------------------+
 | G | tr_sync | tr1 | G | tr1 | data              |
 +---+---------+-----+---+-----+-------------------+
 Channel 2:
 +---+---------+-----+---+-----+-------------------+
 | G | tr_sync | tr2 | G | tr2 | data              |
 +---+---------+-----+---+-----+-------------------+

 Channel 1: Type REGULAR
 +---+-----+---+-----+-----------------------------+
 | G | tr1 | G | tr1 | data                        |
 +---+-----+---+-----+-----------------------------+
 Channel 2:
 +---+-----+---+-----+-----------------------------+
 | G | tr2 | G | tr2 | data                        |
 +---+-----+---+-----+-----------------------------+
*/
/* General (same for regular and sync frame), both frames have to have the same length! */
#define CHANNELS		2
#define BITSPERSYMBOL	4
#define OVERSAMPLING	10
#define GUARDSYMBOLS	1   //number of guard symbols
/* Regular frame */
#define DATASYMBOLS		256 //number of data symbols in one regular frame
#define TRAINLEN		12  //number of training symbols in the trainingsequence for the regular frame
#define FRAMESYMBLENGTH	(2*GUARDSYMBOLS+2*TRAINLEN+DATASYMBOLS) // 282 symbols
/* Synchronization frame */
//#define SYNCREFRESH		2	//synchronization refresh rate (send such a frame every SYNCREFRESH frames)
#define NOOFINFOBYTES   10  //number of information bytes in the first frame
#define SYNCLEN			16  //number of synchronization symbols in the sync frame
#define DATASYMBSYNC	(DATASYMBOLS-SYNCLEN) //number of remaining data symbols in the sync frame
#define SYNCSYMBLENGTH	(2*GUARDSYMBOLS+2*TRAINLEN+SYNCLEN+DATASYMBSYNC) // 282 symbols
/* Pilot sequence at the beginning of the transmission to estimate the frequency offset */
#define SINPERIODS 100	// number of sinus periods
#define IFSYNCSAMP ((SINPERIODS*SAMPFREQ)/INTERFREQ) //number of samples for the pilot sequence
/* Length of one frame in number of samples (frame length has to be the same for both, Regualr and Synchronization!) */
#define FRAMESAMPLENGTH (FRAMESYMBLENGTH*OVERSAMPLING)

/* Buffer sizes for the EDMA buffers */
#define TXOUTBUFF (FRAMESYMBLENGTH*OVERSAMPLING)	//buffersize for the transmitter
#define RXBUFF 512									//buffersize for the receiver

/* Channels */
#define CH1 0
#define CH2 1

/* Macros for bit access */
#define WRITE_BITFIELD(Where, Fieldoffset, Fieldmask, Value) \
        Where = ((Where) & (~((Fieldmask) << (FieldOffset)))) | (((Value) & (Fieldmask)) << (FieldOffset))
#define READ_BITFIELD(Where, Fieldoffset, Fieldmask) \
        (((Where) >> (FieldOffset)) & (Fieldmask))
#define SetBit(Where, BitNumber)  (*(Where) = *(Where) | (1 << BitNumber))
#define ClearBit(Where, BitNumber)  *(Where) = *(Where) & (~(1 << BitNumber))
#define GetBit(Where, BitNumber)  ((*(Where) >> (BitNumber)) & 1)
/* Macros for circular buffer */
#define IncCircIndex(Index, BufLen, Steps) (*(Index) = (*(Index)+Steps < BufLen ? *(Index)+Steps : *(Index)+Steps-BufLen))
#define DecCircIndex(Index, BufLen, Steps) (*(Index) = (*(Index) < Steps ? *(Index)+BufLen-Steps : *(Index)-Steps))

/* Logical defines */
#ifndef TRUE
#define FALSE 0
#define TRUE  1
#endif

/* Error codes */
#define EXIT_RTDX_READ_FAILED	-1	// RTDX_read failed
#define EXIT_RTDX_WRITE_FAILED	-2	// RTDX_write failed
#define EXIT_INVALID_TXSTATE	-3	// state in TxStates.TxState not allowed
#define EXIT_INVALID_RXSTATE	-4	// state in RxState not allowed
#define EXIT_NEGSYNCIDX			-5	// negative index from synchronization
#define EXIT_INVALID_RCVSTATE	-6	// state in ReceiverState.RcvState not allowed
#define EXIT_WORKBUFF_TOOSMALL	-7	// the working buffer in the receiver is too small
#define EXIT_EDMABUFF_TOO_LARGE	-8	// the EDMA buffer is too large
#define EXIT_SYNCFRMLEN_NEQ_DATAFRMLEN	-9	// sync frame length not equal to data frame length
#define EXIT_TOOFEW_SYNCSAMPLES -10 // too few samples available to do the synchronization
#define EXIT_NEG_SYNC_IDX       -11 // the synchronization at the receiver returned a negative index
#define EXIT_FILESIZES_DIFFER   -12 // the files sent by the transmitter and the one selected at the receiver do not match

/*--- Global defines for the transmitter ----------*/

/* Polyphase Root Raised Cosine filter length */
#define RRCLEN 14

/*=== End of global defines for the transmitter ===*/

/*--- Global defines for the receiver -------------*/

/* cosine lookup table size */
#define COS_TAB_SIZE 2048

/*=== End of global defines for the receiver ======*/

/*=== End of global defines ================================================*/


/*--- Global types declaration ---------------------------------------------*/

/* Frame formats */
typedef enum 
{
  eCOM_STARTFRAME,
  eCOM_SYNCFRAME,
  eCOM_DATAFRAME
} typCOM_eFrameFormat;

/* Communication method */
typedef enum 
{
  eCOM_SISO = 0,
  eCOM_MIMO
} typCOM_eCommMethod;

/* Type for a complex valued buffer (Int16) */
typedef struct
{
  Int16 *pIBuffer;
  Int16 *pQBuffer;
} typCOM_iCPLXBUFF;

/* Type for a complex valued buffer (float) */
typedef struct
{
  float *pIBuffer;
  float *pQBuffer;
} typCOM_fCPLXBUFF;

/*=== End of global types declaration ======================================*/


/*--- Global variables declaration -----------------------------------------*/
/*=== End of global variables declaration ==================================*/


/*--- Global constants declaration -----------------------------------------*/
/*=== End of global constants declaration ==================================*/


/*--- Global functions declaration -----------------------------------------*/
/*=== End of global functions declaration ==================================*/
#endif

/*--- AUTOMATICALLY GENERATED VERSION HISTORY --------------------------------

$Log: /MIMO/common/commondef.h $ 
 * 
 * 11    22/05/05 20:34 Maxime
 * 
 * 10    05-05-20 9:13 Adrian
 * moved typTX_eTxState to txmain.h
 * 
 * 9     20.05.05 9:02 Adrian
 * added a define for NOOFINFOBYTES (number of information bytes in the
 * start frame)
 * 
 * 8     05-05-19 12:27 Adrian
 * changed EXIT_NEGSYNCIDX to EXIT_NEG_SYNC_IDX due to problems with an
 * already existing macro(?).
 * 
 * 7     19.05.05 11:10 Adrian
 * two more exit codes and macros for circular buffers (not tested, not
 * yet used)
 * 
 * 6     05-05-18 10:55 Adrian
 * added more exit codes
 * 
 * 5     05-05-17 16:36 Adrian
 * Added the error codes used for exit().
 * 
 * 4     05-05-16 16:00 Adrian
 * moved typRX_eRxState, typRX_eRcvState, and typRX_RECEIVESTATE from
 * commondef.h to rxmain.h
 * 
 * 3     05-05-12 15:54 Adrian
 * added the define FRAMESAMPLENGTH as the number of samples per frame
 * 
 * 2     05-05-11 14:52 Adrian
 * 
 * 1     05-05-11 14:40 Adrian
 * created and added to VSS

===== END OF AUTOMATICALLY GENERATED VERSION HISTORY =======================*/

/**** End of file ***********************************************************/

⌨️ 快捷键说明

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