⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sci.lst

📁 该程序是ST7MC驱动三洋压缩机(交流)
💻 LST
📖 第 1 页 / 共 3 页
字号:
  378:  INPUT           : None
  379:  OUTPUT          : Received Data
  380:  DESCRIPTION     : Retunrs a data received to the user
  381:  COMMENTS        : None
  382:  -----------------------------------------------------------------------------*/
  383:  unsigned char SCI_GetByte(void)
  384:  {  

Function: SCI_GetByte
Source  : ..\..\source\sci.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  385:  #if defined SCI_POLLING_RX     
  386:      return(SCIDR);                     /*Returns the current value of the Data 
  0000 b600     LD    A,SCIDR
  387:                                                           register to the user*/
  388:  #else
  389:  
  390:  #if defined SCI_ITDRV_WITHOUTBUF_RX 
  391:      SCI_Error = 0x00;
  392:      return(SCI_MY_DATA); 	  
  393:  #else	
  394:      return (SCIDR);           
  395:  #endif
  396:  #endif
  397:  }
  0002 81       RET   
  398:  /*-----------------------------------------------------------------------------
  399:  ROUTINE NAME    : SCI_GetBuffer
  400:  INPUT           : *PtrtoBuffer,NbOfBytes
  401:  OUTPUT          :  Error Status
  402:  DESCRIPTION     : Receives a continuous data,stores it into the user buffer and
  403:                    returns the error status to the user
  404:  COMMENTS        : Reception stops as soon as an error occurs
  405:  -----------------------------------------------------------------------------*/
  406:  #ifdef SCI_POLLING_RX
  407:  SCI_RxError_t SCI_GetBuffer(unsigned char *PtrtoBuffer,unsigned char NbOfBytes)
  408:  {

Function: SCI_GetBuffer
Source  : ..\..\source\sci.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  0000 b700     LD    _SCI_GetBufferp0,A
  409:      unsigned char Temp = 0x00 ;
  0002 3f00     CLR   Temp
  410:         
  411:      for (;((NbOfBytes > 0)&& (!(Temp))); --NbOfBytes)           
  0004 2014     JRT   *22 ;abs = 001a
  412:                                      /*Checks if all the bytes are transmitted*/
  413:      {   
  414:          Temp |= (unsigned char)(SCISR & SCI_ErrValue);
  0006 ad1e     CALLR *32 ;abs = 0026
  415:          while (!(SCISR & SCISR_RDRF_OR)); 
  0008 0b00fd   BTJF  SCISR,#5,*0 ;abs = 0008
  416:          Temp |= (unsigned char)(SCISR & SCI_ErrValue);
  000b ad19     CALLR *27 ;abs = 0026
  417:                                             /*waits for the next received byte*/
  418:          *PtrtoBuffer = SCIDR;  
  000d b600     LD    A,SCIDR
  000f 92c700   LD    [_SCI_GetBufferp1.w],A
  419:                                /*copies the received byte into the user buffer*/
  420:          PtrtoBuffer++;               /*Moves the pointer to the next location*/
  0012 3c01     INC   _SCI_GetBufferp1:1
  0014 2602     JRNE  *4 ;abs = 0018
  0016 3c00     INC   _SCI_GetBufferp1
  0018 3a00     DEC   _SCI_GetBufferp0
  001a b600     LD    A,_SCI_GetBufferp0
  001c 2704     JREQ  *6 ;abs = 0022
  001e b600     LD    A,Temp
  0020 27e4     JREQ  *-26 ;abs = 0006
  421:      } 
  422:      return(Temp);
  0022 b600     LD    A,Temp
  0024 5f       CLR   X
  423:  }
  0025 81       RET   
  0026 b600     LD    A,SCISR
  0028 a40f     AND   A,#15
  002a ba00     OR    A,Temp
  002c b700     LD    Temp,A
  002e 81       RET   
  424:  #endif 
  425:  /*-----------------------------------------------------------------------------
  426:  ROUTINE NAME    : SCI_GetString
  427:  INPUT           : *PtrtoString
  428:  OUTPUT          : Error Status
  429:  DESCRIPTION     : Receives a string,Stores it in the user buffer and returns
  430:                    the error status to the user
  431:  COMMENTS        : Reception stops as soon as an error occurs
  432:  -----------------------------------------------------------------------------*/
  433:  #ifdef SCI_POLLING_RX
  434:  SCI_RxError_t SCI_GetString(unsigned char *PtrtoString)
  435:  {

Function: SCI_GetString
Source  : ..\..\source\sci.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  0000 b701     LD    _SCI_GetStringp0:1,A
  0002 bf00     LD    _SCI_GetStringp0,X
  436:      unsigned char Temp = 0x00, Val = 0xff; 
  0004 3f00     CLR   Temp
  437:   
  438:      for (;((Val != '\0')&&(Temp == 0));PtrtoString++)
  439:      {    
  440:          Temp |= (unsigned char)(SCISR & SCI_ErrValue);   
  0006 ad1b     CALLR *29 ;abs = 0023
  441:          while (!(SCISR & SCISR_RDRF_OR));                /*waits for the received byte*/
  0008 0b00fd   BTJF  SCISR,#5,*0 ;abs = 0008
  442:          Temp |= (unsigned char)(SCISR & SCI_ErrValue);          
  000b ad16     CALLR *24 ;abs = 0023
  443:                     /*Temp stores any error that occurred during the reception*/
  444:          *PtrtoString = SCIDR; 
  000d b600     LD    A,SCIDR
  000f 92c700   LD    [_SCI_GetStringp0.w],A
  0012 3c01     INC   _SCI_GetStringp0:1
  0014 2602     JRNE  *4 ;abs = 0018
  0016 3c00     INC   _SCI_GetStringp0
  0018 4d       TNZ   A
  0019 2704     JREQ  *6 ;abs = 001f
  001b b600     LD    A,Temp
  001d 27e7     JREQ  *-23 ;abs = 0006
  445:                           /*Copies the received character into the user string*/
  446:          Val = *PtrtoString;
  447:      }  
  448:      return(Temp);                      /*Returns the error status to the user*/
  001f b600     LD    A,Temp
  0021 5f       CLR   X
  449:  }
  0022 81       RET   
  0023 b600     LD    A,SCISR
  0025 a40f     AND   A,#15
  0027 ba00     OR    A,Temp
  0029 b700     LD    Temp,A
  002b 81       RET   
  450:  #endif 
  451:  
  452:  /*-----------------------------------------------------------------------------
  453:  ROUTINE NAME	: SCI_GetBuffer
  454:  INPUT           : *PtrtoBuffer, NbOfBytes 
  455:  OUTPUT          : None	
  456:  DESCRIPTION     : Starts the reception in the interrupt subroutine
  457:  COMMENTS        : Any data received before calling this function is ignored
  458:  -----------------------------------------------------------------------------*/
  459:  #ifdef SCI_ITDRV_WITHOUTBUF_RX
  460:  void SCI_GetBuffer(unsigned char *PtrtoBuffer,unsigned char NbOfBytes) 
  461:  {
  462:      PtrToSCIBuffRx = PtrtoBuffer;/*Copies user buffer to the global variable */
  463:      SCI_Rx_Buff = NbOfBytes;
  464:      SCI_Rx_Buff++;
  465:      SCI_Error = 0x00;                                     
  466:      SCICR2 |= (unsigned char)RDRF;    /*Enable Interrupt*/    
  467:  }                                                         
  468:  
  469:  /*-----------------------------------------------------------------------------
  470:  ROUTINE NAME    : SCI_GetString
  471:  INPUT           : *PtrtoString  
  472:  OUTPUT          : None 
  473:  DESCRIPTION     : Starts the reception of a string in the interrupt subroutine
  474:  COMMENTS        : Any data received before calling this function is ignored
  475:  -----------------------------------------------------------------------------*/
  476:  void SCI_GetString(unsigned char *PtrtoString) 
  477:  {
  478:      PtrToSCIBuffRx = (PtrtoString); /*Copies the user buffer to global buffer*/
  479:      SCI_Rx_String = 1;                        /*For String recognition in ISR*/ 
  480:      SCI_Error = 0x00;
  481:      SCICR2 |= (unsigned char)RDRF;    /*Enable Interrupt*/    
  482:  }
  483:  #endif
  484:  /*-----------------------------------------------------------------------------
  485:  ROUTINE NAME    : SCI_IsReceptionCompleted
  486:  INPUT           : None
  487:  OUTPUT          : Error Status
  488:  DESCRIPTION     : Returns the error status occurred during the reception in the
  489:                    interrupt subroutine if the reception is completed.
  490:  COMMENTS        : Must be called after SCI_GetBuffer and SCI_GetString in 
  491:                    Interrupt Driven mode to get the reception status.
  492:                    Must be called before SCI_GetByte in interrupt Driven mode.
  493:  -----------------------------------------------------------------------------*/
  494:  SCI_RxError_t SCI_IsReceptionCompleted (void)  
  495:  {   

Function: SCI_IsReceptionCompleted
Source  : ..\..\source\sci.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  496:  #if defined SCI_ITDRV_WITHOUTBUF_RX          
  497:      SCI_Pol_Stat = 0;          
  498:  
  499:      if ((SCI_Rx_String == 1) && (*(PtrToSCIBuffRx) != '\0') && (SCI_Error == 0))
  500:                                          /*String reception request undergoing*/
  501:      {
  502:          return(SCI_STRING_ONGOING);
  503:      }  
  504:      else if ((SCI_Error == 0) && (SCI_Rx_Buff > 1)) 
  505:                                          /*Buffer Reception request undergoing*/
  506:      {   
  507:          return(SCI_BUFFER_ONGOING) ;
  508:      }
  509:      else if ((SCI_Rx_Buff == 0) && (SCI_Rx_String == 0) && (SCI_Pol_Stat == 0))	
  510:                                                     /*Single Byte not received*/
  511:      {
  512:          return (SCI_RX_DATA_EMPTY);	
  513:      }
  514:      else                                             /*Reception is completed*/
  515:      {       
  516:          SCI_Pol_Stat = 0; 
  517:          SCI_Rx_Buff = 0;
  518:          SCI_Rx_String = 0;
  519:          return (SCI_Error);
  520:      }		   
  521:  #else
  522:  #if defined SCI_POLLING_RX   	
  523:      if(SCISR & SCISR_RDRF_OR) 
  0000 0b0006   BTJF  SCISR,#5,*9 ;abs = 0009
  524:      {
  525:          return ((unsigned char)(SCISR & SCI_ErrValue)); 
  0003 b600     LD    A,SCISR
  0005 a40f     AND   A,#15
  0007 2002     JRT   *4 ;abs = 000b
  526:      }
  527:      else
  528:      {
  529:          return (SCI_RX_DATA_EMPTY);    /*Returns the error status to the user*/
  0009 a6fd     LD    A,#253
  000b 5f       CLR   X
  530:      }
  531:  #else 
  532:          return (SCI_RX_DATA_EMPTY);                  /*Dummy return statement*/
  533:  #endif
  534:  #endif		
  535:  }     
  000c 81       RET   
  536:  /*-----------------------------------------------------------------------------
  537:  ROUTINE NAME    : SCI_IT_Function
  538:  INPUT           : None
  539:  OUTPUT          : None
  540:  DESCRIPTION     : Carries out communiction in Interrupt driven mode.
  541:  COMMENTS        : This function must be called inside the SCI interrupt service
  542:                    routine for Interrupt driven communication
  543:  -----------------------------------------------------------------------------*/
  544:  void  SCI_IT_Function (void)
  545:  {                                                 

Function: SCI_IT_Function
Source  : ..\..\source\sci.c
Options : -Cc -F7 -Lasm=%n.lst -Ml -N -Os -Ou -Of -Ol0 -OnPMNC -Or

  546:  /******************************************************************************
  547:  Reception in Interrupt Driven Without Buffer mode
  548:  ******************************************************************************/
  549:  
  550:  #ifdef SCI_ITDRV_WITHOUTBUF_RX 
  551:      unsigned char temp;  
  552:      if(SCISR & ORE)          /*If Interrupt is generated due to overrun error*/
  553:      {
  554:          SCI_Error = (unsigned char)(SCISR & SCI_ErrValue);
  555:          temp = SCIDR;	
  556:          SCI_Pol_Stat = 2;
  557:      } 
  558:      else if (SCISR & RDRF)
  559:      {        
  560:          if((SCI_Rx_String == 1) && (*PtrToSCIBuffRx != '\0') && (SCI_Error == 0))     
  561:                                                          /*If String Reception*/
  562:          {       
  563:              SCI_Error = (unsigned char)(SCISR & SCI_ErrValue);
  564:              *PtrToSCIBuffRx = SCIDR;      
  565:              if (*PtrToSCIBuffRx != '\0')
  566:              {
  567:                  PtrToSCIBuffRx++;
  568:              }		     
  569:              else
  570:              {
  571:                  SCICR2 &= (unsigned char)(~RDRF);   //Disableinterrupt
  572:              }    
  573:              SCI_Pol_Stat = 2;
  574:          }
  575:          else if ((SCI_Rx_Buff > 1) && (SCI_Error == 0))
  576:          {              
  577:              SCI_Error = (unsigned char)(SCISR & SCI_ErrValue) ;  
  578:              *PtrToSCIBuffRx = SCIDR;
  579:              SCI_Rx_Buff--;  
  580:              SCI_Pol_Stat = 2;                       /*If a buffer is received*/
  581:              PtrToSCIBuffRx++;  
  582:              if(SCI_Rx_Buff == 1)
  583:              { 
  584:                  SCICR2 &= (unsigned char)(~RDRF);   //Disableinterrupt
  585:              }    
  586:          }
  587:          else if ((SCI_Rx_Buff == 0) && (SCI_Rx_String == 0))  
  588:         /*If interrupt is generated before calling SCI_GetBuffer/SCI_GetString*/
  589:          {  
  590:              SCI_Error = (unsigned char)(SCISR & SCI_ErrValue) ;  
  591:              SCI_MY_DATA = SCIDR;
  592:              SCI_Pol_Stat = 1;
  593:          }                    
  594:          else
  595:          {   
  596:              SCI_Pol_Stat = 1;
  597:              temp = SCIDR;
  598:          }				
  599:      }	
  600:  #endif 
  601:  
  602:  /******************************************************************************
  603:  Transmission in Interrupt Driven without Buffer mode
  604:  ******************************************************************************/
  605:  
  606:  #ifdef SCI_ITDRV_WITHOUTBUF_TX 
  607:      if((SCISR & TC)&& (SCICR2 & TC))/*Checks if transmit complete flag is set*/
  608:      {      
  609:          if ((SCI_Tx_String == 1) && (*PtrToSCIBuffTx != '\0')) 
  610:                                     /*Checks if complete string is transmitted*/
  611:          {   
  612:              PtrToSCIBuffTx++;
  613:              SCIDR = *PtrToSCIBuffTx;
  614:              if (*PtrToSCIBuffTx == '\0')
  615:              {
  616:                  SCICR2 &= (unsigned char)(~TC);  
  617:                                 /*Disable IT if complete string is transmitted*/
  618:              } 
  619:          } 
  620:          else if (SCI_Tx_Buff > 1)   /*Checks if all the bytes are transmitted*/
  621:          {
  622:              SCI_Tx_Buff--; 
  623:              PtrToSCIBuffTx++;            /*Moves the pointer to next location*/
  624:              SCIDR = *PtrToSCIBuffTx;                /*Transmits a single byte*/
  625:          }                  	    
  626:          else if(SCI_Tx_Buff == 1)
  627:          {
  628:              SCI_Tx_Buff--;
  629:              SCICR2 &= (unsigned char)(~TC);     
  630:                                 /*Disable IT if complete string is transmitted*/
  631:          }
  632:      }
  633:      else if ((SCISR & TDRE)&&(SCICR2 & TDRE))    /*Checks if TDRE Flag is set*/
  634:      {           
  635:          if ((SCI_Tx_String == 1)&&(*PtrToSCIBuffTx != '\0')) /*Checks if complete 
  636:                                                          string is transmitted*/
  637:          {   
  638:             PtrToSCIBuffTx++;
  639:             SCIDR = *PtrToSCIBuffTx;
  640:             if (*PtrToSCIBuffTx == '\0')
  641:             {    
  642:                 Nop();
  643:                 SCICR2 &= (unsigned char)(~TDRE);
  644:                                 /*Disable IT if complete string is transmitted*/
  645:                 Nop();
  646:             }    
  647:  
  648:          }
  649:          else if (SCI_Tx_Buff > 1)   /*Checks if all the bytes are transmitted*/
  650:          {
  651:              SCI_Tx_Buff--; 
  652:              PtrToSCIBuffTx++;            /*Moves the pointer to next location*/
  653:              SCIDR = *PtrToSCIBuffTx;                /*Transmits a single byte*/
  654:          }
  655:          else if(SCI_Tx_Buff == 1)
  656:          {
  657:              SCI_Tx_Buff--;
  658:              SCICR2 &= (unsigned char)(~TDRE);
  659:                                 /*Disable IT if complete string is transmitted*/
  660:          } 
  661:      }	
  662:  #endif
  663:  }
  0000 81       RET   
  664:  /**** (c) 2002   STMicroelectronics *************************** END OF FILE **/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -