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

📄 sampleapp.s51

📁 cc2430讀取短地址程式
💻 S51
📖 第 1 页 / 共 4 页
字号:
        FUNCTION afRegister,0202H
        ARGFRAME XSTACK, 11, STACK
        EXTERN RegisterForKeys
        FUNCTION RegisterForKeys,0202H
        ARGFRAME XSTACK, 11, STACK
        EXTERN osal_memcpy
        FUNCTION osal_memcpy,0202H
        ARGFRAME XSTACK, 14, STACK
        EXTERN aps_AddGroup
        FUNCTION aps_AddGroup,0202H
        ARGFRAME XSTACK, 11, STACK
        EXTERN osal_msg_receive
        FUNCTION osal_msg_receive,0202H
        ARGFRAME XSTACK, 12, STACK
        EXTERN osal_start_timerEx
        FUNCTION osal_start_timerEx,0202H
        ARGFRAME XSTACK, 12, STACK
        EXTERN osal_msg_deallocate
        FUNCTION osal_msg_deallocate,0202H
        ARGFRAME XSTACK, 12, STACK
        EXTERN osal_rand
        FUNCTION osal_rand,0202H
        ARGFRAME XSTACK, 12, STACK
        EXTERN aps_FindGroup
        FUNCTION aps_FindGroup,0202H
        ARGFRAME XSTACK, 10, STACK
        EXTERN aps_RemoveGroup
        FUNCTION aps_RemoveGroup,0202H
        ARGFRAME XSTACK, 10, STACK
        EXTERN AF_DataRequest
        FUNCTION AF_DataRequest,0202H
        ARGFRAME XSTACK, 23, STACK
        EXTERN memcpy
        FUNCTION memcpy,010202H
        ARGFRAME XSTACK, 22, STACK
        EXTERN NLME_GetShortAddr
        FUNCTION NLME_GetShortAddr,0202H
        ARGFRAME XSTACK, 20, STACK
        EXTERN HalUARTWrite
        FUNCTION HalUARTWrite,0202H
        ARGFRAME XSTACK, 20, STACK


        RSEG XDATA_I:XDATA:NOROOT(0)
`?<Constant "Group 1">`:
        DS 8
        REQUIRE `?<Initializer for <Constant "Group 1">>`
        REQUIRE __INIT_XDATA_I
// C:\Texas Instruments\ZStack-1.4.2\Projects\zstack\Samples\SampleApp\Source\SampleApp.c
//    1 /*********************************************************************
//    2   Filename:       SampleApp.c
//    3   Revised:        $Date: 2007-05-31 15:56:04 -0700 (Thu, 31 May 2007) $
//    4   Revision:       $Revision: 14490 $
//    5 
//    6   Description:
//    7 				  - Sample Application (no Profile).
//    8 				
//    9           This application isn't intended to do anything useful,
//   10           it is intended to be a simple example of an application's
//   11           structure.
//   12 
//   13           This application sends it's messages either as broadcast or
//   14           broadcast filtered group messages.  The other (more normal)
//   15           message addressing is unicast.  Most of the other
//   16           sample applications are written to support the unicast
//   17           message model.
//   18 
//   19           Key control:
//   20             SW1:  Sends a flash command to all devices in Group 1.
//   21             SW2:  Adds/Removes (toggles) this device in and out
//   22                   of Group 1.  This will enable and disable the
//   23                   reception of the flash command.
//   24 
//   25   Notes:
//   26 
//   27   Copyright (c) 2007 by Texas Instruments, Inc.
//   28   All Rights Reserved.  Permission to use, reproduce, copy, prepare
//   29   derivative works, modify, distribute, perform, display or sell this
//   30   software and/or its documentation for any purpose is prohibited
//   31   without the express written consent of Texas Instruments, Inc.
//   32 *********************************************************************/
//   33 
//   34 /*********************************************************************
//   35  * INCLUDES
//   36  */
//   37 #include "OSAL.h"
//   38 #include "ZGlobals.h"
//   39 #include "AF.h"
//   40 #include "aps_groups.h"
//   41 #include "ZDApp.h"
//   42 #include "NLMEDE.h"
//   43 #include "SampleApp.h"
//   44 #include "SampleAppHw.h"
//   45 #include "ioCC2430.h"
//   46 #include "OnBoard.h"
//   47 #include "string.h"
//   48 #include "SPIMgr.h"
//   49 /* HAL */
//   50 #include "hal_lcd.h"
//   51 #include "hal_led.h"
//   52 #include "hal_key.h"
//   53 #include "hal_adc.h"
//   54 #include "hal_adc.h"
//   55 
//   56 /* temperture */
//   57 #include "Temp.h"
//   58 
//   59 #define UINT8 unsigned char
//   60 UINT8 SendData(UINT8 *buf, UINT16 addr, UINT8 Leng);
//   61 
//   62 #define OPENLED(y,x) {P##y##SEL&= ~(1<<x);P##y##DIR |=1<<x ;P##y&=~(1<<x);}
//   63 #define CLOSELED(y,x) {P##y##SEL&= ~(1<<x);P##y##DIR |=1<<x;P##y|=(1<<x);}
//   64 /*********************************************************************
//   65  * MACROS
//   66  */
//   67 
//   68 /*********************************************************************
//   69  * CONSTANTS
//   70  */
//   71 
//   72 /*********************************************************************
//   73  * TYPEDEFS
//   74  */
//   75 
//   76 /*********************************************************************
//   77  * GLOBAL VARIABLES
//   78  */
//   79 
//   80 // This list should be filled with Application specific Cluster IDs.

        RSEG XDATA_I:XDATA:NOROOT(0)
