#include "Keyboard+EasyPOD.H"

void USB_Event( void );


//BYTE OutLen;
//BYTE OutBuffer[64];
//BYTE Modifier;
//BYTE MediaKey;


void main( void )
  { Initial();                                   // Do not remove
    while(1)
      { if ( InFlag )                            // Data size of "InLen" is already 
          { // To do..                           // in the "InBuffer[]"
            USB_Read_Data_Complete();            // Do not remove
          }
        
        // To do..
        
        /* Will send data to PC ?? If yes , enable the following function call */
        
        /* In order to gain the best performance, the value of "OutLen" should be  
           the multiple of 62. ( Exp: OutLen = 62, 124, 186, and ... ) */
        // USB_Send_Data_To_PC( OutLen , OutBuffer );
        
        /* Will send Key to PC ?? If yes , enable the following function call */
        // USB_Send_Key_To_PC( Modifier , OutLen , OutBuffer );
        
        /* Will send MediaKey to PC ?? If yes , enable the following function call */
        // USB_Send_MediaKey_To_PC( MediaKey );
        
        USB_Event();                             // Check USB power event
      }   
  }


void USB_Event( void )                           // Do not remove
  { if ( UsbEvent.Suspend == SET )               // Power down event from HOST
      { UsbEvent.Suspend = CLR;
        // To do..
        PCON |= 0x02;                            // MCU will into PowerDown mode
        UsbEvent.WakeUp = SET;
      }
    if ( UsbEvent.WakeUp == SET )                // MCU wakeup already
      { UsbEvent.WakeUp = CLR;
      	// To do..
      }
    if ( UsbEvent.Reset == SET )                 // Reset event from HOST
      { UsbEvent.Reset = CLR;
        // To do..
      }
    if ( UsbEvent.EmuOK == SET )                 // USB enumeration OK
      { // To do..
      }
    if ( UsbEvent.WakeupHost == SET )            // Device self wakeup
      { UsbEvent.WakeupHost = CLR;               // This flag SET by user ISR ( KeyPad/Uart/.. )
        if ( USB_WakeUp_Host() )                 // Wakeup host successful
          { // To do..
          }
        else                                     // Wakeup host fail 
          { // To do..
          }
      }
    if ( UsbEvent.KB_LED == SET )
      { UsbEvent.KB_LED = CLR;                   // Keyboard LED change by host
      	// To do..                               // Change the LED status base on KB_LED
      }
  }