Cypress Semiconductor CapSense® Controller kit CY3280-BK1 CY3280-BK1 CY3280-BK1 Manual De Usuario

Los códigos de productos
CY3280-BK1
Descargar
Página de 26
22
CY3280-BK1 Universal CapSense Controller Quick Start, Doc. # 001-37959 Rev. **
Create a PSoC Designer CapSense Project
Add Code to main.c and Build the Project
5.35 Select View 
Application Editor.
5.36 Ensure the Project View button 
 is selected.
5.37 Double-click main.c under mydesignerproject files 
Source Files on the left.
5.38 Select all text in main.c and delete it.
5.39 Add the following code:
#include <m8c.h>
#include "PSoCAPI.h"
typedef struct I2C_regs {
BYTE button_state;
WORD button_raw_counts;
WORD button_baseline;
} I2C_REGS;
I2C_REGS reg_info;
void main()
{
EzI2Cs_1_SetRamBuffer(sizeof(reg_info), 0, (BYTE *) &reg_info);
M8C_EnableGInt;
EzI2Cs_1_Start();
CSA_1_Start();
CSA_1_InitializeBaselines();
CSA_1_SetDefaultFingerThresholds();
while (1)
{
CSA_1_ScanAllSensors();
CSA_1_UpdateAllBaselines();
CSA_1_bIsAnySensorActive();
M8C_DisableGInt;
reg_info.button_raw_counts = CSA_1_waSnsResult[0];
reg_info.button_baseline = CSA_1_waSnsBaseline[0];
reg_info.button_state = (CSA_1_baSnsOnMask[0] & 1);
M8C_EnableGInt;
if (reg_info.button_state == 1)
LED_1_On();
else
LED_1_Off();
}
}
5.40 Select Build 
Rebuild All and verify the compile finishes with no errors.