📄 probe_com.lst
字号:
\ In segment CODE, align 4, keep-with-next
515 void ProbeCom_InfoHndlrSet (PROBE_COM_INFO_HDNLR_FNCT hndlr)
516 {
\ ProbeCom_InfoHndlrSet:
\ 00000000 10B5 PUSH {R4,LR}
\ 00000002 0400 MOVS R4,R0
517 #if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
518 CPU_SR cpu_sr;
519 #endif
520
521
522 CPU_CRITICAL_ENTER();
\ 00000004 ........ _BLF CPU_SR_Save,??CPU_SR_Save??rT
523 ProbeCom_InfoHndlr = hndlr;
\ 00000008 .... LDR.N R1,??DataTable7 ;; ProbeCom_RxPktCtr + 24
\ 0000000A 0C60 STR R4,[R1, #+0]
524 CPU_CRITICAL_EXIT();
\ 0000000C ........ _BLF CPU_SR_Restore,??CPU_SR_Restore??rT
525 }
\ 00000010 10BD POP {R4,PC} ;; return
526
527
528 /*
529 *********************************************************************************************************
530 * ProbeCom_StrHndlrSet()
531 *
532 * Description : Set the handler that will be invoked when an string write packet is received.
533 *
534 * Argument(s) : hndlr The handler that will be invoked.
535 *
536 * Return(s) : none.
537 *
538 * Caller(s) : Application or communications-specific driver.
539 *
540 * Note(s) : none.
541 *********************************************************************************************************
542 */
543
544 #if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
545 void ProbeCom_StrHndlrSet (PROBE_COM_STR_HDNLR_FNCT hndlr)
546 {
547 #if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
548 CPU_SR cpu_sr;
549 #endif
550
551
552 CPU_CRITICAL_ENTER();
553 ProbeCom_StrHndlr = hndlr;
554 CPU_CRITICAL_EXIT();
555 }
556 #endif
557
558
559 /*
560 *********************************************************************************************************
561 * ProbeCom_TxStr()
562 *
563 * Description : Append a string in the string buffer.
564 *
565 * Argument(s) : pstr Pointer to the string to send.
566 *
567 * dly Delay time (in milliseconds). If this value is zero, then
568 * the function will return after queueing in the buffer the portion that fits
569 * immediately. Otherwise, the function will delay for a certain number of
570 * milliseconds until the entire string has been queued in the buffer.
571 *
572 * Return(s) : DEF_TRUE if the entire string was queued in the buffer.
573 * DEF_FALSE if the entire string could not be queued in the buffer.
574 *
575 * Caller(s) : Application.
576 *
577 * Note(s) : (1) The string buffer is implemented as a circular buffer. This function is one of two
578 * points of access for this buffer, the other being in the task or ISR which forms the
579 * tx packets. Only this function should modify the global current write index
580 * (ProbeCom_StrBufWrIx); only the task or ISR which forms the packets should modify the
581 * global current read index (ProbeCom_StrBufRdIx).
582 *
583 * (2) The global current write index (ProbeCom_StrBufWrIx) is the index of the next location
584 * in the buffer to write. The global current read index (ProbeCom_StrBufRdIx) is the
585 * index of the next location in the buffer to read.
586 *
587 * (3) The string buffer, an array of PROBE_COM_STR_BUF_SIZE bytes, can only hold
588 * (PROBE_COM_STR_BUF_SIZE - 1) bytes so that the condition
589 *
590 * ProbeCom_StrBufWrIx == ProbeCom_StrBufRdIx
591 *
592 * will be true if and only if the buffer is empty. Consequently, this function
593 * always leaves an empty space in the buffer.
594 *
595 * (4) If called from an ISR, dly MUST be 0.
596 *********************************************************************************************************
597 */
598
599 #if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
600 CPU_BOOLEAN ProbeCom_TxStr (CPU_CHAR *pstr,
601 CPU_INT16U dly)
602 {
603 CPU_BOOLEAN ret;
604 CPU_INT32U len;
605 CPU_INT16U wr_ix;
606 CPU_INT16U rd_ix;
607 CPU_INT16U wr_ix_n;
608
609 CPU_INT16U nbytes_free;
610 CPU_INT16U nbytes_wr;
611
612
613 if (dly == 0) {
614 ret = ProbeCom_OS_Pend(DEF_FALSE);
615 } else {
616 ret = ProbeCom_OS_Pend(DEF_TRUE);
617 }
618
619 if (ret == DEF_FALSE) {
620 return (DEF_FALSE);
621 }
622
623 len = (CPU_INT32U)Str_Len(pstr); /* Determine length of the string (without NULL byte). */
624
625 while (len > 0) {
626 rd_ix = ProbeCom_StrBufRdIx;
627 wr_ix = ProbeCom_StrBufWrIx;
628
629 if (rd_ix > wr_ix) { /* If rd_ix > wr_ix, store str at */
630 nbytes_free = rd_ix - wr_ix - 1; /* buf interval [wr_ix, rd_ix - 1). */
631 } else {
632 if (rd_ix == 0) { /* If rd_ix <= wr_ix && rd_ix == 0, store str at */
633 /* buf interval [wr_ix, end_ix - 1). */
634 nbytes_free = PROBE_COM_STR_BUF_SIZE - wr_ix - 1;
635 } else { /* If rd_ix <= wr_ix && rd_ix != 0, store str at */
636 nbytes_free = PROBE_COM_STR_BUF_SIZE - wr_ix; /* buf interval [wr_ix, end_ix). */
637 }
638 }
639
640 if (nbytes_free == 0) { /* If the buf is full ... */
641 if (dly == 0) { /* (a) Rtn if dly = 0. */
642 ProbeCom_OS_Post();
643 return (DEF_FALSE);
644 } else { /* (b) Call OS fnct to dly and continue. */
645 ProbeCom_OS_Dly(dly);
646 }
647 } else {
648 if (nbytes_free > len) { /* If str is shorter than free space. */
649 nbytes_wr = len;
650 } else {
651 nbytes_wr = nbytes_free;
652 }
653
654 wr_ix_n = wr_ix + nbytes_wr; /* Assign wr ix after wr. */
655
656 if (wr_ix_n == PROBE_COM_STR_BUF_SIZE) { /* Wrap buf ix around. */
657 wr_ix_n = 0;
658 }
659
660 Mem_Copy((void *)&ProbeCom_StrBuf[wr_ix], /* Copy str to buf. */
661 (void *) pstr,
662 (CPU_SIZE_T) nbytes_wr);
663
664 ProbeCom_StrBufWrIx = wr_ix_n; /* Assign new global wr ix. */
665 pstr += nbytes_wr; /* Inc str ptr. */
666 len -= nbytes_wr; /* Dec str len. */
667 }
668 }
669
670 ProbeCom_OS_Post();
671 return (DEF_TRUE); /* Rtn TRUE to indicate success. */
672 }
673 #endif
674
675
676 /*
677 *********************************************************************************************************
678 *********************************************************************************************************
679 * LOCAL FUNCTIONS
680 *********************************************************************************************************
681 *********************************************************************************************************
682 */
683
684 /*
685 *********************************************************************************************************
686 * ProbeCom_StrRdy()
687 *
688 * Description : Check if a string is ready for transmission.
689 *
690 * Argument(s) : none.
691 *
692 * Return(s) : DEF_TRUE if a string is in the buffer for transmission.
693 * DEF_FALSE if no string is in the buffer for transmission.
694 *
695 * Caller(s) : ProbeCom_PktModifier().
696 *
697 * Note(s) : (1) See Notes for 'ProbeCom_TxStr()'.
698 *********************************************************************************************************
699 */
700
701 #if (PROBE_COM_SUPPORT_STR == DEF_TRUE)
702 static CPU_BOOLEAN ProbeCom_StrRdy (void)
703 {
704 CPU_BOOLEAN rdy;
705 CPU_INT16U wr_ix;
706 CPU_INT16U rd_ix;
707
708
709 wr_ix = ProbeCom_StrBufWrIx;
710 rd_ix = ProbeCom_StrBufRdIx;
711
712 if (wr_ix == rd_ix) {
713 rdy = DEF_FALSE;
714 } else {
715 rdy = DEF_TRUE;
716 }
717
718 return (rdy);
719 }
720 #endif
721
722
723 /*
724 *********************************************************************************************************
725 * ProbeCom_PktModifier()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -