warpphy.c File Reference

Provide PHY-specific functions for interfacing WARPMAC (and MAC code) to the OFDM PHY peripherals. More...

#include "xparameters.h"
#include "warpphy.h"
#include "warpmac.h"
#include "ofdm_txrx_mimo_regMacros.h"
#include "ofdm_agc_mimo_regMacros.h"
#include "ofdm_pktdetector_mimo_regMacros.h"
#include "warp_timer_regMacros.h"
#include "EEPROM.h"
#include "radio_controller_basic.h"
#include "radio_controller_ext.h"
#include "radio_controller_adv.h"
#include "radio_controller_5ghz.h"
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Defines

#define BITMASK(byte, bit)   (1 << ((byte * 8) + bit))

Functions

int warpphy_init ()
 Initializes the OFDM PHY core The OFDM PHY and radio controller cores have many options which must be configured before they can be used over the air. This funciton configures these cores with sensible defaults.
void warpphy_clearRxInterrupts ()
 Clears any pending Rx interrupts in the PHY. Was warpphy_pktAck() in previous versions.
void mimo_ofdmRx_enable ()
 Releases the OFDM Rx PHY master reset.
void mimo_ofdmRx_disable ()
 Holds the OFDM Rx PHY in reset.
void mimo_ofdmRx_setOptions (unsigned int someOptions, unsigned int intType)
 Configures options in the Rx PHY.
unsigned int mimo_ofdmRx_getOptions ()
 Returns the current value of the Rx PHY configuration register.
void mimo_ofdmTx_disable ()
 Holds the OFDM Tx in reset.
void mimo_ofdmTx_enable ()
 Releases the OFDM Tx reset.
int warpphy_pktTx (unsigned int block)
 Initiates the transmission of a packet.
int warpphy_waitForTx ()
 Polls PHY transmitter and re-enables reception upon completion.
void warpphy_setBuffs (unsigned char txBufOffset, unsigned char rxBufOffset)
 Sets the packet buffer indicies for the OFDM Tx and Rx PHY.
void warpphy_enableSisoMode ()
 Configures the PHY for SISO mode.
void warpphy_enableMimoMode ()
 Configures the PHY for MIMO mode.
void warpphy_enableMisoMode ()
 Configures the TX PHY for MISO mode.
void warpphy_disableMisoMode ()
 Configures the TX PHY for SISO mode.
void warpphy_setNumTrainingSyms (unsigned int c)
 Sets the number of training symbol periods used per packet.
void warpphy_set_modulation (unsigned char baseRate, unsigned char antAFullRate, unsigned char antBFullRate)
 Configure the flexible modulation/demodulation in the OFDM PHY.
void warpphy_setSISOAntenna (unsigned char antSel)
 Selects which antenna is used when the PHY is in SISO mode.
int warpphy_setChannel (unsigned char band, unsigned int c)
 Set the center frequency of the radio transceivers.
int warpphy_setSeparateChannels (unsigned char antA_band, unsigned int antA_chan, unsigned char antB_band, unsigned int antB_chan)
 Set the center frequency of the radio transceivers independently.
void warpphy_setPktDlyPlus ()
void warpphy_setPktDlyMinus ()
void warpphy_set_PN_KPlus (unsigned int increment)
void warpphy_set_PN_KMinus (unsigned int decrement)
void print_CFO_constants ()
void warpphy_set_B_KPPlus (unsigned int increment)
void warpphy_set_B_KPMinus (unsigned int decrement)
void warpphy_set_B_KIPlus (unsigned int increment)
void warpphy_set_B_KIMinus (unsigned int decrement)
void warpphy_set_CFODebugOutput (unsigned char outputSel)
void warpphy_set_FFTOffset_Plus ()
void warpphy_set_FFTOffset_Minus ()
void warpphy_setNoiseTargetPlus ()
void warpphy_setNoiseTargetMinus ()
void warpphy_setTargetPlus ()
void warpphy_setTargetMinus ()
int warpphy_applyTxDCOCalibration (unsigned int radioSelection)
 Applies TX DC offset calibration to the specified radios; the calibration values are stored in the radio's EEPROM.
