#include "xparameters.h"
#include "xstatus.h"
#include "errno.h"
#include "xexception_l.h"
#include "stddef.h"
#include "stdio.h"
#include "string.h"
#include "xdmacentral.h"
#include "xdmacentral_l.h"
#include "xemaclite.h"
#include "xemaclite_l.h"
#include "xintc.h"
#include "xgpio.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 "radio_controller_basic.h"
#include "radio_controller_ext.h"
#include "radio_controller_adv.h"
#include "warp_userio.h"
#include "warpphy.h"
Go to the source code of this file.
Functions | |
| void | nullCallback (void *param) |
| void | warpmac_init () |
| Initializes the framework and all hardware peripherals. | |
| void | phyRx_goodHeader_int_handler () |
| "Good Header" Interrupt handler for the PHY layer. | |
| void | phyRx_badHeader_int_handler () |
| "Bad" Interrupt handler for the PHY layer. | |
| void | emacRx_int_handler (void *CallBackRef) |
| Handles the reception of packets from the emac core. | |
| void | ErrorTrap (char *Message) |
| ErrorTrap This is a wrapper around a print statement. The purpose of this function is provide a single line to comment in or out to disable or enable debug messages. | |
| void | userIO_int_handler (void *InstancePtr) |
| Interrupt handler for the User I/O. | |
| void | timer_int_handler () |
| Interrupt handler for the timer peripheral. | |
| int | warpmac_clearTimer () |
| This function stops the timer. | |
| void | warpmac_setTimerVal (Xuint32 clocks) |
| This function sets the timer to countdown for a given number of clock cycles. | |
| void | warpmac_startTimer (unsigned char mode) |
| This function starts the timer in either a CSMA or non-CSMA mode. | |
| unsigned int | randNum (unsigned int N) |
| Generates a uniform random value between [0,(2^N - 1)], where N is a positive integer. | |
| unsigned int | warpmac_carrierSense () |
| Returns a value corresponding to the instantaneous channel condition {busy or idle}. | |
| void | warpmac_setTimer (int type) |
| Function is responsible for high-level MAC timing. | |
| int | warpmac_startEmacXmit (Macframe *packet) |
| Pushes the given Macframe over ethernet - must come after warpmac_prepEmacForXmit. | |
| void | warpmac_prepEmacForXmit (Macframe *packet) |
| Starts a DMA transfer from the RX PHY to the EMAC for Ethernet transmission. | |
| void | warpmac_setUpButtonCallback (void(*handler)()) |
| Attaches user callback to up button. | |
| void | warpmac_setLeftButtonCallback (void(*handler)()) |
| Attaches user callback to left button. | |
| void | warpmac_setRightButtonCallback (void(*handler)()) |
| Attaches user callback to right button. | |
| void | warpmac_setMiddleButtonCallback (void(*handler)()) |
| Attaches user callback to middle button. | |
| void | warpmac_setTimerCallback (void(*handler)()) |
| Attaches user callback to timer. | |
| void | warpmac_setEmacCallback (void(*handler)()) |
| Attaches user callback to the Emac. | |
| void | warpmac_setGoodHeaderCallback (void(*handler)()) |
| Attaches user callback to PHY's good header interrupt. | |
| void | warpmac_setBadHeaderCallback (void(*handler)()) |
| Attaches user callback to PHY's bad packet interrupt. | |
| void | warpmac_incrementLEDLow () |
| Alternates the bottom two LEDs on the WARP board. | |
| void | warpmac_incrementLEDHigh () |
| Alternates the top two LEDs on the WARP board. | |
| void | warpmac_setBaseRate (unsigned char rate) |
| Sets the base rate modulation order. | |
| void | warpmac_prepPhyForXmit (Macframe *packet, unsigned char buffer) |
| Loads a header into the PHY, but does not immediately transmit. | |
| void | warpmac_startPhyXmit (unsigned char buffer) |
| Sends the current txBuffer's content. | |
| void | warpmac_finishPhyXmit () |
| Blocks on PHY transmission. | |
| *void | warpmac_setRxBuffer (Macframe *packet, unsigned int rxBuff) |
| Tells the PHY which piece of memory to receive to. | |
| *void | warpmac_setTxBuffer (unsigned int txBuff) |
| Tells the PHY which piece of memory to send from. | |
| int | warpmac_getRxBuffer () |
| Returns which buffer PHY is set to receive to. | |
| int | warpmac_getTxBuffer () |
| Returns which buffer PHY is set to send from. | |
| int | warpmac_incrementResend (Macframe *packet) |
| Increments the resend counter for the given Macframe. | |
| int | warpmac_addressedToMe (Macframe *packet) |
| Returns a value corresponding to whether the packet was destined for this particular node. | |
| int | warpmac_addressedFromThem (Macframe *packet, unsigned char *addr) |
| Returns a value corresponding to whether the packet was sourced from a given node. | |
| int | warpmac_addressedToThem (Macframe *packet, unsigned char *addr) |
| Returns a value corresponding to whether the packet was destined for a given node. | |
| void | warpmac_setMaxResend (unsigned int c) |
| Sets the maximum number of resends. | |
| void | warpmac_setMaxCW (unsigned int c) |
| Sets the maximum contention window. | |
| void | warpmac_setMacAddr (unsigned char *addr) |
| Sets wireless MAC address of this node. | |
| void | warpmac_setTimeout (unsigned int time) |
| Sets the amount of time the node is willing to wait for an acknowledgement. | |
| void | warpmac_setSlotTime (unsigned int time) |
| Sets the smallest backoff window. | |
| int | warpmac_inTimeout () |
| Returns a value corresponding to whether or not the node is in timeout. | |
| int | warpmac_getMyId () |
| Reads the value from the user dip switches for use as node identification. | |
| void | warpmac_enableCSMA () |
| Lowers carrier sense threshold such that CSMA state is enabled. | |
| void | warpmac_disableCSMA () |
| Raises carrier sense threshold such that CSMA state is disabled. | |
| unsigned char | sevenSegmentMap (unsigned char x) |
| Maps character to the seven segment display. | |
| void | warpmac_leftHex (unsigned char x) |
| Displays the input character on the left hex display. | |
| void | warpmac_rightHex (unsigned char x) |
| Displays the input character on the right hex display. | |
| void | warpmac_setDebugGPIO (unsigned char val) |
| Raises a signal that is routed out to the debug header on the board. | |
| void | warpmac_enableEthernet () |
| Enabled the Ethernet. | |
| void | warpmac_disableEthernet () |
| Disables the Ethernet. | |
| void | warpmac_pollEthernet () |
| Polls the Ethernet. | |
| void | warpmac_enableMimoMode () |
| void | warpmac_enableSisoMode () |
| void | warpmac_enableMisoMode () |
| void | warpmac_disableMisoMode () |
Variables | |
| Maccontrol | controlStruct |
| unsigned char | timerIntStatus |
| unsigned char | currentEmacBuff |
| Macframe * | rxPacket |
| Macframe * | txPacket |
| unsigned int | LEDHEX_Outputs |
| unsigned int | ledStates |
| unsigned int | leftHex |
| unsigned int | rightHex |
| unsigned int | ledStatesLow [2] |
| unsigned char | ledStatesIndexLow |
| unsigned int | ledStatesHigh [2] |
| unsigned char | ledStatesIndexHigh |
| unsigned char | dipswState |
| unsigned char | warpmac_sisoMode |
| void(*) | usr_upbutton () |
| void(*) | usr_leftbutton () |
| void(*) | usr_middlebutton () |
| void(*) | usr_rightbutton () |
| void(*) | usr_badHeaderCallback () |
| void(*) | usr_goodHeaderCallback () |
| void(*) | usr_timerCallback () |
| void(*) | usr_emacCallback () |
Definition in file warpmac.c.
| void emacRx_int_handler | ( | void * | CallBackRef | ) |
Handles the reception of packets from the emac core.
This function is the ISR for the EMAC. It starts a DMA transfer of the payload into the PHY's packet buffer and calls the user's callback to further processing. Note: The function name is a bit of a misnomer with this release of the reference design. Interrupts have been removed for performance reasons. However, in the interest of symmetry and legacy, the "int_handler" moniker is left in place.
Definition at line 321 of file warpmac.c.
References controlStruct, currentEmacBuff, NUM_HEADER_BYTES, PING, PONG, Maccontrol::txBuffIndex, usr_emacCallback, warpphy_getBuffAddr, and XEmacLite_mGetReceiveDataLength.
Referenced by warpmac_pollEthernet().
| void phyRx_badHeader_int_handler | ( | ) |
"Bad" Interrupt handler for the PHY layer.
This function is the ISR for the RX physical layer peripheral. This function is only called if the packet fails CRC. The received packet is passed to the user's callback, and the PHY is reset.
Definition at line 297 of file warpmac.c.
References usr_badHeaderCallback, and warpphy_clearRxInterrupts().
Referenced by warpmac_init().
| void phyRx_goodHeader_int_handler | ( | ) |
"Good Header" Interrupt handler for the PHY layer.
This function is the ISR for the RX physical layer peripheral. This function is only called if the packet header has no bit errors (i.e., the packet header passes CRCs in the PHY). This interrupt will be asserted *before* the packet is fully received. This function assumes the user's callback will poll the PHY to determine if the packet is eventually good or bad
Definition at line 253 of file warpmac.c.
References controlStruct, Macframe::header, INCOMPLETE, phyHeader::length, MY_XEM_MAX_FRAME_SIZE, NUM_HEADER_BYTES, Maccontrol::rxBuffIndex, rxPacket, state, usr_goodHeaderCallback, warpphy_clearRxInterrupts(), warpphy_getBuffAddr, and warpphy_pollRxStatus().
Referenced by warpmac_init().
| unsigned int randNum | ( | unsigned int | N | ) |
Generates a uniform random value between [0,(2^N - 1)], where N is a positive integer.
Used internally by WARPMAC for random exponential backoffs.
| N | Window size for draw of uniform random value. |
Definition at line 523 of file warpmac.c.
Referenced by updateTimer(), and warpmac_setTimer().
| unsigned char sevenSegmentMap | ( | unsigned char | x | ) |
Maps character to the seven segment display.
| x | Input character |
Definition at line 1066 of file warpmac.c.
Referenced by warpmac_leftHex(), and warpmac_rightHex().
| void timer_int_handler | ( | ) |
Interrupt handler for the timer peripheral.
The timer interrupt handler gets called when a hardware timer set by the user expires. The user's callback is called upon the completion of this event
Definition at line 481 of file warpmac.c.
References controlStruct, timerIntStatus, Maccontrol::timerType, usr_timerCallback, warp_timer_getInterrupts(), and warp_timer_resetInterrupts().
Referenced by warpmac_init().
| void userIO_int_handler | ( | void * | InstancePtr | ) |
Interrupt handler for the User I/O.
This is a low-priority interrupt because it is primarily used for debugging purposes. The various user callbacks are executed, depending upon which button was depressed. Additionally, the board's dip switches also trigger this ISR, though the framework does not currently call user code in this event. We assume that dipswitches are currently only used for beginning-of-time state assignments. This will change in future releases.
Definition at line 441 of file warpmac.c.
References dipswState, usr_leftbutton, usr_middlebutton, usr_rightbutton, and usr_upbutton.
Referenced by warpmac_init().
| int warpmac_addressedFromThem | ( | Macframe * | packet, | |
| unsigned char * | addr | |||
| ) |
Returns a value corresponding to whether the packet was sourced from a given node.
| packet | Pointer to user's Macframe | |
| addr | Pointer to char array containing MAC address to compare against |
| int warpmac_addressedToMe | ( | Macframe * | packet | ) |
Returns a value corresponding to whether the packet was destined for this particular node.
| packet | Pointer to user's Macframe |
Definition at line 941 of file warpmac.c.
Referenced by phyRx_goodHeader_callback(), and rtsmac_phyRx_goodHeader_callback().
| int warpmac_addressedToThem | ( | Macframe * | packet, | |
| unsigned char * | addr | |||
| ) |
Returns a value corresponding to whether the packet was destined for a given node.
| packet | Pointer to user's Macframe | |
| addr | Pointer to char array containing MAC address to compare against |
| unsigned int warpmac_carrierSense | ( | ) |
Returns a value corresponding to the instantaneous channel condition {busy or idle}.
Definition at line 533 of file warpmac.c.
Referenced by emacRx_callback(), initTX(), sendBCD(), and switchChannels().
| int warpmac_clearTimer | ( | ) |
This function stops the timer.
Additionally it will return the amount of time remaining before expiration.
Definition at line 496 of file warpmac.c.
Referenced by phyRx_goodHeader_callback().
| void warpmac_finishPhyXmit | ( | ) |
Blocks on PHY transmission.
This function waits for the PHY to finish transmitting, then re-enables wireless reception and sets packet buffers back to their default values.
Definition at line 878 of file warpmac.c.
References controlStruct, Maccontrol::rxBuffIndex, Maccontrol::txBuffIndex, warpphy_setBuffs(), and warpphy_waitForTx().
Referenced by emacRx_callback(), initTX(), phyRx_goodHeader_callback(), rtsmac_phyRx_goodHeader_callback(), sendBCD(), sendCTS(), sendDAT(), switchChannels(), and timer_callback().
| int warpmac_getMyId | ( | ) |
Reads the value from the user dip switches for use as node identification.
Definition at line 1044 of file warpmac.c.
Referenced by initAddresses(), and main().
| int warpmac_getRxBuffer | ( | ) |
Returns which buffer PHY is set to receive to.
Definition at line 908 of file warpmac.c.
References controlStruct, and Maccontrol::rxBuffIndex.
| int warpmac_getTxBuffer | ( | ) |
Returns which buffer PHY is set to send from.
Definition at line 916 of file warpmac.c.
References controlStruct, and Maccontrol::txBuffIndex.
| int warpmac_incrementResend | ( | Macframe * | packet | ) |
Increments the resend counter for the given Macframe.
Also, it returns whether or not the counter has wrapped around the maximum number of retransmits
| packet | Pointer to user's Macframe |
Definition at line 927 of file warpmac.c.
Referenced by timer_callback().
| void warpmac_init | ( | ) |
Initializes the framework and all hardware peripherals.
This function sets reasonable default values for many of the parameters of the MAC, configures interrupts and exceptions, configures Ethernet, and finally initializes the custom peripherals such as the radio controller, the PHY, the packet detector, and the automatic gain control block.
Definition at line 100 of file warpmac.c.
Referenced by main().
| int warpmac_inTimeout | ( | ) |
Returns a value corresponding to whether or not the node is in timeout.
Definition at line 1037 of file warpmac.c.
Referenced by phyRx_goodHeader_callback().
| void warpmac_leftHex | ( | unsigned char | x | ) |
Displays the input character on the left hex display.
| x | Character to display |
Definition at line 1093 of file warpmac.c.
Referenced by left(), main(), middle(), phyRx_goodHeader_callback(), right(), rtsmac_up(), switchChannels(), timerExpire(), and up().
| void warpmac_pollEthernet | ( | ) |
| void warpmac_prepEmacForXmit | ( | Macframe * | packet | ) |
Starts a DMA transfer from the RX PHY to the EMAC for Ethernet transmission.
| packet | Pointer to user's Macframe |
Definition at line 662 of file warpmac.c.
References controlStruct, ErrorTrap(), Macframe::header, phyHeader::length, NUM_HEADER_BYTES, Maccontrol::rxBuffIndex, and warpphy_getBuffAddr.
Referenced by phyRx_goodHeader_callback(), and rtsmac_phyRx_goodHeader_callback().
| void warpmac_prepPhyForXmit | ( | Macframe * | packet, | |
| unsigned char | buffer | |||
| ) |
Loads a header into the PHY, but does not immediately transmit.
This function performs the conversion from the packet structure to the byte array but does not send the packet over the air. This is used to "preload" and ACK into the PHY while the data packet is still being received. This extra pipelining saves on turn-around time.
| packet | Pointer to user's Macframe | |
| buffer | Packet buffer to send from |
Definition at line 776 of file warpmac.c.
References phyHeader::fullRate, Macframe::header, phyHeader::length, NUM_HEADER_BYTES, numBaseRate, numTrainingSyms, warpmac_sisoMode, warpphy_getBuffAddr, and warpphy_setNumSyms.
Referenced by emacRx_callback(), initTX(), phyRx_goodHeader_callback(), rtsmac_emacRx_callback(), rtsmac_phyRx_goodHeader_callback(), sendCTS(), switchChannels(), and timer_callback().
| void warpmac_rightHex | ( | unsigned char | x | ) |
Displays the input character on the right hex display.
| x | Character to display |
Definition at line 1111 of file warpmac.c.
Referenced by phyRx_goodHeader_callback(), and warpmac_getMyId().
| void warpmac_setBadHeaderCallback | ( | void(*)() | handler | ) |
Attaches user callback to PHY's bad packet interrupt.
| handler | pointer to user's callback |
Definition at line 727 of file warpmac.c.
References usr_badHeaderCallback.
Referenced by main().
| void warpmac_setBaseRate | ( | unsigned char | rate | ) |
| void warpmac_setDebugGPIO | ( | unsigned char | val | ) |
| void warpmac_setEmacCallback | ( | void(*)() | handler | ) |
Attaches user callback to the Emac.
| handler | pointer to user's callback |
Definition at line 714 of file warpmac.c.
References usr_emacCallback.
Referenced by main().
| void warpmac_setGoodHeaderCallback | ( | void(*)() | handler | ) |
Attaches user callback to PHY's good header interrupt.
| handler | pointer to user's callback |
Definition at line 721 of file warpmac.c.
References usr_goodHeaderCallback.
Referenced by main().
| void warpmac_setLeftButtonCallback | ( | void(*)() | handler | ) |
Attaches user callback to left button.
| handler | pointer to user's callback |
Definition at line 689 of file warpmac.c.
References usr_leftbutton.
Referenced by main().
| void warpmac_setMacAddr | ( | unsigned char * | addr | ) |
Sets wireless MAC address of this node.
| addr | Pointer to char array containing MAC address |
Definition at line 1011 of file warpmac.c.
Referenced by initAddresses(), and main().
| void warpmac_setMaxCW | ( | unsigned int | c | ) |
Sets the maximum contention window.
| c | Maximum contention window |
Definition at line 1004 of file warpmac.c.
Referenced by initDelays(), and main().
| void warpmac_setMaxResend | ( | unsigned int | c | ) |
| void warpmac_setMiddleButtonCallback | ( | void(*)() | handler | ) |
Attaches user callback to middle button.
| handler | pointer to user's callback |
Definition at line 701 of file warpmac.c.
References usr_middlebutton.
Referenced by main().
| void warpmac_setRightButtonCallback | ( | void(*)() | handler | ) |
Attaches user callback to right button.
| handler | pointer to user's callback |
Definition at line 695 of file warpmac.c.
References usr_rightbutton.
Referenced by main().
| * void warpmac_setRxBuffer | ( | Macframe * | packet, | |
| unsigned int | rxBuff | |||
| ) |
Tells the PHY which piece of memory to receive to.
Also, it updates the global struct element Maccontrol::rxBuffIndex to keep track of that information
Definition at line 889 of file warpmac.c.
Referenced by main().
| void warpmac_setSlotTime | ( | unsigned int | time | ) |
| void warpmac_setTimeout | ( | unsigned int | time | ) |
| void warpmac_setTimer | ( | int | type | ) |
Function is responsible for high-level MAC timing.
This function is used by user code, and in turn calls the other timer functions. It is capable of initiating either a deterministic timeout, or a random backoff.
Definition at line 550 of file warpmac.c.
Referenced by emacRx_callback(), and timer_callback().
| void warpmac_setTimerCallback | ( | void(*)() | handler | ) |
Attaches user callback to timer.
| handler | pointer to user's callback |
Definition at line 707 of file warpmac.c.
References usr_timerCallback.
Referenced by main().
| void warpmac_setTimerVal | ( | Xuint32 | clocks | ) |
This function sets the timer to countdown for a given number of clock cycles.
| clocks | Number of 40MHz clock cycles to countdown from |
Definition at line 506 of file warpmac.c.
Referenced by main(), phyRx_goodHeader_callback(), timerExpire(), up(), and warpmac_setTimer().
| * void warpmac_setTxBuffer | ( | unsigned int | txBuff | ) |
Tells the PHY which piece of memory to send from.
Also, it updates the global struct element Maccontrol::txBuffIndex to keep track of that information
Definition at line 899 of file warpmac.c.
Referenced by main().
| void warpmac_setUpButtonCallback | ( | void(*)() | handler | ) |
Attaches user callback to up button.
| handler | pointer to user's callback |
Definition at line 683 of file warpmac.c.
References usr_upbutton.
Referenced by main().
| int warpmac_startEmacXmit | ( | Macframe * | packet | ) |
Pushes the given Macframe over ethernet - must come after warpmac_prepEmacForXmit.
| packet | Pointer to user's Macframe |
Definition at line 586 of file warpmac.c.
References Macframe::header, and phyHeader::length.
Referenced by phyRx_goodHeader_callback(), and rtsmac_phyRx_goodHeader_callback().
| void warpmac_startPhyXmit | ( | unsigned char | buffer | ) |
Sends the current txBuffer's content.
This function sends an existing Macframe over the air. This existing Macframe comes from the warpmac_prepPhyForXmit function.
Definition at line 851 of file warpmac.c.
References controlStruct, ErrorTrap(), Maccontrol::rxBuffIndex, TXNOBLOCK, warpphy_pktTx(), and warpphy_setBuffs().
Referenced by emacRx_callback(), initTX(), phyRx_goodHeader_callback(), rtsmac_phyRx_goodHeader_callback(), sendBCD(), sendCTS(), sendDAT(), switchChannels(), and timer_callback().
| void warpmac_startTimer | ( | unsigned char | mode | ) |
This function starts the timer in either a CSMA or non-CSMA mode.
| mode | ENABLECSMA if automatic carrier-sense pausing is desired. DISABLECSMA if received energy is to be ignored. |
Definition at line 514 of file warpmac.c.
Referenced by main(), phyRx_goodHeader_callback(), timerExpire(), up(), and warpmac_setTimer().
| Updated on Wed Aug 6 13:29:32 2008 | |