📄 mac_csp_tx.s51
字号:
// 210 *
// 211 * @param none
// 212 *
// 213 * @return none
// 214 *=================================================================================================
// 215 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 216 static void cspPrepForTxProgram(void)
??cspPrepForTxProgram:
CFI Block cfiBlock2 Using cfiCommon0
CFI Function ??cspPrepForTxProgram
// 217 {
FUNCALL ??cspPrepForTxProgram, halAssertHandler
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
FUNCALL ??cspPrepForTxProgram, macMcuWriteRFIF
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
FUNCALL ??cspPrepForTxProgram, macMcuWriteRFIF
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
PUSH DPL
CFI DPL0 Frame(CFA_SP, 4)
CFI CFA_SP SP+-4
PUSH DPH
CFI DPH0 Frame(CFA_SP, 5)
CFI CFA_SP SP+-5
; Saved register size: 2
; Auto size: 0
// 218 MAC_ASSERT(!(RFIM & IM_CSP_STOP)); /* already an active CSP program */
MOV A,0x91
MOV C,0xE0 /* A */.1
JNC ??cspPrepForTxProgram_1
; Setup parameters for call to function halAssertHandler
MOV DPTR,#(halAssertHandler & 0xffff)
MOV A,#((halAssertHandler >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 219
// 220 /* set up parameters for CSP transmit program */
// 221 CSPY = CSPY_NO_RXTX_COLLISION;
??cspPrepForTxProgram_1:
MOV A,#0x1
MOV DPTR,#-0x20ed
MOVX @DPTR,A
// 222 CSPZ = CSPZ_CODE_CHANNEL_BUSY;
MOV DPTR,#-0x20ec
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();
MOV 0xe1,#-0x1
// 226 MAC_MCU_CSP_STOP_CLEAR_INTERRUPT();
; Setup parameters for call to function macMcuWriteRFIF
MOV R1,#-0x3
MOV DPTR,#(macMcuWriteRFIF & 0xffff)
MOV A,#((macMcuWriteRFIF >> 16) & 0xff)
LCALL ?BCALL ; Banked call to: DPTR()
// 227 MAC_MCU_CSP_INT_CLEAR_INTERRUPT();
; Setup parameters for call to function macMcuWriteRFIF
MOV R1,#-0x2
MOV A,#((macMcuWriteRFIF >> 16) & 0xff)
CFI EndBlock cfiBlock2
REQUIRE ?Subroutine2
; // Fall through to label ?Subroutine2
// 228 }
RSEG BANKED_CODE:CODE:NOROOT(0)
?Subroutine2:
CFI Block cfiBlock3 Using cfiCommon0
CFI NoFunction
CFI CFA_SP SP+-5
CFI DPL0 Frame(CFA_SP, 4)
CFI DPH0 Frame(CFA_SP, 5)
LCALL ?BCALL ; Banked call to: DPTR()
LJMP ??Subroutine0_1 & 0xFFFF
CFI EndBlock cfiBlock3
// 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 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 241 void macCspTxPrepCsmaUnslotted(void)
macCspTxPrepCsmaUnslotted:
CFI Block cfiBlock4 Using cfiCommon0
CFI Function macCspTxPrepCsmaUnslotted
// 242 {
FUNCALL macCspTxPrepCsmaUnslotted, ??cspPrepForTxProgram
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
PUSH DPL
CFI DPL0 Frame(CFA_SP, 4)
CFI CFA_SP SP+-4
PUSH DPH
CFI DPH0 Frame(CFA_SP, 5)
CFI CFA_SP SP+-5
; Saved register size: 2
; Auto size: 0
// 243 cspPrepForTxProgram();
; Setup parameters for call to function cspPrepForTxProgram
MOV DPTR,#(??cspPrepForTxProgram & 0xffff)
MOV A,#((??cspPrepForTxProgram >> 16) & 0xff)
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;
MOV 0xe1,#-0x45
// 254 RFST = WEVENT;
MOV 0xe1,#-0x48
// 255
// 256 /* wait for one backoff to guarantee receiver has been on at least that long */
// 257 RFST = WAITW(1);
MOV 0xe1,#-0x7f
// 258 RFST = WEVENT;
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);
SJMP ?Subroutine0
CFI EndBlock cfiBlock4
// 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 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 302 void macCspTxPrepCsmaSlotted(void)
macCspTxPrepCsmaSlotted:
CFI Block cfiBlock5 Using cfiCommon0
CFI Function macCspTxPrepCsmaSlotted
// 303 {
FUNCALL macCspTxPrepCsmaSlotted, ??cspPrepForTxProgram
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
PUSH DPL
CFI DPL0 Frame(CFA_SP, 4)
CFI CFA_SP SP+-4
PUSH DPH
CFI DPH0 Frame(CFA_SP, 5)
CFI CFA_SP SP+-5
; Saved register size: 2
; Auto size: 0
// 304 cspPrepForTxProgram();
; Setup parameters for call to function cspPrepForTxProgram
MOV DPTR,#(??cspPrepForTxProgram & 0xffff)
MOV A,#((??cspPrepForTxProgram >> 16) & 0xff)
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;
MOV 0xe1,#-0x45
// 312
// 313 /* wait for one backoff to guarantee receiver has been on at least that long */
// 314 RFST = WAITW(1);
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);
MOV 0xe1,#0x20
// 318 RFST = SSTOP;
MOV 0xe1,#-0x21
// 319 RFST = __SNOP__;
MOV 0xe1,#-0x40
// 320
// 321 /* per CSMA in specification, wait one backoff */
// 322 RFST = WAITW(1);
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);
SJMP ?Subroutine0
CFI EndBlock cfiBlock5
// 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 */
RSEG BANKED_CODE:CODE:NOROOT(0)
// 369 void macCspTxGoCsma(void)
macCspTxGoCsma:
CFI Block cfiBlock6 Using cfiCommon0
CFI Function macCspTxGoCsma
// 370 {
FUNCALL macCspTxGoCsma, macMcuOrRFIM
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
FUNCALL macCspTxGoCsma, macMcuOrRFIM
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
FUNCALL macCspTxGoCsma, macRxOn
LOCFRAME ISTACK, 2, STACK
ARGFRAME ISTACK, 2, STACK
PUSH DPL
CFI DPL0 Frame(CFA_SP, 4)
CFI CFA_SP SP+-4
PUSH DPH
CFI DPH0 Frame(CFA_SP, 5)
CFI CFA_SP SP+-5
; Saved register size: 2
; 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 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -