16
CY3280-28XXX Universal CapSense® Controller Development Kit Guide, Spec. # 001-57457 Rev. **
Quick Start
2.3.5
Adding Code to main.c and Building the Project
1. In the Workspace Explorer window, double click
main.c
under
MyProject > Source Files
folder.
2. Select all text in
main.c
and delete it.
3. Add the following code:
#include <m8c.h> /* part specific constants and macros */
#include "PSoCAPI.h" /* PSoC API definitions for all User Modules */
WORD I2C_Buf[15]; /* buffer for EzI2C */
void main(void)
{
BYTE i;
EzI2Cs_1_SetRamBuffer(sizeof(I2C_Buf),sizeof(I2C_Buf),(BYTE *)I2C_Buf); /*
setup I2C buffer */
EzI2Cs_1_Start(); /* I2C start */
M8C_EnableGInt ; /* enable global interrupt */
CSD2X_1_Start(); /* CSD2X start */
CSD2X_1_InitializeBaselines(); /* initialize the baseline */
CSD2X_1_SetDefaultFingerThresholds(); /* set default finger threshold
*/
while(1)
{
CSD2X_1_ScanAllSensors(); /* scan all sensors */
CSD2X_1_UpdateAllBaselines(); /* update all baseline */
if( CSD2X_1_bIsSensorActive(0)) /* check the state of button0 */
LED_1_On(); /* turn on LED0 */
else
LED_1_Off(); /* turn off LED0 */
if( CSD2X_1_bIsSensorActive(1)) /* check the state of button1 */
LED_2_On(); /* turn on LED1 */
else
LED_2_Off(); /* turn off LED1 */
if( CSD2X_1_bIsSensorActive(2)) /* check the state of button2 */
LED_3_On(); /* turn on LED2 */
else
LED_3_Off(); /* turn off LED2 */
if( CSD2X_1_bIsSensorActive(3)) /* check the state of button3 */
LED_4_On(); /* turn on LED3 */
else
LED_4_Off(); /* turn off LED3 */
if( CSD2X_1_bIsSensorActive(4)) /* check the state of button4 */
LED_5_On(); /* turn on LED4 */
else
LED_5_Off(); /* turn off LED4 */
[+] Feedback