Beispiel #1
0
/*
 * BlinkUSBStatus turns on and off LEDs
 * corresponding to the USB device state.
 *
 * mLED macros can be found in HardwareProfile.h
 * USBDeviceState is declared and updated in usb_device.c.
 */
void BlinkUSBStatus (void)
{
	static unsigned led_count = 0;

	if (led_count == 0) {
		led_count = 50000;
	}
	led_count--;

	if (USBDeviceState == CONFIGURED_STATE) {
		if (led_count == 0) {
			mLED_USB_Toggle();
		}
	}
}
Beispiel #2
0
// blink USB/Comms lights to show current status:
//
// USB blinking - powered by USB, comms over USB possible
// USB solid - powered by USB, comms over USB not possible
// Comms blinking - comms currently over USB
// if Comms and USB blink together we are in API mode, otherwise CLI
// FIXME: need a similar stategy for UART
// Comms solid - comms currently over UART
void BlinkCommsStatus(void)
{
    static unsigned int led_count=0;

    if(led_count == 0)
        led_count = 65535;

    led_count--;

    if(USBSuspendControl == 1)
    {
        if(led_count==0)
        {
            mLED_USB_Toggle();
            if(mGetLED_USB())
            {
                mLED_Comms_On();
            }
            else
            {
                mLED_Comms_Off();
            }
        }//end if
    }
    else
    {
        if(USBDeviceState == DETACHED_STATE)
        {
            mLED_Both_Off();
        }
        else if(USBDeviceState == ATTACHED_STATE)
        {
            mLED_Both_On();
        }
        else if(USBDeviceState == POWERED_STATE)
        {
            mLED_Only_USB_On();
        }
        else if(USBDeviceState == DEFAULT_STATE)
        {
            mLED_Only_Comms_On();
        }
        else if(USBDeviceState == ADDRESS_STATE)
        {
            if(led_count == 0)
            {
                mLED_USB_Toggle();
                mLED_Comms_Off();
            }//end if
        }
        else if(USBDeviceState == CONFIGURED_STATE)
        {
            if(led_count==0)
            {
                mLED_USB_Toggle();
                if(mGetLED_USB() ^ Interface)
                {
                    mLED_Comms_Off();
                }
                else
                {
                    mLED_Comms_On();
                }
            }//end if
        }//end if(...)
    }//end if(UCONbits.SUSPND...)

    // are we talking over UART?
    if (CommsChannel == COMMS_UART)
        mLED_Comms_On();

}