Beispiel #1
0
void usb_init(void)
{
    /* Start USB operation with 5-V operation. */
    USB_Start(0u, USB_5V_OPERATION);

    /* Wait for device to enumerate */
    while (0u == USB_GetConfiguration())
    {
        wait_ms(100);
    }
    host_set_driver(psoc_driver());
    // Start listening!
    USB_EnableOutEP(INBOX_EP);


}
Beispiel #2
0
/*******************************************************************************
* Function Name: USB_CyBtldrCommReset.
****************************************************************************//**
*
*  This function resets receive and transmit communication buffers.
*
* \reentrant
*  No
*
*******************************************************************************/
void USB_CyBtldrCommReset(void) 
{
    USB_EnableOutEP(USB_BTLDR_OUT_EP); 
}
Beispiel #3
0
void acknowledge_command(void)
{
    message_for_you_in_the_lobby = false;
    USB_EnableOutEP(INBOX_EP);
}
Beispiel #4
0
void main(void)  
{
    // Initialize Pull Up/Down ressistors
    //Port_0_Data_SHADE = 0x80;                     // Enable distance input pull-up P0.7
    //PRT0DR = Port_0_Data_SHADE;
    Port_2_Data_SHADE = 0x04;                     // Enable pull-down resistor on LED P2.2
    PRT2DR = Port_2_Data_SHADE;
    Port_3_Data_SHADE = 0x20;                     // Enable pull-up on button bit P3.5 
    PRT3DR = Port_3_Data_SHADE;
    Port_4_Data_SHADE = 0x44;						// Enable pull-down LED P4.2, P4.6
    PRT4DR = Port_4_Data_SHADE;

    Timer8_WritePeriod(50);				// 12MHz/15/16/50 = 1KHz => 1ms main timer interrupt
    Timer8_WriteCompareValue(0);
    Timer8_EnableInt();
    Timer8_Start();
	PRS8_WritePolynomial(0x78);			// load the PRS polynomial
	PRS8_WriteSeed(0xFF);				// load the PRS seed
	PRS8_Start();						// start the PRS8
	RED_Start();
	GREEN_Start();
	BLUE_Start();
    PWM8_WritePeriod(100);				// set period to eight clocks
    PWM8_WritePulseWidth(0); 			// set pulse width to generate a % duty cycle 
    PWM8_EnableInt(); 					// ensure interrupt is enabled  
    PWM8_Start();						// start PWM 
    //DAC_CR &= ~0x80;	                // turn off SplitMUX bit 7 (P0[7] on right, others on left)    
    PGA_Start(PGA_HIGHPOWER);           // Start PGA
    ADCINC_Start(ADCINC_HIGHPOWER);     // Start ADC
    ADCINC_GetSamples(1);               // initiate the first sample
	
    M8C_EnableGInt;						// Global interrupt enable
  
	ReadFlash();						// read on/off times and LED dutycyle from FLASH
    if(!(RamFlashBlock.Dummy == 0x55))
    {
        SetFlashDefaults();             // clear flash first time
    } 

	LedPowerTog = 1;						// flag change				
	LedPower = RamFlashBlock.PowerState;
    RedDutyMax = RamFlashBlock.RedDuty;
    BlueDutyMax = RamFlashBlock.BlueDuty;
    GreenDutyMax = RamFlashBlock.GreenDuty;
	the_state = RamFlashBlock.the_state;		
	ledChangeRate = RamFlashBlock.ledChangeRate;
	
    Events.press = 0;
    Events.hold = 0;
    Events.release = 0;  	
    MenuFsm(&Events, &the_state);       // initlaize the state machine 
	
    USB_Start(0, USB_3V_OPERATION);     // Start USB
    //while (!USB_bGetConfiguration());   // Wait to be enumerated
    USB_INT_REG |= USB_INT_SOF_MASK;
    USB_EnableOutEP(1);                 // Post a buffer to wait for a command
			    
    while(1)                            // cycle the puck here
    {       
        MeasureTemperature();               // sample input temperature sensor voltage
        ThermalProtection();                 // decrease LED power if temperature rises above limit
		ButtonStates();                    // button driver
        CommunicateUSB();                       // USB driver
		LedStates();						// LED Cadence state machine
		DelayedSaveFlash();					// Save power state and RGB dutycycle 10 seconds after last button event
	}
}          
Beispiel #5
0
void main()
{

   
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    CyGlobalIntEnable;  /* Uncomment this line to enable global interrupts. */
    init();
    // Start usb operation with 3V
    
    
    //Wait for device to enumerate
    USB_Start(0u,USB_3V_OPERATION);
    while(!USB_bGetConfiguration());
    
    //Enumeration i done, enable out endpoint for recieve data from host
    USB_EnableOutEP(2);
    
    ADC_StartConvert();
    
    
      while(1)
    {
        //wait for data
        while(USB_bGetEPState(2) !=USB_OUT_BUFFER_FULL);
        
        //read received bytes count
        length = USB_wGetEPCount(2);
        //turn on LED
        LED_Write(~LED_Read());
        
        //unload the out buffer
        USB_ReadOutEP(2, &buffer[0], length);
        
       // check for in buffer is empty
       while(USB_bGetEPState(1) != USB_IN_BUFFER_EMPTY);
       // Turn off LED
       
       
       // load the in buffer
       USB_LoadInEP(1, &buffer[0], length);
       while(USB_bGetEPState(1) != USB_IN_BUFFER_EMPTY);
        USB_LoadInEP(1, &buffer[1], length);
    
    
    }
    for(;;)
    {
    
        
   
        
    }
    
    
    
    
    
    /*
    while(!USB_bGetConfiguration());
    
    //Enumeration i done, enable out endpoint for recieve data from host
    USB_EnableOutEP(2);
    
    
    while(1)
    {
        //wait for data
        while(USB_bGetEPState(2) !=USB_OUT_BUFFER_FULL);
        
        //read received bytes count
        length = USB_wGetEPCount(2);
        //turn on LED
        LED_Write(~LED_Read());
        
        //unload the out buffer
        USB_ReadOutEP(2, &buffer[0], length);
        
       // check for in buffer is empty
       while(USB_bGetEPState(1) != USB_IN_BUFFER_EMPTY);
       // Turn off LED
       
       
       // load the in buffer
       USB_LoadInEP(1, &buffer[0], length);
    
    
    }*/
    
    
    /*
        if( ADC_IsEndConversion(ADC_WAIT_FOR_RESULT))
       {
            //LCD_ClearDisplay();
            //LCD_PrintNumber(ADC_GetResult16());
            //CyDelay(250);
            
            Pin_1_Write(~Pin_1_Read());
            
            //buffer[count]=ADC_GetResult8();
            buffer[count]=count;
            ++count;
            USB_LoadInEP(1,&buffer[0],1);
            
            if (count==64)
            {
                // load the in buffer
             *?   //USB_LoadInEP(1, &buffer[0], 64);
                count=0;
            }
            
        }
        */
}