📄 mac_csp_tx.lst
字号:
\ 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);
352 RFST = DECZ;
353 }
354
355
356 /**************************************************************************************************
357 * @fn macCspTxGoCsma
358 *
359 * @brief Run previously loaded CSP program for CSMA transmit. Handles either
360 * slotted or unslotted CSMA transmits. When CSP program has finished,
361 * an interrupt occurs and macCspTxStopIsr() is called. This ISR will in
362 * turn call macTxDoneCallback().
363 *
364 * @param none
365 *
366 * @return none
367 **************************************************************************************************
368 */
\ In segment BANKED_CODE, align 1, keep-with-next
369 void macCspTxGoCsma(void)
\ macCspTxGoCsma:
370 {
\ 000000 C082 PUSH DPL
\ 000002 C083 PUSH DPH
\ 000004 ; Saved register size: 2
\ 000004 ; Auto size: 0
371 /*
372 * Set CSPX with the countdown time of the CSMA delay. Subtract one because there is
373 * a built-in one backoff delay in the CSP program to make sure receiver has been 'on'
374 * for at least one backoff. Don't subtract though if CSPX is already zero!
375 */
376 CSPX = macTxCsmaBackoffDelay;
\ 000004 90.... MOV DPTR,#macTxCsmaBackoffDelay
\ 000007 E0 MOVX A,@DPTR
\ 000008 90DF12 MOV DPTR,#-0x20ee
\ 00000B F0 MOVX @DPTR,A
377 if (CSPX != 0)
\ 00000C E0 MOVX A,@DPTR
\ 00000D 6003 JZ ??macCspTxGoCsma_0
378 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -