#include <device.h>

extern int8  EzI2Cs_1_bRAM_RWcntr;
extern int8  EzI2Cs_1_bState;

struct I2C_Regs{
	uint16 iI2Cbuf[2];
}MyI2C_Regs;

//extern uint8 CapSense_CSD_SensorSignal[CapSense_CSD_TOTAL_SENSOR_COUNT];


void main()
{
	int8 i;
	int16 b;
    
    /* Enable global interrupts */
    CyGlobalIntEnable;

    /* Turn on EZI2C */
	EZI2C_Start();
    /* Set up Buffer1 */
    EZI2C_SetBuffer1(sizeof(MyI2C_Regs),1 , (void *) &MyI2C_Regs);
    
    /* Initialize CapSense CSD and Start the sensor scanning loop */
    /* Start CapSense and baselines */
    CapSense_CSD_Start(); 
    
    /* Initialize baselines */ 
    CapSense_CSD_InitializeAllBaselines();
    CapSense_CSD_InitializeAllBaselines();
    
    while(1u)
    {
        /* Update all baselines */
        CapSense_CSD_UpdateEnabledBaselines();
        
        MyI2C_Regs.iI2Cbuf[0]= CYSWAP_ENDIAN16(CapSense_CSD_ReadSensorRaw(0));
        MyI2C_Regs.iI2Cbuf[1]= CYSWAP_ENDIAN16(CapSense_CSD_ReadSensorRaw(1));
       
        /* Start scan all sensors */
        EZI2C_DisableInt();
        CapSense_CSD_ScanEnabledWidgets();
        while((CapSense_CSD_IsBusy()) != 0u);
        EZI2C_EnableInt();
    }
}


/* [] END OF FILE */