void warpphy_setPktDetPlus (unsigned int offset)
void warpphy_setPktDetMinus (unsigned int offset)
void warpphy_setCSMAPlus (unsigned int offset)
void warpphy_setCSMAMinus (unsigned int offset)
void warpphy_setGainPlus (unsigned int offset)
void warpphy_setGainMinus (unsigned int offset)
void ofdm_AGC_SetDCO (unsigned int AGCstate)
void ofdm_AGC_Reset ()
void ofdm_AGC_MasterReset ()
void ofdm_AGC_Initialize (int noise_estimate)
void ofdm_AGC_setNoiseEstimate (int noise_estimate)
unsigned int ofdm_AGC_GetGains (void)
void ofdm_AGC_SetTarget (unsigned int target)
void warp_timer_start (unsigned char timer)
void warp_timer_stop (unsigned char timer)
void warp_timer_resume (unsigned char timer)
void warp_timer_pause (unsigned char timer)
void warp_timer_setMode (unsigned char timer, unsigned char mode)
void warp_timer_resetInterrupt (unsigned char timer)
void warp_timer_resetInterrupts ()
void warp_timer_setVal (unsigned char timer, unsigned int val)
unsigned int warp_timer_timeLeft (unsigned char timer)
unsigned char warp_timer_getStatus (unsigned char timer)
unsigned char warp_timer_isExpired (unsigned char timer)
unsigned char warp_timer_isActive (unsigned char timer)
unsigned char warp_timer_isPaused (unsigned char timer)
unsigned int warp_timer_getStatuses ()
unsigned char warp_timer_getInterrupts ()
void warp_timer_init ()
char warpphy_pollRxStatus ()
 Polls the receiver and returns INCOMPLETE, GOODPACKET, or BADPACKET.
int warpphy_setTxPower (unsigned char txPwr)
 Set the transmit power (via the radio's RF VGA).

Variables

int agctarget
int agcnoiseEst
unsigned int warpphy_sisoMode
unsigned char baseRateMod
unsigned int numTrainingSyms
unsigned int pktDly
unsigned char globalReset
unsigned int numBaseRate
unsigned char txGain
unsigned int pktdetthresh = 9000
unsigned int csmathresh = 4000
unsigned int bothRadios = FIRST_RADIO | SECOND_RADIO
unsigned int activeRadio
unsigned int lastActiveRadio
unsigned int A_KPval
unsigned int B_KIval
unsigned int B_KPval
unsigned int PN_KVal
unsigned int RxFFT_Window_Offset


Detailed Description

Provide PHY-specific functions for interfacing WARPMAC (and MAC code) to the OFDM PHY peripherals.

Version:
10
Author:
Chris Hunter & Patrick Murphy
Many of the register names and bit assignments in this file depend on the design of the OFDM PHY. You must use matching versions of WARPMAC, WARPPHY and ofdm_txrx_mimo. Refer to the wireless reference designs for known-good combinations of versions.

Definition in file warpphy.c.


Function Documentation

void mimo_ofdmRx_disable (  ) 

Holds the OFDM Rx PHY in reset.

Asserting the RX_GLOBAL_RESET bit clears nearly all the state in the OFDM Rx. Configuration registers are not cleared.

Definition at line 400 of file warpphy.c.

References OFDM_BASEADDR, RX_GLOBAL_RESET, and warpphy_clearRxInterrupts().

Referenced by warpphy_init().

void mimo_ofdmRx_enable (  ) 

Releases the OFDM Rx PHY master reset.

De-asserting RX_GLOBAL_RESET allows the Rx PHY to begin processing packets.

Definition at line 386 of file warpphy.c.

References OFDM_BASEADDR, RX_GLOBAL_RESET, and warpphy_clearRxInterrupts().

Referenced by warpphy_init().

unsigned int mimo_ofdmRx_getOptions (  ) 

Returns the current value of the Rx PHY configuration register.

Returns the value of the OFDM Rx ControlBits register. Use the bit masks from warpphy.h to decode the indivitual bits.

Definition at line 433 of file warpphy.c.

References OFDM_BASEADDR.

Referenced by getByte(), lockRXantenna(), unlockRXantenna(), warpphy_enableMimoMode(), warpphy_enableSisoMode(), and warpphy_setSISOAntenna().

void mimo_ofdmRx_setOptions ( unsigned int  someOptions,
unsigned int  intType 
)

Configures options in the Rx PHY.

Parameters:
someOptions 32-bit options value, composed on bitwise OR'd values from warpphy.h
intType Selects whether to interrupt on good or bad packets. Bitwise OR'd combination of INTR_BAD_PKTS and INTR_GOOD_PKTS

Definition at line 415 of file warpphy.c.

References ALL_INTERRUPT_ENABLE, and OFDM_BASEADDR.

Referenced by getByte(), lockRXantenna(), unlockRXantenna(), warpphy_enableMimoMode(), warpphy_enableSisoMode(), warpphy_init(), and warpphy_setSISOAntenna().

void mimo_ofdmTx_disable (  ) 

Holds the OFDM Tx in reset.

Holds the OFDM Tx in reset; this prevents any state changes in the Tx PHY. Configuration registers are not affected.

Definition at line 442 of file warpphy.c.

References OFDM_BASEADDR.

Referenced by warpphy_init().

void mimo_ofdmTx_enable (  ) 

Releases the OFDM Tx reset.

Releases the OFDM Tx reset

Definition at line 453 of file warpphy.c.

References OFDM_BASEADDR.

Referenced by warpphy_init().

int warpphy_applyTxDCOCalibration ( unsigned int  radioSelection  ) 

Applies TX DC offset calibration to the specified radios; the calibration values are stored in the radio's EEPROM.

Parameters:
radioSelection OR'd combinaton of RADIOx_ADDR values, specifying which radios to update
Returns:
Returns -1 if an EEPROM error occurs; returns 0 if successful

Definition at line 921 of file warpphy.c.

References ICHAN, QCHAN, and WarpRadio_v1_DACOffsetAdj().

Referenced by warpphy_init().

void warpphy_clearRxInterrupts (  ) 

Clears any pending Rx interrupts in the PHY. Was warpphy_pktAck() in previous versions.

The Rx PHY blocks after asserting either its good or bad packet interrupt output. The interrupts are cleared by asserting then de-asserting a register bit per interrupt. This funciton clears both interrupts; there is no harm in clearing an interrupt that isn't actually asserted.

Definition at line 371 of file warpphy.c.

References DEFAULT_INTERRUPTRESETS, and OFDM_BASEADDR.

Referenced by mimo_ofdmRx_disable(), mimo_ofdmRx_enable(), phyRx_badHeader_int_handler(), phyRx_goodHeader_int_handler(), and warpmac_init().

int warpphy_pktTx ( unsigned int  block  ) 

Initiates the transmission of a packet.

Starts the transmission of a packet from the OFDM Tx PHY. If blocking is enabled, this function returns only after the transmission finishes. In this mode, the radio receiver is automatically re-enabled. If blocking is disabled, the receiver must be re-enabled in user code later.

Parameters:
block Selects whether this funciton blocks until the transmission finishes; use TXBLOCK or TXNOBLOCK
radio Selects which radios are enabled for the transmission

Definition at line 471 of file warpphy.c.

References activeRadio, OFDM_BASEADDR, TXBLOCK, WarpRadio_v1_RxEnable(), and WarpRadio_v1_TxEnable().

Referenced by warpmac_startPhyXmit().

char warpphy_pollRxStatus (  ) 

Polls the receiver and returns INCOMPLETE, GOODPACKET, or BADPACKET.

This function is used by the user's good header callback to check wait until the entire packet is received as either good or bad.

Returns:
INCOMPLETE, GOODPACKET, or BADPACKET

Definition at line 1325 of file warpphy.c.

References OFDM_BASEADDR.

Referenced by phyRx_goodHeader_callback(), phyRx_goodHeader_int_handler(), and rtsmac_phyRx_goodHeader_callback().

void warpphy_set_modulation ( unsigned char  baseRate,
unsigned char  antAFullRate,
unsigned char  antBFullRate 
)

Configure the flexible modulation/demodulation in the OFDM PHY.

The OFDM PHY supports flexible modulation, allowing any combination of schemes per subcarrier Currently this code supports simple dynamic modulation, with 48 of 64 subcarriers assigned to carry data, 4 for pilots and 12 empty. The modulation scheme in the 48 data subcarriers is set by this funciton.

Parameters:
baseRate Modulation scheme for base rate symbols
antAFullRate Modulation scheme for full rate symbols on antenna A
antBFullRate Modulation scheme for full rate symbols on antenna B

Definition at line 649 of file warpphy.c.

Referenced by warpmac_setBaseRate(), warpphy_enableMimoMode(), warpphy_enableSisoMode(), and warpphy_init().

void warpphy_setBuffs ( unsigned char  txBufOffset,
unsigned char  rxBufOffset 
)

Sets the packet buffer indicies for the OFDM Tx and Rx PHY.

The PLB_BRAM used a the PHY packet buffer is large enough to hold many PHY packets. This BRAM is divided into many sub-buffers; the PHY can be set to use any sub-buffer for Tx or Rx.

Parameters:
txBufOffset 6-bit integer selecting the sub-buffer for the PHY Tx
rxBufOffset 6-bit integer selecting the sub-buffer for the PHY Rx

Definition at line 537 of file warpphy.c.

References OFDM_BASEADDR.

Referenced by warpmac_finishPhyXmit(), warpmac_init(), warpmac_setRxBuffer(), warpmac_setTxBuffer(), and warpmac_startPhyXmit().

int warpphy_setChannel ( unsigned char  band,
unsigned int  c 
)

Set the center frequency of the radio transceivers.

Parameters:
band Selects 2.4GHz or 5GHz bands (using GHZ_2 or GHZ_5)
c Selects the channel number in the chosen band
Returns:
Returns -1 if an invalid band or channel was specified; otherwise returns the new center frequency in MHz

Definition at line 753 of file warpphy.c.

References FIRST_RADIO, GHZ_2, GHZ_5, SECOND_RADIO, WarpRadio_v1_SetCenterFreq2GHz(), and WarpRadio_v1_SetCenterFreq5GHz().

Referenced by main(), middle(), phyRx_goodHeader_callback(), switchChannels(), timerExpire(), and up().

void warpphy_setNumTrainingSyms ( unsigned int  c  ) 

Sets the number of training symbol periods used per packet.

Configures the number of training symbols which are transmitted with each packet. The Tx and Rx nodes must be configured for the same number. In SISO mode, the single channel is trained c times. In MIMO mode, each channel is trained c/2 times

Parameters:
c number of training periods; must be even

Definition at line 632 of file warpphy.c.

References mimo_ofdmRx_setNumOFDMSyms, numBaseRate, and numTrainingSyms.

Referenced by warpphy_init().

int warpphy_setSeparateChannels ( unsigned char  antA_band,
unsigned int  antA_chan,
unsigned char  antB_band,
unsigned int  antB_chan 
)

Set the center frequency of the radio transceivers independently.

Parameters:
antA_band Selects 2.4GHz or 5GHz bands (using GHZ_2 or GHZ_5) for antenna A
antB_band Selects 2.4GHz or 5GHz bands (using GHZ_2 or GHZ_5) for antenna B
antA_chan Selects the channel number in the chosen band for antenna A
antB_chan Selects the channel number in the chosen band for antenna B
Returns:
Returns -1 if an invalid band or channel was specified; otherwise returns the new center frequency for antenna A in MHz

Definition at line 775 of file warpphy.c.

References FIRST_RADIO, GHZ_2, GHZ_5, SECOND_RADIO, WarpRadio_v1_SetCenterFreq2GHz(), and WarpRadio_v1_SetCenterFreq5GHz().

void warpphy_setSISOAntenna ( unsigned char  antSel  ) 

Selects which antenna is used when the PHY is in SISO mode.

The OFDM PHY can use either antenna when in SISO mode. By default, antenna A is used.

Parameters:
anteSel 0: use Antenna A, 1: use Antenna B

Definition at line 703 of file warpphy.c.

References activeRadio, DEFAULT_INTERRUPTS, FIRST_RADIO, mimo_ofdmRx_getOptions(), mimo_ofdmRx_setOptions(), mimo_ofdmTx_getOptions, mimo_ofdmTx_setControlBits, SECOND_RADIO, SISO_ON_ANTB, SWITCHING_DIV_EN, TX_SISO_ON_ANTB, warpphy_sisoMode, and WarpRadio_v1_RxEnable().

Referenced by initFeedback(), left(), lockRXantenna(), main(), right(), and unlockRXantenna().

int warpphy_setTxPower ( unsigned char  txPwr  ) 

Set the transmit power (via the radio's RF VGA).

Parameters:
txPwr Desired transmit power; must be integer in [0,63]
Returns:
Returns -1 if an invalid power is requested; 0 on success

Definition at line 1334 of file warpphy.c.

References FIRST_RADIO, SECOND_RADIO, and WarpRadio_v1_SetTxGainTiming().

int warpphy_waitForTx (  ) 

Polls PHY transmitter and re-enables reception upon completion.

This function blocks until the transmitter is complete and then re-enables reception by enabing the radio receiver and enabling packet detection.

Definition at line 515 of file warpphy.c.

References activeRadio, OFDM_BASEADDR, and WarpRadio_v1_RxEnable().

Referenced by warpmac_finishPhyXmit().


Updated on Sat Oct 11 00:50:53 2008 WARP