mac_csp_tx.s51
来自「TI的基于ZIGBEE2006的协议栈」· S51 代码 · 共 1,454 行 · 第 1/5 页
S51
1,454 行
// 339 RFST = WHILE(C_SFD_IS_ACTIVE);
// 340 RFST = DECY;
// 341 RFST = __SNOP__;
// 342
// 343 /*
// 344 * Watch the SFD pin to determine when the transmit has finished going out.
// 345 * The INT instruction causes an interrupt to fire. The ISR for this interrupt
// 346 * handles the record the timestamp (which was just captured when SFD went high).
// 347 * Decrement CSPZ at the last step to indicate transmit was successful.
// 348 */
// 349 RFST = WHILE(C_SFD_IS_INACTIVE);
// 350 RFST = INT;
// 351 RFST = WHILE(C_SFD_IS_ACTIVE);
// 352 RFST = DECZ;
// 353 }
// 354
// 355
// 356 /**************************************************************************************************
// 357 * @fn macCspTxGoCsma
// 358 *
// 359 * @brief Run previously loaded CSP program for CSMA transmit. Handles either
// 360 * slotted or unslotted CSMA transmits. When CSP program has finished,
// 361 * an interrupt occurs and macCspTxStopIsr() is called. This ISR will in
// 362 * turn call macTxDoneCallback().
// 363 *
// 364 * @param none
// 365 *
// 366 * @return none
// 367 **************************************************************************************************
// 368 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 369 void macCspTxGoCsma(void)
macCspTxGoCsma:
CFI Block cfiBlock6 Using cfiCommon0
CFI Function macCspTxGoCsma
// 370 {
FUNCALL macCspTxGoCsma, macMcuOrRFIM
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
FUNCALL macCspTxGoCsma, macMcuOrRFIM
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
FUNCALL macCspTxGoCsma, macRxOn
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
PUSH DPL
CFI DPL0 Frame(CFA_SP, 4)
CFI CFA_SP SP+-4
PUSH DPH
CFI DPH0 Frame(CFA_SP, 5)
CFI CFA_SP SP+-5
; Saved register size: 2
; Auto size: 0
// 371 /*
// 372 * Set CSPX with the countdown time of the CSMA delay. Subtract one because there is
// 373 * a built-in one backoff delay in the CSP program to make sure receiver has been 'on'
// 374 * for at least one backoff. Don't subtract though if CSPX is already zero!
// 375 */
// 376 CSPX = macTxCsmaBackoffDelay;
MOV DPTR,#macTxCsmaBackoffDelay
MOVX A,@DPTR
MOV DPTR,#-0x20ee
MOVX @DPTR,A
// 377 if (CSPX != 0)
MOVX A,@DPTR
JZ ??macCspTxGoCsma_0
// 378 {
// 379 CSPX--;
MOVX A,@DPTR
DEC A
MOVX @DPTR,A
// 380 }
// 381
// 382 /*
// 383 * Set WEVENT to trigger at the current value of the timer. This allows
// 384 * unslotted CSMA to transmit just a little bit sooner.
// 385 */
// 386 CSP_WEVENT_SET_TRIGGER_NOW();
??macCspTxGoCsma_0:
MOV A,0xa6
MOV 0x94,0xa7
MOV A,0x94
JNZ ??macCspTxGoCsma_1
MOV 0x94,#0x1
// 387
// 388 /*
// 389 * Enable interrupt that fires when CSP program stops.
// 390 * Also enable interrupt that fires when INT instruction
// 391 * is executed.
// 392 */
// 393 MAC_MCU_CSP_STOP_ENABLE_INTERRUPT();
??macCspTxGoCsma_1:
; Setup parameters for call to function macMcuOrRFIM
MOV R1,#0x2
MOV DPTR,#(macMcuOrRFIM & 0xffff)
MOV A,#((macMcuOrRFIM >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 394 MAC_MCU_CSP_INT_ENABLE_INTERRUPT();
; Setup parameters for call to function macMcuOrRFIM
MOV R1,#0x1
MOV A,#((macMcuOrRFIM >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 395
// 396 /*
// 397 * Turn on the receiver if it is not already on. Receiver must be 'on' for at
// 398 * least one backoff before performing clear channel assessment (CCA).
// 399 */
// 400 macRxOn();
; Setup parameters for call to function macRxOn
MOV DPTR,#(macRxOn & 0xffff)
MOV A,#((macRxOn >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 401
// 402 /* start the CSP program */
// 403 CSP_START_PROGRAM();
MOV 0xe1,#-0x2
// 404 }
SJMP ??Subroutine0_1
CFI EndBlock cfiBlock6
RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine0:
CFI Block cfiBlock7 Using cfiCommon0
CFI NoFunction
CFI CFA_SP SP+-5
CFI DPL0 Frame(CFA_SP, 4)
CFI DPH0 Frame(CFA_SP, 5)
MOV 0xe1,#0x20
MOV 0xe1,#-0x21
MOV 0xe1,#-0x40
??Subroutine0_0:
MOV 0xe1,#-0x3d
MOV 0xe1,#0x39
MOV 0xe1,#0x1
MOV 0xe1,#-0x42
MOV 0xe1,#-0x40
MOV 0xe1,#0x9
MOV 0xe1,#-0x47
MOV 0xe1,#0x1
MOV 0xe1,#-0x41
??Subroutine0_1:
POP DPH
CFI CFA_SP SP+-4
CFI DPH0 SameValue
POP DPL
CFI CFA_SP SP+-3
CFI DPL0 SameValue
LJMP ?BRET
CFI EndBlock cfiBlock7
// 405
// 406
// 407 /**************************************************************************************************
// 408 * @fn macCspTxPrepSlotted
// 409 *
// 410 * @brief Prepare CSP for "Slotted" (non-CSMA) transmit.
// 411 * Load CSP program and set CSP parameters.
// 412 *
// 413 * @param none
// 414 *
// 415 * @return none
// 416 **************************************************************************************************
// 417 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 418 void macCspTxPrepSlotted(void)
macCspTxPrepSlotted:
CFI Block cfiBlock8 Using cfiCommon0
CFI Function macCspTxPrepSlotted
// 419 {
FUNCALL macCspTxPrepSlotted, ??cspPrepForTxProgram
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
PUSH DPL
CFI DPL0 Frame(CFA_SP, 4)
CFI CFA_SP SP+-4
PUSH DPH
CFI DPH0 Frame(CFA_SP, 5)
CFI CFA_SP SP+-5
; Saved register size: 2
; Auto size: 0
// 420 cspPrepForTxProgram();
; Setup parameters for call to function cspPrepForTxProgram
MOV DPTR,#(??cspPrepForTxProgram & 0xffff)
MOV A,#((??cspPrepForTxProgram >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 421
// 422 /*----------------------------------------------------------------------
// 423 * Load CSP program : Slotted transmit (no CSMA)
// 424 */
// 425
// 426 /* wait for X number of backoffs */
// 427 RFST = WAITX;
MOV 0xe1,#-0x45
// 428
// 429 /* just transmit, no CSMA required */
// 430 RFST = STXON;
SJMP ??Subroutine0_0
CFI EndBlock cfiBlock8
// 431
// 432 /*
// 433 * If the SFD pin is high at this point, there was an RX-TX collision.
// 434 * In other words, TXON was strobed while receiving. The CSP variable
// 435 * CSPY is decremented to indicate this happened. The rest of the transmit
// 436 * continues normally.
// 437 */
// 438 RFST = SKIP(2+__SNOP_SKIP__, C_SFD_IS_INACTIVE);
// 439 RFST = WHILE(C_SFD_IS_ACTIVE);
// 440 RFST = DECY;
// 441 RFST = __SNOP__;
// 442
// 443 /*
// 444 * Watch the SFD pin to determine when the transmit has finished going out.
// 445 * The INT instruction causes an interrupt to fire. The ISR for this interrupt
// 446 * handles the record the timestamp (which was just captured when SFD went high).
// 447 * Decrement CSPZ at the last step to indicate transmit was successful.
// 448 */
// 449 RFST = WHILE(C_SFD_IS_INACTIVE);
// 450 RFST = INT;
// 451 RFST = WHILE(C_SFD_IS_ACTIVE);
// 452 RFST = DECZ;
// 453 }
// 454
// 455
// 456 /**************************************************************************************************
// 457 * @fn macCspTxGoSlotted
// 458 *
// 459 * @brief Run previously loaded CSP program for non-CSMA slotted transmit. When CSP
// 460 * program has finished, an interrupt occurs and macCspTxStopIsr() is called.
// 461 * This ISR will in turn call macTxDoneCallback().
// 462 *
// 463 * @param none
// 464 *
// 465 * @return none
// 466 **************************************************************************************************
// 467 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 468 void macCspTxGoSlotted(void)
macCspTxGoSlotted:
CFI Block cfiBlock9 Using cfiCommon0
CFI Function macCspTxGoSlotted
// 469 {
FUNCALL macCspTxGoSlotted, macMcuOrRFIM
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
FUNCALL macCspTxGoSlotted, macMcuOrRFIM
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
PUSH DPL
CFI DPL0 Frame(CFA_SP, 4)
CFI CFA_SP SP+-4
PUSH DPH
CFI DPH0 Frame(CFA_SP, 5)
CFI CFA_SP SP+-5
; Saved register size: 2
; Auto size: 0
// 470 halIntState_t s;
// 471 uint8 lowByteOfBackoffCount;
// 472 uint8 backoffCountdown;
// 473
// 474 /*
// 475 * Enable interrupt that fires when CSP program stops.
// 476 * Also enable interrupt that fires when INT instruction
// 477 * is executed.
// 478 */
// 479 MAC_MCU_CSP_STOP_ENABLE_INTERRUPT();
; Setup parameters for call to function macMcuOrRFIM
MOV R1,#0x2
MOV DPTR,#(macMcuOrRFIM & 0xffff)
MOV A,#((macMcuOrRFIM >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 480 MAC_MCU_CSP_INT_ENABLE_INTERRUPT();
; Setup parameters for call to function macMcuOrRFIM
MOV R1,#0x1
MOV A,#((macMcuOrRFIM >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 481
// 482 /* critical section needed for timer accesses */
// 483 HAL_ENTER_CRITICAL_SECTION(s);
MOV C,0xa8.7
CLR A
MOV 0xE0 /* A */.0,C
MOV R3,A
CLR 0xa8.7
// 484
// 485 /* store lowest byte of backoff count (same as lowest byte of overflow count) */
// 486 lowByteOfBackoffCount = T2OF0;
MOV A,0xa1
MOV R4,A
// 487
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?