//   81 const cId_t SampleApp_ClusterList[SAMPLEAPP_MAX_CLUSTERS] =
SampleApp_ClusterList:
        DS 4
        REQUIRE `?<Initializer for SampleApp_ClusterList>`
        REQUIRE __INIT_XDATA_I
//   82 {
//   83   SAMPLEAPP_PERIODIC_CLUSTERID,
//   84   SAMPLEAPP_FLASH_CLUSTERID
//   85 };
//   86 

        RSEG XDATA_I:XDATA:NOROOT(0)
//   87 const SimpleDescriptionFormat_t SampleApp_SimpleDesc =
SampleApp_SimpleDesc:
        DS 12
        REQUIRE `?<Initializer for SampleApp_SimpleDesc>`
        REQUIRE __INIT_XDATA_I
//   88 {
//   89   SAMPLEAPP_ENDPOINT,              //  int Endpoint;
//   90   SAMPLEAPP_PROFID,                //  uint16 AppProfId[2];
//   91   SAMPLEAPP_DEVICEID,              //  uint16 AppDeviceId[2];
//   92   SAMPLEAPP_DEVICE_VERSION,        //  int   AppDevVer:4;
//   93   SAMPLEAPP_FLAGS,                 //  int   AppFlags:4;
//   94   SAMPLEAPP_MAX_CLUSTERS,          //  uint8  AppNumInClusters;
//   95   (cId_t *)SampleApp_ClusterList,  //  uint8 *pAppInClusterList;
//   96   SAMPLEAPP_MAX_CLUSTERS,          //  uint8  AppNumInClusters;
//   97   (cId_t *)SampleApp_ClusterList   //  uint8 *pAppInClusterList;
//   98 };
//   99 
//  100 // This is the Endpoint/Interface description.  It is defined here, but
//  101 // filled-in in SampleApp_Init().  Another way to go would be to fill
//  102 // in the structure here and make it a "const" (in code space).  The
//  103 // way it's defined in this sample app it is define in RAM.

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  104 endPointDesc_t SampleApp_epDesc;
SampleApp_epDesc:
        DS 6
//  105 
//  106 /*********************************************************************
//  107  * EXTERNAL VARIABLES
//  108  */
//  109 
//  110 /*********************************************************************
//  111  * EXTERNAL FUNCTIONS
//  112  */
//  113 
//  114 /*********************************************************************
//  115  * LOCAL VARIABLES
//  116  */

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  117 uint8 SampleApp_TaskID;   // Task ID for internal task/event processing
SampleApp_TaskID:
        DS 1
//  118                           // This variable will be received when
//  119                           // SampleApp_Init() is called.

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  120 devStates_t SampleApp_NwkState;
SampleApp_NwkState:
        DS 1
//  121 

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  122 uint8 SampleApp_TransID;  // This is the unique message ID (counter)
SampleApp_TransID:
        DS 1
//  123 

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  124 afAddrType_t SampleApp_Periodic_DstAddr;
SampleApp_Periodic_DstAddr:
        DS 4

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  125 afAddrType_t SampleApp_Flash_DstAddr;
SampleApp_Flash_DstAddr:
        DS 4
//  126 

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  127 aps_Group_t SampleApp_Group;
SampleApp_Group:
        DS 18
