📄 mac_csp_tx.lst
字号:
379 CSPX--;
\ 00000F E0 MOVX A,@DPTR
\ 000010 14 DEC A
\ 000011 F0 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:
\ 000012 E5A6 MOV A,0xa6
\ 000014 85A794 MOV 0x94,0xa7
\ 000017 E594 MOV A,0x94
\ 000019 7003 JNZ ??macCspTxGoCsma_1
\ 00001B 759401 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:
\ 00001E ; Setup parameters for call to function macMcuOrRFIM
\ 00001E 7902 MOV R1,#0x2
\ 000020 90.... MOV DPTR,#(macMcuOrRFIM & 0xffff)
\ 000023 74.. MOV A,#((macMcuOrRFIM >> 16) & 0xff)
\ 000025 12.... LCALL ?BCALL ; Banked call to: DPTR()
394 MAC_MCU_CSP_INT_ENABLE_INTERRUPT();
\ 000028 ; Setup parameters for call to function macMcuOrRFIM
\ 000028 7901 MOV R1,#0x1
\ 00002A 74.. MOV A,#((macMcuOrRFIM >> 16) & 0xff)
\ 00002C 12.... 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();
\ 00002F ; Setup parameters for call to function macRxOn
\ 00002F 90.... MOV DPTR,#(macRxOn & 0xffff)
\ 000032 74.. MOV A,#((macRxOn >> 16) & 0xff)
\ 000034 12.... LCALL ?BCALL ; Banked call to: DPTR()
401
402 /* start the CSP program */
403 CSP_START_PROGRAM();
\ 000037 75E1FE MOV 0xe1,#-0x2
404 }
\ 00003A 80.. SJMP ??Subroutine0_1
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 */
\ In segment BANKED_CODE, align 1, keep-with-next
418 void macCspTxPrepSlotted(void)
\ macCspTxPrepSlotted:
419 {
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 0
420 cspPrepForTxProgram();
\ 000004 ; Setup parameters for call to function cspPrepForTxProgram
\ 000004 90.... MOV DPTR,#(??cspPrepForTxProgram & 0xffff)
\ 000007 74.. MOV A,#((??cspPrepForTxProgram >> 16) & 0xff)
\ 000009 12.... 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;
\ 00000C 75E1BB MOV 0xe1,#-0x45
428
429 /* just transmit, no CSMA required */
430 RFST = STXON;
\ 00000F 80.. SJMP ??Subroutine0_0
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 */
\ In segment BANKED_CODE, align 1, keep-with-next
468 void macCspTxGoSlotted(void)
\ macCspTxGoSlotted:
469 {
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; 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();
\ 000004 ; Setup parameters for call to function macMcuOrRFIM
\ 000004 7902 MOV R1,#0x2
\ 000006 90.... MOV DPTR,#(macMcuOrRFIM & 0xffff)
\ 000009 74.. MOV A,#((macMcuOrRFIM >> 16) & 0xff)
\ 00000B 12.... LCALL ?BCALL ; Banked call to: DPTR()
480 MAC_MCU_CSP_INT_ENABLE_INTERRUPT();
\ 00000E ; Setup parameters for call to function macMcuOrRFIM
\ 00000E 7901 MOV R1,#0x1
\ 000010 74.. MOV A,#((macMcuOrRFIM >> 16) & 0xff)
\ 000012 12.... LCALL ?BCALL ; Banked call to: DPTR()
481
482 /* critical section needed for timer accesses */
483 HAL_ENTER_CRITICAL_SECTION(s);
\ 000015 A2AF MOV C,0xa8.7
\ 000017 E4 CLR A
\ 000018 92E0 MOV 0xE0 /* A */.0,C
\ 00001A FB MOV R3,A
\ 00001B C2AF CLR 0xa8.7
484
485 /* store lowest byte of backoff count (same as lowest byte of overflow count) */
486 lowByteOfBackoffCount = T2OF0;
\ 00001D E5A1 MOV A,0xa1
\ 00001F FC MOV R4,A
487
488 /*
489 * Compute the number of backoffs until time to strobe transmit. The strobe should
490 * occur one backoff before the SFD pin is expected to go high. So, the forumla for the
491 * countdown value is to determine when the lower bits would rollover and become zero,
492 * and then subtract one.
493 */
494 backoffCountdown = SLOTTED_TX_MAX_BACKOFF_COUNTDOWN - (lowByteOfBackoffCount & SLOTTED_TX_BACKOFF_COUNT_ALIGN_BIT_MASK) - 1;
\ 000020 740F MOV A,#0xf
\ 000022 5C ANL A,R4
\ 000023 FA MOV R2,A
\ 000024 740F MOV A,#0xf
\ 000026 C3 CLR C
\ 000027 9A SUBB A,R2
\ 000028 FA MOV R2,A
495
496 /*
497 * Store backoff countdown value into CSPX.
498 *
499 * Note: it is OK if this value is zero. The WAITX instruction at the top of the
500 * CSP program will immediately continue if CSPX is zero when executed. However,
501 * if the countdown is zero, it means the transmit function was not called early
502 * enough for a properly timed slotted transmit. The transmit will be late.
503 */
504 CSPX = backoffCountdown;
\ 000029 90DF12 MOV DPTR,#-0x20ee
\ 00002C F0 MOVX @DPTR,A
505
506 /*
507 * The receiver will be turned on during CSP execution, guaranteed.
508 * Since it is not possible to update C variables within the CSP,
509 * the new "on" state of the receiver must be set a little early
510 * here before the CSP is started.
511 */
512 MAC_RX_WAS_FORCED_ON();
\ 00002D 7401 MOV A,#0x1
\ 00002F 90.... MOV DPTR,#macRxOnFlag
\ 000032 F0 MOVX @DPTR,A
513
514 /* start the CSP program */
515 CSP_START_PROGRAM();
\ 000033 75E1FE MOV 0xe1,#-0x2
516
517 /*
518 * If the previous stored low byte of the backoff count is no longer equal to
519 * the current value, a rollover has occurred. This means the backoff countdown
520 * stored in CSPX may not be correct.
521 *
522 * In this case, the value of CSPX is reloaded to reflect the correct backoff
523 * countdown value (this is one less than what was just used as a rollover has
524 * occurred). Since it is certain a rollover *just* occurred, there is no danger
525 * of another rollover occurring. This means the value written to CSPX is guaranteed
526 * to be accurate.
527 *
528 * Also, the logic below ensures that the value written to CSPX is at least one.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -