mac_sleep.lst

来自「TI的基于ZIGBEE2006的协议栈」· LST 代码 · 共 532 行 · 第 1/3 页

LST
532
字号
     10              Copyright (c) 2006 by Texas Instruments, Inc.
     11              All Rights Reserved.  Permission to use, reproduce, copy, prepare
     12              derivative works, modify, distribute, perform, display or sell this
     13              software and/or its documentation for any purpose is prohibited
     14              without the express written consent of Texas Instruments, Inc.
     15          **************************************************************************************************/
     16          
     17          
     18          
     19          /* ------------------------------------------------------------------------------------------------
     20           *                                          Includes
     21           * ------------------------------------------------------------------------------------------------
     22           */
     23          
     24          /* hal */
     25          #include "hal_types.h"
     26          
     27          /* exported low-level */
     28          #include "mac_low_level.h"
     29          
     30          /* low-level specific */
     31          #include "mac_sleep.h"
     32          #include "mac_radio.h"
     33          #include "mac_tx.h"
     34          #include "mac_rx.h"
     35          #include "mac_rx_onoff.h"
     36          
     37          /* target specific */
     38          #include "mac_radio_defs.h"

   \                                 In segment SFR_AN, at 0xbe
   \   unsigned char volatile __sfr SLEEP
   \                     SLEEP:
   \   000000                DS 1

   \                                 In segment SFR_AN, at 0xc3
   \   unsigned char volatile __sfr T2CNF
   \                     T2CNF:
   \   000000                DS 1
     39          
     40          /* debug */
     41          #include "mac_assert.h"
     42          
     43          
     44          /* ------------------------------------------------------------------------------------------------
     45           *                                         Global Variables
     46           * ------------------------------------------------------------------------------------------------
     47           */

   \                                 In segment XDATA_I, align 1, keep-with-next
     48          uint8 macSleepState = MAC_SLEEP_STATE_RADIO_OFF;
   \                     macSleepState:
   \   000000                DS 1
   \   000001                REQUIRE `?<Initializer for macSleepState>`
   \   000001                REQUIRE __INIT_XDATA_I
     49          
     50          
     51          /**************************************************************************************************
     52           * @fn          macSleepWakeUp
     53           *
     54           * @brief       Wake up the radio from sleep mode.
     55           *
     56           * @param       none
     57           *
     58           * @return      none
     59           **************************************************************************************************
     60           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
     61          void macSleepWakeUp(void)
   \                     macSleepWakeUp:
     62          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
     63            /* don't wake up radio if it's already awake */
     64            if (macSleepState == MAC_SLEEP_STATE_AWAKE)
   \   000004   90....       MOV     DPTR,#macSleepState
   \   000007   E0           MOVX    A,@DPTR
   \   000008   603D         JZ      ??macSleepWakeUp_0
     65            {
     66              return;
     67            }
     68          
     69            /* wake up MAC timer */
     70            MAC_RADIO_TIMER_WAKE_UP();
   \   00000A   43C301       ORL     0xc3,#0x1
   \                     ??macSleepWakeUp_1:
   \   00000D   E5C3         MOV     A,0xc3
   \   00000F   A2E0         MOV     C,0xE0 /* A   */.0
   \   000011   50FA         JNC     ??macSleepWakeUp_1
     71          
     72            /* if radio was completely off, restore from that state first */
     73            if (macSleepState == MAC_SLEEP_STATE_RADIO_OFF)
   \   000013   E0           MOVX    A,@DPTR
   \   000014   6402         XRL     A,#0x2
   \   000016   7014         JNZ     ??macSleepWakeUp_2
     74            {
     75              /* turn on radio power */
     76              MAC_RADIO_TURN_ON_POWER();
   \   000018   90DF17       MOV     DPTR,#-0x20e9
   \   00001B   E0           MOVX    A,@DPTR
   \   00001C   C2E3         CLR     0xE0 /* A   */.3
   \   00001E   F0           MOVX    @DPTR,A
   \                     ??macSleepWakeUp_3:
   \   00001F   E0           MOVX    A,@DPTR
   \   000020   A2E4         MOV     C,0xE0 /* A   */.4
   \   000022   40FB         JC      ??macSleepWakeUp_3
     77              
     78              /* power-up initialization of receive logic */
     79              macRxRadioPowerUpInit();
   \   000024                ; Setup parameters for call to function macRxRadioPowerUpInit
   \   000024   90....       MOV     DPTR,#(macRxRadioPowerUpInit & 0xffff)
   \   000027   74..         MOV     A,#((macRxRadioPowerUpInit >> 16) & 0xff)
   \   000029   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
     80            }
     81          
     82            /* turn on the oscillator */
     83            MAC_RADIO_TURN_ON_OSC();
   \                     ??macSleepWakeUp_2:
   \   00002C   E5BE         MOV     A,0xbe
   \   00002E   A2E6         MOV     C,0xE0 /* A   */.6
   \   000030   4008         JC      ??macSleepWakeUp_4
   \   000032                ; Setup parameters for call to function halAssertHandler
   \   000032   90....       MOV     DPTR,#(halAssertHandler & 0xffff)
   \   000035   74..         MOV     A,#((halAssertHandler >> 16) & 0xff)
   \   000037   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
     84            
     85            /* update sleep state here before requesting to turn on receiver */
     86            macSleepState = MAC_SLEEP_STATE_AWAKE;
   \                     ??macSleepWakeUp_4:
   \   00003A   E4           CLR     A
   \   00003B   90....       MOV     DPTR,#macSleepState
   \   00003E   F0           MOVX    @DPTR,A
     87          
     88            /* turn on the receiver if enabled */
     89            macRxOnRequest();
   \   00003F                ; Setup parameters for call to function macRxOnRequest
   \   00003F   90....       MOV     DPTR,#(macRxOnRequest & 0xffff)
   \   000042   74..         MOV     A,#((macRxOnRequest >> 16) & 0xff)
   \   000044   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
     90          }
   \                     ??macSleepWakeUp_0:
   \   000047   D083         POP     DPH
   \   000049   D082         POP     DPL
   \   00004B   02....       LJMP    ?BRET
     91          
     92          
     93          /**************************************************************************************************
     94           * @fn          macSleep
     95           *
     96           * @brief       Puts radio into the selected sleep mode.
     97           *
     98           * @param       sleepState - selected sleep level, see #defines in .h file
     99           *
    100           * @return      TRUE if radio was successfully put into selected sleep mode.
    101           *              FALSE if it was not safe for radio to go to sleep.
    102           **************************************************************************************************
    103           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    104          uint8 macSleep(uint8 sleepState)
   \                     macSleep:
    105          {
   \   000000   74F7         MOV     A,#-0x9
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 9
   \   000005                ; Auto size: 0
   \   000005   E9           MOV     A,R1
   \   000006   FE           MOV     R6,A
    106            halIntState_t  s;
    107           
    108            /* disable interrupts until macSleepState can be set */
    109            HAL_ENTER_CRITICAL_SECTION(s);
   \   000007   A2AF         MOV     C,0xa8.7
   \   000009   E4           CLR     A
   \   00000A   92E0         MOV     0xE0 /* A   */.0,C

⌨️ 快捷键说明

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