Capacitive Touch API User’s Manual December 5, 2014

3y ago
48 Views
2 Downloads
1.13 MB
14 Pages
Last View : 7d ago
Last Download : 4m ago
Upload by : Audrey Hope
Transcription

RX113 FamilyCapacitive Touch API User’s ManualEU00162Rev.1.00December 5, 2014IntroductionThe Renesas Capacitive Touch Application Program Interface (API) has been created to allow users of the CapacitiveTouch Sensing Unit (CTSU) on the RX113 Group devices to easily add capacitive touch handling capability into theirapplication. This application note focuses on using the API and integrating it with your application program.This API requires the hardware configuration for the CTSU module.The API source files comply with the Renesas RX compiler only.Target DeviceThe following is a list of devices able to use this API: RX113 GroupWhen using this application note with other Renesas MCUs, careful evaluation is recommended after makingmodifications to comply with the alternate MCU.Related Documents Firmware Integration Technology User’s Manual (R01AN1833EU) Board Support Package Firmware Integration Technology Module (R01AN1685EU) Adding Firmware Integration Technology Modules to Projects (R01AN1723EU) RX113 Capacitive Touch Evaluation System Quick Start Guide (EU00161)Contents1.Overview . 22.API Information. 33.Usage Notes. 54.Demo Project. 11Website and Support . 12EU00162 Rev.1.00August 12, 2014Page 1 of 12

Capacitive Touch API1. OverviewThis API is written to configure the CTSU peripheral on the Renesas MCUs. The API also provides the user withability to perform simple processing on measurements made by the CTSU for each channel and then treat each channelas a Touch Button, or group channels and use them as linear or circular sliders. The API inherently depends on the userto provide valid configuration values for each Special Function Register (SFR) of the CTSU. The user should obtainthese values by performing calibration with software such as Workbench 6. The demonstration projects provided withthis API provide an example of how the API uses the calibrated configuration values, a simple filter technique tosmooth data measured for each channel, and determine if a channel is being touched. The user can evaluate thesedemonstrations with the RX113 CapTouch MCU Board and it’s daughter boards.1.1FeaturesBelow is a list of the features supported by the Touch API.1.2 Initialize the CTSU hardware Configure for either self-capacitance measurement or mutual capacitance measurement mode Provide hooks to use parameters generated by Capacitive Touch calibration software Read and modify internal threshold and filtering parameters Selectively enable and disable channels Enable and disable drift compensationOverall File structureThe API structure is as follows:r ctsu rel – Contains a modified Workbench6 project as a base for driving the overall capactive touch sensing solution.r touch – The lower layer containing calls into the r ctsu rel layer which is responsible for controlling the CTSUoperation.r touch button – Layer which uses the functions and variables located in r touch and r ctsu rel to monitor and reportthe status of touch sensing channels which are intended to operate as buttons.r touch slider – Layer which uses the functions and variables located in r touch and r ctsu rel to monitor and reportthe status of touch sensing channels which are logically and physically grouped to operate as linear slider or circularslider (wheel).EU00162 Rev.1.00August 12, 2014Page 2 of 12

Capacitive Touch API2. API InformationThis Middleware API follows the Renesas API naming standards.2.1Hardware RequirementsThis middleware requires your MCU support the following peripherals: 2.2CTSU module peripheralHardware Resource RequirementsThis section details the hardware peripherals that this middleware requires. Unless explicitly stated, these resourcesmust be reserved for the middleware and the user cannot use them 2.3Capacitive Touch Sensing Unit (CTSU)Software RequirementsThe API uses a modified Workbench 6 project located under r ctsu rel.2.4Supported ToolchainsThis middleware is tested and working with the following toolchains: 2.5Renesas RX Toolchain v2.10Header FilesThere are three header files which contain API calls available to the user. These are: r touch if.h r touch button if.h r touch slider if.hThe API configuration header files allow the user to change the following parameters. The effect of modifying thesefiles reflects in the private files for each layer. The configuration files are as follows: r touch config.h – Allows the user to enable or disable parameter checks r touch button config.h – Allows the user to specify individual or default values for the following: oTransmit and Receive channel number for each buttonoDebounce counteroRepeat delay counteroRepeat rate countoNumber of scans for which button is determined as pressed before generating a short hold eventoNumber of scans for which button is determined as pressed before generating a long hold eventoEnable/disable events for press, short press-and-hold, long press-and-hold, repeat events on pressperiodicallyoFunction to call when an event occursr touch slider config.h – Allows the user to specify default values used in the slider position calculations. Thevalues configured are the following:oSlider type – Linear or CircularoChannels used for the slideroMaximum value generated after normalizationoApply normalization to the channel dataoValue used for normalizationEU00162 Rev.1.00August 12, 2014Page 3 of 12

Capacitive Touch APIoWeight of running average for each channel, used to smooth data.oWeight of running average for previous sum of focus channels used as cutoff threshold.oAbsolute threshold for sum of slider valuesEU00162 Rev.1.00August 12, 2014Page 4 of 12

Capacitive Touch API3. Usage NotesThe R Touch API is intended to be used with a workbench 6 project which configures the CTSU for measurement andupdates variables which monitor the status of touch on Touch Sense channels which are enabled.3.1R TouchThe R Touch layer is responsible for controlling the CTSU operation and generates data to be used by higher layers.The R Touch layer accesses functions and variables defined in the r ctsu rel layer to control operation of the CTSU.The user can access some of the important configuration settings created by workbench through the R Touch Openfunctions using arguments. Values returned to the user include settings for intial thresholds, hysteresis, and SFR valuesfor diffusion control, offset0, and offset1 which are unique for each channel. The user may also specify a callbackfunction which will be executed once a single scan cycle is completed. The callback function is called from an interrupt.The user is therefore advised to avoid while loops and limit the amount of processing performed within this function.The callback function should be ideally used to unlock semaphores and indicate to other entities that a scan hascompleted. The R Touch Open function also initializes the CTSU by means of the r ctsu rel layer.After the CTSU has been initialized, the user must call the R Touch Process periodically with the optionTOUCH OPTION AUTO SCAN to enable a new scan cycle after all post measurement processing is complete. If theuser provides the first argument which is not a NULL pointer, then the function returns the location which contains theraw result data.Additionally, the R Touch Read function allows the user to access the current value of variables such as thedifference between the reference count and the sensor count (delta count), or the Touch judgment counter.3.2R Touch ButtonThe R Touch Button layer is created to process data from a channel and treat it as a button. Global variables presentwithin the r ctsu rel directory are constantly modified when the CTSU is operational. The R Touch Button layeraccesses the needed values from the lower layers and determines whether a channel is being touched. Depending uponthe configuration of each button, multiple events can be triggered when the corresponding conditions are valid. Theprimary tasks that a user may need are detailed below.3.2.1Adding a buttonIn order to add a button, one needs to first configure/calibrate a CTSU channel as a button using the Workbench 6software. The lower level functions which process buttons are KeyProcess(), and KeyCalibrationProcess(). Thesefunctions eventually update bits in g real touch info and g touch result depending upon whether a channel is beingtouched. The API will fail to report the correct status of the button if configuration and calibration of the CTSU channelis not performed using Workbench 6.Once calibration and configuration with Workbench 6 has been performed, the user can then modify the configurationfiles controlling the API. The configuration file for buttons is r touch button config.h and should be located underthe r config directory. One may use the r touch button config reference.h file as a starting point which uses theRX113 Captouch Wheel/Slider/Buttons daughter board configuration.To add a new button in Self-Capacitance mode, simply add to the configuration file the following statement:#define TOUCH BUTTON CFG BUTTONn CHANNEL RX(m)Where n is a number from 0 to the maximum number of channels available with the CTSU (and configured withWorkbench 6). And m is the touch sensor channel number (TSm).To add a new button in mutual capacitance mode, add the following two statements to the configuration file:#define TOUCH BUTTON CFG BUTTONn CHANNEL TX(p)#define TOUCH BUTTON CFG BUTTONn CHANNEL RX(m)Where p is the channel acting as the transmit electrode for the button with m p.Repeat this procedure for all buttons configured in Workbench 6.3.2.2Configuring a buttonOnce a button has been added, additional configuration options are available to further modify the behavior of all oreach individual button. If all buttons are expected to exhibit similar behavior then preprocessor definitions under basicconfiguration options should be modified. These adjustments are as below:EU00162 Rev.1.00August 12, 2014Page 5 of 12

