int main() { CyGlobalIntEnable; /* Uncomment this line to enable global interrupts. */ isr_1_StartEx(nunchuck_isr); VDAC_Start(); I2C_1_Start(); SendHandshake(); for(;;) { GetDataFromNunChuck(); CyDelay(1); int test = GetJoystickY(); VDAC_SetValue(test + 126); } }
/******************************************************************************* * 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 */