📄 sapi.lst
字号:
55
56 /*********************************************************************
57 * GLOBAL VARIABLES
58 */
59
\ In segment XDATA_Z, align 1, keep-with-next
\ 000000 REQUIRE __INIT_XDATA_Z
60 endPointDesc_t sapi_epDesc;
\ sapi_epDesc:
\ 000000 DS 6
\ In segment XDATA_Z, align 1, keep-with-next
\ 000000 REQUIRE __INIT_XDATA_Z
61 static uint8 sapi_TaskID;
\ ??sapi_TaskID:
\ 000000 DS 1
\ In segment XDATA_Z, align 1, keep-with-next
\ 000000 REQUIRE __INIT_XDATA_Z
62 static uint16 sapi_bindInProgress;
\ ??sapi_bindInProgress:
\ 000000 DS 2
63 /*********************************************************************
64 * LOCAL FUNCTIONS
65 */
66
67 static void SAPI_SendCback( uint8 event, uint8 status, uint16 data );
68
69 static void SAPI_StartConfirm( uint8 status );
70 static void SAPI_SendDataConfirm( uint8 handle, uint8 status );
71 static void SAPI_BindConfirm( uint16 commandId, uint8 status );
72 static void SAPI_FindDeviceConfirm( uint8 searchType,
73 uint8 *searchKey, uint8 *result );
74 static void SAPI_ReceiveDataIndication( uint16 source,
75 uint16 command, uint16 len, uint8 *pData );
76 static void SAPI_AllowBindConfirm( uint16 source );
77
78 /******************************************************************************
79 * @fn zb_SystemReset
80 *
81 * @brief The zb_SystemReset function reboots the ZigBee device. The
82 * zb_SystemReset function can be called after a call to
83 * zb_WriteConfiguration to restart Z-Stack with the updated
84 * configuration.
85 *
86 * @param none
87 *
88 * @return none
89 */
\ In segment BANKED_CODE, align 1, keep-with-next
90 void zb_SystemReset ( void )
\ zb_SystemReset:
91 {
\ 000000 ; Saved register size: 0
\ 000000 ; Auto size: 0
92 SystemReset();
\ 000000 C2AF CLR 0xa8.7
\ 000002 75C9AB MOV 0xc9,#-0x55
\ 000005 75C95B MOV 0xc9,#0x5b
\ ??zb_SystemReset_0:
\ 000008 00 NOP
\ 000009 80FD SJMP ??zb_SystemReset_0
93 }
94
95 /******************************************************************************
96 * @fn zb_StartRequest
97 *
98 * @brief The zb_StartRequest function starts the ZigBee stack. When the
99 * ZigBee stack starts, the device reads configuration parameters
100 * from Nonvolatile memory and the device joins its network. The
101 * ZigBee stack calls the zb_StartConrifm callback function when
102 * the startup process completes.
103 *
104 * @param none
105 *
106 * @return none
107 */
\ In segment BANKED_CODE, align 1, keep-with-next
108 void zb_StartRequest()
\ zb_StartRequest:
109 {
\ 000000 74F7 MOV A,#-0x9
\ 000002 12.... LCALL ?BANKED_ENTER_XDATA
\ 000005 ; Saved register size: 9
\ 000005 ; Auto size: 1
\ 000005 74FF MOV A,#-0x1
\ 000007 12.... LCALL ?ALLOC_XSTACK8
110 uint8 logicalType;
111
112 // Start the device
113 // start delay = min(NWK_START_DELAY, zgStartDelay) + rand() - only for fresh start, not restore
114 if ( zgStartDelay < NWK_START_DELAY )
\ 00000A 90.... MOV DPTR,#zgStartDelay
\ 00000D E0 MOVX A,@DPTR
\ 00000E C3 CLR C
\ 00000F 9464 SUBB A,#0x64
\ 000011 5003 JNC ??zb_StartRequest_0
115 zgStartDelay = 0;
\ 000013 E4 CLR A
\ 000014 8003 SJMP ??zb_StartRequest_1
116 else
117 zgStartDelay -= NWK_START_DELAY;
\ ??zb_StartRequest_0:
\ 000016 E0 MOVX A,@DPTR
\ 000017 249C ADD A,#-0x64
\ ??zb_StartRequest_1:
\ 000019 F0 MOVX @DPTR,A
118
119 // check that bad combinations of compile flag definitions and device type
120 zb_ReadConfiguration( ZCD_NV_LOGICAL_TYPE, sizeof(uint8), &logicalType );
\ 00001A ; Setup parameters for call to function zb_ReadConfiguration
\ 00001A 85..82 MOV DPL,?XSP + 0
\ 00001D 85..83 MOV DPH,?XSP + 1
\ 000020 AC82 MOV R4,DPL
\ 000022 AD83 MOV R5,DPH
\ 000024 7A01 MOV R2,#0x1
\ 000026 7987 MOV R1,#-0x79
\ 000028 90.... MOV DPTR,#(zb_ReadConfiguration & 0xffff)
\ 00002B 74.. MOV A,#((zb_ReadConfiguration >> 16) & 0xff)
\ 00002D 12.... LCALL ?BCALL ; Banked call to: DPTR()
121 if ( ( logicalType > ZG_DEVICETYPE_ENDDEVICE ) ||
122 #if defined( RTR_NWK )
123 #if defined( ZDO_COORDINATOR )
124 // Only RTR or Coord possible
125 ( logicalType == ZG_DEVICETYPE_ENDDEVICE ) ||
126 #else
127 // Only RTR possible
128 ( logicalType != ZG_DEVICETYPE_ROUTER ) ||
129 #endif
130 #else
131 #if defined( ZDO_COORDINATOR )
132 // Error
133 ( 1 ) ||
134 #else
135 // only ED possible
136 ( logicalType != ZG_DEVICETYPE_ENDDEVICE ) ||
137 #endif
138 #endif
139 ( 0 ) )
\ 000030 85..82 MOV DPL,?XSP + 0
\ 000033 85..83 MOV DPH,?XSP + 1
\ 000036 E0 MOVX A,@DPTR
\ 000037 C3 CLR C
\ 000038 9403 SUBB A,#0x3
\ 00003A 5005 JNC ??zb_StartRequest_2
\ 00003C E0 MOVX A,@DPTR
\ 00003D 6402 XRL A,#0x2
\ 00003F 700F JNZ ??zb_StartRequest_3
140 {
141 // error configuration
142 SAPI_SendCback( SAPICB_START_CNF, ZInvalidParameter, 0 );
\ ??zb_StartRequest_2:
\ 000041 ; Setup parameters for call to function SAPI_SendCback
\ 000041 7C00 MOV R4,#0x0
\ 000043 7D00 MOV R5,#0x0
\ 000045 7A02 MOV R2,#0x2
\ 000047 79E2 MOV R1,#-0x1e
\ 000049 90.... MOV DPTR,#(??SAPI_SendCback & 0xffff)
\ 00004C 74.. MOV A,#((??SAPI_SendCback >> 16) & 0xff)
\ 00004E 800C SJMP ??zb_StartRequest_4
143 }
144 else
145 {
146 ZDOInitDevice(zgStartDelay);
\ ??zb_StartRequest_3:
\ 000050 ; Setup parameters for call to function ZDOInitDevice
\ 000050 90.... MOV DPTR,#zgStartDelay
\ 000053 E0 MOVX A,@DPTR
\ 000054 FA MOV R2,A
\ 000055 7B00 MOV R3,#0x0
\ 000057 90.... MOV DPTR,#(ZDOInitDevice & 0xffff)
\ 00005A 74.. MOV A,#((ZDOInitDevice >> 16) & 0xff)
\ ??zb_StartRequest_4:
\ 00005C REQUIRE ?Subroutine13
\ 00005C ; // Fall through to label ?Subroutine13
147 }
148
149 return;
150 }
\ In segment BANKED_CODE, align 1, keep-with-next
\ ?Subroutine13:
\ 000000 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 000003 7401 MOV A,#0x1
\ 000005 12.... LCALL ?DEALLOC_XSTACK8
\ ??Subroutine13_0:
\ 000008 7F01 MOV R7,#0x1
\ 00000A 02.... LJMP ?BANKED_LEAVE_XDATA
151
152 /******************************************************************************
153 * @fn zb_BindDevice
154 *
155 * @brief The zb_BindDevice function establishes or removes a 慴inding
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -