⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mac_radio.s51

📁 cc2430应用实例
💻 S51
📖 第 1 页 / 共 5 页
字号:
//  147 
//  148 
//  149 /**************************************************************************************************
//  150  * @fn          macRadioSetPanID
//  151  *
//  152  * @brief       Set the pan ID on the radio.
//  153  *
//  154  * @param       panID - 16 bit PAN identifier
//  155  *
//  156  * @return      none
//  157  **************************************************************************************************
//  158  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  159 void macRadioSetPanID(uint16 panID)
macRadioSetPanID:
        CFI Block cfiBlock6 Using cfiCommon0
        CFI Function macRadioSetPanID
//  160 {
        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
//  161   /* abstracted radio configuration */
//  162   MAC_RADIO_SET_PAN_ID(panID);
        MOV	A,R2
        MOV	DPTR,#-0x20b4
        MOVX	@DPTR,A
        MOV	A,R3
        SJMP	?Subroutine2
        CFI EndBlock cfiBlock6
//  163 }
//  164 
//  165 
//  166 /**************************************************************************************************
//  167  * @fn          macRadioSetShortAddr
//  168  *
//  169  * @brief       Set the short addrss on the radio.
//  170  *
//  171  * @param       shortAddr - 16 bit short address
//  172  *
//  173  * @return      none
//  174  **************************************************************************************************
//  175  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  176 void macRadioSetShortAddr(uint16 shortAddr)
macRadioSetShortAddr:
        CFI Block cfiBlock7 Using cfiCommon0
        CFI Function macRadioSetShortAddr
//  177 {
        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
//  178   /* abstracted radio configuration */
//  179   MAC_RADIO_SET_SHORT_ADDR(shortAddr);
        MOV	A,R2
        MOV	DPTR,#-0x20b2
        MOVX	@DPTR,A
        MOV	A,R3
        MOV	DPTR,#-0x20b3
        SJMP	??Subroutine2_0
        CFI EndBlock cfiBlock7
//  180 }
//  181 
//  182 
//  183 /**************************************************************************************************
//  184  * @fn          macRadioSetIEEEAddr
//  185  *
//  186  * @brief       Set the IEEE address on the radio.
//  187  *
//  188  * @param       pIEEEAddr - pointer to array holding 64 bit IEEE address; array must be little
//  189  *                          endian format (starts with lowest signficant byte)
//  190  *
//  191  * @return      none
//  192  **************************************************************************************************
//  193  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  194 void macRadioSetIEEEAddr(uint8 * pIEEEAddr)
macRadioSetIEEEAddr:
        CFI Block cfiBlock8 Using cfiCommon0
        CFI Function macRadioSetIEEEAddr
//  195 {
        FUNCALL macRadioSetIEEEAddr, macMemWriteRam
        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
        MOV	A,R2
        MOV	R4,A
        MOV	A,R3
        MOV	R5,A
//  196   /* abstracted radio configuration */
//  197   MAC_RADIO_SET_IEEE_ADDR(pIEEEAddr);
        ; Setup parameters for call to function macMemWriteRam
        MOV	R1,#0x8
        MOV	R2,#0x43
        MOV	R3,#-0x21
        MOV	DPTR,#(macMemWriteRam & 0xffff)
        MOV	A,#((macMemWriteRam >> 16) & 0xff)
        SJMP	??Subroutine0_0
        CFI EndBlock cfiBlock8
//  198 }
//  199 
//  200 
//  201 /**************************************************************************************************
//  202  * @fn          macRadioSetTxPower
//  203  *
//  204  * @brief       Set transmitter power of the radio.
//  205  *
//  206  * @param       txPower - the minus dBm for power but as a postive integer (or if configured
//  207  *                        for it, txPower is the raw register value).
//  208  *
//  209  * @return      none
//  210  **************************************************************************************************
//  211  */
//  212 #ifndef HAL_MAC_USE_REGISTER_POWER_VALUES
//  213 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//  214 

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  215 void macRadioSetTxPower(uint8 txPower)
macRadioSetTxPower:
        CFI Block cfiBlock9 Using cfiCommon0
        CFI Function macRadioSetTxPower
