Ejemplo n.º 1
0
void LED_Init(void)
{
    LED_R_INIT();
    LED_G_INIT();
    LED_R_OFF();
    LED_G_OFF();
}
Ejemplo n.º 2
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;
	}
}