/******************************************************************************* * Function Name: USB_CyBtldrCommStop. ****************************************************************************//** * * This function performs all necessary shutdown tasks required for the USBFS * component. * * \sideeffect * Calls the USBFS_Stop() function. * *******************************************************************************/ void USB_CyBtldrCommStop(void) { USB_Stop(); }
void CommunicateUSB(void) { if (SOF_Flag) { char temp; // Arrive here every 1 msec SOF_Flag = 0; // send data to PC buttons_report[0] = debounced_state; buttons_report[1] = RedDuty; buttons_report[2] = GreenDuty; buttons_report[3] = BlueDuty; buttons_report[4] = Temperature; buttons_report[5] = Temperature+1; buttons_report[6] = Temperature+2; buttons_report[7] = Temperature+3; USB_LoadInEP(1, &buttons_report[0], 8, USB_TOGGLE); // receive data from PC lights_report = USB_INTERFACE_0_OUT_RPT_DATA[0]; // Control input from PC RedDutyMax = USB_INTERFACE_0_OUT_RPT_DATA[1]; // Red brightness from PC GreenDutyMax = USB_INTERFACE_0_OUT_RPT_DATA[2]; // Green brightness from PC BlueDutyMax = USB_INTERFACE_0_OUT_RPT_DATA[3]; // Blue brightness from PC temp = USB_INTERFACE_0_OUT_RPT_DATA[4]; // temp = USB_INTERFACE_0_OUT_RPT_DATA[5]; // temp = USB_INTERFACE_0_OUT_RPT_DATA[6]; // temp = USB_INTERFACE_0_OUT_RPT_DATA[7]; // if(USB_Tog != (lights_report & USB_AUTO_MASK)) // USB Auto status bit toggles { // if software is running USB_Tog = (lights_report & USB_AUTO_MASK); // mask for auto bit USBTimer = 255; // reset watchdog counter } if(USBTimer) { Auto = 0; // PC is in control if(lights_report & USB_BOOT_MASK) // USB Boot status bit { // Stop everything USB_Stop(); Timer8_Stop(); PRS8_Stop(); RED_Stop(); GREEN_Stop(); BLUE_Stop(); PWM8_Stop(); PGA_Stop(); ADCINC_Stop(); M8C_DisableGInt; // Global interrupt disable USB_EnterBootloader(); } if(lights_report & USB_LED_MASK) // USB LED status bit { LedPower = 1; // turn LEDs on LedPowerTog = 1; // flag change } else { LedPower = 0; // turn LEDs on LedPowerTog = 1; // flag change } PRT2DR = Port_2_Data_SHADE; // update port2 } else { Auto = 1; // auto (software not running) RedDutyMax = RamFlashBlock.RedDuty; // reset dutycycle BlueDutyMax = RamFlashBlock.BlueDuty; GreenDutyMax = RamFlashBlock.GreenDuty; } } }