Capacitive Touch APITOUCH BUTTON CFG DEFAULT DEBOUNCE COUNT – Defines the number of consecutive iterations forwhich the lower layers must determine a channel is touched before a button is considered as pressed.TOUCH BUTTON CFG DEFAULT RPT DELAY COUNT – Defines the number of iterations between the pressevent and the first repeat event.TOUCH BUTTON CFG DEFAULT RPT RATE COUNT – Defines the number of iterations after which a channeldetermined to be touched executes the repeat event.TOUCH BUTTON CFG DEFAULT SH HOLD COUNT – Defines the number of iterations after which a shorthold event is generated while a button is considered touched.TOUCH BUTTON CFG DEFAULT LG HOLD COUNT – Defines the number of iterations after which a longhold event is generated while a button is considered touched.TOUCH BUTTON CFG DEFAULT STUCK COUNT – Defines the number of iterations after which an event forstuck button is generated as a button is considered to be touched.TOUCH BUTTON CFG DEFAULT RELEASE EVENT – Defines whether the button event generation is enablewhen the channel is determined to be not touched after being touched.TOUCH BUTTON CFG DEFAULT PRESS EVENT – Defines whether the button event generation is enabledwhen the channel is touched and considered as pressed.TOUCH BUTTON CFG DEFAULT REPEAT EVENT – Defines whether repetitive button event generation isenabled while button is considered pressed.TOUCH BUTTON CFG DEFAULT SHORTHOLD EVENT – Defines whether an event is generated when channelis touched for the duration of SH HOLD COUNT.TOUCH BUTTON CFG DEFAULT LONGHOLD EVENT – Defines whether an event is generated when channelis touched for the duration of LG HOLD COUNT.TOUCH BUTTON CFG DEFAULT CALLBACK – Defines the function which gets called when an event occurs.This function gets passed the event type and the button/key identifier as arguments.3.2.3Advanced configuration optionsWhen creating buttons which behave differently from each other, the user needs to specify parameters other than thebasic default parameters as mentioned above. To assign unique parameters to individual buttons, enable thepreprocessor TOUCH BUTTON CFG ADV DEFAULT and assign as shown below#define TOUCH BUTTON CFG BUTTONn xxxxxxxx(yyy)Where n is 0 number of channels configured as buttons.These unique values will replace the corresponding default values for button n in the file r touch button private.h.The user is advised to take a quick look at r touch button private.h for further understanding.3.2.4Evaluating button stateOnce a button has been properly configured, the user can call the function R Touch Button Open to initialize thebuttons. If the user chooses to provide arguments other than NULL to the open function, then the particular values forthe configuration will be overridden.After the button has been configured and initialized, the user must periodically call R Touch Button Handler tocheck if the button has changed states and if any events have occurred. Arguments passed to the handler are buttonhandles and the number of handles passed (as an array). Handles to all buttons are obtained as a return value throughR Touch Button Open when no arguments are passed to it. When arguments are passed to the handler, only thosebuttons are checked for which handles are passed. The following is an example code for checking only 3 channels outof a total of 12 configured as buttons using basic configuration in self-capacitance mode.EU00162 Rev.1.00August 12, 2014Page 6 of 12

Capacitive Touch API#include stddef.h #include "r touch if.h"#include "r touch button if.h"touch button hdl t* all button handles;touch button key t last button;void R Touch Button Callback( touch button key t key, touch button event t event ){/* Verify by placing a breakpoint at the nop */nop();}void main(void){/* Find out how many buttons are currently in use,* and get the configuration location */all button handles R Touch Button Open(&last button, NULL, NULL);while(1){/* Check only buttons 9, 10, and 11. */if( g ctsu soft mode CTSU FINISH MODE g ctsu soft mode CTSU READY MODE ){R Touch Button Handler(&all button handles[9],3);}}}Figure 1: Test code for R Touch efine#define#define#define#define#defineTOUCH BUTTON CFG BUTTON0 CHANNEL RXTOUCH BUTTON CFG BUTTON1 CHANNEL RXTOUCH BUTTON CFG BUTTON2 CHANNEL RXTOUCH BUTTON CFG BUTTON3 CHANNEL RXTOUCH BUTTON CFG BUTTON4 CHANNEL RXTOUCH BUTTON CFG BUTTON5 CHANNEL RXTOUCH BUTTON CFG BUTTON6 CHANNEL RXTOUCH BUTTON CFG BUTTON7 CHANNEL RXTOUCH BUTTON CFG BUTTON8 CHANNEL RXTOUCH BUTTON CFG BUTTON9 CHANNEL RXTOUCH BUTTON CFG BUTTON10 CHANNEL RXTOUCH BUTTON CFG BUTTON11 CHANNEL RX(0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11)Figure 2: Button Channel Configuration3.3R Touch SliderIn capacitive touch sensing, a slider is a collection of closely located electrodes with a pattern that allows estimating aninterpolated location of a touch. For example, if the user is touching a position midway between two elements of a twochannel slider, then the position of the touch should be at 50% of the maximum absolute output. The R Touch layeractivates layers below it to run the CTSU to perform measurements on the channels and update related global datavariables. The R Touch Slider layer selectively uses some of these global variables to compute the position of thetouched location on a collection of channels. The R Touch Slider allows the user to create two types of sliders, linearsliders and circular sliders in Self-Capacitance mode only.EU00162 Rev.1.00August 12, 2014Page 7 of 12

Capacitive Touch APILinear sliderCircular sliderFigure 3: Self Capacitance Demonstration BoardThe primary tasks a user may need to accomplish with a slider are detailed in the following material.3.3.1Adding a SliderIn order to add a slider, the user must first configure/calibrate the CTSU using the Workbench 6 software. This allowsthe variables in the lower levels to be activated and updated when the CTSU is operational. The R Touch Sliderprimarily uses the g dcount variable array which is updated by the lower levels to determine the position. Withoutproper configuration with Workbench 6, this variable may not be updated periodically.After configuration and calibration is performed with Workbench 6, the user can then modify the configuration filescontrolling the API. The configuration file for buttons is r touch slider config.h and should be located under ther config directory. One may use the r touch slider config reference.h file as a starting point which uses the RX113Captouch Wheel/Slider/Buttons daughter board configuration.To add a slider add the following equivalent statements to r touch slider config.h.#define TOUCH SLIDER CFG SLIDERn TYPE(m)Where n 1 to number of sliders to use, and m is the type of slider. If m 0, then the calculations on channel readingsassume a linear slider. If m 1, then the calculations on channel readings assume a circular slider/wheel.After declaring the type for slider ‘n’, the user needs to define the channels used for the slider position calculations.This is done as follows:#define TOUCH SLIDER CFG SLIDERn CHANNELp(q)Where p is the element number (0 to number of channels part of the slider), and q channel used for element p.3.3.2Configuring a sliderOnce a slider has been added, additional configuration options allow the user to change thebehavior of the calculations performed for the position. For example, the user may want toconfigure a circular slider to report the position of touch as an absolute value from 0 to 360 . Basicconfiguration options available are as follows:TOUCH SLIDER CFG DEFAULT USE NORM – Defines if normalization is performed on eachchannel.TOUCH SLIDER CFG DEFAULT NORM – Defines the divisor value used to normalize achannel measurement.EU00162 Rev.1.00August 12, 2014Page 8 of 12

