mac_csp_tx.lst
来自「TI的基于ZIGBEE2006的协议栈」· LST 代码 · 共 1,102 行 · 第 1/5 页
LST
1,102 行
\ 000026 D082 POP DPL
\ 000028 02.... LJMP ?BRET
203
204
205 /*=================================================================================================
206 * @fn cspPrepForTxProgram
207 *
208 * @brief Prepare and initialize for transmit CSP program.
209 * Call *before* loading the CSP program!
210 *
211 * @param none
212 *
213 * @return none
214 *=================================================================================================
215 */
\ In segment BANKED_CODE, align 1, keep-with-next
216 static void cspPrepForTxProgram(void)
\ ??cspPrepForTxProgram:
217 {
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 0
218 MAC_ASSERT(!(RFIM & IM_CSP_STOP)); /* already an active CSP program */
\ 000004 E591 MOV A,0x91
\ 000006 A2E1 MOV C,0xE0 /* A */.1
\ 000008 5008 JNC ??cspPrepForTxProgram_1
\ 00000A ; Setup parameters for call to function halAssertHandler
\ 00000A 90.... MOV DPTR,#(halAssertHandler & 0xffff)
\ 00000D 74.. MOV A,#((halAssertHandler >> 16) & 0xff)
\ 00000F 12.... LCALL ?BCALL ; Banked call to: DPTR()
219
220 /* set up parameters for CSP transmit program */
221 CSPY = CSPY_NO_RXTX_COLLISION;
\ ??cspPrepForTxProgram_1:
\ 000012 7401 MOV A,#0x1
\ 000014 90DF13 MOV DPTR,#-0x20ed
\ 000017 F0 MOVX @DPTR,A
222 CSPZ = CSPZ_CODE_CHANNEL_BUSY;
\ 000018 90DF14 MOV DPTR,#-0x20ec
\ 00001B F0 MOVX @DPTR,A
223
224 /* clear the currently loaded CSP, this generates a stop interrupt which must be cleared */
225 CSP_STOP_AND_CLEAR_PROGRAM();
\ 00001C 75E1FF MOV 0xe1,#-0x1
226 MAC_MCU_CSP_STOP_CLEAR_INTERRUPT();
\ 00001F ; Setup parameters for call to function macMcuWriteRFIF
\ 00001F 79FD MOV R1,#-0x3
\ 000021 90.... MOV DPTR,#(macMcuWriteRFIF & 0xffff)
\ 000024 74.. MOV A,#((macMcuWriteRFIF >> 16) & 0xff)
\ 000026 12.... LCALL ?BCALL ; Banked call to: DPTR()
227 MAC_MCU_CSP_INT_CLEAR_INTERRUPT();
\ 000029 ; Setup parameters for call to function macMcuWriteRFIF
\ 000029 79FE MOV R1,#-0x2
\ 00002B 74.. MOV A,#((macMcuWriteRFIF >> 16) & 0xff)
\ 00002D REQUIRE ?Subroutine2
\ 00002D ; // Fall through to label ?Subroutine2
228 }
\ In segment BANKED_CODE, align 1, keep-with-next
\ ?Subroutine2:
\ 000000 12.... LCALL ?BCALL ; Banked call to: DPTR()
\ 000003 02.... LJMP ??Subroutine0_1 & 0xFFFF
229
230
231 /**************************************************************************************************
232 * @fn macCspTxPrepCsmaUnslotted
233 *
234 * @brief Prepare CSP for "Unslotted CSMA" transmit. Load CSP program and set CSP parameters.
235 *
236 * @param none
237 *
238 * @return none
239 **************************************************************************************************
240 */
\ In segment BANKED_CODE, align 1, keep-with-next
241 void macCspTxPrepCsmaUnslotted(void)
\ macCspTxPrepCsmaUnslotted:
242 {
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 0
243 cspPrepForTxProgram();
\ 000004 ; Setup parameters for call to function cspPrepForTxProgram
\ 000004 90.... MOV DPTR,#(??cspPrepForTxProgram & 0xffff)
\ 000007 74.. MOV A,#((??cspPrepForTxProgram >> 16) & 0xff)
\ 000009 12.... LCALL ?BCALL ; Banked call to: DPTR()
244
245 /*----------------------------------------------------------------------
246 * Load CSP program : Unslotted CSMA transmit
247 */
248
249 /*
250 * Wait for X number of backoffs, then wait for intra-backoff count
251 * to reach value set for WEVENT.
252 */
253 RFST = WAITX;
\ 00000C 75E1BB MOV 0xe1,#-0x45
254 RFST = WEVENT;
\ 00000F 75E1B8 MOV 0xe1,#-0x48
255
256 /* wait for one backoff to guarantee receiver has been on at least that long */
257 RFST = WAITW(1);
\ 000012 75E181 MOV 0xe1,#-0x7f
258 RFST = WEVENT;
\ 000015 75E1B8 MOV 0xe1,#-0x48
259
260 /* sample CCA, if it fails exit from here, CSPZ indicates result */
261 RFST = SKIP(1+__SNOP_SKIP__, C_CCA_IS_VALID);
\ 000018 80.. SJMP ?Subroutine0
262 RFST = SSTOP;
263 RFST = __SNOP__;
264
265 /* CSMA has passed so transmit */
266 RFST = STXON;
267
268 /*
269 * If the SFD pin is high at this point, there was an RX-TX collision.
270 * In other words, TXON was strobed while receiving. The CSP variable
271 * CSPY is decremented to indicate this happened. The rest of the transmit
272 * continues normally.
273 */
274 RFST = SKIP(2+__SNOP_SKIP__, C_SFD_IS_INACTIVE);
275 RFST = WHILE(C_SFD_IS_ACTIVE);
276 RFST = DECY;
277 RFST = __SNOP__;
278
279 /*
280 * Watch the SFD pin to determine when the transmit has finished going out.
281 * The INT instruction causes an interrupt to fire. The ISR for this interrupt
282 * handles the record the timestamp (which was just captured when SFD went high).
283 * Decrement CSPZ at the last step to indicate transmit was successful.
284 */
285 RFST = WHILE(C_SFD_IS_INACTIVE);
286 RFST = INT;
287 RFST = WHILE(C_SFD_IS_ACTIVE);
288 RFST = DECZ;
289 }
290
291
292 /**************************************************************************************************
293 * @fn macCspTxPrepCsmaSlotted
294 *
295 * @brief Prepare CSP for "Slotted CSMA" transmit. Load CSP program and set CSP parameters.
296 *
297 * @param none
298 *
299 * @return none
300 **************************************************************************************************
301 */
\ In segment BANKED_CODE, align 1, keep-with-next
302 void macCspTxPrepCsmaSlotted(void)
\ macCspTxPrepCsmaSlotted:
303 {
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 0
304 cspPrepForTxProgram();
\ 000004 ; Setup parameters for call to function cspPrepForTxProgram
\ 000004 90.... MOV DPTR,#(??cspPrepForTxProgram & 0xffff)
\ 000007 74.. MOV A,#((??cspPrepForTxProgram >> 16) & 0xff)
\ 000009 12.... LCALL ?BCALL ; Banked call to: DPTR()
305
306 /*----------------------------------------------------------------------
307 * Load CSP program : Slotted CSMA transmit
308 */
309
310 /* wait for X number of backoffs */
311 RFST = WAITX;
\ 00000C 75E1BB MOV 0xe1,#-0x45
312
313 /* wait for one backoff to guarantee receiver has been on at least that long */
314 RFST = WAITW(1);
\ 00000F 75E181 MOV 0xe1,#-0x7f
315
316 /* sample CCA, if it fails exit from here, CSPZ indicates result */
317 RFST = SKIP(1+__SNOP_SKIP__, C_CCA_IS_VALID);
\ 000012 75E120 MOV 0xe1,#0x20
318 RFST = SSTOP;
\ 000015 75E1DF MOV 0xe1,#-0x21
319 RFST = __SNOP__;
\ 000018 75E1C0 MOV 0xe1,#-0x40
320
321 /* per CSMA in specification, wait one backoff */
322 RFST = WAITW(1);
\ 00001B 75E181 MOV 0xe1,#-0x7f
323
324 /* sample CCA again, if it fails exit from here, CSPZ indicates result */
325 RFST = SKIP(1+__SNOP_SKIP__, C_CCA_IS_VALID);
\ 00001E 80.. SJMP ?Subroutine0
326 RFST = SSTOP;
327 RFST = __SNOP__;
328
329 /* CSMA has passed so transmit */
330 RFST = STXON;
331
332 /*
333 * If the SFD pin is high at this point, there was an RX-TX collision.
334 * In other words, TXON was strobed while receiving. The CSP variable
335 * CSPY is decremented to indicate this happened. The rest of the transmit
336 * continues normally.
337 */
338 RFST = SKIP(2+__SNOP_SKIP__, C_SFD_IS_INACTIVE);
339 RFST = WHILE(C_SFD_IS_ACTIVE);
340 RFST = DECY;
341 RFST = __SNOP__;
342
343 /*
344 * Watch the SFD pin to determine when the transmit has finished going out.
345 * The INT instruction causes an interrupt to fire. The ISR for this interrupt
346 * handles the record the timestamp (which was just captured when SFD went high).
347 * Decrement CSPZ at the last step to indicate transmit was successful.
348 */
349 RFST = WHILE(C_SFD_IS_INACTIVE);
350 RFST = INT;
351 RFST = WHILE(C_SFD_IS_ACTIVE);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?