
Overview
========

 SmartSense user module has auto tuning algorithm built over the CSD capacitive
 sensing algorithm. Proper operation of CSD requires serveral parameters to be 
 configured depending on the value of parasitic capacitance which is called 
 Tuning. SmartSense algorithm optimize these parameters in runtime 
 automatically for each sensor. This project is an example for usage of 
 SmartSense user module. EzI2Cs user module is 	used in this project to send 
 the status information of each button & centroid position of slider to the I2C 
 master.
	
Operation
=========

 Upon program execution all hardware settings from the device configuration are
 loaded into the device and main.c is executed. SmartSense, EzI2Cs UMs are 
 initialized. All sensors are scanned continuously & I2C buffer is updated with 
 ON/OFF status of each button & centroid position of slider. When any button is 
 touched by the user, its corresponding LED is  turned ON. and it is turned OFF 
 when the button is released. When Slider is touched, One LED is turned on 
 depending on the finger position on slider.
	
Pin Assignment
==============

	P0[3] - Cmod		(Connect Capacitor, 2.2nF between Pin P0[3] & Gnd)
	P1[6] - SW0			(CapSense button 0)
	P1[3] - SW1			(CapSense button 1)
	P3[3] - SW2			(CapSense button 2)
	P2[1] - SW3			(CapSense button 3)
	P2[3] - SW4			(CapSense button 4)
	P1[4] - SLD0		(Slider Segment 0)
	P0[6] - SLD1		(Slider Segment 1)
	P0[4] - SLD2		(Slider Segment 2)
	P0[2] - SLD3		(Slider Segment 3)
	P2[6] - SLD4		(Slider Segment 4)
	P2[4] - SLD5		(Slider Segment 5)
	P2[2] - SLD6		(Slider Segment 6)
	P2[0] - SLD7		(Slider Segment 7)
	P3[2] - SLD8		(Slider Segment 8)
	P3[0] - SLD9		(Slider Segment 9)
	P2[5] - LED0		(Active Low)
	P2[7] - LED1		(Active Low)
	P0[1] - LED2		(Active Low)
	P0[5] - LED3		(Active Low)
	P1[2] - LED4		(Active Low)
	P1[0] - EzI2Cs SDA
	P1[1] - EzI2Cs SCL

Project Settings
================

 The following changes have to be made in the Device Editor:
  1. Selecting & placing user modules from "User Modules" catalog
      a. Select SmartSense under Cap Sensors & place it. Rename it to 
	    "SmartSense".
	  b. Select EzI2Cs under Digital Comm & place it. Rename it to "EzI2Cs".
  2. Configure the global resources & user modules settings as given below.
  3. Assign pins for buttons & slider segments from SmartSense wizard
  4. Assign pins for LED in Pinout section
 
 A. Global Resources
     IMO Setting  = 24MHz     ;System clock is set to 24MHz
  	 CPU_Clock    = SysClk/1  ;CPU clock set to 24 MHz
	 [leave all other parameters with default values]

 B. User Module parameter Settings
	-------------------------------------------------------------------------------------------------------------------
 	UM			Parameter 			Value 			Comments   
	-------------------------------------------------------------------------------------------------------------------
	SmartSense	        Sensors Autoreset	        Disabled        When the parameter is set to disabled, the baseline is updated only
	                                                                        when raw count & baseline difference is below the noise threshold 
							 			parameter.
														
				Debounce			3		Finger touch is taken as valid touch only if difference count is 
				                                                more than (finger threshold + Hysterisis) for at least 'Debounce'
						      			        number of times for successive samples. 
				
				ShieldElectrodeOut		None		Shield electrode is not used in this project. Jumper on CY3280-SLM 
				                                                module should be placed between GND & SHIELD.

				Sensor Sensitivity		0.3 pF		This parameter sets the threshold for increase in sensor 
									 	capacitance due to finger touch. If it exceeds the threshold, 
													button is considered to be active.

				Modulator capacitor		P0[3]		Tells which pin Cmod is connected to.

	-------------------------------------------------------------------------------------------------------------------
	
	EzI2Cs			Slave Address			04		This parameter decides the address that is assigned to the slave. 
										If we set Address_Type 	to 'Dynamic', this can be changed using API
										during runtime. Value assigned can be any vaue	from 0 to 7Fh.

				Address_Type			Static		If set to static, I2C address cannot be changed dynamically during 
										runtime, but, saves	one byte of RAM. Setting this option to dynamic 
										allows the firmware to change the address at any time.
														
				ROM Registers			Disable		If we set this to Enable, we can use RAM area as one slave and ROM 
										area as another slave with the addresses differing only by MSB of 
										7-bit address.
														
										MSB = 1 ---> ROM Regsters addressed.
										MSB = 0 ---> RAM area addressed.
														
										E.g: if slave address is 0x0A, RAM address=0x0A & ROM address=0x4A

				HW Addr Rec			Disable		This parameter enables/disables the hardware I2C slave address 
				                          
				
				I2C Clock			400k Standard	It decides the maximum clock speed that the slave can operate at.
										recognition feature.	
													
				I2C Pin				P1[0]-P1[1]	Pins assigned for SDA and SCL lines of I2C.
	-------------------------------------------------------------------------------------------------------------------

 C. Pin Drive modes
   	 1. I2C Lines
       	 Pin	    Select	            Drive
    	 ----------------------------------------------
    	 P1[0]	   I2C SDA	    	Open Drain Low
	 P1[1]	   I2C SCL		Open Drain Low
		 ----------------------------------------------
	 2. Sensor & LED
     	 Pin	    Select	            Drive
    	 ----------------------------------------------
		 P1[6]		SW0		 	HIGH Z Analog
		 P1[3]		SW1			HIGH Z Analog
		 P3[3]		SW2			HIGH Z Analog
		 P2[1]		SW3			HIGH Z Analog
		 P2[3]		SW4			HIGH Z Analog
		 P1[4]		SLD0		HIGH Z Analog
		 P0[6]		SLD1		HIGH Z Analog
		 P0[4]		SLD2		HIGH Z Analog
		 P0[2]		SLD3		HIGH Z Analog
		 P2[6]		SLD4		HIGH Z Analog
		 P2[4]		SLD5		HIGH Z Analog
		 P2[2]		SLD6		HIGH Z Analog
		 P2[0]		SLD7		HIGH Z Analog
		 P3[2]		SLD8		HIGH Z Analog
		 P3[0]		SLD9		HIGH Z Analog
		 P0[3]	   	Cmod		HIGH Z Analog
		 P2[5]		LED0		STRONG, Initial Value=1
		 P2[7]		LED1		STRONG, Initial Value=1
		 P0[1]		LED2		STRONG, Initial Value=1
		 P0[5]		LED3		STRONG, Initial Value=1
		 P1[2]		LED4		STRONG, Initial Value=1
		
