void BlinkUSBStatus(void) { static WORD led_count = 0; if (led_count == 0) led_count = 10000U; led_count--; #define mLED_Both_Off() \ { \ mLED_1_Off(); \ mLED_2_Off(); \ } #define mLED_Both_On() \ { \ mLED_1_On(); \ mLED_2_On(); \ } #define mLED_Only_1_On() \ { \ mLED_1_On(); \ mLED_2_Off(); \ } #define mLED_Only_2_On() \ { \ mLED_1_Off(); \ mLED_2_On(); \ } if (USBSuspendControl == 1) { if (led_count == 0) { mLED_1_Toggle(); if (mGetLED_1()) { mLED_2_On(); } else { mLED_2_Off(); } } } else { if (USBDeviceState == DETACHED_STATE) { mLED_Both_Off(); } else if (USBDeviceState == ATTACHED_STATE) { mLED_Both_On(); } else if (USBDeviceState == POWERED_STATE) { mLED_Only_1_On(); } else if (USBDeviceState == DEFAULT_STATE) { mLED_Only_2_On(); } else if (USBDeviceState == ADDRESS_STATE) { if (led_count == 0) { mLED_1_Toggle(); mLED_2_Off(); } } else if (USBDeviceState == CONFIGURED_STATE) { if (led_count < 100) { mLED_Both_On(); } else { mLED_Both_Off(); } } } }
/******************************************************************** * Function: void BlinkUSBStatus(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: BlinkUSBStatus turns on and off LEDs * corresponding to the USB device state. * * Note: mLED macros can be found in HardwareProfile.h * USBDeviceState is declared and updated in * usb_device.c. *******************************************************************/ void BlinkUSBStatus(void) { static WORD led_count=0; if(led_count == 0)led_count = 10000U; led_count--; #define mLED_Both_Off() {mLED_1_Off();mLED_2_Off();} #define mLED_Both_On() {mLED_1_On();mLED_2_On();} #define mLED_Only_1_On() {mLED_1_On();mLED_2_Off();} #define mLED_Only_2_On() {mLED_1_Off();mLED_2_On();} if(USBSuspendControl == 1) { if(led_count==0) { mLED_1_Toggle(); mLED_2 = mLED_1; // Both blink at the same time }//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_1_On(); } else if(USBDeviceState == DEFAULT_STATE) { mLED_Only_2_On(); } else if(USBDeviceState == ADDRESS_STATE) { if(led_count == 0) { mLED_1_Toggle(); mLED_2_Off(); }//end if } else if(USBDeviceState == CONFIGURED_STATE) { if(led_count==0) { mLED_1_Toggle(); mLED_2 = !mLED_1; // Alternate blink }//end if }//end if(...) }//end if(UCONbits.SUSPND...) }//end BlinkUSBStatus
// *--------------------------------------------------------------------------------* void BlinkUSBStatus(void){ static WORD led_count=0; if(led_count == 0)led_count = 50000U; led_count--; #define mLED_Both_Off() {LED1_OFF();LED2_OFF();} #define mLED_Both_On() {LED1_ON();LED2_ON();} #define mLED_Only_1_On() {LED1_ON();LED2_OFF();} #define mLED_Only_2_On() {LED1_OFF();LED2_ON();} if(USBSuspendControl == 1){ if(led_count==0){ LED1_TOGGLE(); if(LED1_READ()){ LED2_ON(); }else{ LED2_OFF(); } } }else{ if(USBDeviceState == DETACHED_STATE){ mLED_Both_Off(); }else if(USBDeviceState == ATTACHED_STATE){ mLED_Both_On(); }else if(USBDeviceState == POWERED_STATE){ mLED_Only_1_On(); }else if(USBDeviceState == DEFAULT_STATE){ mLED_Only_2_On(); }else if(USBDeviceState == ADDRESS_STATE){ if(led_count == 0){ LED1_TOGGLE(); LED2_OFF(); } }else if(USBDeviceState == CONFIGURED_STATE){ if(led_count==0){ LED1_TOGGLE(); if(LED1_READ()){ LED2_OFF(); }else{ LED2_ON(); } } } } }
void usb_tty_status(void) { static WORD led_count = 0; if (led_count == 0)led_count = 4U; led_count--; // verifica UCONbits.SUSPND if (USBSuspendControl == 1) { if (led_count == 0) { mLED_1_Toggle(); if (mGetLED_1()) { mLED_2_On(); } else { mLED_2_Off(); } } } else { if (USBDeviceState == DETACHED_STATE) { mLED_Both_Off(); } else if (USBDeviceState == ATTACHED_STATE) { mLED_Both_On(); } else if (USBDeviceState == POWERED_STATE) { mLED_Only_1_On(); } else if (USBDeviceState == DEFAULT_STATE) { mLED_Only_2_On(); } else if (USBDeviceState == ADDRESS_STATE) { if (led_count == 0) { mLED_1_Toggle(); mLED_2_Off(); } } else if (USBDeviceState == CONFIGURED_STATE) { if (led_count == 0) { mLED_1_Toggle(); if (mGetLED_1()) { mLED_2_Off(); } else { mLED_2_On(); } } } } }
void USB_blinkStatus(void) { static WORD led_count = 0; if (led_count == 0)led_count = 2000U; // Ajustado para USB low speed led_count--; if (USBSuspendControl == 1) { if (led_count == 0) { mLED_1_Toggle(); if (mGetLED_1()) { mLED_2_On(); } else { mLED_2_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_1_On(); } else if (USBDeviceState == DEFAULT_STATE) { mLED_Only_2_On(); } else if (USBDeviceState == ADDRESS_STATE) { if (led_count == 0) { mLED_1_Toggle(); mLED_2_Off(); }//end if } else if (USBDeviceState == CONFIGURED_STATE) { if (led_count == 0) { mLED_1_Toggle(); if (mGetLED_1()) { mLED_2_Off(); } else { mLED_2_On(); } }//end if }//end if(...) }//end if(UCONbits.SUSPND...) }//end BlinkUSBStatus
/******************************************************************** * Function: void BlinkUSBStatus(void) * * PreCondition: None * * Input: None * * Output: None * * Side Effects: None * * Overview: BlinkUSBStatus turns on and off LEDs * corresponding to the USB device state. * * Note: mLED macros can be found in HardwareProfile.h * USBDeviceState is declared and updated in * usb_device.c. *******************************************************************/ void BlinkUSBStatus(void) { static WORD led_count=0; char a=0; if(led_count == 0)led_count = 10000U; led_count--; #define mLED_Both_Off() {mLED_1_Off();mLED_2_Off();} #define mLED_Both_On() {mLED_1_On();mLED_2_On();} #define mLED_Only_1_On() {mLED_1_On();mLED_2_Off();} #define mLED_Only_2_On() {mLED_1_Off();mLED_2_On();} a = is_clear(); if(a=1) { mLED_3_On(); } else { mLED_3_Off(); } if(USBSuspendControl == 1) { if(led_count==0) { mLED_1_Toggle(); if(mGetLED_1()) { mLED_2_On(); } else { mLED_2_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_1_On(); } else if(USBDeviceState == DEFAULT_STATE) { mLED_Only_2_On(); } else if(USBDeviceState == ADDRESS_STATE) { if(led_count == 0) { mLED_1_Toggle(); mLED_2_Off(); }//end if } else if(USBDeviceState == CONFIGURED_STATE) { if(led_count==0) { mLED_1_Toggle(); if(mGetLED_1()) { mLED_2_Off(); } else { mLED_2_On(); } }//end if }//end if(...) }//end if(UCONbits.SUSPND...) }//end BlinkUSBStatus
// 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(); }