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

📄 sampleapp.s51

📁 cc2430讀取短地址程式
💻 S51
📖 第 1 页 / 共 4 页
字号:
        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, 62, STACK
        EXTERN NLME_GetShortAddr
        FUNCTION NLME_GetShortAddr,0202H
        ARGFRAME XSTACK, 60, STACK
        EXTERN sprintf
        FUNCTION sprintf,0202H
        ARGFRAME XSTACK, 68, STACK
        EXTERN strlen
        FUNCTION strlen,010202H
        ARGFRAME XSTACK, 60, STACK
        EXTERN HalUARTWrite
        FUNCTION HalUARTWrite,0202H
        ARGFRAME XSTACK, 60, STACK


        RSEG XDATA_I:XDATA:NOROOT(0)
`?<Constant "Group 1">`:
        DS 8
        REQUIRE `?<Initializer for <Constant "Group 1">>`
        REQUIRE __INIT_XDATA_I

        RSEG XDATA_I:XDATA:NOROOT(0)
`?<Constant "Short Address : 0x%x%...">`:
        DS 27
        REQUIRE `?<Initializer for <Constant "Short Address : 0`
        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 <stdio.h>
//   38 #include "OSAL.h"
//   39 #include "ZGlobals.h"
//   40 #include "AF.h"
//   41 #include "aps_groups.h"
//   42 #include "ZDApp.h"
//   43 #include "NLMEDE.h"
//   44 #include "SampleApp.h"
//   45 #include "SampleAppHw.h"
//   46 #include "ioCC2430.h"
//   47 #include "OnBoard.h"
//   48 #include "string.h"
//   49 #include "SPIMgr.h"
//   50 /* HAL */
//   51 #include "hal_lcd.h"
//   52 #include "hal_led.h"
//   53 #include "hal_key.h"
//   54 #include "hal_adc.h"
//   55 #include "hal_adc.h"
//   56 
//   57 /* temperture */
//   58 #include "Temp.h"
//   59 
//   60 #define UINT8 unsigned char
//   61 UINT8 SendData(UINT8 *buf, UINT16 addr, UINT8 Leng);
//   62 
//   63 #define OPENLED(y,x) {P##y##SEL&= ~(1<<x);P##y##DIR |=1<<x ;P##y&=~(1<<x);}
//   64 #define CLOSELED(y,x) {P##y##SEL&= ~(1<<x);P##y##DIR |=1<<x;P##y|=(1<<x);}
//   65 /*********************************************************************
//   66  * MACROS
//   67  */
//   68 
//   69 /*********************************************************************
//   70  * CONSTANTS
//   71  */
//   72 
//   73 /*********************************************************************
//   74  * TYPEDEFS
//   75  */
//   76 
//   77 /*********************************************************************
//   78  * GLOBAL VARIABLES
//   79  */
//   80 
//   81 // This list should be filled with Application specific Cluster IDs.

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

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

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

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

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

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

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

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

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

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

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

        RSEG BANKED_CODE:CODE:NOROOT(0)
//  163 void SampleApp_Init( uint8 task_id )
SampleApp_Init:
        CFI Block cfiBlock0 Using cfiCommon0
        CFI Function SampleApp_Init
//  164 {
        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
//  165   SampleApp_TaskID = task_id;
        MOV	A,R1
        MOV	DPTR,#SampleApp_TaskID
        MOVX	@DPTR,A
//  166   SampleApp_NwkState = DEV_INIT;
        MOV	A,#0x1
        MOV	DPTR,#SampleApp_NwkState
        MOVX	@DPTR,A
//  167   SampleApp_TransID = 0;
        CLR	A
        MOV	DPTR,#SampleApp_TransID
        MOVX	@DPTR,A
//  168 
//  169   // Device hardware initialization can be added here or in main() (Zmain.c).
//  170   // If the hardware is application specific - add it here.
//  171   // If the hardware is other parts of the device add it in main().
//  172 
//  173  #if defined ( SOFT_START )
//  174   // The "Demo" target is setup to have SOFT_START and HOLD_AUTO_START
//  175   // SOFT_START is a compile option that allows the device to start
//  176   //  as a coordinator if one isn't found.
//  177   // We are looking at a jumper (defined in SampleAppHw.c) to be jumpered
//  178   // together - if they are - we will start up a coordinator. Otherwise,
//  179   // the device will start as a router.
//  180   if ( readCoordinatorJumper() )
//  181     zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
//  182   else
//  183     zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;

⌨️ 快捷键说明

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