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

📄 etpuc_qom.c

📁 mpc55**系列芯片的例程 包括SCI,SPI,TIMER,FIT,EDMA等几乎所有功能的实现
💻 C
📖 第 1 页 / 共 3 页
字号:
|                  pending matches. This could happen if the channel was    |
|                  running another function before this one.                |
|              2. Disable transition detection and clear the transition     |
|                 latch.                                                    |
|              2a.Initialise Overrun variable to 0.                         |
|              3. Configure channel to use TCR1/2 as per Option register    |
|              4. Generate time reference variable as follows               |
|                  If immediate mode ertb takes value of selected           |
|                  timebase                                                 |
|                  If last event mode ertb takes value of last recorded     |
|                  match event                                              |
|                  If reference address mode ertb takes value of contents   |
|                  of reference address pointer                             |
|              5. Get offsets and future pin states for first and second    |
|                 matches from table                                        |
|              6. Program ertb/erta and future pins action accordingly      |
|              7. Update Current_Match_Ptr.                                 |
|              8. Schedule 1st and 2nd matches.                             |
|              9. Enable match and transition event handling                |
|              10. Configure channel mode , PDCM = em_nb_st                 |
|              11. Clear link service request latch                         |
|              12. Clear channel flag0                                      |
+--------------------------------------------------------------------------*/
    else if( HostServiceRequest == INIT_PIN_NO_CHANGE )
    {
	DisableMatchesInThread();

Initialise_QOM:
	Overrun=0;
  EnableOutputBuffer();

	if ((Option & 0x80 ) != FALSE ) /*use tcr2*/
	{
	    ActionUnitA( MatchTCR2, CaptureTCR2, GreaterEqual);
	    ActionUnitB( MatchTCR2, CaptureTCR2, GreaterEqual);
	    ertb = tcr2; /*default immed.*/
	}
	else /*use TCR1 */
	{
	    ActionUnitA( MatchTCR1, CaptureTCR1, GreaterEqual);
	    ActionUnitB( MatchTCR1, CaptureTCR1, GreaterEqual);
	    ertb = tcr1; /*default immed.*/
	}
	if ((Option & 0x1) != FALSE) /*mode other than immed.?*/
	{
	    if ((Option & 0x2) != FALSE )
	    {
		ertb  = *Ref_Addr_ptr; /*over write default (immed.)*/
	    }
	    else
	    {
		ertb  = Last_Match_Time; /*over write default (immed.)*/
	    }
	}
	Offset = *Table_Start_Ptr; /*get first offset plus next pin state*/
	Offset = Offset >>1;
	if (CC.C ==1)
	{
	    OnMatchB(PinHigh);
	}
	else
	{
	    OnMatchB(PinLow);
	}
	ertb = ertb  + Offset; /*update erta with first value*/

	Current_Match_Ptr = Table_Start_Ptr + 4; /*increment pointer*/
	Offset = *Current_Match_Ptr; /*get 2nd offset*/
	Offset = Offset >>1;
	if (CC.C ==1)
	{
	    OnMatchA(PinHigh);
	}
	else
	{
	    OnMatchA(PinLow);
	}
	erta = ertb + Offset; /*update ertb with second value*/

	EitherMatchNonBlockingSingleTransition();

	ConfigMatch_AB();

	OnTransA(NoDetect);
	OnTransB(NoDetect);
	Clear(TransLatch);
	Clear(LSRLatch);
	Set(flag0);
    }
/*--------------------------------------------------------------------------+
| THREAD NAME: SERVICE_LINK                                                 |
| DESCRIPTION: Run queue when a link service request is received            |
|              1. Matches are disabled in this thread                       |
|              2. If LSR_flag is set (i.e. link has been initialised) then  |
|                 proceed as per INIT_NC                                    |
|              3. Otherwise ignore LSR (clear link service latch and exit)  |
*----------------------------------------=----------------------------------*/
    else if (IsLinkServiceRequestEvent())
    {
	DisableMatchesInThread();
	if ((Option & 0x40) != FALSE) /*only service if LSR_flag is armed*/
	{

	   goto Initialise_QOM;

	}
	else
	{
	    Clear(LSRLatch);
	}
    }
/*--------------------------------------------------------------------------+
| THREAD NAME: DOUBLE_MATCH_0                                               |
| DESCRIPTION: This thread occurrs when a match exists on both Action unit A|
|              and action unit B.  and channel flag0 is 0. A match will be  |
|              scheduled for action unit A leaving MatchB unserviced        |
|              1. erta or B already contains the match time which caused    |
|                 this thread                                               |
|              3. If continuous mode and Current_Match_Ptr has overflowed   |
|                 point it to start of table                                |
|              4. If looping and loop iterations are complete then:         |
|                    Set channel flag0                                      |
|                    Record last match event time (in Last_Match_Time)      |
|                    Clear match on action unit A                           |
|                    If Overrun =1                                          |
|                      (i.e. the last match in the queue ahs been serviced) |
|                         Set Interrupt and DMA request bits                |
|                         Clear Link Service Request Event register.        |
|                         Clear LSR_flag.                                   |
|                    Increment Overrun                                      |
|                    Schedule no more matches and exit thread               |
|              5. If loop mode and Current_Match_Ptr has overflowed         |
|                 point it to start of table and decrement loop counter     |
|              6. If in single shot mode and Current_Match_Ptr has          |
|                 overflowed                                                |
|                    Set channel flag0                                      |
|                    Record last match event time (in Last_Match_Time)      |
|                    Clear match on action unit A                           |
|                    If Overrun =1                                          |
|                      (i.e. the last match in the queue ahs been serviced) |
|                         Set Interrupt and DMA request bits                |
|                         Clear Link Service Request Event register.        |
|                         Clear LSR_flag.                                   |
|                    Increment Overrun                                      |
|                    Schedule no more matches and exit thread               |
|              7. Clear exisitng match and schedule future match according  |
|                 to next queue entry                                       |
|              8. Set channel flag0                                         |
+--------------------------------------------------------------------------*/
    else if( m1==1 && m2==1  && (flag0==0) )
    {
Service_single_match0	:
	/*read_match() not required as Thread entered because of double match; so erta & ertb already hold value of last matches.*/
	Current_Match_Ptr++ ; /*increment pointer*/
	if ( IsLatchedFuncMode1() ) /*continuous mode FM=10|11 */
	{
	    if (Current_Match_Ptr > Table_End_Ptr)
	    {
		Current_Match_Ptr = Table_Start_Ptr;
	    }
	}
	else /* FM = 0x*/
	{
	    if (IsLatchedFuncMode0()) /*loop mode FM=01*/
	    {
		if (Loop ==1 )
		{
Done0:
		    if (Current_Match_Ptr > Table_End_Ptr)
		    {
			Set(flag0);
			ClearMatchAEvent();
			Last_Match_Time = erta;
			goto Clear_Matches0;
		    }
		}
		else
		{
		    if (Current_Match_Ptr > Table_End_Ptr)
		    {
			Current_Match_Ptr = Table_Start_Ptr;
			Loop--;
		    }
		}
	    }
	    else /*  single shot FM=00*/
	    {
		goto Done0;
	    }
	}
	Offset= *Current_Match_Ptr;
	Offset = Offset >>1;
	if (CC.C ==1)
	{
	    OnMatchA(PinHigh);
	}
	else
	{
	    OnMatchA(PinLow);
	}
	erta = ertb + Offset ; /*update ertb with next value*/
	ClearMatchAEvent();
	WriteErtAToMatchAAndEnable();
	Set(flag0);
    }
/*--------------------------------------------------------------------------+
| THREAD NAME: DOUBLE_MATCH_1                                               |
| DESCRIPTION: This thread occurrs when a match exists on both Action unit A|
|              and action unit B.  and channel flag0 is 1. A match will be  |
|              scheduled for action unit B leaving MatchA unserviced        |
|              1. erta or B already contains the match time which caused    |
|                 this thread                                               |
|              3. If continuous mode and Current_Match_Ptr has overflowed   |
|                 point it to start of table                                |
|              4. If looping and loop iterations are complete then:         |
|                    Clear channel flag0                                    |
|                    Record last match event time (in Last_Match_Time)      |
|                    Clear match on action unit B                           |

⌨️ 快捷键说明

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