root/PlatformSupport/WARPMAC/warpphy.h

Revision 1015, 8.9 kB (checked in by murphpo, 3 days ago)

updating WARPMAC/WARPPHY with better support for the PHY's MIMO mode

Line 
1/*! \file warpphy.h
2\brief Header file for the WARPPHY functions
3
4@version 10
5@author Patrick Murphy and Chris Hunter
6
7This header file contains the macros, function prototypes, and typedefs required for WARPPHY.
8*/
9
10//WARPPHY Interface
11/***************CHANGELOG*****************
12
13******************************************/
14/*****************WARPPHY*****************
15Description: This file specifies the
16interface between to the PHY.
17******************************************/
18
19#ifndef WARPPHY_H
20#define WARPPHY_H
21
22//"XPAR_OFDM_TXRX_MIMO_PLBW_0_XC_VERSION" will be defined only when using the PLB46 flow in EDK/Sysgen 10.1+
23#define OFDM_BASEADDR 0
24#define OFDM_PKTBUFF_BASEADDR XPAR_XPS_BRAM_IF_CNTLR_2_BASEADDR
25
26//Masks for configuring modulation settings in the PHY
27//Each is 8 copies of a 4-bit modulation value
28#define MODMASK_BPSK 0x11111111
29#define MODMASK_QPSK 0x22222222
30#define MODMASK_16QAM 0x44444444
31#define MODMASK_64QAM 0x66666666
32
33#define NUMPKTBUFFS 4
34
35//Define a bunch of cryptic constants for the PHY's phase tracking filter
36#define INIT_A_KPVAL 0//0x7FFFFFFF//0xA6800
37#define INIT_B_KIVAL 0x2500//xD000//x380000//0x7FFFFFFF//0xA6800
38#define INIT_B_KPVAL 0xD0000//x2F000//x2620000//x7FFFFFFF//0x54afb0//0x1BC7D10//0x2C3C38//0xA6800
39#define INIT_PN_KVAL 0x2700000//xFFFFFFFF
40#define INIT_RXFFTOFSET 12
41
42//Define scaling values for the PHY's FFT cores
43#define TX_FFT_SCALING_STAGE1 1
44#define TX_FFT_SCALING_STAGE2 2
45#define TX_FFT_SCALING_STAGE3 3
46
47#define RX_FFT_SCALING_STAGE1 0 //1
48#define RX_FFT_SCALING_STAGE2 1 //2
49#define RX_FFT_SCALING_STAGE3 1 //1
50
51//RX Status register values
52#define INCOMPLETE 0
53#define GOODPACKET 1
54#define BADPACKET 2
55
56//Bit masks for the options configured in Rx_ControlBits
57#define RESET_BER                       0x1
58#define REQ_LONG_CORR           0x2
59#define DYNAMC_PKT_LENGTHS      0x4
60#define BIG_PKTBUF_MODE         0x8
61#define RX_SISO_MODE            0x10
62#define REQ_TWO_LONG_CORR       0x20
63#define REQ_SHORT_CORR          0x40
64#define EXT_PKT_DETECT          0x80
65#define INT_PKT_DETECT          0x100
66#define BYPASS_CARR_REC         0x200
67#define COARSE_CFO_EN           0x400
68#define DEBUG_CFO_OUTSEL        0x800
69#define CFO_USE_LONGCORR        0x1000
70#define USE_PILOT_ARCTAN        0x2000
71#define EQ_BYPASS_DIVISION  0x4000
72#define SIMPLE_DYN_MOD_EN       0x10000
73#define SWITCHING_DIV_EN        0x20000
74#define SISO_ON_ANTB            0x40000
75#define RESET_ON_BAD_HDR        0x80000
76#define RX_GLOBAL_RESET         0x80000000
77
78//Bit masks for the Tx/Rx interrupt enables
79#define INTR_RST_HEADER         0x1
80#define INTR_RST_PKTS                   0x2
81#define INTR_RST_TXDONE         0x4
82#define INTR_EN_GOOD_PKT        0x8
83#define INTR_EN_BAD_PKT         0x10
84#define INTR_EN_GOOD_HEADER     0x20
85#define INTR_EN_BAD_HEADER              0x40
86#define INTR_EN_TX_DONE                 0x80
87
88#define ALL_INTERRUPT_ENABLE (INTR_EN_GOOD_HEADER|INTR_EN_BAD_HEADER|INTR_EN_BAD_PKT|INTR_EN_GOOD_PKT|INTR_EN_TX_DONE)
89#define DEFAULT_INTERRUPTS (INTR_EN_GOOD_HEADER|INTR_EN_BAD_HEADER|INTR_EN_BAD_PKT|INTR_EN_GOOD_PKT)
90#define DEFAULT_INTERRUPTRESETS (INTR_RST_HEADER|INTR_RST_PKTS|INTR_RST_TXDONE)
91
92//Define which radios get used
93//RADIOx_ADDR are defined by the radio controller driver
94#define FIRST_RADIO RADIO2_ADDR
95#define SECOND_RADIO RADIO3_ADDR
96
97//Shorthand for configuring the radio controller's selected band
98#define GHZ_5 0
99#define GHZ_2 1
100
101//Bit masks for OFDM Tx options
102#define TX_SISO_MODE            0x1
103#define TX_RANDOM_MODE          0x2
104#define TX_DISABLE_ANTB_PREAMBLE 0x4
105#define TX_PILOT_SCRAMBLING 0x8
106//Bits 0xF0 are used for 4-bit preable shift value
107#define TX_SISO_ON_ANTB 0x100
108
109//MAC2PHY Options
110#define TXBLOCK         0x0
111#define TXNOBLOCK       0x1
112
113//Macros for accessing the OFDM packet buffer; buff is an integer in [0,NUMPKTBUFFS-1]
114#define warpphy_copyBytesToPhy(buff,src,len) memcpy(OFDM_PKTBUFF_BASEADDR + buff * 0x1000,(src),(len))
115#define warpphy_copyBytesFromPhy(buff,dest,len) memcpy((dest), OFDM_PKTBUFF_BASEADDR + buff * 0x1000, (len))
116
117//Macro to retrieve the physical memory address for a given packet buffer index
118#define warpphy_getBuffAddr(c) OFDM_PKTBUFF_BASEADDR + (c < NUMPKTBUFFS)*c*(0x800)
119
120//Macros to read/write PHY registers
121#define mimo_ofdmRx_setByteNums(c) ofdm_txrx_mimo_WriteReg_Rx_pktByteNums(OFDM_BASEADDR, c)
122#define mimo_ofdmRx_setRxScaling(c) ofdm_txrx_mimo_WriteReg_Rx_Constellation_Scaling(OFDM_BASEADDR, c)
123#define mimo_ofdmRx_setLongCorrParams(c) ofdm_txrx_mimo_WriteReg_Rx_PktDet_LongCorr_Params(OFDM_BASEADDR, c)
124#define mimo_ofdmRx_setNumOFDMSyms(c) ofdm_txrx_mimo_WriteReg_Rx_OFDM_SymbolCounts(OFDM_BASEADDR, c)
125#define mimo_ofdmRx_setCFO_B_KI(c) ofdm_txrx_mimo_WriteReg_Rx_FreqOffFilt_B_KI(OFDM_BASEADDR, c)
126#define mimo_ofdmRx_setCFO_B_KP(c) ofdm_txrx_mimo_WriteReg_Rx_FreqOffFilt_B_KP(OFDM_BASEADDR, c)
127#define mimo_ofdmRx_setPNTrack_K(c) ofdm_txrx_mimo_WriteReg_Rx_PhaseNoiseTrack_K(OFDM_BASEADDR, c)
128#define mimo_ofdmTx_setPilot1Index(c) ofdm_txrx_mimo_WriteReg_Tx_Pilots_Index1(OFDM_BASEADDR, c)
129#define mimo_ofdmTx_setPilot1Value(c) ofdm_txrx_mimo_WriteReg_Tx_Pilots_Value1(OFDM_BASEADDR, c)
130#define mimo_ofdmTx_setPilot2Index(c) ofdm_txrx_mimo_WriteReg_Tx_Pilots_Index2(OFDM_BASEADDR, c)
131#define mimo_ofdmTx_setPilot2Value(c) ofdm_txrx_mimo_WriteReg_Tx_Pilots_Value2(OFDM_BASEADDR, c)
132#define warpphy_setNumSyms(c) ofdm_txrx_mimo_WriteReg_Tx_OFDM_SymCounts(OFDM_BASEADDR, c)
133#define mimo_ofdmTx_setPreambleScaling(c) ofdm_txrx_mimo_WriteReg_Tx_PreambleScaling(OFDM_BASEADDR, c)
134#define mimo_ofdmTx_setControlBits(c) ofdm_txrx_mimo_WriteReg_Tx_ControlBits(OFDM_BASEADDR, c)
135#define mimo_ofdmTx_getOptions() ofdm_txrx_mimo_ReadReg_Tx_ControlBits(OFDM_BASEADDR)
136#define mimo_ofdmTxRx_setFFTScaling(c) ofdm_txrx_mimo_WriteReg_TxRx_FFT_Scaling(OFDM_BASEADDR, c)
137#define mimo_ofdmRx_setFFTWindowOffset(c) ofdm_txrx_mimo_WriteReg_Rx_PktDet_Delay(OFDM_BASEADDR, (ofdm_txrx_mimo_ReadReg_Rx_PktDet_Delay(OFDM_BASEADDR) & 0xFFFFE07F) | ((c&0x3F)<<7))
138#define mimo_ofdmRx_setPktDetDly(c) ofdm_txrx_mimo_WriteReg_Rx_PktDet_Delay(OFDM_BASEADDR, (ofdm_txrx_mimo_ReadReg_Rx_PktDet_Delay(OFDM_BASEADDR) & 0xFFFFFF80)| (c&0x7F))
139#define mimo_ofdmTx_setPktDoneReset(c) ofdm_txrx_mimo_WriteReg_Tx_Start_Reset_Control(OFDM_BASEADDR, (c<<2)&0x4)
140
141///Structure contains PHY header
142typedef struct {
143        ///Full-rate modulation order
144        unsigned char fullRate;
145        ///Reserved byte
146        unsigned char reserved4;
147        ///The length of the packet (in bytes). NOTE: This should only specify the length of the payload to-be-sent.
148        unsigned short int length;
149        ///Type of packet this particular Macframe corresponds to (e.g. DATA, ACKPACKET, etc.)
150        unsigned char pktType;
151        ///Destination MAC address.
152        unsigned char destAddr[6];
153        ///Source MAC address.
154        unsigned char srcAddr[6];
155        ///Number of times this packet has been retransmitted.
156        unsigned char currReSend;
157        ///Reserved byte
158        unsigned char reserved1;
159        ///Reserved byte
160        unsigned char reserved2;
161        ///Reserved byte
162        unsigned char reserved3;
163        ///Checksum of the packet will be automatically inserted by PHY
164        unsigned short int checksum;
165} phyHeader __attribute__((__aligned__(8)));
166
167//Prototypes for functions in warpphy.c
168int warpphy_init();
169void warpphy_clearRxInterrupts();
170void warpphy_clearTxInterrupts();
171int warpphy_pktTx(unsigned int block);
172void mimo_ofdmRx_enable();
173void mimo_ofdmRx_disable();
174void mimo_ofdmRx_setOptions(unsigned int someOptions, unsigned int intType);
175unsigned int mimo_ofdmRx_getOptions();
176void mimo_ofdmTx_disable();
177void mimo_ofdmTx_enable();
178void warpphy_setBuffs(unsigned char txBufOffset, unsigned char rxBufOffset);
179void warpphy_enableSisoMode();
180void warpphy_enableMimoMode();
181void warpphy_setNumTrainingSyms(unsigned int c);
182void warpphy_setPktDlyPlus();
183void warpphy_setPktDlyMinus();
184void warpphy_set_PN_KPlus(unsigned int increment);
185void warpphy_set_PN_KMinus(unsigned int decrement);
186void warpphy_set_CFODebugOutput(unsigned char outputSel);
187void print_CFO_constants();
188void warpphy_set_B_KPPlus(unsigned int increment);
189void warpphy_set_B_KPMinus(unsigned int decrement);
190void warpphy_set_B_KIPlus(unsigned int increment);
191void warpphy_set_B_KIMinus(unsigned int decrement);
192void warpphy_set_FFTOffset_Plus();
193void warpphy_set_FFTOffset_Minus();
194void warpphy_setNoiseTargetPlus();
195void warpphy_setNoiseTargetMinus();
196void warpphy_setTargetPlus();
197void warpphy_setTargetMinus();
198void warpphy_set_modulation(unsigned char baseRate, unsigned char antAFullRate, unsigned char antBFullRate);
199void warpphy_setSISOAntenna(unsigned char antSel);
200int warpphy_setChannel(unsigned char band,unsigned int c);
201int warpphy_applyTxDCOCorrection(unsigned int radioSelection);
202void warpphy_clearRxHeaderInterrupt();
203void warpphy_setPktDetPlus(unsigned int offset);
204void warpphy_setPktDetMinus(unsigned int offset);
205void warpphy_setCSMAPlus(unsigned int offset);
206void warpphy_setCSMAMinus(unsigned int offset);
207int warpphy_isFree();
208char warpphy_pollRxStatus();
209void ofdm_AGC_SetTarget(unsigned int target);
210void ofdm_AGC_SetDCO(unsigned int AGCstate);
211void ofdm_AGC_Reset();
212void ofdm_AGC_MasterReset();
213void ofdm_AGC_Initialize(int noise_estimate);
214void ofdm_AGC_setNoiseEstimate(int noise_estimate);
215unsigned int ofdm_AGC_GetGains(void);
216void ofdm_timer_start();
217void ofdm_timer_stop();
218void ofdm_timer_clearInterrupt();
219void ofdm_timer_init();
220
221#endif
222
Note: See TracBrowser for help on using the browser.