| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | #include "xparameters.h" |
|---|
| 13 | #include "xemac.h" |
|---|
| 14 | #include <xstatus.h> |
|---|
| 15 | #include "xintc.h" |
|---|
| 16 | #include "xgpio.h" |
|---|
| 17 | #include <errno.h> |
|---|
| 18 | #include "xexception_l.h" |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | #include "ofdm_txrx_alamouti.h" |
|---|
| 22 | #include "ofdm_AGC_mimo.h" |
|---|
| 23 | #include "ofdm_timer.h" |
|---|
| 24 | #include "ofdm_pktDetector_mimo.h" |
|---|
| 25 | #include "EEPROM.h" |
|---|
| 26 | #include "radio_controller_basic.h" |
|---|
| 27 | #include "radio_controller_ext.h" |
|---|
| 28 | #include "radio_controller_adv.h" |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | #include "warpmac.h" |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | Maccontrol controlStruct; |
|---|
| 38 | XGpio Gpio; |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | int agctarget = -13; |
|---|
| 42 | int agcnoiseEst = -95; |
|---|
| 43 | |
|---|
| 44 | unsigned int numTrainingSyms = 2; |
|---|
| 45 | unsigned int pktDly = 58; |
|---|
| 46 | unsigned char globalReset = 0; |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | unsigned int numBaseRate = 0; |
|---|
| 50 | |
|---|
| 51 | unsigned char mod_fullRate = 2; |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | #define INIT_A_KPVAL 0//0x7FFFFFFF//0xA6800 |
|---|
| 55 | #define INIT_B_KIVAL 0x2500//xD000//x380000//0x7FFFFFFF//0xA6800 |
|---|
| 56 | #define INIT_B_KPVAL 0xD0000//x2F000//x2620000//x7FFFFFFF//0x54afb0//0x1BC7D10//0x2C3C38//0xA6800 |
|---|
| 57 | #define INIT_PN_KVAL 0x2700000//xFFFFFFFF |
|---|
| 58 | #define INIT_PN_KAlphaVAL 0x40000000 |
|---|
| 59 | #define INIT_PN_KBetaVAL 0x40000000 |
|---|
| 60 | #define INIT_PN_KGammaVAL 0x40000000 |
|---|
| 61 | #define INIT_RXFFTOFSET 10 |
|---|
| 62 | unsigned int A_KPval = INIT_A_KPVAL; |
|---|
| 63 | unsigned int B_KIval = INIT_B_KIVAL; |
|---|
| 64 | unsigned int B_KPval = INIT_B_KPVAL; |
|---|
| 65 | unsigned int PN_KVal = INIT_PN_KVAL; |
|---|
| 66 | unsigned int PN_KAlphaVal = INIT_PN_KAlphaVAL; |
|---|
| 67 | unsigned int PN_KBetaVal = INIT_PN_KBetaVAL; |
|---|
| 68 | unsigned int PN_KGammaVal = INIT_PN_KGammaVAL; |
|---|
| 69 | unsigned int RxFFT_Window_Offset = INIT_RXFFTOFSET; |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | unsigned int ledStates[LEDLEN] = {1,2,4,8,4,2}; |
|---|
| 74 | unsigned int ledCounter = 0; |
|---|
| 75 | unsigned char ledStatesIndex = 0; |
|---|
| 76 | unsigned int ledStatesLow[2] = {1,2}; |
|---|
| 77 | unsigned int ledCounterLow = 0; |
|---|
| 78 | unsigned char ledStatesIndexLow = 0; |
|---|
| 79 | unsigned int ledStatesHigh[2] = {4,8}; |
|---|
| 80 | unsigned int ledCounterHigh = 0; |
|---|
| 81 | unsigned char ledStatesIndexHigh = 0; |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | XEmac Emac; |
|---|
| 86 | XEmac *InstancePtr = &Emac; |
|---|
| 87 | static Xuint8 LocalAddress[XEM_MAC_ADDR_SIZE] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06}; |
|---|
| 88 | static volatile int RxMutex; |
|---|
| 89 | static volatile int TxMutex; |
|---|
| 90 | static XStatus ErrorCode; |
|---|
| 91 | static XStatus RxStatus; |
|---|
| 92 | static Xuint32 RxFrameLength; |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | static XIntc myIntc; |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | void (*usr_upbutton) (); |
|---|
| 102 | void (*usr_leftbutton) (); |
|---|
| 103 | void (*usr_middlebutton) (); |
|---|
| 104 | void (*usr_rightbutton) (); |
|---|
| 105 | void (*usr_badPacketHandler) (); |
|---|
| 106 | void (*usr_goodPacketHandler) (); |
|---|
| 107 | void (*usr_timerHandler) (); |
|---|
| 108 | void (*usr_emacHandler) (); |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | Macframe* rxPacket; |
|---|
| 114 | Macframe* txPacket; |
|---|
| 115 | |
|---|
| 116 | void nullHandler(void* param){ |
|---|
| 117 | }; |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | void warpmac_phyInterruptClear(){ |
|---|
| 122 | alamouti_mac2phy_PktAck(); |
|---|
| 123 | return; |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | static void emacRx_int_handler(void *Callback) { |
|---|
| 128 | XEmac *EmacPtr = (XEmac *)Callback; |
|---|
| 129 | Xuint32 length = MY_XEM_MAX_FRAME_SIZE; |
|---|
| 130 | |
|---|
| 131 | if(controlStruct.enableEthernetInt){ |
|---|
| 132 | RxStatus = XEmac_FifoRecv(EmacPtr, txPacket->data, &length); |
|---|
| 133 | if(RxStatus != XST_SUCCESS){ |
|---|
| 134 | xil_printf("Error in Fifo Recv: %d\r\n", RxStatus); |
|---|
| 135 | return; |
|---|
| 136 | } |
|---|
| 137 | RxMutex=1; |
|---|
| 138 | usr_emacHandler(RxMutex,length); |
|---|
| 139 | } |
|---|
| 140 | else{ |
|---|
| 141 | RxMutex=0; |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | XIntc_Acknowledge(&myIntc,XPAR_OPB_INTC_0_ETHERNET_MAC_IP2INTC_IRPT_INTR); |
|---|
| 145 | |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | static void emacTx_int_handler(void *Callback){ |
|---|
| 150 | TxMutex=0; |
|---|
| 151 | rxPacket->isNew=0; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | static void emacErr_int_handler(void *Callback, XStatus ErrCode){ |
|---|
| 156 | xil_printf("ERROR IN EMAC #%d\r\n",ErrCode); |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | void warpmac_incrementLED(){ |
|---|
| 163 | if(ledCounter==0){ |
|---|
| 164 | XGpio_mSetDataReg(XPAR_LEDS_4BIT_BASEADDR, 1, ledStates[ledStatesIndex]); |
|---|
| 165 | ledStatesIndex = (ledStatesIndex+1)%LEDLEN; |
|---|
| 166 | } |
|---|
| 167 | ledCounter = (ledCounter+1)%BLINKEVERY; |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | |
|---|
| 172 | void warpmac_incrementLEDLow(){ |
|---|
| 173 | if(ledCounterLow==0){ |
|---|
| 174 | XGpio_mSetDataReg(XPAR_LEDS_4BIT_BASEADDR, 1, (ledStatesLow[ledStatesIndexLow]|ledStatesHigh[ledStatesIndexHigh])); |
|---|
| 175 | ledStatesIndexLow = (ledStatesIndexLow+1)%2; |
|---|
| 176 | } |
|---|
| 177 | ledCounterLow = (ledCounterLow+1)%BLINKEVERY; |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | |
|---|
| 182 | void warpmac_incrementLEDHigh(){ |
|---|
| 183 | if(ledCounterHigh==0){ |
|---|
| 184 | |
|---|
| 185 | XGpio_mSetDataReg(XPAR_LEDS_4BIT_BASEADDR, 1, (ledStatesLow[ledStatesIndexLow]|ledStatesHigh[ledStatesIndexHigh])); |
|---|
| 186 | ledStatesIndexHigh = (ledStatesIndexHigh+1)%2; |
|---|
| 187 | |
|---|
| 188 | } |
|---|
| 189 | ledCounterHigh = (ledCounterHigh+1)%BLINKEVERY; |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | |
|---|
| 196 | void timer_a_int_handler(void * baseaddr_p) { |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | ofdm_timer_clearInterrupt(); |
|---|
| 201 | int baseaddr = (int) baseaddr_p; |
|---|
| 202 | controlStruct.timerEnabled = 0; |
|---|
| 203 | |
|---|
| 204 | usr_timerHandler(controlStruct.timerType); |
|---|
| 205 | |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | void rxPhyBad(void *baseaddr_p) { |
|---|
| 214 | |
|---|
| 215 | unsigned char header[24]; |
|---|
| 216 | unsigned int numPayloadBytes; |
|---|
| 217 | int length; |
|---|
| 218 | |
|---|
| 219 | |
|---|
| 220 | alamouti_ofdmRx_copyHeader(header,24); |
|---|
| 221 | |
|---|
| 222 | unsigned int b = (unsigned int)header[18]; |
|---|
| 223 | unsigned int a = (unsigned int)header[19]; |
|---|
| 224 | |
|---|
| 225 | numPayloadBytes = a*256 + b; |
|---|
| 226 | |
|---|
| 227 | #ifdef DEBUG_PKT_PRINT |
|---|
| 228 | xil_printf("\r\n******************\r\nBAD:"); |
|---|
| 229 | xil_printf(" (%x %x -> %d) ",a, b, numPayloadBytes); |
|---|
| 230 | |
|---|
| 231 | int i; |
|---|
| 232 | for(i=0;i<24;i++) |
|---|
| 233 | { |
|---|
| 234 | xil_printf("%x.",header[i]); |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | xil_printf("\r\n"); |
|---|
| 238 | #endif |
|---|
| 239 | |
|---|
| 240 | usr_badPacketHandler(rxPacket); |
|---|
| 241 | alamouti_mac2phy_PktAck(); |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | void rxPhyGood(void *baseaddr_p) { |
|---|
| 254 | |
|---|
| 255 | if(rxPacket->isNew==0){ |
|---|
| 256 | unsigned char header[24]; |
|---|
| 257 | unsigned int numPayloadBytes; |
|---|
| 258 | int length; |
|---|
| 259 | alamouti_ofdmRx_copyHeader(header,24); |
|---|
| 260 | rxPacket->pktType = header[13]; |
|---|
| 261 | rxPacket->destAddr[0] = header[3]; |
|---|
| 262 | rxPacket->destAddr[1] = header[2]; |
|---|
| 263 | rxPacket->destAddr[2] = header[1]; |
|---|
| 264 | rxPacket->destAddr[3] = header[0]; |
|---|
| 265 | rxPacket->destAddr[4] = header[7]; |
|---|
| 266 | rxPacket->destAddr[5] = header[6]; |
|---|
| 267 | rxPacket->srcAddr[0] = header[5]; |
|---|
| 268 | rxPacket->srcAddr[1] = header[4]; |
|---|
| 269 | rxPacket->srcAddr[2] = header[11]; |
|---|
| 270 | rxPacket->srcAddr[3] = header[10]; |
|---|
| 271 | rxPacket->srcAddr[4] = header[9]; |
|---|
| 272 | rxPacket->srcAddr[5] = header[8]; |
|---|
| 273 | rxPacket->pktRev = header[15]; |
|---|
| 274 | |
|---|
| 275 | unsigned int b = (unsigned int)header[18]; |
|---|
| 276 | unsigned int a = (unsigned int)header[19]; |
|---|
| 277 | |
|---|
| 278 | numPayloadBytes = a*256 + b; |
|---|
| 279 | |
|---|
| 280 | if(controlStruct.sequenceVec[rxPacket->srcAddr[5]].sequenceNumber[1] == header[16]){ |
|---|
| 281 | controlStruct.packetDupe=1; |
|---|
| 282 | |
|---|
| 283 | } |
|---|
| 284 | else{ |
|---|
| 285 | controlStruct.packetDupe=0; |
|---|
| 286 | controlStruct.sequenceVec[rxPacket->srcAddr[5]].sequenceNumber[1] = header[16]; |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | #ifdef DEBUG_PKT_PRINT |
|---|
| 290 | xil_printf("\r\n******************\r\nGOOD:"); |
|---|
| 291 | xil_printf(" (%d) ",numPayloadBytes); |
|---|
| 292 | xil_printf(" (%d) ",ofdm_txrx_alamouti_ReadReg_Rx_packet_done(OFDM_BASEADDR)); |
|---|
| 293 | |
|---|
| 294 | int i; |
|---|
| 295 | for(i=0;i<24;i++) |
|---|
| 296 | { |
|---|
| 297 | xil_printf("%x.",header[i]); |
|---|
| 298 | } |
|---|
| 299 | |
|---|
| 300 | xil_printf("\r\n"); |
|---|
| 301 | #endif |
|---|
| 302 | |
|---|
| 303 | rxPacket->length = numPayloadBytes - 24 - 4; |
|---|
| 304 | if(rxPacket->length < 0 || rxPacket->length>MY_XEM_MAX_FRAME_SIZE){ |
|---|
| 305 | rxPacket->length=0; |
|---|
| 306 | } |
|---|
| 307 | usr_goodPacketHandler(rxPacket); |
|---|
| 308 | |
|---|
| 309 | } |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | alamouti_mac2phy_PktAck(); |
|---|
| 313 | |
|---|
| 314 | } |
|---|
| 315 | |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | |
|---|
| 319 | void pb_int_handler(void *baseaddr_p) { |
|---|
| 320 | |
|---|
| 321 | Xuint32 dsr; |
|---|
| 322 | XStatus stat; |
|---|
| 323 | char lock; |
|---|
| 324 | |
|---|
| 325 | dsr = XGpio_mGetDataReg(XPAR_PUSH_BUTTONS_4BIT_BASEADDR, 2); |
|---|
| 326 | switch(dsr) { |
|---|
| 327 | |
|---|
| 328 | case 0x01: |
|---|
| 329 | usr_middlebutton(); |
|---|
| 330 | break; |
|---|
| 331 | |
|---|
| 332 | case 0x02: |
|---|
| 333 | usr_rightbutton(); |
|---|
| 334 | break; |
|---|
| 335 | |
|---|
| 336 | case 0x08: |
|---|
| 337 | usr_upbutton(); |
|---|
| 338 | break; |
|---|
| 339 | case 0x04: |
|---|
| 340 | usr_leftbutton(); |
|---|
| 341 | break; |
|---|
| 342 | |
|---|
| 343 | default : { |
|---|
| 344 | } |
|---|
| 345 | |
|---|
| 346 | } |
|---|
| 347 | XGpio_InterruptClear(&Gpio, 0x3); |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | |
|---|
| 351 | |
|---|
| 352 | int warpmac_clearTimer(){ |
|---|
| 353 | int time; |
|---|
| 354 | time = ofdm_timer_timeLeft(); |
|---|
| 355 | ofdm_timer_stop(); |
|---|
| 356 | controlStruct.currBackoff=0; |
|---|
| 357 | return time; |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | |
|---|
| 361 | |
|---|
| 362 | void warpmac_setTimerVal(Xuint32 clocks){ |
|---|
| 363 | ofdm_timer_setVal(clocks); |
|---|
| 364 | } |
|---|
| 365 | |
|---|
| 366 | |
|---|
| 367 | |
|---|
| 368 | void warpmac_startTimer(unsigned char mode){ |
|---|
| 369 | ofdm_timer_setMode(mode); |
|---|
| 370 | ofdm_timer_start(); |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | |
|---|
| 374 | int randNum(int N){ |
|---|
| 375 | return rand() >> (32-(N+6)); |
|---|
| 376 | |
|---|
| 377 | |
|---|
| 378 | |
|---|
| 379 | |
|---|
| 380 | |
|---|
| 381 | |
|---|
| 382 | |
|---|
| 383 | } |
|---|
| 384 | |
|---|
| 385 | |
|---|
| 386 | unsigned int warpmac_carrierSense(){ |
|---|
| 387 | return ofdm_pktDetector_mimo_ReadReg_pktDet_idleDifs(PKTDET_BASEADDR); |
|---|
| 388 | } |
|---|
| 389 | |
|---|
| 390 | |
|---|
| 391 | int warpmac_setTimer(int type){ |
|---|
| 392 | unsigned int setTime; |
|---|
| 393 | int myRandNum; |
|---|
| 394 | int retval; |
|---|
| 395 | switch(type) { |
|---|
| 396 | case TIMEOUT: |
|---|
| 397 | controlStruct.timerType=TIMEOUT; |
|---|
| 398 | setTime = controlStruct.timeout*40; |
|---|
| 399 | warpmac_setTimerVal(setTime); |
|---|
| 400 | warpmac_startTimer(DISABLECSMA); |
|---|
| 401 | return 0; |
|---|
| 402 | break; |
|---|
| 403 | |
|---|
| 404 | case BACKOFF: |
|---|
| 405 | controlStruct.timerType=BACKOFF; |
|---|
| 406 | myRandNum = randNum(controlStruct.currBackoff); |
|---|
| 407 | setTime = myRandNum*controlStruct.slotTime*40; |
|---|
| 408 | if(controlStruct.currBackoff < controlStruct.maxBackoff){ |
|---|
| 409 | |
|---|
| 410 | |
|---|
| 411 | controlStruct.currBackoff = controlStruct.currBackoff + 1; |
|---|
| 412 | } |
|---|
| 413 | |
|---|
| 414 | |
|---|
| 415 | if(setTime != 0){ |
|---|
| 416 | warpmac_setTimerVal(setTime); |
|---|
| 417 | warpmac_startTimer(ENABLECSMA); |
|---|
| 418 | return 0; |
|---|
| 419 | } |
|---|
| 420 | |
|---|
| 421 | if(setTime == 0){ |
|---|
| 422 | usr_timerHandler(controlStruct.timerType); |
|---|
| 423 | } |
|---|
| 424 | break; |
|---|
| 425 | |
|---|
| 426 | } |
|---|
| 427 | } |
|---|
| 428 | |
|---|
| 429 | |
|---|
| 430 | |
|---|
| 431 | int warpmac_init() { |
|---|
| 432 | |
|---|
| 433 | usr_upbutton = nullHandler; |
|---|
| 434 | usr_leftbutton = nullHandler; |
|---|
| 435 | usr_middlebutton = nullHandler; |
|---|
| 436 | usr_rightbutton = nullHandler; |
|---|
| 437 | usr_badPacketHandler = nullHandler; |
|---|
| 438 | usr_goodPacketHandler = nullHandler; |
|---|
| 439 | |
|---|
| 440 | xil_printf("Initializing WARPMAC...\r\n"); |
|---|
| 441 | |
|---|
| 442 | xil_printf(" Initializing Ethernet..."); |
|---|
| 443 | |
|---|
| 444 | |
|---|
| 445 | |
|---|
| 446 | xil_printf(" Initializing controlStruct..."); |
|---|
| 447 | |
|---|
| 448 | controlStruct.enableSequencing = 0; |
|---|
| 449 | controlStruct.packetDupe=0; |
|---|
| 450 | controlStruct.mySequenceNum.sequenceNumber[1] = 0; |
|---|
| 451 | controlStruct.maxReSend = 4; |
|---|
| 452 | controlStruct.currBackoff = 0; |
|---|
| 453 | controlStruct.timerEnabled = 0; |
|---|
| 454 | controlStruct.maxBackoff = 5; |
|---|
| 455 | xil_printf("complete!\r\n"); |
|---|
| 456 | |
|---|
| 457 | int retval; |
|---|
| 458 | |
|---|
| 459 | xil_printf(" Initializing Interrupts..."); |
|---|
| 460 | |
|---|
| 461 | XGpio_mSetDataReg(XPAR_LEDS_4BIT_BASEADDR, 1, 0x0004); |
|---|
| 462 | |
|---|
| 463 | |
|---|
| 464 | XGpio_Initialize(&Gpio, XPAR_PUSH_BUTTONS_4BIT_DEVICE_ID); |
|---|
| 465 | |
|---|
| 466 | XGpio_mSetDataDirection(XPAR_PUSH_BUTTONS_4BIT_BASEADDR, 1, 0x3); |
|---|
| 467 | |
|---|
| 468 | XGpio_InterruptEnable(&Gpio, XGPIO_IR_CH1_MASK); |
|---|
| 469 | |
|---|
| 470 | |
|---|
| 471 | XGpio_InterruptGlobalEnable(&Gpio); |
|---|
| 472 | |
|---|
| 473 | |
|---|
| 474 | XIntc_Initialize(&myIntc, XPAR_OPB_INTC_0_DEVICE_ID); |
|---|
| 475 | |
|---|
| 476 | |
|---|
| 477 | XIntc_SetIntrSvcOption(XPAR_OPB_INTC_0_BASEADDR,XIN_SVC_ALL_ISRS_OPTION); |
|---|
| 478 | |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | XIntc_Connect(&myIntc, XPAR_OPB_INTC_0_PUSH_BUTTONS_4BIT_IP2INTC_IRPT_INTR,(XInterruptHandler)pb_int_handler, NULL); |
|---|
| 483 | XIntc_Connect(&myIntc, XPAR_OPB_INTC_0_OFDM_TXRX_ALAMOUTI_OPBW_0_RX_INT_GOODPKT_INTR,(XInterruptHandler)rxPhyGood, NULL); |
|---|
| 484 | XIntc_Connect(&myIntc, XPAR_OPB_INTC_0_OFDM_TXRX_ALAMOUTI_OPBW_0_RX_INT_BADPKT_INTR,(XInterruptHandler)rxPhyBad, NULL); |
|---|
| 485 | XIntc_Connect(&myIntc, XPAR_OPB_INTC_0_OFDM_TIMER_OPBW_0_TIMEREXPIRE_INTR,(XInterruptHandler)timer_a_int_handler, NULL); |
|---|
| 486 | XIntc_Connect(&myIntc, XPAR_OPB_INTC_0_ETHERNET_MAC_IP2INTC_IRPT_INTR,(XInterruptHandler) XEmac_IntrHandlerFifo, &Emac); |
|---|
| 487 | |
|---|
| 488 | |
|---|
| 489 | |
|---|
| 490 | XIntc_Start(&myIntc, XIN_REAL_MODE); |
|---|
| 491 | XIntc_Enable(&myIntc, XPAR_OPB_INTC_0_PUSH_BUTTONS_4BIT_IP2INTC_IRPT_INTR); |
|---|
| 492 | XIntc_Enable(&myIntc, XPAR_OPB_INTC_0_OFDM_TXRX_ALAMOUTI_OPBW_0_RX_INT_GOODPKT_INTR); |
|---|
| 493 | XIntc_Enable(&myIntc, XPAR_OPB_INTC_0_OFDM_TXRX_ALAMOUTI_OPBW_0_RX_INT_BADPKT_INTR); |
|---|
| 494 | XIntc_Enable(&myIntc, XPAR_OPB_INTC_0_OFDM_TIMER_OPBW_0_TIMEREXPIRE_INTR); |
|---|
| 495 | XIntc_Enable(&myIntc, XPAR_OPB_INTC_0_ETHERNET_MAC_IP2INTC_IRPT_INTR); |
|---|
| 496 | |
|---|
| 497 | |
|---|
| 498 | |
|---|
| 499 | |
|---|
| 500 | |
|---|
| 501 | xil_printf("Setting up exceptions...\r\n"); |
|---|
| 502 | XExc_Init(); |
|---|
| 503 | XExc_RegisterHandler(XEXC_ID_NON_CRITICAL_INT,(XExceptionHandler)XIntc_InterruptHandler,&myIntc); |
|---|
| 504 | XExc_mEnableExceptions(XEXC_NON_CRITICAL); |
|---|
| 505 | |
|---|
| 506 | |
|---|
| 507 | |
|---|
| 508 | xil_printf("complete!\r\n"); |
|---|
| 509 | |
|---|
| 510 | |
|---|
| 511 | |
|---|
| 512 | |
|---|
| 513 | int i,l; |
|---|
| 514 | XStatus Status; |
|---|
| 515 | Xuint32 Options; |
|---|
| 516 | Xuint16 DeviceId = XPAR_ETHERNET_MAC_DEVICE_ID; |
|---|
| 517 | |
|---|
| 518 | |
|---|
| 519 | |
|---|
| 520 | |
|---|
| 521 | |
|---|
| 522 | Status = XEmac_Initialize(InstancePtr, DeviceId); |
|---|
| 523 | if (Status != XST_SUCCESS) |
|---|
| 524 | { |
|---|
| 525 | xil_printf("Failed to initialize EMAC\r\n"); |
|---|
| 526 | return XST_FAILURE; |
|---|
| 527 | } |
|---|
| 528 | |
|---|
| 529 | |
|---|
| 530 | |
|---|
| 531 | |
|---|
| 532 | |
|---|
| 533 | Status = XEmac_SelfTest(InstancePtr); |
|---|
| 534 | if (Status != XST_SUCCESS) |
|---|
| 535 | { |
|---|
| 536 | xil_printf("Self Test Failed\r\n"); |
|---|
| 537 | return XST_FAILURE; |
|---|
| 538 | } |
|---|
| 539 | |
|---|
| 540 | |
|---|
| 541 | |
|---|
| 542 | |
|---|
| 543 | |
|---|
| 544 | |
|---|
| 545 | Options = (XEM_INSERT_FCS_OPTION | |
|---|
| 546 | XEM_INSERT_PAD_OPTION | |
|---|
| 547 | XEM_UNICAST_OPTION | |
|---|
| 548 | XEM_BROADCAST_OPTION | |
|---|
| 549 | |
|---|
| 550 | |
|---|
| 551 | XEM_PROMISC_OPTION| |
|---|
| 552 | XEM_STRIP_PAD_FCS_OPTION); |
|---|
| 553 | |
|---|
| 554 | Status = XEmac_SetOptions(InstancePtr, Options); |
|---|
| 555 | if (Status != XST_SUCCESS) |
|---|
| 556 | { |
|---|
| 557 | xil_printf("Failed to set options of EMAC\r\n"); |
|---|
| 558 | return XST_FAILURE; |
|---|
| 559 | } |
|---|
| 560 | |
|---|
| 561 | |
|---|
| 562 | |
|---|
| 563 | |
|---|
| 564 | |
|---|
| 565 | Status = XEmac_SetMacAddress(InstancePtr, LocalAddress); |
|---|
| 566 | |
|---|
| 567 | |
|---|
| 568 | if (Status != XST_SUCCESS) |
|---|
| 569 | { |
|---|
| 570 | xil_printf("Failed to set MAC of EMAC\r\n"); |
|---|
| 571 | return XST_FAILURE; |
|---|
| 572 | } |
|---|
| 573 | |
|---|
| 574 | |
|---|
| 575 | |
|---|
| 576 | |
|---|
| 577 | XEmac_SetFifoSendHandler(InstancePtr, InstancePtr, |
|---|
| 578 | (XEmac_FifoHandler)emacTx_int_handler); |
|---|
| 579 | XEmac_SetFifoRecvHandler(InstancePtr, InstancePtr, |
|---|
| 580 | (XEmac_FifoHandler)emacRx_int_handler); |
|---|
| 581 | XEmac_SetErrorHandler(InstancePtr, InstancePtr, |
|---|
| 582 | (XEmac_ErrorHandler)emacErr_int_handler); |
|---|
| 583 | |
|---|
| 584 | Status = XEmac_Start(InstancePtr); |
|---|
| 585 | if (Status != XST_SUCCESS) |
|---|
| 586 | { |
|---|
| 587 | xil_printf("Failed to start EMAC\r\n"); |
|---|
| 588 | return XST_FAILURE; |
|---|
| 589 | } |
|---|
| 590 | xil_printf("complete!\r\n"); |
|---|
| 591 | |
|---|
| 592 | RxMutex=0; |
|---|
| 593 | TxMutex=0; |
|---|
| 594 | |
|---|
| 595 | |
|---|
| 596 | |
|---|
| 597 | |
|---|
| 598 | |
|---|
| 599 | xil_printf(" Initializing Radio Transmitter..."); |
|---|
| 600 | |
|---|
| 601 | warpmac_CalibrateTxDCO(); |
|---|
| 602 | |
|---|
| 603 | |
|---|
| 604 | WarpRadio_v1_Reset((unsigned int *)XPAR_RADIO_CONTROLLER_0_BASEADDR); |
|---|
| 605 | WarpRadio_v1_TxLpfCornFreqCoarseAdj( 0x1, FIRST_RADIO | SECOND_RADIO); |
|---|
| 606 | |
|---|
| 607 | |
|---|
| 608 | |
|---|
| 609 | |
|---|
| 610 | WarpRadio_v1_24AmpEnable(FIRST_RADIO | SECOND_RADIO); |
|---|
| 611 | WarpRadio_v1_SetTxTiming(FIRST_RADIO, 50, 0, 0, 0); |
|---|
| 612 | WarpRadio_v1_SetTxTiming(SECOND_RADIO, 50, 255, 0, 0); |
|---|
| 613 | WarpRadio_v1_SetTxGainTiming(FIRST_RADIO | SECOND_RADIO, 0x3F, 0xF, 2); |
|---|
| 614 | WarpRadio_v1_BaseBandTxGain(0x0, FIRST_RADIO | SECOND_RADIO); |
|---|
| 615 | |
|---|
| 616 | xil_printf("complete!\r\n"); |
|---|
| 617 | |
|---|
| 618 | |
|---|
| 619 | |
|---|
| 620 | |
|---|
| 621 | xil_printf(" Initializing Radio Receiver..."); |
|---|
| 622 | |
|---|
| 623 | |
|---|
| 624 | WarpRadio_v1_SoftwareRxGainControl(0,FIRST_RADIO | SECOND_RADIO); |
|---|
| 625 | |
|---|
| 626 | |
|---|
| 627 | |
|---|
| 628 | |
|---|
| 629 | |
|---|
| 630 | WarpRadio_v1_RxLpfCornFreqCoarseAdj(0x0, FIRST_RADIO | SECOND_RADIO); |
|---|
| 631 | |
|---|
| 632 | |
|---|
| 633 | xil_printf("complete\r\n"); |
|---|
| 634 | |
|---|
| 635 | |
|---|
| 636 | |
|---|
| 637 | |
|---|
| 638 | |
|---|
| 639 | xil_printf(" Initializing OFDM Transmitter..."); |
|---|
| 640 | |
|---|
| 641 | #define TX_FFT_SCALING_STAGE1 1 |
|---|
| 642 | #define TX_FFT_SCALING_STAGE2 2 |
|---|
| 643 | #define TX_FFT_SCALING_STAGE3 3 |
|---|
| 644 | |
|---|
| 645 | |
|---|
| 646 | |
|---|
| 647 | |
|---|
| 648 | alamouti_ofdmTx_init(); |
|---|
| 649 | alamouti_ofdmTx_setFFTScaling((unsigned int)(16*TX_FFT_SCALING_STAGE1 + 4*TX_FFT_SCALING_STAGE2 + 1*TX_FFT_SCALING_STAGE3)); |
|---|
| 650 | alamouti_ofdmTx_setPilot1Index((7 + ((64-7)<<16) )); |
|---|
| 651 | alamouti_ofdmTx_setPilot1Value(0x8000); |
|---|
| 652 | alamouti_ofdmTx_setPilot2Index((21 + ((64-21)<<16))); |
|---|
| 653 | alamouti_ofdmTx_setPilot2Value(0x7fff); |
|---|
| 654 | alamouti_ofdmTx_setRandom(0); |
|---|
| 655 | |
|---|
| 656 | #ifdef DEBUG_PKT_PRINT |
|---|
| 657 | xil_printf("numTxBytes: %d\r\n",ofdm_txrx_alamouti_ReadReg_Tx_NumPayloadBytes(XPAR_OFDM_TXRX_ALAMOUTI_OPBW_0_BASEADDR)); |
|---|
| 658 | #endif |
|---|
| 659 | |
|---|
| 660 | alamouti_ofdmTx_setNumSyms(numTrainingSyms + (numBaseRate*256)); |
|---|
| 661 | alamouti_ofdmTx_setPreambleScaling(0x42FF); |
|---|
| 662 | alamouti_ofdmTx_setControlBits( |
|---|
| 663 | (2000 << 16) | |
|---|
| 664 | (0 << 9) | |
|---|
| 665 | (0 << 8) | |
|---|
| 666 | (2 << 4) | |
|---|
| 667 | |
|---|
| 668 | |
|---|
| 669 | TX_PILOT_SCRAMBLING |
|---|
| 670 | ); |
|---|
| 671 | alamouti_ofdmTx_enable(); |
|---|
| 672 | |
|---|
| 673 | |
|---|
| 674 | |
|---|
| 675 | |
|---|
| 676 | |
|---|
| 677 | xil_printf(" Initializing OFDM Receiver..."); |
|---|
| 678 | #define FFT_SCALING_STAGE1 0 |
|---|
| 679 | #define FFT_SCALING_STAGE2 1 |
|---|
| 680 | #define FFT_SCALING_STAGE3 1 |
|---|
| 681 | |
|---|
| 682 | alamouti_ofdmRx_init(); |
|---|
| 683 | |
|---|
| 684 | |
|---|
| 685 | |
|---|
| 686 | |
|---|
| 687 | |
|---|
| 688 | |
|---|
| 689 | |
|---|
| 690 | |
|---|
| 691 | |
|---|
| 692 | |
|---|
| 693 | unsigned int myScaling = 134219776; |
|---|
| 694 | |
|---|
| 695 | alamouti_ofdmRx_setFFTScaling((unsigned int)(16*FFT_SCALING_STAGE1 + 4*FFT_SCALING_STAGE2 + 1*FFT_SCALING_STAGE3)); |
|---|
| 696 | alamouti_ofdmRx_setFFTWindowOffset(INIT_RXFFTOFSET); |
|---|
| 697 | alamouti_ofdmRx_setRxScaling(myScaling); |
|---|
| 698 | alamouti_ofdmRx_setCorrThresh(0x60); |
|---|
| 699 | alamouti_ofdmRx_setEnergyThresh(0x0); |
|---|
| 700 | alamouti_ofdmRx_setLongCorrParams(251-16 + (2500*65536)); |
|---|
| 701 | alamouti_ofdmRx_setPktDetDly(80); |
|---|
| 702 | alamouti_ofdmRx_setNumOFDMSyms(numTrainingSyms + (numBaseRate*65536)); |
|---|
| 703 | |
|---|
| 704 | |
|---|
| 705 | alamouti_ofdmRx_setByteNums( (unsigned int)(24 + (18<<16) + (19<<24) )); |
|---|
| 706 | |
|---|
| 707 | |
|---|
| 708 | alamouti_ofdmRx_setCFODly(16); |
|---|
| 709 | |
|---|
| 710 | |
|---|
| 711 | |
|---|
| 712 | alamouti_ofdmRx_setCFO_A_KP(INIT_A_KPVAL); |
|---|
| 713 | |
|---|
| 714 | alamouti_ofdmRx_setCFO_B_KI(INIT_B_KIVAL); |
|---|
| 715 | alamouti_ofdmRx_setCFO_B_KP(INIT_B_KPVAL); |
|---|
| 716 | |
|---|
| 717 | alamouti_ofdmRx_setPNTrack_K(INIT_PN_KVAL); |
|---|
| 718 | alamouti_ofdmRx_setPNTrack_Kalpha(INIT_PN_KAlphaVAL); |
|---|
| 719 | alamouti_ofdmRx_setPNTrack_Kbeta(INIT_PN_KBetaVAL); |
|---|
| 720 | alamouti_ofdmRx_setPNTrack_Kgamma(INIT_PN_KGammaVAL); |
|---|
| 721 | |
|---|
| 722 | alamouti_ofdmRx_setOptions( |
|---|
| 723 | |
|---|
| 724 | REQ_LONG_CORR | |
|---|
| 725 | DYNAMC_PKT_LENGTHS | |
|---|
| 726 | REQ_TWO_LONG_CORR | |
|---|
| 727 | REQ_SHORT_CORR | |
|---|
| 728 | |
|---|
| 729 | |
|---|
| 730 | |
|---|
| 731 | USE_PILOT_ARCTAN | |
|---|
| 732 | SWITCHING_DIVERSITY | |
|---|
| 733 | QUAD_LONGCORR_EN | |
|---|
| 734 | EXT_PKT_DETECT, |
|---|
| 735 | INTR_BAD_PKTS | INTR_GOOD_PKTS |
|---|
| 736 | ); |
|---|
| 737 | alamouti_ofdmRx_enable(); |
|---|
| 738 | |
|---|
| 739 | |
|---|
| 740 | |
|---|
| 741 | |
|---|
| 742 | |
|---|
| 743 | xil_printf("complete!\r\n"); |
|---|
| 744 | |
|---|
| 745 | |
|---|
| 746 | |
|---|
| 747 | xil_printf(" Initializing AGC..."); |
|---|
| 748 | |
|---|
| 749 | WarpRadio_v1_RxHpSoftControlDisable(FIRST_RADIO | SECOND_RADIO); |
|---|
| 750 | |
|---|
| 751 | WarpRadio_v1_RxHighPassCornerFreq(1, FIRST_RADIO | SECOND_RADIO); |
|---|
| 752 | |
|---|
| 753 | ofdm_AGC_Initialize(agcnoiseEst); |
|---|
| 754 | ofdm_AGC_setNoiseEstimate(agcnoiseEst); |
|---|
| 755 | ofdm_AGC_FiltSel(1); |
|---|
| 756 | ofdm_AGC_SetDCO(1); |
|---|
| 757 | ofdm_AGC_SetTarget(agctarget); |
|---|
| 758 | ofdm_AGC_Reset(); |
|---|
| 759 | xil_printf("complete!\r\n"); |
|---|
| 760 | |
|---|
| 761 | |
|---|
| 762 | xil_printf(" Initializing Packet Detection..."); |
|---|
| 763 | |
|---|
| 764 | ofdm_pktDetector_mimo_WriteReg_csma_enableBusy(PKTDET_BASEADDR, 1); |
|---|
| 765 | ofdm_pktDetector_mimo_WriteReg_csma_enableIdle(PKTDET_BASEADDR, 1); |
|---|
| 766 | ofdm_pktDetector_mimo_WriteReg_pktDet_masterReset(PKTDET_BASEADDR, 1); |
|---|
| 767 | ofdm_pktDetector_mimo_WriteReg_pktDet_detectionMask(PKTDET_BASEADDR, 3); |
|---|
| 768 | |
|---|
| 769 | |
|---|
| 770 | ofdm_pktDetector_mimo_WriteReg_pktDet_detectionMode(PKTDET_BASEADDR, 1); |
|---|
| 771 | ofdm_pktDetector_mimo_WriteReg_pktDet_resetDuration(PKTDET_BASEADDR, 32); |
|---|
| 772 | ofdm_pktDetector_mimo_WriteReg_pktDet_avgLen(PKTDET_BASEADDR, 16); |
|---|
| 773 | ofdm_pktDetector_mimo_WriteReg_pktDet_avgThresh(PKTDET_BASEADDR, 7000); |
|---|
| 774 | ofdm_pktDetector_mimo_WriteReg_csma_avgThresh(PKTDET_BASEADDR, 16000); |
|---|
| 775 | ofdm_pktDetector_mimo_WriteReg_csma_difsPeriod(PKTDET_BASEADDR, 625); |
|---|
| 776 | ofdm_pktDetector_mimo_WriteReg_pktDet_masterReset(PKTDET_BASEADDR, 0); |
|---|
| 777 | ofdm_pktDetector_mimo_WriteReg_pktDet_reset(PKTDET_BASEADDR, 0); |
|---|
| 778 | |
|---|
| 779 | xil_printf("complete!\r\n"); |
|---|
| 780 | |
|---|
| 781 | |
|---|
| 782 | WarpRadio_v1_RxEnable(FIRST_RADIO | SECOND_RADIO); |
|---|
| 783 | |
|---|
| 784 | return 0; |
|---|
| 785 | |
|---|
| 786 | } |
|---|
| 787 | |
|---|
| 788 | |
|---|
| 789 | void warpmac_pollEthernet(int* callback()){ |
|---|
| 790 | xil_printf("Deprecated Function\r\n"); |
|---|
| 791 | } |
|---|
| 792 | |
|---|
| 793 | |
|---|
| 794 | void warpmac_sendEthernet(Macframe* packet){ |
|---|
| 795 | |
|---|
| 796 | if(!((controlStruct.enableSequencing) && (controlStruct.packetDupe)) && TxMutex==0){ |
|---|
| 797 | unsigned int length; |
|---|
| 798 | length = (packet->length)-4; |
|---|
| 799 | |
|---|
| 800 | XEmac_FifoSend(InstancePtr, OFDM_TXRX_ALAMOUTI_RXPKTBUFFER_BASEADDR+24, length); |
|---|
| 801 | |
|---|
| 802 | TxMutex=1; |
|---|
| 803 | rxPacket->isNew=1; |
|---|
| 804 | |
|---|
| 805 | } |
|---|
| 806 | |
|---|
| 807 | TxMutex = 0; |
|---|
| 808 | } |
|---|
| 809 | |
|---|
| 810 | |
|---|
| 811 | |
|---|
| 812 | |
|---|
| 813 | int warpmac_sendOfdm(Macframe* packet){ |
|---|
| 814 | int i; |
|---|
| 815 | unsigned int numPayloadBytes; |
|---|
| 816 | unsigned int Npld; |
|---|
| 817 | unsigned char header[24]; |
|---|
| 818 | |
|---|
| 819 | ofdm_pktDetector_mimo_WriteReg_pktDet_reset(PKTDET_BASEADDR, 1); |
|---|
| 820 | |
|---|
| 821 | |
|---|
| 822 | |
|---|
| 823 | |
|---|
| 824 | |
|---|
| 825 | Npld = 2 + ((packet->length + 4 + (6*mod_fullRate-1))/(6*mod_fullRate)); |
|---|
| 826 | Npld = Npld + (Npld%2); |
|---|
| 827 | |
|---|
| 828 | numPayloadBytes = 24 + packet->length + 4; |
|---|
| 829 | |
|---|
| 830 | alamouti_ofdmTx_setNumBytes(numPayloadBytes); |
|---|
| 831 | alamouti_ofdmTx_setNumSyms(numTrainingSyms + (numBaseRate*256) + (Npld*65536)); |
|---|
| 832 | |
|---|
| 833 | header[0]= (packet->destAddr[3]); |
|---|
| 834 | header[1]= (packet->destAddr[2]); |
|---|
| 835 | header[2]= (packet->destAddr[1]); |
|---|
| 836 | header[3]= (packet->destAddr[0]); |
|---|
| 837 | header[4]= (packet->srcAddr[1]); |
|---|
| 838 | header[5]= (packet->srcAddr[0]); |
|---|
| 839 | header[6]= (packet->destAddr[5]); |
|---|
| 840 | header[7]= (packet->destAddr[4]); |
|---|
| 841 | header[8]= (packet->srcAddr[5]); |
|---|
| 842 | header[9]= (packet->srcAddr[4]); |
|---|
| 843 | header[10]= (packet->srcAddr[3]); |
|---|
| 844 | header[11]= (packet->srcAddr[2]); |
|---|
| 845 | header[12]= 0; |
|---|
| 846 | header[13]= packet->pktType; |
|---|
| 847 | header[14]= mod_fullRate; |
|---|
| 848 | header[15]= packet->pktRev; |
|---|
| 849 | header[16]= (controlStruct.mySequenceNum.sequenceNumber[1]); |
|---|
| 850 | header[17]= 0; |
|---|
| 851 | header[18]= (0xFF & numPayloadBytes); |
|---|
| 852 | header[19]= (0xFF & (numPayloadBytes >> 8)); |
|---|
| 853 | header[20]= 0; |
|---|
| 854 | header[21]= 0; |
|---|
| 855 | header[22]= 0; |
|---|
| 856 | header[23]= 0; |
|---|
| 857 | |
|---|
| 858 | alamouti_ofdmTx_copyHeader(header,(size_t)24); |
|---|
| 859 | alamouti_ofdmTx_copyPayload(packet->data, (size_t)(packet->length) ); |
|---|
| 860 | |
|---|
| 861 | #ifdef DEBUG_PKT_PRINT |
|---|
| 862 | xil_printf("\r\n******************\r\nTX:"); |
|---|
| 863 | xil_printf(" (%d - %d) ",numPayloadBytes, Npld); |
|---|
| 864 | |
|---|
| 865 | for(i=0;i<24;i++) |
|---|
| 866 | { |
|---|
| 867 | xil_printf("%x.",header[i]); |
|---|
| 868 | } |
|---|
| 869 | |
|---|
| 870 | xil_printf("\r\n"); |
|---|
| 871 | #endif |
|---|
| 872 | |
|---|
| 873 | alamouti_mac2phy_pktTx(TXBLOCK, FIRST_RADIO | SECOND_RADIO); |
|---|
| 874 | |
|---|
| 875 | WarpRadio_v1_RxEnable(FIRST_RADIO | SECOND_RADIO); |
|---|
| 876 | |
|---|
| 877 | if(globalReset==0) ofdm_pktDetector_mimo_WriteReg_pktDet_reset(PKTDET_BASEADDR, 0); |
|---|
| 878 | |
|---|
| 879 | return 0; |
|---|
| 880 | } |
|---|
| 881 | |
|---|
| 882 | |
|---|
| 883 | void warpmac_setUpButtonHandler(void(*handler)()){ |
|---|
| 884 | usr_upbutton = handler; |
|---|
| 885 | } |
|---|
| 886 | |
|---|
| 887 | |
|---|
| 888 | void warpmac_setLeftButtonHandler(void(*handler)()){ |
|---|
| 889 | usr_leftbutton = handler; |
|---|
| 890 | } |
|---|
| 891 | |
|---|
| 892 | |
|---|
| 893 | void warpmac_setRightButtonHandler(void(*handler)()){ |
|---|
| 894 | usr_rightbutton = handler; |
|---|
| 895 | } |
|---|
| 896 | |
|---|
| 897 | |
|---|
| 898 | void warpmac_setMiddleButtonHandler(void(*handler)()){ |
|---|
| 899 | usr_middlebutton = handler; |
|---|
| 900 | } |
|---|
| 901 | |
|---|
| 902 | |
|---|
| 903 | void warpmac_setTimerHandler(void(*handler)()){ |
|---|
| 904 | usr_timerHandler = handler; |
|---|
| 905 | } |
|---|
| 906 | |
|---|
| 907 | |
|---|
| 908 | |
|---|
| 909 | |
|---|
| 910 | void warpmac_setEmacHandler(void(*handler)()){ |
|---|
| 911 | usr_emacHandler = handler; |
|---|
| 912 | } |
|---|
| 913 | |
|---|
| 914 | |
|---|
| 915 | void warpmac_setGoodPacketHandler(void(*handler)()){ |
|---|
| 916 | usr_goodPacketHandler = handler; |
|---|
| 917 | } |
|---|
| 918 | |
|---|
| 919 | |
|---|
| 920 | void warpmac_setBadPacketHandler(void(*handler)()){ |
|---|
| 921 | usr_badPacketHandler = handler; |
|---|
| 922 | } |
|---|
| 923 | |
|---|
| 924 | |
|---|
| 925 | |
|---|
| 926 | |
|---|
| 927 | |
|---|
| 928 | int warpmac_incrementResend(Macframe* packet){ |
|---|
| 929 | int status = 1; |
|---|
| 930 | packet->currReSend = ( packet->currReSend+1)%((controlStruct.maxReSend)+1); |
|---|
| 931 | if( packet->currReSend == 0) { |
|---|
| 932 | status = 0; |
|---|
| 933 | |
|---|
| 934 | controlStruct.currBackoff=0; |
|---|
| 935 | packet->isNew = 0; |
|---|
| 936 | } |
|---|
| 937 | return status; |
|---|
| 938 | } |
|---|
| 939 | |
|---|
| 940 | |
|---|
| 941 | |
|---|
| 942 | |
|---|
| 943 | int warpmac_allocatePayload(Macframe* packet,unsigned int length){ |
|---|
| 944 | xil_printf("Deprecated Function\r\n"); |
|---|
| 945 | } |
|---|
| 946 | |
|---|
| 947 | |
|---|