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

📄 genericapp.lst

📁 cc2430应用实例
💻 LST
📖 第 1 页 / 共 4 页
字号:
    107          /*********************************************************************
    108           * LOCAL VARIABLES
    109           */

   \                                 In segment XDATA_Z, align 1, keep-with-next
   \   000000                REQUIRE __INIT_XDATA_Z
    110          byte GenericApp_TaskID;   // Task ID for internal task/event processing
   \                     GenericApp_TaskID:
   \   000000                DS 1
    111                                    // This variable will be received when
    112                                    // GenericApp_Init() is called.

   \                                 In segment XDATA_Z, align 1, keep-with-next
   \   000000                REQUIRE __INIT_XDATA_Z
    113          devStates_t GenericApp_NwkState;
   \                     GenericApp_NwkState:
   \   000000                DS 1
    114          
    115          

   \                                 In segment XDATA_Z, align 1, keep-with-next
   \   000000                REQUIRE __INIT_XDATA_Z
    116          byte GenericApp_TransID;  // This is the unique message ID (counter)
   \                     GenericApp_TransID:
   \   000000                DS 1
    117          

   \                                 In segment XDATA_Z, align 1, keep-with-next
   \   000000                REQUIRE __INIT_XDATA_Z
    118          afAddrType_t GenericApp_DstAddr;
   \                     GenericApp_DstAddr:
   \   000000                DS 4
    119          
    120          /*********************************************************************
    121           * LOCAL FUNCTIONS
    122           */
    123          void GenericApp_HandleKeys( byte shift, byte keys );
    124          void GenericApp_MessageMSGCB( afIncomingMSGPacket_t *pckt );
    125          void GenericApp_SendTheMessage( void );
    126          
    127          /*********************************************************************
    128           * NETWORK LAYER CALLBACKS
    129           */
    130          
    131          /*********************************************************************
    132           * PUBLIC FUNCTIONS
    133           */
    134          
    135          /*********************************************************************
    136           * @fn      GenericApp_Init
    137           *
    138           * @brief   Initialization function for the Generic App Task.
    139           *          This is called during initialization and should contain
    140           *          any application specific initialization (ie. hardware
    141           *          initialization/setup, table initialization, power up
    142           *          notificaiton ... ).
    143           *
    144           * @param   task_id - the ID assigned by OSAL.  This ID should be
    145           *                    used to send messages and set timers.
    146           *
    147           * @return  none
    148           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    149          void GenericApp_Init( byte task_id )
   \                     GenericApp_Init:
    150          {
   \   000000   C082         PUSH    DPL
   \   000002   C083         PUSH    DPH
   \   000004                ; Saved register size: 2
   \   000004                ; Auto size: 0
    151            GenericApp_TaskID = task_id;
   \   000004   E9           MOV     A,R1
   \   000005   90....       MOV     DPTR,#GenericApp_TaskID
   \   000008   F0           MOVX    @DPTR,A
    152            GenericApp_NwkState = DEV_INIT;
   \   000009   7401         MOV     A,#0x1
   \   00000B   90....       MOV     DPTR,#GenericApp_NwkState
   \   00000E   F0           MOVX    @DPTR,A
    153            GenericApp_TransID = 0;
   \   00000F   E4           CLR     A
   \   000010   90....       MOV     DPTR,#GenericApp_TransID
   \   000013   F0           MOVX    @DPTR,A
    154          
    155            // Device hardware initialization can be added here or in main() (Zmain.c).
    156            // If the hardware is application specific - add it here.
    157            // If the hardware is other parts of the device add it in main().
    158          
    159            GenericApp_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
   \   000014   90....       MOV     DPTR,#(GenericApp_DstAddr + 2)
   \   000017   F0           MOVX    @DPTR,A
    160            GenericApp_DstAddr.endPoint = 0;
   \   000018   90....       MOV     DPTR,#(GenericApp_DstAddr + 3)
   \   00001B   F0           MOVX    @DPTR,A
    161            GenericApp_DstAddr.addr.shortAddr = 0;
   \   00001C   90....       MOV     DPTR,#GenericApp_DstAddr
   \   00001F   F0           MOVX    @DPTR,A
   \   000020   A3           INC     DPTR
   \   000021   F0           MOVX    @DPTR,A
    162          
    163            // Fill out the endpoint description.
    164            GenericApp_epDesc.endPoint = GENERICAPP_ENDPOINT;
   \   000022   740A         MOV     A,#0xa
   \   000024   90....       MOV     DPTR,#GenericApp_epDesc
   \   000027   F0           MOVX    @DPTR,A
    165            GenericApp_epDesc.task_id = &GenericApp_TaskID;
   \   000028   90....       MOV     DPTR,#(GenericApp_epDesc + 1)
   \   00002B   74..         MOV     A,#(GenericApp_TaskID & 0xff)
   \   00002D   F0           MOVX    @DPTR,A
   \   00002E   A3           INC     DPTR
   \   00002F   74..         MOV     A,#((GenericApp_TaskID >> 8) & 0xff)
   \   000031   F0           MOVX    @DPTR,A
    166            GenericApp_epDesc.simpleDesc
    167                      = (SimpleDescriptionFormat_t *)&GenericApp_SimpleDesc;
   \   000032   90....       MOV     DPTR,#(GenericApp_epDesc + 3)
   \   000035   74..         MOV     A,#(GenericApp_SimpleDesc & 0xff)
   \   000037   F0           MOVX    @DPTR,A
   \   000038   A3           INC     DPTR
   \   000039   74..         MOV     A,#((GenericApp_SimpleDesc >> 8) & 0xff)
   \   00003B   F0           MOVX    @DPTR,A
    168            GenericApp_epDesc.latencyReq = noLatencyReqs;
   \   00003C   E4           CLR     A
   \   00003D   90....       MOV     DPTR,#(GenericApp_epDesc + 5)
   \   000040   F0           MOVX    @DPTR,A
    169          
    170            // Register the endpoint description with the AF
    171            afRegister( &GenericApp_epDesc );
   \   000041                ; Setup parameters for call to function afRegister
   \   000041   7A..         MOV     R2,#(GenericApp_epDesc & 0xff)
   \   000043   7B..         MOV     R3,#((GenericApp_epDesc >> 8) & 0xff)
   \   000045   90....       MOV     DPTR,#(afRegister & 0xffff)
   \   000048   74..         MOV     A,#((afRegister >> 16) & 0xff)
   \   00004A   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    172          
    173            // Register for all key events - This app will handle all key events
    174            RegisterForKeys( GenericApp_TaskID );
   \   00004D                ; Setup parameters for call to function RegisterForKeys
   \   00004D   90....       MOV     DPTR,#GenericApp_TaskID
   \   000050   E0           MOVX    A,@DPTR
   \   000051   F9           MOV     R1,A
   \   000052   90....       MOV     DPTR,#(RegisterForKeys & 0xffff)
   \   000055   74..         MOV     A,#((RegisterForKeys >> 16) & 0xff)
   \   000057   12....       LCALL   ?BCALL               ; Banked call to: DPTR()
    175          
    176            // Update the display
    177          #if defined ( LCD_SUPPORTED )
    178              HalLcdWriteString( "GenericApp", HAL_LCD_LINE_1 );
    179          #endif
    180          }
   \   00005A   D083         POP     DPH
   \   00005C   D082         POP     DPL
   \   00005E   02....       LJMP    ?BRET
    181          
    182          /*********************************************************************
    183           * @fn      GenericApp_ProcessEvent
    184           *
    185           * @brief   Generic Application Task event processor.  This function
    186           *          is called to process all events for the task.  Events
    187           *          include timers, messages and any other user defined events.
    188           *
    189           * @param   task_id  - The OSAL assigned task ID.
    190           * @param   events - events to process.  This is a bit map and can
    191           *                   contain more than one event.
    192           *
    193           * @return  none
    194           */

   \                                 In segment BANKED_CODE, align 1, keep-with-next
    195          UINT16 GenericApp_ProcessEvent( byte task_id, UINT16 events )
   \                     GenericApp_ProcessEvent:
    196          {
   \   000000   74F4         MOV     A,#-0xc
   \   000002   12....       LCALL   ?BANKED_ENTER_XDATA
   \   000005                ; Saved register size: 12
   \   000005                ; Auto size: 0
   \   000005   EA           MOV     A,R2
   \   000006   FE           MOV     R6,A
   \   000007   EB           MOV     A,R3
   \   000008   FF           MOV     R7,A
    197            afIncomingMSGPacket_t *MSGpkt;
    198            afDataConfirm_t *afDataConfirm;
    199            ZDO_NewDstAddr_t *ZDO_NewDstAddr;
    200            byte dstEP;
    201            zAddrType_t *dstAddr;
    202          
    203            // Data Confirmation message fields
    204            byte sentEP;
    205            ZStatus_t sentStatus;
    206            byte sentTransID;       // This should match the value sent
    207          
    208            if ( events & SYS_EVENT_MSG )
   \   000009   7480         MOV     A,#-0x80
   \   00000B   5F           ANL     A,R7
   \   00000C   F9           MOV     R1,A
   \   00000D   E4           CLR     A
   \   00000E   7001         JNZ     ??GenericApp_ProcessEvent_0
   \   000010   E9           MOV     A,R1
   \                     ??GenericApp_ProcessEvent_0:
   \   000011   7003         JNZ     $+5
   \   000013   02....       LJMP    ??GenericApp_ProcessEvent_1 & 0xFFFF
    209            {
    210              MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( GenericApp_TaskID );
   \   000016                ; Setup parameters for call to function osal_msg_receive
   \   000016   8036         SJMP    ??GenericApp_ProcessEvent_2
    211              while ( MSGpkt )
    212              {
    213                switch ( MSGpkt->hdr.event )
    214                {
    215                  case KEY_CHANGE:
    216                    GenericApp_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
    217                    break;
    218          
    219                  case AF_DATA_CONFIRM_CMD:
    220                    // This message is received as a confirmation of a data packet sent.
    221                    // The status is of ZStatus_t type [defined in ZComDef.h]
    222                    // The message fields are defined in AF.h
    223                    afDataConfirm = (afDataConfirm_t *)MSGpkt;
    224                    sentEP = afDataConfirm->endpoint;
    225                    sentStatus = afDataConfirm->hdr.status;
    226                    sentTransID = afDataConfirm->transID;
    227                    (void)sentEP;
    228                    (void)sentTransID;
    229          
    230                    // Action taken when confirmation is received.
    231                    if ( sentStatus != ZSuccess )
    232                    {
    233                      // The data wasn't delivered -- Do something
    234                    }
    235                    break;
    236          
    237                  case AF_INCOMING_MSG_CMD:
    238                    GenericApp_MessageMSGCB( MSGpkt );
    239                    break;
    240          
    241                  case ZDO_NEW_DSTADDR:
    242                    ZDO_NewDstAddr = (ZDO_NewDstAddr_t *)MSGpkt;
    243          
    244                    dstEP = ZDO_NewDstAddr->dstAddrDstEP;
    245                    dstAddr = &ZDO_NewDstAddr->dstAddr;
    246                    GenericApp_DstAddr.addrMode = (afAddrMode_t)dstAddr->addrMode;
    247                    GenericApp_DstAddr.endPoint = dstEP;
    248          
    249                    GenericApp_DstAddr.addr.shortAddr = dstAddr->addr.shortAddr;
    250                    break;
    251          
    252                  case ZDO_STATE_CHANGE:
    253                    GenericApp_NwkState = (devStates_t)(MSGpkt->hdr.status);
   \                     ??GenericApp_ProcessEvent_3:
   \   000018   85..82       MOV     DPL,?V0 + 0
   \   00001B   85..83       MOV     DPH,?V0 + 1
   \   00001E   A3           INC     DPTR
   \   00001F   E0           MOVX    A,@DPTR
   \   000020   90....       MOV     DPTR,#GenericApp_NwkState
   \   000023   F0           MOVX    @DPTR,A
    254                    if ( (GenericApp_NwkState == DEV_ZB_COORD)
    255                        || (GenericApp_NwkState == DEV_ROUTER)

⌨️ 快捷键说明

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