//------------------------------------------------------------------------------ // Cypress provided (C) 2005 framework for the FX2LP USB microcontroller. // All rights reserved. // Update from Piero Giubilato to fit the PARROT project. //------------------------------------------------------------------------------ //______________________________________________________________________________ // {Trace} // [File name] "FX2Hooks.c" // [Author] "Cypress" // [Modified by] "Piero Giubilato" // [Last revision] "02 Nov 2007" // [Language] "C Standard" // [Compiler] "Keil uVision 3.53" // [Member of] "FX2 Firmware" // [Project] "PARROT" // [Description] "This file contains the hooks called by the firmware framework // upon different USB status condition. The only relevant one used by the PARROT // system is the TD_Init, called once at startup, that is used to put the device // into a so-called Slave FIFO Mode by setting the internal registers as defined // inside SlaveFIFOMode.c" // [Key documentation] "Cypress EZ-USB Technical Reference Manual" // {Trace} //______________________________________________________________________________ //______________________________________________________________________________ // {Description} // // // // // // // {Description} //______________________________________________________________________________ #pragma NOIV // Do not generate interrupt vectors #include "fx2.h" #include "fx2regs.h" #include "syncdly.h" // SYNCDELAY macro extern BOOL GotSUD; // Received setup data flag extern BOOL Sleep; extern BOOL Rwuen; extern BOOL Selfpwr; BYTE Configuration; // Current configuration BYTE AlternateSetting; // Alternate settings // External functions void SlaveFIFOMode (void); // Set up the Slave FIFO Mode //------------------------------------------------------------------------------ // Task Dispatcher hooks // The following hooks are called by the task dispatcher. //------------------------------------------------------------------------------ // Called once at startup, this routine is used to initialize the system. // Here there is a call to the sub that contains all the settings necessary // to put the device in a SlaveFIFO mode (contained into SlaveFIFOMode.c). void TD_Init(void) { // Put the device into a FIFO Slave Mode SlaveFIFOMode(); } // Called repeatedly while the device is idle void TD_Poll(void) {} // Called before the device goes into suspend mode BOOL TD_Suspend(void) {return(TRUE);} // Called after the device resumes BOOL TD_Resume(void) {return(TRUE);} //------------------------------------------------------------------------------ // Device Request hooks // The following hooks are called by the end point 0 device request parser. //------------------------------------------------------------------------------ BOOL DR_GetDescriptor(void) {return(TRUE);} // Called when a Set Configuration command is received BOOL DR_SetConfiguration(void) { Configuration = SETUPDAT[2]; return(TRUE); // Handled by user code } // Called when a Get Configuration command is received BOOL DR_GetConfiguration(void) { EP0BUF[0] = Configuration; EP0BCH = 0; EP0BCL = 1; return(TRUE); // Handled by user code } // Called when a Set Interface command is received BOOL DR_SetInterface(void) { AlternateSetting = SETUPDAT[2]; return(TRUE); // Handled by user code } // Called when a Set Interface command is received BOOL DR_GetInterface(void) { EP0BUF[0] = AlternateSetting; EP0BCH = 0; EP0BCL = 1; return(TRUE); // Handled by user code } BOOL DR_GetStatus(void) {return(TRUE);} BOOL DR_ClearFeature(void) {return(TRUE);} BOOL DR_SetFeature(void) {return(TRUE);} BOOL DR_VendorCmnd(void) {return(TRUE);} //------------------------------------------------------------------------------ // USB Interrupt Handlers // The following functions are called by the USB interrupt jump table. //------------------------------------------------------------------------------ // Setup Data Available Interrupt Handler void ISR_Sudav(void) interrupt 0 { GotSUD = TRUE; // Set flag EZUSB_IRQ_CLEAR(); USBIRQ = bmSUDAV; // Clear SUDAV IRQ } // Setup Token Interrupt Handler void ISR_Sutok(void) interrupt 0 { EZUSB_IRQ_CLEAR(); USBIRQ = bmSUTOK; // Clear SUTOK IRQ } void ISR_Sof(void) interrupt 0 { EZUSB_IRQ_CLEAR(); USBIRQ = bmSOF; // Clear SOF IRQ } void ISR_Ures(void) interrupt 0 { // Whenever we get a USB reset, we should revert to full speed mode pConfigDscr = pFullSpeedConfigDscr; ((CONFIGDSCR xdata *) pConfigDscr)->type = CONFIG_DSCR; pOtherConfigDscr = pHighSpeedConfigDscr; ((CONFIGDSCR xdata *) pOtherConfigDscr)->type = OTHERSPEED_DSCR; EZUSB_IRQ_CLEAR(); USBIRQ = bmURES; // Clear URES IRQ } void ISR_Susp(void) interrupt 0 { Sleep = TRUE; EZUSB_IRQ_CLEAR(); USBIRQ = bmSUSP; } void ISR_Highspeed(void) interrupt 0 { if (EZUSB_HIGHSPEED()) { pConfigDscr = pHighSpeedConfigDscr; ((CONFIGDSCR xdata *) pConfigDscr)->type = CONFIG_DSCR; pOtherConfigDscr = pFullSpeedConfigDscr; ((CONFIGDSCR xdata *) pOtherConfigDscr)->type = OTHERSPEED_DSCR; } EZUSB_IRQ_CLEAR(); USBIRQ = bmHSGRANT; } void ISR_Ep0ack(void) interrupt 0 {} void ISR_Stub(void) interrupt 0 {} void ISR_Ep0in(void) interrupt 0 {} void ISR_Ep0out(void) interrupt 0 {} void ISR_Ep1in(void) interrupt 0 {} void ISR_Ep1out(void) interrupt 0 {} void ISR_Ep2inout(void) interrupt 0 {} void ISR_Ep4inout(void) interrupt 0 {} void ISR_Ep6inout(void) interrupt 0 {} void ISR_Ep8inout(void) interrupt 0 {} void ISR_Ibn(void) interrupt 0 {} void ISR_Ep0pingnak(void) interrupt 0 {} void ISR_Ep1pingnak(void) interrupt 0 {} void ISR_Ep2pingnak(void) interrupt 0 {} void ISR_Ep4pingnak(void) interrupt 0 {} void ISR_Ep6pingnak(void) interrupt 0 {} void ISR_Ep8pingnak(void) interrupt 0 {} void ISR_Errorlimit(void) interrupt 0 {} void ISR_Ep2piderror(void) interrupt 0 {} void ISR_Ep4piderror(void) interrupt 0 {} void ISR_Ep6piderror(void) interrupt 0 {} void ISR_Ep8piderror(void) interrupt 0 {} void ISR_Ep2pflag(void) interrupt 0 {} void ISR_Ep4pflag(void) interrupt 0 {} void ISR_Ep6pflag(void) interrupt 0 {} void ISR_Ep8pflag(void) interrupt 0 {} void ISR_Ep2eflag(void) interrupt 0 {} void ISR_Ep4eflag(void) interrupt 0 {} void ISR_Ep6eflag(void) interrupt 0 {} void ISR_Ep8eflag(void) interrupt 0 {} void ISR_Ep2fflag(void) interrupt 0 {} void ISR_Ep4fflag(void) interrupt 0 {} void ISR_Ep6fflag(void) interrupt 0 {} void ISR_Ep8fflag(void) interrupt 0 {} void ISR_GpifComplete(void) interrupt 0 {} void ISR_GpifWaveform(void) interrupt 0 {}