//----------------------------------------------------------------------------
// C main line
//----------------------------------------------------------------------------

#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules
#include <math.h>

struct I2C_Regs { // Example I2C interface structure
	BYTE fSync;
	WORD amplitude;
	float sinValue;
	} MyI2C_Regs;
float x = 0;
float PI = 3.1415926535897932f;
void main(void)
{
	// Set up RAM buffer
	EzI2Cs_SetRamBuffer(sizeof(MyI2C_Regs), 3, (BYTE *) &MyI2C_Regs);
	M8C_EnableGInt ; // Turn on interrupts
	EzI2Cs_Start(); // Turn on I2C
		
	while(1) { 
		if(MyI2C_Regs.fSync > 0)
		{
			x += PI / 36;
			MyI2C_Regs.sinValue =  MyI2C_Regs.amplitude*sin (x);
			MyI2C_Regs.fSync = 0;
		}
	}
}