コード例 #1
0
ファイル: main.c プロジェクト: ryood/PSoC4_DCO
int main()
{
    uint8 status = STS_CMD_FAIL;

    RGB_LED_OFF;
    
    /* Setup buffer and start EZI2C slave (SCB mode) */
    EZI2C_EzI2CSetBuffer1(BUFFER_SIZE, READ_ONLY_OFFSET, ezI2cBuffer);
    EZI2C_Start();
    
    CyGlobalIntEnable; /* Enable global interrupts. */

    for(;;)
    {
        /* Write complete: parse packet */
        if (0u != (EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_WRITE1))
        {
            /* Check start and end of packet markers */
            if ((ezI2cBuffer[PACKET_SOP_POS] == PACKET_SOP) &&
                (ezI2cBuffer[PACKET_EOP_POS] == PACKET_EOP))
            {
                status = ExecuteCommand(ezI2cBuffer[PACKET_CMD_POS]);
            }

            /* Update buffer with status */
            ezI2cBuffer[PACKET_STS_POS] = status;
            status = STS_CMD_FAIL;
        }

        /* Buffer is always available to be read */
    }
}
コード例 #2
0
ファイル: main.c プロジェクト: kmmankad/EzI2C_WaveformViewer
void main()
{
	ISR_UpBuff_Start(); //Start the Interrupt Component.
	ISR_UpBuff_SetVector(BufferUpdate);//Set Vector to the above ISR.
	
    CyGlobalIntEnable;//Enable Global Interrupts,EzI2C ad ADC require them.
	
	EZI2C_Start();//Start the EzI2C component.
	EZI2C_SetBuffer1(BUFFER_SIZE,BUFFER_RW_AREA_SIZE,(void *) (&EZI2C_Buffer));//Configure the Buffer for the EzI2C Component.
	
	ADC_Start();//Start the ADC
	ADC_IRQ_Enable();//Enable the EOC Interrupt
	ADC_StartConvert();//Start the Conversion
	
    for(;;);//Everything is done in the ISR.
}
コード例 #3
0
ファイル: main.c プロジェクト: spiricom/Birl
int main()
{
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
    EZI2C_Init();
    EZI2C_Start();
    CapSense_Start();
    CyGlobalIntEnable;
    CapSense_InitializeAllBaselines();
    EZI2C_EzI2CSetBuffer1(BUFFER_SIZE, BUFFER_SIZE, ezi2cBuffer);
    /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
    for(;;)
    {
           /* Update all baselines */
            CapSense_UpdateEnabledBaselines();
        
   		    /* Start scanning all enabled sensors */
    	    CapSense_ScanEnabledWidgets();   
    
            /* Wait for scanning to complete */
		
            while(CapSense_IsBusy() != 0)
            {
                ; //wait for the scan to finish
            }
            
            touched = CapSense_GetTouchCentroidPos(CapSense_TOUCHPAD0__TP, pos);
            
            
            ezi2cBuffer[0] = (uint8) pos[0];
            ezi2cBuffer[1] = (uint8) pos[1];
            ezi2cBuffer[2] = touched;
            
            //ezi2cBuffer[0] = i;
            //ezi2cBuffer[1] = i+1;
            //i++;
            XY_DATAREADY_Write(1);
            
            while (!(EZI2C_EzI2CGetActivity() & EZI2C_EZI2C_STATUS_READ1))
            {
                ; //wait for the data to be read from the master
            }
            
            XY_DATAREADY_Write(0);
            
    }
}
コード例 #4
0
ファイル: main.c プロジェクト: hakanjansson/psoc_nuggets
int main()
{
    uint8 interruptState;

    CyGlobalIntEnable; /* Enable global interrupts */
    
    EZI2C_Start(); /* Start EZI2C component */
    
    /*
    * Set up communication and initialize data buffer to CapSense data structure
    * to use Tuner application
    */
    EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam), sizeof(CapSense_dsRam),
                            (uint8 *)&CapSense_dsRam);

    CapSense_Start(); /* Initialize component */

    BleHandler_Init();
    Tuner_Init(BleHandler_RefreshBuffer, BleHandler_SendBuffer);

    CapSense_ScanAllWidgets(); /* Scan all widgets */

    for(;;)
    {
        /* Do this only when a scan is done */
        interruptState = CyEnterCriticalSection();
        if(CapSense_NOT_BUSY == CapSense_IsBusy())
        {
            CyExitCriticalSection(interruptState);
            CapSense_ProcessAllWidgets(); /* Process all widgets */
            Tuner_RunTuner();

            if (CapSense_IsAnyWidgetActive()) /* Scan result verification */
            {
                /* add custom tasks to execute when touch detected */
            }
            CapSense_ScanAllWidgets(); /* Start next scan */
        }
        CySysPmSleep(); /* Sleep until scan is finished */
        CyExitCriticalSection(interruptState);
    }
}
コード例 #5
0
ファイル: main.c プロジェクト: iotexpert/TheCreek
int main()
{
    dp.signedByte = -123;
    dp.unsignedByte = 234;
    dp.signedInt = -12345;
    dp.unsignedInt = 54321;
    dp.floatVariable = 1234.567;
    dp.doubleVariable = 7654321.1234;
    
    CyGlobalIntEnable; /* Enable global interrupts. */

    EZI2C_Start();
	EZI2C_EzI2CSetBuffer1(sizeof(dp),0,(uint8 *)&dp);
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

    for(;;)
    {
        /* Place your application code here. */
    }
}
コード例 #6
0
/*******************************************************************************
* Function Name: int  main( void )
********************************************************************************/
int main(void)
{
    uint32  i;
    
    CyGlobalIntEnable; /* Enable global interrupts. */

    EZI2C_Start();
    #ifdef ENABLE_TUNER
    EZI2C_EzI2CSetBuffer1(sizeof(CapSense_dsRam), sizeof(CapSense_dsRam),(uint8 *)&CapSense_dsRam);        
    #else
    EZI2C_EzI2CSetBuffer1(sizeof(I2Cbuf), RW, (void *) &I2Cbuf);     
    #endif   
    
    SmartIO_Start();    
    VDAC_Start();
    PVref_ALS_Start();
    Opamp_ALS1_Start();
    Opamp_ALS2_Start();
    PVref_Therm_Start();
    Opamp_Therm_Start();    
    ADC_Start();
    ADC_IRQ_Enable();
    
    CapSense_Start();   
    /* Over-ride IDAC values for buttons but keep auto for Prox and Humidity */
    CapSense_BUTTON0_IDAC_MOD0_VALUE =          7u;
    CapSense_BUTTON0_SNS0_IDAC_COMP0_VALUE =    6u;
    CapSense_BUTTON1_IDAC_MOD0_VALUE =          7u;
    CapSense_BUTTON1_SNS0_IDAC_COMP0_VALUE =    7u;
    CapSense_BUTTON2_IDAC_MOD0_VALUE =          9u;
    CapSense_BUTTON2_SNS0_IDAC_COMP0_VALUE =    7u;
    CapSense_BUTTON3_IDAC_MOD0_VALUE =          9u;
    CapSense_BUTTON3_SNS0_IDAC_COMP0_VALUE =    8u;
    /* Setup first widget and run the scan */    
    CapSense_SetupWidget(CapSense_BUTTON0_WDGT_ID);
    CapSense_Scan();      
    
    /* Start SysTick Timer to give a 1ms interrupt */
    CySysTickStart();
    /* Find unused callback slot and assign the callback. */
    for (i = 0u; i < CY_SYS_SYST_NUM_OF_CALLBACKS; ++i)
    {
        if (CySysTickGetCallback(i) == NULL)
        {
            /* Set callback */
            CySysTickSetCallback(i, SysTickISRCallback);
            break;
        }
    }
    
    /* Initialize I2C and local data registers to 0's */
    I2Cbuf.dacVal = 0.0;
    I2Cbuf.ledVal = 0x00;
    I2Cbuf.ledControl = 0x00;
    I2Cbuf.buttonVal = 0x00;
    I2Cbuf.temperature = 0.0;
    I2Cbuf.humidity = 0.0;
    I2Cbuf.illuminance = 0.0;
    I2Cbuf.potVal = 0.0;
    
    LocData.dacVal = 0.0;
    LocData.ledVal = 0x00;
    LocData.ledControl = 0x00;
    LocData.buttonVal = 0x00;
    LocData.temperature = 0.0;
    LocData.humidity = 0.0;
    LocData.illuminance = 0.0;
    LocData.potVal = 0.0;
    
    for(;;)
    {
        processButtons();  /* Mechanical buttons and bootloader entry */
        processCapSense(); /* CapSense Scanning */
        processDAC();      /* VDAC output voltage setting */
        processADC();      /* Process ADC results after each scan completes */
        processI2C();      /* Copy date between I2C registers and local operating registers */
    }
} /* End of main */