//  216 {
        FUNCALL macRadioSetTxPower, macRadioUpdateTxPower
        LOCFRAME XSTACK, 10, STACK
        ARGFRAME XSTACK, 10, STACK
        MOV	A,#-0xa
        LCALL	?BANKED_ENTER_XDATA
        CFI DPH0 load(1, XDATA, add(CFA_XSP16, literal(-1)))
        CFI DPL0 load(1, XDATA, add(CFA_XSP16, literal(-2)))
        CFI ?BRET_EXT load(1, XDATA, add(CFA_XSP16, literal(-3)))
        CFI ?RET_HIGH load(1, XDATA, add(CFA_XSP16, literal(-4)))
        CFI ?RET_LOW load(1, XDATA, add(CFA_XSP16, literal(-5)))
        CFI R7 load(1, XDATA, add(CFA_XSP16, literal(-6)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 10)
        ; Saved register size: 10
        ; Auto size: 0
//  217   halIntState_t  s;
//  218 
//  219   /* if the selected dBm is out of range, use the closest available */
//  220   if (txPower > MAC_RADIO_TX_POWER_MAX_MINUS_DBM)
        MOV	A,R1
        CLR	C
        SUBB	A,#0x1a
        JC	??macRadioSetTxPower_0
//  221   {
//  222     txPower = MAC_RADIO_TX_POWER_MAX_MINUS_DBM;
        MOV	R1,#0x19
//  223   }
//  224 
//  225   /*
//  226    *  Set the global variable reqTxPower.  This variable is referenced
//  227    *  by the function macRadioUpdateTxPower() to write the radio register.
//  228    *
//  229    *  A lookup table is used to translate the power level to the register
//  230    *  value.
//  231    */
//  232   HAL_ENTER_CRITICAL_SECTION(s);
??macRadioSetTxPower_0:
        MOV	C,0xa8.7
        CLR	A
        MOV	0xE0 /* A   */.0,C
        MOV	R2,A
        CLR	0xa8.7
//  233   reqTxPower = macRadioDefsTxPowerTable[txPower];
        MOV	?V0 + 0,R1
        MOV	A,?V0 + 0
        ADD	A,#(macRadioDefsTxPowerTable & 0xff)
        MOV	DPL,A
        CLR	A
        ADDC	A,#((macRadioDefsTxPowerTable >> 8) & 0xff)
        MOV	DPH,A
        CLR	A
        MOVC	A,@A+DPTR
        MOV	DPTR,#??reqTxPower
        MOVX	@DPTR,A
//  234   HAL_EXIT_CRITICAL_SECTION(s);
        MOV	A,R2
        MOV	C,0xE0 /* A   */.0
        MOV	0xa8.7,C
//  235 
//  236   /* update the radio power setting */
//  237   macRadioUpdateTxPower();
        ; Setup parameters for call to function macRadioUpdateTxPower
        MOV	DPTR,#(macRadioUpdateTxPower & 0xffff)
        MOV	A,#((macRadioUpdateTxPower >> 16) & 0xff)
        LCALL	?BCALL               ; Banked call to: DPTR()
//  238 }
        MOV	R7,#0x2
        LJMP	?BANKED_LEAVE_XDATA
        CFI EndBlock cfiBlock9
//  239 
//  240 #else
//  241 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
//  242 
//  243 void macRadioSetTxPower(uint8 txPower)
//  244 {
//  245   halIntState_t  s;
//  246 
//  247   /* same as above but with no lookup table, use raw register value */
//  248   HAL_ENTER_CRITICAL_SECTION(s);
//  249   reqTxPower = txPower;
//  250   HAL_EXIT_CRITICAL_SECTION(s);
//  251 
//  252   /* update the radio power setting */
//  253   macRadioUpdateTxPower();
//  254 }
//  255 
//  256 #endif
//  257 
//  258 
//  259 /**************************************************************************************************
//  260  * @fn          macRadioUpdateTxPower
//  261  *
//  262  * @brief       Update the radio's transmit power if a new power level has been requested
//  263  *
//  264  * @param       reqTxPower - file scope variable that holds the last request power level
//  265  *              macPhyTxPower - global variable that holds radio's set power level
//  266  *
//  267  * @return      none
//  268  **************************************************************************************************
//  269  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  270 void macRadioUpdateTxPower(void)
macRadioUpdateTxPower:
        CFI Block cfiBlock10 Using cfiCommon0
        CFI Function macRadioUpdateTxPower
//  271 {
        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
//  272   halIntState_t  s;
//  273 
//  274   /*
//  275    *  If the requested power setting is different from the actual radio setting,
//  276    *  attempt to udpate to the new power setting.
//  277    */
//  278   HAL_ENTER_CRITICAL_SECTION(s);
        MOV	C,0xa8.7
        CLR	A
        MOV	0xE0 /* A   */.0,C
        MOV	R3,A
        CLR	0xa8.7
//  279   if (reqTxPower != macPhyTxPower)
        MOV	DPTR,#??reqTxPower
        MOVX	A,@DPTR
        MOV	R2,A
        MOV	DPTR,#macPhyTxPower
        MOVX	A,@DPTR
        XRL	A,R2
        JZ	??macRadioUpdateTxPower_0
//  280   {
//  281     /*
//  282      *  Radio power cannot be updated when the radio is physically transmitting.
//  283      *  If there is a possibility radio is transmitting, do not change the power
//  284      *  setting.  This function will be called again after the current transmit
//  285      *  completes.
//  286      */
//  287     if (!macRxOutgoingAckFlag && !MAC_TX_IS_PHYSICALLY_ACTIVE())
        MOV	DPTR,#macRxOutgoingAckFlag
        MOVX	A,@DPTR
        JNZ	??macRadioUpdateTxPower_0
        MOV	DPTR,#macTxActive
        MOVX	A,@DPTR
        MOV	C,0xE0 /* A   */.7
        JC	??macRadioUpdateTxPower_0
//  288     {
//  289       /*
//  290        *  Set new power level;  update the shadow value and write
//  291        *  the new value to the radio hardware.
//  292        */
//  293       macPhyTxPower = reqTxPower;
        MOV	DPTR,#??reqTxPower
        MOVX	A,@DPTR
        MOV	DPTR,#macPhyTxPower
        MOVX	@DPTR,A
//  294       MAC_RADIO_SET_TX_POWER(macPhyTxPower);
        MOV	DPTR,#-0x20f5
        MOVX	@DPTR,A
//  295     }
//  296   }
//  297   HAL_EXIT_CRITICAL_SECTION(s);
??macRadioUpdateTxPower_0:
        MOV	A,R3
        MOV	C,0xE0 /* A   */.0
        MOV	0xa8.7,C
//  298 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -