📄 sampleapp.s51
字号:
// 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
// 43 #include "SampleApp.h"
// 44 #include "SampleAppHw.h"
// 45
// 46 #include "OnBoard.h"
// 47
// 48 /* HAL */
// 49 #include "hal_lcd.h"
// 50 #include "hal_led.h"
// 51 #include "hal_key.h"
// 52 #include "ZDProfile.h"
// 53 /*********************************************************************
// 54 * MACROS
// 55 */
// 56
// 57 /*********************************************************************
// 58 * CONSTANTS
// 59 */
// 60
// 61 /*********************************************************************
// 62 * TYPEDEFS
// 63 */
// 64
// 65 /*********************************************************************
// 66 * GLOBAL VARIABLES
// 67 */
// 68
// 69 // This list should be filled with Application specific Cluster IDs.
RSEG XDATA_I:XDATA:NOROOT(0)
// 70 const cId_t SampleApp_ClusterList[SAMPLEAPP_MAX_CLUSTERS] =
SampleApp_ClusterList:
DS 4
REQUIRE `?<Initializer for SampleApp_ClusterList>`
REQUIRE __INIT_XDATA_I
// 71 {
// 72 SAMPLEAPP_PERIODIC_CLUSTERID,
// 73 SAMPLEAPP_FLASH_CLUSTERID
// 74 };
// 75
RSEG XDATA_I:XDATA:NOROOT(0)
// 76 const SimpleDescriptionFormat_t SampleApp_SimpleDesc =
SampleApp_SimpleDesc:
DS 12
REQUIRE `?<Initializer for SampleApp_SimpleDesc>`
REQUIRE __INIT_XDATA_I
// 77 {
// 78 SAMPLEAPP_ENDPOINT, // int Endpoint;
// 79 SAMPLEAPP_PROFID, // uint16 AppProfId[2];
// 80 SAMPLEAPP_DEVICEID, // uint16 AppDeviceId[2];
// 81 SAMPLEAPP_DEVICE_VERSION, // int AppDevVer:4;
// 82 SAMPLEAPP_FLAGS, // int AppFlags:4;
// 83 SAMPLEAPP_MAX_CLUSTERS, // uint8 AppNumInClusters;
// 84 (cId_t *)SampleApp_ClusterList, // uint8 *pAppInClusterList;
// 85 SAMPLEAPP_MAX_CLUSTERS, // uint8 AppNumInClusters;
// 86 (cId_t *)SampleApp_ClusterList // uint8 *pAppInClusterList;
// 87 };
// 88
// 89 // This is the Endpoint/Interface description. It is defined here, but
// 90 // filled-in in SampleApp_Init(). Another way to go would be to fill
// 91 // in the structure here and make it a "const" (in code space). The
// 92 // way it's defined in this sample app it is define in RAM.
RSEG XDATA_Z:XDATA:NOROOT(0)
REQUIRE __INIT_XDATA_Z
// 93 endPointDesc_t SampleApp_epDesc;
SampleApp_epDesc:
DS 6
// 94
// 95 /*********************************************************************
// 96 * EXTERNAL VARIABLES
// 97 */
// 98
// 99 /*********************************************************************
// 100 * EXTERNAL FUNCTIONS
// 101 */
// 102
// 103 /*********************************************************************
// 104 * LOCAL VARIABLES
// 105 */
RSEG XDATA_Z:XDATA:NOROOT(0)
REQUIRE __INIT_XDATA_Z
// 106 uint8 SampleApp_TaskID; // Task ID for internal task/event processing
SampleApp_TaskID:
DS 1
// 107 // This variable will be received when
// 108 // SampleApp_Init() is called.
RSEG XDATA_Z:XDATA:NOROOT(0)
REQUIRE __INIT_XDATA_Z
// 109 devStates_t SampleApp_NwkState;
SampleApp_NwkState:
DS 1
// 110
RSEG XDATA_Z:XDATA:NOROOT(0)
REQUIRE __INIT_XDATA_Z
// 111 uint8 SampleApp_TransID; // This is the unique message ID (counter)
SampleApp_TransID:
DS 1
// 112
RSEG XDATA_Z:XDATA:NOROOT(0)
REQUIRE __INIT_XDATA_Z
// 113 afAddrType_t SampleApp_Periodic_DstAddr;
SampleApp_Periodic_DstAddr:
DS 4
RSEG XDATA_Z:XDATA:NOROOT(0)
REQUIRE __INIT_XDATA_Z
// 114 afAddrType_t SampleApp_Flash_DstAddr;
SampleApp_Flash_DstAddr:
DS 4
// 115
RSEG XDATA_Z:XDATA:NOROOT(0)
REQUIRE __INIT_XDATA_Z
// 116 aps_Group_t SampleApp_Group;
SampleApp_Group:
DS 18
// 117
RSEG XDATA_Z:XDATA:NOROOT(0)
REQUIRE __INIT_XDATA_Z
// 118 uint8 SampleAppPeriodicCounter = 0;
SampleAppPeriodicCounter:
DS 1
RSEG XDATA_Z:XDATA:NOROOT(0)
REQUIRE __INIT_XDATA_Z
// 119 uint8 SampleAppFlashCounter = 0;
SampleAppFlashCounter:
DS 1
// 120
// 121 /*********************************************************************
// 122 * LOCAL FUNCTIONS
// 123 */
// 124 void SampleApp_HandleKeys( uint8 shift, uint8 keys );
// 125 void SampleApp_MessageMSGCB( afIncomingMSGPacket_t *pckt );
// 126 void SampleApp_SendPeriodicMessage( void );
// 127 void SampleApp_SendFlashMessage( uint16 flashTime );
// 128
// 129 /*********************************************************************
// 130 * NETWORK LAYER CALLBACKS
// 131 */
// 132
// 133 /*********************************************************************
// 134 * PUBLIC FUNCTIONS
// 135 */
// 136
// 137 /*********************************************************************
// 138 * @fn SampleApp_Init
// 139 *
// 140 * @brief Initialization function for the Generic App Task.
// 141 * This is called during initialization and should contain
// 142 * any application specific initialization (ie. hardware
// 143 * initialization/setup, table initialization, power up
// 144 * notificaiton ... ).
// 145 *
// 146 * @param task_id - the ID assigned by OSAL. This ID should be
// 147 * used to send messages and set timers.
// 148 *
// 149 * @return none
// 150 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 151 void SampleApp_Init( uint8 task_id )
SampleApp_Init:
CFI Block cfiBlock0 Using cfiCommon0
CFI Function SampleApp_Init
// 152 {
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
// 153 SampleApp_TaskID = task_id;
MOV A,R1
MOV DPTR,#SampleApp_TaskID
MOVX @DPTR,A
// 154 SampleApp_NwkState = DEV_INIT;
MOV A,#0x1
MOV DPTR,#SampleApp_NwkState
MOVX @DPTR,A
// 155 SampleApp_TransID = 0;
CLR A
MOV DPTR,#SampleApp_TransID
MOVX @DPTR,A
// 156
// 157 // Device hardware initialization can be added here or in main() (Zmain.c).
// 158 // If the hardware is application specific - add it here.
// 159 // If the hardware is other parts of the device add it in main().
// 160
// 161 #if defined ( SOFT_START )
// 162 // The "Demo" target is setup to have SOFT_START and HOLD_AUTO_START
// 163 // SOFT_START is a compile option that allows the device to start
// 164 // as a coordinator if one isn't found.
// 165 // We are looking at a jumper (defined in SampleAppHw.c) to be jumpered
// 166 // together - if they are - we will start up a coordinator. Otherwise,
// 167 // the device will start as a router.
// 168 if ( readCoordinatorJumper() )
// 169 zgDeviceLogicalType = ZG_DEVICETYPE_COORDINATOR;
// 170 else
// 171 zgDeviceLogicalType = ZG_DEVICETYPE_ROUTER;
// 172 #endif // SOFT_START
// 173
// 174 #if defined ( HOLD_AUTO_START )
// 175 // HOLD_AUTO_START is a compile option that will surpress ZDApp
// 176 // from starting the device and wait for the application to
// 177 // start the device.
// 178 ZDOInitDevice(0);
// 179 #endif
// 180
// 181 // Setup for the periodic message's destination address
// 182 // Broadcast to everyone
// 183 SampleApp_Periodic_DstAddr.addrMode = (afAddrMode_t)AddrBroadcast;
MOV A,#0xf
MOV DPTR,#(SampleApp_Periodic_DstAddr + 2)
MOVX @DPTR,A
// 184 SampleApp_Periodic_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
MOV A,#0x14
MOV DPTR,#(SampleApp_Periodic_DstAddr + 3)
MOVX @DPTR,A
// 185 SampleApp_Periodic_DstAddr.addr.shortAddr = 0xFFFF;
MOV DPTR,#SampleApp_Periodic_DstAddr
MOV A,#-0x1
MOVX @DPTR,A
INC DPTR
MOVX @DPTR,A
// 186
// 187 // Setup for the flash command's destination address - Group 1
// 188 SampleApp_Flash_DstAddr.addrMode = (afAddrMode_t)afAddrGroup;
MOV A,#0x1
MOV DPTR,#(SampleApp_Flash_DstAddr + 2)
MOVX @DPTR,A
// 189 SampleApp_Flash_DstAddr.endPoint = SAMPLEAPP_ENDPOINT;
MOV A,#0x14
MOV DPTR,#(SampleApp_Flash_DstAddr + 3)
MOVX @DPTR,A
// 190 SampleApp_Flash_DstAddr.addr.shortAddr = SAMPLEAPP_FLASH_GROUP;
MOV DPTR,#SampleApp_Flash_DstAddr
MOV A,#0x1
MOVX @DPTR,A
INC DPTR
CLR A
MOVX @DPTR,A
// 191
// 192 // Fill out the endpoint description.
// 193 SampleApp_epDesc.endPoint = SAMPLEAPP_ENDPOINT;
MOV A,#0x14
MOV DPTR,#SampleApp_epDesc
MOVX @DPTR,A
// 194 SampleApp_epDesc.task_id = &SampleApp_TaskID;
MOV DPTR,#(SampleApp_epDesc + 1)
MOV A,#(SampleApp_TaskID & 0xff)
MOVX @DPTR,A
INC DPTR
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -