/*******************************************************************************
* Function Name: main
********************************************************************************
* Summary:
*  Main function performs following functions:
*   1. Enable global interrupts.
*   2. Initialize CapSense CSD and Start the sensor scanning loop.
*   3. Process scanning results and display it on with LEDs.
*
* Parameters:
*  None
*
* Return:
*  None
*
*******************************************************************************/
int main()
{
    /* Enable global interrupts */
    CyGlobalIntEnable;

    /* Start PWM and CapSense components */
    LED_CONTROL_Start();

    CapSense_CSD_Start();

    /* Initialize baselines */
    CapSense_CSD_InitializeAllBaselines();

    while(1u)
    {
        /* Check whether the scanning of all enabled widgets is completed. */
        if(0u == CapSense_CSD_IsBusy())
        {
            /* Update all baselines */
            CapSense_CSD_UpdateEnabledBaselines();

            /* Start scanning all enabled sensors */
            CapSense_CSD_ScanEnabledWidgets();
        }

        /* Display CapSense state using LEDs */
        CapSense_DisplayState();
    }
}
/*******************************************************************************
* Function Name:  CapSenseInit
********************************************************************************
*
* Summary:
*   Initializes CapSense  
*
* Parameters:  
*  None
*
* Return: 
*  None 
*  
*******************************************************************************/
void CapSenseInit(void)
{
    /* Start CapSense components */
    CapSense_CSD_Start();
    
    /* Initialize baselines */
    CapSense_CSD_InitializeAllBaselines();
}