Capacitive Touch APITOUCH SLIDER CFG NORM MAX – Indicates the maximum value generated for a channelmeasurement after normalization. This value is co-dependent on divisor values used for eachchannel.TOUCH SLIDER CFG DEFAULT CH AVG WEIGHT – Weight of running average for eachchannel, used to smooth data.TOUCH SLIDER CFG DEFAULT PREV SUM WEIGHT – Weight of running average forprevious sum of focus channels.TOUCH SLIDER CFG DEFAULT THRESHOLD – Cumulative sums below this value will not beregistered as a touch.TOUCH SLIDER CFG DEFAULT CUTOFF – Indicates how far sum of slider values should fallbelow running average to indicate inactive touch.3.3.3Advanced optionsIf the user needs to specify unique parameters for each individual slider, the user needs to set the preprocessor statementTOUCH SLIDER CFG ADV DEFAULT to 0 for selecting advanced settings for each slider. When using theadvanced configuration option, the user can define and override individual configuration parameters for each slider withthe prefix to a preprocessor statement as shown below:#define TOUCH SLIDER CFG SLIDER1 xxxxxxxx(yyy)Note that the user can also define normalizations for individual slider channels as#define TOUCH SLIDER CFG SLIDERn NORMp(zzzzz)Providing these advanced options will affect structure instances defined in r touch slider private.h. The user isrecommended to take a quick look at how changes in the configuration file affect these instances.3.3.4Evaluating a sliderIn order to acquire the position of a touch, the u

The API also provides the user with ability to perform simple processing on measurements made by the CTSU for each channel and then treat each channel as a Touch Button, or group channels and use them as linear or circular sliders. The API inherently depends on the user to provide valid configuration values for each Special Function Register (SFR) of the CTSU. The user should obtain these .

Related Documents:

รายละเอียด 4-way Switch Digital Touch Capacitive Module This Capacitive Touch Module uses the touch-sensing IC TTP224 to add capacitive touch to your project . Just power with 2.4 to 5.5VDC and touch the pad to activate the sensor. These touch switches interface e

discontinue this product without notice. Product Preview Proximity Capacitive Touch Sensor Controller MPR084 OVERVIEW The MPR084 is an Inter-Integrated Circuit Communication (I 2C) driven Capacitive Touch Sensor Controller , optimized to manage an 8-touch pad capacitive array. The device can accommodate a wide range of

Product Preview Proximity Capacitive Touch Sensor Controller MPR083 OVERVIEW The MPR083 is an Inter-Integrated Circuit Communication (I 2C) driven Capacitive Touch Sensor Controller, optimized to manage an 8-position rotary shaped capacitive array. The device can accommodate a wide . MPR084 I2C Yes — 8 keys

several touch pads continuously and only wake the CPU when a touch is detected. Regardless of which EFM32 is used for capacitive touch sensing, the design of printed circuit boards or similar hardware for capacitive touch sensing follows the same

touch products. How It Works A metal-over-capacitive touch system uses a conductive target layer suspended over a capacitive touch sensor, to act as a second capacitor plate. When the user applies a downward pressure on the target, the resulting deformation moves the center of the target closer to the capacitive sensor.

api 20 e rapid 20e api 20 ne api campy api nh api staph api 20 strep api coryne api listeriaapi 20 c aux api 20 a rapid id 32 a api 50 ch api 50 chb/e 50 chl reagents to be ordered. strips ref microorganisms suspension inoculum transfer medium i

Latest API exams,latest API-571 dumps,API-571 pdf,API-571 vce,API-571 dumps,API-571 exam questions,API-571 new questions,API-571 actual tests,API-571 practice tests,API-571 real exam questions Created Date

3 API Industry Guide on API Design Apiary - Apiary jump-started the modern API design movement by making API definitions more than just about API documentation, allowing API designers to define APIs in the machine-readable API definition format API blueprint, then mock, share, and publish