//  128 

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  129 uint8 SampleAppPeriodicCounter = 0;
SampleAppPeriodicCounter:
        DS 1

        RSEG XDATA_Z:XDATA:NOROOT(0)
        REQUIRE __INIT_XDATA_Z
//  130 uint8 SampleAppFlashCounter = 0;
SampleAppFlashCounter:
        DS 1
//  131 
//  132 /*********************************************************************
//  133  * LOCAL FUNCTIONS
//  134  */
//  135 void SampleApp_HandleKeys( uint8 shift, uint8 keys );
//  136 void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pckt );
//  137 void SampleApp_SendPeriodicMessage( void );
//  138 void SampleApp_SendFlashMessage( uint16 flashTime );
//  139 
//  140 /*********************************************************************
//  141  * NETWORK LAYER CALLBACKS
//  142  */
//  143 
//  144 /*********************************************************************
//  145  * PUBLIC FUNCTIONS
//  146  */
//  147 
//  148 /*********************************************************************
//  149  * @fn      SampleApp_Init
//  150  *
//  151  * @brief   Initialization function for the Generic App Task.
//  152  *          This is called during initialization and should contain
//  153  *          any application specific initialization (ie. hardware
//  154  *          initialization/setup, table initialization, power up
//  155  *          notificaiton ... ).
//  156  *
//  157  * @param   task_id - the ID assigned by OSAL.  This ID should be
//  158  *                    used to send messages and set timers.
//  159  *
//  160  * @return  none
//  161  */

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  162 void SampleApp_Init( uint8 task_id )
SampleApp_Init:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function SampleApp_Init
//  163 {
        FUNCALL SampleApp_Init, afRegister
        LOCFRAME XSTACK, 11, STACK
        ARGFRAME XSTACK, 11, STACK
        FUNCALL SampleApp_Init, RegisterForKeys
        LOCFRAME XSTACK, 11, STACK
        ARGFRAME XSTACK, 11, STACK
        FUNCALL SampleApp_Init, osal_memcpy
        LOCFRAME XSTACK, 14, STACK
        ARGFRAME XSTACK, 14, STACK
        FUNCALL SampleApp_Init, aps_AddGroup
        LOCFRAME XSTACK, 11, STACK
        ARGFRAME XSTACK, 11, STACK
        MOV	A,#-0xb
        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 V2 load(1, XDATA, add(CFA_XSP16, literal(-7)))
        CFI V1 load(1, XDATA, add(CFA_XSP16, literal(-8)))
        CFI V0 load(1, XDATA, add(CFA_XSP16, literal(-9)))
        CFI VB load(1, XDATA, add(CFA_XSP16, literal(-10)))
        CFI R6 load(1, XDATA, add(CFA_XSP16, literal(-11)))
        CFI CFA_SP SP+0
        CFI CFA_XSP16 add(XSP16, 11)
        ; Saved register size: 11
        ; Auto size: 0
//  164   SampleApp_TaskID = task_id;
        MOV	A,R1
        MOV	DPTR,#SampleApp_TaskID
        MOVX	@DPTR,A
//  165   SampleApp_NwkState = DEV_INIT;
        MOV	A,#0x1
        MOV	DPTR,#SampleApp_NwkState
        MOVX	@DPTR,A
//  166   SampleApp_TransID = 0;
        CLR	A
        MOV	DPTR,#SampleApp_TransID
        MOVX	@DPTR,A
//  167 
//  168   // Device hardware initialization can be added here or in main() (Zmain.c).
//  169   // If the hardware is application specific - add it here.
//  170   // If the hardware is other parts of the device add it in main().
//  171 
//  172  #if defined ( SOFT_START )
//  173   // The "Demo" target is setup to have SOFT_START and HOLD_AUTO_START
//  174   // SOFT_START is a compile option that allows the device to start
//  175   //  as a coordinator if one isn't found.
//  176   // We are looking at a jumper (defined in SampleAppHw.c) to be jumpered
//  177   // together - if they are - we will start up a coordinator. Otherwise,
//  178   // the device will start as a router.
//  179   if ( readCoordinatorJumper() )
//  180     zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
//  181   else
//  182     zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
//  183 #endif // SOFT_START
//  184 
//  185 #if defined ( HOLD_AUTO_START )
//  186   // HOLD_AUTO_START is a compile option that will surpress ZDApp
//  187   //  from starting the device and wait for the application to

⌨️ 快捷键说明

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