📄 mac_radio.s51
字号:
MOV DPTR,#(halAssertHandler & 0xffff)
MOV A,#((halAssertHandler >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 398 macRxFilter = RX_FILTER_NON_BEACON_FRAMES;
??macRadioStartScan_6:
MOV A,#0x2
MOV DPTR,#macRxFilter
MOVX @DPTR,A
// 399
// 400 /* for active and passive scans, per spec the pan ID must be 0xFFFF */
// 401 MAC_RADIO_SET_PAN_ID(0xFFFF);
MOV A,#-0x1
MOV DPTR,#-0x20b4
MOVX @DPTR,A
MOV DPTR,#-0x20b5
??macRadioStartScan_4:
MOVX @DPTR,A
// 402 }
// 403 }
LJMP ?Subroutine1 & 0xFFFF
CFI EndBlock cfiBlock14
// 404
// 405
// 406 /**************************************************************************************************
// 407 * @fn macRadioStopScan
// 408 *
// 409 * @brief Takes radio out of scan mode. Note can be called if
// 410 *
// 411 * @param none
// 412 *
// 413 * @return none
// 414 **************************************************************************************************
// 415 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 416 void macRadioStopScan(void)
macRadioStopScan:
CFI Block cfiBlock15 Using cfiCommon0
CFI Function macRadioStopScan
// 417 {
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
// 418 macRxFilter = RX_FILTER_OFF;
CLR A
MOV DPTR,#macRxFilter
MOVX @DPTR,A
// 419
// 420 /* restore the pan ID (passive and active scans set pan ID to 0xFFFF) */
// 421 MAC_RADIO_SET_PAN_ID(macPib.panId);
MOV DPTR,#(macPib + 29)
MOVX A,@DPTR
MOV DPTR,#-0x20b4
MOVX @DPTR,A
MOV DPTR,#(macPib + 30)
MOVX A,@DPTR
LJMP ?Subroutine2 & 0xFFFF
CFI EndBlock cfiBlock15
// 422 }
// 423
// 424
// 425 /**************************************************************************************************
// 426 * @fn macRadioEnergyDetectStart
// 427 *
// 428 * @brief Initiates energy detect. The highest energy detected is recorded from the time
// 429 * when this function is called until the energy detect is stopped.
// 430 *
// 431 * @param none
// 432 *
// 433 * @return none
// 434 **************************************************************************************************
// 435 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 436 void macRadioEnergyDetectStart(void)
macRadioEnergyDetectStart:
CFI Block cfiBlock16 Using cfiCommon0
CFI Function macRadioEnergyDetectStart
// 437 {
FUNCALL macRadioEnergyDetectStart, macMcuRecordMaxRssiStart
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
// 438 MAC_RADIO_RECORD_MAX_RSSI_START();
; Setup parameters for call to function macMcuRecordMaxRssiStart
MOV DPTR,#(macMcuRecordMaxRssiStart & 0xffff)
MOV A,#((macMcuRecordMaxRssiStart >> 16) & 0xff)
LJMP ??Subroutine0_0 & 0xFFFF
CFI EndBlock cfiBlock16
// 439 }
// 440
// 441
// 442 /**************************************************************************************************
// 443 * @fn macRadioEnergyDetectStop
// 444 *
// 445 * @brief Called at completion of an energy detect. Note: can be called even if energy
// 446 * detect is already stopped (needed by reset).
// 447 *
// 448 * @param none
// 449 *
// 450 * @return highest energy detect measurement
// 451 **************************************************************************************************
// 452 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 453 uint8 macRadioEnergyDetectStop(void)
macRadioEnergyDetectStop:
CFI Block cfiBlock17 Using cfiCommon0
CFI Function macRadioEnergyDetectStop
// 454 {
FUNCALL macRadioEnergyDetectStop, macMcuRecordMaxRssiStop
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
FUNCALL macRadioEnergyDetectStop, ??radioComputeED
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
// 455 uint8 rssiDbm;
// 456 uint8 energyDetectMeasurement;
// 457
// 458 rssiDbm = MAC_RADIO_RECORD_MAX_RSSI_STOP() + MAC_RADIO_RSSI_OFFSET;
; Setup parameters for call to function macMcuRecordMaxRssiStop
MOV DPTR,#(macMcuRecordMaxRssiStop & 0xffff)
MOV A,#((macMcuRecordMaxRssiStop >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
MOV A,R1
ADD A,#-0x2d
MOV R1,A
// 459 energyDetectMeasurement = radioComputeED(rssiDbm);
// 460
// 461 return(energyDetectMeasurement);
; Setup parameters for call to function radioComputeED
LJMP ?Subroutine0 & 0xFFFF
CFI EndBlock cfiBlock17
// 462 }
// 463
// 464 /*=================================================================================================
// 465 * @fn radioComputeED
// 466 *
// 467 * @brief Compute energy detect measurement.
// 468 *
// 469 * @param rssi - raw RSSI value from radio hardware
// 470 *
// 471 * @return energy detect measurement in the range of 0x00-0xFF
// 472 *=================================================================================================
// 473 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 474 static uint8 radioComputeED(int8 rssiDbm)
??radioComputeED:
CFI Block cfiBlock18 Using cfiCommon0
CFI Function ??radioComputeED
// 475 {
; Saved register size: 0
; Auto size: 0
// 476 uint8 ed;
// 477
// 478 /*
// 479 * Keep RF power between minimum and maximum values.
// 480 * This min/max range is derived from datasheet and specification.
// 481 */
// 482 if (rssiDbm < ED_RF_POWER_MIN_DBM)
MOV A,R1
CLR C
SUBB A,#-0x51
MOV C,0xD0 /* PSW */.2
XRL A,PSW
RLC A
JNC ??radioComputeED_1
// 483 {
// 484 rssiDbm = ED_RF_POWER_MIN_DBM;
MOV R1,#-0x51
SJMP ??radioComputeED_2
// 485 }
// 486 else if (rssiDbm > ED_RF_POWER_MAX_DBM)
??radioComputeED_1:
MOV A,R1
CLR C
SUBB A,#0xb
MOV C,0xD0 /* PSW */.2
XRL A,PSW
RLC A
JC ??radioComputeED_2
// 487 {
// 488 rssiDbm = ED_RF_POWER_MAX_DBM;
MOV R1,#0xa
// 489 }
// 490
// 491 /*
// 492 * Create energy detect measurement by normalizing and scaling RF power level.
// 493 *
// 494 * Note : The division operation below is designed for maximum accuracy and
// 495 * best granularity. This is done by grouping the math operations to
// 496 * compute the entire numerator before doing any division.
// 497 */
// 498 ed = (MAC_SPEC_ED_MAX * (rssiDbm - ED_RF_POWER_MIN_DBM)) / (ED_RF_POWER_MAX_DBM - ED_RF_POWER_MIN_DBM);
// 499
// 500 return(ed);
??radioComputeED_2:
MOV A,R1
MOV R0,A
RLC A
SUBB A,0xE0 /* A */
MOV R1,A
MOV A,#0x51
ADD A,R0
MOV R0,A
CLR A
ADDC A,R1
MOV R1,A
MOV A,R0
MOV B,#-0x1
MUL AB
MOV R0,A
MOV R2,B
MOV B,#-0x1
MOV A,R1
MUL AB
ADD A,R2
MOV R1,A
MOV R2,#0x5b
MOV R3,#0x0
LCALL ?S_DIV_MOD
MOV A,R0
MOV R1,A
LJMP ?BRET
CFI EndBlock cfiBlock18
// 501 }
// 502
// 503
// 504 /**************************************************************************************************
// 505 * @fn macRadioComputeLQI
// 506 *
// 507 * @brief Compute link quality indication.
// 508 *
// 509 * @param rssi - raw RSSI value from radio hardware
// 510 * corr - correlation value from radio hardware
// 511 *
// 512 * @return link quality indicator value
// 513 **************************************************************************************************
// 514 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 515 uint8 macRadioComputeLQI(int8 rssiDbm, uint8 corr)
macRadioComputeLQI:
CFI Block cfiBlock19 Using cfiCommon0
CFI Function macRadioComputeLQI
// 516 {
FUNCALL macRadioComputeLQI, ??radioComputeED
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
// 517 (void) corr; /* suppress compiler warning of unused parameter */
// 518
// 519 /*
// 520 * Note : Currently the LQI value is simply the energy detect measurement.
// 521 * A more accurate value could be derived by using the correlation
// 522 * value along with the RSSI value.
// 523 */
// 524 return(radioComputeED(rssiDbm));
; Setup parameters for call to function radioComputeED
LJMP ?Subroutine0 & 0xFFFF
CFI EndBlock cfiBlock19
// 525 }
ASEGN SFR_AN:DATA:NOROOT,0a8H
// union <unnamed> volatile __sfr _A_IEN0
_A_IEN0:
DS 1
END
// 526
// 527
// 528 /**************************************************************************************************
// 529 */
//
// 643 bytes in segment BANKED_CODE
// 1 byte in segment SFR_AN
// 4 bytes in segment XDATA_Z
//
// 643 bytes of CODE memory
// 0 bytes of DATA memory (+ 1 byte shared)
// 4 bytes of XDATA memory
//
//Errors: none
//Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -