示例#1
0
void LED_Init(void)
{
    LED_R_INIT();
    LED_G_INIT();
    LED_R_OFF();
    LED_G_OFF();
}
示例#2
0
文件: mytest.c 项目: nvero/fmhobby
//
// Call at 1ms ISR - Part of ISR 
// ISR complete within 5uS
//
void my_TMR_ISR(void)
{
	unsigned char tFS=0;
	static u32 tPACC=0;
	static unsigned char tLED=0;
	static unsigned int tTMR=0;

#ifdef debug_isr
	DEBUG_H();
#endif

	tTMR++;
	if (tTMR>=200)
	{
		// Generate Sync. Task Flag on Every 100mS
		// Decouple it from ISR
		mTask_Sync_Flag = 1;
		mTMR_100ms +=2;
		tTMR = 0;
	}


//	Phase Accumulator to generate Flow Sensor count
//	60000 phase unit per cycle
//	n 		delta phase unit = n count / min
//  1 		delta phase unit = 1 count / min
//  3000 	delta phase unit = 3000 counts / min

	mDP = mFR;
	tPACC += mDP;

	if (tPACC>=60000)
	{
		tPACC = 0;
	}

	if (tPACC<30000)
	{	FS_O = 1;
	}
	else
	{	FS_O = 0;
  	}

	// Flow Sensor Input 0
	tFS = FS_I0;
	if ((tFS != mFS_CNT[0][1]) && (tFS==1))
		mFS_CNT[0][0]++;
	mFS_CNT[0][1] = tFS;	

	// Flow Sensor Input 1
	tFS = FS_I1;
	if ((tFS != mFS_CNT[1][1]) && (tFS==1))
		mFS_CNT[1][0]++;
	mFS_CNT[1][1] = tFS;	

	// Flow Sensor Input 2
	tFS = FS_I2;
	if ((tFS != mFS_CNT[2][1]) && (tFS==1))
		mFS_CNT[2][0]++;
	mFS_CNT[2][1] = tFS;	


 	tLED ++;
	if (tLED>=16)
	{
		tLED = 0;
	}


	if (mLED[0]>tLED)
	{
		LED_R_ON();		

	}		
	else
	{
		LED_R_OFF();

	}

	my_printQ();

#ifdef debug_isr
	DEBUG_L();
#endif

}
示例#3
0
/***************************************************
 * Function:        void timer0_isr(void)
 *
 * OverView:		If low interrupt actived, called this function.
 *					Control LED
 *
 * Note:			reference BootLoader.h
 ***************************************************/
void timer0_isr(void)
{
	if(INTCONbits.TMR0IF)
	{
		INTCONbits.TMR0IF = 0;
		TMR0L = tmr0l_temp;

		if(!wg_ledCtrl)
		{
			if(wg_ledPwmDuty <= 0)
			{
				TMR0L = wg_ledPwmDuty;
				LED_WG_OFF();
			}

			else if(TMR0L == wg_ledPwmDuty)
			{
				TMR0L = 255 - wg_ledPwmDuty;
				LED_WG_ON();
			}
			else
			{
				TMR0L = wg_ledPwmDuty;
				LED_WG_OFF();
			}
		}
		else if(!r_ledCtrl)
		{
			if(r_ledPwmDuty <= 0)
			{
				TMR0L = r_ledPwmDuty;
				LED_R_OFF();
			}

			else if(TMR0L == r_ledPwmDuty)
			{
				TMR0L = 255 - r_ledPwmDuty;
				LED_R_ON();
			}
			else
			{
				TMR0L = r_ledPwmDuty;
				LED_R_OFF();
			}
		}
		else if(!g_ledCtrl)
		{
			if(g_ledPwmDuty <= 0)
			{
				TMR0L = g_ledPwmDuty;
				LED_G_OFF();
			}

			else if(TMR0L == g_ledPwmDuty)
			{
				TMR0L = 255 - g_ledPwmDuty;
				LED_G_ON();
			}
			else
			{
				TMR0L = g_ledPwmDuty;
				LED_G_OFF();
			}
		}
		else if(!b_ledCtrl)
		{
			if(b_ledPwmDuty <= 0)
			{
				TMR0L = b_ledPwmDuty;
				LED_B_OFF();
			}

			else if(TMR0L == b_ledPwmDuty)
			{
				TMR0L = 255 - b_ledPwmDuty;
				LED_B_ON();
			}
			else
			{
				TMR0L = b_ledPwmDuty;
				LED_B_OFF();
			}
		}
		else
		{
			TMR0L = tmr0l_temp;
			LED_WG_OFF();
			LED_R_OFF();
			LED_G_OFF();
			LED_B_OFF();
		}
		tmr0l_temp = TMR0L;
	}
}