#include <device.h>

#include <math.h>

struct I2C_Regs { // Example I2C interface structure
	int8 fSync;
    int16 amplitude;
	float sinValue;
	} MyI2C_Regs;
float x = 0;
float PI = 3.1415926535897932f;

void main()
{
	CYGlobalIntEnable;
	
    /* Turn on EZI2C */
	EZI2C_1_Start();  
        
    /* Set up Buffer1 */
    EZI2C_1_SetBuffer1(sizeof(MyI2C_Regs),3 , (void *) &MyI2C_Regs);
    
	for(;;)
    {    
    	if(MyI2C_Regs.fSync > 0)
		{
			x += PI / 36;
			MyI2C_Regs.sinValue =  MyI2C_Regs.amplitude*sin (x);
			MyI2C_Regs.fSync = 0;
		}
    }
}