From 2dc8cc7ff14998a1b7bd4d412b5a11db35f0794d Mon Sep 17 00:00:00 2001 From: gitlab-runner Date: Thu, 10 Aug 2023 09:52:07 -0500 Subject: [PATCH] Upload capsense 4.0.0.5737 [1696] --- .../TOOLCHAIN_ARM/libcy_capsense.ar | Bin 16230 -> 16134 bytes .../TOOLCHAIN_A_Clang/libcy_capsense.a | Bin 10952 -> 10976 bytes .../TOOLCHAIN_GCC_ARM/libcy_capsense.a | Bin 15626 -> 14558 bytes .../TOOLCHAIN_IAR/libcy_capsense.a | Bin 24304 -> 23946 bytes .../TOOLCHAIN_ARM/libcy_capsense.ar | Bin 17902 -> 17934 bytes .../TOOLCHAIN_A_Clang/libcy_capsense.a | Bin 10952 -> 10976 bytes .../TOOLCHAIN_GCC_ARM/libcy_capsense.a | Bin 17018 -> 16174 bytes .../TOOLCHAIN_IAR/libcy_capsense.a | Bin 22918 -> 22760 bytes README.md | 36 +- RELEASE.md | 62 +- cy_capsense.h | 356 +- cy_capsense_centroid.c | 99 +- cy_capsense_centroid.h | 26 +- cy_capsense_common.h | 437 +- cy_capsense_control.c | 1320 ++-- cy_capsense_control.h | 34 +- cy_capsense_csd_v2.c | 173 +- cy_capsense_csd_v2.h | 6 +- cy_capsense_csx_v2.c | 86 +- cy_capsense_csx_v2.h | 2 +- cy_capsense_filter.c | 355 +- cy_capsense_filter.h | 10 +- cy_capsense_generator_lp.c | 1308 ++++ cy_capsense_generator_lp.h | 1315 ++++ cy_capsense_generator_v3.c | 182 +- cy_capsense_generator_v3.h | 2 +- cy_capsense_gesture_lib.h | 31 +- cy_capsense_lib.h | 45 +- cy_capsense_processing.c | 1259 ++-- cy_capsense_processing.h | 108 +- cy_capsense_selftest.c | 630 +- cy_capsense_selftest.h | 60 +- cy_capsense_selftest_lp.c | 4310 +++++++++++ cy_capsense_selftest_lp.h | 182 + cy_capsense_selftest_v2.c | 245 +- cy_capsense_selftest_v2.h | 4 +- cy_capsense_selftest_v3.c | 340 +- cy_capsense_selftest_v3.h | 51 +- cy_capsense_sensing.c | 1400 +++- cy_capsense_sensing.h | 105 +- cy_capsense_sensing_lp.c | 6328 +++++++++++++++++ cy_capsense_sensing_lp.h | 670 ++ cy_capsense_sensing_v2.c | 501 +- cy_capsense_sensing_v2.h | 18 +- cy_capsense_sensing_v3.c | 1798 +++-- cy_capsense_sensing_v3.h | 130 +- cy_capsense_sm_base_full_wave_lp.h | 1514 ++++ cy_capsense_sm_base_full_wave_v3.h | 12 +- cy_capsense_structure.c | 502 +- cy_capsense_structure.h | 1455 ++-- cy_capsense_tuner.c | 250 +- cy_capsense_tuner.h | 6 +- .../html/CAPSENSE_SOLUTION_MSCLP.png | Bin 0 -> 68379 bytes .../html/annotated.html | 77 +- .../html/capsense_solution.png | Bin 127635 -> 0 bytes .../html/check_power.png | Bin 140279 -> 93539 bytes .../html/classes.html | 26 +- .../html/functions.html | 18 +- .../html/functions_b.html | 21 +- .../html/functions_c.html | 165 +- .../html/functions_d.html | 16 +- .../html/functions_e.html | 12 +- .../html/functions_f.html | 12 +- .../html/functions_g.html | 6 +- .../html/functions_h.html | 6 +- .../html/functions_i.html | 35 +- .../html/functions_k.html | 6 +- .../html/functions_l.html | 38 +- .../html/functions_m.html | 30 +- .../html/functions_n.html | 37 +- .../html/functions_o.html | 12 +- .../html/functions_p.html | 74 +- .../html/functions_r.html | 27 +- .../html/functions_s.html | 19 +- .../html/functions_t.html | 10 +- .../html/functions_v.html | 8 +- .../html/functions_vars.html | 18 +- .../html/functions_vars_b.html | 21 +- .../html/functions_vars_c.html | 165 +- .../html/functions_vars_d.html | 16 +- .../html/functions_vars_e.html | 12 +- .../html/functions_vars_f.html | 12 +- .../html/functions_vars_g.html | 6 +- .../html/functions_vars_h.html | 6 +- .../html/functions_vars_i.html | 35 +- .../html/functions_vars_k.html | 6 +- .../html/functions_vars_l.html | 38 +- .../html/functions_vars_m.html | 30 +- .../html/functions_vars_n.html | 37 +- .../html/functions_vars_o.html | 12 +- .../html/functions_vars_p.html | 74 +- .../html/functions_vars_r.html | 27 +- .../html/functions_vars_s.html | 19 +- .../html/functions_vars_t.html | 10 +- .../html/functions_vars_v.html | 8 +- .../html/functions_vars_w.html | 17 +- .../html/functions_vars_x.html | 6 +- .../html/functions_vars_y.html | 6 +- .../html/functions_vars_z.html | 6 +- .../html/functions_w.html | 17 +- .../html/functions_x.html | 6 +- .../html/functions_y.html | 6 +- .../html/functions_z.html | 6 +- .../group__group__capsense__callbacks.html | 46 +- ...oup__group__capsense__data__structure.html | 9 +- .../html/group__group__capsense__enums.html | 105 +- .../html/group__group__capsense__enums.js | 21 +- ..._group__capsense__gesture__structures.html | 9 +- ...p__group__capsense__gesture__structures.js | 8 + .../group__group__capsense__high__level.html | 662 +- .../group__group__capsense__high__level.js | 13 +- .../group__group__capsense__low__level.html | 1121 ++- .../group__group__capsense__low__level.js | 23 +- .../html/group__group__capsense__macros.html | 6 +- .../group__group__capsense__macros__bist.html | 36 +- .../group__group__capsense__macros__bist.js | 4 +- ...oup__group__capsense__macros__general.html | 56 +- ...group__group__capsense__macros__general.js | 12 +- ...oup__group__capsense__macros__gesture.html | 12 +- ...group__group__capsense__macros__gesture.js | 1 + ...roup__capsense__macros__miscellaneous.html | 32 +- ..._group__capsense__macros__miscellaneous.js | 8 +- ...p__group__capsense__macros__mw__state.html | 30 +- ...oup__group__capsense__macros__mw__state.js | 6 + .../group__group__capsense__macros__pin.html | 80 +- .../group__group__capsense__macros__pin.js | 7 +- ...oup__group__capsense__macros__process.html | 20 +- ...group__group__capsense__macros__process.js | 5 +- ...up__group__capsense__macros__settings.html | 152 +- ...roup__group__capsense__macros__settings.js | 34 +- ...roup__group__capsense__macros__status.html | 22 +- .../group__group__capsense__macros__status.js | 6 +- ...group__group__capsense__macros__touch.html | 6 +- .../group__group__capsense__structures.html | 34 +- .../group__group__capsense__structures.js | 295 +- .../html/index.html | 161 +- .../html/modules.html | 6 +- .../html/navtreedata.js | 12 +- .../html/navtreeindex0.js | 354 +- .../html/navtreeindex1.js | 378 +- .../html/navtreeindex2.js | 368 +- .../html/navtreeindex3.js | 360 +- .../html/navtreeindex4.js | 203 +- .../html/search/all_0.js | 4 + .../html/search/all_1.js | 5 +- .../html/search/all_10.js | 10 +- .../html/search/all_11.js | 6 +- .../html/search/all_12.js | 2 +- .../html/search/all_13.js | 5 +- .../html/search/all_2.js | 193 +- .../html/search/all_3.js | 10 +- .../html/search/all_4.js | 2 + .../html/search/all_5.js | 2 + .../html/search/all_8.js | 15 +- .../html/search/all_a.js | 17 +- .../html/search/all_b.js | 12 +- .../html/search/all_c.js | 13 +- .../html/search/all_d.js | 4 +- .../html/search/all_e.js | 44 +- .../html/search/all_f.js | 10 +- .../html/search/classes_0.js | 9 +- .../html/search/enums_0.js | 2 +- .../html/search/enumvalues_0.js | 7 + .../html/search/functions_0.js | 34 +- .../html/search/pages_0.html | 26 - .../html/search/pages_0.js | 4 - .../html/search/searchdata.js | 9 +- .../html/search/typedefs_0.js | 5 +- .../html/search/variables_0.js | 4 + .../html/search/variables_1.js | 7 +- .../html/search/variables_10.js | 10 +- .../html/search/variables_11.js | 6 +- .../html/search/variables_12.js | 2 +- .../html/search/variables_13.js | 5 +- .../html/search/variables_2.js | 66 +- .../html/search/variables_3.js | 10 +- .../html/search/variables_4.js | 2 + .../html/search/variables_5.js | 2 + .../html/search/variables_8.js | 15 +- .../html/search/variables_a.js | 17 +- .../html/search/variables_b.js | 12 +- .../html/search/variables_c.js | 13 +- .../html/search/variables_d.js | 4 +- .../html/search/variables_e.js | 44 +- .../html/search/variables_f.js | 10 +- ..._stc__capsense__active__scan__sns__t.html} | 138 +- ...capsense__adaptive__filter__config__t.html | 6 +- ...psense__advanced__centroid__config__t.html | 6 +- ...psense__advanced__touchpad__config__t.html | 6 +- ..._stc__capsense__alp__fltr__channel__t.html | 6 +- ...__stc__capsense__alp__fltr__config__t.html | 6 +- ..._stc__capsense__auto__tune__config__t.html | 8 +- ...__stc__capsense__ballistic__config__t.html | 6 +- ..._stc__capsense__ballistic__context__t.html | 6 +- ...y__stc__capsense__ballistic__delta__t.html | 6 +- ...ctcy__stc__capsense__bist__context__t.html | 283 +- ...capsense__bist__custom__parameters__t.html | 6 +- ...cy__stc__capsense__channel__config__t.html | 290 + ...tcy__stc__capsense__common__config__t.html | 1299 ++-- ...cy__stc__capsense__common__context__t.html | 158 +- .../structcy__stc__capsense__context__t.html | 100 +- ..._stc__capsense__csx__touch__buffer__t.html | 6 +- ...stc__capsense__csx__touch__history__t.html | 6 +- ...__stc__capsense__electrode__config__t.html | 6 +- ...cy__stc__capsense__gesture__config__t.html | 14 +- ...y__stc__capsense__gesture__context__t.html | 10 +- ...__stc__capsense__gesture__position__t.html | 6 +- ...__capsense__hw__smartsense__config__t.html | 10 +- ...__stc__capsense__idac__gain__table__t.html | 6 +- ...__stc__capsense__internal__context__t.html | 1023 ++- ...tructcy__stc__capsense__mp__table__t.html} | 30 +- ...ctcy__stc__capsense__ofcd__context__t.html | 6 +- ...ctcy__stc__capsense__ofdc__context__t.html | 6 +- ...ctcy__stc__capsense__ofes__context__t.html | 6 +- ...ctcy__stc__capsense__offl__context__t.html | 6 +- ...ctcy__stc__capsense__oflp__context__t.html | 120 + ...ctcy__stc__capsense__ofrt__context__t.html | 6 +- ...ctcy__stc__capsense__ofsc__context__t.html | 6 +- ...ctcy__stc__capsense__ofsl__context__t.html | 6 +- ...ructcy__stc__capsense__pin__config__t.html | 8 +- .../structcy__stc__capsense__position__t.html | 8 +- ...tructcy__stc__capsense__scan__slot__t.html | 8 +- ...cy__stc__capsense__sensor__context__t.html | 12 +- ...__smartsense__csd__noise__envelope__t.html | 6 +- ...se__smartsense__update__thresholds__t.html | 6 +- ...ctcy__stc__capsense__tfsc__context__t.html | 6 +- ...ctcy__stc__capsense__tfsl__context__t.html | 6 +- ...ctcy__stc__capsense__tfzm__context__t.html | 6 +- .../structcy__stc__capsense__touch__t.html | 6 +- ...tcy__stc__capsense__widget__config__t.html | 109 +- ...cy__stc__capsense__widget__context__t.html | 128 +- ...__stc__capsense__widget__crc__data__t.html | 234 +- ...tructcy__stc__msc__channel__config__t.html | 149 - version.xml | 2 +- 234 files changed, 30549 insertions(+), 8196 deletions(-) create mode 100644 cy_capsense_generator_lp.c create mode 100644 cy_capsense_generator_lp.h create mode 100644 cy_capsense_selftest_lp.c create mode 100644 cy_capsense_selftest_lp.h create mode 100644 cy_capsense_sensing_lp.c create mode 100644 cy_capsense_sensing_lp.h create mode 100644 cy_capsense_sm_base_full_wave_lp.h create mode 100644 docs/capsense_api_reference_manual/html/CAPSENSE_SOLUTION_MSCLP.png delete mode 100644 docs/capsense_api_reference_manual/html/capsense_solution.png delete mode 100644 docs/capsense_api_reference_manual/html/search/pages_0.html delete mode 100644 docs/capsense_api_reference_manual/html/search/pages_0.js rename docs/capsense_api_reference_manual/html/{structcy__stc__active__scan__sns__t.html => structcy__stc__capsense__active__scan__sns__t.html} (54%) create mode 100644 docs/capsense_api_reference_manual/html/structcy__stc__capsense__channel__config__t.html rename docs/capsense_api_reference_manual/html/{structcy__stc__capsense__mptx__table__t.html => structcy__stc__capsense__mp__table__t.html} (70%) create mode 100644 docs/capsense_api_reference_manual/html/structcy__stc__capsense__oflp__context__t.html delete mode 100644 docs/capsense_api_reference_manual/html/structcy__stc__msc__channel__config__t.html diff --git a/COMPONENT_HARDFP/TOOLCHAIN_ARM/libcy_capsense.ar b/COMPONENT_HARDFP/TOOLCHAIN_ARM/libcy_capsense.ar index 63f25f20a8d381ac358b3569d4f6889c1653c0ad..d007678878c0f7d87307ead58a0b1bdb305d84cb 100644 GIT binary patch delta 5913 zcmb7I4^R|Wnt$Cr^z;mbX^;>ci8P4N5+ef+I{t~agLH^x2~m=m#9cAxCgd)Ei09=r zv78ms8pG=k7{ zX?8y)KUfOK~xNTb5X@eVcVVb#wnxFO0HUE%MKG zJW(!p6u!D-mh`yfmI4y%G;x*A+D8#Q1eD$nW!GnB`HkO)Cs$XDmr`y?-a%b0RS0Uk zUEa}Wvpi1_$NIX8HW9=Y`Br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Ey)*8-N!_B#h7C0M(E{}&_%Ncp|wC0H^f>@ z#U1y_vrLmml#40xgQz^QhWLiGdYB*w#VjBjNn3oMKxUdiQd?sJKZh}Fg$f;QEkKaC zh_#r4#(U(62xUwYNWv~A@ZVqzd#4oq76_tXEHueJ(tZm)rZl11Y4U79$K+MR7(`4d zXaJ4s;QXl;)36z4rVHdi0trIm$7JX+footqT|si|5CzE|(#Ss2Dxgo7=Y|EckI0*u t3Xhn;QWz5rW383aub3jBr`KkfhAW197^Y(?6OJJu7+@z7VvZqd|1X?D`l0{; diff --git a/COMPONENT_HARDFP/TOOLCHAIN_A_Clang/libcy_capsense.a b/COMPONENT_HARDFP/TOOLCHAIN_A_Clang/libcy_capsense.a index 8d06018abba7216287d8b58e573394771aaadb3a..da598570bd602ac973650b5d69603eeceabfac9a 100644 GIT binary patch literal 10976 zcmb_i4^$IZy1z4%gd~Iz5M4yn0feU5YEYzkt-B2qGU}=Y(Y9{?5rnj`OC>^ZvFouD zu-yTzFZ7QmDEhGNc5TbHfVQW9u)%hHr|n{20)4yC#qPMft$*h1J4r;|Z1YZe-<<>n zOKt0Wb8_?DJNKJA-=E+2-8*+CV`X_=Mb%HVS$RvBndqxWUcqez1KqxjQ%A?{~M@Rk5D=Rd`VDZ^c2v}9E8LeokK?3o1yK^LdYGXOzixY7=0mjo`-gs zbw`=C+_}-Qwcb%ySXu6LRd08&)io|h-I}e{uIlod>c<>q>#Db0kF&I4>r5=$%ePiI zDy@#KuDaUl%2f{6rrL&zDr;?RU1jywa+jlihKp*Pz*o54QCI%ROt-CZURSCbXQ`v! z;o9he(PtcdMoF3Snwsi*S9Qhuh8kD3v!>cn_sxq}IqF>vb&j$kM@4O=W4bja`>x)6 zdjD0K@2ah?ci6UWchuB6XOIxY`wot~ot2>5rm8weeN}Bu*bly!3TOB1J zTSa*d^ncTexE~7!$l6}*+95Llx)FkS!(nvg$TQux{I>i&^RneL$J+|CImT<(R_rLN zD0kM&5H62Fxa?sW!(}zqTb9(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CM~dINv{z?;nQV=t5{s9^OP?Qo`Z!L5(Ga+UQ285_-a~ zmcSL)`OnMa34ddyfYjg-LK0-sug~|;As+;SXl`0FbT1zI?xc^h63gJ_sb} zpw2tZW=M z@Tvj8?|y;@>47}mt~?zH8Brui;4*|l(60k zZNrw`+rP2lI${eTrl4)xpWZeaY>_F@?0HH(l~f+2vFH#w2Drjgi2rkx7}3qdi^Q#W z%&OZ21k(??&Z1mGlCaY7YT#wyT`2w-sOR29eFmt>ETM+s6!kAftdt zHbp%yK6>XY;XLR!T@wqWQ-OEkupsb0pd+ThwEFk~Abu}AL}T*2dJ{hvEbs!J=t?$y z!Lp}v{DeRkAj#7Q2qGv~8FGXKzx^hL{%H!5kQEr}a}1{x90ZsoLg6VWc>4|fU^}z{ zLqAXv4M`a)FobGKES^%30lyLjbEWFKf`0_ubPtB6DG1p=#qaqXzbOSR!0$uxKN`z~ z>8m5Kn&d6fhHQ<3HodvkQ`(%%Ym?tTDjkrZZ^1jA9|IvLS`&WcVo>0>2gYC>c}P+q qbb(SYS({-98A!I0`T!a(S>Ck(fW)cC3pC3BL0HUym#`(<_kRHg@#f9| diff --git a/COMPONENT_SOFTFP/TOOLCHAIN_A_Clang/libcy_capsense.a b/COMPONENT_SOFTFP/TOOLCHAIN_A_Clang/libcy_capsense.a index 8d06018abba7216287d8b58e573394771aaadb3a..da598570bd602ac973650b5d69603eeceabfac9a 100644 GIT binary patch literal 10976 zcmb_i4^$IZy1z4%gd~Iz5M4yn0feU5YEYzkt-B2qGU}=Y(Y9{?5rnj`OC>^ZvFouD zu-yTzFZ7QmDEhGNc5TbHfVQW9u)%hHr|n{20)4yC#qPMft$*h1J4r;|Z1YZe-<<>n zOKt0Wb8_?DJNKJA-=E+2-8*+CV`X_=Mb%HVS$RvBndqxWUcqez1KqxjQ%A?{~M@Rk5D=Rd`VDZ^c2v}9E8LeokK?3o1yK^LdYGXOzixY7=0mjo`-gs zbw`=C+_}-Qwcb%ySXu6LRd08&)io|h-I}e{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^&=A9IQR&ZO$^w zG}dTyjj>(mV`Hcv;5&d5jlRW%lz$rYTIeX$pNdO*v`x;%&JG`ib5`ky-!V z#~|J^>)$cStbgMYz)oV;zlv$B{t?eKv&OB$cuFR#TDK)UiNeWJXB*ERVtWtSWTmuy zh|FzH53hHSX*pEETDBpFo^B|j@%0Y58`HGfDtT{WY(r+rYqgstZ-d<|dENHOlJ^6< aS@NQGx}wBaJc|31ePl5fD^f)E0{$0PH86w# diff --git a/README.md b/README.md index c330ad6..f4dfdcd 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,14 @@ # CAPSENSE™ Middleware Library ### Overview -CAPSENSE™ is a CYPRESS™ capacitive sensing solution from Infineon. Capacitive sensing can be used in a variety of applications and products where conventional mechanical buttons can be replaced with sleek human interfaces to transform the way users interact with electronic systems. These include home appliances, automotive, IoT, and industrial applications. CAPSENSE™ supports multiple interfaces (widgets) using both Self-Capacitance (CSD) and Mutual-Capacitance (CSX) sensing methods with robust performance. +CAPSENSE™ is CYPRESS™ capacitive sensing solution from Infineon Technologies AG. Capacitive sensing can be used in a variety of applications and products where +conventional mechanical buttons can be replaced with sleek human interfaces to transform the way users interact with electronic systems. +These include home appliances, automotive, IoT, and industrial applications. CAPSENSE™ supports multiple interfaces (widgets) using the Self-Capacitance (CSD), +Mutual-Capacitance (CSX), and Inductive sensing (ISX) sensing methods with robust performance. -CAPSENSE™ has become a popular technology to replace conventional mechanical- and optical-based user interfaces. There are fewer parts involved, which saves cost and increases reliability with no wear-and-tear. The main advantages of CAPSENSE™ compared with other solutions are: robust performance in harsh environmental conditions and rejection of a wide range of external noise sources. +CAPSENSE™ has become a popular technology to replace conventional mechanical- and optical-based user interfaces. There are fewer parts involved, +which saves cost and increases the reliability with no wear-and-tear. The main advantages of CAPSENSE™ compared with other solutions are: +robust performance in harsh environmental conditions and rejection of a wide range of external noise sources. Use CAPSENSE™ for: * Touch and gesture detection for various interfaces @@ -13,40 +18,45 @@ Use CAPSENSE™ for: ### Features * Offers best-in-class signal-to-noise ratio (SNR) -* Supports Self-Capacitance (CSD) and Mutual-Capacitance (CSX) sensing methods +* Supports the Self-Capacitance (CSD), Mutual-Capacitance (CSX), and Inductive (ISX) sensing methods * Features smart sensing algorithm auto-tuning technology for CSD sensing to avoid complex manual tuning process * Supports various Widgets, such as Buttons, Matrix Buttons, Sliders, Touchpads, and Proximity Sensors * Provides ultra-low power consumption and liquid-tolerant capacitive sensing technology -* Contains the integrated graphical CAPSENSE™ Tuner tool for real-time tuning, testing, and debugging +* Contains integrated graphical CAPSENSE™ Tuner for real-time tuning, testing, and debugging * Provides superior immunity against external noise and low-radiated emission * Offers best-in-class liquid tolerance * Supports one-finger and two-finger gestures -### Quick Start -The [ModusToolbox™ CAPSENSE™ Configurator Tool Guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_CAPSENSE_Configurator_5.0_User_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c8386267f0183a960b36a598c) describes step-by-step instructions how to configure and launch CAPSENSE™ in [ModusToolbox™](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software/). The CAPSENSE™ Configurator Tool can be launched in ModusToolbox™ IDE from the CSD personality, as well as in stand-alone mode. Refer to [ModusToolbox™ Software Environment, Quick Start Guide, Documentation, and Videos](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software/). +### Quick start +The [ModusToolbox™ CAPSENSE™ Configurator User Guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_CAPSENSE_Configurator_5.0_User_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c8386267f0183a960b36a598c) instructs step-by-step +how to configure and launch the CAPSENSE™ Configurator in [ModusToolbox™](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software). +The CAPSENSE™ Configurator can be launched in the ModusToolbox™ IDE from the CSD, MSC or MSCLP personality and as a stand-alone tool. Refer to [ModusToolbox™ Software Environment, Quick Start Guide, Documentation, and Videos](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software/). -The quickest way to get started with CAPSENSE™ is using code examples. Infineon Technologies continuously extends their portfolio of code examples at the Infineon Technologies and at the Infineon Technologies GitHub. +Use code examples to quickly start the CAPSENSE™ Configurator. Infineon Technologies AG continuously extends their portfolio of code examples at the Infineon Technologies and at the Infineon Technologies GitHub. ### More information -The following resources contain more information: -* CAPSENSE™ Overview: +For more information, refer to: +* CAPSENSE™ overview: * [CAPSENSE™ Middleware RELEASE.md](./RELEASE.md) * [CAPSENSE™ Middleware API Reference Guide](https://infineon.github.io/capsense/capsense_api_reference_manual/html/index.html) - * [ModusToolbox™ CAPSENSE™ Configurator Tool Guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_CAPSENSE_Configurator_Guide_4-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d718a49017d99ab1e6531c8) - * [ModusToolbox™ CAPSENSE™ Tuner Tool Guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_CAPSENSE_Tuner_5.0_User_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c8386267f0183a960ac735989) + * [ModusToolbox™ CAPSENSE™ Configurator Tool Guide](www.cypress.com/ModusToolboxCapSenseConfig) + * [ModusToolbox™ CAPSENSE™ Tuner Tool Guide](www.cypress.com/ModusToolboxCapSenseTuner) * [CAPSENSE™ Design Guide](https://www.infineon.com/dgdl/Infineon-AN85951_PSoC_4_and_PSoC_6_MCU_CapSense_Design_Guide-ApplicationNotes-v27_00-EN.pdf?fileId=8ac78c8c7cdc391c017d0723535d4661) * [CSDADC Middleware API Reference Guide](https://infineon.github.io/csdadc/csdadc_api_reference_manual/html/index.html) * [CSDIDAC Middleware API Reference Guide](https://infineon.github.io/csdidac/csdidac_api_reference_manual/html/index.html) + * ModusToolbox™ Overview: * [ModusToolbox™ Software Environment, Quick Start Guide, Documentation, and Videos](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software) - * [ModusToolbox™ Device Configurator Tool Guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_Device_Configurator_4.0_User_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c8386267f0183a960bd41598f) -* Infineon Technologies Kits and Code Examples: + * [ModusToolbox™ Device Configurator Tool Guide](https://www.cypress.com/ModusToolboxDeviceConfig) + +* Infineon Technologies AG Kits and Code Examples: * [CAPSENSE™ Middleware Code Example for MBED OS](https://github.com/Infineon/mbed-os-example-capsense) * [CAPSENSE™ Middleware Code Example for FreeRTOS](https://github.com/Infineon/mtb-example-psoc6-emwin-eink-freertos) * [CY8CKIT-145-40XX PSoC™ 4000S CAPSENSE™ Prototyping Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-145-40xx/) * [CY8CKIT-149 PSoC™ 4100S Plus Prototyping Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-149/) * [CY8CKIT-041-40XX PSoC™ 4 S-Series Pioneer Kit](https://www.infineon.com/dgdl/Infineon-CY8CKIT-041-40XX_PSoC_4_S-Series_Pioneer_Kit_Quick_Start_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0efc44781263) * [CY8CKIT-041-41XX PSoC™ 4100S CAPSENSE™ Pioneer Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-041-41xx/) + * General Information: * [AN210781 Getting Started with PSoC™ 6 MCU with Bluetooth Low Energy (BLE) Connectivity](https://www.infineon.com/dgdl/Infineon-AN210781_Getting_Started_with_PSoC_6_MCU_with_Bluetooth_Low_Energy_(BLE)_Connectivity_on_PSoC_Creator-ApplicationNotes-v05_00-EN.pdf?fileId=8ac78c8c7cdc391c017d0d311f536528) * [PSoC™ 6 Technical Reference Manual](https://www.infineon.com/dgdl/Infineon-PSoC_6_MCU_PSoC_63_with_BLE_Architecture_Technical_Reference_Manual-AdditionalTechnicalInformation-v11_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0f946fea01ca) diff --git a/RELEASE.md b/RELEASE.md index f20071d..0035cd9 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,56 +1,62 @@ -# CAPSENSE™ Middleware Library 3.0.1 +# CAPSENSE™ Middleware Library 4.0 -### What's Included? -Please refer to the [README.md](./README.md) and the [API Reference Guide](https://infineon.github.io/capsense/capsense_api_reference_manual/html/index.html) for a complete description of the CAPSENSE™ Middleware. -The revision history of the CAPSENSE™ Middleware is also available on the [API Reference Guide Changelog](https://infineon.github.io/capsense/capsense_api_reference_manual/html/index.html#section_capsense_changelog). -New important things in this release: -* Added CAPSENSE™ fifth-generation device support -* Added flash memory optimization +### What is Included? +For a complete description of the CAPSENSE™ middleware, refer to [README.md](./README.md) and [API Reference Guide](https://infineon.github.io/capsense/capsense_api_reference_manual/html/index.html). +The revision history of the CAPSENSE™ middleware is also available at [API Reference Guide Changelog](https://infineon.github.io/capsense/capsense_api_reference_manual/html/index.html#section_capsense_changelog). +The new support added in this release: +* The CAPSENSE™ fifth-generation LP device support +* The Inductive sensing (ISX) method support +* The Long Press gesture support -### Known Issues -Refer to the [API Reference Guide - Errata section](https://infineon.github.io/capsense/capsense_api_reference_manual/html/index.html#section_capsense_errata) for a complete description of the known issues and possible workarounds +### Known issues +For a complete description of the known issues and possible workarounds, refer to the [API Reference Guide - Errata section](https://infineon.github.io/capsense/capsense_api_reference_manual/html/index.html#section_capsense_errata). -### Supported Software and Tools -This version of the CAPSENSE™ Middleware was validated for compatibility with the following Software and Tools: -| Software and Tools | Version | +### Supported software and tools +This version of the CAPSENSE™ middleware was validated for compatibility with the following software and tools: + +| Software and tools | Version | | :--- | :----: | -| ModusToolbox™ Software Environment | 3.0 | -| - ModusToolbox™ Device Configurator | 4.0 | -| - ModusToolbox™ MSC Superblock Personality for for PSoC™ 4 devices in the Device Configurator | 1.0 | -| - ModusToolbox™ MSC Personality for PSoC™ 4 devices in Device Configurator | 1.1 | -| - ModusToolbox™ CSD Personality for PSoC™ 4 devices in Device Configurator | 2.0 | -| - ModusToolbox™ CSD Personality for PSoC™ 6 devices in Device Configurator | 3.0 | -| - ModusToolbox™ CAPSENSE™ Configurator / Tuner tools | 5.0.0 | -| CAT1 Peripheral Driver Library (PDL) | 3.0.0 | -| CAT2 Peripheral Driver Library (PDL) | 2.0.0 | -| GCC Compiler | 10.3.1 | +| ModusToolbox™ Software Environment | 3.1 | +| - ModusToolbox™ Device Configurator | 4.10 | +| - ModusToolbox™ MSC Superblock Personality for PSoC™ 4 devices in the Device Configurator | 1.0 | +| - ModusToolbox™ MSCLP Personality for PSoC™ 4 devices in the Device Configurator | 3.0 | +| - ModusToolbox™ MSC Personality for PSoC™ 4 devices in the Device Configurator | 1.1 | +| - ModusToolbox™ CSD Personality for PSoC™ 4 devices in the Device Configurator | 2.0 | +| - ModusToolbox™ CSD Personality for PSoC™ 6 devices in the Device Configurator | 2.0 | +| - ModusToolbox™ CAPSENSE™ Configurator / Tuner | 6.10 | +| CAT1 Peripheral Driver Library (PDL) | 3.3.1 | +| CAT2 Peripheral Driver Library (PDL) | 2.5.0 | +| GCC Compiler | 11.3.1 | | IAR Compiler | 8.42.1 | | ARM Compiler 6 | 6.13 | | MBED OS | 5.15.8 | | FreeRTOS | 10.4.5 | ### More information -The following resources contain more information: -* CAPSENSE™ Overview: +For more information, refer to: +* CAPSENSE™ overview: * [CAPSENSE™ Middleware RELEASE.md](./RELEASE.md) * [CAPSENSE™ Middleware API Reference Guide](https://infineon.github.io/capsense/capsense_api_reference_manual/html/index.html) - * [ModusToolbox™ CAPSENSE™ Configurator Tool Guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_CAPSENSE_Configurator_Guide_4-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d718a49017d99ab1e6531c8) - * [ModusToolbox™ CAPSENSE™ Tuner Tool Guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_CAPSENSE_Tuner_5.0_User_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c8386267f0183a960ac735989) + * [ModusToolbox™ CAPSENSE™ Configurator Tool Guide](www.cypress.com/ModusToolboxCapSenseConfig) + * [ModusToolbox™ CAPSENSE™ Tuner Tool Guide](www.cypress.com/ModusToolboxCapSenseTuner) * [CAPSENSE™ Design Guide](https://www.infineon.com/dgdl/Infineon-AN85951_PSoC_4_and_PSoC_6_MCU_CapSense_Design_Guide-ApplicationNotes-v27_00-EN.pdf?fileId=8ac78c8c7cdc391c017d0723535d4661) * [CSDADC Middleware API Reference Guide](https://infineon.github.io/csdadc/csdadc_api_reference_manual/html/index.html) * [CSDIDAC Middleware API Reference Guide](https://infineon.github.io/csdidac/csdidac_api_reference_manual/html/index.html) + * ModusToolbox™ Overview: * [ModusToolbox™ Software Environment, Quick Start Guide, Documentation, and Videos](https://www.infineon.com/cms/en/design-support/tools/sdk/modustoolbox-software) - * [ModusToolbox™ Device Configurator Tool Guide](https://www.infineon.com/dgdl/Infineon-ModusToolbox_Device_Configurator_4.0_User_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c8386267f0183a960bd41598f) -* Infineon Technologies Kits and Code Examples: + * [ModusToolbox™ Device Configurator Tool Guide](https://www.cypress.com/ModusToolboxDeviceConfig) + +* Infineon Technologies AG Kits and Code Examples * [CAPSENSE™ Middleware Code Example for MBED OS](https://github.com/Infineon/mbed-os-example-capsense) * [CAPSENSE™ Middleware Code Example for FreeRTOS](https://github.com/Infineon/mtb-example-psoc6-emwin-eink-freertos) * [CY8CKIT-145-40XX PSoC™ 4000S CAPSENSE™ Prototyping Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-145-40xx) * [CY8CKIT-149 PSoC™ 4100S Plus Prototyping Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-149) * [CY8CKIT-041-40XX PSoC™ 4 S-Series Pioneer Kit](https://www.infineon.com/dgdl/Infineon-CY8CKIT-041-40XX_PSoC_4_S-Series_Pioneer_Kit_Quick_Start_Guide-UserManual-v01_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0efc44781263) * [CY8CKIT-041-41XX PSoC™ 4100S CAPSENSE™ Pioneer Kit](https://www.infineon.com/cms/en/product/evaluation-boards/cy8ckit-041-41xx/) + * General information: * [AN210781 Getting Started with PSoC™ 6 MCU with Bluetooth Low Energy (BLE) Connectivity](https://www.infineon.com/dgdl/Infineon-AN210781_Getting_Started_with_PSoC_6_MCU_with_Bluetooth_Low_Energy_(BLE)_Connectivity_on_PSoC_Creator-ApplicationNotes-v05_00-EN.pdf?fileId=8ac78c8c7cdc391c017d0d311f536528) * [PSoC™ 6 Technical Reference Manual](https://www.infineon.com/dgdl/Infineon-PSoC_6_MCU_PSoC_63_with_BLE_Architecture_Technical_Reference_Manual-AdditionalTechnicalInformation-v11_00-EN.pdf?fileId=8ac78c8c7d0d8da4017d0f946fea01ca) diff --git a/cy_capsense.h b/cy_capsense.h index 858d2f7..94bf7fe 100644 --- a/cy_capsense.h +++ b/cy_capsense.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file includes all the header files of the CAPSENSE™ middleware. @@ -16,15 +16,14 @@ /** ******************************************************************************** -* \mainpage CAPSENSE™ Middleware Library 3.0.1 +* \mainpage ******************************************************************************** -* * CAPSENSE™ is a CYPRESS™ capacitive sensing solution from Infineon. * Capacitive sensing can be used in a variety of applications and products where * conventional mechanical buttons can be replaced with sleek human interfaces to * transform the way users interact with electronic systems. These include home * appliances, and automotive, IoT, and industrial applications. CAPSENSE™ -* supports multiple interfaces (widgets) using both CSX and CSD sensing methods +* supports multiple interfaces (widgets) using CSD, CSX, and ISX sensing methods * with robust performance. * * CAPSENSE™ has become a popular technology to replace conventional @@ -36,7 +35,7 @@ * * Use CAPSENSE™ for: * * Touch and gesture detection for various interfaces -* * Proximity detection for innovative user experiences and low-power +* * Proximity detection for innovative user experiences and low power * optimization * * Contactless liquid-level sensing in a variety of applications * * Touch-free operations in hazardous materials @@ -45,10 +44,11 @@ * \section section_capsense_general General Description ******************************************************************************** * -* The CAPSENSE™ middleware Library supports operation with fourth-generation and -* fifth-generation of CAPSENSE™ HW. CAPSENSE™ HW enables multiple sensing -* capabilities on PSoC™ devices including the self-cap (CSD) and mutual-cap (CSX) -* capacitive touch sensing solutions, inductive sensing, impedance measurement, and +* The CAPSENSE™ middleware Library supports operation with fourth-generation, +* fifth-generation and fifth-generation LP of CAPSENSE™ HW. +* CAPSENSE™ HW enables the multiple sensing +* capabilities on PSoC™ devices including the Self-Capacitance (CSD) and Mutual-Capacitance (CSX) +* capacitive touch sensing solutions, inductive sensing (ISX), impedance measurement, and * other features. * * Middleware access available the CAPSENSE™ HW block through the corresponding @@ -57,6 +57,8 @@ * CAPSENSE™ HW; * - MSC (Multi-Sensor Converter) driver for the fifth-generation of the * CAPSENSE™ HW; +* - MSCLP (Multi-Sensor Converter Low Power) driver for the fifth-generation of the +* CAPSENSE™ HW; * * The CAPSENSE™ peripheral driver does not provide any system-level functions. * It only implements the interface to the CAPSENSE™ HW resource. @@ -64,19 +66,19 @@ * The supported CAPSENSE™ HW blocks can perform only one function at a time. * However, all supported functionality (like CAPSENSE™, CSDADC, etc.) can be * time-multiplexed in a design. I.e. you can save the existing state of -* the CAPSENSE™ middleware, restore the state of the the CSDADC middleware, perform +* the CAPSENSE™ middleware, restore the state of the CSDADC middleware, perform * CSDADC measurements, and then switch back to the CAPSENSE™ functionality. * For details and code examples, refer to the description of the * Cy_CapSense_Save() and Cy_CapSense_Restore() functions. * -* \image html capsense_solution.png "CAPSENSE™ Solution" width=800px -* \image latex capsense_solution.png +* \image html CAPSENSE_SOLUTION_MSCLP.png "CAPSENSE™ Solution" width=800px +* \image latex CAPSENSE_SOLUTION_MSCLP.png * * This section describes only the CAPSENSE™ middleware. Refer to the corresponding * sections of documentation for other middleware supported by the CAPSENSE™ HW. * * A CAPSENSE™ solution includes: -* * The CAPSENSE™ Configurator to create +* * The CAPSENSE™ Configurator tool to create * and configure CAPSENSE™ widgets. It can be launched in ModusToolbox™ * from the CAPSENSE™ superblock personality and in Stand-alone mode. * It contains a separate document about how to create and @@ -99,11 +101,13 @@ * \subsection subsection_capsense_features Features * * * Offers best-in-class signal-to-noise ratio (SNR) -* * Supports Self-Capacitance (CSD) and Mutual-Capacitance (CSX) -* sensing methods +* * Supports Self-Capacitance (CSD) and Mutual-Capacitance (CSX) sensing methods +* * Inductive sensing method (ISX) available for fifth-generation low power CAPSENSE™ +* * Fifth-generation low power CAPSENSE™ supports autonomous scanning in Deep Sleep +* power mode * * Supports various Widgets, such as Buttons, Matrix Buttons, Sliders, * Touchpads, and Proximity Sensors -* * Provides ultra-low power consumption and liquid-tolerant capacitive +* * Provides ultra-low power consumption capacitive * sensing technology * * Contains the integrated graphical CAPSENSE™ Tuner tool for real-time tuning, * testing, and debugging @@ -142,7 +146,7 @@ * * * CSX Button Manual Tuning * -* * +* * * CSD Slider Manual Tuning * * * @@ -157,7 +161,7 @@ * Two Buttons and Slider with CAPSENSE™ Tuner * * * -* Low-Power Slider and Ganged Sensors with FreeRTOS +* low power Slider and Ganged Sensors with FreeRTOS * * * * Custom Scan @@ -192,7 +196,7 @@ * \note * Ensure to set up the device power voltages correctly * to the proper operation of the device power domains. The Setup is -* on the System Tab of the Device Configurator. Enable the Power check box +* on the System Tab of the Device Configurator tool. Enable the Power check box * and set up the voltages as they are red-outlined in the picture below. * * \image html check_power.png "Power Setup" width=800px @@ -201,9 +205,9 @@ * \subsection group_capsense_quick_start_mbed MBED OS Configuration Considerations * * You can immediately start with the following MBED OS code example available -* at the -* Cypress Semiconductor GitHub: -* * +* at the +* Infineon GitHub: +* * * CAPSENSE™ buttons and slider for PSoC™ 6 MCU with Mbed OS * * If you are doing your own project, remember to include cycfg.h file: @@ -216,7 +220,7 @@ * \section section_capsense_configuration Summary of Application Programming Interface (API) ******************************************************************************** * -* The CAPSENSE™ middleware operates on the top of the MSC/CSD HW driver. +* The CAPSENSE™ middleware operates on the top of the MSCLP/MSC/CSD HW driver. * Refer to the PDL API Reference Manual. * * This document provides descriptions of the functions in the CAPSENSE™ @@ -246,47 +250,51 @@ * * * ModusToolbox™ Software Environment -* 3.0 +* 3.1 * * -* - ModusToolbox™ Device Configurator -* 4.0 +* - ModusToolbox™ Device Configurator tool +* 4.10 * * -* - ModusToolbox™ MSC Superblock Personality for for PSoC™ 4 devices in the Device Configurator +* - ModusToolbox™ MSC Superblock Personality for PSoC™ 4 devices in the Device Configurator tool * 1.0 * * -* - ModusToolbox™ MSC Personality for PSoC™ 4 devices in the Device Configurator +* - ModusToolbox™ MSC Personality for PSoC™ 4 devices in the Device Configurator tool * 1.1 * * -* - ModusToolbox™ CSD Personality for PSoC™ 4 devices in the Device Configurator +* - ModusToolbox™ MSCLP Personality for PSoC™ 4 devices in the Device Configurator tool +* 3.0 +* +* +* - ModusToolbox™ CSD Personality for PSoC™ 4 devices in the Device Configurator tool * 2.0 * * -* - ModusToolbox™ CSD Personality for PSoC™ 6 devices in the Device Configurator -* 3.0 +* - ModusToolbox™ CSD Personality for PSoC™ 6 devices in the Device Configurator tool +* 2.0 * * * - ModusToolbox™ CAPSENSE™ Configurator tool -* 5.0.0 +* 6.10 * * * - ModusToolbox™ CAPSENSE™ Tuner tool -* 5.0.0 +* 6.10 * * * CAT1 Peripheral Driver Library (PDL) -* 3.0.0 +* 3.3.1 * * * CAT2 Peripheral Driver Library (PDL) -* 2.0.0 +* 2.5.0 * * * GCC Compiler -* 10.3.1 +* 11.3.1 * * * IAR Compiler @@ -325,9 +333,9 @@ * \ref section_capsense_toolchain. * * Ensure: -* * The specified version of the ModusToolbox™ Device Configurator and +* * The specified version of the ModusToolbox™ Device Configurator tool and * the Personality are used to re-generate the device configuration. -* * The specified version of the ModusToolbox™ CAPSENSE™ Configurator is used +* * The specified version of the ModusToolbox™ CAPSENSE™ Configurator tool is used * to re-generate the middleware configuration. * * The toolchains are set up properly for your environment per the settings * outlined in the Supported Software and Tools. @@ -336,10 +344,10 @@ * * You might need to re-generate the configuration structures for either the * device initialization code or the middleware initialization code. -* * Launch the ModusToolbox™ Device Configurator and perform the File->Save command +* * Launch the ModusToolbox™ Device Configurator tool and perform the File->Save command * to re-generate the device initialization code. -* * From the ModusToolbox™ Device Configurator, launch the -* ModusToolbox™ CAPSENSE™ Configurator and perform the File->Save command to +* * From the ModusToolbox™ Device Configurator tool, launch the +* ModusToolbox™ CAPSENSE™ Configurator tool and perform the File->Save command to * re-generate the middleware initialization code. * ******************************************************************************** @@ -361,16 +369,20 @@ * * * -* +* * -* -* -* -* -* -* -* -* +* +* +* +* +* +* +* +* +* +* +* +* * * * @@ -403,8 +415,8 @@ *
Configuration:ModeSensor Connection TypeMemory TypeConfiguration 1Configuration 2Configuration 3Configuration 4Configuration 5Configuration 6Configuration 7Configuration 8Configuration 9
4th GenIntDrvAMUXFlash:< 5.9 kB< 8.5 kB< 11.7 kB< 5.5 kB
4th GenIntDrvAMUXFlash:< 6.0 kB< 8.8 kB< 11.7 kB< 5.5 kB< 6.8 kB< 7.8 kB< 9.1 kB< 9.4 kB< 18.7 kB
SRAM:< 0.6 kB< 0.8 kB< 0.8 kB< 0.8 kB< 0.8 kB< 1.1 kB< 1.8 kB< 0.7 kB< 2.4 kB
5th GenIntDrvAMUXFlash:< 7.3 kB< 10.3 kB< 11.5 kB< 7.4 kB< 8.8 kB< 9.9 kB< 11.0 kB< 11.3 kB< 15.0 kB
SRAM:< 1.1 kB< 1.2 kB< 1.1 kB< 1.3 kB< 1.3 kB< 1.7 kB< 2.3 kB< 1.7 kB< 3.3 kB
CTRL_MUXFlash:Flash memory consumption 1000 bytes higher then CTRL_MUX - DMA
SRAM:SRAM memory consumption is the same as in CTRL_MUX - DMA
DMACTRL_MUXFlash:< 7.7 kB< 11.0 kB< 11.1 kB< 7.8 kB< 9.6 kB< 10.2 kB< 11.4 kB< 11.7 kB< 15.4 kB
SRAM:< 1.3 kB< 1.5 kB< 1.4 kB< 2.1 kB< 2.1 kB< 2.6 kB< 3.3 kB< 2.1 kB< 5.4 kB
SRAM:< 0.6 kB< 0.8 kB< 0.9 kB< 0.8 kB< 0.8 kB< 1.1 kB< 1.8 kB< 0.7 kB< 2.4 kB
5th GenIntDrvAMUXFlash:< 8.0 kB< 10.4 kB< 11.8 kB< 7.9 kB< 9.3 kB< 10.1 kB< 11.2 kB< 12.0 kB< 15.0 kB
SRAM:< 1.1 kB< 1.3 kB< 1.4 kB< 1.3 kB< 1.3 kB< 1.7 kB< 2.4 kB< 1.7 kB< 3.3 kB
CTRL_MUXFlash:< 7.6 kB< 10.7 kB< 11.4 kB< 7.4 kB< 9.2 kB< 9.8 kB< 10.9 kB< 11.9 kB< 14.8 kB
SRAM:< 1.1 kB< 1.3 kB< 1.4 kB< 1.3 kB< 1.3 kB< 1.7 kB< 2.4 kB< 1.7 kB< 3.3 kB
DMACTRL_MUXFlash:< 7.9 kB< 11.3 kB< 12.1 kB< 8.0 kB< 9.8 kB< 10.4 kB< 11.5 kB< 12.0 kB< 15.4 kB
SRAM:< 1.4 kB< 1.6 kB< 1.7 kB< 2.2 kB< 2.2 kB< 2.7 kB< 3.3 kB< 2.1 kB< 5.4 kB
5th Gen Low PowerLP-AOSAMUXFlash:< 7.5 kB< 10.8 kB< 11.3 kB< 7.4 kB< 9.2 kB< 9.6 kB< 11.1 kB< 11.3 kB< 14.4 kB
SRAM:< 1.4 kB< 1.6 kB< 1.7 kB< 2.1 kB< 2.1 kB< 2.6 kB< 3.1 kB< 1.8 kB< 5.1 kB
Widgets
CSD Button3(10 sensors)3(10 sensors)3(10 sensors)    1(1 sensor)1(1 sensor)
CSD Matrix Buttons         
* * \note -* * To select values for the Scan mode and Sensor connection method parameters (for the fifth-generation of the CAPSENSE™ HW) -* navigate to the Advanced tab in the CAPSENSE™ Configurator tool, and then select the General settings sub-tab. +* * To select values for the Scan mode and Sensor connection method parameters (for the fifth-generation of the CAPSENSE™ HW) +* navigate to the Advanced tab in the CAPSENSE™ Configurator tool, and then select the General settings sub-tab. * * * For the forth-generation of the CAPSENSE™ HW, the IntDrv mode with the AMUX sensor connection type is available only. * @@ -543,6 +555,14 @@ * * * +* Rule 11.4 +* A conversion should not be performed between a pointer to object and an integer type. +* +* Advisory. There is an issue with a SYSCLK driver (IFXID-10550), due to which integer type +* is cast to an object pointer type. Code is manually checked and reviewed to be safe. +* +* +* * Rule 11.5 * A conversion should not be performed from pointer to void into pointer to object. * @@ -567,7 +587,7 @@ * * * -* \subsection subsection_capsense_misra-cfg CAPSENSE™ Configurator Generated Sources Deviation +* \subsection subsection_capsense_misra-cfg CAPSENSE™ Configurator Tool Generated Sources Deviation * * * @@ -584,7 +604,7 @@ * * * -* * * @@ -648,10 +668,146 @@ *
Rule 8.4A compatible declaration shall be visible when an object or function with external linkage is defined.The CAPSENSE™ middleware library consists of several modules. One of them is CapSense Built-in Self Test (BIST). +* The CAPSENSE™ middleware library consists of several modules. One of them is CAPSENSE™ Built-in Self Test (BIST). * All the BIST variables are used in other data structures and accessed using pointers.
* * -* -* -* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* * * * @@ -731,7 +887,7 @@ * * * -* * * @@ -880,8 +1036,8 @@ * design guidelines, different interfaces and tuning guidelines necessary * for a successful design of a CAPSENSE™ system is available in the Getting * Started with CAPSENSE™ document and the product-specific CAPSENSE™ design guide. -* CYPRESS™ highly recommends starting with these documents. They can be -* found on the CYPRESS™ web site at www.cypress.com. +* Infineon Technologies highly recommends starting with these documents. They can be +* found on the Infineon Technologies web site at www.infineon.com. * * For more information, refer to the following documents: * @@ -893,12 +1049,12 @@ * * ModusToolbox™ * CAPSENSE™ Tuner Tool Guide * -* * +* * * CAPSENSE™ Design Guide * * * ModusToolbox™ Overview: * -* * +* * * ModusToolbox™ Software Environment, Quick Start Guide, Documentation, * and Videos * @@ -907,45 +1063,39 @@ * * * Infineon Technologies Kits and Code Examples: * -* * +* * * CAPSENSE™ buttons and slider for PSoC™ 6 MCU with Mbed OS * -* * +* * * CAPSENSE™ Middleware Code Example for FreeRTOS * -* * +* * * CY8CKIT-145-40XX PSoC™ 4000S CAPSENSE™ Prototyping Kit * -* * +* * * CY8CKIT-149 PSoC™ 4100S Plus Prototyping Kit * -* * -* CY8CKIT-041-40XX PSoC™ 4 S-Series Pioneer Kit -* -* * -* CY8CKIT-041-41XX PSoC™ 4100S CAPSENSE™ Pioneer Kit -* * * General Information: * -* * +* * * CAT1 PDL API Reference * -* * +* * * CAT2 PDL API Reference * -* * AN210781 Getting Started with +* * AN210781 Getting Started with * PSoC™ 6 MCU with Bluetooth Low Energy (BLE) Connectivity * -* * +* * * PSoC™ 6 Technical Reference Manual * -* * +* * * PSoC™ 4000S Family: PSoC™ 4 Architecture Technical Reference Manual (TRM) * -* * +* * * PSoC™ 4100S and PSoC™ 4100S Plus: PSoC™ 4 Architecture Technical Reference Manual (TRM) * -* * +* * * PSoC™ 63 with BLE Datasheet Programmable System-on-Chip datasheet * * * Infineon Technologies GitHub @@ -1027,6 +1177,8 @@ * initialization is required based on a sensing method or type of * widgets is automatically handled by these functions. Therefore, these * functions are sensing methods, features, and widget type agnostics. +* The only exception is the functions for low power widget scanning, +* they are available only for the fifth-generation low power CAPSENSE™. * * All the tasks required to implement a sensing system can be fulfilled * by the high-level functions. But, there is a set of @@ -1112,6 +1264,10 @@ * program to ensure register map rule are not violated while * modifying the value of data field in CAPSENSE™ Data Structure. * +* Note: If the middleware configuration from the application program is changed +* by writing registers to the data structure, call the Cy_CapSense_Enable() function +* to repeat the initialization process. +* * \} */ /******************************************************************************/ @@ -1137,7 +1293,15 @@ * @@ -1149,7 +1313,11 @@ * * +* \par +* * For the fifth-generation CAPSENSE™ in CS-DMA mode this callback is called * with NULL passed as a parameter. * * @@ -1158,7 +1326,11 @@ * * * +* synchronous communication with the Tuner tool. +* \par +* * For the fifth-generation low power CAPSENSE™ the callback is called only once for each new scan. +* \par +* * For the previous CAPSENSE™ generations the callback is called once per scan cycle or periodically if device is in suspended mode. * * * @@ -1166,7 +1338,8 @@ * * * +* synchronous communication with the Tuner tool. +* * * * @@ -1178,8 +1351,10 @@ * the first initialization scan. Using this callback is not * recommended. It is used only to implement only user's * specific use cases (while changing the CAPSENSE™ -* default configuration). The callback is available for Fifth -* Generation CAPSENSE™ devices. +* default configuration). +* \par +* * The callback is available for Fifth Generation CAPSENSE™ and +* Fifth Generation low power CAPSENSE™ devices. * *
VersionChangesReason for Change
3.0.1Fixed call of Cy_DMAC_Descriptor_SetDstAddress() accordingly to changes -* in DMAC v1.20 mtb-pdl-cat2 driver.mtb-pdl-cat2 v2.0.0 support4.0 +* This version is not backward compatible with the +* previous version due to fifth-generation LP devices support +* implementation and defect fixes. +* We tried to keep the established API, but your design may need to be +* updated to operate with CAPSENSE™ middleware v4.0. +* +*
+* Added CAPSENSE™ fifth-generation LP device support +* +* Feature enhancement +*
+* Added the Inductive sensing method support (ISX) +* +* Feature enhancement +*
+* Added the feature of enabling/disabling widgets and built-in +* self-test working/non-working widgets +* +* Feature enhancement +*
+* Added Multi-phase Self support for fifth-generation LP devices +* +* Feature enhancement +*
+* Updated the CIC2 functionality for the fifth-generation devices +* to be consistent with the fifth-generation LP devices. +* +* Feature enhancement +*
+* Added saturated scan during CAPSENSE™ initialization to measure +* maximum rawcounts precisely instead of using equations. +* +* Feature enhancement +*
+* Changed the meaning of bit[2] of the widget status register in the cy_stc_capsense_widget_context_t: +* logical 1 means the widget is enabled. Replaced CY_CAPSENSE_WD_DISABLE_MASK with +* CY_CAPSENSE_WD_ENABLE_MASK for consistency +* +* Defect fixing +*
+* Swapped the position of bit[0] and bit[1] of the sensor status register in the cy_stc_capsense_sensor_context_t: +* bit[0] reports the Proximity sensor status, bit[1] - the regular sensor status. +* Updated values of CY_CAPSENSE_SNS_PROX_STATUS_MASK and CY_CAPSENSE_SNS_TOUCH_STATUS_MASK macros. +* +* Defect fixing +*
+* Renamed cy_stc_active_scan_sns_t to cy_stc_capsense_active_scan_sns_t. +* +* Following naming convention. Defect fixing +*
+* Renamed cy_stc_msc_channel_config_t to cy_stc_capsense_channel_config_t, updated field names +* +* Following naming convention. Updated for consistency between fifth-generation and fifth-generation LP devices +*
+* Renamed Cy_CapSense_ProcessWidgetMptxDeconvolution() to Cy_CapSense_ProcessWidgetMpDeconvolution() +* +* Updated function name to better reflect its purpose +*
+* Renamed Cy_CapSense_SetCalibrationTargets() to Cy_CapSense_SetCalibrationTarget(), +* updated function interface and implementation to cover all sensing methods. +* +* Feature enhancement. +*
+* Fixed incorrect shield pins configuration for Cy_CapSense_MeasureCapacitanceSensor() +* function for fourth-generation devices +* +* Defect fixing +*
+* Updater measurement error handling for Cy_CapSense_MeasureCapacitanceShieldElectrode(), +* Cy_CapSense_MeasureCapacitanceSlotSensors() and Cy_CapSense_MeasureCapacitanceSensorElectrode() +* functions for fifth-generation devices +* +* Defect fixing +*
+* Optimized cy_stc_capsense_common_config_t structure (renamed fields, removed unused fields) +* +* User experience improvement +*
3.0Improved robustness of a sensing module
Added a possibility to enable / disable independent features of +* Added a possibility to enable/disable independent features of * BIST moduleExpanded flexibility
This is called before each sensor scan triggering. Such a callback * can be used to implement user-specific use cases like changing scan * parameters depending on whether a sensor is going to be scanned. -* For the fifth-generation CAPSENSE™ in CS-DMA mode this callback is called +* \par +* * For fifth-generation low power CAPSENSE™ this callback is called +* by CapSense MW before scan triggering. If a timeout to postpone a scan +* is configured (using Cy_CapSense_ConfigureMsclpTimer() function) then callback +* will be called before this timeout. The StartSample callback is called +* only once before entire frame scan in Cy_CapSense_ScanSlots() +* and Cy_CapSense_ScanLpSlots() functions. +* \par +* * For the fifth-generation CAPSENSE™ in CS-DMA mode this callback is called * only once in Cy_CapSense_ScanSlots() function with NULL passed as a parameter. * In INT driven mode it is called in Cy_CapSense_ScanSlots() and * in Cy_CapSense_ScanISR() function before HW starting the scan. \ref cy_capsense_callback_tThis is called after sensor scan completion and there is no other * sensor in the queue to be scanned. -* For the fifth-generation CAPSENSE™ in CS-DMA mode this callback is called +* \par +* * For the fifth-generation low power CAPSENSE™ this callback is called +* with NULL passed as a parameter.
ptrTunerSendCallback\ref cy_capsense_tuner_send_callback_tThis is called by the Cy_CapSense_RunTuner() function to establish -* synchronous communication with the Tuner tool.
4ptrTunerReceiveCallback\ref cy_capsense_tuner_receive_callback_tThis is called by the Cy_CapSense_RunTuner() function to establish -* synchronous communication with the Tuner tool.
5
* @@ -1222,11 +1397,18 @@ #include "cy_capsense_csx_v2.h" #include "cy_capsense_sensing_v2.h" #include "cy_capsense_selftest_v2.h" -#else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) #include "cy_capsense_generator_v3.h" #include "cy_capsense_sensing_v3.h" #include "cy_capsense_selftest_v3.h" #include "cy_capsense_sm_base_full_wave_v3.h" +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_capsense_generator_lp.h" + #include "cy_capsense_sensing_lp.h" + #include "cy_capsense_selftest_lp.h" + #include "cy_capsense_sm_base_full_wave_lp.h" +#else + /* Supported platform not found */ #endif #endif /* CY_CAPSENSE_H */ diff --git a/cy_capsense_centroid.c b/cy_capsense_centroid.c index 55bc6d3..4b4f622 100644 --- a/cy_capsense_centroid.c +++ b/cy_capsense_centroid.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_centroid.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the source code for the centroid calculation methods @@ -27,8 +27,8 @@ #include "cy_capsense_filter.h" #include "cycfg_capsense_defines.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) +#if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN)) /******************************************************************************* @@ -57,48 +57,47 @@ /** \cond SECTION_CAPSENSE_INTERNAL */ /** \addtogroup group_capsense_internal *//** \{ */ /******************************************************************************/ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) static void Cy_CapSense_TransferTouch( uint32_t newIndex, uint32_t oldIndex, const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) static void Cy_CapSense_NewTouch( uint32_t newIndex, const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) static uint32_t Cy_CapSense_CalcDistance( uint32_t newIndex, uint32_t oldIndex, const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) static void Cy_CapSense_Hungarian( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) static void Cy_CapSense_CopyTouchRecord( cy_stc_capsense_position_t * destination, const cy_stc_capsense_position_t * source); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) __STATIC_INLINE void Cy_CapSense_TouchDownDebounce( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) __STATIC_INLINE void Cy_CapSense_SortByAge( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) __STATIC_INLINE uint8_t Cy_CapSense_GetLowestId(uint8_t idMask); #endif /** \} \endcond */ -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_DIPLEX_SLIDER_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_DIPLEX_SLIDER_EN)) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_DIPLEX_SLIDER_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpCentroidDiplex ****************************************************************************//** @@ -211,12 +210,10 @@ void Cy_CapSense_DpCentroidDiplex( newTouch->numPosition = CY_CAPSENSE_POSITION_NONE; } } -#endif /*((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_DIPLEX_SLIDER_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_DIPLEX_SLIDER_EN)) */ +#endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_DIPLEX_SLIDER_EN) */ -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_LINEAR_SLIDER_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_LINEAR_SLIDER_EN)) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_LINEAR_SLIDER_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpCentroidLinear ****************************************************************************//** @@ -256,7 +253,7 @@ void Cy_CapSense_DpCentroidLinear( uint32_t multiplier; uint32_t offset; - if(snsCount < CY_CAPSENSE_LINEAR_SLIDER_MIN_SNS_COUNT) + if (snsCount < CY_CAPSENSE_LINEAR_SLIDER_MIN_SNS_COUNT) { snsCount = CY_CAPSENSE_LINEAR_SLIDER_MIN_SNS_COUNT; } @@ -328,11 +325,10 @@ void Cy_CapSense_DpCentroidLinear( /* This is a place holder for local maximum searching when number of centroids could be more than one */ } } -#endif /* ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_LINEAR_SLIDER_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_LINEAR_SLIDER_EN)) */ +#endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_LINEAR_SLIDER_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_RADIAL_SLIDER_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_RADIAL_SLIDER_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpCentroidRadial ****************************************************************************//** @@ -435,7 +431,7 @@ void Cy_CapSense_DpCentroidRadial( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_RADIAL_SLIDER_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpCentroidTouchpad ****************************************************************************//** @@ -477,12 +473,12 @@ void Cy_CapSense_DpCentroidTouchpad( uint32_t multiplier; uint32_t offset; - if(CY_CAPSENSE_TOUCHPAD_MIN_COL_SNS_COUNT > colCount) + if (CY_CAPSENSE_TOUCHPAD_MIN_COL_SNS_COUNT > colCount) { colCount = CY_CAPSENSE_TOUCHPAD_MIN_COL_SNS_COUNT; } - if(CY_CAPSENSE_TOUCHPAD_MIN_ROW_SNS_COUNT > rowCount) + if (CY_CAPSENSE_TOUCHPAD_MIN_ROW_SNS_COUNT > rowCount) { rowCount = CY_CAPSENSE_TOUCHPAD_MIN_ROW_SNS_COUNT; } @@ -556,7 +552,7 @@ void Cy_CapSense_DpCentroidTouchpad( newTouch->numPosition = CY_CAPSENSE_POSITION_NONE; } - if(newTouch->numPosition != CY_CAPSENSE_POSITION_NONE) + if (newTouch->numPosition != CY_CAPSENSE_POSITION_NONE) { /*********************************************************************** * Y Axis (Rows) @@ -692,7 +688,7 @@ void Cy_CapSense_DpAdvancedCentroidTouchpad( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_ADVANCED_CENTROID_5X5_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpFindLocalMaxDd ****************************************************************************//** @@ -856,7 +852,7 @@ void Cy_CapSense_DpFindLocalMaxDd( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /* CY_ID633 */ #if defined(__ICCARM__) #pragma optimize=none @@ -896,7 +892,7 @@ void Cy_CapSense_DpCalcTouchPadCentroid( uint32_t touchNum = ptrWdConfig->ptrCsxTouchBuffer->newPeakNumber; cy_stc_capsense_position_t * ptrNewPeak = &ptrWdConfig->ptrCsxTouchBuffer->newPeak[0]; - for(number = 0u; number < touchNum; number++) + for (number = 0u; number < touchNum; number++) { /* Set the sensor pointer to the local maximum sensor */ ptrSnsCxt = ptrWdConfig->ptrSnsContext; @@ -1000,15 +996,24 @@ void Cy_CapSense_DpCalcTouchPadCentroid( /* The Y position is rounded to the nearest integer value and normalized to the resolution range */ ptrNewPeak->y = (uint16_t)(((uint32_t)weightedSumY + CY_CAPSENSE_CENTROID_ROUND_VALUE) >> 8u); - /* The z value is a sum of raw counts of sensors that form 3x3 matrix with a local maximum in the center */ - ptrNewPeak->z = (uint8_t)(totalSum >> CY_CAPSENSE_CSX_TOUCHPAD_Z_SHIFT); + /* The z value is a summ of sensor difference counts divided by 16 that form 3x3 matrix with a local maximum in the center */ + totalSum >>= CY_CAPSENSE_CSX_TOUCHPAD_Z_SHIFT; + if (totalSum > 0xFFu) + { + ptrNewPeak->z = 0xFFu; + } + else + { + ptrNewPeak->z = (uint8_t)totalSum; + } + ptrNewPeak++; } } #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpTouchTracking ****************************************************************************//** @@ -1153,7 +1158,7 @@ void Cy_CapSense_DpTouchTracking( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_TransferTouch ****************************************************************************//** @@ -1208,7 +1213,7 @@ static void Cy_CapSense_TransferTouch( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_NewTouch ****************************************************************************//** @@ -1256,7 +1261,7 @@ static void Cy_CapSense_NewTouch( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_GetLowestId ****************************************************************************//** @@ -1296,7 +1301,7 @@ __STATIC_INLINE uint8_t Cy_CapSense_GetLowestId(uint8_t idMask) #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_TouchDownDebounce ****************************************************************************//** @@ -1333,7 +1338,7 @@ __STATIC_INLINE void Cy_CapSense_TouchDownDebounce( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_CalcDistance ****************************************************************************//** @@ -1374,7 +1379,7 @@ static uint32_t Cy_CapSense_CalcDistance( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_Hungarian ****************************************************************************//** @@ -1508,7 +1513,7 @@ static void Cy_CapSense_Hungarian( } } - if(j == -1) + if (j == -1) { j = 0; } @@ -1557,7 +1562,7 @@ static void Cy_CapSense_Hungarian( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_SortByAge ****************************************************************************//** @@ -1647,7 +1652,7 @@ __STATIC_INLINE void Cy_CapSense_SortByAge( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_CopyTouchRecord ****************************************************************************//** @@ -1670,7 +1675,7 @@ static void Cy_CapSense_CopyTouchRecord( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpFilterTouchRecord ****************************************************************************//** @@ -1817,7 +1822,7 @@ void Cy_CapSense_DpFilterTouchRecord( } else { - ptrWdConfig->ptrWdContext->status = CY_CAPSENSE_WD_ACTIVE_MASK; + ptrWdConfig->ptrWdContext->status |= CY_CAPSENSE_WD_ACTIVE_MASK; } } #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ @@ -2120,7 +2125,7 @@ void Cy_CapSense_RunPositionFiltersRadial( * between the new position and IIR filter history is bigger than * half of resolution, then all enabled position filters are reset. */ - if(temp >= halfResolution) + if (temp >= halfResolution) { /* Perform Initialization */ Cy_CapSense_InitPositionFilters(filterCfg, ptrInput, ptrHistory); @@ -2167,7 +2172,7 @@ void Cy_CapSense_RunPositionFiltersRadial( * between the new position and IIR filter history is bigger than * half of resolution, then all enabled position filters are reset. */ - if(temp >= halfResolution) + if (temp >= halfResolution) { /* Perform Initialization */ Cy_CapSense_InitPositionFilters(filterCfg, ptrInput, ptrHistory); @@ -2287,9 +2292,9 @@ void Cy_CapSense_ProcessPositionFilters( } /* Process touches that exists from previous processing */ - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_RADIAL_SLIDER_EN) &&\ + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_RADIAL_SLIDER_EN) &&\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_POSITION_FILTER_EN)) - if((uint8_t)CY_CAPSENSE_WD_RADIAL_SLIDER_E == ptrWdConfig->wdType) + if ((uint8_t)CY_CAPSENSE_WD_RADIAL_SLIDER_E == ptrWdConfig->wdType) { for (posIndex = 0u; posIndex < numPosMin; posIndex++) { @@ -2328,6 +2333,6 @@ void Cy_CapSense_ProcessPositionFilters( } #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_POSITION_FILTER_EN) */ #endif /* ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN)) */ -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ /* [] END OF FILE */ diff --git a/cy_capsense_centroid.h b/cy_capsense_centroid.h index f535b0d..2711b9c 100644 --- a/cy_capsense_centroid.h +++ b/cy_capsense_centroid.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_centroid.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the function prototypes for the centroid calculation @@ -24,8 +24,8 @@ #include "cy_capsense_structure.h" #include "cycfg_capsense_defines.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) +#if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN)) #if defined(__cplusplus) extern "C" { @@ -45,24 +45,22 @@ extern "C" { /** \addtogroup group_capsense_internal *//** \{ */ /******************************************************************************/ -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_LINEAR_SLIDER_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_LINEAR_SLIDER_EN)) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_LINEAR_SLIDER_EN) void Cy_CapSense_DpCentroidLinear( cy_stc_capsense_touch_t * newTouch, const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_RADIAL_SLIDER_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_RADIAL_SLIDER_EN) void Cy_CapSense_DpCentroidRadial( cy_stc_capsense_touch_t * newTouch, const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_DIPLEX_SLIDER_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_DIPLEX_SLIDER_EN)) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_DIPLEX_SLIDER_EN) void Cy_CapSense_DpCentroidDiplex( cy_stc_capsense_touch_t * newTouch, const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) void Cy_CapSense_DpCentroidTouchpad( cy_stc_capsense_touch_t * newTouch, const cy_stc_capsense_widget_config_t * ptrWdConfig); @@ -72,19 +70,19 @@ extern "C" { cy_stc_capsense_touch_t * newTouch, const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) void Cy_CapSense_DpFindLocalMaxDd( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) void Cy_CapSense_DpCalcTouchPadCentroid( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) void Cy_CapSense_DpTouchTracking( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) void Cy_CapSense_DpFilterTouchRecord( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif @@ -115,7 +113,7 @@ extern "C" { #endif #endif /* ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN)) */ -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif /* CY_CAPSENSE_CENTROID_H */ diff --git a/cy_capsense_common.h b/cy_capsense_common.h index a318980..21ebff9 100644 --- a/cy_capsense_common.h +++ b/cy_capsense_common.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_common.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the common CAPSENSE™ middleware definitions. @@ -22,7 +22,8 @@ #include "cy_sysint.h" #include "cycfg_capsense_defines.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) + +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if defined(__cplusplus) extern "C" { @@ -39,10 +40,12 @@ extern "C" { #define CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN (1u) #define CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN (0u) + #define CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP (0u) #define CY_CAPSENSE_PSOC4_FOURTH_GEN (1u) #define CY_CAPSENSE_PSOC6_FOURTH_GEN (0u) #define CY_CAPSENSE_PSOC4_FIFTH_GEN (0u) + #define CY_CAPSENSE_PSOC4_FIFTH_GEN_LP (0u) #elif (defined(CY_IP_MXCSDV2)) @@ -51,10 +54,12 @@ extern "C" { #define CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN (1u) #define CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN (0u) + #define CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP (0u) #define CY_CAPSENSE_PSOC4_FOURTH_GEN (0u) #define CY_CAPSENSE_PSOC6_FOURTH_GEN (1u) #define CY_CAPSENSE_PSOC4_FIFTH_GEN (0u) + #define CY_CAPSENSE_PSOC4_FIFTH_GEN_LP (0u) #elif (defined(CY_IP_M0S8MSCV3)) @@ -63,10 +68,26 @@ extern "C" { #define CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN (0u) #define CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN (1u) + #define CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP (0u) #define CY_CAPSENSE_PSOC4_FOURTH_GEN (0u) #define CY_CAPSENSE_PSOC6_FOURTH_GEN (0u) #define CY_CAPSENSE_PSOC4_FIFTH_GEN (1u) + #define CY_CAPSENSE_PSOC4_FIFTH_GEN_LP (0u) + +#elif (defined(CY_IP_M0S8MSCV3LP)) + + #define CY_CAPSENSE_PLATFORM_DEVICE_PSOC4 (1u) + #define CY_CAPSENSE_PLATFORM_DEVICE_PSOC6 (0u) + + #define CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN (0u) + #define CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN (0u) + #define CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP (1u) + + #define CY_CAPSENSE_PSOC4_FOURTH_GEN (0u) + #define CY_CAPSENSE_PSOC6_FOURTH_GEN (0u) + #define CY_CAPSENSE_PSOC4_FIFTH_GEN (0u) + #define CY_CAPSENSE_PSOC4_FIFTH_GEN_LP (1u) #endif @@ -75,6 +96,8 @@ extern "C" { #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) #include "cy_csd.h" +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_msclp.h" #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ #include "cy_msc.h" #endif @@ -83,11 +106,11 @@ extern "C" { /** \addtogroup group_capsense_macros_general *//** \{ */ /******************************************************************************/ /** Middleware major version */ -#define CY_CAPSENSE_MW_VERSION_MAJOR (3) +#define CY_CAPSENSE_MW_VERSION_MAJOR (4) /** Middleware minor version */ #define CY_CAPSENSE_MW_VERSION_MINOR (0) /** Middleware version */ -#define CY_CAPSENSE_MW_VERSION (300) +#define CY_CAPSENSE_MW_VERSION (400) #if (CY_CAPSENSE_PSOC6_FOURTH_GEN) /** Defined supported CSD driver version */ @@ -146,6 +169,10 @@ extern "C" { #endif +#if (CY_CAPSENSE_PSOC4_FIFTH_GEN_LP) + #define CY_CAPSENSE_USE_CAPTURE (1u) +#endif + #if !defined (CY_CAPSENSE_USE_CAPTURE) /** Use CSD/MSC Init function */ #define CY_CAPSENSE_USE_CAPTURE (0u) @@ -154,23 +181,6 @@ extern "C" { /** Middleware ID */ #define CY_CAPSENSE_ID (CY_PDL_DRV_ID(0x07uL)) - -/* Scanning status */ -/** The CAPSENSE™ middleware is busy */ -#define CY_CAPSENSE_BUSY (0x80u) -/** The CAPSENSE™ middleware is not busy */ -#define CY_CAPSENSE_NOT_BUSY (0x00u) - -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - /** The CAPSENSE™ middleware busy mask */ - #define CY_CAPSENSE_BUSY_MASK (0xFFu) - /** The MSCv3 channel busy mask */ - #define CY_CAPSENSE_BUSY_CH_MASK (0x01u) - /** All MSCv3 channels busy mask */ - #define CY_CAPSENSE_BUSY_ALL_CH_MASK (0x0Fu) -#endif - - /** CAPSENSE™ MW initialization is done */ #define CY_CAPSENSE_INIT_DONE (1u) /** CAPSENSE™ MW initialization is needed */ @@ -181,23 +191,46 @@ extern "C" { /** Feature disabled */ #define CY_CAPSENSE_DISABLE (0u) -/** Sensor active status mask */ +/** Regular Sensor active status mask */ #define CY_CAPSENSE_SNS_TOUCH_STATUS_MASK (0x01u) -/** Proximity active status mask */ -#define CY_CAPSENSE_SNS_PROX_STATUS_MASK (0x02u) +/** Proximity Sensor active status mask */ +#define CY_CAPSENSE_SNS_PROX_STATUS_MASK (0x01u) +/** Proximity Sensor touch active status mask */ +#define CY_CAPSENSE_SNS_TOUCH_PROX_STATUS_MASK (0x02u) /** Sensor overflow mask */ #define CY_CAPSENSE_SNS_OVERFLOW_MASK (0x04u) + /** Widget active status mask */ #define CY_CAPSENSE_WD_ACTIVE_MASK (0x01u) /** Widget disable status mask */ -#define CY_CAPSENSE_WD_DISABLE_MASK (0x02u) +#define CY_CAPSENSE_WD_ENABLE_MASK (0x02u) /** Widget working status mask */ #define CY_CAPSENSE_WD_WORKING_MASK (0x04u) +/** Widget maximum raw count calculation enable mask */ +#define CY_CAPSENSE_WD_MAXCOUNT_CALC_MASK (0x08u) +/** Widget row maximum raw count calculation enable mask */ +#define CY_CAPSENSE_WD_MAXCOUNT_ROW_CALC_MASK (0x10u) /** \} */ /******************************************************************************/ /** \addtogroup group_capsense_macros_mw_state *//** \{ */ /******************************************************************************/ +/** The CAPSENSE™ middleware is busy */ +#define CY_CAPSENSE_BUSY (0x80u) +/** The CAPSENSE™ middleware is not busy */ +#define CY_CAPSENSE_NOT_BUSY (0x00u) + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + /** The CAPSENSE™ middleware busy mask */ + #define CY_CAPSENSE_BUSY_MASK (0xFFu) + /** The MSCv3 channel busy mask */ + #define CY_CAPSENSE_BUSY_CH_MASK (0x01u) + /** All MSCv3 channels busy mask */ + #define CY_CAPSENSE_BUSY_ALL_CH_MASK (0x0Fu) +#endif + +/** There was any sensor touch detected at the previous low power widget scan */ +#define CY_CAPSENSE_MW_STATE_LP_ACTIVE_MASK (0x400u) /** The BIST is currently in progress */ #define CY_CAPSENSE_MW_STATE_BIST_MASK (0x800u) /** The auto-calibration in Single CDAC mode */ @@ -212,8 +245,24 @@ extern "C" { #define CY_CAPSENSE_MW_STATE_SCAN_SLOT_MASK (0xFFFF0000u) /** Current scan slot position in status */ #define CY_CAPSENSE_MW_STATE_SCAN_SLOT_POS (16u) + +#if (CY_CAPSENSE_PSOC4_FIFTH_GEN_LP) + /** The last or currently scanned widget type is Active widget + * * \note This macro is available only for the fifth-generation low power CAPSENSE™. + */ + #define CY_CAPSENSE_MW_STATE_ACTIVE_WD_SCAN_MASK (0x10u) + /** The last or currently scanned widget type is Low Power widget + * * \note This macro is available only for the fifth-generation low power CAPSENSE™. + */ + #define CY_CAPSENSE_MW_STATE_LP_WD_SCAN_MASK (0x20u) + /** The mask for the last or currently scanned widget type + * * \note This macro is available only for the fifth-generation low power CAPSENSE™. + */ + #define CY_CAPSENSE_MW_STATE_WD_SCAN_MASK (0x30u) +#endif /** \} */ + /******************************************************************************/ /** \addtogroup group_capsense_macros_settings *//** \{ */ /******************************************************************************/ @@ -259,27 +308,19 @@ extern "C" { #define CY_CAPSENSE_BIST_CSX_GROUP (5u) /** BIST shield capacitance measurement group */ #define CY_CAPSENSE_BIST_SHIELD_GROUP (6u) +/** ISX sensing group */ +#define CY_CAPSENSE_ISX_GROUP (10u) +/** MPSC-D sensing group */ +#define CY_CAPSENSE_MPSC_GROUP (11u) -/** Sensing mode undefined */ -#define CY_CAPSENSE_REG_MODE_UNDEFINED (255u) -/** CSD sense mode configuration index */ -#define CY_CAPSENSE_REG_MODE_CSD (0u) -/** CSX sense mode configuration index */ -#define CY_CAPSENSE_REG_MODE_CSX (1u) -/** CSD sense mode configuration index with CapDAC dithering enabled */ -#define CY_CAPSENSE_REG_MODE_CSD_DITHERING (2u) -/** CSX sense mode configuration index with CapDAC dithering enabled */ -#define CY_CAPSENSE_REG_MODE_CSX_DITHERING (3u) - -/** First mode index with CapDAC dithering enabled */ -#define CY_CAPSENSE_REG_MODE_DITHERING (CY_CAPSENSE_REG_MODE_CSD_DITHERING) - -/** Total number of modes */ -#define CY_CAPSENSE_REG_MODE_NUMBER (4u) +/** Total number of mode templates */ +#define CY_CAPSENSE_REG_MODE_NUMBER (6u) /* The values of these macros should be not changed due to CY_ID374670 */ /* Initialization Group */ +/** Pin function undefined */ +#define CY_CAPSENSE_SCW_FUNC_PIN_STATE_IDX_UNDEFINED (255u) /** Control mux switch state is ground */ #define CY_CAPSENSE_CTRLMUX_PIN_STATE_GND (0u) /** Control mux switch state is High-Z */ @@ -299,8 +340,47 @@ extern "C" { /** Control mux switch state defined as CSDBUSC connected electrode */ #define CY_CAPSENSE_CTRLMUX_PIN_STATE_VDDA2 (7u) +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) +/** Pin function undefined */ +#define CY_CAPSENSE_PIN_STATE_IDX_UNDEFINED (255u) +/** Pin function is ground */ +#define CY_CAPSENSE_PIN_STATE_IDX_GND (0u) +/** Pin function is High-Z */ +#define CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z (1u) +/** Pin function is CSX Rx electrode */ +#define CY_CAPSENSE_PIN_STATE_IDX_CSX_RX (2u) +/** Pin function is CSX Tx electrode */ +#define CY_CAPSENSE_PIN_STATE_IDX_CSX_TX (3u) +/** Pin function is CSX Negative Tx electrode */ +#define CY_CAPSENSE_PIN_STATE_IDX_CSX_NEG_TX (4u) +/** Pin function is CSD sensor */ +#define CY_CAPSENSE_PIN_STATE_IDX_CSD_SNS (5u) +/** Pin function is ISX Lx electrode */ +#define CY_CAPSENSE_PIN_STATE_IDX_ISX_LX (6u) +/** Pin function is ISX Rx electrode */ +#define CY_CAPSENSE_PIN_STATE_IDX_ISX_RX (7u) +/** Pin function is Active shield */ +#define CY_CAPSENSE_PIN_STATE_IDX_ACT_SHIELD (8u) +/** Pin function is Passive shield */ +#define CY_CAPSENSE_PIN_STATE_IDX_PAS_SHIELD (9u) +/** Pin function is CSX VDDA/2 connection */ +#define CY_CAPSENSE_PIN_STATE_IDX_CSX_VDDA2 (10u) +/** Pin function is MPSC CSP connection */ +#define CY_CAPSENSE_PIN_STATE_IDX_MPSC_CSP (11u) +/** Pin function is MPSC CSN connection */ +#define CY_CAPSENSE_PIN_STATE_IDX_MPSC_CSN (12u) +/** Pin function is MPSC CSZ connection */ +#define CY_CAPSENSE_PIN_STATE_IDX_MPSC_CSZ (13u) + +/** Number of CTRLMUX Pin States for LP */ +#define CY_CAPSENSE_CTRLMUX_PIN_STATE_NUMBER (14u) + +#else /* All the rest platforms */ + /** Number of CTRLMUX Pin State */ #define CY_CAPSENSE_CTRLMUX_PIN_STATE_NUMBER (8u) +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + /** Number of CTRLMUX Pin State MASK registers */ #define CY_CAPSENSE_CTRLMUX_PIN_STATE_MASK_NUMBER (3u) @@ -329,6 +409,18 @@ extern "C" { #define CY_CAPSENSE_MFS_CH1_INDEX (1u) /** Multi-frequency channel 2 constant */ #define CY_CAPSENSE_MFS_CH2_INDEX (2u) +/** Multi-frequency channel number mask */ +#define CY_CAPSENSE_MFS_FREQ_CHANNELS_NUM_MASK (0xFu) +/** Multi-frequency enable mask */ +#define CY_CAPSENSE_MFS_EN_MASK (0x10u) +/** Multi-frequency channels position */ +#define CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_POS (0x05u) +/** Multi-frequency channels mask */ +#define CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK (0x60u) +/** Multi-frequency channel 1 mask */ +#define CY_CAPSENSE_MFS_WIDGET_FREQ_CH_1_MASK (0x20u) +/** Multi-frequency channel 2 mask */ +#define CY_CAPSENSE_MFS_WIDGET_FREQ_CH_2_MASK (0x40u) /* Inactive sensor connection options */ /** Inactive sensor connection undefined */ @@ -368,6 +460,12 @@ extern "C" { #define CY_CAPSENSE_CSH_PRECHARGE_IO_BUF (1u) #endif +/** Auto-mode of CIC2 Shift mask */ +#define CY_CAPSENSE_CIC_AUTO_MASK (0x80u) +/** CIC2 Shift field position in register */ +#define CY_CAPSENSE_CIC_FIELD_POSITION (28u) + + /* Sense clock selection options */ /** Auto-mode of clock source selection mask */ #define CY_CAPSENSE_CLK_SOURCE_AUTO_MASK (0x80u) @@ -524,19 +622,21 @@ extern "C" { /* Raw count filter macros */ /** Offset of raw count filter history size */ -#define CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_OFFSET (0u) +#define CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_OFFSET (0u) /** Offset of raw count median filter enable mask */ -#define CY_CAPSENSE_RC_FILTER_MEDIAN_EN_OFFSET (4u) +#define CY_CAPSENSE_RC_FILTER_MEDIAN_EN_OFFSET (4u) /** Offset of raw count median filter mode mask */ -#define CY_CAPSENSE_RC_FILTER_MEDIAN_MODE_OFFSET (5u) +#define CY_CAPSENSE_RC_FILTER_MEDIAN_MODE_OFFSET (5u) /** Offset of raw count IIR filter enable mask */ -#define CY_CAPSENSE_RC_FILTER_IIR_EN_OFFSET (7u) +#define CY_CAPSENSE_RC_FILTER_IIR_EN_OFFSET (7u) /** Offset of raw count IIR filter mode mask */ -#define CY_CAPSENSE_RC_FILTER_IIR_MODE_OFFSET (8u) +#define CY_CAPSENSE_RC_FILTER_IIR_MODE_OFFSET (8u) /** Offset of raw count average filter enable mask */ -#define CY_CAPSENSE_RC_FILTER_AVERAGE_EN_OFFSET (10u) +#define CY_CAPSENSE_RC_FILTER_AVERAGE_EN_OFFSET (10u) /** Offset of raw count average filter mode mask */ -#define CY_CAPSENSE_RC_FILTER_AVERAGE_MODE_OFFSET (11u) +#define CY_CAPSENSE_RC_FILTER_AVERAGE_MODE_OFFSET (11u) +/** Offset of raw count HW IIR filter enable mask */ +#define CY_CAPSENSE_RC_HW_IIR_FILTER_EN_OFFSET (13u) /** Mask of raw count filter history size */ #define CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_MASK ((uint16_t)((uint16_t)0x000Fu << CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_OFFSET)) @@ -552,6 +652,8 @@ extern "C" { #define CY_CAPSENSE_RC_FILTER_AVERAGE_EN_MASK ((uint16_t)((uint16_t)0x0001u << CY_CAPSENSE_RC_FILTER_AVERAGE_EN_OFFSET)) /** Average raw count filter mode mask */ #define CY_CAPSENSE_RC_FILTER_AVERAGE_MODE_MASK ((uint16_t)((uint16_t)0x0003u << CY_CAPSENSE_RC_FILTER_AVERAGE_MODE_OFFSET)) +/** Raw count HW IIR filter enable mask */ +#define CY_CAPSENSE_RC_HW_IIR_FILTER_EN_MASK ((uint16_t)((uint16_t)0x0001u << CY_CAPSENSE_RC_HW_IIR_FILTER_EN_OFFSET)) /** All raw count filters enable mask */ #define CY_CAPSENSE_RC_FILTER_ALL_EN_MASK (CY_CAPSENSE_RC_FILTER_MEDIAN_EN_MASK |\ CY_CAPSENSE_RC_FILTER_IIR_EN_MASK |\ @@ -565,11 +667,11 @@ extern "C" { /** \} */ /* Slot configuration */ -/** Shield only slot */ +/** Shield only slot, can be assigned to the \ref cy_stc_capsense_scan_slot_t::wdId */ #define CY_CAPSENSE_SLOT_SHIELD_ONLY (0xFFFDu) -/** TX only slot */ +/** TX only slot, can be assigned to the \ref cy_stc_capsense_scan_slot_t::wdId */ #define CY_CAPSENSE_SLOT_TX_ONLY (0xFFFEu) -/** Empty slot */ +/** Empty slot, can be assigned to the \ref cy_stc_capsense_scan_slot_t::wdId */ #define CY_CAPSENSE_SLOT_EMPTY (0xFFFFu) /* Centroid configuration */ @@ -662,6 +764,14 @@ extern "C" { #define CY_CAPSENSE_MPTX_MIN_ORDER (4u) /** Multi-phase TX max order */ #define CY_CAPSENSE_MPTX_MAX_ORDER (32u) + +/** Multi-phase Self-Cap min order */ +#define CY_CAPSENSE_MPSC_MIN_ORDER (5u) +/** Multi-phase Self-Cap max order */ +#define CY_CAPSENSE_MPSC_MAX_ORDER (32u) + +/** Multi-phase max order */ +#define CY_CAPSENSE_MULTIPHASE_MAX_ORDER (32u) /** \} */ /******************************************************************************/ @@ -675,20 +785,44 @@ extern "C" { #define CY_CAPSENSE_SHIELD (2u) /** Configuring of pin as a CSD sensor */ #define CY_CAPSENSE_SENSOR (3u) -/** Configuring of pin as a Tx */ +/** Configuring of pin as a CSX Tx electrode */ #define CY_CAPSENSE_TX_PIN (4u) -/** Configuring of pin as a Rx */ +/** Configuring of pin as a CSX Rx electrode */ #define CY_CAPSENSE_RX_PIN (5u) -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) -/** Configuring of pin as a negative Tx - * \note This macro is available only for the fifth-generation CAPSENSE™. - */ -#define CY_CAPSENSE_NEGATIVE_TX_PIN (6u) -#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + /** Configuring of pin as a negative Tx + * \note This macro is available only for the fifth-generation CAPSENSE™ and the fifth-generation low power + * CAPSENSE™ + */ + #define CY_CAPSENSE_NEGATIVE_TX_PIN (6u) + /** Configuring of pin as an ISX Lx + * \note This macro is available only for the fifth-generation CAPSENSE™ and the fifth-generation low power + * CAPSENSE™ + */ + #define CY_CAPSENSE_ISX_LX_PIN (7u) + /** Configuring of pin as an ISX Rx + * \note This macro is available only for the fifth-generation CAPSENSE™ and the fifth-generation low power + * CAPSENSE™ + */ + #define CY_CAPSENSE_ISX_RX_PIN (8u) + /** Configuring of pin as an ISX Rx + * \note This macro is available only for the fifth-generation CAPSENSE™ and the fifth-generation low power + * CAPSENSE™ + */ + #define CY_CAPSENSE_VDDA2 (9u) +#endif /* ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) */ + /** Pin is not connected to scanning bus */ #define CY_CAPSENSE_SNS_DISCONNECTED (0u) /** Pin is connected to scanning bus */ #define CY_CAPSENSE_SNS_CONNECTED (1u) + +/** Defines pin state as not controlled by / disconnected from MSCLP HW block */ +#define CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS (0u) +/** Defines pin state as controlled by / connected to MSCLP HW block */ +#define CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN (1u) + /** \} */ /******************************************************************************/ @@ -701,11 +835,25 @@ extern "C" { /** Defines the status if restart was done in Cy_CapSense_RunTuner() */ #define CY_CAPSENSE_STATUS_RESTART_DONE (0x01u) #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) -/** Number of supported idac gains */ -#define CY_CAPSENSE_IDAC_GAIN_NUMBER (6u) + /** The size of the idac gain look-up table */ + #define CY_CAPSENSE_IDAC_GAIN_TABLE_SIZE (7u) + + #if (CY_CAPSENSE_PLATFORM_DEVICE_PSOC4) + #if (2u <= CY_IP_M0S8CSDV2_VERSION) + /** Defines the number of supported idac gains for the CSDv2_ver2-based devices */ + #define CY_CAPSENSE_IDAC_GAIN_NUMBER (7u) + #else + /** Defines the number of supported idac gains for the CSDv2_ver1-based devices */ + #define CY_CAPSENSE_IDAC_GAIN_NUMBER (6u) + #endif + #else + #define CY_CAPSENSE_IDAC_GAIN_NUMBER (6u) + #endif #endif /** 100% value */ #define CY_CAPSENSE_PERCENTAGE_100 (100u) +/** An approximate duration in CPU cycles of the check loop with the software watchdog timer */ +#define CY_CAPSENSE_APPROX_LOOP_DURATION (5u) /* Scope of scanning macros */ /** Widget scanning scope is a single sensor */ @@ -728,7 +876,15 @@ extern "C" { #define CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING (2u) /** CAPSENSE™ related HW is configured to execute the BIST functions */ #define CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY (3u) - +/** CAPSENSE™ related HW is configured to the MPSC scanning */ +#define CY_CAPSENSE_HW_CONFIG_MPSC_SCANNING (4u) +/** CAPSENSE™ related HW is configured to execute a scan with the saturated channel */ +#define CY_CAPSENSE_HW_CONFIG_CHANNEL_SATURATION (5u) +/** CAPSENSE™ related HW is configured to the smart sense */ +#define CY_CAPSENSE_HW_CONFIG_SMARTSENSE (6u) + +/** Maximum Decimation Rate */ +#define CY_CAPSENSE_MAX_DECIMATION_RATE (255u) /** \} */ @@ -747,58 +903,80 @@ extern "C" { #define CY_CAPSENSE_BIST_SNS_CAP_MASK ((uint32_t)CY_CAPSENSE_TST_SNS_CAP_EN << 4uL) /** The mask for a shield capacitance measurement test */ #define CY_CAPSENSE_BIST_SHIELD_CAP_MASK ((uint32_t)CY_CAPSENSE_TST_SH_CAP_EN << 5uL) -#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) - /** The mask for an external capacitor capacitance measurement test */ - #define CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK ((uint32_t)CY_CAPSENSE_TST_EXTERNAL_CAP_EN << 6uL) - /** The mask for a VDDA measurement test */ - #define CY_CAPSENSE_BIST_VDDA_MASK ((uint32_t)CY_CAPSENSE_TST_VDDA_EN << 7uL) -#else - /** The mask for an electrode capacitance measurement test */ - #define CY_CAPSENSE_BIST_ELTD_CAP_MASK ((uint32_t)CY_CAPSENSE_TST_ELTD_CAP_EN << 8uL) -#endif - +/** The mask for an external capacitor capacitance measurement test */ +#define CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK ((uint32_t)CY_CAPSENSE_TST_EXTERNAL_CAP_EN << 6uL) +/** The mask for a VDDA measurement test */ +#define CY_CAPSENSE_BIST_VDDA_MASK ((uint32_t)CY_CAPSENSE_TST_VDDA_EN << 7uL) +/** The mask for an electrode capacitance measurement test */ +#define CY_CAPSENSE_BIST_ELTD_CAP_MASK ((uint32_t)CY_CAPSENSE_TST_ELTD_CAP_EN << 8uL) #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) /** The mask for all enabled self-test functions */ #define CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK (CY_CAPSENSE_BIST_CRC_WDGT_MASK | \ - CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK | \ - CY_CAPSENSE_BIST_SNS_CAP_MASK | \ - CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK |\ - CY_CAPSENSE_BIST_VDDA_MASK |\ - CY_CAPSENSE_BIST_SHIELD_CAP_MASK) + CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK | \ + CY_CAPSENSE_BIST_SNS_CAP_MASK | \ + CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK |\ + CY_CAPSENSE_BIST_VDDA_MASK |\ + CY_CAPSENSE_BIST_SHIELD_CAP_MASK) /** The mask for all enabled measurement self-test functions */ #define CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN (CY_CAPSENSE_BIST_EN && \ - (CY_CAPSENSE_TST_SNS_CAP_EN || \ - CY_CAPSENSE_TST_SH_CAP_EN ||\ - CY_CAPSENSE_TST_VDDA_EN ||\ - CY_CAPSENSE_TST_EXTERNAL_CAP_EN)) + (CY_CAPSENSE_TST_SNS_CAP_EN || \ + CY_CAPSENSE_TST_SH_CAP_EN ||\ + CY_CAPSENSE_TST_VDDA_EN ||\ + CY_CAPSENSE_TST_EXTERNAL_CAP_EN)) /** The mask for all enabled self-test functions which changes HW configuration */ #define CY_CAPSENSE_TST_HW_GROUP_EN (CY_CAPSENSE_BIST_EN && \ - (CY_CAPSENSE_TST_SNS_SHORT_EN ||\ - CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) + (CY_CAPSENSE_TST_SNS_SHORT_EN ||\ + CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + /** The mask for all enabled self-test functions */ + #define CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK (CY_CAPSENSE_BIST_CRC_WDGT_MASK | \ + CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK | \ + CY_CAPSENSE_BIST_SNS_CAP_MASK | \ + CY_CAPSENSE_BIST_ELTD_CAP_MASK | \ + CY_CAPSENSE_BIST_SHIELD_CAP_MASK) -#else + /** The mask for all enabled measurement self-test functions */ + #define CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN (CY_CAPSENSE_BIST_EN && \ + (CY_CAPSENSE_TST_SNS_CAP_EN || \ + CY_CAPSENSE_TST_SH_CAP_EN ||\ + CY_CAPSENSE_TST_ELTD_CAP_EN)) + /** The mask for all enabled self-test functions which changes HW configuration */ + #define CY_CAPSENSE_TST_HW_GROUP_EN (CY_CAPSENSE_BIST_EN && \ + (CY_CAPSENSE_TST_SNS_SHORT_EN ||\ + CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) +#else /** The mask for all enabled self-test functions */ #define CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK (CY_CAPSENSE_BIST_CRC_WDGT_MASK | \ - CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK | \ - CY_CAPSENSE_BIST_SNS_CAP_MASK | \ - CY_CAPSENSE_BIST_ELTD_CAP_MASK | \ - CY_CAPSENSE_BIST_SHIELD_CAP_MASK) + CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK | \ + CY_CAPSENSE_BIST_SNS_CAP_MASK | \ + CY_CAPSENSE_BIST_ELTD_CAP_MASK | \ + CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK |\ + CY_CAPSENSE_BIST_VDDA_MASK |\ + CY_CAPSENSE_BIST_SHIELD_CAP_MASK) /** The mask for all enabled measurement self-test functions */ #define CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN (CY_CAPSENSE_BIST_EN && \ - (CY_CAPSENSE_TST_SNS_CAP_EN || \ - CY_CAPSENSE_TST_SH_CAP_EN ||\ - CY_CAPSENSE_TST_ELTD_CAP_EN)) + (CY_CAPSENSE_TST_SNS_CAP_EN || \ + CY_CAPSENSE_TST_SH_CAP_EN ||\ + CY_CAPSENSE_TST_ELTD_CAP_EN ||\ + CY_CAPSENSE_TST_VDDA_EN ||\ + CY_CAPSENSE_TST_EXTERNAL_CAP_EN)) /** The mask for all enabled self-test functions which changes HW configuration */ #define CY_CAPSENSE_TST_HW_GROUP_EN (CY_CAPSENSE_BIST_EN && \ - (CY_CAPSENSE_TST_SNS_SHORT_EN ||\ - CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) + (CY_CAPSENSE_TST_SNS_SHORT_EN ||\ + CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) +#endif +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + /** The estimated serial resistance value of the external capacitor charging/discharging + * circuit including GPIO, AMuxBus, PCB and all another resistances. The value is used + * for the external capacitor charging/discharging time estimations */ + #define CY_CAPSENSE_BIST_EXT_CAP_SERIAL_RESISTANCE (1000u) #endif /** \} */ @@ -832,20 +1010,85 @@ extern "C" { /** Return status \ref cy_capsense_status_t of CAPSENSE™ operation: Unable to perform calibration */ #define CY_CAPSENSE_STATUS_CALIBRATION_CHECK_FAIL (0x400u) /** Return status \ref cy_capsense_status_t of CAPSENSE™ operation: Sense Clock Divider -* is out of the valid range for the specified Clock source configuration +* is out of the valid range for the specified Clock source configuration */ #define CY_CAPSENSE_STATUS_BAD_CLOCK_CONFIG (0x800u) +/** Return status \ref cy_capsense_status_t of CAPSENSE™ operation: Used scan configuration +* is not sufficient to accumulate at least one valid CIC2 sample. +*/ +#define CY_CAPSENSE_STATUS_CIC2_ACC_UNDERFLOW (0x1000u) + +/** Return status \ref cy_capsense_status_t of CAPSENSE™ operation: Used scan configuration +* leads to the overflow in the CIC2 accumulation register. +*/ +#define CY_CAPSENSE_STATUS_CIC2_ACC_OVERFLOW (0x2000u) +/** Return status \ref cy_capsense_status_t of CAPSENSE™ operation: Unable to perform a scan when MPSC sensors and +* other sense method sensors are located in the same frame +*/ +#define CY_CAPSENSE_STATUS_MIXED_SENSORS (0x4000u) /** Return status \ref cy_capsense_status_t of CAPSENSE™ operation: Unknown */ #define CY_CAPSENSE_STATUS_UNKNOWN (0x80000000u) +/** State of Low Power sensor processing mask */ +#define CY_CAPSENSE_LP_PROCESS_ENABLED_MASK (0x1uL) + /** \} */ -#define CY_CAPSENSE_BYTES_IN_16_BITS (2u) -#define CY_CAPSENSE_BYTE_IN_32_BIT (4u) +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + /* HW IIR Filter enable status for Active widgets */ + #define CY_CAPSENSE_RC_HW_IIR_FILTER_EN (CY_CAPSENSE_REGULAR_RC_HW_IIR_FILTER_EN || \ + CY_CAPSENSE_PROX_RC_HW_IIR_FILTER_EN) +#else + #define CY_CAPSENSE_RC_HW_IIR_FILTER_EN (0u) +#endif + +/* Shift to 8 bits */ +#define CY_CAPSENSE_BYTE_SHIFT (8u) + +/* The time interval is required for settling analog part of the HW block. */ +#define CY_CAPSENSE_ANALOG_SETTLING_TIME_US (25u) + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) +/* The time interval in us is required for settling analog part of the MSCLP HW block. */ +#define CY_CAPSENSE_MSCLP_HW_SETTLING_TIME_US (10u) + +/* The Sequencer FSM Operating Mode, +* to be used with cy_stc_capsense_internal_context_t::operatingMode +*/ +#define CY_CAPSENSE_MODE_CPU (0x0u) /* The regular (interrupt-driven) CPU mode */ +#define CY_CAPSENSE_MODE_AS_MS (0x2u) /* The Autonomous-Scan Multi-Sensor Mode */ +#define CY_CAPSENSE_MODE_LP_AOS (0x3u) /* The Low Power Always-On-Scanning Mode */ + +/* These definitions on CDAC_ FINE below should be removed once Configurator support achieved */ +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + #if !defined(CY_CAPSENSE_CSD_CDAC_FINE_EN) + #define CY_CAPSENSE_CSD_CDAC_FINE_EN (CY_CAPSENSE_ENABLE) + #endif +#endif + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + #if !defined(CY_CAPSENSE_CSX_CDAC_FINE_EN) + #define CY_CAPSENSE_CSX_CDAC_FINE_EN (CY_CAPSENSE_ENABLE) + #endif +#endif + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + #if !defined(CY_CAPSENSE_ISX_CDAC_FINE_EN) + #define CY_CAPSENSE_ISX_CDAC_FINE_EN (CY_CAPSENSE_DISABLE) + #endif +#endif + +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + +#define CY_CAPSENSE_BYTES_IN_16_BITS (2uL) +#define CY_CAPSENSE_BYTE_IN_32_BIT (4uL) #define CY_CAPSENSE_CONVERSION_MEGA (1000000u) #define CY_CAPSENSE_CONVERSION_KILO (1000u) +#define CY_CAPSENSE_CONVERSION_HECTO (100u) +#define CY_CAPSENSE_CONVERSION_DEKA (10u) #define CY_CAPSENSE_DIVIDER_TWO (2u) #define CY_CAPSENSE_16_BIT_MASK (0xFFFFu) +#define CY_CAPSENSE_14_BIT_MASK (0x3FFFu) /* * These defines are obsolete and kept for backward compatibility only. @@ -861,7 +1104,7 @@ extern "C" { } #endif -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif /* CY_CAPSENSE_COMMON_H */ diff --git a/cy_capsense_control.c b/cy_capsense_control.c index 7af6f7f..89b5571 100644 --- a/cy_capsense_control.c +++ b/cy_capsense_control.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_control.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the source code to the Control module functions. @@ -30,12 +30,21 @@ #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) #include "cy_capsense_sensing_v2.h" #include "cy_csd.h" +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_capsense_sensing_lp.h" + #include "cy_msclp.h" #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ #include "cy_capsense_sensing_v3.h" #include "cy_msc.h" #endif -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if !defined(CY_CAPSENSE_SMARTSENSE_LP_HW_EN) + #define CY_CAPSENSE_SMARTSENSE_LP_HW_EN (0u) + #endif +#endif /******************************************************************************* * Function Name: Cy_CapSense_Init @@ -90,6 +99,9 @@ * program according to the examples below:
* For PSoC™ 4 CPU or for PSoC™ 6 CM0+ core: * \snippet capsense/snippet/main.c snippet_m0p_capsense_interrupt_source_declaration +* \note MSCLP HW contains two interrupt sources. +* The CAPSENSE™ Middleware supports only the msclp_interrupt_lp_IRQn +* vector and therefore it should be used. * * For CM4 core: * \snippet capsense/snippet/main.c snippet_m4_capsense_interrupt_source_declaration @@ -104,20 +116,17 @@ * the following default names are used: * * csd_\_csd_\_HW - for forth-generation CAPSENSE™ HW. * * msc_\_msc_\_HW - for fifth-generation CAPSENSE™ HW. +* * msclp_\_msclp_\_HW - for fifth-generation low power CAPSENSE™ HW. * *******************************************************************************/ cy_capsense_status_t Cy_CapSense_Init(cy_stc_capsense_context_t * context) { cy_capsense_status_t result = CY_CAPSENSE_STATUS_BAD_PARAM; cy_stc_capsense_internal_context_t * ptrInternalCxt; + uint32_t wdIndex; + cy_stc_capsense_widget_context_t * ptrWdCxt; - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN)) - uint32_t wdIndex; - cy_stc_capsense_widget_context_t * ptrWdCxt; - const cy_stc_capsense_widget_config_t * ptrWdCfg; - #endif + #if((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) const cy_stc_capsense_common_config_t * ptrCommonCfg; #endif @@ -126,59 +135,100 @@ cy_capsense_status_t Cy_CapSense_Init(cy_stc_capsense_context_t * context) ptrInternalCxt = context->ptrInternalContext; ptrInternalCxt->intrCsdInactSnsConn = CY_CAPSENSE_SNS_CONNECTION_UNDEFINED; ptrInternalCxt->intrCsxInactSnsConn = CY_CAPSENSE_SNS_CONNECTION_UNDEFINED; + ptrInternalCxt->ptrSSCallback = NULL; ptrInternalCxt->ptrEOSCallback = NULL; ptrInternalCxt->ptrTunerReceiveCallback = NULL; ptrInternalCxt->ptrTunerSendCallback = NULL; - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN)) - ptrWdCfg = context->ptrWdConfig; - for (wdIndex = 0u; wdIndex < context->ptrCommonConfig->numWd; wdIndex++) - { - ptrWdCxt = ptrWdCfg->ptrWdContext; - if(CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) - { - ptrWdCxt->snsClk = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK; - ptrWdCxt->rowSnsClk = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK; - } + ptrWdCxt = context->ptrWdConfig->ptrWdContext; + for (wdIndex = 0u; wdIndex < CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex++) + { + ptrWdCxt->status |= (CY_CAPSENSE_WD_ENABLE_MASK | CY_CAPSENSE_WD_WORKING_MASK); + ptrWdCxt++; + } - ptrWdCfg++; - } - #endif + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + /* Set the maximum refresh rate (default value) for ACTIVE scan mode */ + ptrInternalCxt->activeWakeupTimer = 0u; + /* Set default compensation factor for nominal ILO frequency (40KHz) */ + ptrInternalCxt->iloCompensationFactor = CY_CAPSENSE_DEFAULT_ILO_FACTOR; + #endif + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) ptrCommonCfg = context->ptrCommonConfig; - result = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_UNDEFINED, context); - ptrInternalCxt->ptrEODsInitCallback = NULL; - - ptrInternalCxt->numEpiCycles = ptrCommonCfg->numEpiCycles; + ptrInternalCxt->intrIsxInactSnsConn = CY_CAPSENSE_SNS_CONNECTION_UNDEFINED; + ptrInternalCxt->intrCsdRawTarget = ptrCommonCfg->csdRawTarget; + ptrInternalCxt->intrCsxRawTarget = ptrCommonCfg->csxRawTarget; + ptrInternalCxt->intrIsxRawTarget = ptrCommonCfg->isxRawTarget; ptrInternalCxt->numCoarseInitChargeCycles = ptrCommonCfg->numCoarseInitChargeCycles; ptrInternalCxt->numCoarseInitSettleCycles = ptrCommonCfg->numCoarseInitSettleCycles; - ptrInternalCxt->numFineInitWaitCycles = context->ptrCommonContext->numFineInitWaitCycles; ptrInternalCxt->numProOffsetCycles = ptrCommonCfg->numProOffsetCycles; ptrInternalCxt->proOffsetCdacComp = ptrCommonCfg->proOffsetCdacComp; - /* Set auto-calibration internal parameters */ - ptrInternalCxt->intrCsdRawTarget = ptrCommonCfg->csdRawTarget; - ptrInternalCxt->intrCsxRawTarget = ptrCommonCfg->csxRawTarget; + ptrInternalCxt->lfsrPoly = CY_CAPSENSE_LFSR_POLY; + ptrInternalCxt->lfsrScale = CY_CAPSENSE_LFSR_SCALE; + ptrInternalCxt->cdacDitherSeed = CY_CAPSENSE_CDAC_DITHER_SEED; + ptrInternalCxt->cdacDitherPoly = CY_CAPSENSE_CDAC_DITHER_POLY; + ptrInternalCxt->modClk = CY_CAPSENSE_MODCLK_DIV; + + ptrWdCxt = context->ptrWdConfig->ptrWdContext; + for (wdIndex = 0u; wdIndex < CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex++) + { + if(0u == ptrWdCxt->maxRawCount) + { + ptrWdCxt->status |= CY_CAPSENSE_WD_MAXCOUNT_CALC_MASK; + } + if(0u == ptrWdCxt->maxRawCountRow) + { + ptrWdCxt->status |= CY_CAPSENSE_WD_MAXCOUNT_ROW_CALC_MASK; + } + ptrWdCxt++; + } + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + ptrInternalCxt->numEpiCycles = ptrCommonCfg->numEpiCycles; + ptrInternalCxt->numFineInitWaitCycles = CY_CAPSENSE_NUM_FINE_INIT_WAIT_CYCLES; + ptrInternalCxt->numFineInitCycles = CY_CAPSENSE_NUM_FINE_INIT_CYCLES; + + #if (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) + /* Set undefined value to initiate DMA configuration in Cy_CapSense_ScanSlots() function */ + ptrInternalCxt->currentSlotIndex = CY_CAPSENSE_SLOT_COUNT_MAX_VALUE; + (void)Cy_CapSense_InitializeDmaArrays(context); + #endif + #endif - #if (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) - /* Set undefined value to initiate DMA configuration in Cy_CapSense_ScanSlots() function */ - context->ptrInternalContext->currentSlotIndex = CY_CAPSENSE_SLOT_COUNT_MAX_VALUE; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + ptrInternalCxt->numProWaitKrefDelay = ptrCommonCfg->numProWaitKrefDelay; + ptrInternalCxt->numProWaitKrefDelayPrs = ptrCommonCfg->numProWaitKrefDelayPrs; + ptrInternalCxt->numEpiKrefDelay = ptrCommonCfg->numEpiKrefDelay; + ptrInternalCxt->numEpiKrefDelayPrs = ptrCommonCfg->numEpiKrefDelayPrs; + ptrInternalCxt->mrssStateAfterScan = CY_CAPSENSE_MRSS_TURN_OFF; + + ptrInternalCxt->numFineInitCycles = CY_CAPSENSE_NUM_FINE_INIT_CYCLES; + ptrInternalCxt->csdCdacDitherEn = CY_CAPSENSE_CSD_CDAC_DITHER_EN; + ptrInternalCxt->csxCdacDitherEn = CY_CAPSENSE_CSX_CDAC_DITHER_EN; + ptrInternalCxt->isxCdacDitherEn = CY_CAPSENSE_ISX_CDAC_DITHER_EN; + ptrInternalCxt->bslnCoefSlow = CY_CAPSENSE_BSLN_COEFF_SLOW; + ptrInternalCxt->bslnCoefFast = CY_CAPSENSE_BSLN_COEFF_FAST; + ptrInternalCxt->bslnUpdateDelay = CY_CAPSENSE_BSLN_UPDATE_DELAY; + ptrInternalCxt->iirCoeffLp = CY_CAPSENSE_IIR_COEFF_LP; + ptrInternalCxt->wotScanInterval = CY_CAPSENSE_WOT_SCAN_INTERVAL; + ptrInternalCxt->wotTimeout = CY_CAPSENSE_WOT_TIMEOUT; #endif + result = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_UNDEFINED, context); + if (CY_CAPSENSE_STATUS_SUCCESS == result) { result = Cy_CapSense_Restore(context); } - #else - result = Cy_CapSense_Restore(context); #endif - /* The time interval is required for settling analog part of the HW block. */ - Cy_SysLib_DelayUs(CY_CAPSENSE_ANALOG_SETTLING_TIME_US); + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + result = Cy_CapSense_Restore(context); + #endif } return result; @@ -203,7 +253,7 @@ cy_capsense_status_t Cy_CapSense_Init(cy_stc_capsense_context_t * context) * Basic tab, the auto-tuning functionality is executed to set the optimal * values for the CAPSENSE™ HW block parameters of the widgets/sensors. * 5. Calibrate the sensors and find the optimal values for DACs of each widget/sensor, -* if the auto-calibration is enabled in the CSD Setting or CSX Setting tabs. +* if the auto-calibration is enabled in the CSD Settings, CSX Settings or ISX Settings tabs. * 6. Perform scanning for all the sensors and initialize the baseline history. * 7. If the firmware filters are enabled in the Advanced General tab, the * filter histories are also initialized. @@ -216,6 +266,9 @@ cy_capsense_status_t Cy_CapSense_Init(cy_stc_capsense_context_t * context) * The repeated call of this function is also done inside the * Cy_CapSense_RunTuner() function when a restart command is received. * +* The function calls the Cy_CapSense_ScanAllWidgets() function to proper +* baseline setup. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -234,6 +287,9 @@ cy_capsense_status_t Cy_CapSense_Init(cy_stc_capsense_context_t * context) * program according to the examples below:
* For CM0+ core: * \snippet capsense/snippet/main.c snippet_m0p_capsense_interrupt_source_declaration +* \note MSCLP HW contains two interrupt sources. +* The CAPSENSE™ Middleware supports only the msclp_interrupt_lp_IRQn +* vector and therefore it should be used. * * For CM4 core: * \snippet capsense/snippet/main.c snippet_m4_capsense_interrupt_source_declaration @@ -248,6 +304,7 @@ cy_capsense_status_t Cy_CapSense_Init(cy_stc_capsense_context_t * context) * the following default names are used: * * csd_\_csd_\_HW - for forth-generation CAPSENSE™ HW. * * msc_\_msc_\_HW - for fifth-generation CAPSENSE™ HW. +* * msclp_\_msclp_\_HW - for fifth-generation low power CAPSENSE™ HW. * *******************************************************************************/ cy_capsense_status_t Cy_CapSense_Enable(cy_stc_capsense_context_t * context) @@ -255,10 +312,10 @@ cy_capsense_status_t Cy_CapSense_Enable(cy_stc_capsense_context_t * context) cy_capsense_status_t result; uint32_t cpuFreqMHz; uint32_t watchdogCounter; - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) context->ptrCommonContext->status |= CY_CAPSENSE_MW_STATE_INITIALIZATION_MASK; uint32_t widgetId; - #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + #endif /* Approximate duration of Wait For Init loop */ const uint32_t isBusyLoopDuration = 5uL; @@ -266,36 +323,78 @@ cy_capsense_status_t Cy_CapSense_Enable(cy_stc_capsense_context_t * context) /* Wait For Init watchdog timeout in microseconds */ const uint32_t isBusyWatchdogTimeUs = 1000000uL; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + context->ptrInternalContext->hwIirInit = 0u; + (void)Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT, context); + #endif + /* Initialize CAPSENSE™ modules */ result = Cy_CapSense_Initialize(context); - if(CY_CAPSENSE_STATUS_SUCCESS == result) + if (CY_CAPSENSE_STATUS_SUCCESS == result) { #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN)) result |= Cy_CapSense_SsAutoTune(context); #elif (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) - result |= Cy_CapSense_CalibrateAllCsdWidgets(context); + result |= Cy_CapSense_CalibrateAllCsdWidgets(context); #endif #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) result |= Cy_CapSense_CalibrateAllCsxWidgets(context); #endif - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN)) result |= Cy_CapSense_SsAutoTune(context); #endif #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) + result |= Cy_CapSense_CalibrateAllSlots(context); + #endif + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_LP_HW_EN)) + result |= Cy_CapSense_SsAutoTune(context); + #endif + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) { result |= Cy_CapSense_CalibrateAllSlots(context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + result |= Cy_CapSense_CalibrateAllLpSlots(context); + #endif /* CY_CAPSENSE_LP_EN */ } #endif #endif - result |= Cy_CapSense_ScanAllWidgets(context); + /* Scan each widget separately if the MPSC is enabled */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + for (widgetId = 0u; widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT; widgetId++) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != context->ptrWdConfig[widgetId].wdType) + { + result |= Cy_CapSense_ScanSlots(context->ptrWdConfig[widgetId].firstSlotId, + context->ptrWdConfig[widgetId].numSlots, context); + } + #else + result |= Cy_CapSense_ScanSlots(context->ptrWdConfig[widgetId].firstSlotId, + context->ptrWdConfig[widgetId].numSlots, context); + #endif + + result |= Cy_CapSense_WaitEndScan(1000000uL, context); /* 1sec timeout */ + } + #else + result |= Cy_CapSense_ScanAllSlots(context); + #endif /* CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED */ + #else + result |= Cy_CapSense_ScanAllWidgets(context); + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ /* Init Watchdog Counter to prevent a hang */ cpuFreqMHz = context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA; @@ -303,23 +402,42 @@ cy_capsense_status_t Cy_CapSense_Enable(cy_stc_capsense_context_t * context) while (CY_CAPSENSE_NOT_BUSY != Cy_CapSense_IsBusy(context)) { - if(0uL == watchdogCounter) + if (0uL == watchdogCounter) { + result = CY_CAPSENSE_STATUS_TIMEOUT; break; } watchdogCounter--; } - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - for (widgetId = 0u; widgetId < context->ptrCommonConfig->numWd; widgetId++) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + context->ptrInternalContext->hwIirInit = (uint8_t)MSCLP_CE_CTL_RCF_EN_Msk; + (void)Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT, context); + #endif + + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + for (widgetId = 0u; widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT; widgetId++) { Cy_CapSense_PreProcessWidget(widgetId, context); - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED) - if (CY_CAPSENSE_MPTX_MIN_ORDER <= context->ptrWdConfig[widgetId].mptxOrder) - { - result |= Cy_CapSense_ProcessWidgetMptxDeconvolution(widgetId, context); - } + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (((CY_CAPSENSE_MPSC_MIN_ORDER <= context->ptrWdConfig[widgetId].mpOrder) || + (CY_CAPSENSE_MPSC_MIN_ORDER <= context->ptrWdConfig[widgetId].mpOrderRows)) && + (CY_CAPSENSE_CSD_GROUP == context->ptrWdConfig[widgetId].senseMethod)) + { + result |= Cy_CapSense_ProcessWidgetMpDeconvolution(widgetId, context); + } + #endif + #endif + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) + if ((CY_CAPSENSE_MPTX_MIN_ORDER <= context->ptrWdConfig[widgetId].mpOrder) && + (CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod)) + { + result |= Cy_CapSense_ProcessWidgetMpDeconvolution(widgetId, context); + } + #endif #endif } #endif @@ -330,9 +448,9 @@ cy_capsense_status_t Cy_CapSense_Enable(cy_stc_capsense_context_t * context) #endif Cy_CapSense_InitializeAllBaselines(context); - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) context->ptrCommonContext->status &= ~(uint32_t)CY_CAPSENSE_MW_STATE_INITIALIZATION_MASK; - #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + #endif return result; } @@ -356,6 +474,8 @@ cy_capsense_status_t Cy_CapSense_Enable(cy_stc_capsense_context_t * context) * * \return * Return CY_CAPSENSE_STATUS_SUCCESS if the initialization was successful. +* If CY_CAPSENSE_STATUS_SUCCESS is not received, some of the initialization +* fails. * *******************************************************************************/ cy_capsense_status_t Cy_CapSense_Initialize(cy_stc_capsense_context_t * context) @@ -382,7 +502,7 @@ cy_capsense_status_t Cy_CapSense_Initialize(cy_stc_capsense_context_t * context) } } - return (result); + return result; } @@ -430,7 +550,7 @@ cy_capsense_status_t Cy_CapSense_DeInit(cy_stc_capsense_context_t * context) context->ptrCommonContext->initDone = CY_CAPSENSE_INIT_NEEDED; } - return (result); + return result; } @@ -456,14 +576,14 @@ cy_capsense_status_t Cy_CapSense_DeInit(cy_stc_capsense_context_t * context) * widgets (and sensors) in the middleware are scanned. Calling this function * multiple times without sensor scanning causes unexpected behavior. * -* The disabled widgets are not processed by this function. +* Disabled and/or non-working widgets are not processed by this function. * * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * * \return -* Returns the status of the processing operation. If CY_CAPSENSE_STATUS_SUCCESS is not received, -* the processing fails and retries may be required. +* Returns the status of the processing operation. If CY_CAPSENSE_STATUS_SUCCESS +* is not received, the processing fails and retries may be required. * *******************************************************************************/ cy_capsense_status_t Cy_CapSense_ProcessAllWidgets(cy_stc_capsense_context_t * context) @@ -471,17 +591,25 @@ cy_capsense_status_t Cy_CapSense_ProcessAllWidgets(cy_stc_capsense_context_t * c uint32_t wdIndex; cy_capsense_status_t result = CY_CAPSENSE_STATUS_SUCCESS; - for (wdIndex = context->ptrCommonConfig->numWd; wdIndex-- > 0u;) + for (wdIndex = CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex-- > 0u;) { - #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN)) - if (0u == ((&context->ptrWdConfig[wdIndex])->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK)) - { - /* Processes all widgets with disabled MFS and all widgets with original (main) frequency */ - result |= Cy_CapSense_ProcessWidget(wdIndex, context); - } - #else - result |= Cy_CapSense_ProcessWidget(wdIndex, context); - #endif + if (0u != Cy_CapSense_IsWidgetEnabled(wdIndex, context)) + { + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP && (CY_CAPSENSE_DISABLE != CY_CAPSENSE_LP_EN)) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != context->ptrWdConfig[wdIndex].wdType) + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP & CY_CAPSENSE_LP_EN */ + { + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN)) + if (0u == ((&context->ptrWdConfig[wdIndex])->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK)) + { + /* Processes all widgets with disabled MFS and all widgets with the original (main) frequency */ + result |= Cy_CapSense_ProcessWidget(wdIndex, context); + } + #else + result |= Cy_CapSense_ProcessWidget(wdIndex, context); + #endif + } + } } return result; } @@ -499,7 +627,9 @@ cy_capsense_status_t Cy_CapSense_ProcessAllWidgets(cy_stc_capsense_context_t * c * Cy_CapSense_Scan() functions (4th Generation) to scan and process data for a specific * widget or with the Cy_CapSense_ScanSlots() function (5th Generation). * This function is called only after all the sensors in the -* widgets are scanned. A disabled widget is not processed by this function. +* widgets are scanned. +* +* The disabled and/or non-working widgets are not processed by this function. * * A pipeline scan method (i.e. during scanning of a current widget (N), * perform processing of the previously scanned widget (N-1)) can be @@ -507,7 +637,7 @@ cy_capsense_status_t Cy_CapSense_ProcessAllWidgets(cy_stc_capsense_context_t * c * increase the refresh rate, and decrease the average power consumption. * See the function usage example below for details on usage. * -* For the Fifth generation CapSense if the specified widget has the enabled +* For the Fifth generation CAPSENSE™ if the specified widget has the enabled * multi-frequency scan feature then the function does the following: * - If the specified widget ID refers to main (base) frequency then the function * processes raw count processing of all three widgets (main and two sub-widgets) @@ -520,6 +650,11 @@ cy_capsense_status_t Cy_CapSense_ProcessAllWidgets(cy_stc_capsense_context_t * c * Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed and +* \ref CY_CAPSENSE_STATUS_BAD_PARAM is returned +* if a widget of this type is passed. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -544,89 +679,119 @@ cy_capsense_status_t Cy_CapSense_ProcessWidget( const cy_stc_capsense_widget_config_t * ptrWdCfg; /* Check parameter validity */ - if (widgetId >= context->ptrCommonConfig->numWd) + if (widgetId >= CY_CAPSENSE_TOTAL_WIDGET_COUNT) { result = CY_CAPSENSE_STATUS_BAD_PARAM; } - - if (CY_CAPSENSE_STATUS_SUCCESS == result) + else { ptrWdCfg = &context->ptrWdConfig[widgetId]; - /* Check widget enable status */ - if (0u != (ptrWdCfg->ptrWdContext->status & CY_CAPSENSE_WD_DISABLE_MASK)) + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType) { - result = CY_CAPSENSE_STATUS_INVALID_STATE; + result = CY_CAPSENSE_STATUS_BAD_PARAM; } - #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN)) - /* Check for sub-widget */ - if (0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK)) + else + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + { + /* Check widget enable status */ + if (0u == Cy_CapSense_IsWidgetEnabled(widgetId, context)) { - result |= CY_CAPSENSE_STATUS_BAD_PARAM; + result = CY_CAPSENSE_STATUS_INVALID_STATE; } - #endif + #if (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) &&\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN)) + /* Check for sub-widget */ + if ((0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK)) && + (0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK))) + { + result |= CY_CAPSENSE_STATUS_BAD_PARAM; + } + #endif + } } - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - if (CY_CAPSENSE_STATUS_SUCCESS == result) - { + if (CY_CAPSENSE_STATUS_SUCCESS == result) + { + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) if (0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK)) { Cy_CapSense_PreProcessWidget(widgetId + CY_CAPSENSE_MFS_CH2_INDEX, context); Cy_CapSense_PreProcessWidget(widgetId + CY_CAPSENSE_MFS_CH1_INDEX, context); + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) || + (CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrderRows)) && + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod)) + { + result |= Cy_CapSense_ProcessWidgetMpDeconvolution(widgetId + CY_CAPSENSE_MFS_CH2_INDEX, context); + result |= Cy_CapSense_ProcessWidgetMpDeconvolution(widgetId + CY_CAPSENSE_MFS_CH1_INDEX, context); + } + #endif + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) + if ((CY_CAPSENSE_MPTX_MIN_ORDER <= ptrWdCfg->mpOrder) && + (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod)) + { + result |= Cy_CapSense_ProcessWidgetMpDeconvolution(widgetId + CY_CAPSENSE_MFS_CH2_INDEX, context); + result |= Cy_CapSense_ProcessWidgetMpDeconvolution(widgetId + CY_CAPSENSE_MFS_CH1_INDEX, context); + } + #endif } #endif + Cy_CapSense_PreProcessWidget(widgetId, context); - } - #endif + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) || + (CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrderRows)) && + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod)) + { + result |= Cy_CapSense_ProcessWidgetMpDeconvolution(widgetId, context); + } + #endif + #endif + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) + if ((CY_CAPSENSE_MPTX_MIN_ORDER <= ptrWdCfg->mpOrder) && + (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod)) + { + result |= Cy_CapSense_ProcessWidgetMpDeconvolution(widgetId, context); + } + #endif + #endif - if (CY_CAPSENSE_STATUS_SUCCESS == result) - { - switch(ptrWdCfg->senseMethod) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) + if (0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK)) + { + result |= Cy_CapSense_DpProcessWidgetRawCounts(widgetId + CY_CAPSENSE_MFS_CH2_INDEX, context); + result |= Cy_CapSense_DpProcessWidgetRawCounts(widgetId + CY_CAPSENSE_MFS_CH1_INDEX, context); + } + #endif + result |= Cy_CapSense_DpProcessWidgetRawCounts(widgetId, context); + + switch (ptrWdCfg->senseMethod) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) case CY_CAPSENSE_CSD_GROUP: - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) - if (0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK)) - { - /* Processes all sub-widgets of MFS widgets with derivative frequency */ - result |= Cy_CapSense_DpProcessCsdWidgetRawCounts(widgetId + CY_CAPSENSE_MFS_CH2_INDEX, context); - result |= Cy_CapSense_DpProcessCsdWidgetRawCounts(widgetId + CY_CAPSENSE_MFS_CH1_INDEX, context); - } - #endif - result |= Cy_CapSense_DpProcessCsdWidgetRawCounts(widgetId, context); Cy_CapSense_DpProcessCsdWidgetStatus(ptrWdCfg, context); break; #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) case CY_CAPSENSE_CSX_GROUP: - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) - if (0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK)) - { - /* Processes all sub-widgets of MFS widgets with derivative frequency */ - #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED)) - if (CY_CAPSENSE_MPTX_MIN_ORDER <= ptrWdCfg->mptxOrder) - { - result |= Cy_CapSense_ProcessWidgetMptxDeconvolution(widgetId + CY_CAPSENSE_MFS_CH2_INDEX, context); - result |= Cy_CapSense_ProcessWidgetMptxDeconvolution(widgetId + CY_CAPSENSE_MFS_CH1_INDEX, context); - } - #endif - result |= Cy_CapSense_DpProcessCsxWidgetRawCounts(widgetId + CY_CAPSENSE_MFS_CH2_INDEX, context); - result |= Cy_CapSense_DpProcessCsxWidgetRawCounts(widgetId + CY_CAPSENSE_MFS_CH1_INDEX, context); - } - #endif - #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED)) - if (CY_CAPSENSE_MPTX_MIN_ORDER <= ptrWdCfg->mptxOrder) - { - result |= Cy_CapSense_ProcessWidgetMptxDeconvolution(widgetId, context); - } - #endif - result |= Cy_CapSense_DpProcessCsxWidgetRawCounts(widgetId, context); Cy_CapSense_DpProcessCsxWidgetStatus(ptrWdCfg); break; #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_GROUP: + Cy_CapSense_DpProcessIsxWidgetStatus(ptrWdCfg); + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ + default: result |= CY_CAPSENSE_STATUS_BAD_PARAM; break; @@ -648,8 +813,8 @@ cy_capsense_status_t Cy_CapSense_ProcessWidget( * available scan functions. This function should be called only after all * the sensors in the specified widget are scanned. Calling this function * multiple times with the same mode without new sensor scan causes -* unexpected behavior. This function ignores the value of the -* wdgtEnable register. +* unexpected behavior. This function ignores the widget statuses like +* disabled and/or non-working and performs processing in any case. * * The CY_CAPSENSE_PROCESS_CALC_NOISE and CY_CAPSENSE_PROCESS_THRESHOLDS masks * for mode parameter are supported only when smart sensing algorithm is enabled @@ -662,31 +827,49 @@ cy_capsense_status_t Cy_CapSense_ProcessWidget( * For more details, refer to function usage example below. * * \note -* For the the fifth-generation CAPSENSE™ an extra processing should be -* performed prior a call of this function: +* For the fifth-generation CAPSENSE™ and fifth-generation low power +* CAPSENSE™ extra processing should be performed prior a call of +* this function: * * A raw count pre-processing calling either the Cy_CapSense_PreProcessWidget() * or Cy_CapSense_PreProcessSensor() functions. -* * A deconvolution for widgets with multi-phase Tx calling the -* Cy_CapSense_ProcessWidgetMptxDeconvolution() function. +* * A deconvolution for widgets with multi-phase Tx or Self calling the +* Cy_CapSense_ProcessWidgetMpDeconvolution() function +* (multi-phase Self is available only for the fifth-generation low power CAPSENSE™) * In this case a full processing flow consists of the following: * * Cy_CapSense_PreProcessWidget() -* * Cy_CapSense_ProcessWidgetMptxDeconvolution() +* * Cy_CapSense_ProcessWidgetMpDeconvolution() * * Cy_CapSense_ProcessWidgetExt() * +* \note +* For the fifth generation and fifth-generation low power CAPSENSE™ +* if the specified widget has the enabled multi-frequency scan feature +* then the processing must follow the following order: +* * Sub-widget channel 2 +* * Sub-widget channel 1 +* * Main widget channel 0 +* The CY_CAPSENSE_PROCESS_MFS_FILTER option is skipped for sub-widgets, +* however CY_CAPSENSE_PROCESS_STATUS option is available. +* * \param widgetId * Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed and +* \ref CY_CAPSENSE_STATUS_BAD_PARAM is returned +* if a widget of this type is passed. +* * \param mode * Specifies the type of widget processing to be executed for the * specified widget: * 1. Bits [31..7] - Reserved. * 2. Bits [6..0] - CY_CAPSENSE_PROCESS_ALL - Execute all of the below tasks. -* 3. Bit [6] - CY_CAPSENSE_PROCESS_MFS_FILTER - Run the firmware filters -* for MFS on sensor rawcounts -* (applicable only for fifth-generation CAPSENSE™). -* 4. Bit [5] - CY_CAPSENSE_PROCESS_STATUS - Update the status +* 3. Bit [6] - CY_CAPSENSE_PROCESS_STATUS - Update the status * (on/off, centroid position). +* 4. Bit [5] - CY_CAPSENSE_PROCESS_MFS_FILTER - Run the firmware filters +* for MFS on sensor rawcounts +* (applicable only for fifth-generation CAPSENSE™ +* and fifth-generation low power CAPSENSE™). * 5. Bit [4] - CY_CAPSENSE_PROCESS_THRESHOLDS - Update the thresholds * (only in CSD auto-tuning mode). * 6. Bit [3] - CY_CAPSENSE_PROCESS_CALC_NOISE - Calculate the noise @@ -729,88 +912,94 @@ cy_capsense_status_t Cy_CapSense_ProcessWidgetExt( const cy_stc_capsense_widget_config_t * ptrWdCfg; /* Check parameter validity */ - if (widgetId < context->ptrCommonConfig->numWd) + if (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) { ptrWdCfg = &context->ptrWdConfig[widgetId]; - snsHistorySize = (uint32_t)ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_MASK; - /* Run the desired processing for the all CSD widget sensors */ - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ { - ptrSnsCxtSns = &ptrWdCfg->ptrSnsContext[freqChIndex * context->ptrCommonConfig->numSns]; - ptrBslnInvSns = &ptrWdCfg->ptrBslnInv[freqChIndex * context->ptrCommonConfig->numSns]; - ptrHistorySns = &ptrWdCfg->ptrRawFilterHistory[freqChIndex * (CY_CAPSENSE_RAW_HISTORY_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; - if(CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) - { - ptrHistoryLowSns = &ptrWdCfg->ptrRawFilterHistoryLow[freqChIndex * - (CY_CAPSENSE_IIR_HISTORY_LOW_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; - } + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + snsHistorySize = (uint32_t)ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_MASK; - for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + /* Run the desired processing for the all CSD widget sensors */ + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) - { - capStatus = Cy_CapSense_DpProcessCsxSensorRawCountsExt(ptrWdCfg, ptrSnsCxtSns, - ptrHistorySns, ptrHistoryLowSns, mode, ptrBslnInvSns, context); - } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + ptrSnsCxtSns = &ptrWdCfg->ptrSnsContext[freqChIndex * context->ptrCommonConfig->numSns]; + ptrBslnInvSns = &ptrWdCfg->ptrBslnInv[freqChIndex * context->ptrCommonConfig->numSns]; + ptrHistorySns = &ptrWdCfg->ptrRawFilterHistory[freqChIndex * (CY_CAPSENSE_RAW_HISTORY_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; + if (CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) + { + ptrHistoryLowSns = &ptrWdCfg->ptrRawFilterHistoryLow[freqChIndex * + (CY_CAPSENSE_IIR_HISTORY_LOW_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; + } + + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + capStatus |= Cy_CapSense_DpProcessSensorRawCountsExt(ptrWdCfg, ptrSnsCxtSns, ptrHistorySns, + ptrHistoryLowSns, mode, ptrBslnInvSns, context); - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + ptrSnsCxtSns++; + ptrBslnInvSns++; + ptrHistorySns += snsHistorySize; + if (NULL != ptrHistoryLowSns) { - capStatus = Cy_CapSense_DpProcessCsdSensorRawCountsExt(ptrWdCfg, ptrSnsCxtSns, - ptrHistorySns, ptrHistoryLowSns, mode, ptrBslnInvSns, context); + ptrHistoryLowSns++; } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + } + } - /* Placeholder for further methods */ + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN)) + ptrSnsCxtSns = ptrWdCfg->ptrSnsContext; + for (snsIndex = ptrWdCfg->numSns; snsIndex-- > 0u;) + { + Cy_CapSense_RunMfsFiltering(ptrSnsCxtSns, context); + ptrSnsCxtSns++; + } + #endif - ptrSnsCxtSns++; - ptrBslnInvSns++; - ptrHistorySns += snsHistorySize; - if(NULL != ptrHistoryLowSns) + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) && \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP))) + if ((0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK)) && + (0u == (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK))) { - ptrHistoryLowSns++; + if (0u != (mode & CY_CAPSENSE_PROCESS_MFS_FILTER)) + { + (void)Cy_CapSense_RunMfsMedian(widgetId, context); + } } - } - } + #endif - #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) && \ - (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN)) - ptrSnsCxtSns = ptrWdCfg->ptrSnsContext; - for (snsIndex = ptrWdCfg->numSns; snsIndex-- > 0u;) + if (0u != (mode & CY_CAPSENSE_PROCESS_STATUS)) { - Cy_CapSense_RunMfsFiltering(ptrSnsCxtSns, context); - ptrSnsCxtSns++; - } - #endif + switch (ptrWdCfg->senseMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + Cy_CapSense_DpProcessCsxWidgetStatus(ptrWdCfg); + break; + #endif - #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) && \ - (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)) - if (0u != (mode & CY_CAPSENSE_PROCESS_MFS_FILTER)) - { - (void) Cy_CapSense_RunMfsMedian(widgetId, context); - } - #endif + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + Cy_CapSense_DpProcessCsdWidgetStatus(ptrWdCfg, context); + break; + #endif - if (0u != (mode & CY_CAPSENSE_PROCESS_STATUS)) - { - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) - { - Cy_CapSense_DpProcessCsxWidgetStatus(ptrWdCfg); - } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_GROUP: + Cy_CapSense_DpProcessIsxWidgetStatus(ptrWdCfg); + break; + #endif - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) - { - Cy_CapSense_DpProcessCsdWidgetStatus(ptrWdCfg, context); + default: + capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + /* No action */ + break; } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ - - /* Placeholder for further methods */ + } } } return capStatus; @@ -835,15 +1024,17 @@ cy_capsense_status_t Cy_CapSense_ProcessWidgetExt( * function usage example below. * * \note -* For the the fifth CAPSENSE™ HW generation an extra processing should be -* performed prior a call of this function: +* For the fifth-generation CAPSENSE™ and fifth-generation low power +* CAPSENSE™ HW generation an extra processing should be performed prior +* a call of this function: * * A raw count pre-processing calling either the Cy_CapSense_PreProcessWidget() * or Cy_CapSense_PreProcessSensor() functions. -* * A deconvolution for widgets with multi-phase Tx calling the -* Cy_CapSense_ProcessWidgetMptxDeconvolution() function. +* * A deconvolution for widgets with multi-phase Tx or Self calling the +* Cy_CapSense_ProcessWidgetMpDeconvolution() function +* (multi-phase Self is available only for the fifth-generation low power CAPSENSE™) * In this case a full processing flow consists of the following: * * Cy_CapSense_PreProcessWidget() -* * Cy_CapSense_ProcessWidgetMptxDeconvolution() +* * Cy_CapSense_ProcessWidgetMpDeconvolution() * * Cy_CapSense_ProcessSensorExt() - each sensor * * Cy_CapSense_ProcessWidgetExt() * @@ -851,6 +1042,11 @@ cy_capsense_status_t Cy_CapSense_ProcessWidgetExt( * Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed and +* \ref CY_CAPSENSE_STATUS_BAD_PARAM is returned +* if a widget of this type is passed. +* * \param sensorId * Specifies the ID number of the sensor within the widget. A macro for the * sensor ID within a specified widget can be found in the cycfg_capsense.h @@ -900,48 +1096,40 @@ cy_capsense_status_t Cy_CapSense_ProcessSensorExt( cy_stc_capsense_sensor_context_t * ptrSnsCxt; const cy_stc_capsense_widget_config_t * ptrWdCfg; - if (widgetId < context->ptrCommonConfig->numWd) + if (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) { ptrWdCfg = &context->ptrWdConfig[widgetId]; + if (sensorId < ptrWdCfg->numSns) { - snsHistorySize = (uint32_t)ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_MASK; - capStatus = CY_CAPSENSE_STATUS_SUCCESS; - - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ { - ptrSnsCxt = &ptrWdCfg->ptrSnsContext[sensorId + (freqChIndex * context->ptrCommonConfig->numSns)]; - ptrSnsBslnInv = &ptrWdCfg->ptrBslnInv[sensorId + (freqChIndex * context->ptrCommonConfig->numSns)]; - ptrHistory = &ptrWdCfg->ptrRawFilterHistory[(freqChIndex * (CY_CAPSENSE_RAW_HISTORY_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)) + - (snsHistorySize * sensorId)]; - if(CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) - { - ptrHistoryLow = &ptrWdCfg->ptrRawFilterHistoryLow[freqChIndex * - (CY_CAPSENSE_IIR_HISTORY_LOW_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; - } - - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) - { - capStatus = Cy_CapSense_DpProcessCsxSensorRawCountsExt(ptrWdCfg, ptrSnsCxt, - ptrHistory, ptrHistoryLow, mode, ptrSnsBslnInv, context); - } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + snsHistorySize = (uint32_t)ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_MASK; + capStatus = CY_CAPSENSE_STATUS_SUCCESS; - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + { + ptrSnsCxt = &ptrWdCfg->ptrSnsContext[sensorId + (freqChIndex * context->ptrCommonConfig->numSns)]; + ptrSnsBslnInv = &ptrWdCfg->ptrBslnInv[sensorId + (freqChIndex * context->ptrCommonConfig->numSns)]; + ptrHistory = &ptrWdCfg->ptrRawFilterHistory[(freqChIndex * (CY_CAPSENSE_RAW_HISTORY_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)) + + (snsHistorySize * sensorId)]; + if (CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) { - capStatus = Cy_CapSense_DpProcessCsdSensorRawCountsExt(ptrWdCfg, ptrSnsCxt, - ptrHistory, ptrHistoryLow, mode, ptrSnsBslnInv, context); + ptrHistoryLow = &ptrWdCfg->ptrRawFilterHistoryLow[freqChIndex * + (CY_CAPSENSE_IIR_HISTORY_LOW_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ - /* Placeholder for further methods */ + capStatus |= Cy_CapSense_DpProcessSensorRawCountsExt(ptrWdCfg, ptrSnsCxt, ptrHistory, + ptrHistoryLow, mode, ptrSnsBslnInv, context); + } + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN)) + ptrSnsCxt = ptrWdCfg->ptrSnsContext; + Cy_CapSense_RunMfsFiltering(ptrSnsCxt, context); + #endif } - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) - ptrSnsCxt = ptrWdCfg->ptrSnsContext; - Cy_CapSense_RunMfsFiltering(ptrSnsCxt, context); - #endif } } return capStatus; @@ -955,15 +1143,19 @@ cy_capsense_status_t Cy_CapSense_ProcessSensorExt( * Resumes the middleware after System Deep Sleep. * * This function is used to resume the middleware operation after exiting -* System Deep Sleep. After the CAPSENSE™ HW block is powered off, +* System Deep Sleep. After the CAPSENSE™ HW block is powered on, * an extra delay is required to establish the correct operation of -* the CAPSENSE™ HW block. +* the CAPSENSE™ HW block. No need for the Cy_CapSense_Wakeup() function +* call for the fifth-generation low power CAPSENSE™ because all needed +* delays are managed automatically in scan start functions. * * This function is called by the Cy_CapSense_DeepSleepCallback() function after -* exiting System Deep Sleep if the CAPSENSE™ Deep Sleep callback is registered. +* exiting System Deep Sleep if the CAPSENSE™ Deep Sleep callback +* is registered. * * \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* The pointer to the CAPSENSE™ context structure +* \ref cy_stc_capsense_context_t. * *******************************************************************************/ void Cy_CapSense_Wakeup(const cy_stc_capsense_context_t * context) @@ -976,24 +1168,25 @@ void Cy_CapSense_Wakeup(const cy_stc_capsense_context_t * context) * Function Name: Cy_CapSense_DeepSleepCallback ****************************************************************************//** * -* Handles CPU active to System Deep Sleep power mode transition for the CAPSENSE™ -* middleware. +* Handles CPU active to System Deep Sleep power mode transition +* for the CAPSENSE™ middleware. * -* Calling this function directly from the application program is not recommended. -* Instead, Cy_SysPm_CpuEnterDeepSleep() should be used for the CPU active to System Deep Sleep -* power mode transition of the device. +* Calling this function directly from the application program +* is not recommended. Instead, Cy_SysPm_CpuEnterDeepSleep() should be +* used for the CPU active to System Deep Sleep power mode transition +* of the device. * \note * After the CPU Deep Sleep transition, the device automatically goes * to System Deep Sleep if all conditions are fulfilled: another core is * in CPU Deep Sleep, all the peripherals are ready to System Deep Sleep, etc. * (see details in the device TRM). * -* For proper operation of the CAPSENSE™ middleware during the CPU active to -* System Deep Sleep mode transition, a callback to this function should be registered -* using the Cy_SysPm_RegisterCallback() function with CY_SYSPM_DEEPSLEEP -* type. After the callback is registered, this function is called by the -* Cy_SysPm_CpuEnterDeepSleep() function to prepare the middleware to the device -* power mode transition. +* For proper operation of the CAPSENSE™ middleware during +* the CPU active to System Deep Sleep mode transition, a callback to +* this function should be registered using the Cy_SysPm_RegisterCallback() +* function with CY_SYSPM_DEEPSLEEP type. After the callback is registered, +* this function is called by the Cy_SysPm_CpuEnterDeepSleep() function to +* prepare the middleware to the device power mode transition. * * When this function is called with CY_SYSPM_CHECK_READY as an input, this * function returns CY_SYSPM_SUCCESS if no scanning is in progress or not @@ -1003,16 +1196,21 @@ void Cy_CapSense_Wakeup(const cy_stc_capsense_context_t * context) * a transition to System Deep Sleep during the scan can disrupt the middleware * operation. * -* When this function is called with CY_SYSPM_AFTER_TRANSITION as an input, then -* the Cy_CapSense_Wakeup() function is called to resume the middleware -* operation after exiting System Deep Sleep. If there are no CAPSENSE™ captured -* HW blocks the Cy_CapSense_Wakeup() function calling is omitted and restoring -* CAPSENSE™ immediately after Deep Sleep without the wake-up delay can lead to -* unpredictable behavior. +* When this function is called with CY_SYSPM_AFTER_TRANSITION as an input, +* then the Cy_CapSense_Wakeup() function is called to resume the middleware +* operation after exiting System Deep Sleep. If there are no CAPSENSE™ +* captured HW blocks, no need for the Cy_CapSense_Wakeup() function call and +* restoring CAPSENSE™ immediately after Deep Sleep without +* the wake-up delay can lead to unpredictable behavior. * * For details of SysPm types and macros refer to the SysPm section of the * PDL documentation. * +* \note For the fifth-generation low power CAPSENSE™ this function does +* nothing. The device can easily go to and out of System Deep Sleep power mode. +* So there is no need to register it into the SysPm driver. Also the function +* should not be called from any interrupt handler for any device generation. +* * \param callbackParams * Refer to the description of the cy_stc_syspm_callback_params_t type in the * Peripheral Driver Library documentation. @@ -1032,12 +1230,18 @@ cy_en_syspm_status_t Cy_CapSense_DeepSleepCallback( cy_en_syspm_callback_mode_t mode) { cy_en_syspm_status_t retVal = CY_SYSPM_SUCCESS; - const cy_stc_capsense_context_t * capsenseCxt = (cy_stc_capsense_context_t *)callbackParams->context; + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + const cy_stc_capsense_context_t * capsenseCxt = (cy_stc_capsense_context_t *)callbackParams->context; + #else /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + (void)callbackParams; + (void)mode; + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) cy_en_csd_key_t mwKey; - switch(mode) + switch (mode) { case CY_SYSPM_CHECK_READY: mwKey = Cy_CSD_GetLockStatus(capsenseCxt->ptrCommonConfig->ptrCsdBase, capsenseCxt->ptrCommonConfig->ptrCsdContext); @@ -1064,11 +1268,11 @@ cy_en_syspm_status_t Cy_CapSense_DeepSleepCallback( /* No action for other modes */ break; } - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) uint32_t curChIndex; - const cy_stc_msc_channel_config_t * ptrMscChCfg = &capsenseCxt->ptrCommonConfig->ptrMscChConfig[0u]; + const cy_stc_capsense_channel_config_t * ptrChCfg = &capsenseCxt->ptrCommonConfig->ptrChConfig[0u]; - switch(mode) + switch (mode) { case CY_SYSPM_CHECK_READY: if (CY_CAPSENSE_NOT_BUSY != Cy_CapSense_IsBusy(capsenseCxt)) @@ -1080,13 +1284,13 @@ cy_en_syspm_status_t Cy_CapSense_DeepSleepCallback( case CY_SYSPM_AFTER_TRANSITION: for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - if (CY_MSC_CAPSENSE_KEY == Cy_MSC_GetLockStatus(ptrMscChCfg->ptrMscBase, - ptrMscChCfg->ptrMscContext)) + if (CY_MSC_CAPSENSE_KEY == Cy_MSC_GetLockStatus(ptrChCfg->ptrHwBase, + ptrChCfg->ptrHwContext)) { Cy_CapSense_Wakeup(capsenseCxt); break; } - ptrMscChCfg++; + ptrChCfg++; } break; @@ -1096,7 +1300,7 @@ cy_en_syspm_status_t Cy_CapSense_DeepSleepCallback( } #endif - return(retVal); + return retVal; } #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_GESTURE_EN) || \ @@ -1227,107 +1431,246 @@ void Cy_CapSense_SetGestureTimestamp( cy_capsense_status_t Cy_CapSense_Restore(cy_stc_capsense_context_t * context) { #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) - - cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_INVALID_STATE; - cy_en_csd_key_t mvKey; - cy_en_csd_status_t csdHwStatus; - cy_stc_csd_context_t * ptrCsdCxt = context->ptrCommonConfig->ptrCsdContext; - CSD_Type * ptrCsdBaseAdd = context->ptrCommonConfig->ptrCsdBase; - uint32_t watchdogCounter; - - /* Number of cycle of one for() loop */ - const uint32_t cyclesPerLoop = 5u; - /* Timeout in microseconds */ - const uint32_t watchdogTimeoutUs = 10000u; - - /* Get the CSD HW block status */ - mvKey = Cy_CSD_GetLockStatus(ptrCsdBaseAdd, ptrCsdCxt); - if(CY_CSD_NONE_KEY == mvKey) - { - /* Reset CSD HW block sequencer state always to handle a corner case when the sequencer is not in the idle state */ - context->ptrCommonConfig->ptrCsdBase->INTR_MASK = CY_CAPSENSE_CSD_INTR_MASK_CLEAR_MSK; - context->ptrCommonConfig->ptrCsdBase->SEQ_START = CY_CAPSENSE_CSD_SEQ_START_ABORT_MSK; - watchdogCounter = Cy_CapSense_WatchdogCyclesNum(watchdogTimeoutUs, - context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA, cyclesPerLoop); - do - { - csdHwStatus = Cy_CSD_GetConversionStatus(ptrCsdBaseAdd, ptrCsdCxt); - watchdogCounter--; - } - while((CY_CSD_BUSY == csdHwStatus) && (0u != watchdogCounter)); - - if(CY_CSD_SUCCESS == csdHwStatus) - { - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_USE_CAPTURE) - csdHwStatus = Cy_CSD_Capture(ptrCsdBaseAdd, CY_CSD_CAPSENSE_KEY, ptrCsdCxt); - #else - csdHwStatus = Cy_CSD_Init(ptrCsdBaseAdd, &cy_capsense_csdCfg, CY_CSD_CAPSENSE_KEY, ptrCsdCxt); - #endif - - if(CY_CSD_SUCCESS == csdHwStatus) - { - capStatus = CY_CAPSENSE_STATUS_SUCCESS; - } - } - } - return (capStatus); - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ - uint32_t curChIndex; - cy_en_msc_status_t mscHwStatus; - cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; - const cy_stc_msc_channel_config_t * ptrMscChCfg = &context->ptrCommonConfig->ptrMscChConfig[0u]; - - for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) - { - /* Get MSC HW blocks statuses */ - if(CY_MSC_NONE_KEY != Cy_MSC_GetLockStatus(ptrMscChCfg->ptrMscBase, ptrMscChCfg->ptrMscContext)) - { - capStatus = CY_CAPSENSE_STATUS_HW_LOCKED; - break; - } - ptrMscChCfg++; - } - - if (capStatus == CY_CAPSENSE_STATUS_SUCCESS) - { - capStatus = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT, context); - if (capStatus == CY_CAPSENSE_STATUS_SUCCESS) - { - ptrMscChCfg = &context->ptrCommonConfig->ptrMscChConfig[0u]; - /* Capture MSC HW blocks */ - for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) - { - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_USE_CAPTURE) - mscHwStatus = Cy_MSC_Capture(ptrMscChCfg->ptrMscBase, - CY_MSC_CAPSENSE_KEY, ptrMscChCfg->ptrMscContext); - #else - mscHwStatus = Cy_MSC_Init(ptrMscChCfg->ptrMscBase, &cy_capsense_mscCfg, - CY_MSC_CAPSENSE_KEY, ptrMscChCfg->ptrMscContext); - #endif - - if(CY_MSC_SUCCESS != mscHwStatus) - { - capStatus = CY_CAPSENSE_STATUS_INVALID_STATE; - break; - } - ptrMscChCfg++; - } - } - } - - return (capStatus); + return Cy_CapSense_Restore_V2(context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + return Cy_CapSense_Restore_V3(context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + return Cy_CapSense_Restore_V3Lp(context); + #elif + #error Unsupported platform #endif } - +#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) /******************************************************************************* -* Function Name: Cy_CapSense_Save +* Function Name: Cy_CapSense_Restore_V2 ****************************************************************************//** * -* Saves the state of CAPSENSE™ so the functionality can be restored -* using the Cy_CapSense_Restore() function. +* Resumes the middleware operation if the Cy_CapSense_Save() function was +* called previously. * -* This function, along with the Cy_CapSense_Restore() function, is specifically +* This function, along with the Cy_CapSense_Save() function is specifically +* designed for ease of use and supports time multiplexing of the CAPSENSE™ HW +* block among multiple middleware. When the CAPSENSE™ HW blocks are shared by +* multiple middleware, this function can be used to restore the previous state of +* the CAPSENSE™ HW block(s) and CAPSENSE™ Middleware is saved using the +* Cy_CapSense_Save() function. See the function usage example below for +* details on usage. +* +* This function performs the same tasks as Cy_CapSense_Init() function and is +* kept for API consistency among middlewares. It is recommended to use +* Cy_CapSense_Save() and Cy_CapSense_Restore() functions to implement +* time-multiplexed mode instead of Cy_CapSense_DeInit() and Cy_CapSense_Init() +* functions for further compatibility. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the resume process. If CY_CAPSENSE_STATUS_SUCCESS is not +* received, the resume process fails and retries may be required. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_Restore_V2(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_INVALID_STATE; + cy_en_csd_key_t mvKey; + cy_en_csd_status_t csdHwStatus; + cy_stc_csd_context_t * ptrCsdCxt = context->ptrCommonConfig->ptrCsdContext; + CSD_Type * ptrCsdBaseAdd = context->ptrCommonConfig->ptrCsdBase; + uint32_t watchdogCounter; + + /* Number of cycle of one for () loop */ + const uint32_t cyclesPerLoop = 5u; + /* Timeout in microseconds */ + const uint32_t watchdogTimeoutUs = 10000u; + + /* Get the CSD HW block status */ + mvKey = Cy_CSD_GetLockStatus(ptrCsdBaseAdd, ptrCsdCxt); + if (CY_CSD_NONE_KEY == mvKey) + { + /* Reset CSD HW block sequencer state always to handle a corner case when the sequencer is not in the idle state */ + context->ptrCommonConfig->ptrCsdBase->INTR_MASK = CY_CAPSENSE_CSD_INTR_MASK_CLEAR_MSK; + context->ptrCommonConfig->ptrCsdBase->SEQ_START = CY_CAPSENSE_CSD_SEQ_START_ABORT_MSK; + watchdogCounter = Cy_CapSense_WatchdogCyclesNum(watchdogTimeoutUs, + context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA, cyclesPerLoop); + do + { + csdHwStatus = Cy_CSD_GetConversionStatus(ptrCsdBaseAdd, ptrCsdCxt); + watchdogCounter--; + } + while((CY_CSD_BUSY == csdHwStatus) && (0u != watchdogCounter)); + + if(CY_CSD_SUCCESS == csdHwStatus) + { + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_USE_CAPTURE) + csdHwStatus = Cy_CSD_Capture(ptrCsdBaseAdd, CY_CSD_CAPSENSE_KEY, ptrCsdCxt); + #else + csdHwStatus = Cy_CSD_Init(ptrCsdBaseAdd, &cy_capsense_csdCfg, CY_CSD_CAPSENSE_KEY, ptrCsdCxt); + + /* The time interval is required for settling analog part of the HW block. */ + Cy_SysLib_DelayUs(CY_CAPSENSE_ANALOG_SETTLING_TIME_US); + #endif + + if (CY_CSD_SUCCESS == csdHwStatus) + { + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + } + } + } + return capStatus; +} +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ + + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) +/******************************************************************************* +* Function Name: Cy_CapSense_Restore_V3 +****************************************************************************//** +* +* Resumes the middleware operation if the Cy_CapSense_Save() function was +* called previously. +* +* This function, along with the Cy_CapSense_Save() function is specifically +* designed for ease of use and supports time multiplexing of the CAPSENSE™ HW +* block among multiple middleware. When the CAPSENSE™ HW blocks are shared by +* multiple middleware, this function can be used to restore the previous state of +* the CAPSENSE™ HW block(s) and CAPSENSE™ Middleware is saved using the +* Cy_CapSense_Save() function. See the function usage example below for +* details on usage. +* +* This function performs the same tasks as Cy_CapSense_Init() function and is +* kept for API consistency among middlewares. It is recommended to use +* Cy_CapSense_Save() and Cy_CapSense_Restore() functions to implement +* time-multiplexed mode instead of Cy_CapSense_DeInit() and Cy_CapSense_Init() +* functions for further compatibility. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the resume process. If CY_CAPSENSE_STATUS_SUCCESS is not +* received, the resume process fails and retries may be required. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_Restore_V3(cy_stc_capsense_context_t * context) +{ + uint32_t curChIndex; + cy_en_msc_status_t mscHwStatus; + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + const cy_stc_capsense_channel_config_t * ptrChConfig = &context->ptrCommonConfig->ptrChConfig[0u]; + + for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) + { + /* Get MSC HW blocks statuses */ + if (CY_MSC_NONE_KEY != Cy_MSC_GetLockStatus(ptrChConfig->ptrHwBase, ptrChConfig->ptrHwContext)) + + { + capStatus = CY_CAPSENSE_STATUS_HW_LOCKED; + break; + } + ptrChConfig++; + } + + if (capStatus == CY_CAPSENSE_STATUS_SUCCESS) + { + capStatus = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT, context); + if (capStatus == CY_CAPSENSE_STATUS_SUCCESS) + { + ptrChConfig = &context->ptrCommonConfig->ptrChConfig[0u]; + /* Capture MSC HW blocks */ + for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) + { + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_USE_CAPTURE) + mscHwStatus = Cy_MSC_Capture(ptrChConfig->ptrHwBase, + CY_MSC_CAPSENSE_KEY, ptrChConfig->ptrHwContext); + #else + mscHwStatus = Cy_MSC_Init(ptrChConfig->ptrHwBase, &cy_capsense_mscCfg, + CY_MSC_CAPSENSE_KEY, ptrChConfig->ptrHwContext); + #endif + + if (CY_MSC_SUCCESS != mscHwStatus) + { + capStatus = CY_CAPSENSE_STATUS_INVALID_STATE; + break; + } + ptrChConfig++; + } + } + } + return capStatus; +} +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) +/******************************************************************************* +* Function Name: Cy_CapSense_Restore_V3Lp +****************************************************************************//** +* +* Resumes the middleware operation if the Cy_CapSense_Save() function was +* called previously. +* +* This function, along with the Cy_CapSense_Save() function is specifically +* designed for ease of use and supports time multiplexing of the CAPSENSE™ HW +* block among multiple middleware. When the CAPSENSE™ HW blocks are shared by +* multiple middleware, this function can be used to restore the previous state of +* the CAPSENSE™ HW block(s) and CAPSENSE™ Middleware is saved using the +* Cy_CapSense_Save() function. See the function usage example below for +* details on usage. +* +* This function performs the same tasks as Cy_CapSense_Init() function and is +* kept for API consistency among middlewares. It is recommended to use +* Cy_CapSense_Save() and Cy_CapSense_Restore() functions to implement +* time-multiplexed mode instead of Cy_CapSense_DeInit() and Cy_CapSense_Init() +* functions for further compatibility. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the resume process. If CY_CAPSENSE_STATUS_SUCCESS is not +* received, the resume process fails and retries may be required. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_Restore_V3Lp(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_HW_LOCKED; + cy_en_msclp_status_t msclpHwStatus; + const cy_stc_capsense_channel_config_t * ptrChConfig = context->ptrCommonConfig->ptrChConfig; + + if (CY_MSCLP_NONE_KEY == Cy_MSCLP_GetLockStatus(ptrChConfig->ptrHwBase, ptrChConfig->ptrHwContext)) + { + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_USE_CAPTURE) + msclpHwStatus = Cy_MSCLP_Capture(ptrChConfig->ptrHwBase, + CY_MSCLP_CAPSENSE_KEY, ptrChConfig->ptrHwContext); + #else + msclpHwStatus = Cy_MSCLP_Init(ptrChConfig->ptrHwBase, &cy_capsense_msclpCfg, + CY_MSCLP_CAPSENSE_KEY, ptrChConfig->ptrHwContext); + #endif + + if (CY_MSCLP_SUCCESS != msclpHwStatus) + { + capStatus = CY_CAPSENSE_STATUS_INVALID_STATE; + } + else + { + capStatus = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT, context); + } + } + + return capStatus; +} +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + +/******************************************************************************* +* Function Name: Cy_CapSense_Save +****************************************************************************//** +* +* Saves the state of CAPSENSE™ so the functionality can be restored +* using the Cy_CapSense_Restore() function. +* +* This function, along with the Cy_CapSense_Restore() function, is specifically * designed for ease of use and supports time multiplexing of the CAPSENSE™ HW * block among multiple middleware. When the CAPSENSE™ HW block is shared by * multiple middleware, this function can be used to save the current state of @@ -1357,7 +1700,7 @@ cy_capsense_status_t Cy_CapSense_Restore(cy_stc_capsense_context_t * context) * * \funcusage * -* An example of sharing the CAPSENSE™ HW block by the CapSense and CSDADC middleware.
+* An example of sharing the CAPSENSE™ HW block by the CAPSENSE™ and CSDADC middleware.
* Declares the CapSense_ISR_cfg variable: * \snippet capsense/snippet/main.c snippet_m4_capsense_interrupt_source_declaration * @@ -1365,7 +1708,7 @@ cy_capsense_status_t Cy_CapSense_Restore(cy_stc_capsense_context_t * context) * \snippet capsense/snippet/main.c snippet_m4_adc_interrupt_source_declaration * * Defines the CapSense interrupt handler: -* \snippet capsense/snippet/main.c snippet_CapSense_Interrupt +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_IntHandler * * Defines the CSDADC interrupt handler: * \snippet capsense/snippet/main.c snippet_CSDADC_Interrupt @@ -1377,75 +1720,228 @@ cy_capsense_status_t Cy_CapSense_Restore(cy_stc_capsense_context_t * context) cy_capsense_status_t Cy_CapSense_Save(cy_stc_capsense_context_t * context) { #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + return Cy_CapSense_Save_V2(context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + return Cy_CapSense_Save_V3(context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + return Cy_CapSense_Save_V3Lp(context); + #elif + #error Unsupported platform + #endif +} - cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_INVALID_STATE; - cy_en_csd_status_t initStatus; +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) +/******************************************************************************* +* Function Name: Cy_CapSense_Save_V3Lp +****************************************************************************//** +* +* Saves the state of CAPSENSE™ so the functionality can be restored +* using the Cy_CapSense_Restore() function. +* +* This function, along with the Cy_CapSense_Restore() function, is specifically +* designed for ease of use and supports time multiplexing of the CAPSENSE™ HW +* block among multiple middleware. When the CAPSENSE™ HW block is shared by +* multiple middleware, this function can be used to save the current state of +* the CAPSENSE™ HW block and CAPSENSE™ Middleware prior to releasing the +* CAPSENSE™ HW block for use by other middleware. See the function usage example +* below for details on usage. +* +* This function performs the same tasks as the Cy_CapSense_DeInit() function and is +* kept for API consistency among middlewares. It is recommended to use +* Cy_CapSense_Save() and Cy_CapSense_Restore() functions to implement +* Time-multiplexed mode instead of Cy_CapSense_DeInit() and Cy_CapSense_Init() +* functions for further compatibility. +* +* This function performs the following operations: +* * Releases the CAPSENSE™ HW block. +* * Configures sensor pins to the default state and disconnects them from +* analog buses. +* * Disconnects external capacitors from analog buses. +* * Sets the middleware state to default. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return status +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_Save_V3Lp(cy_stc_capsense_context_t * context) +{ + cy_en_msclp_status_t initStatus; + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_INVALID_STATE; + const cy_stc_capsense_channel_config_t * ptrChannel = context->ptrCommonConfig->ptrChConfig; - if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + { + if (CY_MSCLP_CAPSENSE_KEY == Cy_MSCLP_GetLockStatus(ptrChannel->ptrHwBase, ptrChannel->ptrHwContext)) { /* Disconnect external capacitors and sensor pins from analog bus */ - (void)Cy_CapSense_SwitchSensingMode(CY_CAPSENSE_UNDEFINED_GROUP, context); - - /* Release the CSD HW block */ - initStatus = Cy_CSD_DeInit( - context->ptrCommonConfig->ptrCsdBase, - CY_CSD_CAPSENSE_KEY, - context->ptrCommonConfig->ptrCsdContext); - - if (CY_CSD_SUCCESS == initStatus) + (void)Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_UNDEFINED, context); + initStatus = Cy_MSCLP_DeInit(ptrChannel->ptrHwBase, CY_MSCLP_CAPSENSE_KEY, ptrChannel->ptrHwContext); + if (CY_MSCLP_SUCCESS == initStatus) { capStatus = CY_CAPSENSE_STATUS_SUCCESS; } } + else + { + capStatus = CY_CAPSENSE_STATUS_HW_LOCKED; + } + } + else + { + capStatus = CY_CAPSENSE_STATUS_HW_BUSY; + } - return capStatus; + return capStatus; +} +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ - uint32_t curChIndex; - cy_en_msc_status_t initStatus; - cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; - const cy_stc_msc_channel_config_t * ptrMscChannel = context->ptrCommonConfig->ptrMscChConfig; +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) +/******************************************************************************* +* Function Name: Cy_CapSense_Save_V3 +****************************************************************************//** +* +* Saves the state of CAPSENSE™ so the functionality can be restored +* using the Cy_CapSense_Restore() function. +* +* This function, along with the Cy_CapSense_Restore() function, is specifically +* designed for ease of use and supports time multiplexing of the CAPSENSE™ HW +* block among multiple middleware. When the CAPSENSE™ HW block is shared by +* multiple middleware, this function can be used to save the current state of +* the CAPSENSE™ HW block and CAPSENSE™ Middleware prior to releasing the +* CAPSENSE™ HW block for use by other middleware. See the function usage example +* below for details on usage. +* +* This function performs the same tasks as the Cy_CapSense_DeInit() function and is +* kept for API consistency among middlewares. It is recommended to use +* Cy_CapSense_Save() and Cy_CapSense_Restore() functions to implement +* Time-multiplexed mode instead of Cy_CapSense_DeInit() and Cy_CapSense_Init() +* functions for further compatibility. +* +* This function performs the following operations: +* * Releases the CAPSENSE™ HW block. +* * Configures sensor pins to the default state and disconnects them from +* analog buses. +* * Disconnects external capacitors from analog buses. +* * Sets the middleware state to default. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return status +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_Save_V3(cy_stc_capsense_context_t * context) +{ + uint32_t curChIndex; + cy_en_msc_status_t initStatus; + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + const cy_stc_capsense_channel_config_t * ptrChannel = context->ptrCommonConfig->ptrChConfig; - if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + { + for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) + /* Get MSC HW blocks statuses */ + if (CY_MSC_CAPSENSE_KEY != Cy_MSC_GetLockStatus(ptrChannel[curChIndex].ptrHwBase, ptrChannel[curChIndex].ptrHwContext)) { - /* Get MSC HW blocks statuses */ - if(CY_MSC_CAPSENSE_KEY != Cy_MSC_GetLockStatus(ptrMscChannel[curChIndex].ptrMscBase, ptrMscChannel[curChIndex].ptrMscContext)) - { - capStatus = CY_CAPSENSE_STATUS_HW_LOCKED; - break; - } + capStatus = CY_CAPSENSE_STATUS_HW_LOCKED; + break; } - - if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + } + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + capStatus = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_UNDEFINED, context); + if (capStatus == CY_CAPSENSE_STATUS_SUCCESS) { - capStatus = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_UNDEFINED, context); - if (capStatus == CY_CAPSENSE_STATUS_SUCCESS) + for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) + initStatus = Cy_MSC_DeInit(ptrChannel[curChIndex].ptrHwBase, CY_MSC_CAPSENSE_KEY, ptrChannel[curChIndex].ptrHwContext); + if (CY_MSC_SUCCESS != initStatus) { - initStatus = Cy_MSC_DeInit(ptrMscChannel[curChIndex].ptrMscBase, CY_MSC_CAPSENSE_KEY, ptrMscChannel[curChIndex].ptrMscContext); - if (CY_MSC_SUCCESS != initStatus) - { - capStatus = CY_CAPSENSE_STATUS_HW_LOCKED; - break; - } + capStatus = CY_CAPSENSE_STATUS_HW_LOCKED; + break; } } } } - else - { - capStatus = CY_CAPSENSE_STATUS_HW_BUSY; - } + } + else + { + capStatus = CY_CAPSENSE_STATUS_HW_BUSY; + } + return capStatus; +} +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ - return capStatus; - #endif -} +#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) +/******************************************************************************* +* Function Name: Cy_CapSense_Save_V2 +****************************************************************************//** +* +* Saves the state of CAPSENSE™ so the functionality can be restored +* using the Cy_CapSense_Restore() function. +* +* This function, along with the Cy_CapSense_Restore() function, is specifically +* designed for ease of use and supports time multiplexing of the CAPSENSE™ HW +* block among multiple middleware. When the CAPSENSE™ HW block is shared by +* multiple middleware, this function can be used to save the current state of +* the CAPSENSE™ HW block and CAPSENSE™ Middleware prior to releasing the +* CAPSENSE™ HW block for use by other middleware. See the function usage example +* below for details on usage. +* +* This function performs the same tasks as the Cy_CapSense_DeInit() function and is +* kept for API consistency among middlewares. It is recommended to use +* Cy_CapSense_Save() and Cy_CapSense_Restore() functions to implement +* Time-multiplexed mode instead of Cy_CapSense_DeInit() and Cy_CapSense_Init() +* functions for further compatibility. +* +* This function performs the following operations: +* * Releases the CAPSENSE™ HW block. +* * Configures sensor pins to the default state and disconnects them from +* analog buses. +* * Disconnects external capacitors from analog buses. +* * Sets the middleware state to default. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return status +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_Save_V2(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_INVALID_STATE; + cy_en_csd_status_t initStatus; + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + { + /* Disconnect external capacitors and sensor pins from analog bus */ + (void)Cy_CapSense_SwitchSensingMode(CY_CAPSENSE_UNDEFINED_GROUP, context); + /* Release the CSD HW block */ + initStatus = Cy_CSD_DeInit( + context->ptrCommonConfig->ptrCsdBase, + CY_CSD_CAPSENSE_KEY, + context->ptrCommonConfig->ptrCsdContext); + if (CY_CSD_SUCCESS == initStatus) + + { + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + } + } + return capStatus; +} +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ /******************************************************************************* * Function Name: Cy_CapSense_RegisterCallback @@ -1481,10 +1977,10 @@ cy_capsense_status_t Cy_CapSense_RegisterCallback( { cy_capsense_status_t retVal = CY_CAPSENSE_STATUS_SUCCESS; - if((NULL != callbackFunction) && (NULL != context)) + if ((NULL != callbackFunction) && (NULL != context)) { - switch(callbackType) + switch (callbackType) { case CY_CAPSENSE_START_SAMPLE_E: context->ptrInternalContext->ptrSSCallback = callbackFunction; @@ -1502,7 +1998,7 @@ cy_capsense_status_t Cy_CapSense_RegisterCallback( retVal = CY_CAPSENSE_STATUS_BAD_PARAM; } - return(retVal); + return retVal; } @@ -1533,9 +2029,9 @@ cy_capsense_status_t Cy_CapSense_UnRegisterCallback( { cy_capsense_status_t retVal = CY_CAPSENSE_STATUS_SUCCESS; - if(NULL != context) + if (NULL != context) { - switch(callbackType) + switch (callbackType) { case CY_CAPSENSE_START_SAMPLE_E: context->ptrInternalContext->ptrSSCallback = NULL; @@ -1553,11 +2049,11 @@ cy_capsense_status_t Cy_CapSense_UnRegisterCallback( retVal = CY_CAPSENSE_STATUS_BAD_PARAM; } - return(retVal); + return retVal; } -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ /* [] END OF FILE */ diff --git a/cy_capsense_control.h b/cy_capsense_control.h index 6e61a41..809d8f0 100644 --- a/cy_capsense_control.h +++ b/cy_capsense_control.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_control.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the function prototypes of the Control module. @@ -22,19 +22,13 @@ #include "cy_capsense_structure.h" #include "cy_capsense_common.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if defined(__cplusplus) extern "C" { #endif -/******************************************************************************* -* Local definition -*******************************************************************************/ -#define CY_CAPSENSE_ANALOG_SETTLING_TIME_US (25u) - - /******************************************************************************* * Function Prototypes *******************************************************************************/ @@ -105,13 +99,35 @@ cy_capsense_status_t Cy_CapSense_ProcessSensorExt( cy_capsense_status_t Cy_CapSense_Initialize( cy_stc_capsense_context_t * context); +#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + cy_capsense_status_t Cy_CapSense_Save_V2( + cy_stc_capsense_context_t * context); +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + cy_capsense_status_t Cy_CapSense_Save_V3( + cy_stc_capsense_context_t * context); +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + cy_capsense_status_t Cy_CapSense_Save_V3Lp( + cy_stc_capsense_context_t * context); +#endif + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + cy_capsense_status_t Cy_CapSense_Restore_V2( + cy_stc_capsense_context_t * context); +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + cy_capsense_status_t Cy_CapSense_Restore_V3( + cy_stc_capsense_context_t * context); +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + cy_capsense_status_t Cy_CapSense_Restore_V3Lp( + cy_stc_capsense_context_t * context); +#endif + /** \} \endcond */ #if defined(__cplusplus) } #endif -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif /* CY_CAPSENSE_CONTROL_H */ diff --git a/cy_capsense_csd_v2.c b/cy_capsense_csd_v2.c index d0dc00d..3a851da 100644 --- a/cy_capsense_csd_v2.c +++ b/cy_capsense_csd_v2.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_csd_v2.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file defines the data structure global variables and provides @@ -80,11 +80,11 @@ static void Cy_CapSense_CSDCalibrate( uint32_t widgetId, uint32_t target, cy_stc_capsense_context_t * context); - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_AUTO_GAIN_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_AUTO_GAIN_EN) static uint32_t Cy_CapSense_CSDSwitchIdacGain(cy_stc_capsense_context_t * context); #endif - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) static void Cy_CapSense_CSDNormalizeIdac( cy_stc_capsense_widget_config_t const * ptrWdConfig, uint32_t target, @@ -224,15 +224,6 @@ void Cy_CapSense_CSDInitialize(cy_stc_capsense_context_t * context) Cy_CapSense_CSDClearSensors(context); Cy_CapSense_DischargeExtCapacitors(context); - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) - /* Connect shields to AMUX-B bus (config HSIOM regs) */ - Cy_CapSense_CSDEnableShieldElectrodes(context); - - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_CAP_EN) - Cy_CapSense_SsConfigPinRegisters(context->ptrCommonConfig->portCsh, (uint32_t)context->ptrCommonConfig->pinCsh, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXB); - #endif - #endif - /* Initialize the unused CSD IP registers to default state */ context->ptrCommonConfig->ptrCsdBase->HSCMP = 0u; context->ptrCommonConfig->ptrCsdBase->SEQ_TIME = 0u; @@ -250,6 +241,15 @@ void Cy_CapSense_CSDInitialize(cy_stc_capsense_context_t * context) context->ptrCommonConfig->ptrCsdBase->SW_AMUXBUF_SEL = context->ptrInternalContext->csdRegSwAmuxbufSel; context->ptrCommonConfig->ptrCsdBase->SW_HS_P_SEL = context->ptrInternalContext->csdRegSwHsPSelScan; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + /* Connect shields to AMUX-B bus (config HSIOM regs) */ + Cy_CapSense_CSDEnableShieldElectrodes(context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_CAP_EN) + Cy_CapSense_SsConfigPinRegisters(context->ptrCommonConfig->portCsh, (uint32_t)context->ptrCommonConfig->pinCsh, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXB); + #endif + #endif + /* Connection AMUXBUS-A to CSDBUS-A / AMUXBUS-B to CSDBUS-B */ context->ptrCommonConfig->ptrCsdBase->SW_BYP_SEL = context->ptrInternalContext->csdRegSwBypSel; @@ -323,7 +323,7 @@ void Cy_CapSense_CSDSnsStateCheck(cy_stc_capsense_context_t * context) * * Modulator IDAC is taken from widget context structure and Compensation * IDAC is taken from sensor context structure. -* The cy_stc_active_scan_sns_t structure must be updated to the current +* The cy_stc_capsense_active_scan_sns_t structure must be updated to the current * widget/sensor by Cy_CapSense_InitActivePtr() before calling this function. * * \param context @@ -334,14 +334,14 @@ void Cy_CapSense_CSDSetUpIdacs(cy_stc_capsense_context_t * context) { uint32_t regValue; - const cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + const cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; const uint32_t idacaBitsToWrite = CSD_IDACA_VAL_Msk | CSD_IDACA_RANGE_Msk | CSD_IDACA_LEG1_EN_Msk | CSD_IDACA_LEG2_EN_Msk; - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) const uint32_t idacbBitsToWrite = CSD_IDACB_VAL_Msk | CSD_IDACB_RANGE_Msk | CSD_IDACB_LEG1_EN_Msk | @@ -365,7 +365,7 @@ void Cy_CapSense_CSDSetUpIdacs(cy_stc_capsense_context_t * context) (context->ptrCommonConfig->ptrCsdBase->IDACA & ~idacaBitsToWrite) | (regValue & idacaBitsToWrite); - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) /* IDAC B Code */ regValue = ptrActive->ptrSnsContext->idacComp; regValue |= context->ptrCommonConfig->idacGainTable[ptrActive->ptrWdContext->idacGainIndex].gainReg; @@ -413,7 +413,7 @@ uint32_t Cy_CapSense_CSDGetNumberOfConversions(uint32_t snsClkDivider, uint32_t snsClkDividerLocal <<= 1u; } - if(CY_CAPSENSE_16_BIT_RESOLUTION <= resolution) + if (CY_CAPSENSE_16_BIT_RESOLUTION <= resolution) { /* CY_ID285392 */ extraCounts = CY_CAPSENSE_EXTRA_COUNTS_MAX; @@ -545,7 +545,7 @@ void Cy_CapSense_CSDCalculateScanDuration(cy_stc_capsense_context_t * context) *******************************************************************************/ void Cy_CapSense_CSDSetupWidget(uint32_t widgetId, cy_stc_capsense_context_t * context) { - #if((CY_CAPSENSE_DISABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) &&\ + #if ((CY_CAPSENSE_DISABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) &&\ ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN))) const cy_stc_capsense_widget_config_t * ptrWdCfg; @@ -567,11 +567,11 @@ void Cy_CapSense_CSDSetupWidget(uint32_t widgetId, cy_stc_capsense_context_t * c * the Sense Clock and the Scan Duration will be configured for each call * of the Cy_CapSense_CSDScan() function. */ - #if(CY_CAPSENSE_DISABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) ptrWdCfg = context->ptrActiveScanSns->ptrWdConfig; - if(((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E != ptrWdCfg->wdType) && + if (((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E != ptrWdCfg->wdType) && ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E != ptrWdCfg->wdType)) { Cy_CapSense_CSDCalculateScanDuration(context); @@ -668,7 +668,10 @@ void Cy_CapSense_CSDSetupWidgetExt(uint32_t widgetId, uint32_t sensorId, cy_stc_ *******************************************************************************/ void Cy_CapSense_CSDStartSample(cy_stc_capsense_context_t * context) { - if(NULL != context->ptrInternalContext->ptrSSCallback) + /* Force the LFSR BITS to default before callback, so they can be changed */ + context->ptrCommonConfig->ptrCsdBase->SENSE_PERIOD |= CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_BITS_MSK; + + if (NULL != context->ptrInternalContext->ptrSSCallback) { context->ptrInternalContext->ptrSSCallback(context->ptrActiveScanSns); } @@ -716,7 +719,7 @@ void Cy_CapSense_CSDStartSample(cy_stc_capsense_context_t * context) *******************************************************************************/ void Cy_CapSense_CSDScanExt(cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; /* Set MFS channel index to 0 */ ptrActive->mfsChannelIndex = 0u; @@ -782,7 +785,7 @@ void Cy_CapSense_CSDScanExt(cy_stc_capsense_context_t * context) *******************************************************************************/ void Cy_CapSense_CSDScan(cy_stc_capsense_context_t * context) { - #if((CY_CAPSENSE_DISABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) &&\ + #if ((CY_CAPSENSE_DISABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) &&\ ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN))) const cy_stc_capsense_widget_config_t * ptrWdCfg; @@ -800,13 +803,13 @@ void Cy_CapSense_CSDScan(cy_stc_capsense_context_t * context) * the Sense Clock and the Scan Duration will be configured only once in the scope * of the Cy_CapSense_CSDSetupWidget() function. */ - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) Cy_CapSense_CSDCalculateScanDuration(context); Cy_CapSense_CSDConfigClock(context); - #elif((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + #elif ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) ptrWdCfg = context->ptrActiveScanSns->ptrWdConfig; - if(((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType) || + if (((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType) || ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType)) { Cy_CapSense_CSDCalculateScanDuration(context); @@ -841,13 +844,13 @@ void Cy_CapSense_CSDScan(cy_stc_capsense_context_t * context) *******************************************************************************/ void Cy_CapSense_CSDConnectSnsExt(cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; const cy_stc_capsense_electrode_config_t * ptrActiveSns = ptrActive->ptrEltdConfig; const cy_stc_capsense_pin_config_t * ptrActivePin = ptrActiveSns->ptrPin; uint32_t i; /* Connect all pins of current sensors */ - for(i = 0u; i < ptrActiveSns->numPins; i++) + for (i = 0u; i < ptrActiveSns->numPins; i++) { Cy_CapSense_CSDConnectSns(ptrActivePin, context); ptrActivePin++; @@ -875,14 +878,14 @@ void Cy_CapSense_CSDConnectSnsExt(cy_stc_capsense_context_t * context) *******************************************************************************/ void Cy_CapSense_CSDDisconnectSnsExt(cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; const cy_stc_capsense_electrode_config_t * ptrActiveSns = ptrActive->ptrEltdConfig; const cy_stc_capsense_pin_config_t * ptrActivePin = ptrActiveSns->ptrPin; uint32_t i; /* Disconnect all pins of current sensors */ - for(i = 0u; i < ptrActiveSns->numPins; i++) + for (i = 0u; i < ptrActiveSns->numPins; i++) { Cy_CapSense_CSDDisconnectSns(ptrActivePin, context); ptrActivePin++; @@ -926,17 +929,12 @@ void Cy_CapSense_CSDDisconnectSnsExt(cy_stc_capsense_context_t * context) * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * -* \funcusage -* -* An example of using the function to perform port pin re-connection: -* \snippet capsense/snippet/main.c snippet_Cy_CapSense_CSDConnect -* *******************************************************************************/ void Cy_CapSense_CSDConnectSns( const cy_stc_capsense_pin_config_t * snsAddrPtr, const cy_stc_capsense_context_t * context) { - (void) context; + (void)context; Cy_CapSense_SsConfigPinRegisters(snsAddrPtr->pcPtr, (uint32_t)snsAddrPtr->pinNumber, CY_CAPSENSE_CSD_SCAN_PIN_DM, CY_CAPSENSE_HSIOM_SEL_CSD_SENSE); } @@ -968,11 +966,6 @@ void Cy_CapSense_CSDConnectSns( * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * -* \funcusage -* -* An example of using the function to perform port pin re-connection: -* \snippet capsense/snippet/main.c snippet_Cy_CapSense_CSDConnect -* *******************************************************************************/ void Cy_CapSense_CSDDisconnectSns( const cy_stc_capsense_pin_config_t * snsAddrPtr, @@ -1023,7 +1016,7 @@ void Cy_CapSense_CSDClearSensors(const cy_stc_capsense_context_t * context) { ptrPin = ptrSnsCfg->ptrPin; /* Go through all pins in sensor */ - for(pinIndex = 0u; pinIndex < ptrSnsCfg->numPins; pinIndex++) + for (pinIndex = 0u; pinIndex < ptrSnsCfg->numPins; pinIndex++) { /* Set CSD pin default state */ Cy_CapSense_CSDDisconnectSns(ptrSnsCfg->ptrPin, context); @@ -1051,7 +1044,7 @@ void Cy_CapSense_CSDSetWidgetSenseClkSrc(const cy_stc_capsense_widget_config_t * uint32_t lfsrSize; uint32_t conversionsNum; cy_stc_capsense_widget_context_t * ptrWdCxt = ptrWdConfig->ptrWdContext; - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) uint32_t rowLfsrSize; uint8_t widgetType = ptrWdConfig->wdType; #endif @@ -1065,7 +1058,7 @@ void Cy_CapSense_CSDSetWidgetSenseClkSrc(const cy_stc_capsense_widget_config_t * lfsrSize = Cy_CapSense_CSDCalcPrsSize((uint32_t)ptrWdCxt->snsClk << 1uL, (uint32_t)ptrWdCxt->resolution); } - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) if (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == widgetType) || ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == widgetType)) { if (ptrWdCxt->rowSnsClk != ptrWdCxt->snsClk) @@ -1174,7 +1167,7 @@ void Cy_CapSense_CSDDischargeCmod(cy_stc_capsense_context_t * context) } -#if((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) && \ +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) && \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN)) /******************************************************************************* * Function Name: Cy_CapSense_CSDNormalizeIdac @@ -1209,14 +1202,14 @@ static void Cy_CapSense_CSDNormalizeIdac( cy_stc_capsense_widget_context_t * ptrWdCxt = ptrWdConfig->ptrWdContext; uint32_t maxRawLevel = ptrWdCxt->maxRawCount; cy_stc_capsense_sensor_context_t * ptrSnsCxt; - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { /* Find maximum and minimum IDACs */ maxIdac = ptrWdConfig->ptrWdContext->idacMod[freqChIndex]; minIdac = maxIdac; ptrSnsCxt = &ptrWdConfig->ptrSnsContext[freqChIndex * context->ptrCommonConfig->numSns]; minRaw = ptrSnsCxt->raw; - for(snsIndex = 0u; snsIndex < ptrWdConfig->numCols; snsIndex++) + for (snsIndex = 0u; snsIndex < ptrWdConfig->numCols; snsIndex++) { if (minIdac > ptrSnsCxt->idacComp) { @@ -1238,7 +1231,7 @@ static void Cy_CapSense_CSDNormalizeIdac( /* Re-calculate compensation IDAC */ ptrSnsCxt = &ptrWdConfig->ptrSnsContext[freqChIndex * context->ptrCommonConfig->numSns]; - for(snsIndex = 0u; snsIndex < ptrWdConfig->numCols; snsIndex++) + for (snsIndex = 0u; snsIndex < ptrWdConfig->numCols; snsIndex++) { rawLevel = ((((uint32_t)ptrSnsCxt->raw * CY_CAPSENSE_PERCENTAGE_100) / maxRawLevel) + CY_CAPSENSE_PERCENTAGE_100) * ptrSnsCxt->idacComp; @@ -1254,7 +1247,7 @@ static void Cy_CapSense_CSDNormalizeIdac( ptrSnsCxt++; } /* IDAC Normalization is performed separately for row and column */ - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) if (((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdConfig->wdType) || ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdConfig->wdType)) { @@ -1263,7 +1256,7 @@ static void Cy_CapSense_CSDNormalizeIdac( minIdac = ptrWdCxt->rowIdacMod[freqChIndex]; ptrSnsCxt = &(ptrWdConfig->ptrSnsContext[(freqChIndex * context->ptrCommonConfig->numSns) + ptrWdConfig->numCols]); minRaw = ptrSnsCxt->raw; - for(snsIndex = ptrWdConfig->numCols; snsIndex < ptrWdConfig->numSns; snsIndex++) + for (snsIndex = ptrWdConfig->numCols; snsIndex < ptrWdConfig->numSns; snsIndex++) { if (minIdac > ptrSnsCxt->idacComp) { @@ -1285,7 +1278,7 @@ static void Cy_CapSense_CSDNormalizeIdac( /* Re-calculate compensation IDAC */ ptrSnsCxt = &(ptrWdConfig->ptrSnsContext[(freqChIndex * context->ptrCommonConfig->numSns) + ptrWdConfig->numCols]); - for(snsIndex = 0u; snsIndex < ptrWdConfig->numCols; snsIndex++) + for (snsIndex = 0u; snsIndex < ptrWdConfig->numCols; snsIndex++) { rawLevel = ((((uint32_t)ptrSnsCxt->raw * CY_CAPSENSE_PERCENTAGE_100) / maxRawLevel) + CY_CAPSENSE_PERCENTAGE_100) * ptrSnsCxt->idacComp; @@ -1334,7 +1327,7 @@ static uint32_t Cy_CapSense_CSDSwitchIdacGain(cy_stc_capsense_context_t * contex uint32_t maxIdac; uint32_t minIdac; uint32_t swStatus = 0u; - const cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + const cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; uint32_t gainIndex = ptrActive->ptrWdContext->idacGainIndex; uint32_t idacVal; uint32_t freqChIndex; @@ -1342,12 +1335,12 @@ static uint32_t Cy_CapSense_CSDSwitchIdacGain(cy_stc_capsense_context_t * contex maxIdac = 0u; minIdac = CY_CAPSENSE_CAL_IDAC_MAX_VALUE; - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) const cy_stc_capsense_sensor_context_t * ptrSnsCxt; uint32_t snsIndex; #endif - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { /* Find maximum and minimum IDACs */ idacVal = ptrActive->ptrWdContext->idacMod[freqChIndex]; @@ -1360,7 +1353,7 @@ static uint32_t Cy_CapSense_CSDSwitchIdacGain(cy_stc_capsense_context_t * contex minIdac = idacVal; } /* Check for sensorIndex >= numCols added and choose rowIdac if needed */ - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) if ((((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrActive->ptrWdConfig->wdType) || ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrActive->ptrWdConfig->wdType)) && (ptrActive->ptrWdConfig->numCols <= ptrActive->sensorIndex)) @@ -1378,8 +1371,8 @@ static uint32_t Cy_CapSense_CSDSwitchIdacGain(cy_stc_capsense_context_t * contex #endif /* Set value for iDac comp */ - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) - for(snsIndex = 0u; snsIndex < ptrActive->ptrWdConfig->numSns; snsIndex++) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + for (snsIndex = 0u; snsIndex < ptrActive->ptrWdConfig->numSns; snsIndex++) { ptrSnsCxt = &ptrActive->ptrWdConfig->ptrSnsContext[snsIndex]; idacVal = ptrSnsCxt[freqChIndex * context->ptrCommonConfig->numSns].idacComp; @@ -1406,7 +1399,7 @@ static uint32_t Cy_CapSense_CSDSwitchIdacGain(cy_stc_capsense_context_t * contex } } } - return (swStatus); + return swStatus; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_AUTO_GAIN_EN) */ @@ -1481,7 +1474,7 @@ static void Cy_CapSense_CSDCalibrate( rawTarget = ((uint32_t)ptrWdCxt->maxRawCount * target) / CY_CAPSENSE_PERCENTAGE_100; - for(snsIndex = 0u; snsIndex < (uint32_t)ptrWdCfg->numSns; snsIndex++) + for (snsIndex = 0u; snsIndex < (uint32_t)ptrWdCfg->numSns; snsIndex++) { /* Set default IDAC code */ calMask = (uint8_t)CY_CAPSENSE_CAL_MIDDLE_VALUE; @@ -1499,16 +1492,16 @@ static void Cy_CapSense_CSDCalibrate( ptrIdacMax = maxRowIdac; } - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { ptrIdacMod[freqChIndex] = calMask; - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) ptrSnsCxt[freqChIndex * context->ptrCommonConfig->numSns].idacComp = calMask; #endif } modClkDivider = context->ptrCommonContext->modCsdClk; - if(0u == modClkDivider) + if (0u == modClkDivider) { modClkDivider = 1u; } @@ -1517,7 +1510,7 @@ static void Cy_CapSense_CSDCalibrate( isBusyWatchdogTimeUs *= (uint64_t)modClkDivider * CY_CAPSENSE_CONVERSION_MEGA; isBusyWatchdogTimeUs /= context->ptrCommonConfig->periClkHz; - if(0u == isBusyWatchdogTimeUs) + if (0u == isBusyWatchdogTimeUs) { isBusyWatchdogTimeUs = 1u; } @@ -1539,7 +1532,7 @@ static void Cy_CapSense_CSDCalibrate( /* Wait for EOS */ while (CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY)) { - if(0uL == watchdogCounter) + if (0uL == watchdogCounter) { break; } @@ -1547,7 +1540,7 @@ static void Cy_CapSense_CSDCalibrate( } /* Switch to the lower IDAC mask */ - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { /* Update IDAC based on scan result */ if (ptrSnsCxt[freqChIndex * context->ptrCommonConfig->numSns].raw < rawTarget) @@ -1557,19 +1550,19 @@ static void Cy_CapSense_CSDCalibrate( ptrIdacMod[freqChIndex] |= (uint8_t)(calMask >> 1u); - if(0u == ptrIdacMod[freqChIndex]) + if (0u == ptrIdacMod[freqChIndex]) { ptrIdacMod[freqChIndex] = 1u; } - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) ptrSnsCxt[freqChIndex * context->ptrCommonConfig->numSns].idacComp = ptrIdacMod[freqChIndex]; #endif } calMask >>= 1u; } - while(calMask != 0u); + while (calMask != 0u); - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { /* Set the max Idac value */ if (ptrIdacMax[freqChIndex] < ptrIdacMod[freqChIndex]) @@ -1588,7 +1581,7 @@ static void Cy_CapSense_CSDCalibrate( /* Wait for EOS */ while (CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY)) { - if(0uL == watchdogCounter) + if (0uL == watchdogCounter) { break; } @@ -1596,11 +1589,11 @@ static void Cy_CapSense_CSDCalibrate( } } - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { ptrWdCxt->idacMod[freqChIndex] = maxColIdac[freqChIndex]; - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) if (((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType) || ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType)) { @@ -1687,7 +1680,7 @@ cy_capsense_status_t Cy_CapSense_CSDCalibrateWidget( uint32_t modClkDivider; const cy_stc_capsense_widget_config_t * ptrWdCfg; - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_AUTO_GAIN_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_AUTO_GAIN_EN) uint32_t gainSwitch; #endif @@ -1697,39 +1690,39 @@ cy_capsense_status_t Cy_CapSense_CSDCalibrateWidget( /* Wait For Init watchdog timeout in microseconds */ uint64_t isBusyWatchdogTimeUs; - if(context->ptrCommonConfig->numWd <= widgetId) + if (context->ptrCommonConfig->numWd <= widgetId) { calibrateStatus = CY_CAPSENSE_STATUS_BAD_PARAM; } - if(CY_CAPSENSE_CSD_GROUP != context->ptrWdConfig[widgetId].senseMethod) + if (CY_CAPSENSE_CSD_GROUP != context->ptrWdConfig[widgetId].senseMethod) { calibrateStatus = CY_CAPSENSE_STATUS_BAD_PARAM; } - if(CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY)) + if (CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY)) { /* Previous widget is being scanned, return error */ calibrateStatus = CY_CAPSENSE_STATUS_INVALID_STATE; } - if(CY_CAPSENSE_STATUS_SUCCESS == calibrateStatus) + if (CY_CAPSENSE_STATUS_SUCCESS == calibrateStatus) { ptrWdCfg = &context->ptrWdConfig[widgetId]; ptrWdCfg->ptrWdContext->idacGainIndex = context->ptrCommonConfig->csdIdacGainInitIndex; /* Perform calibration */ - #if(CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSD_IDAC_AUTO_GAIN_EN) + #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSD_IDAC_AUTO_GAIN_EN) Cy_CapSense_CSDCalibrate(widgetId, target, context); #else do { Cy_CapSense_CSDCalibrate(widgetId, target, context); gainSwitch = Cy_CapSense_CSDSwitchIdacGain(context); - } while(0u != gainSwitch); + } while (0u != gainSwitch); #endif - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) /* IDAC Normalization in Dual IDAC mode */ Cy_CapSense_CSDNormalizeIdac(ptrWdCfg, target, context); #endif @@ -1739,7 +1732,7 @@ cy_capsense_status_t Cy_CapSense_CSDCalibrateWidget( Cy_CapSense_CSDScan(context); modClkDivider = context->ptrCommonContext->modCsdClk; - if(0u == modClkDivider) + if (0u == modClkDivider) { modClkDivider = 1u; } @@ -1752,7 +1745,7 @@ cy_capsense_status_t Cy_CapSense_CSDCalibrateWidget( isBusyWatchdogTimeUs *= (uint64_t)modClkDivider * CY_CAPSENSE_CONVERSION_MEGA; isBusyWatchdogTimeUs /= context->ptrCommonConfig->periClkHz; - if(0u == isBusyWatchdogTimeUs) + if (0u == isBusyWatchdogTimeUs) { isBusyWatchdogTimeUs = 1u; } @@ -1763,7 +1756,7 @@ cy_capsense_status_t Cy_CapSense_CSDCalibrateWidget( while (CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY)) { - if(0uL == watchdogCounter) + if (0uL == watchdogCounter) { break; } @@ -1895,9 +1888,7 @@ static void Cy_CapSense_CSDTriggerScan(cy_stc_capsense_context_t * context) context->ptrCommonConfig->ptrCsdBase->HSCMP = context->ptrInternalContext->csdRegHscmpScan; /* Force the LFSR to it's initial state (all ones) */ - context->ptrCommonConfig->ptrCsdBase->SENSE_PERIOD = - context->ptrCommonConfig->ptrCsdBase->SENSE_PERIOD | - CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_CLEAR_MSK | CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_BITS_MSK; + context->ptrCommonConfig->ptrCsdBase->SENSE_PERIOD |= CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_CLEAR_MSK; /* Start SEQUENCER for fine initialization scan for Cmod and then for normal scan */ context->ptrCommonConfig->ptrCsdBase->SEQ_START = CY_CAPSENSE_CSD_SEQ_START_AZ0_SKIP_MSK | @@ -1934,7 +1925,7 @@ void Cy_CapSense_CSDScanISR(void * capsenseContext) uint32_t rawData; uint32_t maxCount; cy_stc_capsense_context_t * cxt = (cy_stc_capsense_context_t *)capsenseContext; - const cy_stc_active_scan_sns_t * ptrActive = cxt->ptrActiveScanSns; + const cy_stc_capsense_active_scan_sns_t * ptrActive = cxt->ptrActiveScanSns; /* Clear pending interrupt */ cxt->ptrCommonConfig->ptrCsdBase->INTR = CY_CAPSENSE_CSD_INTR_ALL_MSK; @@ -1947,7 +1938,7 @@ void Cy_CapSense_CSDScanISR(void * capsenseContext) maxCount = (1uL << ptrActive->ptrWdContext->resolution) - 1uL; rawData = cxt->ptrCommonConfig->ptrCsdBase->RESULT_VAL1 & CY_CAPSENSE_CSD_RESULT_VAL1_VALUE_MSK; - if(rawData > maxCount) + if (rawData > maxCount) { rawData = maxCount; } @@ -2002,7 +1993,7 @@ void Cy_CapSense_CSDScanISR(void * capsenseContext) *******************************************************************************/ static void Cy_CapSense_CSDInitNextSnsScan(cy_stc_capsense_context_t * context) { - const cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + const cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; uint32_t sensorId = ptrActive->sensorIndex + 1uL; /* Check if all the sensors are scanned in widget */ @@ -2047,7 +2038,7 @@ static void Cy_CapSense_CSDInitNextSnsScan(cy_stc_capsense_context_t * context) *******************************************************************************/ static void Cy_CapSense_CSDInitNextChScan(cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; ptrActive->mfsChannelIndex++; ptrActive->ptrSnsContext += context->ptrCommonConfig->numSns; diff --git a/cy_capsense_csd_v2.h b/cy_capsense_csd_v2.h index f0271e0..251caa5 100644 --- a/cy_capsense_csd_v2.h +++ b/cy_capsense_csd_v2.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_csd_v2.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the function prototypes specific to the CSD sensing @@ -43,9 +43,9 @@ extern "C" { #define CY_CAPSENSE_EXT_CAP_DISCHARGE_TIME (1u) -/*************************************** +/******************************************************************************* * Function Prototypes -**************************************/ +*******************************************************************************/ /******************************************************************************/ /** \cond SECTION_CAPSENSE_INTERNAL */ diff --git a/cy_capsense_csx_v2.c b/cy_capsense_csx_v2.c index bfdec45..9feb596 100644 --- a/cy_capsense_csx_v2.c +++ b/cy_capsense_csx_v2.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_csx_v2.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file defines the data structure global variables and provides @@ -139,7 +139,7 @@ void Cy_CapSense_CSXInitialize(cy_stc_capsense_context_t * context) #endif modClkDivider = (uint32_t)context->ptrCommonContext->modCsxClk; - if(0u == modClkDivider) + if (0u == modClkDivider) { modClkDivider = 1u; } @@ -426,7 +426,7 @@ void Cy_CapSense_CSXScan(cy_stc_capsense_context_t * context) *******************************************************************************/ void Cy_CapSense_CSXScanExt(cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; /* Set busy flag and start conversion */ Cy_CapSense_SetBusyFlags(context); @@ -435,7 +435,7 @@ void Cy_CapSense_CSXScanExt(cy_stc_capsense_context_t * context) ptrActive->scanScope = CY_CAPSENSE_SCAN_SCOPE_SNGL_SNS; #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) - if(0u != ptrActive->mfsChannelIndex) + if (0u != ptrActive->mfsChannelIndex) { Cy_CapSense_InitActivePtrSns(ptrActive->sensorIndex, context); Cy_CapSense_CSXSetSnsClkFreq(CY_CAPSENSE_MFS_CH0_INDEX, context); @@ -517,25 +517,23 @@ cy_capsense_status_t Cy_CapSense_CSXCalibrateWidget( /* Wait For Init watchdog timeout in microseconds */ uint64_t isBusyWatchdogTimeUs = 0u; - - if((context->ptrCommonConfig->numWd <= widgetId) || - (CY_CAPSENSE_DISABLE == context->ptrCommonConfig->csxIdacAutocalEn)) + if (context->ptrCommonConfig->numWd <= widgetId) { calibrateStatus = CY_CAPSENSE_STATUS_BAD_PARAM; } - if(CY_CAPSENSE_CSX_GROUP != context->ptrWdConfig[widgetId].senseMethod) + if (CY_CAPSENSE_CSX_GROUP != context->ptrWdConfig[widgetId].senseMethod) { calibrateStatus = CY_CAPSENSE_STATUS_BAD_PARAM; } - if(CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY)) + if (CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY)) { /* Previous widget is being scanned, return error */ calibrateStatus = CY_CAPSENSE_STATUS_INVALID_STATE; } - if(CY_CAPSENSE_STATUS_SUCCESS == calibrateStatus) + if (CY_CAPSENSE_STATUS_SUCCESS == calibrateStatus) { ptrWdCfg = &context->ptrWdConfig[widgetId]; ptrActSnsContext = ptrWdCfg->ptrSnsContext; @@ -545,7 +543,7 @@ cy_capsense_status_t Cy_CapSense_CSXCalibrateWidget( rawTarget = ((uint32_t)context->ptrWdContext[widgetId].maxRawCount * target) / CY_CAPSENSE_PERCENTAGE_100; /* Clear raw count registers and IDAC registers of all the sensors/nodes */ - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { /* Clear raw count registers and IDAC registers of all the sensors/nodes */ for (calibrationIndex = 0u; calibrationIndex < totalSns; calibrationIndex++) @@ -557,18 +555,18 @@ cy_capsense_status_t Cy_CapSense_CSXCalibrateWidget( modClkDivider = (uint32_t)context->ptrCommonContext->modCsxClk; snsClkDivider = (uint32_t)ptrWdCfg->ptrWdContext->snsClk; - if(0u == modClkDivider) + if (0u == modClkDivider) { modClkDivider = 1u; } - if(0u == snsClkDivider) + if (0u == snsClkDivider) { snsClkDivider = 1u; } #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) - if(context->ptrCommonConfig->csxMfsDividerOffsetF1 > + if (context->ptrCommonConfig->csxMfsDividerOffsetF1 > context->ptrCommonConfig->csxMfsDividerOffsetF2) { snsClkDivider += context->ptrCommonConfig->csxMfsDividerOffsetF1; @@ -586,7 +584,7 @@ cy_capsense_status_t Cy_CapSense_CSXCalibrateWidget( isBusyWatchdogTimeUs *= (uint64_t)snsClkDivider * modClkDivider * CY_CAPSENSE_CONVERSION_MEGA; isBusyWatchdogTimeUs /= context->ptrCommonConfig->periClkHz; - if(0uL == isBusyWatchdogTimeUs) + if (0uL == isBusyWatchdogTimeUs) { isBusyWatchdogTimeUs = 1u; } @@ -606,7 +604,7 @@ cy_capsense_status_t Cy_CapSense_CSXCalibrateWidget( /* Wait for EOS */ while (CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY)) { - if(0uL == watchdogCounter) + if (0uL == watchdogCounter) { break; } @@ -642,7 +640,7 @@ cy_capsense_status_t Cy_CapSense_CSXCalibrateWidget( calibrateStatus = CY_CAPSENSE_STATUS_SUCCESS; } - if(CY_CAPSENSE_STATUS_SUCCESS == calibrateStatus) + if (CY_CAPSENSE_STATUS_SUCCESS == calibrateStatus) { /* Perform specified widget scan to check calibration result */ /* Scan all the sensors/nodes in widget */ @@ -655,7 +653,7 @@ cy_capsense_status_t Cy_CapSense_CSXCalibrateWidget( /* Wait for EOS */ while (CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY)) { - if(0uL == watchdogCounter) + if (0uL == watchdogCounter) { calibrateStatus = CY_CAPSENSE_STATUS_TIMEOUT; break; @@ -664,13 +662,13 @@ cy_capsense_status_t Cy_CapSense_CSXCalibrateWidget( watchdogCounter--; } - if(CY_CAPSENSE_STATUS_SUCCESS == calibrateStatus) + if (CY_CAPSENSE_STATUS_SUCCESS == calibrateStatus) { calibrateStatus = Cy_CapSense_CalibrateCheck(widgetId, target, CY_CAPSENSE_CSX_GROUP, context); } } - return(calibrateStatus); + return calibrateStatus; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) */ @@ -720,7 +718,7 @@ static void Cy_CapSense_CSXStartSample(cy_stc_capsense_context_t * context) /* Enable interrupt */ context->ptrCommonConfig->ptrCsdBase->INTR_MASK = CY_CAPSENSE_CSD_INTR_MASK_SAMPLE_MSK; - if(NULL != context->ptrInternalContext->ptrSSCallback) + if (NULL != context->ptrInternalContext->ptrSSCallback) { context->ptrInternalContext->ptrSSCallback(context->ptrActiveScanSns); } @@ -764,17 +762,12 @@ static void Cy_CapSense_CSXStartSample(cy_stc_capsense_context_t * context) * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * -* \funcusage -* -* An example of using the function to perform port pin re-connection: -* \snippet capsense/snippet/main.c snippet_Cy_CapSense_CSXConnect -* *******************************************************************************/ void Cy_CapSense_CSXConnectRx( const cy_stc_capsense_pin_config_t * rxPtr, const cy_stc_capsense_context_t * context) { - (void) context; + (void)context; Cy_CapSense_SsConfigPinRegisters(rxPtr->pcPtr, (uint32_t)rxPtr->pinNumber, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXA); } @@ -814,17 +807,12 @@ void Cy_CapSense_CSXConnectRx( * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * -* \funcusage -* -* An example of using the function to perform port pin re-connection: -* \snippet capsense/snippet/main.c snippet_Cy_CapSense_CSXConnect -* *******************************************************************************/ void Cy_CapSense_CSXConnectTx( const cy_stc_capsense_pin_config_t * txPtr, const cy_stc_capsense_context_t * context) { - (void) context; + (void)context; Cy_CapSense_SsConfigPinRegisters(txPtr->pcPtr, (uint32_t)txPtr->pinNumber, CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF, CY_CAPSENSE_CSX_TX_SCAN_PIN_HSIOM); } @@ -857,17 +845,12 @@ void Cy_CapSense_CSXConnectTx( * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * -* \funcusage -* -* An example of using the function to perform port pin re-connection: -* \snippet capsense/snippet/main.c snippet_Cy_CapSense_CSXConnect -* *******************************************************************************/ void Cy_CapSense_CSXDisconnectRx( const cy_stc_capsense_pin_config_t * rxPtr, const cy_stc_capsense_context_t * context) { - (void) context; + (void)context; Cy_CapSense_SsConfigPinRegisters(rxPtr->pcPtr, (uint32_t)rxPtr->pinNumber, context->ptrInternalContext->csxInactiveSnsDm, context->ptrInternalContext->csxInactiveSnsHsiom); @@ -902,17 +885,12 @@ void Cy_CapSense_CSXDisconnectRx( * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * -* \funcusage -* -* An example of using the function to perform port pin re-connection: -* \snippet capsense/snippet/main.c snippet_Cy_CapSense_CSXConnect -* *******************************************************************************/ void Cy_CapSense_CSXDisconnectTx( const cy_stc_capsense_pin_config_t * txPtr, const cy_stc_capsense_context_t * context) { - (void) context; + (void)context; Cy_CapSense_SsConfigPinRegisters(txPtr->pcPtr, (uint32_t)txPtr->pinNumber, context->ptrInternalContext->csxInactiveSnsDm, context->ptrInternalContext->csxInactiveSnsHsiom); @@ -1096,7 +1074,7 @@ void Cy_CapSense_CSXScanISR(void * capsenseContext) { uint32_t tmpRawCount; cy_stc_capsense_context_t * cxt = (cy_stc_capsense_context_t *)capsenseContext; - const cy_stc_active_scan_sns_t * ptrActive = cxt->ptrActiveScanSns; + const cy_stc_capsense_active_scan_sns_t * ptrActive = cxt->ptrActiveScanSns; uint32_t maxCount = (uint32_t) ptrActive->ptrWdContext->maxRawCount; cxt->ptrCommonConfig->ptrCsdBase->INTR_MASK = CY_CAPSENSE_CSD_INTR_MASK_CLEAR_MSK; @@ -1113,7 +1091,7 @@ void Cy_CapSense_CSXScanISR(void * capsenseContext) CY_CAPSENSE_CSD_RESULT_VAL2_VALUE_MSK); /* This workaround needed to prevent overflow in the SW register map. ID #234358 */ - if(tmpRawCount > maxCount) + if (tmpRawCount > maxCount) { tmpRawCount = maxCount; } @@ -1121,7 +1099,7 @@ void Cy_CapSense_CSXScanISR(void * capsenseContext) #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) /* Either complete scan or initiate new one */ - if(ptrActive->mfsChannelIndex < CY_CAPSENSE_MFS_CH2_INDEX) + if (ptrActive->mfsChannelIndex < CY_CAPSENSE_MFS_CH2_INDEX) { Cy_CapSense_CSXInitNextChScan(cxt); } @@ -1176,7 +1154,7 @@ void Cy_CapSense_CSXScanISR(void * capsenseContext) *******************************************************************************/ static void Cy_CapSense_CSXInitNextScan(cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; ptrActive->mfsChannelIndex = 0u; ptrActive->ptrSnsContext = &ptrActive->ptrWdConfig->ptrSnsContext[ptrActive->sensorIndex]; @@ -1278,10 +1256,10 @@ __STATIC_INLINE void Cy_CapSense_CSXStartSampleExt(cy_stc_capsense_context_t * c watchdogCounter = Cy_CapSense_WatchdogCyclesNum(initWatchdogTimeUs, cpuFreqMHz, intrInitLoopDuration); /* Approximate duration of Wait For Init loop */ - while((0u != (CY_CAPSENSE_CSD_SEQ_START_START_MSK & + while ((0u != (CY_CAPSENSE_CSD_SEQ_START_START_MSK & context->ptrCommonConfig->ptrCsdBase->SEQ_START))) { - if(0uL == watchdogCounter) + if (0uL == watchdogCounter) { break; } @@ -1291,7 +1269,7 @@ __STATIC_INLINE void Cy_CapSense_CSXStartSampleExt(cy_stc_capsense_context_t * c /* Reset the sequencer to the IDLE state if HSCMP not triggered till watchdog period is out. */ - if(0u != (CY_CAPSENSE_CSD_SEQ_START_START_MSK & context->ptrCommonConfig->ptrCsdBase->SEQ_START)) + if (0u != (CY_CAPSENSE_CSD_SEQ_START_START_MSK & context->ptrCommonConfig->ptrCsdBase->SEQ_START)) { context->ptrCommonConfig->ptrCsdBase->SEQ_START = CY_CAPSENSE_DEFAULT_CSD_SEQ_START_CFG; } @@ -1330,7 +1308,7 @@ __STATIC_INLINE void Cy_CapSense_CSXStartSampleExt(cy_stc_capsense_context_t * c *******************************************************************************/ static void Cy_CapSense_CSXInitNextChScan(cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; ptrActive->mfsChannelIndex++; ptrActive->ptrSnsContext += context->ptrCommonConfig->numSns; @@ -1391,7 +1369,7 @@ static void Cy_CapSense_CSXSetSnsClkFreq(uint32_t channelIndex, cy_stc_capsense_ } #else - (void) channelIndex; + (void)channelIndex; #endif tmpRegVal = (uint32_t)context->ptrActiveScanSns->ptrWdContext->snsClkSource & (uint32_t)~((uint32_t)CY_CAPSENSE_CLK_SOURCE_AUTO_MASK); diff --git a/cy_capsense_csx_v2.h b/cy_capsense_csx_v2.h index 0f40926..48e27ae 100644 --- a/cy_capsense_csx_v2.h +++ b/cy_capsense_csx_v2.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_csx_v2.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the function prototypes specific to the CSX sensing diff --git a/cy_capsense_filter.c b/cy_capsense_filter.c index 2e638ec..569e75f 100644 --- a/cy_capsense_filter.c +++ b/cy_capsense_filter.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_filter.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file contains the source code of all filters implementation. @@ -21,7 +21,7 @@ #include "cy_capsense_common.h" #include "cy_capsense_lib.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) /******************************************************************************* @@ -57,21 +57,24 @@ static cy_capsense_status_t Cy_CapSense_CheckBaselineInv( * Function Name: Cy_CapSense_UpdateAllBaselines ****************************************************************************//** * -* Updates the baseline for all the sensors in all the widgets. -* -* Baselines must be updated after sensor scan to ignore low frequency -* changes in the sensor data caused by environment changes such as -* temperature from sensor status decision. -* +* Updates the baseline for all the sensors in all the widgets. +* +* Baselines must be updated after sensor scan to ignore low frequency +* changes in the sensor data caused by environment changes such as +* temperature from sensor status decision. +* * This function ignores the widget enable bit in the widget status register. -* Calling this function multiple times without a new sensor scan leads to -* unexpected behavior and should be avoided. -* -* This function is called by Cy_CapSense_ProcessAllWidgets() and -* Cy_CapSense_ProcessWidget(), hence the application program need not use this -* function if any of the above functions is already used. This function can be +* Calling this function multiple times without a new sensor scan leads to +* unexpected behavior and should be avoided. +* +* This function is called by Cy_CapSense_ProcessAllWidgets() and +* Cy_CapSense_ProcessWidget(), hence the application program need not use this +* function if any of the above functions is already used. This function can be * used for custom application implementation. -* +* +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -87,12 +90,17 @@ cy_capsense_status_t Cy_CapSense_UpdateAllBaselines( uint32_t wdIndex; cy_capsense_status_t bslnStatus = CY_CAPSENSE_STATUS_SUCCESS; - for(wdIndex = context->ptrCommonConfig->numWd; wdIndex-- > 0u;) + for (wdIndex = CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex-- > 0u;) { - bslnStatus |= Cy_CapSense_UpdateWidgetBaseline(wdIndex, context); + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != context->ptrWdConfig[wdIndex].wdType) + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + { + bslnStatus |= Cy_CapSense_UpdateWidgetBaseline(wdIndex, context); + } } - return(bslnStatus); + return bslnStatus; } @@ -100,44 +108,57 @@ cy_capsense_status_t Cy_CapSense_UpdateAllBaselines( * Function Name: Cy_CapSense_UpdateWidgetBaseline ****************************************************************************//** * -* Updates the baselines for all the sensors in a widget specified by -* the input parameter. -* -* This function performs exactly the same tasks as +* Updates the baselines for all the sensors in a widget specified by +* the input parameter. +* +* This function performs exactly the same tasks as * Cy_CapSense_UpdateAllBaselines() but only for a specified widget. -* -* Calling this function multiple times without a new sensor scan leads to -* unexpected behavior and should be avoided. The application program need -* not use this function if the Cy_CapSense_UpdateAllBaselines(), -* Cy_CapSense_ProcessAllWidgets() or Cy_CapSense_ProcessWidget() functions +* +* Calling this function multiple times without a new sensor scan leads to +* unexpected behavior and should be avoided. The application program need +* not use this function if the Cy_CapSense_UpdateAllBaselines(), +* Cy_CapSense_ProcessAllWidgets() or Cy_CapSense_ProcessWidget() functions * are already used. * * \param widgetId -* Specifies the ID number of the widget. A macro for the widget ID can be found +* Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed and +* \ref CY_CAPSENSE_STATUS_BAD_PARAM is returned +* if a widget of this type is passed. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * * \return * Returns the status of the specified widget update baseline operation: * - CY_CAPSENSE_STATUS_SUCCESS - The operation is successfully completed. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. * - CY_CAPSENSE_STATUS_BAD_DATA - The baseline processing failed. * *******************************************************************************/ cy_capsense_status_t Cy_CapSense_UpdateWidgetBaseline( - uint32_t widgetId, + uint32_t widgetId, const cy_stc_capsense_context_t * context) { uint32_t snsIndex; - cy_capsense_status_t bslnStatus = CY_CAPSENSE_STATUS_SUCCESS; + cy_capsense_status_t bslnStatus = CY_CAPSENSE_STATUS_BAD_PARAM; - for(snsIndex = context->ptrWdConfig[widgetId].numSns; snsIndex-- > 0u;) +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != context->ptrWdConfig[widgetId].wdType) +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ { - bslnStatus |= Cy_CapSense_UpdateSensorBaseline(widgetId, snsIndex, context); + bslnStatus = CY_CAPSENSE_STATUS_SUCCESS; + + for (snsIndex = context->ptrWdConfig[widgetId].numSns; snsIndex-- > 0u;) + { + bslnStatus |= Cy_CapSense_UpdateSensorBaseline(widgetId, snsIndex, context); + } } - return(bslnStatus); + return bslnStatus; } @@ -145,26 +166,29 @@ cy_capsense_status_t Cy_CapSense_UpdateWidgetBaseline( * Function Name: Cy_CapSense_UpdateSensorBaseline ****************************************************************************//** * -* Updates the baseline for a sensor in a widget specified by the -* input parameters. -* -* This function performs exactly the same tasks as -* Cy_CapSense_UpdateAllBaselines() and Cy_CapSense_UpdateWidgetBaseline() +* Updates the baseline for a sensor in a widget specified by the +* input parameters. +* +* This function performs exactly the same tasks as +* Cy_CapSense_UpdateAllBaselines() and Cy_CapSense_UpdateWidgetBaseline() * but only for a specified sensor. -* -* Calling this function multiple times without a new sensor scan leads to -* unexpected behavior and should be avoided. The application need not use -* this function if the Cy_CapSense_UpdateWidgetBaseline (), -* Cy_CapSense_UpdateAllBaselines (), Cy_CapSense_ProcessAllWidgets(), +* +* Calling this function multiple times without a new sensor scan leads to +* unexpected behavior and should be avoided. The application need not use +* this function if the Cy_CapSense_UpdateWidgetBaseline (), +* Cy_CapSense_UpdateAllBaselines (), Cy_CapSense_ProcessAllWidgets(), * or Cy_CapSense_ProcessWidget() functions are already used. * * \param widgetId -* Specifies the ID number of the widget. A macro for the widget ID can be found +* Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ it is not recommended +* to call this function for widgets of the \ref CY_CAPSENSE_WD_LOW_POWER_E type. +* * \param sensorId -* Specifies the ID number of the sensor within the widget. A macro for the -* sensor ID within a specified widget can be found in the cycfg_capsense.h +* Specifies the ID number of the sensor within the widget. A macro for the +* sensor ID within a specified widget can be found in the cycfg_capsense.h * file defined as CY_CAPSENSE__SNS_ID. * * \param context @@ -173,21 +197,22 @@ cy_capsense_status_t Cy_CapSense_UpdateWidgetBaseline( * \return * Returns the status of the specified sensor update baseline operation: * - CY_CAPSENSE_STATUS_SUCCESS - The operation is successfully completed. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. * - CY_CAPSENSE_STATUS_BAD_DATA - The baseline processing failed. * *******************************************************************************/ cy_capsense_status_t Cy_CapSense_UpdateSensorBaseline( - uint32_t widgetId, - uint32_t sensorId, + uint32_t widgetId, + uint32_t sensorId, const cy_stc_capsense_context_t * context) { - uint32_t result; + cy_capsense_status_t bslnStatus = CY_CAPSENSE_STATUS_BAD_PARAM; const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; cy_stc_capsense_sensor_context_t * ptrSnsCxt = &ptrWdCfg->ptrSnsContext[sensorId]; - result = Cy_CapSense_FtUpdateBaseline(ptrWdCfg->ptrWdContext, ptrSnsCxt, &ptrWdCfg->ptrBslnInv[sensorId], context); + bslnStatus = Cy_CapSense_FtUpdateBaseline(ptrWdCfg->ptrWdContext, ptrSnsCxt, &ptrWdCfg->ptrBslnInv[sensorId], context); - return (result); + return bslnStatus; } @@ -245,10 +270,10 @@ static cy_capsense_status_t Cy_CapSense_CheckBaselineInv( context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_BSLN_INTEGRITY_MASK; } #else - (void) ptrWdContext; - (void) ptrSnsContext; - (void) ptrSnsBslnInv; - (void) context; + (void)ptrWdContext; + (void)ptrSnsContext; + (void)ptrSnsBslnInv; + (void)context; #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN)) */ @@ -307,7 +332,7 @@ cy_capsense_status_t Cy_CapSense_FtUpdateBaseline( if (CY_CAPSENSE_STATUS_SUCCESS == result) { /* Reset negative baseline counter */ - if(ptrSnsContext->raw >= ptrSnsContext->bsln) + if (ptrSnsContext->raw >= ptrSnsContext->bsln) { ptrSnsContext->negBslnRstCnt = 0u; } @@ -360,19 +385,19 @@ cy_capsense_status_t Cy_CapSense_FtUpdateBaseline( ****************************************************************************//** * * Initializes the baselines of all the sensors of all the widgets. -* -* This function initializes baselines for all sensors and widgets in the project. -* It can also be used to re-initialize baselines at any time, however, note -* that all sensor data history information and sensor status shall be reset +* +* This function initializes baselines for all sensors and widgets in the project. +* It can also be used to re-initialize baselines at any time, however, note +* that all sensor data history information and sensor status shall be reset * along with re-initialization of baseline. -* -* Following functions to initialize sensor and widgets and filter history -* should be called after initializing baseline for proper operation of +* +* Following functions to initialize sensor and widgets and filter history +* should be called after initializing baseline for proper operation of * the CAPSENSE™ middleware: * * Cy_CapSense_InitializeAllStatuses() * * Cy_CapSense_InitializeAllFilters() -* -* These functions are called by the CapSense_Enable() function, hence it is +* +* These functions are called by the CapSense_Enable() function, hence it is * not required to use this function if above function is used. * * \param context @@ -383,7 +408,7 @@ void Cy_CapSense_InitializeAllBaselines(cy_stc_capsense_context_t * context) { uint32_t wdIndex; - for(wdIndex = context->ptrCommonConfig->numWd; wdIndex-- > 0u;) + for (wdIndex = CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex-- > 0u;) { Cy_CapSense_InitializeWidgetBaseline(wdIndex, context); } @@ -394,39 +419,47 @@ void Cy_CapSense_InitializeAllBaselines(cy_stc_capsense_context_t * context) * Function Name: Cy_CapSense_InitializeWidgetBaseline ****************************************************************************//** * -* Initializes the baselines of all the sensors in a specific widget. -* -* This function initializes baselines for all sensors in a specific widget -* in the project. It can also be used to re-initialize baselines at any time, -* however, note that all sensor data history information and sensor status +* Initializes the baselines of all the sensors in a specific widget. +* +* This function initializes baselines for all sensors in a specific widget +* in the project. It can also be used to re-initialize baselines at any time, +* however, note that all sensor data history information and sensor status * should be reset along with re-initialization of baseline. -* -* The following functions to initialize sensor and widgets and filter history -* should be called after initializing baselines for proper operation of +* +* The following functions to initialize sensor and widgets and filter history +* should be called after initializing baselines for proper operation of * middleware. * * Cy_CapSense_InitializeWidgetStatus() * * Cy_CapSense_InitializeWidgetFilter() -* -* These functions are called by CapSense_Enable() function, hence it is not +* +* These functions are called by CapSense_Enable() function, hence it is not * required to use this function is above function is used. -* +* * \param widgetId -* Specifies the ID number of the widget. A macro for the widget ID can be found +* Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * *******************************************************************************/ void Cy_CapSense_InitializeWidgetBaseline( - uint32_t widgetId, + uint32_t widgetId, cy_stc_capsense_context_t * context) { uint32_t snsIndex; - for(snsIndex = context->ptrWdConfig[widgetId].numSns; snsIndex-- > 0u;) +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != context->ptrWdConfig[widgetId].wdType) +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ { - Cy_CapSense_InitializeSensorBaseline(widgetId, snsIndex, context); + for (snsIndex = context->ptrWdConfig[widgetId].numSns; snsIndex-- > 0u;) + { + Cy_CapSense_InitializeSensorBaseline(widgetId, snsIndex, context); + } } } @@ -439,12 +472,15 @@ void Cy_CapSense_InitializeWidgetBaseline( * by the input parameters. * * \param widgetId -* Specifies the ID number of the widget. A macro for the widget ID can be found +* Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ it is not recommended +* to call this function for widgets of the \ref CY_CAPSENSE_WD_LOW_POWER_E type. +* * \param sensorId -* Specifies the ID number of the sensor within the widget. A macro for the -* sensor ID within a specified widget can be found in the cycfg_capsense.h +* Specifies the ID number of the sensor within the widget. A macro for the +* sensor ID within a specified widget can be found in the cycfg_capsense.h * file defined as CY_CAPSENSE__SNS_ID. * * \param context @@ -452,25 +488,26 @@ void Cy_CapSense_InitializeWidgetBaseline( * *******************************************************************************/ void Cy_CapSense_InitializeSensorBaseline( - uint32_t widgetId, - uint32_t sensorId, + uint32_t widgetId, + uint32_t sensorId, cy_stc_capsense_context_t * context) { uint32_t cxtOffset; uint32_t freqChIndex; - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; + + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) cxtOffset = sensorId + (freqChIndex * context->ptrCommonConfig->numSns); #else cxtOffset = sensorId; #endif - Cy_CapSense_FtInitializeBaseline(&context->ptrWdConfig[widgetId].ptrSnsContext[cxtOffset]); + Cy_CapSense_FtInitializeBaseline(&ptrWdCfg->ptrSnsContext[cxtOffset]); /* If BIST enabled, create a baseline inverse duplication */ #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) &&\ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN)) - context->ptrWdConfig[widgetId].ptrBslnInv[cxtOffset] = - ~context->ptrWdConfig[widgetId].ptrSnsContext[cxtOffset].bsln; + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN)) + ptrWdCfg->ptrBslnInv[cxtOffset] = ~ptrWdCfg->ptrSnsContext[cxtOffset].bsln; #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN)) */ } @@ -484,7 +521,7 @@ void Cy_CapSense_InitializeSensorBaseline( * Initializes the baseline history for a sensor indicated by an input * parameter. * -* \param ptrSnsContext +* \param ptrSnsContext * The pointer to the sensor context structure. * *******************************************************************************/ @@ -500,10 +537,10 @@ void Cy_CapSense_FtInitializeBaseline(cy_stc_capsense_sensor_context_t * ptrSnsC * Function Name: Cy_CapSense_InitializeAllFilters ****************************************************************************//** * -* Initializes (or re-initializes) all the firmware filter history, except +* Initializes (or re-initializes) all the firmware filter history, except * the baseline. * -* Calling this function is accompanied by +* Calling this function is accompanied by * * Cy_CapSense_InitializeAllStatuses() * * Cy_CapSense_InitializeAllBaselines() * @@ -515,7 +552,7 @@ void Cy_CapSense_InitializeAllFilters(const cy_stc_capsense_context_t * context) { uint32_t widgetId; - for(widgetId = context->ptrCommonConfig->numWd; widgetId-- > 0u;) + for (widgetId = CY_CAPSENSE_TOTAL_WIDGET_COUNT; widgetId-- > 0u;) { Cy_CapSense_InitializeWidgetFilter(widgetId, context); } @@ -526,23 +563,26 @@ void Cy_CapSense_InitializeAllFilters(const cy_stc_capsense_context_t * context) * Function Name: Cy_CapSense_InitializeWidgetFilter ****************************************************************************//** * -* Initializes (or re-initializes) the raw count filter history of all +* Initializes (or re-initializes) the raw count filter history of all * the sensors in a widget specified by the input parameter. * -* Calling this function is accompanied by +* Calling this function is accompanied by * - Cy_CapSense_InitializeWidgetStatus(). * - Cy_CapSense_InitializeWidgetBaseline(). * * \param widgetId -* Specifies the ID number of the widget. A macro for the widget ID can be found +* Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * *******************************************************************************/ void Cy_CapSense_InitializeWidgetFilter( - uint32_t widgetId, + uint32_t widgetId, const cy_stc_capsense_context_t * context) { uint32_t snsIndex; @@ -562,62 +602,67 @@ void Cy_CapSense_InitializeWidgetFilter( uint8_t * ptrHistoryLow = NULL; #endif - snsHistorySize = (uint32_t)ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_MASK; - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ { - for(snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + snsHistorySize = (uint32_t)ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_MASK; + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { - ptrSnsCtx = &ptrWdCfg->ptrSnsContext[snsIndex + (freqChIndex * context->ptrCommonConfig->numSns)]; - historyOffset = (freqChIndex * (CY_CAPSENSE_RAW_HISTORY_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)) + (snsHistorySize * snsIndex); - ptrHistory = &ptrWdCfg->ptrRawFilterHistory[historyOffset]; - - #if (CY_CAPSENSE_REGULAR_RC_MEDIAN_FILTER_EN || CY_CAPSENSE_PROX_RC_MEDIAN_FILTER_EN) - if(0u != (CY_CAPSENSE_RC_FILTER_MEDIAN_EN_MASK & rawFilterCfg)) + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + ptrSnsCtx = &ptrWdCfg->ptrSnsContext[snsIndex + (freqChIndex * context->ptrCommonConfig->numSns)]; + historyOffset = (freqChIndex * (CY_CAPSENSE_RAW_HISTORY_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)) + (snsHistorySize * snsIndex); + ptrHistory = &ptrWdCfg->ptrRawFilterHistory[historyOffset]; + + #if (CY_CAPSENSE_REGULAR_RC_MEDIAN_FILTER_EN || CY_CAPSENSE_PROX_RC_MEDIAN_FILTER_EN) + if (0u != (CY_CAPSENSE_RC_FILTER_MEDIAN_EN_MASK & rawFilterCfg)) + { + Cy_CapSense_InitializeMedianInternal(ptrWdCfg, ptrSnsCtx, ptrHistory); + ptrHistory += CY_CAPSENSE_RC_MEDIAN_SIZE; + } + #endif + + #if (CY_CAPSENSE_REGULAR_RC_IIR_FILTER_EN || CY_CAPSENSE_PROX_RC_IIR_FILTER_EN) + if (0u != (CY_CAPSENSE_RC_FILTER_IIR_EN_MASK & rawFilterCfg)) { - Cy_CapSense_InitializeMedianInternal(ptrWdCfg, ptrSnsCtx, ptrHistory); - ptrHistory += CY_CAPSENSE_RC_MEDIAN_SIZE; + if (CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) + { + ptrHistoryLow = &ptrWdCfg->ptrRawFilterHistoryLow[snsIndex + + (freqChIndex * (CY_CAPSENSE_IIR_HISTORY_LOW_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM))]; + } + Cy_CapSense_InitializeIIRInternal(ptrWdCfg, ptrSnsCtx, ptrHistory, ptrHistoryLow); + ptrHistory += CY_CAPSENSE_RC_IIR_SIZE; } - #endif + #endif - #if (CY_CAPSENSE_REGULAR_RC_IIR_FILTER_EN || CY_CAPSENSE_PROX_RC_IIR_FILTER_EN) - if(0u != (CY_CAPSENSE_RC_FILTER_IIR_EN_MASK & rawFilterCfg)) - { - if(CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) + #if (CY_CAPSENSE_REGULAR_RC_AVERAGE_FILTER_EN || CY_CAPSENSE_PROX_RC_AVERAGE_FILTER_EN) + if (0u != (CY_CAPSENSE_RC_FILTER_AVERAGE_EN_MASK & rawFilterCfg)) { - ptrHistoryLow = &ptrWdCfg->ptrRawFilterHistoryLow[snsIndex + - (freqChIndex * (CY_CAPSENSE_IIR_HISTORY_LOW_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM))]; + Cy_CapSense_InitializeAverageInternal(ptrWdCfg, ptrSnsCtx, ptrHistory); } - Cy_CapSense_InitializeIIRInternal(ptrWdCfg, ptrSnsCtx, ptrHistory, ptrHistoryLow); - ptrHistory += CY_CAPSENSE_RC_IIR_SIZE; - } - #endif - - #if (CY_CAPSENSE_REGULAR_RC_AVERAGE_FILTER_EN || CY_CAPSENSE_PROX_RC_AVERAGE_FILTER_EN) - if(0u != (CY_CAPSENSE_RC_FILTER_AVERAGE_EN_MASK & rawFilterCfg)) - { - Cy_CapSense_InitializeAverageInternal(ptrWdCfg, ptrSnsCtx, ptrHistory); + #endif } - #endif } - } - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - /* Noise envelope is available for CSD widgets only */ - if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) - { - ptrSnsCtx = ptrWdCfg->ptrSnsContext; - ptrNEHistory = ptrWdCfg->ptrNoiseEnvelope; - for(snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + /* Noise envelope is available for CSD widgets only */ + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) { - Cy_CapSense_InitializeNoiseEnvelope_Lib(ptrSnsCtx->raw, - ptrWdCfg->ptrWdContext->sigPFC, ptrNEHistory); - ptrSnsCtx++; - ptrNEHistory++; + ptrSnsCtx = ptrWdCfg->ptrSnsContext; + ptrNEHistory = ptrWdCfg->ptrNoiseEnvelope; + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + Cy_CapSense_InitializeNoiseEnvelope_Lib(ptrSnsCtx->raw, + ptrWdCfg->ptrWdContext->sigPFC, ptrNEHistory); + ptrSnsCtx++; + ptrNEHistory++; + } } - } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ - #endif + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + #endif + } } #endif /*(CY_CAPSENSE_DISABLE != CY_CAPSENSE_RAWCOUNT_FILTER_EN)*/ @@ -628,7 +673,7 @@ void Cy_CapSense_InitializeWidgetFilter( * * Initializes the IIR filter history. * -* \param ptrWdConfig +* \param ptrWdConfig * The pointer to the widget configuration structure. * * \param ptrSnsContext @@ -685,7 +730,7 @@ void Cy_CapSense_RunIIRInternal( uint32_t tempHistory; uint32_t tempRaw; - if(CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdConfig->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) + if (CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdConfig->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) { tempRaw = ((uint32_t)ptrSnsContext->raw) << CY_CAPSENSE_IIR_SHIFT_PERFORMANCE; tempHistory = ((uint32_t)(*ptrSnsRawHistory)) << CY_CAPSENSE_IIR_SHIFT_PERFORMANCE; @@ -755,8 +800,8 @@ void Cy_CapSense_RunMedianInternal( uint16_t * ptrSnsRawHistory) { uint32_t temp = Cy_CapSense_FtMedian( - (uint32_t)ptrSnsContext->raw, - (uint32_t)ptrSnsRawHistory[0u], + (uint32_t)ptrSnsContext->raw, + (uint32_t)ptrSnsRawHistory[0u], (uint32_t)ptrSnsRawHistory[1u]); (void)ptrWdConfig; @@ -802,7 +847,7 @@ void Cy_CapSense_InitializeAverageInternal( * * Runs the average filter. * -* \param ptrWdConfig +* \param ptrWdConfig * The pointer to the widget configuration structure. * * \param ptrSnsContext @@ -819,7 +864,7 @@ void Cy_CapSense_RunAverageInternal( { uint32_t temp; - if(CY_CAPSENSE_AVERAGE_FILTER_LEN_4 == (ptrWdConfig->rawFilterConfig & CY_CAPSENSE_RC_FILTER_AVERAGE_MODE_MASK)) + if (CY_CAPSENSE_AVERAGE_FILTER_LEN_4 == (ptrWdConfig->rawFilterConfig & CY_CAPSENSE_RC_FILTER_AVERAGE_MODE_MASK)) { temp = ((uint32_t)ptrSnsContext->raw + ptrSnsRawHistory[0u] + ptrSnsRawHistory[1u] + ptrSnsRawHistory[2u]) >> 2u; ptrSnsRawHistory[2u] = ptrSnsRawHistory[1u]; @@ -841,7 +886,7 @@ void Cy_CapSense_RunAverageInternal( * * Runs all enabled filters. * -* \param ptrWdConfig +* \param ptrWdConfig * The pointer to the widget configuration structure. * * \param ptrSnsContext @@ -865,15 +910,15 @@ void Cy_CapSense_FtRunEnabledFiltersInternal( uint16_t * ptrSnsRawHistoryLocal = ptrSnsRawHistory; #if (CY_CAPSENSE_REGULAR_RC_MEDIAN_FILTER_EN || CY_CAPSENSE_PROX_RC_MEDIAN_FILTER_EN) - if(0u != (CY_CAPSENSE_RC_FILTER_MEDIAN_EN_MASK & rawFilterCfg)) + if (0u != (CY_CAPSENSE_RC_FILTER_MEDIAN_EN_MASK & rawFilterCfg)) { Cy_CapSense_RunMedianInternal(ptrWdConfig, ptrSnsContext, ptrSnsRawHistoryLocal); ptrSnsRawHistoryLocal += CY_CAPSENSE_RC_MEDIAN_SIZE; } - #endif + #endif #if (CY_CAPSENSE_REGULAR_RC_IIR_FILTER_EN || CY_CAPSENSE_PROX_RC_IIR_FILTER_EN) - if(0u != (CY_CAPSENSE_RC_FILTER_IIR_EN_MASK & rawFilterCfg)) + if (0u != (CY_CAPSENSE_RC_FILTER_IIR_EN_MASK & rawFilterCfg)) { Cy_CapSense_RunIIRInternal(ptrWdConfig, ptrSnsContext, ptrSnsRawHistoryLocal, ptrSnsRawHistoryLow); ptrSnsRawHistoryLocal += CY_CAPSENSE_RC_IIR_SIZE; @@ -883,7 +928,7 @@ void Cy_CapSense_FtRunEnabledFiltersInternal( #endif #if (CY_CAPSENSE_REGULAR_RC_AVERAGE_FILTER_EN || CY_CAPSENSE_PROX_RC_AVERAGE_FILTER_EN) - if(0u != (CY_CAPSENSE_RC_FILTER_AVERAGE_EN_MASK & rawFilterCfg)) + if (0u != (CY_CAPSENSE_RC_FILTER_AVERAGE_EN_MASK & rawFilterCfg)) { Cy_CapSense_RunAverageInternal(ptrWdConfig, ptrSnsContext, ptrSnsRawHistoryLocal); } @@ -1000,7 +1045,7 @@ uint32_t Cy_CapSense_FtJitter(uint32_t input, uint32_t prevOutput) } #endif /*(CY_CAPSENSE_DISABLE != CY_CAPSENSE_POS_JITTER_FILTER_EN)*/ -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ /* [] END OF FILE */ diff --git a/cy_capsense_filter.h b/cy_capsense_filter.h index 0370dcc..51247d8 100644 --- a/cy_capsense_filter.h +++ b/cy_capsense_filter.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_filter.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file contains the definitions for all the filters implementation. @@ -24,16 +24,16 @@ #include "cy_capsense_structure.h" #include "cy_capsense_common.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if defined(__cplusplus) extern "C" { #endif -/*************************************** +/******************************************************************************* * Function Prototypes -***************************************/ +*******************************************************************************/ /******************************************************************************* * LOW LEVEL FUNCTIONS @@ -135,7 +135,7 @@ uint32_t Cy_CapSense_FtIIR1stOrder(uint32_t input, uint32_t prevOutput, uint32_t } #endif -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif /* CY_CAPSENSE_FILTER_H */ diff --git a/cy_capsense_generator_lp.c b/cy_capsense_generator_lp.c new file mode 100644 index 0000000..62279d8 --- /dev/null +++ b/cy_capsense_generator_lp.c @@ -0,0 +1,1308 @@ +/***************************************************************************//** +* \file cy_capsense_generator_lp.c +* \version 4.0 +* +* \brief +* This file contains the source of functions common for register map +* generator module. +* +******************************************************************************** +* \copyright +* Copyright 2020-2023, Cypress Semiconductor Corporation (an Infineon company) +* or an affiliate of Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +*******************************************************************************/ + + +#include +#include "cycfg_capsense_defines.h" +#include "cycfg_peripherals.h" +#include "cy_capsense_common.h" +#include "cy_capsense_structure.h" +#include "cy_capsense_sensing_lp.h" +#include "cy_capsense_generator_lp.h" +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_msclp.h" +#endif + +#if (defined(CY_IP_M0S8MSCV3LP)) + + +/******************************************************************************* +* Internal function prototypes +*******************************************************************************/ +void Cy_CapSense_GenerateModeConfig( + const cy_stc_capsense_context_t * context); + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_ENABLED) + static void Cy_CapSense_GenerateMultiphaseSensorConfig( + uint32_t snsFrameType, + uint32_t scanSlotIndex, + uint32_t * ptrSensorCfgLoc, + cy_stc_capsense_context_t * context); +#endif + + +/******************************************************************************* +* Function Name: Cy_CapSense_GenerateBaseConfig +****************************************************************************//** +* +* Generates the configuration for all registers that have to be configured +* one-time to initialize the MSCLP block. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_GenerateBaseConfig(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus; + + cy_stc_capsense_internal_context_t * ptrIntrCxt = context->ptrInternalContext; + const cy_stc_msclp_base_config_t cy_capsense_smTemplate = CY_CAPSENSE_SENSING_METHOD_BASE_TEMPLATE; + cy_stc_msclp_base_config_t * ptrBaseCfg = context->ptrBaseFrameContext; + const cy_stc_msclp_base_config_t * ptrTemplateCfg = &cy_capsense_smTemplate; + + /* + * BASE CONFIGURATION + */ + + /* Copy template of a base config */ + ptrBaseCfg->ctl = ptrTemplateCfg->ctl; + ptrBaseCfg->scanCtl1 = ptrTemplateCfg->scanCtl1; + ptrBaseCfg->scanCtl2 = ptrTemplateCfg->scanCtl2; + ptrBaseCfg->initCtl1 = ptrTemplateCfg->initCtl1; + ptrBaseCfg->initCtl2 = ptrTemplateCfg->initCtl2; + ptrBaseCfg->initCtl3 = ptrTemplateCfg->initCtl3; + ptrBaseCfg->initCtl4 = ptrTemplateCfg->initCtl4; + ptrBaseCfg->senseDutyCtl = ptrTemplateCfg->senseDutyCtl; + ptrBaseCfg->ccompCdacCtl = ptrTemplateCfg->ccompCdacCtl; + ptrBaseCfg->mscCmpCtl = ptrTemplateCfg->mscCmpCtl; + + ptrBaseCfg->aosCtl = ptrTemplateCfg->aosCtl; + ptrBaseCfg->ceCtl = ptrTemplateCfg->ceCtl; + ptrBaseCfg->pumpCtl = ptrTemplateCfg->pumpCtl; + + ptrBaseCfg->intr = ptrTemplateCfg->intr; + ptrBaseCfg->intrSet = ptrTemplateCfg->intrSet; + ptrBaseCfg->intrMask = ptrTemplateCfg->intrMask; + ptrBaseCfg->intrLp = ptrTemplateCfg->intrLp; + ptrBaseCfg->intrLpSet = ptrTemplateCfg->intrLpSet; + ptrBaseCfg->intrLpMask = ptrTemplateCfg->intrLpMask; + ptrBaseCfg->swSelCdacRe = ptrTemplateCfg->swSelCdacRe; + ptrBaseCfg->swSelCdacCo = ptrTemplateCfg->swSelCdacCo; + ptrBaseCfg->swSelCdacCf = ptrTemplateCfg->swSelCdacCf; + ptrBaseCfg->swSelBgr = ptrTemplateCfg->swSelBgr; + + /* + * CONFIGURATION FROM CAPSENSE™ DATA STRUCTURE + */ + + ptrBaseCfg->ctl &= ~MSCLP_CTL_EXT_FRAME_START_MODE_Msk; + + /* Set the current scanning mode */ + CY_REG32_CLR_SET(ptrBaseCfg->ctl, MSCLP_CTL_OPERATING_MODE, ptrIntrCxt->operatingMode); + /* Generating the common configuration for the number of the auto-resampling cycles and the counter behaviour when the + * RAW_COUNT exceeds 0xFFFF + */ + CY_REG32_CLR_SET(ptrBaseCfg->scanCtl1, MSCLP_SCAN_CTL1_NUM_AUTO_RESAMPLE, context->ptrCommonConfig->numBadScans); + CY_REG32_CLR_SET(ptrBaseCfg->scanCtl1, MSCLP_SCAN_CTL1_RAW_COUNT_MODE, context->ptrCommonConfig->counterMode); + + /* Generating the common configuration for the number of epilogue cycles */ + CY_REG32_CLR_SET(ptrBaseCfg->scanCtl2, MSCLP_SCAN_CTL2_NUM_EPI_KREF_DELAY, ((0u < ptrIntrCxt->numEpiKrefDelay) ? ptrIntrCxt->numEpiKrefDelay : 1uL)); + CY_REG32_CLR_SET(ptrBaseCfg->scanCtl2, MSCLP_SCAN_CTL2_NUM_EPI_KREF_DELAY_PRS, ((0u < ptrIntrCxt->numEpiKrefDelayPrs) ? ptrIntrCxt->numEpiKrefDelayPrs : 1uL)); + /* Generating the common configuration for the system level chopping */ + CY_REG32_CLR_SET(ptrBaseCfg->scanCtl2, MSCLP_SCAN_CTL2_CHOP_POL, context->ptrCommonConfig->chopPolarity); + + /* Generating the common configuration for the coarse initialization and coarse short phase */ + CY_REG32_CLR_SET(ptrBaseCfg->initCtl1, MSCLP_INIT_CTL1_NUM_INIT_CMOD_12_RAIL_CYCLES, ptrIntrCxt->numCoarseInitChargeCycles); + CY_REG32_CLR_SET(ptrBaseCfg->initCtl1, MSCLP_INIT_CTL1_NUM_INIT_CMOD_12_SHORT_CYCLES, ptrIntrCxt->numCoarseInitSettleCycles); + + CY_REG32_CLR_SET(ptrBaseCfg->initCtl3, MSCLP_INIT_CTL3_CMOD_SEL, CY_CAPSENSE_CMOD12_PAIR_SELECTION); + CY_REG32_CLR_SET(ptrBaseCfg->initCtl3, MSCLP_INIT_CTL3_NUM_PRO_OFFSET_CYCLES, ptrIntrCxt->numProOffsetCycles); + + /* Generating the common configuration for the number of sub-conversions to be run during PRO_DUMMY and PRO_WAIT phases. */ + CY_REG32_CLR_SET(ptrBaseCfg->initCtl4, MSCLP_INIT_CTL4_NUM_PRO_DUMMY_SUB_CONVS, context->ptrInternalContext->numFineInitCycles); + CY_REG32_CLR_SET(ptrBaseCfg->initCtl4, MSCLP_INIT_CTL4_NUM_PRO_WAIT_KREF_DELAY, context->ptrInternalContext->numProWaitKrefDelay); + CY_REG32_CLR_SET(ptrBaseCfg->initCtl4, MSCLP_INIT_CTL4_NUM_PRO_WAIT_KREF_DELAY_PRS, context->ptrInternalContext->numProWaitKrefDelayPrs); + + /* Generating the common configuration for the clock dithering */ + ptrBaseCfg->sensePeriodCtl = _VAL2FLD(MSCLP_SENSE_PERIOD_CTL_LFSR_POLY, context->ptrInternalContext->lfsrPoly) | + _VAL2FLD(MSCLP_SENSE_PERIOD_CTL_LFSR_SCALE, context->ptrInternalContext->lfsrScale); + + /* Generating the common configuration for the CIC2 Filter */ + ptrBaseCfg->filterCtl = _VAL2FLD(MSCLP_FILTER_CTL_FILTER_MODE, CY_CAPSENSE_CIC2_FILTER_EN); + + /* Generating the common configuration for the dithering CapDAC */ + ptrBaseCfg->ditherCdacCtl = _VAL2FLD(MSCLP_DITHER_CDAC_CTL_SEL_FL, context->ptrInternalContext->cdacDitherSeed) | + _VAL2FLD(MSCLP_DITHER_CDAC_CTL_LFSR_POLY_FL, context->ptrInternalContext->cdacDitherPoly); + + /* Generating the common configuration for the Compensation CDAC */ + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_COMP_USAGE)) + CY_REG32_CLR_SET(ptrBaseCfg->ccompCdacCtl, MSCLP_CCOMP_CDAC_CTL_SEL_CO_PRO_OFFSET, ptrIntrCxt->proOffsetCdacComp); + #else + ptrBaseCfg->swSelCdacCo = 0u; + #endif + + #if (CY_CAPSENSE_IMO_FREQUENCY == CY_CAPSENSE_IMO_25_MHZ) + ptrBaseCfg->imoCtl = _VAL2FLD(MSCLP_IMO_CTL_FREQ, CY_MSCLP_IMO_25_MHZ); + #elif (CY_CAPSENSE_IMO_FREQUENCY == CY_CAPSENSE_IMO_38_MHZ) + ptrBaseCfg->imoCtl = _VAL2FLD(MSCLP_IMO_CTL_FREQ, CY_MSCLP_IMO_38_MHZ); + #else /* (CY_CAPSENSE_IMO_FREQUENCY == CY_CAPSENSE_IMO_46_MHZ) */ + ptrBaseCfg->imoCtl = _VAL2FLD(MSCLP_IMO_CTL_FREQ, CY_MSCLP_IMO_46_MHZ); + #endif + ptrBaseCfg->imoCtl |= _VAL2FLD(MSCLP_IMO_CTL_CLOCK_MSC_DIV, (uint32_t)context->ptrInternalContext->modClk - 1u); + + Cy_CapSense_GenerateModeConfig(context); + + /* PINS FUNCTIONS CONFIGURATION */ + capStatus = Cy_CapSense_GeneratePinFunctionConfig(context); + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GeneratePinFunctionConfig +****************************************************************************//** +* +* Configures pin function-related registers in base configuration per defined +* CapSense configuration. +* +* \param context +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_GeneratePinFunctionConfig( + const cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + + uint32_t i; + uint8_t idCounter = 0u; + + uint8_t * ptrMapping = &context->ptrInternalContext->mapPinState[0u]; + uint32_t * ptrCswFunc = &context->ptrBaseFrameContext->swSelCswFunc[0u]; + const uint32_t pinStates[CY_CAPSENSE_CTRLMUX_PIN_STATE_NUMBER] = CY_CAPSENSE_PIN_STATES_ARR; + + for (i = 0u; i < CY_CAPSENSE_CTRLMUX_PIN_STATE_NUMBER; i++) + { + ptrMapping[i] = CY_CAPSENSE_PIN_STATE_IDX_UNDEFINED; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_RX] = idCounter; + idCounter++; + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_TX] = idCounter; + idCounter++; + + /* Set CSX inactive sensor connection */ + switch (context->ptrInternalContext->intrCsxInactSnsConn) + { + case CY_CAPSENSE_SNS_CONNECTION_HIGHZ: + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z] = idCounter; + idCounter++; + break; + case CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2: + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_VDDA2] = idCounter; + idCounter++; + break; + default: + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_GND] = idCounter; + idCounter++; + break; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_NEG_TX] = idCounter; + idCounter++; + #endif /* CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED */ + #endif /* CY_CAPSENSE_CSX_EN */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_ISX_RX] = idCounter; + idCounter++; + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_ISX_LX] = idCounter; + idCounter++; + + /* Set ISX inactive sensor connection (only High-Z) if it is not assigned already */ + if (CY_CAPSENSE_PIN_STATE_IDX_UNDEFINED == + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z]) + { + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z] = idCounter; + idCounter++; + } + #endif /* CY_CAPSENSE_ISX_EN */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSD_SNS] = idCounter; + idCounter++; + + /* Set CSD inactive sensor connection if it is not assigned already */ + switch (context->ptrInternalContext->intrCsdInactSnsConn) + { + case CY_CAPSENSE_SNS_CONNECTION_HIGHZ: + if (CY_CAPSENSE_PIN_STATE_IDX_UNDEFINED == ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z]) + { + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z] = idCounter; + idCounter++; + } + break; + case CY_CAPSENSE_SNS_CONNECTION_GROUND: + if (CY_CAPSENSE_PIN_STATE_IDX_UNDEFINED == ptrMapping[CY_CAPSENSE_CTRLMUX_PIN_STATE_GND]) + { + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_GND] = idCounter; + idCounter++; + } + break; + default: + /* No action */ + break; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_PASSIVE_EN) + if (CY_CAPSENSE_PIN_STATE_IDX_UNDEFINED == + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_PAS_SHIELD]) + { + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_PAS_SHIELD] = idCounter; + idCounter++; + } + #else + if (CY_CAPSENSE_PIN_STATE_IDX_UNDEFINED == + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_ACT_SHIELD]) + { + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_ACT_SHIELD] = idCounter; + idCounter++; + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_PASSIVE_EN) */ + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_MPSC_CSP] = idCounter; + idCounter++; + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_MPSC_CSN] = idCounter; + idCounter++; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MPSC_ZERO_PIN_EN) + ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_MPSC_CSZ] = idCounter; + idCounter++; + #endif + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) */ + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + + context->ptrInternalContext->numFunc = idCounter; + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) && \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED))) + if (MSCLP_CSW_GLOBAL_FUNC_NR < idCounter) + { + capStatus = CY_CAPSENSE_STATUS_CONFIG_OVERFLOW; + } + else + { + for (i = 0u; i < CY_CAPSENSE_CTRLMUX_PIN_STATE_NUMBER; i++) + { + if (CY_CAPSENSE_PIN_STATE_IDX_UNDEFINED != ptrMapping[i]) + { + ptrCswFunc[ptrMapping[i]] = pinStates[i]; + } + } + } + #else + for (i = 0u; i < CY_CAPSENSE_CTRLMUX_PIN_STATE_NUMBER; i++) + { + if (CY_CAPSENSE_PIN_STATE_IDX_UNDEFINED != ptrMapping[i]) + { + ptrCswFunc[ptrMapping[i]] = pinStates[i]; + } + } + #endif + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GenerateSensorConfig +****************************************************************************//** +* +* Generates configuration to configure registers to +* the scan of the single sensor in the specified slot of the specified Sensor Frame. +* +* \param snsFrameType +* The Sensor Frame type: +* * CY_CAPSENSE_SNS_FRAME_ACTIVE - Sensor frame for Active slot +* * CY_CAPSENSE_SNS_FRAME_LOW_POWER - Sensor frame for Low Power slot +* +* \param scanSlot +* The specified slot index. +* +* \param ptrSensorCfg +* Specifies the pointer to the sensor configuration to be filled. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_GenerateSensorConfig( + uint32_t snsFrameType, + uint32_t scanSlot, + uint32_t * ptrSensorCfg, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + const cy_stc_capsense_internal_context_t * ptrInternalCxt = context->ptrInternalContext; + const cy_stc_capsense_scan_slot_t * ptrScanSlot = (CY_CAPSENSE_SNS_FRAME_ACTIVE == snsFrameType) ? &context->ptrScanSlots[scanSlot] : + &context->ptrLpScanSlots[scanSlot]; + #else + const cy_stc_capsense_scan_slot_t * ptrScanSlot = &context->ptrScanSlots[scanSlot]; + (void)snsFrameType; + #endif /* CY_CAPSENSE_LP_EN */ + cy_stc_capsense_widget_config_t const * ptrWdCfg = &context->ptrWdConfig[ptrScanSlot->wdId]; + cy_stc_capsense_widget_context_t const * ptrWdCxt = &context->ptrWdContext[ptrScanSlot->wdId]; + uint32_t snsMethod = ptrWdCfg->senseMethod; + uint32_t modeSel = 0u; + uint32_t tempValue; + uint32_t *ptrSensorCfgLocal = ptrSensorCfg; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if (CY_CAPSENSE_SNS_FRAME_LOW_POWER == snsFrameType) /* If Low Power Sensor Frame */ + { + ptrSensorCfgLocal[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL0] = _VAL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL0_RC_COEFF, ptrInternalCxt->iirCoeffLp) | + _VAL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL0_BL_COEFF_SLOW, ptrInternalCxt->bslnCoefSlow) | + _VAL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL0_BL_COEFF_FAST, ptrInternalCxt->bslnCoefFast) | + _VAL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL0_LOW_BL_RESET, ptrWdCxt->lowBslnRst) | + _VAL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL0_BL_UPDATE_DELAY, ptrInternalCxt->bslnUpdateDelay); + ptrSensorCfgLocal[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL1] = _VAL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL1_NOISE_THR, ptrWdCxt->noiseTh) | + _VAL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL1_NOISE_THR_NEG, ptrWdCxt->nNoiseTh); + ptrSensorCfgLocal[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL2] = _VAL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL2_SIGNAL_THR, ptrWdCxt->fingerTh) | + _VAL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL2_DEBOUNCE_THRESHOLD, ptrWdCxt->onDebounce) | + _BOOL2FLD(MSCLP_SNS_SNS_LP_AOS_SNS_CTL2_SIGNAL_TYPE, (CY_CAPSENSE_CSD_GROUP != snsMethod)); + ptrSensorCfgLocal[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL3] = 0u; + ptrSensorCfgLocal[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL4] = 0u; + + ptrSensorCfgLocal += (CY_MSCLP_11_SNS_REGS - CY_MSCLP_6_SNS_REGS); + } + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + if (CY_CAPSENSE_SNS_FRAME_LOW_POWER != snsFrameType) + { + /* Set raw count filter coefficient */ + ptrSensorCfgLocal[CY_CAPSENSE_SNS_HW_IIR_INDEX] = (uint32_t)((uint32_t)ptrWdCfg->iirCoeffHw << CY_CAPSENSE_RC_HW_IIR_FILTER_COEFF_POS); + } + #endif + + ptrSensorCfgLocal[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] = _VAL2FLD(MSCLP_SNS_SNS_SCAN_CTL_NUM_CONV, (uint32_t)ptrWdCfg->numChopCycles - 1uL) | /* System level chopping */ + _VAL2FLD(MSCLP_SNS_SNS_SCAN_CTL_NUM_SUB_CONVS, (uint32_t)ptrWdCxt->numSubConversions - 1uL); /* Number of sub-conversions */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + tempValue = ptrWdCxt->cicShift; + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_TOUCHPAD_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_MATRIX_EN)) + if ((((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || + ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType)) && + (ptrWdCfg->numCols <= ptrScanSlot->snsId) && + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod)) + { + tempValue = ptrWdCxt->rowCicShift; + } + #endif + ptrSensorCfgLocal[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] |= (uint32_t)(tempValue & (uint32_t)~(uint32_t)CY_CAPSENSE_CIC_AUTO_MASK) << CY_CAPSENSE_CIC_FIELD_POSITION; + #endif + + if((CY_CAPSENSE_ENABLE == ptrWdCxt->coarseInitBypassEn) && + (scanSlot != ptrWdCfg->firstSlotId)) + { + ptrSensorCfgLocal[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] |= MSCLP_SNS_SNS_SCAN_CTL_INIT_BYPASS_Msk; + } + + /* CapDAC configuration, after the SNS_SCAN_CTL initialization */ + capStatus = Cy_CapSense_GenerateCdacConfig(ptrScanSlot, ptrSensorCfgLocal, context); + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + tempValue = ptrWdCxt->snsClk; + switch (snsMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + modeSel = CY_CAPSENSE_REG_MODE_CSD; + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_TOUCHPAD_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_MATRIX_EN)) + if ((((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || + ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType)) && + (ptrWdCfg->numCols <= ptrScanSlot->snsId)) + { + tempValue = ptrWdCxt->rowSnsClk; + } + #endif /* CY_CAPSENSE_CSD_TOUCHPAD_EN || CY_CAPSENSE_CSD_MATRIX_EN */ + break; + #endif /* CY_CAPSENSE_CSD_EN */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + modeSel = CY_CAPSENSE_REG_MODE_CSX; + break; + #endif /* CY_CAPSENSE_CSX_EN */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_GROUP: + modeSel = CY_CAPSENSE_REG_MODE_ISX; + break; + #endif /* CY_CAPSENSE_ISX_EN */ + + default: + capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + break; + } + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + tempValue = Cy_CapSense_AdjustSnsClkDivider((uint8_t)snsMethod, ptrWdCxt->snsClkSource, (uint16_t)tempValue) - 1u; + + ptrSensorCfgLocal[CY_CAPSENSE_SNS_CTL_INDEX] = _VAL2FLD(MSCLP_SNS_SNS_CTL_SENSE_MODE_SEL, modeSel) | + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) + _VAL2FLD(MSCLP_SNS_SNS_CTL_DECIM_RATE, (uint32_t)ptrWdCxt->cicRate - 1u) | + #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) */ + MSCLP_SNS_SNS_CTL_VALID_Msk | + MSCLP_SNS_SNS_CTL_START_SCAN_Msk | + _VAL2FLD(MSCLP_SNS_SNS_CTL_SENSE_DIV, tempValue) | + _VAL2FLD(MSCLP_SNS_SNS_CTL_LFSR_MODE, ptrWdCxt->snsClkSource) | + _VAL2FLD(MSCLP_SNS_SNS_CTL_LFSR_BITS, ptrWdCxt->lfsrBits); + } + } + + return capStatus; +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_ENABLED) +/******************************************************************************* +* Function Name: Cy_CapSense_GenerateMultiphaseSensorConfig +******************************************************************************** +* +* Generates configuration for the multi-phase sensor groups. +* +* \param snsFrameType +* The Sensor Frame type: +* * CY_CAPSENSE_SNS_FRAME_ACTIVE - Sensor frame for Active slot +* * CY_CAPSENSE_SNS_FRAME_LOW_POWER - Sensor frame for Low Power slot +* +* \param scanSlotIndex +* Sensor frame slot number. +* +* \param ptrSensorCfgLoc +* Specifies the pointer to the mask registers. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +static void Cy_CapSense_GenerateMultiphaseSensorConfig( + uint32_t snsFrameType, + uint32_t scanSlotIndex, + uint32_t * ptrSensorCfgLoc, + cy_stc_capsense_context_t * context) +{ + uint8_t * ptrMapping = &context->ptrInternalContext->mapPinState[0u]; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + + uint32_t snsFuncState; + cy_stc_capsense_electrode_config_t const * eltdPinCfg; + + uint32_t wdIndex; + uint32_t snsMethod; + uint32_t snsIndex; + + uint32_t i = 0u; + uint32_t j = 0u; + uint32_t pattern = 0u; + uint32_t order; + + uint32_t snsMask = 0u; + uint32_t snsMaskNegative; + uint32_t snsFuncStateNegative; + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MPSC_ZERO_PIN_EN)) + uint32_t zeroPattern = 0u; + uint32_t snsMaskZero = 0u; + uint32_t snsFuncStateZero; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + ptrScanSlots = (snsFrameType == CY_CAPSENSE_SNS_FRAME_ACTIVE) ? (context->ptrScanSlots) : (context->ptrLpScanSlots); + #else + ptrScanSlots = context->ptrScanSlots; + (void)snsFrameType; + #endif + + snsIndex = ptrScanSlots[scanSlotIndex].snsId; + wdIndex = ptrScanSlots[scanSlotIndex].wdId; + ptrWdCfg = &context->ptrWdConfig[wdIndex]; + snsMethod = ptrWdCfg->senseMethod; + + /* Prepare masks and pin states */ + snsMask = 0u; + snsMaskNegative = 0u; + + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_TX]; + snsFuncStateNegative = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_NEG_TX]; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (CY_CAPSENSE_CSD_GROUP == snsMethod) + { + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_MPSC_CSP]; + snsFuncStateNegative = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_MPSC_CSN]; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MPSC_ZERO_PIN_EN) + snsFuncStateZero = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_MPSC_CSZ]; + #endif + } + #endif + + order = ptrWdCfg->mpOrder; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) + if (CY_CAPSENSE_CSX_GROUP == snsMethod) + { + /* Finds the first sensor number in mptx group */ + i = snsIndex - (snsIndex % order); + /* Finds TX electrode of the first group sensor */ + i = ptrWdCfg->numCols + (i % ptrWdCfg->numRows); + } + #endif + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (CY_CAPSENSE_CSD_GROUP == snsMethod) + { + if (snsIndex < ptrWdCfg->numCols) + { + /* Finds the first sensor number in mpsc group */ + i = snsIndex - (snsIndex % order); + } + else + { + order = ptrWdCfg->mpOrderRows; + /* Finds the first sensor number in mpsc group */ + i = snsIndex - ((snsIndex - ptrWdCfg->numCols) % order); + } + } + #endif + + /* Finds the first electrode of the sensor */ + eltdPinCfg = &ptrWdCfg->ptrEltdConfig[i]; + + /* Finding the right vector / pattern for mpsc operation */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) + if (CY_CAPSENSE_CSX_GROUP == snsMethod) + { + pattern = ptrWdCfg->ptrMpTable->vector; + i = (snsIndex % ptrWdCfg->mpOrder); + } + #endif + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (CY_CAPSENSE_CSD_GROUP == snsMethod) + { + pattern = (snsIndex < ptrWdCfg->numCols) ? ptrWdCfg->ptrMpTable->vector : (ptrWdCfg->ptrMpTable + 1u)->vector; + + if (snsIndex < ptrWdCfg->numCols) + { + i = (snsIndex % order); /* bit position in vector */ + } + else + { + i = ((snsIndex - ptrWdCfg->numCols) % order); + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MPSC_ZERO_PIN_EN) + /* Set initial position of the zero electrode position */ + zeroPattern = (0uL != (order % 2u)) ? 1u : 0u; + #endif + } + #endif + + if (0u != i) + { + pattern = (pattern >> i) | (pattern << (order - i)); /* rotate (adjust) the vector for the proper electrode position */ + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MPSC_ZERO_PIN_EN)) + if (0uL != (order % 2u)) + { + zeroPattern = (1uL << order) >> i; /* recalculate zero electrode position */ + } + #endif + } + + if (CY_CAPSENSE_MULTIPHASE_MAX_ORDER > order) + { + pattern &= (0x01uL << order) - 1u; /* cut the pattern to the vector/order size */ + } + + /* Loop through all involved MPSC electrodes */ + for (j = 0u; j < order; j++) + { + if (0u != (pattern & 0x01u)) /* Positive electrode */ + { + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMask |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + } + else /* Negative electrode */ + { + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMaskNegative |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + } + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MPSC_ZERO_PIN_EN)) + if (CY_CAPSENSE_CSD_GROUP == snsMethod) + { + if (0u != (zeroPattern & 0x01u)) + { + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMaskZero |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + } + } + #endif + + pattern >>= 0x01u; + eltdPinCfg++; + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MPSC_ZERO_PIN_EN)) + if (CY_CAPSENSE_CSD_GROUP == snsMethod) + { + if (0uL != (order % 2u)) + { + zeroPattern >>= 0x01u; + } + } + #endif + } + Cy_CapSense_CalculateMaskRegisters(snsMask, snsFuncState, ptrSensorCfgLoc); + Cy_CapSense_CalculateMaskRegisters(snsMaskNegative, snsFuncStateNegative, ptrSensorCfgLoc); + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MPSC_ZERO_PIN_EN)) + if (CY_CAPSENSE_CSD_GROUP == snsMethod) + { + if (0uL != (order % 2u)) + { + Cy_CapSense_CalculateMaskRegisters(snsMaskZero, snsFuncStateZero, ptrSensorCfgLoc); + } + } + #endif +} +#endif /* CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_ENABLED */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_GenerateAllSensorConfig +******************************************************************************** +* +* Generates configuration to configure registers to start +* a scan for all sensors of the specified Sensor Frame. +* +* \param snsFrameType +* The Sensor Frame type: +* * CY_CAPSENSE_SNS_FRAME_ACTIVE - Sensor frame for Active slot +* * CY_CAPSENSE_SNS_FRAME_LOW_POWER - Sensor frame for Low Power slot +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_GenerateAllSensorConfig( + uint32_t snsFrameType, + cy_stc_capsense_context_t * context) +{ + uint32_t scanSlotIndex; + const cy_stc_capsense_pin_config_t * ptrPinCfg = context->ptrPinConfig; + uint32_t * ptrSensorCfgLoc; + uint32_t sensorSlotNum; + uint8_t * ptrMapping = &context->ptrInternalContext->mapPinState[0u]; + uint32_t snsMethod; + uint32_t snsMaskInactive = 0u; + uint32_t snsFuncState; + uint32_t snsFuncStateSelfCap; + uint32_t snsFuncStateMutualCap; + uint32_t snsFuncStateInductive; + uint32_t wdIndex; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + + uint32_t i = 0u; + uint32_t snsMask = 0u; + uint32_t snsIndex; + cy_stc_capsense_electrode_config_t const * eltdPinCfg; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + ptrScanSlots = (snsFrameType == CY_CAPSENSE_SNS_FRAME_ACTIVE) ? (context->ptrScanSlots) : (context->ptrLpScanSlots); + #else + ptrScanSlots = context->ptrScanSlots; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + uint32_t snsMaskInactiveIsx = 0u; + uint32_t numEltd; + uint32_t eltdIndex; + #endif + + /* Create mask for all project electrodes */ + for (i = 0u; i < context->ptrCommonConfig->numPin; i++) + { + snsMask |= (0x01uL << ptrPinCfg->padNumber); + ptrPinCfg++; + } + + /* Add to mask all shield electrodes (if present) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + ptrPinCfg = context->ptrShieldPinConfig; + for (i = 0u; i < context->ptrCommonConfig->csdShieldNumPin; i++) + { + snsMask |= (0x01uL << ptrPinCfg->padNumber); + ptrPinCfg++; + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) */ + + snsMaskInactive = snsMask; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + /* Create separate inactive mask of ISX pins only */ + for (wdIndex = 0u; wdIndex < context->ptrCommonConfig->numWd; wdIndex++) + { + ptrWdCfg = &context->ptrWdConfig[wdIndex]; + snsMethod = ptrWdCfg->senseMethod; + + if(CY_CAPSENSE_ISX_GROUP == snsMethod) + { + numEltd = (uint32_t)ptrWdCfg->numRows + ptrWdCfg->numCols; + eltdPinCfg = ptrWdCfg->ptrEltdConfig; + + for (eltdIndex = 0u; eltdIndex < numEltd; eltdIndex++) + { + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMaskInactiveIsx |= (0x01uL << eltdPinCfg->ptrPin[i].padNumber); + } + eltdPinCfg++; + } + } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ + + /* Define inactive pin state for CSX scans */ + switch (context->ptrInternalContext->intrCsxInactSnsConn) + { + case CY_CAPSENSE_SNS_CONNECTION_HIGHZ: + snsFuncStateMutualCap = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z]; + break; + case CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2: + snsFuncStateMutualCap = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_VDDA2]; + break; + default: + snsFuncStateMutualCap = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_GND]; + break; + } + + /* Define inactive pin state for ISX scans */ + snsFuncStateInductive = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z]; + + /* Define inactive pin state for CSD scans */ + switch (context->ptrInternalContext->intrCsdInactSnsConn) + { + case CY_CAPSENSE_SNS_CONNECTION_HIGHZ: + snsFuncStateSelfCap = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z]; + break; + case CY_CAPSENSE_SNS_CONNECTION_SHIELD: + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_PASSIVE_EN) + snsFuncStateSelfCap = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_PAS_SHIELD]; + #else + snsFuncStateSelfCap = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_ACT_SHIELD]; + #endif + break; + default: + snsFuncStateSelfCap = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_GND]; + break; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if (CY_CAPSENSE_SNS_FRAME_LOW_POWER == snsFrameType) + { + sensorSlotNum = CY_CAPSENSE_SLOT_LP_COUNT; + ptrSensorCfgLoc = context->ptrSensorFrameLpContext; + ptrScanSlots = context->ptrLpScanSlots; + } + else + { + sensorSlotNum = CY_CAPSENSE_SLOT_COUNT; + ptrSensorCfgLoc = context->ptrSensorFrameContext; + ptrScanSlots = context->ptrScanSlots; + } + #else + sensorSlotNum = CY_CAPSENSE_SLOT_COUNT; + ptrSensorCfgLoc = context->ptrSensorFrameContext; + ptrScanSlots = context->ptrScanSlots; + #endif + + for (scanSlotIndex = 0u; scanSlotIndex < sensorSlotNum; scanSlotIndex++) + { + (void)Cy_CapSense_GenerateSensorConfig(snsFrameType, scanSlotIndex, ptrSensorCfgLoc, context); + + snsIndex = ptrScanSlots[scanSlotIndex].snsId; + wdIndex = ptrScanSlots[scanSlotIndex].wdId; + ptrWdCfg = &context->ptrWdConfig[wdIndex]; + snsMethod = ptrWdCfg->senseMethod; + + if (CY_CAPSENSE_CSD_GROUP == snsMethod) + { + snsFuncState = snsFuncStateSelfCap; + } + else if (CY_CAPSENSE_CSX_GROUP == snsMethod) + { + snsFuncState = snsFuncStateMutualCap; + } + else + { + snsFuncState = snsFuncStateInductive; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if (CY_CAPSENSE_SNS_FRAME_LOW_POWER == snsFrameType) + { + ptrSensorCfgLoc += (CY_MSCLP_11_SNS_REGS - CY_MSCLP_6_SNS_REGS); + } + #endif + + /* INACTIVE SENSORS */ + Cy_CapSense_CalculateMaskRegisters(snsMaskInactive, snsFuncState, ptrSensorCfgLoc); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + Cy_CapSense_CalculateMaskRegisters(snsMaskInactiveIsx, snsFuncStateInductive, ptrSensorCfgLoc); + #endif + + /* SHIELD ELECTRODE */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + if (0u < context->ptrCommonConfig->csdShieldNumPin) + { + snsMask = 0u; + + if (CY_CAPSENSE_CSD_GROUP == snsMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_PASSIVE_EN) + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_PAS_SHIELD]; + #else + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_ACT_SHIELD]; + #endif + } + + for (i = 0u; i < context->ptrCommonConfig->csdShieldNumPin; i++) + { + snsMask |= 0x01uL << context->ptrShieldPinConfig[i].padNumber; + } + Cy_CapSense_CalculateMaskRegisters(snsMask, snsFuncState, ptrSensorCfgLoc); + } + #endif + + /* ACTIVE SELF-CAP SENSOR */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + if (CY_CAPSENSE_CSD_GROUP == snsMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) && (snsIndex < ptrWdCfg->numCols)) || /* for cols */ + ((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrderRows) && (snsIndex >= ptrWdCfg->numCols))) /* for rows */ + { + Cy_CapSense_GenerateMultiphaseSensorConfig(snsFrameType, scanSlotIndex, ptrSensorCfgLoc, context); + } + else + { + snsMask = 0u; + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSD_SNS]; + eltdPinCfg = &ptrWdCfg->ptrEltdConfig[snsIndex]; + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMask |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + Cy_CapSense_CalculateMaskRegisters(snsMask, snsFuncState, ptrSensorCfgLoc); + } + #else + snsMask = 0u; + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSD_SNS]; + eltdPinCfg = &ptrWdCfg->ptrEltdConfig[snsIndex]; + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMask |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + Cy_CapSense_CalculateMaskRegisters(snsMask, snsFuncState, ptrSensorCfgLoc); + #endif /* CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED */ + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + + /* ACTIVE MUTUAL-CAP SENSOR */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + if (CY_CAPSENSE_CSX_GROUP == snsMethod) + { + /* RX ELECTRODE */ + snsMask = 0u; + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_RX]; + i = snsIndex / ptrWdCfg->numRows; + eltdPinCfg = &ptrWdCfg->ptrEltdConfig[i]; + + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMask |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + Cy_CapSense_CalculateMaskRegisters(snsMask, snsFuncState, ptrSensorCfgLoc); + + /* Handles multi-phase TX feature */ + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) + if (ptrWdCfg->mpOrder >= CY_CAPSENSE_MPTX_MIN_ORDER) + { + Cy_CapSense_GenerateMultiphaseSensorConfig(snsFrameType, scanSlotIndex, ptrSensorCfgLoc, context); + } + else + { + /* TX ELECTRODE */ + snsMask = 0u; + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_TX]; + i = ptrWdCfg->numCols + + (snsIndex % ptrWdCfg->numRows); + eltdPinCfg = &ptrWdCfg->ptrEltdConfig[i]; + + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMask |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + Cy_CapSense_CalculateMaskRegisters(snsMask, snsFuncState, ptrSensorCfgLoc); + } + #else + /* TX ELECTRODE */ + snsMask = 0u; + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_CSX_TX]; + i = ptrWdCfg->numCols + (snsIndex % ptrWdCfg->numRows); + eltdPinCfg = &ptrWdCfg->ptrEltdConfig[i]; + + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMask |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + Cy_CapSense_CalculateMaskRegisters(snsMask, snsFuncState, ptrSensorCfgLoc); + #endif + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + + /* ACTIVATE INDUCTIVE SENSOR */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + if (CY_CAPSENSE_ISX_GROUP == snsMethod) + { + /* RX ELECTRODE */ + snsMask = 0u; + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_ISX_RX]; + i = snsIndex; + eltdPinCfg = &ptrWdCfg->ptrEltdConfig[i]; + + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMask |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + Cy_CapSense_CalculateMaskRegisters(snsMask, snsFuncState, ptrSensorCfgLoc); + + /* LX ELECTRODE */ + snsMask = 0u; + snsFuncState = ptrMapping[CY_CAPSENSE_PIN_STATE_IDX_ISX_LX]; + i = snsIndex + ptrWdCfg->numRows; + eltdPinCfg = &ptrWdCfg->ptrEltdConfig[i]; + + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < eltdPinCfg->numPins; i++) + { + snsMask |= 0x01uL << eltdPinCfg->ptrPin[i].padNumber; + } + Cy_CapSense_CalculateMaskRegisters(snsMask, snsFuncState, ptrSensorCfgLoc); + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ + + ptrSensorCfgLoc += CY_MSCLP_6_SNS_REGS; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + if (CY_CAPSENSE_SNS_FRAME_LOW_POWER != snsFrameType) + { + ptrSensorCfgLoc++; + } + #endif + } +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_CalculateMaskRegisters +****************************************************************************//** +* +* Calculates the mask for pins that have to be updated for Control MUX +* connection. +* +* \param mask +* Specifies the mask of pins that should be updated. +* +* \param funcState +* Specifies the pin state functionality. +* +* \param ptrCfg +* Specifies the pointer to the mask registers. +* +*******************************************************************************/ +void Cy_CapSense_CalculateMaskRegisters( + uint32_t mask, + uint32_t funcState, + uint32_t * ptrCfg) +{ + uint32_t * ptrCfgMask = ptrCfg; + + ptrCfgMask[0u] &= ~mask; + ptrCfgMask[1u] &= ~mask; + ptrCfgMask[2u] &= ~mask; + if (0u != (funcState & 0x04u)) + { + ptrCfgMask[0u] |= mask; + } + if (0u != (funcState & 0x02u)) + { + ptrCfgMask[1u] |= mask; + } + if (0u != (funcState & 0x01u)) + { + ptrCfgMask[2u] |= mask; + } +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GenerateCdacConfig +****************************************************************************//** +* +* Generates the Cap DAC configuration for a selected sensor. +* +* \param ptrScanSlot +* The pointer to the slot structure \ref cy_stc_capsense_scan_slot_t. +* +* \param ptrSensorCfg +* Specifies the pointer to the sensor configuration to be filled. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_GenerateCdacConfig( + const cy_stc_capsense_scan_slot_t * ptrScanSlot, + uint32_t * ptrSensorCfg, + const cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + uint32_t compDiv; + uint32_t wdIndex = ptrScanSlot->wdId; + uint32_t snsIndex = ptrScanSlot->snsId; + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[wdIndex]; + uint32_t snsCdacCtlReg = MSCLP_SNS_SNS_CDAC_CTL_CLOCK_REF_RATE_Msk; + uint8_t senseMethod = ptrWdCfg->senseMethod; + cy_stc_capsense_internal_context_t * ptrIntCxt = context->ptrInternalContext; + + /* Compensation CDAC Divider */ + compDiv = context->ptrWdContext[wdIndex].cdacCompDivider; + compDiv = (compDiv > 0u) ? (compDiv - 1u) : 0u; + ptrSensorCfg[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] |= _VAL2FLD(MSCLP_SNS_SNS_SCAN_CTL_COMP_DIV, compDiv); + + if (((CY_CAPSENSE_CSD_GROUP == senseMethod) && (CY_CAPSENSE_ENABLE == ptrIntCxt->csdCdacDitherEn)) || + ((CY_CAPSENSE_CSX_GROUP == senseMethod) && (CY_CAPSENSE_ENABLE == ptrIntCxt->csxCdacDitherEn)) || + ((CY_CAPSENSE_ISX_GROUP == senseMethod) && (CY_CAPSENSE_ENABLE == ptrIntCxt->isxCdacDitherEn))) + { + snsCdacCtlReg |= _VAL2FLD(MSCLP_SNS_SNS_CDAC_CTL_LFSR_SCALE_FL, ptrWdCfg->ptrWdContext->cdacDitherValue) | + _VAL2FLD(MSCLP_SNS_SNS_CDAC_CTL_FL_MODE, 1uL); /* the same as it was for msc */ + } + + if (0u == (CY_CAPSENSE_MW_STATE_CALIBRATION_SINGLE_MASK & context->ptrCommonContext->status)) + { + /* Ref CDAC Code setup */ + if ((CY_CAPSENSE_CSD_GROUP == senseMethod) && + (ptrWdCfg->numCols <= snsIndex)) + { + snsCdacCtlReg |= _VAL2FLD(MSCLP_SNS_SNS_CDAC_CTL_SEL_RE, ptrWdCfg->ptrWdContext->rowCdacRef); + } + else + { + snsCdacCtlReg |= _VAL2FLD(MSCLP_SNS_SNS_CDAC_CTL_SEL_RE, ptrWdCfg->ptrWdContext->cdacRef); + } + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_FINE_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_FINE_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_FINE_EN)) + /* Ref CDAC Code setup */ + if ((CY_CAPSENSE_CSD_GROUP == senseMethod) && + (ptrWdCfg->numCols <= snsIndex)) + { + snsCdacCtlReg |= _VAL2FLD(MSCLP_SNS_SNS_CDAC_CTL_SEL_CF, ptrWdCfg->ptrWdContext->rowCdacFine); + } + else + { + snsCdacCtlReg |= _VAL2FLD(MSCLP_SNS_SNS_CDAC_CTL_SEL_CF, ptrWdCfg->ptrWdContext->cdacFine); + } + #endif + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_COMP_EN)) + switch (senseMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN) + case CY_CAPSENSE_CSD_GROUP : + #endif /* CY_CAPSENSE_CSD_CDAC_COMP_EN */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN) + case CY_CAPSENSE_CSX_GROUP : + #endif /* CY_CAPSENSE_CSX_CDAC_COMP_EN */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_COMP_EN) + case CY_CAPSENSE_ISX_GROUP : + #endif /* CY_CAPSENSE_ISX_CDAC_COMP_EN */ + snsCdacCtlReg |= _VAL2FLD(MSCLP_SNS_SNS_CDAC_CTL_SEL_CO, ptrWdCfg->ptrSnsContext[snsIndex].cdacComp); + break; + default: + /* No action for other methods */ + break; + } + #endif + } + + ptrSensorCfg[CY_CAPSENSE_SNS_CDAC_CTL_INDEX] = snsCdacCtlReg; + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GenerateModeConfig +****************************************************************************//** +* +* Configures mode-related registers in base configuration per defined +* CapSense configuration. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_GenerateModeConfig(const cy_stc_capsense_context_t * context) +{ + const cy_stc_msclp_mode_config_t modeArr[CY_CAPSENSE_REG_MODE_NUMBER] = CY_CAPSENSE_SM_MODES_ARR; + cy_stc_msclp_mode_config_t * mode = context->ptrBaseFrameContext->mode; + + mode[CY_CAPSENSE_REG_MODE_CSD] = modeArr[CY_CAPSENSE_REG_MODE_CSD]; + mode[CY_CAPSENSE_REG_MODE_CSX] = modeArr[CY_CAPSENSE_REG_MODE_CSX]; + mode[CY_CAPSENSE_REG_MODE_ISX] = modeArr[CY_CAPSENSE_REG_MODE_ISX]; + + if (CY_CAPSENSE_ENABLE == context->ptrInternalContext->csdCdacDitherEn) + { + mode[CY_CAPSENSE_REG_MODE_CSD] = modeArr[CY_CAPSENSE_MODE_IDX_CSD_DITHERING]; + } + + if (CY_CAPSENSE_ENABLE == context->ptrInternalContext->csxCdacDitherEn) + { + mode[CY_CAPSENSE_REG_MODE_CSX] = modeArr[CY_CAPSENSE_MODE_IDX_CSX_DITHERING]; + } + + if (CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 == context->ptrInternalContext->intrCsxInactSnsConn) + { + /* Close the reference to filter switch */ + mode[CY_CAPSENSE_REG_MODE_CSX].swSelSh |= MSCLP_MODE_SW_SEL_SH_SOMB_Msk; + } + + if (CY_CAPSENSE_ENABLE == context->ptrInternalContext->isxCdacDitherEn) + { + mode[CY_CAPSENSE_REG_MODE_ISX] = modeArr[CY_CAPSENSE_MODE_IDX_ISX_DITHERING]; + } +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_AdjustSnsClkDivider +****************************************************************************//** +* +* If the PRS is selected as the Sense Clock source, adjusts the Sense Clock +* divider to obtain the max frequency of the PRS sequence equal to +* ModClkFreq / SenseClkDivider. Updates the sense Clock divider with the minimal +* supported value in case if it is out of range for the specified parameters. +* +* \param snsMethod +* Specifies the widget group: +* - CSD (CY_CAPSENSE_CSD_GROUP) +* - CSX (CY_CAPSENSE_CSX_GROUP) +* - ISX (CY_CAPSENSE_ISX_GROUP) +* +* \param snsClkSource +* Specifies the sense Clock source, supported by MSCv3 HW: +* - CY_CAPSENSE_CLK_SOURCE_DIRECT +* - CY_CAPSENSE_CLK_SOURCE_SSC +* - CY_CAPSENSE_CLK_SOURCE_PRS +* +* \param snsClkDivider +* The divider value for the sense clock. +* +* \return +* Adjusted value of the Sense Clock divider. +* +*******************************************************************************/ +uint32_t Cy_CapSense_AdjustSnsClkDivider( + uint8_t snsMethod, + uint8_t snsClkSource, + uint16_t snsClkDivider) +{ + uint32_t retVal = (uint32_t)snsClkDivider; + + if (CY_CAPSENSE_CLK_SOURCE_PRS == ((uint32_t)snsClkSource & CY_CAPSENSE_CLK_SOURCE_MASK)) + { + if ((CY_CAPSENSE_CSD_GROUP == snsMethod) || + (CY_CAPSENSE_ISX_GROUP == snsMethod)) + { + retVal >>= CY_CAPSENSE_4PH_PRS_SNS_CLOCK_DIVIDER_SHIFT; + } + else + { + retVal >>= CY_CAPSENSE_2PH_PRS_SNS_CLOCK_DIVIDER_SHIFT; + } + } + + return retVal; +} + + +#endif /* CY_IP_M0S8MSCV3LP */ + + +/* [] END OF FILE */ diff --git a/cy_capsense_generator_lp.h b/cy_capsense_generator_lp.h new file mode 100644 index 0000000..a6ad1bc --- /dev/null +++ b/cy_capsense_generator_lp.h @@ -0,0 +1,1315 @@ +/***************************************************************************//** +* \file cy_capsense_generator_lp.h +* \version 4.0 +* +* \brief +* This file provides the function prototypes specific to the register +* map generation module. +* +******************************************************************************** +* \copyright +* Copyright 2020-2023, Cypress Semiconductor Corporation (an Infineon company) +* or an affiliate of Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +*******************************************************************************/ + + +#if !defined(CY_CAPSENSE_GENERATOR_LP_H) +#define CY_CAPSENSE_GENERATOR_LP_H + +#include "cy_capsense_common.h" +#include "cy_capsense_structure.h" +#include "cy_capsense_sm_base_full_wave_lp.h" + +#if (defined(CY_IP_M0S8MSCV3LP)) + +#if defined(__cplusplus) +extern "C" { +#endif + +/******************************************************************************* +* Function Prototypes +*******************************************************************************/ + +/******************************************************************************/ +/** \cond SECTION_CAPSENSE_INTERNAL */ +/** \addtogroup group_capsense_internal *//** \{ */ +/******************************************************************************/ +cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_GeneratePinFunctionConfig( + const cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_GenerateSensorConfig( + uint32_t snsFrameType, + uint32_t scanSlot, + uint32_t * ptrSensorCfg, + cy_stc_capsense_context_t * context); +void Cy_CapSense_GenerateAllSensorConfig( + uint32_t snsFrameType, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_GenerateCdacConfig( + const cy_stc_capsense_scan_slot_t * ptrScanSlot, + uint32_t * ptrSensorCfg, + const cy_stc_capsense_context_t * context); +void Cy_CapSense_CalculateMaskRegisters( + uint32_t mask, + uint32_t funcState, + uint32_t * ptrCfg); +uint32_t Cy_CapSense_AdjustSnsClkDivider( + uint8_t snsMethod, + uint8_t snsClkSource, + uint16_t snsClkDivider); +/** \} \endcond */ + + +/******************************************************************************* +* Sensing modes +*******************************************************************************/ +/** CSD sense mode configuration index */ +#define CY_CAPSENSE_REG_MODE_CSD (0u) +/** CSX sense mode configuration index */ +#define CY_CAPSENSE_REG_MODE_CSX (1u) +/** ISX sense mode configuration index */ +#define CY_CAPSENSE_REG_MODE_ISX (2u) +/** CSD sense mode configuration index with CapDAC dithering enabled */ +#define CY_CAPSENSE_MODE_IDX_CSD_DITHERING (3u) +/** CSX sense mode configuration index with CapDAC dithering enabled */ +#define CY_CAPSENSE_MODE_IDX_CSX_DITHERING (4u) +/** ISX sense mode configuration index with CapDAC dithering enabled */ +#define CY_CAPSENSE_MODE_IDX_ISX_DITHERING (5u) + + +/******************************************************************************* +* Sensor Config Register indexes in the frame +*******************************************************************************/ +#define CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL0 (0u) +#define CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL1 (1u) +#define CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL2 (2u) +#define CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL3 (3u) +#define CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL4 (4u) +#define CY_CAPSENSE_FRM_LP_SNS_SW_SEL_CSW_LO_MASK2_INDEX (5u) +#define CY_CAPSENSE_FRM_LP_SNS_SW_SEL_CSW_LO_MASK1_INDEX (6u) +#define CY_CAPSENSE_FRM_LP_SNS_SW_SEL_CSW_LO_MASK0_INDEX (7u) +#define CY_CAPSENSE_FRM_LP_SNS_SCAN_CTL_INDEX (8u) +#define CY_CAPSENSE_FRM_LP_SNS_CDAC_CTL_INDEX (9u) +#define CY_CAPSENSE_FRM_LP_SNS_CTL_INDEX (10u) + +#define CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK2_INDEX (0u) +#define CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK1_INDEX (1u) +#define CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK0_INDEX (2u) +#define CY_CAPSENSE_SNS_SCAN_CTL_INDEX (3u) +#define CY_CAPSENSE_SNS_CDAC_CTL_INDEX (4u) +#define CY_CAPSENSE_SNS_CTL_INDEX (5u) +#define CY_CAPSENSE_SNS_HW_IIR_INDEX (6u) + + +/******************************************************************************* +* Macros for Cmod selection +*******************************************************************************/ +#define CY_CAPSENSE_CMOD12_PAIR_SELECTION (0uL) + + +/* CSW0 = GND */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW0_GND_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW1 = HIGH-Z */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW1_HIGH_Z_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW2 = CSX RX */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW2_CSX_RX_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW3 = CSX TX */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW3_CSX_TX_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW4 = CSX NTX */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW4_CSX_NEG_TX_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW5 = CSD SNS */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW5_CSD_SNS_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW6 = ISX LX */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW6_ISX_LX_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW7 = ISX RX */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW7_ISX_RX_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW8 = SHIELD Active */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW8_ACT_SHLD_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW9 = SHIELD Passive */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW9_PAS_SHLD_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW10 = VDDA/2 */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW10_VDDA2_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW11 = CSP */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW11_CSP_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW12 = CSN */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW12_CSN_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + +/* CSW13 = CSZ */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW13_CSZ_VALUE \ +((CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_SW_AMUXA << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_SW_AMUXB << MSCLP_SW_SEL_CSW_FUNC_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_SW_PU << MSCLP_SW_SEL_CSW_FUNC_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_SW_PD << MSCLP_SW_SEL_CSW_FUNC_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_REF_MODE << MSCLP_SW_SEL_CSW_FUNC_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_DDRV_EN << MSCLP_SW_SEL_CSW_FUNC_DDRV_EN_Pos)) + + +/* Indexes of this values must correspond to the CY_CAPSENSE_CTRLMUX_PIN_STATE_... definitions in the common.h */ +#define CY_CAPSENSE_PIN_STATES_ARR \ +{CY_CAPSENSE_SM_REG_SW_SEL_CSW0_GND_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW1_HIGH_Z_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW2_CSX_RX_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW3_CSX_TX_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW4_CSX_NEG_TX_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW5_CSD_SNS_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW6_ISX_LX_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW7_ISX_RX_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW8_ACT_SHLD_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW9_PAS_SHLD_VALUE,\ + CY_CAPSENSE_SM_REG_SW_SEL_CSW10_VDDA2_VALUE, \ + CY_CAPSENSE_SM_REG_SW_SEL_CSW11_CSP_VALUE, \ + CY_CAPSENSE_SM_REG_SW_SEL_CSW12_CSN_VALUE, \ + CY_CAPSENSE_SM_REG_SW_SEL_CSW13_CSZ_VALUE} + + +/************************* CSD RM register values *****************************/ + +#define CY_CAPSENSE_CSD_RM_SENSE_DUTY_CTL \ +((CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH2_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH3_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PH_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHX_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_SHIFT_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_MODE_SEL_Pos)) + +#define CY_CAPSENSE_CSD_RM_SW_SEL_CDAC_FL \ +((CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTCA << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLCB << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE << MSCLP_MODE_SW_SEL_CDAC_FL_ACTIVATION_MODE_Pos)) + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_ACTIVE_EN) +#define CY_CAPSENSE_CSD_RM_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_CSD_RM_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) +#elif (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_PASSIVE_EN) +#define CY_CAPSENSE_CSD_RM_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_CSD_RM_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) +#else +#define CY_CAPSENSE_CSD_RM_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_CSD_RM_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) +#endif /* CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_ACTIVE_EN */ + +#define CY_CAPSENSE_CSD_RM_SW_SEL_COMP \ +((CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPCS1 << MSCLP_MODE_SW_SEL_COMP_CPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPCS3 << MSCLP_MODE_SW_SEL_COMP_CPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPCA << MSCLP_MODE_SW_SEL_COMP_CPCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPCB << MSCLP_MODE_SW_SEL_COMP_CPCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMCB << MSCLP_MODE_SW_SEL_COMP_CMCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPF << MSCLP_MODE_SW_SEL_COMP_CPF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMCS2 << MSCLP_MODE_SW_SEL_COMP_CMCS2_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMCS4 << MSCLP_MODE_SW_SEL_COMP_CMCS4_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMV << MSCLP_MODE_SW_SEL_COMP_CMV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMG << MSCLP_MODE_SW_SEL_COMP_CMG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_HALF_WAVE_EN << MSCLP_MODE_SW_SEL_COMP_HALF_WAVE_EN_Pos)) + +#define CY_CAPSENSE_CSD_RM_SW_SEL_CMOD1 \ +((CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_C1CA << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_C1CC << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD1_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD1_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD1_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD1_DDRV_EN_Pos)) + +#define CY_CAPSENSE_CSD_RM_SW_SEL_CMOD2 \ +((CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_C2CB << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_C2CD << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD2_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD2_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD2_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD2_DDRV_EN_Pos)) + +/************************* CSX RM register values *****************************/ + +#define CY_CAPSENSE_CSX_RM_SENSE_DUTY_CTL \ +((CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH2_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH3_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PH_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHX_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_SHIFT_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_MODE_SEL_Pos)) + +#define CY_CAPSENSE_CSX_RM_SW_SEL_CDAC_FL \ +((CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLTCA << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLCB << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLTV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLTG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLBV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLBG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE << MSCLP_MODE_SW_SEL_CDAC_FL_ACTIVATION_MODE_Pos)) + +#define CY_CAPSENSE_CSX_RM_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_CSX_RM_SW_SEL_COMP \ +((CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPCS1 << MSCLP_MODE_SW_SEL_COMP_CPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPCS3 << MSCLP_MODE_SW_SEL_COMP_CPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPCA << MSCLP_MODE_SW_SEL_COMP_CPCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPCB << MSCLP_MODE_SW_SEL_COMP_CPCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMCB << MSCLP_MODE_SW_SEL_COMP_CMCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPF << MSCLP_MODE_SW_SEL_COMP_CPF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMCS2 << MSCLP_MODE_SW_SEL_COMP_CMCS2_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMCS4 << MSCLP_MODE_SW_SEL_COMP_CMCS4_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMV << MSCLP_MODE_SW_SEL_COMP_CMV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMG << MSCLP_MODE_SW_SEL_COMP_CMG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_HALF_WAVE_EN << MSCLP_MODE_SW_SEL_COMP_HALF_WAVE_EN_Pos)) + +#define CY_CAPSENSE_CSX_RM_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) + +#define CY_CAPSENSE_CSX_RM_SW_SEL_CMOD1 \ +((CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_C1CA << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_C1CC << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD1_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD1_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD1_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD1_DDRV_EN_Pos)) + +#define CY_CAPSENSE_CSX_RM_SW_SEL_CMOD2 \ +((CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_C2CB << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_C2CD << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD2_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD2_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD2_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD2_DDRV_EN_Pos)) + +/************************* ISX RM register values *****************************/ + +#define CY_CAPSENSE_ISX_RM_SENSE_DUTY_CTL \ +((CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH2_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH3_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PH_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHX_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_SHIFT_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_MODE_SEL_Pos)) + +#define CY_CAPSENSE_ISX_RM_SW_SEL_CDAC_FL \ +((CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLTCA << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLCB << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLTV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLTG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLBV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLBG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE << MSCLP_MODE_SW_SEL_CDAC_FL_ACTIVATION_MODE_Pos)) + +#define CY_CAPSENSE_ISX_RM_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_ISX_RM_SW_SEL_COMP \ +((CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPCS1 << MSCLP_MODE_SW_SEL_COMP_CPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPCS3 << MSCLP_MODE_SW_SEL_COMP_CPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPCA << MSCLP_MODE_SW_SEL_COMP_CPCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPCB << MSCLP_MODE_SW_SEL_COMP_CPCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMCB << MSCLP_MODE_SW_SEL_COMP_CMCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPF << MSCLP_MODE_SW_SEL_COMP_CPF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMCS2 << MSCLP_MODE_SW_SEL_COMP_CMCS2_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMCS4 << MSCLP_MODE_SW_SEL_COMP_CMCS4_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMV << MSCLP_MODE_SW_SEL_COMP_CMV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMG << MSCLP_MODE_SW_SEL_COMP_CMG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_HALF_WAVE_EN << MSCLP_MODE_SW_SEL_COMP_HALF_WAVE_EN_Pos)) + +#define CY_CAPSENSE_ISX_RM_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) + +#define CY_CAPSENSE_ISX_RM_SW_SEL_CMOD1 \ +((CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_C1CA << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_C1CC << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD1_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD1_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD1_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD1_DDRV_EN_Pos)) + +#define CY_CAPSENSE_ISX_RM_SW_SEL_CMOD2 \ +((CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_C2CB << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_C2CD << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD2_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD2_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD2_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD2_DDRV_EN_Pos)) + +/****************** CSD RM with CapDAC dithering register values *********************/ + +#define CY_CAPSENSE_CSD_RM_DITHER_SENSE_DUTY_CTL \ +((CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH2_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH3_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PH_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHX_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_SHIFT_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_MODE_SEL_Pos)) + +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_CDAC_FL \ +((CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLTCA << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLCB << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLTV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLTG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLBV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLBG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE << MSCLP_MODE_SW_SEL_CDAC_FL_ACTIVATION_MODE_Pos)) + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_ACTIVE_EN) +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) +#elif (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_PASSIVE_EN) +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) +#else +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) +#endif /* CY_CAPSENSE_ENABLE == CY_CAPSENSE_SHIELD_ACTIVE_EN */ + +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_COMP \ +((CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPCS1 << MSCLP_MODE_SW_SEL_COMP_CPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPCS3 << MSCLP_MODE_SW_SEL_COMP_CPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPCA << MSCLP_MODE_SW_SEL_COMP_CPCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPCB << MSCLP_MODE_SW_SEL_COMP_CPCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMCB << MSCLP_MODE_SW_SEL_COMP_CMCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPF << MSCLP_MODE_SW_SEL_COMP_CPF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMCS2 << MSCLP_MODE_SW_SEL_COMP_CMCS2_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMCS4 << MSCLP_MODE_SW_SEL_COMP_CMCS4_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMV << MSCLP_MODE_SW_SEL_COMP_CMV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMG << MSCLP_MODE_SW_SEL_COMP_CMG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_HALF_WAVE_EN << MSCLP_MODE_SW_SEL_COMP_HALF_WAVE_EN_Pos)) + +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_CMOD1 \ +((CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_C1CA << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_C1CC << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD1_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD1_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD1_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD1_DDRV_EN_Pos)) + +#define CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_CMOD2 \ +((CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_C2CB << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_C2CD << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD2_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD2_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD2_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD2_DDRV_EN_Pos)) + +/****************** CSX RM with CapDAC dithering register values *********************/ + +#define CY_CAPSENSE_CSX_RM_DITHER_SENSE_DUTY_CTL \ +((CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH2_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH3_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PH_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHX_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_SHIFT_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_MODE_SEL_Pos)) + +#define CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_CDAC_FL \ +((CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLTCA << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLCB << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLTV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLTG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLBV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLBG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE << MSCLP_MODE_SW_SEL_CDAC_FL_ACTIVATION_MODE_Pos)) + +#define CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_COMP \ +((CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPCS1 << MSCLP_MODE_SW_SEL_COMP_CPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPCS3 << MSCLP_MODE_SW_SEL_COMP_CPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPCA << MSCLP_MODE_SW_SEL_COMP_CPCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPCB << MSCLP_MODE_SW_SEL_COMP_CPCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMCB << MSCLP_MODE_SW_SEL_COMP_CMCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPF << MSCLP_MODE_SW_SEL_COMP_CPF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMCS2 << MSCLP_MODE_SW_SEL_COMP_CMCS2_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMCS4 << MSCLP_MODE_SW_SEL_COMP_CMCS4_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMV << MSCLP_MODE_SW_SEL_COMP_CMV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMG << MSCLP_MODE_SW_SEL_COMP_CMG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_HALF_WAVE_EN << MSCLP_MODE_SW_SEL_COMP_HALF_WAVE_EN_Pos)) + +#define CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) + +#define CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_CMOD1 \ +((CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_C1CA << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_C1CC << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD1_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD1_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD1_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD1_DDRV_EN_Pos)) + +#define CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_CMOD2 \ +((CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_C2CB << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_C2CD << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD2_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD2_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD2_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD2_DDRV_EN_Pos)) + +/****************** ISX RM with CapDAC dithering register values *********************/ + +#define CY_CAPSENSE_ISX_RM_DITHER_SENSE_DUTY_CTL \ +((CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH2_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH3_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PH_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHX_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_SHIFT_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_MODE_SEL_Pos)) + +#define CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_CDAC_FL \ +((CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLTCA << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLCB << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLTV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLTG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLBV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLBG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE << MSCLP_MODE_SW_SEL_CDAC_FL_ACTIVATION_MODE_Pos)) + +#define CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_TOP \ +((CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_COMP \ +((CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPCS1 << MSCLP_MODE_SW_SEL_COMP_CPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPCS3 << MSCLP_MODE_SW_SEL_COMP_CPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPCA << MSCLP_MODE_SW_SEL_COMP_CPCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPCB << MSCLP_MODE_SW_SEL_COMP_CPCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMCB << MSCLP_MODE_SW_SEL_COMP_CMCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPF << MSCLP_MODE_SW_SEL_COMP_CPF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMCS2 << MSCLP_MODE_SW_SEL_COMP_CMCS2_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMCS4 << MSCLP_MODE_SW_SEL_COMP_CMCS4_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMV << MSCLP_MODE_SW_SEL_COMP_CMV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMG << MSCLP_MODE_SW_SEL_COMP_CMG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_HALF_WAVE_EN << MSCLP_MODE_SW_SEL_COMP_HALF_WAVE_EN_Pos)) + +#define CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_SH \ +((CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) + +#define CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_CMOD1 \ +((CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_C1CA << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_C1CC << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD1_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD1_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD1_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD1_DDRV_EN_Pos)) + +#define CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_CMOD2 \ +((CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_C2CB << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_C2CD << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD2_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD2_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD2_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD2_DDRV_EN_Pos)) + +/************************* MPSC RM register values *****************************/ + +#define CY_CAPSENSE_MPSC_RM_SENSE_DUTY_CTL \ + ((CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH2_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH3_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PH_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHX_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_SHIFT_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_MODE_SEL_Pos)) + +#define CY_CAPSENSE_MPSC_RM_SW_SEL_CDAC_FL \ + ((CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLTCA << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLCB << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLTV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLTG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLBV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLBG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE << MSCLP_MODE_SW_SEL_CDAC_FL_ACTIVATION_MODE_Pos)) + +#define CY_CAPSENSE_MPSC_RM_SW_SEL_TOP \ + ((CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_MPSC_RM_SW_SEL_COMP \ + ((CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPCS1 << MSCLP_MODE_SW_SEL_COMP_CPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPCS3 << MSCLP_MODE_SW_SEL_COMP_CPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPCA << MSCLP_MODE_SW_SEL_COMP_CPCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPCB << MSCLP_MODE_SW_SEL_COMP_CPCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMCB << MSCLP_MODE_SW_SEL_COMP_CMCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPF << MSCLP_MODE_SW_SEL_COMP_CPF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMCS2 << MSCLP_MODE_SW_SEL_COMP_CMCS2_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMCS4 << MSCLP_MODE_SW_SEL_COMP_CMCS4_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMV << MSCLP_MODE_SW_SEL_COMP_CMV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMG << MSCLP_MODE_SW_SEL_COMP_CMG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_HALF_WAVE_EN << MSCLP_MODE_SW_SEL_COMP_HALF_WAVE_EN_Pos)) + +#define CY_CAPSENSE_MPSC_RM_SW_SEL_SH \ + ((CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) + +#define CY_CAPSENSE_MPSC_RM_SW_SEL_CMOD1 \ + ((CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_C1CA << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_C1CC << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD1_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD1_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD1_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD1_DDRV_EN_Pos)) + +#define CY_CAPSENSE_MPSC_RM_SW_SEL_CMOD2 \ + ((CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_C2CB << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_C2CD << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD2_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD2_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD2_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD2_DDRV_EN_Pos)) + +/************************* MPSC RM with CapDAC dithering register values *****************************/ + +#define CY_CAPSENSE_MPSC_RM_DITHER_SENSE_DUTY_CTL \ + ((CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH2_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH3_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH0_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH1_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PH_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH0X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_GAP_PH1X_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHX_GAP_2CYCLE_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_SHIFT_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL << MSCLP_MODE_SENSE_DUTY_CTL_PHASE_MODE_SEL_Pos)) + +#define CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_CDAC_FL \ + ((CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLTCA << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLCB << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLTV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLTG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLTG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLBV << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLBG << MSCLP_MODE_SW_SEL_CDAC_FL_SW_FLBG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE << MSCLP_MODE_SW_SEL_CDAC_FL_ACTIVATION_MODE_Pos)) + +#define CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_TOP \ + ((CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_CACB << MSCLP_MODE_SW_SEL_TOP_CACB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_AYB_CTL << MSCLP_MODE_SW_SEL_TOP_AYB_CTL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_AYB_EN << MSCLP_MODE_SW_SEL_TOP_AYB_EN_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_BYB << MSCLP_MODE_SW_SEL_TOP_BYB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_BGRF << MSCLP_MODE_SW_SEL_TOP_BGRF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_MBF << MSCLP_MODE_SW_SEL_TOP_MBF_Pos)) + +#define CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_COMP \ + ((CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPCS1 << MSCLP_MODE_SW_SEL_COMP_CPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPCS3 << MSCLP_MODE_SW_SEL_COMP_CPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPCA << MSCLP_MODE_SW_SEL_COMP_CPCA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPCB << MSCLP_MODE_SW_SEL_COMP_CPCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMCB << MSCLP_MODE_SW_SEL_COMP_CMCB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPF << MSCLP_MODE_SW_SEL_COMP_CPF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMCS2 << MSCLP_MODE_SW_SEL_COMP_CMCS2_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMCS4 << MSCLP_MODE_SW_SEL_COMP_CMCS4_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMV << MSCLP_MODE_SW_SEL_COMP_CMV_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMG << MSCLP_MODE_SW_SEL_COMP_CMG_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_HALF_WAVE_EN << MSCLP_MODE_SW_SEL_COMP_HALF_WAVE_EN_Pos)) + +#define CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_SH \ + ((CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_SOMB << MSCLP_MODE_SW_SEL_SH_SOMB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_SPCS1 << MSCLP_MODE_SW_SEL_SH_SPCS1_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_SPCS3 << MSCLP_MODE_SW_SEL_SH_SPCS3_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)) + +#define CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_CMOD1 \ + ((CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_C1CA << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_C1CC << MSCLP_MODE_SW_SEL_CMOD1_SW_C1CC_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD1_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD1_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD1_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD1_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD1_DDRV_EN_Pos)) + +#define CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_CMOD2 \ + ((CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_AMUXA << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXA_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_AMUXB << MSCLP_MODE_SW_SEL_CMOD2_SW_AMUXB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_C2CB << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CB_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_C2CD << MSCLP_MODE_SW_SEL_CMOD2_SW_C2CD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_PU << MSCLP_MODE_SW_SEL_CMOD2_SW_PU_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_PD << MSCLP_MODE_SW_SEL_CMOD2_SW_PD_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_REF_MODE << MSCLP_MODE_SW_SEL_CMOD2_REF_MODE_Pos) | \ + (CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_DDRV_EN << MSCLP_MODE_SW_SEL_CMOD2_DDRV_EN_Pos)) + + +#define CY_CAPSENSE_CSD_RM_MODE \ + { \ + .senseDutyCtl = CY_CAPSENSE_CSD_RM_SENSE_DUTY_CTL,\ + .swSelCdacFl = CY_CAPSENSE_CSD_RM_SW_SEL_CDAC_FL,\ + .swSelTop = CY_CAPSENSE_CSD_RM_SW_SEL_TOP, \ + .swSelComp = CY_CAPSENSE_CSD_RM_SW_SEL_COMP, \ + .swSelSh = CY_CAPSENSE_CSD_RM_SW_SEL_SH, \ + .swSelCmod1 = CY_CAPSENSE_CSD_RM_SW_SEL_CMOD1, \ + .swSelCmod2 = CY_CAPSENSE_CSD_RM_SW_SEL_CMOD2, \ + } + +#define CY_CAPSENSE_CSX_RM_MODE \ + { \ + .senseDutyCtl = CY_CAPSENSE_CSX_RM_SENSE_DUTY_CTL,\ + .swSelCdacFl = CY_CAPSENSE_CSX_RM_SW_SEL_CDAC_FL,\ + .swSelTop = CY_CAPSENSE_CSX_RM_SW_SEL_TOP, \ + .swSelComp = CY_CAPSENSE_CSX_RM_SW_SEL_COMP, \ + .swSelSh = CY_CAPSENSE_CSX_RM_SW_SEL_SH, \ + .swSelCmod1 = CY_CAPSENSE_CSX_RM_SW_SEL_CMOD1, \ + .swSelCmod2 = CY_CAPSENSE_CSX_RM_SW_SEL_CMOD2, \ + } + +#define CY_CAPSENSE_ISX_RM_MODE \ + { \ + .senseDutyCtl = CY_CAPSENSE_ISX_RM_SENSE_DUTY_CTL,\ + .swSelCdacFl = CY_CAPSENSE_ISX_RM_SW_SEL_CDAC_FL,\ + .swSelTop = CY_CAPSENSE_ISX_RM_SW_SEL_TOP, \ + .swSelComp = CY_CAPSENSE_ISX_RM_SW_SEL_COMP, \ + .swSelSh = CY_CAPSENSE_ISX_RM_SW_SEL_SH, \ + .swSelCmod1 = CY_CAPSENSE_ISX_RM_SW_SEL_CMOD1, \ + .swSelCmod2 = CY_CAPSENSE_ISX_RM_SW_SEL_CMOD2, \ + } + +#define CY_CAPSENSE_MPSC_RM_MODE \ + { \ + .senseDutyCtl = CY_CAPSENSE_MPSC_RM_SENSE_DUTY_CTL,\ + .swSelCdacFl = CY_CAPSENSE_MPSC_RM_SW_SEL_CDAC_FL,\ + .swSelTop = CY_CAPSENSE_MPSC_RM_SW_SEL_TOP, \ + .swSelComp = CY_CAPSENSE_MPSC_RM_SW_SEL_COMP, \ + .swSelSh = CY_CAPSENSE_MPSC_RM_SW_SEL_SH, \ + .swSelCmod1 = CY_CAPSENSE_MPSC_RM_SW_SEL_CMOD1, \ + .swSelCmod2 = CY_CAPSENSE_MPSC_RM_SW_SEL_CMOD2, \ + } + +#define CY_CAPSENSE_CSD_RM_DITHER_MODE \ + { \ + .senseDutyCtl = CY_CAPSENSE_CSD_RM_DITHER_SENSE_DUTY_CTL,\ + .swSelCdacFl = CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_CDAC_FL,\ + .swSelTop = CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_TOP, \ + .swSelComp = CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_COMP, \ + .swSelSh = CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_SH, \ + .swSelCmod1 = CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_CMOD1, \ + .swSelCmod2 = CY_CAPSENSE_CSD_RM_DITHER_SW_SEL_CMOD2, \ + } + +#define CY_CAPSENSE_CSX_RM_DITHER_MODE \ + { \ + .senseDutyCtl = CY_CAPSENSE_CSX_RM_DITHER_SENSE_DUTY_CTL,\ + .swSelCdacFl = CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_CDAC_FL,\ + .swSelTop = CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_TOP, \ + .swSelComp = CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_COMP, \ + .swSelSh = CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_SH, \ + .swSelCmod1 = CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_CMOD1, \ + .swSelCmod2 = CY_CAPSENSE_CSX_RM_DITHER_SW_SEL_CMOD2, \ + } + +#define CY_CAPSENSE_ISX_RM_DITHER_MODE \ + { \ + .senseDutyCtl = CY_CAPSENSE_ISX_RM_DITHER_SENSE_DUTY_CTL,\ + .swSelCdacFl = CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_CDAC_FL,\ + .swSelTop = CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_TOP, \ + .swSelComp = CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_COMP, \ + .swSelSh = CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_SH, \ + .swSelCmod1 = CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_CMOD1, \ + .swSelCmod2 = CY_CAPSENSE_ISX_RM_DITHER_SW_SEL_CMOD2, \ + } + +#define CY_CAPSENSE_MPSC_DITHER_RM_MODE \ + { \ + .senseDutyCtl = CY_CAPSENSE_MPSC_RM_DITHER_SENSE_DUTY_CTL,\ + .swSelCdacFl = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_CDAC_FL,\ + .swSelTop = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_TOP, \ + .swSelComp = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_COMP, \ + .swSelSh = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_SH, \ + .swSelCmod1 = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_CMOD1, \ + .swSelCmod2 = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_CMOD2, \ + } + +#define CY_CAPSENSE_SM_MODES_ARR \ + {CY_CAPSENSE_CSD_RM_MODE, CY_CAPSENSE_CSX_RM_MODE, CY_CAPSENSE_ISX_RM_MODE, \ + CY_CAPSENSE_CSD_RM_DITHER_MODE, CY_CAPSENSE_CSX_RM_DITHER_MODE, CY_CAPSENSE_ISX_RM_DITHER_MODE} + + +/** Initialization of sensing method template variable */ + +#define CY_CAPSENSE_SENSING_METHOD_BASE_TEMPLATE \ + { \ + .ctl = \ + ((CY_CAPSENSE_SM_REG_CTL_FLD_SENSE_EN << MSCLP_CTL_SENSE_EN_Pos) |\ + (CY_CAPSENSE_SM_REG_CTL_FLD_MSCCMP_EN << MSCLP_CTL_MSCCMP_EN_Pos) |\ + (CY_CAPSENSE_SM_REG_CTL_FLD_CLK_SYNC_EN << MSCLP_CTL_CLK_SYNC_EN_Pos) |\ + (CY_CAPSENSE_SM_REG_CTL_FLD_EXT_FRAME_START_MODE << MSCLP_CTL_EXT_FRAME_START_MODE_Pos) |\ + (CY_CAPSENSE_SM_REG_CTL_FLD_CFG_OFFSET << MSCLP_CTL_CFG_OFFSET_Pos) |\ + (CY_CAPSENSE_SM_REG_CTL_FLD_OPERATING_MODE << MSCLP_CTL_OPERATING_MODE_Pos) |\ + (CY_CAPSENSE_SM_REG_CTL_FLD_BUF_MODE << MSCLP_CTL_BUF_MODE_Pos) |\ + (CY_CAPSENSE_SM_REG_CTL_FLD_CLK_MSC_RATIO << MSCLP_CTL_CLK_MSC_RATIO_Pos) |\ + (CY_CAPSENSE_SM_REG_CTL_FLD_DEBUG_EN << MSCLP_CTL_DEBUG_EN_Pos) |\ + (CY_CAPSENSE_SM_REG_CTL_FLD_ENABLED << MSCLP_CTL_ENABLED_Pos)), \ + .scanCtl1 = \ + ((CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_NUM_AUTO_RESAMPLE << MSCLP_SCAN_CTL1_NUM_AUTO_RESAMPLE_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_RESCAN_DEBUG_MODE << MSCLP_SCAN_CTL1_RESCAN_DEBUG_MODE_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_NUM_SAMPLES << MSCLP_SCAN_CTL1_NUM_SAMPLES_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_RAW_COUNT_MODE << MSCLP_SCAN_CTL1_RAW_COUNT_MODE_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_DEBUG_CONV_PH_SEL << MSCLP_SCAN_CTL1_DEBUG_CONV_PH_SEL_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_FRAME_RES_START_ADDR << MSCLP_SCAN_CTL1_FRAME_RES_START_ADDR_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_RC_STORE_EN << MSCLP_SCAN_CTL1_RC_STORE_EN_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_RC_STORE_MODE << MSCLP_SCAN_CTL1_RC_STORE_MODE_Pos)), \ + .scanCtl2 = \ + ((CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_NUM_EPI_KREF_DELAY_PRS << MSCLP_SCAN_CTL2_NUM_EPI_KREF_DELAY_PRS_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_NUM_EPI_KREF_DELAY << MSCLP_SCAN_CTL2_NUM_EPI_KREF_DELAY_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_CHOP_POL << MSCLP_SCAN_CTL2_CHOP_POL_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_FRAME_CFG_START_ADDR << MSCLP_SCAN_CTL2_FRAME_CFG_START_ADDR_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_EXT_REF_CLK_EN << MSCLP_SCAN_CTL2_EXT_REF_CLK_EN_Pos) |\ + (CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_INFINITE_SCAN_MODE << MSCLP_SCAN_CTL2_INFINITE_SCAN_MODE_Pos)), \ + .initCtl1 = \ + ((CY_CAPSENSE_SM_REG_INIT_CTL1_FLD_NUM_INIT_CMOD_12_RAIL_CYCLES << MSCLP_INIT_CTL1_NUM_INIT_CMOD_12_RAIL_CYCLES_Pos) |\ + (CY_CAPSENSE_SM_REG_INIT_CTL1_FLD_NUM_INIT_CMOD_12_SHORT_CYCLES << MSCLP_INIT_CTL1_NUM_INIT_CMOD_12_SHORT_CYCLES_Pos) |\ + (CY_CAPSENSE_SM_REG_INIT_CTL1_FLD_PER_SAMPLE << MSCLP_INIT_CTL1_PER_SAMPLE_Pos)), \ + .initCtl2 = \ + (0u), \ + .initCtl3 = \ + ((CY_CAPSENSE_SM_REG_INIT_CTL3_FLD_NUM_PRO_OFFSET_CYCLES << MSCLP_INIT_CTL3_NUM_PRO_OFFSET_CYCLES_Pos) |\ + (CY_CAPSENSE_SM_REG_INIT_CTL3_FLD_NUM_PRO_OFFSET_TRIPS << MSCLP_INIT_CTL3_NUM_PRO_OFFSET_TRIPS_Pos) |\ + (CY_CAPSENSE_SM_REG_INIT_CTL3_FLD_CMOD_SEL << MSCLP_INIT_CTL3_CMOD_SEL_Pos) |\ + (CY_CAPSENSE_SM_REG_INIT_CTL3_FLD_INIT_MODE << MSCLP_INIT_CTL3_INIT_MODE_Pos)), \ + .initCtl4 = \ + ((CY_CAPSENSE_SM_REG_INIT_CTL4_FLD_NUM_PRO_DUMMY_SUB_CONVS << MSCLP_INIT_CTL4_NUM_PRO_DUMMY_SUB_CONVS_Pos) |\ + (CY_CAPSENSE_SM_REG_INIT_CTL4_FLD_NUM_PRO_WAIT_KREF_DELAY_PRS << MSCLP_INIT_CTL4_NUM_PRO_WAIT_KREF_DELAY_PRS_Pos) |\ + (CY_CAPSENSE_SM_REG_INIT_CTL4_FLD_NUM_PRO_WAIT_KREF_DELAY << MSCLP_INIT_CTL4_NUM_PRO_WAIT_KREF_DELAY_Pos) |\ + (CY_CAPSENSE_SM_REG_INIT_CTL4_FLD_PRO_BYPASS << MSCLP_INIT_CTL4_PRO_BYPASS_Pos)), \ + .senseDutyCtl = \ + ((CY_CAPSENSE_SM_REG_SENSE_DUTY_CTL_FLD_PHASE_WIDTH << MSCLP_SENSE_DUTY_CTL_PHASE_WIDTH_Pos) |\ + (CY_CAPSENSE_SM_REG_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_CYCLES << MSCLP_SENSE_DUTY_CTL_PHASE_SHIFT_CYCLES_Pos) |\ + (CY_CAPSENSE_SM_REG_SENSE_DUTY_CTL_FLD_PHASE_WIDTH_SEL << MSCLP_SENSE_DUTY_CTL_PHASE_WIDTH_SEL_Pos)), \ + .sensePeriodCtl = \ + ((CY_CAPSENSE_SM_REG_SENSE_PERIOD_CTL_FLD_LFSR_POLY << MSCLP_SENSE_PERIOD_CTL_LFSR_POLY_Pos) |\ + (CY_CAPSENSE_SM_REG_SENSE_PERIOD_CTL_FLD_LFSR_SCALE << MSCLP_SENSE_PERIOD_CTL_LFSR_SCALE_Pos)), \ + .filterCtl = \ + ((CY_CAPSENSE_SM_REG_FILTER_CTL_FLD_BIT_FORMAT << MSCLP_FILTER_CTL_BIT_FORMAT_Pos) |\ + (CY_CAPSENSE_SM_REG_FILTER_CTL_FLD_FILTER_MODE << MSCLP_FILTER_CTL_FILTER_MODE_Pos)), \ + .ccompCdacCtl = \ + ((CY_CAPSENSE_SM_REG_CCOMP_CDAC_CTL_FLD_SEL_CO_PRO_OFFSET << MSCLP_CCOMP_CDAC_CTL_SEL_CO_PRO_OFFSET_Pos) |\ + (CY_CAPSENSE_SM_REG_CCOMP_CDAC_CTL_FLD_COMP_BLANKING_MODE << MSCLP_CCOMP_CDAC_CTL_COMP_BLANKING_MODE_Pos) |\ + (CY_CAPSENSE_SM_REG_CCOMP_CDAC_CTL_FLD_EPILOGUE_EN << MSCLP_CCOMP_CDAC_CTL_EPILOGUE_EN_Pos)), \ + .ditherCdacCtl = \ + ((CY_CAPSENSE_SM_REG_DITHER_CDAC_CTL_FLD_SEL_FL << MSCLP_DITHER_CDAC_CTL_SEL_FL_Pos) |\ + (CY_CAPSENSE_SM_REG_DITHER_CDAC_CTL_FLD_LFSR_POLY_FL << MSCLP_DITHER_CDAC_CTL_LFSR_POLY_FL_Pos)), \ + .mscCmpCtl = \ + ((CY_CAPSENSE_SM_REG_MSCCMP_CTL_FLD_PWR << MSCLP_MSCCMP_CTL_PWR_Pos) |\ + (CY_CAPSENSE_SM_REG_MSCCMP_CTL_FLD_FILT << MSCLP_MSCCMP_CTL_FILT_Pos)), \ + .obsCtl = \ + (0u), \ + .aosCtl = \ + ((CY_CAPSENSE_SM_REG_AOS_CTL_FLD_WAKEUP_TIMER << MSCLP_AOS_CTL_WAKEUP_TIMER_Pos) |\ + (CY_CAPSENSE_SM_REG_AOS_CTL_FLD_FR_TIMEOUT_INTERVAL << MSCLP_AOS_CTL_FR_TIMEOUT_INTERVAL_Pos) |\ + (CY_CAPSENSE_SM_REG_AOS_CTL_FLD_STOP_ON_SD << MSCLP_AOS_CTL_STOP_ON_SD_Pos) |\ + (CY_CAPSENSE_SM_REG_AOS_CTL_FLD_MRSS_PWR_CYCLE_EN << MSCLP_AOS_CTL_MRSS_PWR_CYCLE_EN_Pos)), \ + .ceCtl = \ + ((CY_CAPSENSE_SM_REG_CE_CTL_FLD_RCF_EN << MSCLP_CE_CTL_RCF_EN_Pos) |\ + (CY_CAPSENSE_SM_REG_CE_CTL_FLD_BLSD_EN << MSCLP_CE_CTL_BLSD_EN_Pos) |\ + (CY_CAPSENSE_SM_REG_CE_CTL_FLD_CE_TEST_MODE << MSCLP_CE_CTL_CE_TEST_MODE_Pos) |\ + (CY_CAPSENSE_SM_REG_CE_CTL_FLD_ENABLED << MSCLP_CE_CTL_ENABLED_Pos)), \ + .pumpCtl = \ + (CY_CAPSENSE_SM_REG_PUMP_CTL_FLD_PUMP_MODE << MSCLP_PUMP_CTL_PUMP_MODE_Pos), \ + .intr = \ + ((CY_CAPSENSE_SM_REG_INTR_FLD_SUB_SAMPLE << MSCLP_INTR_SUB_SAMPLE_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_FLD_SAMPLE << MSCLP_INTR_SAMPLE_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_FLD_SCAN << MSCLP_INTR_SCAN_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_FLD_INIT << MSCLP_INTR_INIT_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_FLD_FRAME << MSCLP_INTR_FRAME_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_FLD_CONFIG_REQ << MSCLP_INTR_CONFIG_REQ_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_FLD_FIFO_UNDERFLOW << MSCLP_INTR_FIFO_UNDERFLOW_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_FLD_FIFO_OVERFLOW << MSCLP_INTR_FIFO_OVERFLOW_Pos)), \ + .intrSet = \ + ((CY_CAPSENSE_SM_REG_INTR_SET_FLD_SUB_SAMPLE << MSCLP_INTR_SET_SUB_SAMPLE_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_SET_FLD_SAMPLE << MSCLP_INTR_SET_SAMPLE_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_SET_FLD_SCAN << MSCLP_INTR_SET_SCAN_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_SET_FLD_INIT << MSCLP_INTR_SET_INIT_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_SET_FLD_FRAME << MSCLP_INTR_SET_FRAME_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_SET_FLD_CONFIG_REQ << MSCLP_INTR_SET_CONFIG_REQ_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_SET_FLD_FIFO_UNDERFLOW << MSCLP_INTR_SET_FIFO_UNDERFLOW_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_SET_FLD_FIFO_OVERFLOW << MSCLP_INTR_SET_FIFO_OVERFLOW_Pos)), \ + .intrMask = \ + (0u), \ + .intrLp = \ + ((CY_CAPSENSE_SM_REG_INTR_LP_FLD_SIG_DET << MSCLP_INTR_LP_SIG_DET_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_LP_FLD_FR_TIMEOUT << MSCLP_INTR_LP_FR_TIMEOUT_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_LP_FLD_FRAME << MSCLP_INTR_LP_FRAME_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_LP_FLD_CE_DONE << MSCLP_INTR_LP_CE_DONE_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_LP_FLD_IMO_UP << MSCLP_INTR_LP_IMO_UP_Pos)), \ + .intrLpSet = \ + ((CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_SIG_DET << MSCLP_INTR_LP_SET_SIG_DET_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_FR_TIMEOUT << MSCLP_INTR_LP_SET_FR_TIMEOUT_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_FRAME << MSCLP_INTR_LP_SET_FRAME_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_CE_DONE << MSCLP_INTR_LP_SET_CE_DONE_Pos) |\ + (CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_IMO_UP << MSCLP_INTR_LP_SET_IMO_UP_Pos)), \ + .intrLpMask = \ + (0u), \ + .swSelCdacRe = \ + ((CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RETCC << MSCLP_SW_SEL_CDAC_RE_SW_RETCC_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RECD << MSCLP_SW_SEL_CDAC_RE_SW_RECD_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RETV << MSCLP_SW_SEL_CDAC_RE_SW_RETV_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RETG << MSCLP_SW_SEL_CDAC_RE_SW_RETG_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_REBV << MSCLP_SW_SEL_CDAC_RE_SW_REBV_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_REBG << MSCLP_SW_SEL_CDAC_RE_SW_REBG_Pos)), \ + .swSelCdacCo = \ + ((CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COTCA << MSCLP_SW_SEL_CDAC_CO_SW_COTCA_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COCB << MSCLP_SW_SEL_CDAC_CO_SW_COCB_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COTV << MSCLP_SW_SEL_CDAC_CO_SW_COTV_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COTG << MSCLP_SW_SEL_CDAC_CO_SW_COTG_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COBV << MSCLP_SW_SEL_CDAC_CO_SW_COBV_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COBG << MSCLP_SW_SEL_CDAC_CO_SW_COBG_Pos)), \ + .swSelCdacCf = \ + ((CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFTCA << MSCLP_SW_SEL_CDAC_CF_SW_CFTCA_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFTCB << MSCLP_SW_SEL_CDAC_CF_SW_CFTCB_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFTV << MSCLP_SW_SEL_CDAC_CF_SW_CFTV_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFTG << MSCLP_SW_SEL_CDAC_CF_SW_CFTG_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFBV << MSCLP_SW_SEL_CDAC_CF_SW_CFBV_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFBG << MSCLP_SW_SEL_CDAC_CF_SW_CFBG_Pos)), \ + .swSelBgr = \ + ((CY_CAPSENSE_SM_REG_SW_SEL_BGR_FLD_SW_BGRCM << MSCLP_SW_SEL_BGR_SW_BGRCM_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_BGR_FLD_SW_IGMA << MSCLP_SW_SEL_BGR_SW_IGMA_Pos) |\ + (CY_CAPSENSE_SM_REG_SW_SEL_BGR_FLD_SW_BGRMA << MSCLP_SW_SEL_BGR_SW_BGRMA_Pos)), \ + .swSelCswFunc = \ + { \ + [0u] = 0u, \ + [1u] = 0u, \ + [2u] = 0u, \ + [3u] = 0u, \ + [4u] = 0u, \ + [5u] = 0u, \ + [6u] = 0u, \ + [7u] = 0u, \ + }, \ + .mode = \ + { \ + [0u] = \ + { \ + .senseDutyCtl = 0u, \ + .swSelCdacFl = 0u, \ + .swSelTop = 0u, \ + .swSelComp = 0u, \ + .swSelSh = 0u, \ + .swSelCmod1 = 0u, \ + .swSelCmod2 = 0u, \ + }, \ + [1u] = \ + { \ + .senseDutyCtl = 0u, \ + .swSelCdacFl = 0u, \ + .swSelTop = 0u, \ + .swSelComp = 0u, \ + .swSelSh = 0u, \ + .swSelCmod1 = 0u, \ + .swSelCmod2 = 0u, \ + }, \ + [2u] = \ + { \ + .senseDutyCtl = 0u, \ + .swSelCdacFl = 0u, \ + .swSelTop = 0u, \ + .swSelComp = 0u, \ + .swSelSh = 0u, \ + .swSelCmod1 = 0u, \ + .swSelCmod2 = 0u, \ + }, \ + [3u] = \ + { \ + .senseDutyCtl = 0u, \ + .swSelCdacFl = 0u, \ + .swSelTop = 0u, \ + .swSelComp = 0u, \ + .swSelSh = 0u, \ + .swSelCmod1 = 0u, \ + .swSelCmod2 = 0u, \ + }, \ + }, \ + } + + + + +/** \cond SECTION_CAPSENSE_INTERNAL */ + /** The Sensor Frame types, to be used with \ref Cy_CapSense_GenerateSensorConfig and \ref Cy_CapSense_GenerateAllSensorConfig */ + #define CY_CAPSENSE_SNS_FRAME_ACTIVE (0uL) /**< - Sensor frame for Active slot */ + #define CY_CAPSENSE_SNS_FRAME_LOW_POWER (1uL) /**< - Sensor frame for Low Power slot */ +/** \endcond */ + +#if defined(__cplusplus) +} +#endif + +#endif /* CY_IP_M0S8MSCV3LP */ + +#endif /* CY_CAPSENSE_GENERATOR_LP_H */ + + +/* [] END OF FILE */ diff --git a/cy_capsense_generator_v3.c b/cy_capsense_generator_v3.c index 33c1620..7238d7b 100644 --- a/cy_capsense_generator_v3.c +++ b/cy_capsense_generator_v3.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_generator_v3.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file contains the source of functions common for register map @@ -29,6 +29,22 @@ #if (defined(CY_IP_M0S8MSCV3)) +/******************************************************************************* +* Local definitions +*******************************************************************************/ +/** Sensing mode undefined */ +#define CY_CAPSENSE_REG_MODE_UNDEFINED (255u) +/** CSD sense mode configuration index */ +#define CY_CAPSENSE_REG_MODE_CSD (0u) +/** CSX sense mode configuration index */ +#define CY_CAPSENSE_REG_MODE_CSX (1u) +/** CSD sense mode configuration index with CapDAC dithering enabled */ +#define CY_CAPSENSE_REG_MODE_CSD_DITHERING (2u) +/** CSX sense mode configuration index with CapDAC dithering enabled */ +#define CY_CAPSENSE_REG_MODE_CSX_DITHERING (3u) +/** First mode index with CapDAC dithering enabled */ +#define CY_CAPSENSE_REG_MODE_DITHERING (CY_CAPSENSE_REG_MODE_CSD_DITHERING) + /******************************************************************************* * Internal function prototypes *******************************************************************************/ @@ -100,7 +116,7 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( cy_stc_msc_base_config_t * ptrBaseCfg; const cy_stc_msc_base_config_t * ptrTemplateCfg; - const cy_stc_msc_channel_config_t * ptrMscChConfig = &context->ptrCommonConfig->ptrMscChConfig[chIndex]; + const cy_stc_capsense_channel_config_t * ptrChConfig = &context->ptrCommonConfig->ptrChConfig[chIndex]; /* * BASE CONFIGURATION @@ -110,7 +126,7 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( /* Copies template of a base config */ ptrBaseCfg->ctl = ptrTemplateCfg->ctl; - if(context->ptrCommonContext->modClk > 1u) + if (context->ptrInternalContext->modClk > 1u) { ptrBaseCfg->ctl &= (~MSC_CTL_CLK_MSC_RATIO_Msk); } @@ -141,8 +157,8 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( ptrBaseCfg->swSelCmod3 = ptrTemplateCfg->swSelCmod3; ptrBaseCfg->swSelCmod4 = ptrTemplateCfg->swSelCmod4; - if((CY_CAPSENSE_MSC0_CMOD1PADD_PIN != ptrMscChConfig->pinCmod1) && - (CY_CAPSENSE_MSC1_CMOD1PADD_PIN != ptrMscChConfig->pinCmod1)) + if ((CY_CAPSENSE_MSC0_CMOD1PADD_PIN != ptrChConfig->pinCmod1) && + (CY_CAPSENSE_MSC1_CMOD1PADD_PIN != ptrChConfig->pinCmod1)) { ptrBaseCfg->swSelCmod1 = 0u; ptrBaseCfg->swSelCmod2 = 0u; @@ -160,7 +176,7 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( /* Set the scanning mode */ #if (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) - ptrBaseCfg->ctl |= CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN << MSC_CTL_OPERATING_MODE_Pos; + ptrBaseCfg->ctl |= (uint32_t)CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN << MSC_CTL_OPERATING_MODE_Pos; #endif /* (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) @@ -218,21 +234,21 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - if(CY_CAPSENSE_CSX_GROUP == snsMethod) + if (CY_CAPSENSE_CSX_GROUP == snsMethod) { ptrBaseCfg->mode[idCounter].senseDutyCtl = CY_CAPSENSE_FW_CSX_AMUX_MODE_SENSE_DUTY_CTL_VALUE; } #endif #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - if(CY_CAPSENSE_CSD_GROUP == snsMethod) + if (CY_CAPSENSE_CSD_GROUP == snsMethod) { ptrBaseCfg->mode[idCounter].senseDutyCtl = 0u; } #endif #endif - if((CY_CAPSENSE_MSC0_CMOD1PADD_PIN != ptrMscChConfig->pinCmod1) && - (CY_CAPSENSE_MSC1_CMOD1PADD_PIN != ptrMscChConfig->pinCmod1)) + if ((CY_CAPSENSE_MSC0_CMOD1PADD_PIN != ptrChConfig->pinCmod1) && + (CY_CAPSENSE_MSC1_CMOD1PADD_PIN != ptrChConfig->pinCmod1)) { ptrBaseCfg->mode[idCounter].swSelComp &= (~MSC_MODE_SW_SEL_COMP_CPCS1_Msk); ptrBaseCfg->mode[idCounter].swSelComp &= (~MSC_MODE_SW_SEL_COMP_CMCS2_Msk); @@ -244,7 +260,7 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( } #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - if(CY_CAPSENSE_CSX_GROUP == snsMethod) + if (CY_CAPSENSE_CSX_GROUP == snsMethod) { #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) ptrBaseCfg->mode[idCounter].swSelTop = CY_CAPSENSE_CSX_FW_AMUX_MODE_SW_SEL_TOP_VALUE; @@ -252,7 +268,7 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( ptrBaseCfg->mode[idCounter].swSelTop = CY_CAPSENSE_CSX_FW_CTLMUX_MODE_SW_SEL_TOP_VALUE; #endif - if(CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 == ptrIntrCxt->intrCsxInactSnsConn) + if (CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 == ptrIntrCxt->intrCsxInactSnsConn) { /* Close the reference to filter switch */ ptrBaseCfg->mode[idCounter].swSelTop |= MSC_MODE_SW_SEL_TOP_RMF_Msk; @@ -302,13 +318,13 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( /* Shielding is available in CSD only */ #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN)) - if(CY_CAPSENSE_REG_MODE_UNDEFINED != ptrMapping[CY_CAPSENSE_REG_MODE_CSD]) + if (CY_CAPSENSE_REG_MODE_UNDEFINED != ptrMapping[CY_CAPSENSE_REG_MODE_CSD]) { ptrBaseCfgMode = &ptrBaseCfg->mode[ptrMapping[CY_CAPSENSE_REG_MODE_CSD]]; Cy_CapSense_ApplyShieldConfig(ptrBaseCfgMode, context); } - if(CY_CAPSENSE_REG_MODE_UNDEFINED != ptrMapping[CY_CAPSENSE_REG_MODE_CSD_DITHERING]) + if (CY_CAPSENSE_REG_MODE_UNDEFINED != ptrMapping[CY_CAPSENSE_REG_MODE_CSD_DITHERING]) { ptrBaseCfgMode = &ptrBaseCfg->mode[ptrMapping[CY_CAPSENSE_REG_MODE_CSD_DITHERING]]; Cy_CapSense_ApplyShieldConfig(ptrBaseCfgMode, context); @@ -316,8 +332,8 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( #endif /* Generating the common configuration for the Compensation CDAC */ - #if((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) || \ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE)) + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE)) ptrBaseCfg->ccompCdacCtl |= (uint32_t)ptrIntrCxt->proOffsetCdacComp << MSC_CCOMP_CDAC_CTL_SEL_CO_PRO_OFFSET_Pos; #else ptrBaseCfg->swSelCdacCo = 0u; @@ -334,8 +350,8 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) */ /* Generating the common configuration for the dithering CapDAC */ - ptrBaseCfg->ditherCdacCtl = (uint32_t)context->ptrCommonContext->cdacDitherSeed | - ((uint32_t)context->ptrCommonContext->cdacDitherPoly << MSC_DITHER_CDAC_CTL_LFSR_POLY_FL_Pos); + ptrBaseCfg->ditherCdacCtl = (uint32_t)context->ptrInternalContext->cdacDitherSeed | + ((uint32_t)context->ptrInternalContext->cdacDitherPoly << MSC_DITHER_CDAC_CTL_LFSR_POLY_FL_Pos); /* Configures synchronization signals */ @@ -361,13 +377,13 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( /* Generating the multi-channel mode for each channel with updating the sensor control registers */ if (0u != context->ptrCommonConfig->syncMode) { - context->ptrCommonConfig->ptrMscChConfig[chIndex].ptrMscBase->SNS_CTL = + context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase->SNS_CTL = ((uint32_t)context->ptrCommonConfig->syncMode << MSC_SNS_CTL_MULTI_CH_MODE_Pos); } /* Generating the common configuration for the clock dithering */ - ptrBaseCfg->sensePeriodCtl = ((uint32_t)context->ptrCommonContext->lfsrPoly << MSC_SENSE_PERIOD_CTL_LFSR_POLY_Pos) | - ((uint32_t)context->ptrCommonContext->lfsrScale << MSC_SENSE_PERIOD_CTL_LFSR_SCALE_Pos); + ptrBaseCfg->sensePeriodCtl = ((uint32_t)context->ptrInternalContext->lfsrPoly << MSC_SENSE_PERIOD_CTL_LFSR_POLY_Pos) | + ((uint32_t)context->ptrInternalContext->lfsrScale << MSC_SENSE_PERIOD_CTL_LFSR_SCALE_Pos); /* Generating the common configuration for the number of the auto-resampling cycles and the counter behaviour when the * RAW_COUNT exceeds 0xFFFF @@ -398,8 +414,8 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( ptrBaseCfg->initCtl2 &= ~MSC_INIT_CTL2_NUM_INIT_CMOD_34_RAIL_CYCLES_Msk; ptrBaseCfg->initCtl2 &= ~MSC_INIT_CTL2_NUM_INIT_CMOD_34_SHORT_CYCLES_Msk; - if((CY_CAPSENSE_MSC0_CMOD1PADD_PIN == ptrMscChConfig->pinCmod1) || - (CY_CAPSENSE_MSC1_CMOD1PADD_PIN == ptrMscChConfig->pinCmod1)) + if ((CY_CAPSENSE_MSC0_CMOD1PADD_PIN == ptrChConfig->pinCmod1) || + (CY_CAPSENSE_MSC1_CMOD1PADD_PIN == ptrChConfig->pinCmod1)) { ptrBaseCfg->initCtl1 |= (uint32_t)ptrIntrCxt->numCoarseInitChargeCycles << MSC_INIT_CTL1_NUM_INIT_CMOD_12_RAIL_CYCLES_Pos; ptrBaseCfg->initCtl1 |= (uint32_t)ptrIntrCxt->numCoarseInitSettleCycles << MSC_INIT_CTL1_NUM_INIT_CMOD_12_SHORT_CYCLES_Pos; @@ -417,10 +433,10 @@ cy_capsense_status_t Cy_CapSense_GenerateBaseConfig( /* Generating the common configuration for the number of sub-conversions to be run during PRO_DUMMY and PRO_WAIT phases. */ ptrBaseCfg->initCtl4 &= ~MSC_INIT_CTL4_NUM_PRO_DUMMY_SUB_CONVS_Msk; ptrBaseCfg->initCtl4 &= ~MSC_INIT_CTL4_NUM_PRO_WAIT_CYCLES_Msk; - ptrBaseCfg->initCtl4 |= (uint32_t)context->ptrCommonContext->numFineInitCycles << MSC_INIT_CTL4_NUM_PRO_DUMMY_SUB_CONVS_Pos; + ptrBaseCfg->initCtl4 |= (uint32_t)context->ptrInternalContext->numFineInitCycles << MSC_INIT_CTL4_NUM_PRO_DUMMY_SUB_CONVS_Pos; ptrBaseCfg->initCtl4 |= (uint32_t)context->ptrInternalContext->numFineInitWaitCycles << MSC_INIT_CTL4_NUM_PRO_WAIT_CYCLES_Pos; - return (capStatus); + return capStatus; } @@ -497,8 +513,8 @@ cy_capsense_status_t Cy_CapSense_GenerateSensorConfigValid( ptrSensorCfg[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] |= ((uint32_t)context->ptrWdContext[wdIndex].numSubConversions - 1u) << MSC_SNS_SCAN_CTL_NUM_SUB_CONVS_Pos; ptrSensorCfg[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] &= ~(MSC_SNS_SCAN_CTL_INIT_BYPASS_Msk); - if((CY_CAPSENSE_ENABLE == context->ptrWdContext[wdIndex].coarseInitBypassEn) && - ((scanSlot % CY_CAPSENSE_SLOT_COUNT) != context->ptrWdConfig[wdIndex].firstSlotId)) + if ((CY_CAPSENSE_ENABLE == context->ptrWdContext[wdIndex].coarseInitBypassEn) && + ((scanSlot % CY_CAPSENSE_SLOT_COUNT) != context->ptrWdConfig[wdIndex].firstSlotId)) { ptrSensorCfg[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] |= (MSC_SNS_SCAN_CTL_INIT_BYPASS_Msk); } @@ -506,7 +522,7 @@ cy_capsense_status_t Cy_CapSense_GenerateSensorConfigValid( ptrSensorCfg[CY_CAPSENSE_SNS_CTL_INDEX] |= (MSC_SNS_CTL_VALID_Msk); ptrSensorCfg[CY_CAPSENSE_SNS_CTL_INDEX] |= (MSC_SNS_CTL_START_SCAN_Msk); - return (capStatus); + return capStatus; } @@ -549,9 +565,9 @@ cy_capsense_status_t Cy_CapSense_GenerateSensorConfig( wdIndex = context->ptrScanSlots[scanSlot].wdId; - if((wdIndex == CY_CAPSENSE_SLOT_EMPTY) || - (wdIndex == CY_CAPSENSE_SLOT_SHIELD_ONLY) || - (wdIndex == CY_CAPSENSE_SLOT_TX_ONLY)) + if ((wdIndex == CY_CAPSENSE_SLOT_EMPTY) || + (wdIndex == CY_CAPSENSE_SLOT_SHIELD_ONLY) || + (wdIndex == CY_CAPSENSE_SLOT_TX_ONLY)) { #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) if (chIndex == 0u) @@ -566,17 +582,11 @@ cy_capsense_status_t Cy_CapSense_GenerateSensorConfig( nextChIndex = ((chIndex == 0u) ? 1u : 0u); slotIndex = context->ptrActiveScanSns[chIndex].currentChannelSlotIndex + (nextChIndex * CY_CAPSENSE_SLOT_COUNT); #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD)*/ - - /* Generate proper config for sensor */ - capStatus = Cy_CapSense_GenerateSensorConfigValid(slotIndex, ptrSensorCfg, context); - } - else - { - /* Generate proper config for sensor */ - capStatus = Cy_CapSense_GenerateSensorConfigValid(slotIndex, ptrSensorCfg, context); } + /* Generate proper config for sensor */ + capStatus = Cy_CapSense_GenerateSensorConfigValid(slotIndex, ptrSensorCfg, context); - return (capStatus); + return capStatus; } @@ -620,7 +630,7 @@ void Cy_CapSense_GenerateAllSensorConfig( uint32_t widgetSenseGroup; const cy_stc_capsense_electrode_config_t * eltdPinCfg; - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) uint32_t j = 0u; uint32_t pattern; uint32_t snsMaskNegative; @@ -752,8 +762,8 @@ void Cy_CapSense_GenerateAllSensorConfig( } /* Handles multi-phase TX feature */ - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED) - if (context->ptrWdConfig[wdIndex].mptxOrder >= CY_CAPSENSE_MPTX_MIN_ORDER) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) + if (context->ptrWdConfig[wdIndex].mpOrder >= CY_CAPSENSE_MPTX_MIN_ORDER) { /* Multiple TX ELECTRODES */ snsMask = 0u; @@ -761,23 +771,23 @@ void Cy_CapSense_GenerateAllSensorConfig( snsFuncState = CY_CAPSENSE_CTRLMUX_PIN_STATE_TX; snsFuncStateNegative = CY_CAPSENSE_CTRLMUX_PIN_STATE_TX_NEGATIVE; /* Finds the first sensor number in mptx group */ - i = snsIndex - (snsIndex % context->ptrWdConfig[wdIndex].mptxOrder); + i = snsIndex - (snsIndex % context->ptrWdConfig[wdIndex].mpOrder); /* Finds TX electrode of the first group sensor */ i = context->ptrWdConfig[wdIndex].numCols + (i % context->ptrWdConfig[wdIndex].numRows); eltdPinCfg = &context->ptrWdConfig[wdIndex].ptrEltdConfig[i]; /* Finding the right vector / pattern for mptx operation */ - pattern = context->ptrWdConfig[wdIndex].ptrMptxTable->vector; - i = (snsIndex % context->ptrWdConfig[wdIndex].mptxOrder); + pattern = context->ptrWdConfig[wdIndex].ptrMpTable->vector; + i = (snsIndex % context->ptrWdConfig[wdIndex].mpOrder); if (0u != i) { - pattern = (pattern >> i) | (pattern << (context->ptrWdConfig[wdIndex].mptxOrder - i)); + pattern = (pattern >> i) | (pattern << (context->ptrWdConfig[wdIndex].mpOrder - i)); } - if (CY_CAPSENSE_MPTX_MAX_ORDER > context->ptrWdConfig[wdIndex].mptxOrder) + if (CY_CAPSENSE_MPTX_MAX_ORDER > context->ptrWdConfig[wdIndex].mpOrder) { - pattern &= (0x01uL << context->ptrWdConfig[wdIndex].mptxOrder) - 1u; + pattern &= (0x01uL << context->ptrWdConfig[wdIndex].mpOrder) - 1u; } /* Loop through all involved mptx TX electrodes, positive and negative */ - for (j = 0u; j < context->ptrWdConfig[wdIndex].mptxOrder; j++) + for (j = 0u; j < context->ptrWdConfig[wdIndex].mpOrder; j++) { if ((chId + context->ptrCommonConfig->channelOffset) == eltdPinCfg->chId) { @@ -946,17 +956,27 @@ cy_capsense_status_t Cy_CapSense_GenerateCdacConfig( { cy_capsense_status_t capStatus = 0u; const cy_stc_capsense_widget_config_t * ptrWdCfg; - const cy_stc_capsense_sensor_context_t * ptrSnsCxt; uint32_t compDiv; uint32_t wdIndex; uint32_t snsIndex; uint32_t cdacLfsrScale; uint32_t snsCdacCtlReg = 0u; + #if ((CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN)) + const cy_stc_capsense_sensor_context_t * ptrSnsCxt; + #endif + wdIndex = context->ptrScanSlots[scanSlot].wdId; snsIndex = context->ptrScanSlots[scanSlot].snsId; ptrWdCfg = &context->ptrWdConfig[wdIndex]; - ptrSnsCxt = &ptrWdCfg->ptrSnsContext[snsIndex]; + + #if ((CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN)) + ptrSnsCxt = &ptrWdCfg->ptrSnsContext[snsIndex]; + #endif /* Compensation CDAC Divider */ compDiv = context->ptrWdContext[wdIndex].cdacCompDivider; @@ -976,7 +996,7 @@ cy_capsense_status_t Cy_CapSense_GenerateCdacConfig( snsCdacCtlReg |= MSC_SNS_CDAC_CTL_FL_EN_Msk; } - #if(CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) if (0u != (CY_CAPSENSE_MW_STATE_CALIBRATION_SINGLE_MASK & context->ptrCommonContext->status)) { /* If calibration, reuse compensation CDAC field as Ref CDAC in single CDAC mode */ @@ -997,12 +1017,26 @@ cy_capsense_status_t Cy_CapSense_GenerateCdacConfig( MSC_SNS_CDAC_CTL_SEL_RE_Pos; } - if(((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && - (CY_CAPSENSE_ENABLE == context->ptrCommonConfig->csdCdacCompEn)) || - ((CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) && - (CY_CAPSENSE_ENABLE == context->ptrCommonConfig->csxCdacCompEn))) + switch (ptrWdCfg->senseMethod) { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN) + case CY_CAPSENSE_CSD_GROUP: + /* Fall through */ + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN) + case CY_CAPSENSE_CSX_GROUP: + #endif + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN)) snsCdacCtlReg |= ((uint32_t)ptrSnsCxt->cdacComp) << MSC_SNS_CDAC_CTL_SEL_CO_Pos; + break; + #endif + + default: + /* Do nothing */ + break; } } #else @@ -1021,19 +1055,33 @@ cy_capsense_status_t Cy_CapSense_GenerateCdacConfig( MSC_SNS_CDAC_CTL_SEL_RE_Pos; } - if(((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && - (CY_CAPSENSE_ENABLE == context->ptrCommonConfig->csdCdacCompEn)) || - ((CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) && - (CY_CAPSENSE_ENABLE == context->ptrCommonConfig->csxCdacCompEn))) + switch (ptrWdCfg->senseMethod) { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN) + case CY_CAPSENSE_CSD_GROUP: + /* Fall through */ + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN) + case CY_CAPSENSE_CSX_GROUP: + #endif + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN)) snsCdacCtlReg |= ((uint32_t)ptrSnsCxt->cdacComp) << MSC_SNS_CDAC_CTL_SEL_CO_Pos; + break; + #endif + + default: + /* Do nothing */ + break; } } #endif ptrSensorCfg[CY_CAPSENSE_SNS_CDAC_CTL_INDEX] = snsCdacCtlReg; - return (capStatus); + return capStatus; } @@ -1165,8 +1213,8 @@ static void Cy_CapSense_ConfigSensorClock( /* Getting column sense clock divider */ snsClkDividerVal = ptrWdCxt->snsClk; - if((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && - (ptrWdCfg->numCols <= context->ptrScanSlots[scanSlot].snsId)) + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + (ptrWdCfg->numCols <= context->ptrScanSlots[scanSlot].snsId)) { snsClkDividerVal = ptrWdCxt->rowSnsClk; } @@ -1223,7 +1271,7 @@ uint32_t Cy_CapSense_AdjustSnsClkDivider( snsClkDividerTmp = snsClkDivider; snsClkSourceTmp = ((uint32_t)snsClkSource & CY_CAPSENSE_CLK_SOURCE_MASK); - if(CY_CAPSENSE_CSD_GROUP == snsMethod) + if (CY_CAPSENSE_CSD_GROUP == snsMethod) { snsClkDividerShift = CY_CAPSENSE_4PH_PRS_SNS_CLOCK_DIVIDER_SHIFT; } @@ -1232,12 +1280,12 @@ uint32_t Cy_CapSense_AdjustSnsClkDivider( snsClkDividerShift = CY_CAPSENSE_2PH_PRS_SNS_CLOCK_DIVIDER_SHIFT; } - if(CY_CAPSENSE_CLK_SOURCE_PRS == snsClkSourceTmp) + if (CY_CAPSENSE_CLK_SOURCE_PRS == snsClkSourceTmp) { snsClkDividerTmp >>= snsClkDividerShift; } - return (snsClkDividerTmp); + return snsClkDividerTmp; } diff --git a/cy_capsense_generator_v3.h b/cy_capsense_generator_v3.h index 7051cbb..5ab90a6 100644 --- a/cy_capsense_generator_v3.h +++ b/cy_capsense_generator_v3.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_generator_v3.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the function prototypes specific to the register diff --git a/cy_capsense_gesture_lib.h b/cy_capsense_gesture_lib.h index f9fa53f..625fe21 100644 --- a/cy_capsense_gesture_lib.h +++ b/cy_capsense_gesture_lib.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_gesture_lib.h -* \version 3.0.1 +* \version 4.0 * * \brief * Provides the gesture interface. @@ -20,7 +20,7 @@ #include -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if defined(__cplusplus) extern "C" { @@ -48,6 +48,7 @@ typedef struct uint16_t clickTimeoutMin; /**< Click minimum timeout */ uint16_t secondClickIntervalMax; /**< Second Click maximum interval */ uint16_t secondClickIntervalMin; /**< Second Click minimum interval */ + uint16_t longPressTimeoutMin; /**< Long Press minimum timeout */ /* Distance */ uint16_t zoomDistanceMin; /**< Zoom minimum distance */ @@ -57,6 +58,7 @@ typedef struct uint16_t edgeDistanceMin; /**< Edge Swipe minimum distance */ uint8_t secondClickDistanceMax; /**< Second Click maximum distance */ uint8_t clickDistanceMax; /**< Click maximum distance */ + uint8_t longPressDistanceMax; /**< Long Press maximum distance */ /* Debounce */ uint8_t zoomDebounce; /**< Zoom debounce */ @@ -165,6 +167,14 @@ typedef struct uint8_t debounce; /**< Gesture debounce counter */ } cy_stc_capsense_ofrt_context_t; +/** Gesture One Finger Long Press context structure */ +typedef struct +{ + uint32_t touchStartTime1; /**< Touchdown time */ + cy_stc_capsense_gesture_position_t touchStartPosition1; /**< Touchdown position */ + uint8_t state; /**< Gesture state */ +} cy_stc_capsense_oflp_context_t; + /** Gesture global context structure */ typedef struct { @@ -172,11 +182,11 @@ typedef struct cy_stc_capsense_gesture_position_t positionLast1; /**< Previous position of the first touch */ cy_stc_capsense_gesture_position_t position2; /**< Current position of the second touch */ cy_stc_capsense_gesture_position_t positionLast2; /**< Previous position of the second touch */ - + uint32_t timestamp; /**< Current timestamp */ uint16_t detected; /**< Detected gesture mask */ uint16_t direction; /**< Mask of direction of detected gesture */ - + cy_stc_capsense_ofrt_context_t ofrtContext; /**< One-finger rotate gesture context */ cy_stc_capsense_ofsl_context_t ofslContext; /**< One-finger scroll gesture context */ cy_stc_capsense_tfzm_context_t tfzmContext; /**< Two-finger zoom gesture context */ @@ -187,6 +197,7 @@ typedef struct cy_stc_capsense_ofdc_context_t ofdcContext; /**< One-finger double click gesture context */ cy_stc_capsense_ofcd_context_t ofcdContext; /**< One-finger click and drag gesture context */ cy_stc_capsense_tfsl_context_t tfslContext; /**< Two-finger scroll gesture context */ + cy_stc_capsense_oflp_context_t oflpContext; /**< One-finger long press gesture context */ uint8_t numPosition; /**< Current number of touches */ uint8_t numPositionLast; /**< Previous number of touches */ @@ -211,7 +222,7 @@ typedef struct * Initializes internal variables and states. * * \param context -* The pointer to the gesture context structure +* The pointer to the gesture context structure * \ref cy_stc_capsense_gesture_context_t. * *******************************************************************************/ @@ -235,11 +246,11 @@ void Cy_CapSense_Gesture_ResetState( * The pointer to the array of positions \ref cy_stc_capsense_gesture_position_t. * * \param config -* The pointer to the gesture configuration structure +* The pointer to the gesture configuration structure * \ref cy_stc_capsense_gesture_config_t. * * \param context -* The pointer to the gesture context structure +* The pointer to the gesture context structure * \ref cy_stc_capsense_gesture_context_t. * *******************************************************************************/ @@ -262,7 +273,7 @@ void Cy_CapSense_Gesture_Decode( /** No gesture detected */ #define CY_CAPSENSE_GESTURE_NO_GESTURE (0x00u) /** All gestures enable / detection mask */ -#define CY_CAPSENSE_GESTURE_ALL_GESTURES_MASK (0x03FFu) +#define CY_CAPSENSE_GESTURE_ALL_GESTURES_MASK (0x07FFu) /** Gesture enable filtering mask */ #define CY_CAPSENSE_GESTURE_FILTERING_MASK (0x8000u) /** Detection mask of Touchdown */ @@ -290,6 +301,8 @@ void Cy_CapSense_Gesture_Decode( #define CY_CAPSENSE_GESTURE_ONE_FNGR_ROTATE_MASK (0x0100u) /** Enable / detection mask of two-finger zoom gesture */ #define CY_CAPSENSE_GESTURE_TWO_FNGR_ZOOM_MASK (0x0200u) +/** Enable / detection mask of one-finger long press gesture */ +#define CY_CAPSENSE_GESTURE_ONE_FNGR_LONG_PRESS_MASK (0x0400u) /* Direction Offsets */ /** Offset of direction of one-finger scroll gesture */ @@ -356,7 +369,7 @@ void Cy_CapSense_Gesture_Decode( } #endif -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif /* CY_CAPSENSE_GESTURE_LIB_H */ diff --git a/cy_capsense_lib.h b/cy_capsense_lib.h index 0727bcb..da1e9d2 100644 --- a/cy_capsense_lib.h +++ b/cy_capsense_lib.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_lib.h -* \version 3.0.1 +* \version 4.0 * * \brief * The file contains application programming interface to the CAPSENSE™ library. @@ -106,7 +106,8 @@ typedef struct * Reserved * Reserved * Reserved -* MSB = Age of touch; LSB = Z-value +* MSB = Age of touch; LSB = Z-value represents a touch strength (summ of sensor diff counts divided by 16 +* that form 3x3 matrix with a local maximum in the center) * * * id @@ -146,7 +147,7 @@ typedef struct uint32_t sensorCap; /**< Sensor parasitic capacitance in fF 10^-15 */ uint32_t iDacGain; /**< IDAC gain in pA */ uint16_t * ptrSenseClk; /**< Pointer to SnsClk divider */ - uint16_t * sigPFC; /**< Pointer to sigPFC value (Signal Per Finger Capacitance) */ + uint16_t * sigPFC; /**< Pointer to sigPFC value (75% of Signal Per Finger Capacitance) */ uint16_t snsClkConstantR; /**< Resistance in series to a sensor */ uint16_t vRef; /**< Vref in mVolts */ uint16_t fingerCap; /**< Finger capacitance in fF 10^-15 (Set in Basic tab in pF 10^-12) */ @@ -168,8 +169,8 @@ typedef struct uint16_t kRef0; /**< Base sense frequency */ uint16_t kRef1; /**< Final sense frequency */ uint16_t fingerCap; /**< Finger capacitance in fF 10^-15 (Set in Basic tab in pF 10^-12) */ - uint16_t sigPFC; /**< sigPFC value (Signal Per Finger Capacitance) */ - uint8_t refCdac; /**< Reference CAP DAC code */ + uint16_t sigPFC; /**< sigPFC value (75% of signal Per Finger Capacitance) */ + uint8_t refCdac; /**< Reference CAP DAC code for getting capacitance and calibration target for getting Nsub */ uint8_t correctionCoeff; /**< Correction coefficient for CTRL_MUX mode */ } cy_stc_capsense_hw_smartsense_config_t; @@ -289,12 +290,9 @@ void Cy_CapSense_AdaptiveFilterInitialize_Lib( * * This function runs the Adaptive Filter algorithm for the centroid position. * -* Equation: result = ((k * curPos) + ((divisor-k) * prevPos)) / divisor -* where k is adaptive coefficient. -* * The function supposes that the filter history is updated at first touch * outside of the library. I.e. at the first touchdown the filter history has -* be initialized by touch positions before calling this function. +* to be initialized by touch positions before calling this function. * * \param config * The pointer to the configuration structure of the Adaptive Filter. @@ -442,15 +440,6 @@ uint32_t Cy_CapSense_AlpGetAverage_Lib( * * This internal function tunes the Sense Clock divider. * -* Found IDAC code in Single IDAC mode is used to calculate the optimal SnsClk. -* The SnsClk divider is set to meet the requirement that the widget -* clock period should be greater than or equal to: -* Period > 2*5*R*Cp, -* where: -* * Cp is the maximum sensor parasitic capacitance within the widget. -* * R is the user input value in the expression view of the customizer for a -* series resistor. -* * \param config * The configuration structure. * @@ -467,17 +456,6 @@ uint32_t Cy_CapSense_TunePrescalers_Lib( * * Configure scanning resolution to achieve the sufficient sensitivity. * -* The function searches the lowest possible resolution that produces signal -* greater than 50 counts (Difference Counts) for user defined finger capacitance. -* In addition, function calculates 75%-value of the achieved signal, that becomes -* candidate to finger threshold. -* -* Used equation to calculate signal at resolution 16-bit: -* sigPFCmax = (2^16-1) * vRef * snsClk * fingerCap / idacCurrent -* -* sigPFCmax contains absolute number of difference counts that user receives as -* result of sensor scanning at corresponding resolution. -* * This function requires non-zero Modulator IDAC code (if IDAC is equal to zero it * is considered as non-valid use case). * @@ -497,9 +475,6 @@ uint8_t Cy_CapSense_TuneSensitivity_Lib( * * Returns capacitance that corresponds to the provided parameters. * -* Calculates sensor capacitance as follows: -* Cp = Raw * RefCDAC / Nsub0 -* * \param autoTuneConfig * The configuration structure. * @@ -516,9 +491,6 @@ uint32_t Cy_CapSense_GetSmartSenseCapacitance( * * Returns minimum sense clock divider. * -* Calculates minimal sense clock divider as follows: -* Kref = 4 * 5tau * Fmod * R * Cp -* * \param autoTuneConfig * The configuration structure. * @@ -535,9 +507,6 @@ uint32_t Cy_CapSense_GetSmartSenseFrequencyDivider( * * Returns optimum number of sub-conversions. * -* Calculates number of sub-conversions as follows: -* Nsub = RoundUp(minRaw * RefCDAC * kRef0 /(sigPFC * kRef1) -* * \param autoTuneConfig * The configuration structure. * diff --git a/cy_capsense_processing.c b/cy_capsense_processing.c index 03f397f..aa017ad 100644 --- a/cy_capsense_processing.c +++ b/cy_capsense_processing.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_processing.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the source code for the Data Processing module functions. @@ -28,9 +28,8 @@ #include "cy_capsense_filter.h" #include "cy_capsense_lib.h" #include "cy_capsense_centroid.h" -#include "cy_capsense_sensing_v3.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) /******************************************************************************* * Local definition @@ -39,13 +38,6 @@ #define CY_CAPSENSE_SCALING_SHIFT (15) #define CY_CAPSENSE_MAX_TX_PATTERN_NUM (32) -/* CIC2 Filter Divider */ -#define CY_CAPSENSE_CIC2_DIVIDER_1 (1u) -#define CY_CAPSENSE_CIC2_DIVIDER_2 (2u) -#define CY_CAPSENSE_CIC2_DIVIDER_4 (4u) -#define CY_CAPSENSE_CIC2_DIVIDER_8 (8u) -#define CY_CAPSENSE_CIC2_DIVIDER_16 (16u) - /** \} \endcond */ @@ -75,7 +67,13 @@ void Cy_CapSense_InitializeAllStatuses(const cy_stc_capsense_context_t * context { uint32_t widgetId; - for(widgetId = context->ptrCommonConfig->numWd; widgetId-- > 0u;) + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if (CY_CAPSENSE_LP_EN) + context->ptrCommonContext->status &= (uint32_t)~((uint32_t)CY_CAPSENSE_MW_STATE_LP_ACTIVE_MASK); + #endif + #endif + + for (widgetId = CY_CAPSENSE_TOTAL_WIDGET_COUNT; widgetId-- > 0u;) { Cy_CapSense_InitializeWidgetStatus(widgetId, context); #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_GESTURE_EN) @@ -100,7 +98,7 @@ void Cy_CapSense_InitializeAllStatuses(const cy_stc_capsense_context_t * context * * Enables the widget. * * The Button and Matrix Button widgets have individual debounce counters per -* sensor for the CSD widgets and per node for the CSX widgets. +* sensor for the CSD widgets and per node for the CSX and ISX widgets. * * The Slider and Touchpad widgets have a single debounce counter per widget. * @@ -118,6 +116,9 @@ void Cy_CapSense_InitializeAllStatuses(const cy_stc_capsense_context_t * context * Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -132,115 +133,102 @@ void Cy_CapSense_InitializeWidgetStatus( cy_stc_capsense_sensor_context_t * ptrSnsCxt = ptrWdCfg->ptrSnsContext; uint32_t snsNumber = ptrWdCfg->numSns; - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) uint32_t filterSize; cy_stc_capsense_position_t * ptrHistory; #endif - /* Clear widget statuses (Non active, Not disabled, Working) */ - ptrWdCxt->status &= (uint8_t)~(CY_CAPSENSE_WD_ACTIVE_MASK | - CY_CAPSENSE_WD_DISABLE_MASK | - CY_CAPSENSE_WD_WORKING_MASK); - /* Clear sensor status */ - for (snsIndex = snsNumber; snsIndex-- >0u;) +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ { - ptrSnsCxt->status &= (uint8_t)~(CY_CAPSENSE_SNS_TOUCH_STATUS_MASK | CY_CAPSENSE_SNS_PROX_STATUS_MASK); - ptrSnsCxt++; - } - - /* Reset debounce counters */ - switch (ptrWdCfg->wdType) - { - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_BUTTON_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MATRIX_EN)) - case (uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E: - case (uint8_t)CY_CAPSENSE_WD_BUTTON_E: - /* Each button requires one debounce counter */ - (void)memset(ptrWdCfg->ptrDebounceArr, (int32_t)ptrWdCxt->onDebounce, (size_t)snsNumber); - break; - #endif - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN)) - case (uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E: - case (uint8_t)CY_CAPSENSE_WD_RADIAL_SLIDER_E: - case (uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E: - /* Each widget requires one debounce counter */ - if (ptrWdCfg->senseMethod == CY_CAPSENSE_CSD_GROUP) - { - *(ptrWdCfg->ptrDebounceArr) = ptrWdCxt->onDebounce; - } - else - { - /* - * CSX Touchpad has debounce located in another place. Moreover, - * debounce counter is initialized at ID assignment, so no need - * to do it here. - */ - } - break; - #endif - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) - case (uint8_t)CY_CAPSENSE_WD_PROXIMITY_E: - /* Proximity widgets have 2 debounce counters per sensor (for touch and prox detection) */ - (void)memset(ptrWdCfg->ptrDebounceArr, (int32_t)ptrWdCxt->onDebounce, (size_t)(snsNumber << 1u)); - break; - #endif - default: - /* No other widget types */ - break; - } + /* Clear widget active status */ + ptrWdCxt->status &= (uint8_t)~(CY_CAPSENSE_WD_ACTIVE_MASK); + /* Clear sensor status */ + for (snsIndex = snsNumber; snsIndex-- >0u;) + { + ptrSnsCxt->status &= (uint8_t)~(CY_CAPSENSE_SNS_TOUCH_STATUS_MASK | CY_CAPSENSE_SNS_TOUCH_PROX_STATUS_MASK); + ptrSnsCxt++; + } - /* Reset touch numbers */ - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN)) + /* Reset debounce counters */ switch (ptrWdCfg->wdType) { - case (uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E: - case (uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E: - case (uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E: - case (uint8_t)CY_CAPSENSE_WD_RADIAL_SLIDER_E: - /* Clean number of touches */ - ptrWdCxt->wdTouch.numPosition = CY_CAPSENSE_POSITION_NONE; - if (0u != (ptrWdCfg->posFilterConfig & CY_CAPSENSE_POSITION_FILTERS_MASK)) - { - ptrWdCfg->ptrPosFilterHistory->numPosition = CY_CAPSENSE_POSITION_NONE; - } - break; + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_BUTTON_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MATRIX_EN)) + case (uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E: + case (uint8_t)CY_CAPSENSE_WD_BUTTON_E: + /* Each button requires one debounce counter */ + (void)memset(ptrWdCfg->ptrDebounceArr, (int32_t)ptrWdCxt->onDebounce, (size_t)snsNumber); + break; + #endif + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN)) + case (uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E: + case (uint8_t)CY_CAPSENSE_WD_RADIAL_SLIDER_E: + case (uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E: + /* Each widget requires one debounce counter */ + switch (ptrWdCfg->senseMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + *(ptrWdCfg->ptrDebounceArr) = ptrWdCxt->onDebounce; + break; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + if ((uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E == ptrWdCfg->wdType) + { + *(ptrWdCfg->ptrDebounceArr) = ptrWdCxt->onDebounce; + } + + /* + * CSX Touchpad has debounce located in another place. Moreover, + * debounce counter is initialized at ID assignment, so no need + * to do it here. + */ + break; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_GROUP: + *(ptrWdCfg->ptrDebounceArr) = ptrWdCxt->onDebounce; + break; + #endif + + default: + /* No action */ + break; + } + break; + #endif + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) + case (uint8_t)CY_CAPSENSE_WD_PROXIMITY_E: + /* Proximity widgets have 2 debounce counters per sensor (for touch and prox detection) */ + (void)memset(ptrWdCfg->ptrDebounceArr, (int32_t)ptrWdCxt->onDebounce, (size_t)(snsNumber << 1u)); + break; + #endif default: - /* No action on other widget types */ + /* No other widget types */ break; } - #endif - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_BALLISTIC_MULTIPLIER_EN) - /* Reset ballistic displacement */ - if (0u != (ptrWdCfg->centroidConfig & CY_CAPSENSE_CENTROID_BALLISTIC_MASK)) - { - ptrWdCxt->xDelta = 0; - ptrWdCxt->yDelta = 0; - ptrWdCfg->ptrBallisticContext->oldTouchNumber = 0u; - } - #endif - - /* Reset touch history */ - if (0u != (ptrWdCfg->posFilterConfig & CY_CAPSENSE_POSITION_FILTERS_MASK)) - { - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) + /* Reset touch numbers */ + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN)) switch (ptrWdCfg->wdType) { case (uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E: - /* Clean position filter history */ - if (ptrWdCfg->senseMethod == CY_CAPSENSE_CSX_GROUP) + case (uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E: + case (uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E: + case (uint8_t)CY_CAPSENSE_WD_RADIAL_SLIDER_E: + /* Clean number of touches */ + ptrWdCxt->wdTouch.numPosition = CY_CAPSENSE_POSITION_NONE; + if (0u != (ptrWdCfg->posFilterConfig & CY_CAPSENSE_POSITION_FILTERS_MASK)) { - /* Reset all history IDs to undefined state */ - ptrHistory = ptrWdCfg->ptrPosFilterHistory->ptrPosition; - filterSize = (ptrWdCfg->posFilterConfig & CY_CAPSENSE_POSITION_FILTERS_SIZE_MASK) >> CY_CAPSENSE_POSITION_FILTERS_SIZE_OFFSET; - for (snsIndex = 0u; snsIndex < CY_CAPSENSE_MAX_CENTROIDS; snsIndex++) - { - ptrHistory->id = CY_CAPSENSE_CSX_TOUCHPAD_ID_UNDEFINED; - ptrHistory += filterSize; - } + ptrWdCfg->ptrPosFilterHistory->numPosition = CY_CAPSENSE_POSITION_NONE; } break; default: @@ -249,14 +237,51 @@ void Cy_CapSense_InitializeWidgetStatus( } #endif - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_ADAPTIVE_FILTER_EN) - /* Init Adaptive IIR filter */ - if (0u != (ptrWdCfg->posFilterConfig & CY_CAPSENSE_POSITION_AIIR_MASK)) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_BALLISTIC_MULTIPLIER_EN) + /* Reset ballistic displacement */ + if (0u != (ptrWdCfg->centroidConfig & CY_CAPSENSE_CENTROID_BALLISTIC_MASK)) { - Cy_CapSense_AdaptiveFilterInitialize_Lib(&ptrWdCfg->aiirConfig, - ptrWdCfg->ptrPosFilterHistory->ptrPosition); + ptrWdCxt->xDelta = 0; + ptrWdCxt->yDelta = 0; + ptrWdCfg->ptrBallisticContext->oldTouchNumber = 0u; } #endif + + /* Reset touch history */ + if (0u != (ptrWdCfg->posFilterConfig & CY_CAPSENSE_POSITION_FILTERS_MASK)) + { + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) + switch (ptrWdCfg->wdType) + { + case (uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E: + /* Clean position filter history */ + if (ptrWdCfg->senseMethod == CY_CAPSENSE_CSX_GROUP) + { + /* Reset all history IDs to undefined state */ + ptrHistory = ptrWdCfg->ptrPosFilterHistory->ptrPosition; + filterSize = (ptrWdCfg->posFilterConfig & CY_CAPSENSE_POSITION_FILTERS_SIZE_MASK) >> CY_CAPSENSE_POSITION_FILTERS_SIZE_OFFSET; + for (snsIndex = 0u; snsIndex < CY_CAPSENSE_MAX_CENTROIDS; snsIndex++) + { + ptrHistory->id = CY_CAPSENSE_CSX_TOUCHPAD_ID_UNDEFINED; + ptrHistory += filterSize; + } + } + break; + default: + /* No action on other widget types */ + break; + } + #endif + + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_ADAPTIVE_FILTER_EN) + /* Init Adaptive IIR filter */ + if (0u != (ptrWdCfg->posFilterConfig & CY_CAPSENSE_POSITION_AIIR_MASK)) + { + Cy_CapSense_AdaptiveFilterInitialize_Lib(&ptrWdCfg->aiirConfig, + ptrWdCfg->ptrPosFilterHistory->ptrPosition); + } + #endif + } } } @@ -282,17 +307,13 @@ void Cy_CapSense_InitializeWidgetGestures( const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; cy_stc_capsense_widget_context_t * ptrWdCxt = ptrWdCfg->ptrWdContext; - if (((uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E == ptrWdCfg->wdType) || - ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType)) + if (NULL != ptrWdCfg->ptrGestureConfig) { - if (NULL != ptrWdCfg->ptrGestureConfig) + if (0u != (ptrWdCfg->ptrGestureConfig->gestureEnableMask & CY_CAPSENSE_GESTURE_ALL_GESTURES_MASK)) { - if (0u != (ptrWdCfg->ptrGestureConfig->gestureEnableMask & CY_CAPSENSE_GESTURE_ALL_GESTURES_MASK)) - { - ptrWdCxt->gestureDetected = 0u; - ptrWdCxt->gestureDirection = 0u; - Cy_CapSense_Gesture_ResetState(ptrWdCfg->ptrGestureContext); - } + ptrWdCxt->gestureDetected = 0u; + ptrWdCxt->gestureDirection = 0u; + Cy_CapSense_Gesture_ResetState(ptrWdCfg->ptrGestureContext); } } } @@ -339,6 +360,7 @@ void Cy_CapSense_InitializeWidgetGestures( * * bit[7] - one-finger flick * * bit[8] - one-finger rotate * * bit[9] - two-finger zoom +* * bit[10] - one-finger long press * * bit[13] - touchdown event * * bit[14] - liftoff event * * bit[16..31] - gesture direction if detected @@ -369,12 +391,21 @@ uint32_t Cy_CapSense_DecodeWidgetGestures( cy_stc_capsense_widget_context_t * ptrWdCxt = ptrWdCfg->ptrWdContext; cy_stc_capsense_gesture_position_t position[CY_CAPSENSE_MAX_CENTROIDS]; - if (((uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E == ptrWdCfg->wdType) || - ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType)) + if (NULL != ptrWdCfg->ptrGestureConfig) { - if (NULL != ptrWdCfg->ptrGestureConfig) + if (0u != (ptrWdCfg->ptrGestureConfig->gestureEnableMask & CY_CAPSENSE_GESTURE_ALL_GESTURES_MASK)) { - if (0u != (ptrWdCfg->ptrGestureConfig->gestureEnableMask & CY_CAPSENSE_GESTURE_ALL_GESTURES_MASK)) + if (((uint8_t)CY_CAPSENSE_WD_BUTTON_E == ptrWdCfg->wdType) || + ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType)) + { + positionNum = (uint32_t)ptrWdCxt->status & CY_CAPSENSE_WD_ACTIVE_MASK; + for (posIndex = 0u; posIndex < positionNum; posIndex++) + { + position[posIndex].x = 0u; + position[posIndex].y = 0u; + } + } + else { positionNum = ptrWdCxt->wdTouch.numPosition; if (positionNum > CY_CAPSENSE_MAX_CENTROIDS) @@ -386,25 +417,25 @@ uint32_t Cy_CapSense_DecodeWidgetGestures( position[posIndex].x = ptrWdCxt->wdTouch.ptrPosition[posIndex].x; position[posIndex].y = ptrWdCxt->wdTouch.ptrPosition[posIndex].y; } - Cy_CapSense_Gesture_Decode(context->ptrCommonContext->timestamp, (uint32_t)ptrWdCxt->wdTouch.numPosition, - &position[0u], ptrWdCfg->ptrGestureConfig, ptrWdCfg->ptrGestureContext); - ptrWdCxt->gestureDetected = ptrWdCfg->ptrGestureContext->detected; - ptrWdCxt->gestureDirection = ptrWdCfg->ptrGestureContext->direction; - gestureStatus = (uint32_t)ptrWdCxt->gestureDetected | ((uint32_t)ptrWdCxt->gestureDirection << CY_CAPSENSE_GESTURE_DIRECTION_OFFSET); } + Cy_CapSense_Gesture_Decode(context->ptrCommonContext->timestamp, positionNum, + &position[0u], ptrWdCfg->ptrGestureConfig, ptrWdCfg->ptrGestureContext); + ptrWdCxt->gestureDetected = ptrWdCfg->ptrGestureContext->detected; + ptrWdCxt->gestureDirection = ptrWdCfg->ptrGestureContext->direction; + gestureStatus = (uint32_t)ptrWdCxt->gestureDetected | ((uint32_t)ptrWdCxt->gestureDirection << CY_CAPSENSE_GESTURE_DIRECTION_OFFSET); } } + return gestureStatus; } #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_GESTURE_EN) */ -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) /******************************************************************************* -* Function Name: Cy_CapSense_DpProcessCsxWidgetRawCounts +* Function Name: Cy_CapSense_DpProcessWidgetRawCounts ****************************************************************************//** * -* Performs default processing of the raw counts of the specified CSX widget. +* Performs default processing of the raw counts of the specified widget. * * The processing includes the following tasks: * - Run Filters. @@ -421,12 +452,12 @@ uint32_t Cy_CapSense_DecodeWidgetGestures( * * \return * Returns the status of the specified widget processing operation: -* - Zero - if operation was successfully completed; +* - Zero - if operation was successfully completed. * - Non-zero - if baseline processing of any sensor of the specified widget * failed. The result is concatenated with the index of failed sensor. * *******************************************************************************/ -uint32_t Cy_CapSense_DpProcessCsxWidgetRawCounts( +uint32_t Cy_CapSense_DpProcessWidgetRawCounts( uint32_t widgetId, const cy_stc_capsense_context_t * context) { @@ -441,14 +472,20 @@ uint32_t Cy_CapSense_DpProcessCsxWidgetRawCounts( const cy_stc_capsense_widget_config_t * ptrWdCfg; ptrWdCfg = &context->ptrWdConfig[widgetId]; + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN)) + cy_stc_capsense_smartsense_csd_noise_envelope_t * ptrNEHistory = ptrWdCfg->ptrNoiseEnvelope; + #endif + snsHistorySize = (uint32_t)ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_MASK; - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { ptrSnsCxtSns = &ptrWdCfg->ptrSnsContext[freqChIndex * context->ptrCommonConfig->numSns]; ptrBslnInvSns = &ptrWdCfg->ptrBslnInv[freqChIndex * context->ptrCommonConfig->numSns]; ptrHistorySns = &ptrWdCfg->ptrRawFilterHistory[freqChIndex * (CY_CAPSENSE_RAW_HISTORY_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; - if(CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) + if (CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) { ptrHistoryLowSns = &ptrWdCfg->ptrRawFilterHistoryLow[freqChIndex * (CY_CAPSENSE_IIR_HISTORY_LOW_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; @@ -459,19 +496,41 @@ uint32_t Cy_CapSense_DpProcessCsxWidgetRawCounts( #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_RAWCOUNT_FILTER_EN) Cy_CapSense_FtRunEnabledFiltersInternal(ptrWdCfg, ptrSnsCxtSns, ptrHistorySns, ptrHistoryLowSns); #endif + + /* Run auto-tuning activities */ + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN)) + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + { + Cy_CapSense_RunNoiseEnvelope_Lib(ptrSnsCxtSns->raw, ptrWdCfg->ptrWdContext->sigPFC, ptrNEHistory); + Cy_CapSense_DpUpdateThresholds(ptrWdCfg->ptrWdContext, ptrNEHistory, snsIndex); + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) + if ((uint8_t)CY_CAPSENSE_WD_PROXIMITY_E == ptrWdCfg->wdType) + { + ptrWdCfg->ptrWdContext->proxTh = ptrWdCfg->ptrWdContext->fingerTh; + ptrWdCfg->ptrWdContext->fingerTh = (uint16_t)(((uint32_t)ptrWdCfg->ptrWdContext->fingerTh * + context->ptrCommonConfig->proxTouchCoeff) / CY_CAPSENSE_PERCENTAGE_100); + } + #endif + ptrNEHistory++; + } + #endif + result |= Cy_CapSense_FtUpdateBaseline(ptrWdCfg->ptrWdContext, ptrSnsCxtSns, ptrBslnInvSns, context); Cy_CapSense_DpUpdateDifferences(ptrWdCfg->ptrWdContext, ptrSnsCxtSns); + ptrSnsCxtSns++; ptrBslnInvSns++; ptrHistorySns += snsHistorySize; - if(NULL != ptrHistoryLowSns) + if (NULL != ptrHistoryLowSns) { ptrHistoryLowSns++; } } } - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN)) ptrSnsCxtSns = ptrWdCfg->ptrSnsContext; for (snsIndex = ptrWdCfg->numSns; snsIndex-- > 0u;) { @@ -480,13 +539,16 @@ uint32_t Cy_CapSense_DpProcessCsxWidgetRawCounts( } #endif - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) - (void) Cy_CapSense_RunMfsMedian(widgetId, context); + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) && \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP))) + (void)Cy_CapSense_RunMfsMedian(widgetId, context); #endif return result; } + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpProcessCsxWidgetStatus ****************************************************************************//** @@ -508,21 +570,21 @@ void Cy_CapSense_DpProcessCsxWidgetStatus( { switch (ptrWdConfig->wdType) { - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_BUTTON_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN)) + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_BUTTON_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN)) case (uint8_t)CY_CAPSENSE_WD_BUTTON_E: case (uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E: Cy_CapSense_DpProcessButton(ptrWdConfig); break; #endif - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_LINEAR_SLIDER_EN) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_LINEAR_SLIDER_EN) case (uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E: Cy_CapSense_DpProcessSlider(ptrWdConfig); break; #endif - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) case (uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E: Cy_CapSense_DpProcessCsxTouchpad(ptrWdConfig); break; @@ -533,205 +595,128 @@ void Cy_CapSense_DpProcessCsxWidgetStatus( break; } } +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) /******************************************************************************* -* Function Name: Cy_CapSense_DpProcessCsxSensorRawCountsExt +* Function Name: Cy_CapSense_DpProcessCsdWidgetStatus ****************************************************************************//** * -* Performs customized processing of the CSX sensor raw counts. +* Updates the status of the CSD widget in the Data Structure. * -* If all bits are set at once, the default processing order will take place. -* For a custom order, this function can be called multiple times and execute -* one task at a time. +* This function determines the type of widget and runs the appropriate function +* that implements the status update algorithm for this type of widget. +* +* When the widget-specific processing completes this function updates the +* sensor and widget status registers in the data structure. * * \param ptrWdConfig * The pointer to the widget configuration structure. * -* \param ptrSnsContext -* The pointer to the sensor context structure. -* -* \param ptrSnsRawHistory -* The pointer to the filter history. -* -* \param ptrSnsRawHistoryLow -* The pointer to the extended filter history. -* -* \param mode -* The bit-mask with the data processing tasks to be executed. -* The mode parameters can take the following values: -* - CY_CAPSENSE_PROCESS_FILTER (0x01) Run Firmware Filter -* - CY_CAPSENSE_PROCESS_BASELINE (0x02) Update Baselines -* - CY_CAPSENSE_PROCESS_DIFFCOUNTS (0x04) Update Difference Counts -* - CY_CAPSENSE_PROCESS_ALL Execute all tasks -* -* \param ptrSnsBslnInv -* The pointer to the sensor baseline inversion used for BIST if enabled. -* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * -* \return -* Returns the status of the specified sensor processing operation: -* - CY_CAPSENSE_STATUS_SUCCESS if operation was successfully completed; -* - Non-zero - if baseline processing of any -* sensor of the specified widget failed. The result is concatenated with the index -* of failed sensor. -* *******************************************************************************/ -uint32_t Cy_CapSense_DpProcessCsxSensorRawCountsExt( +void Cy_CapSense_DpProcessCsdWidgetStatus( const cy_stc_capsense_widget_config_t * ptrWdConfig, - cy_stc_capsense_sensor_context_t * ptrSnsContext, - uint16_t * ptrSnsRawHistory, - uint8_t * ptrSnsRawHistoryLow, - uint32_t mode, - uint16_t * ptrSnsBslnInv, - const cy_stc_capsense_context_t * context) + cy_stc_capsense_context_t * context) { - uint32_t result = CY_CAPSENSE_STATUS_SUCCESS; - cy_stc_capsense_widget_context_t * ptrWdCxt = ptrWdConfig->ptrWdContext; + (void)context; + switch (ptrWdConfig->wdType) + { + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_BUTTON_EN) + case (uint8_t)CY_CAPSENSE_WD_BUTTON_E: + Cy_CapSense_DpProcessButton(ptrWdConfig); + break; + #endif - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_RAWCOUNT_FILTER_EN) - if (0u != (mode & CY_CAPSENSE_PROCESS_FILTER)) - { - Cy_CapSense_FtRunEnabledFiltersInternal(ptrWdConfig, - ptrSnsContext, - ptrSnsRawHistory, - ptrSnsRawHistoryLow); - } - #else - (void)ptrSnsRawHistory; - (void)ptrSnsRawHistoryLow; - #endif + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_SLIDER_EN) + case (uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E: + case (uint8_t)CY_CAPSENSE_WD_RADIAL_SLIDER_E: + Cy_CapSense_DpProcessSlider(ptrWdConfig); + break; + #endif - if (0u != (mode & CY_CAPSENSE_PROCESS_BASELINE)) - { - result = Cy_CapSense_FtUpdateBaseline(ptrWdCxt, ptrSnsContext, ptrSnsBslnInv, context); - } - if (0u != (mode & CY_CAPSENSE_PROCESS_DIFFCOUNTS)) - { - Cy_CapSense_DpUpdateDifferences(ptrWdCxt, ptrSnsContext); - } + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) + case (uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E: + Cy_CapSense_DpProcessCsdMatrix(ptrWdConfig); + break; + #endif - return result; + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) + case (uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E: + Cy_CapSense_DpProcessCsdTouchpad(ptrWdConfig, context); + break; + #endif + + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) + case (uint8_t)CY_CAPSENSE_WD_PROXIMITY_E: + Cy_CapSense_DpProcessProximity(ptrWdConfig); + break; + #endif + + default: + /* No other widget types */ + break; + } } -#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) /******************************************************************************* -* Function Name: Cy_CapSense_DpProcessCsdWidgetRawCounts +* Function Name: Cy_CapSense_DpProcessIsxWidgetStatus ****************************************************************************//** * -* Performs default processing of the raw counts of the specified CSD widget. +* Updates the status of the ISX widget in the Data Structure. * -* The processing includes the following tasks: -* - Run Filters. -* - Update Baselines. -* - Update Differences. -* The same process is applied to all the sensors of the specified widget. -* -* \param widgetId -* Specifies the ID number of the widget. A macro for the widget ID can be found -* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* This function determines the type of widget and runs the appropriate function +* that implements the status update algorithm for this type of widget. * -* \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* When the widget-specific processing completes this function updates the +* sensor and widget status registers in the data structure. * -* \return -* Returns the status of the specified widget processing operation: -* - Zero - if operation was successfully completed. -* - Non-zero - if baseline processing of any sensor of the specified widget -* failed. The result is concatenated with the index of failed sensor. +* \param ptrWdConfig +* The pointer to the widget configuration structure. * *******************************************************************************/ -uint32_t Cy_CapSense_DpProcessCsdWidgetRawCounts( - uint32_t widgetId, - const cy_stc_capsense_context_t * context) +void Cy_CapSense_DpProcessIsxWidgetStatus( + const cy_stc_capsense_widget_config_t * ptrWdConfig) { - uint32_t result = CY_CAPSENSE_STATUS_SUCCESS; - uint32_t snsIndex; - uint32_t snsHistorySize; - uint32_t freqChIndex; - uint16_t * ptrHistorySns; - uint16_t * ptrBslnInvSns; - uint8_t * ptrHistoryLowSns = NULL; - cy_stc_capsense_sensor_context_t * ptrSnsCxtSns; - const cy_stc_capsense_widget_config_t * ptrWdCfg; - - ptrWdCfg = &context->ptrWdConfig[widgetId]; - - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) - cy_stc_capsense_smartsense_csd_noise_envelope_t * ptrNEHistory = ptrWdCfg->ptrNoiseEnvelope; - #endif - - snsHistorySize = (uint32_t)ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_SNS_HISTORY_SIZE_MASK; - - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + switch (ptrWdConfig->wdType) { - ptrSnsCxtSns = &ptrWdCfg->ptrSnsContext[freqChIndex * context->ptrCommonConfig->numSns]; - ptrBslnInvSns = &ptrWdCfg->ptrBslnInv[freqChIndex * context->ptrCommonConfig->numSns]; - ptrHistorySns = &ptrWdCfg->ptrRawFilterHistory[freqChIndex * (CY_CAPSENSE_RAW_HISTORY_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; - if(CY_CAPSENSE_IIR_FILTER_PERFORMANCE == (ptrWdCfg->rawFilterConfig & CY_CAPSENSE_RC_FILTER_IIR_MODE_MASK)) - { - ptrHistoryLowSns = &ptrWdCfg->ptrRawFilterHistoryLow[freqChIndex * - (CY_CAPSENSE_IIR_HISTORY_LOW_SIZE / CY_CAPSENSE_CONFIGURED_FREQ_NUM)]; - } + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_ISX_BUTTON_EN) + case (uint8_t)CY_CAPSENSE_WD_BUTTON_E: + Cy_CapSense_DpProcessButton(ptrWdConfig); + break; + #endif - for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) - { - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_RAWCOUNT_FILTER_EN) - Cy_CapSense_FtRunEnabledFiltersInternal(ptrWdCfg, ptrSnsCxtSns, ptrHistorySns, ptrHistoryLowSns); - #endif - /* Run auto-tuning activities */ - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) - Cy_CapSense_RunNoiseEnvelope_Lib(ptrSnsCxtSns->raw, ptrWdCfg->ptrWdContext->sigPFC, ptrNEHistory); - Cy_CapSense_DpUpdateThresholds(ptrWdCfg->ptrWdContext, ptrNEHistory, snsIndex); - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) - if ((uint8_t)CY_CAPSENSE_WD_PROXIMITY_E == ptrWdCfg->wdType) - { - ptrWdCfg->ptrWdContext->proxTh = (uint16_t)(((uint32_t)ptrWdCfg->ptrWdContext->fingerTh * - context->ptrCommonConfig->proxTouchCoeff) / CY_CAPSENSE_PERCENTAGE_100); - } - #endif - ptrNEHistory++; - #endif + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_ISX_LINEAR_SLIDER_EN) + case (uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E: + Cy_CapSense_DpProcessSlider(ptrWdConfig); + break; + #endif - result |= Cy_CapSense_FtUpdateBaseline(ptrWdCfg->ptrWdContext, ptrSnsCxtSns, ptrBslnInvSns, context); - Cy_CapSense_DpUpdateDifferences(ptrWdCfg->ptrWdContext, ptrSnsCxtSns); + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_ISX_PROXIMITY_EN) + case (uint8_t)CY_CAPSENSE_WD_PROXIMITY_E: + Cy_CapSense_DpProcessProximity(ptrWdConfig); + break; + #endif - ptrSnsCxtSns++; - ptrBslnInvSns++; - ptrHistorySns += snsHistorySize; - if(NULL != ptrHistoryLowSns) - { - ptrHistoryLowSns++; - } - } + default: + /* No other widget types */ + break; } - - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) - ptrSnsCxtSns = ptrWdCfg->ptrSnsContext; - for (snsIndex = ptrWdCfg->numSns; snsIndex-- > 0u;) - { - Cy_CapSense_RunMfsFiltering(ptrSnsCxtSns, context); - ptrSnsCxtSns++; - } - #endif - - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) - (void) Cy_CapSense_RunMfsMedian(widgetId, context); - #endif - - return result; } +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ /******************************************************************************* -* Function Name: Cy_CapSense_DpProcessCsdSensorRawCountsExt +* Function Name: Cy_CapSense_DpProcessSensorRawCountsExt ****************************************************************************//** * -* Performs customized processing of the CSX sensor raw counts. +* Performs customized processing of the sensor raw counts. * * If all bits are set at once, the default processing order will take place. * For a custom order, this function can be called multiple times and execute @@ -755,11 +740,9 @@ uint32_t Cy_CapSense_DpProcessCsdWidgetRawCounts( * - CY_CAPSENSE_PROCESS_FILTER (0x01) Run Firmware Filter * - CY_CAPSENSE_PROCESS_BASELINE (0x02) Update Baselines * - CY_CAPSENSE_PROCESS_DIFFCOUNTS (0x04) Update Difference Counts -* - CY_CAPSENSE_PROCESS_CALC_NOISE (0x08) Calculate Noise (only if FW Tuning is enabled) -* - CY_CAPSENSE_PROCESS_THRESHOLDS (0x10) Update Thresholds (only if FW Tuning is enabled) * - CY_CAPSENSE_PROCESS_ALL Execute all tasks * -* \param ptrBslnInvSns +* \param ptrSnsBslnInv * The pointer to the sensor baseline inversion used for BIST if enabled. * * \param context @@ -767,19 +750,20 @@ uint32_t Cy_CapSense_DpProcessCsdWidgetRawCounts( * * \return * Returns the status of the specified sensor processing operation: -* - CY_CAPSENSE_STATUS_SUCCESS if operation was successfully completed. -* - CY_CAPSENSE_STATUS_BAD_DATA if baseline processing of any sensor of the specified widget -* failed. +* - CY_CAPSENSE_STATUS_SUCCESS if operation was successfully completed; +* - Non-zero - if baseline processing of any +* sensor of the specified widget failed. The result is concatenated with the index +* of failed sensor. * *******************************************************************************/ -uint32_t Cy_CapSense_DpProcessCsdSensorRawCountsExt( - const cy_stc_capsense_widget_config_t * ptrWdConfig, - cy_stc_capsense_sensor_context_t * ptrSnsContext, - uint16_t * ptrSnsRawHistory, - uint8_t * ptrSnsRawHistoryLow, - uint32_t mode, - uint16_t * ptrBslnInvSns, - const cy_stc_capsense_context_t * context) +uint32_t Cy_CapSense_DpProcessSensorRawCountsExt( + const cy_stc_capsense_widget_config_t * ptrWdConfig, + cy_stc_capsense_sensor_context_t * ptrSnsContext, + uint16_t * ptrSnsRawHistory, + uint8_t * ptrSnsRawHistoryLow, + uint32_t mode, + uint16_t * ptrSnsBslnInv, + const cy_stc_capsense_context_t * context) { uint32_t result = CY_CAPSENSE_STATUS_SUCCESS; cy_stc_capsense_widget_context_t * ptrWdCxt = ptrWdConfig->ptrWdContext; @@ -797,7 +781,7 @@ uint32_t Cy_CapSense_DpProcessCsdSensorRawCountsExt( if (0u != (mode & CY_CAPSENSE_PROCESS_BASELINE)) { - result = Cy_CapSense_FtUpdateBaseline(ptrWdCxt, ptrSnsContext, ptrBslnInvSns, context); + result = Cy_CapSense_FtUpdateBaseline(ptrWdCxt, ptrSnsContext, ptrSnsBslnInv, context); } if (0u != (mode & CY_CAPSENSE_PROCESS_DIFFCOUNTS)) { @@ -807,70 +791,6 @@ uint32_t Cy_CapSense_DpProcessCsdSensorRawCountsExt( return result; } -/******************************************************************************* -* Function Name: Cy_CapSense_DpProcessCsdWidgetStatus -****************************************************************************//** -* -* Updates the status of the CSD widget in the Data Structure. -* -* This function determines the type of widget and runs the appropriate function -* that implements the status update algorithm for this type of widget. -* -* When the widget-specific processing completes this function updates the -* sensor and widget status registers in the data structure. -* -* \param ptrWdConfig -* The pointer to the widget configuration structure. -* -* \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. -* -*******************************************************************************/ -void Cy_CapSense_DpProcessCsdWidgetStatus( - const cy_stc_capsense_widget_config_t * ptrWdConfig, - cy_stc_capsense_context_t * context) -{ - (void)context; - switch (ptrWdConfig->wdType) - { - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_BUTTON_EN) - case (uint8_t)CY_CAPSENSE_WD_BUTTON_E: - Cy_CapSense_DpProcessButton(ptrWdConfig); - break; - #endif - - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_SLIDER_EN) - case (uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E: - case (uint8_t)CY_CAPSENSE_WD_RADIAL_SLIDER_E: - Cy_CapSense_DpProcessSlider(ptrWdConfig); - break; - #endif - - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) - case (uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E: - Cy_CapSense_DpProcessCsdMatrix(ptrWdConfig); - break; - #endif - - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) - case (uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E: - Cy_CapSense_DpProcessCsdTouchpad(ptrWdConfig, context); - break; - #endif - - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) - case (uint8_t)CY_CAPSENSE_WD_PROXIMITY_E: - Cy_CapSense_DpProcessProximity(ptrWdConfig); - break; - #endif - - default: - /* No other widget types */ - break; - } -} -#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ - /******************************************************************************* * Function Name: Cy_CapSense_DpUpdateThresholds @@ -940,14 +860,14 @@ void Cy_CapSense_DpUpdateDifferences( } -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_BUTTON_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN)) +#if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_BUTTON_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN)) /******************************************************************************* * Function Name: Cy_CapSense_DpProcessButton ****************************************************************************//** * * Processes the status of the Button widget. * -* This function processes the status of the CSD/CSX Button widget and +* This function processes the status of the CSD/CSX/ISX Button widget and * CSX Matrix Button widget. It applies the hysteresis and debounce algorithm * to each sensor difference value. This function is expected to be called * after each new widget scan. If it is called multiple times for the same @@ -963,7 +883,7 @@ void Cy_CapSense_DpProcessButton( uint32_t snsIndex; uint32_t activeCount = 0u; uint32_t touchTh; - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN) uint32_t startIndex = 0u; #endif @@ -1000,7 +920,7 @@ void Cy_CapSense_DpProcessButton( { ptrSnsCxt->status = CY_CAPSENSE_SNS_TOUCH_STATUS_MASK; activeCount++; - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN) startIndex = snsIndex; #endif } @@ -1015,7 +935,7 @@ void Cy_CapSense_DpProcessButton( ptrDebounceCnt++; } /* Update position struct */ - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN) if (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdConfig->wdType) && (CY_CAPSENSE_CSX_GROUP == ptrWdConfig->senseMethod)) { @@ -1029,7 +949,7 @@ void Cy_CapSense_DpProcessButton( #endif /* ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_BUTTON_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN)) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_PROXIMITY_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpProcessProximity ****************************************************************************//** @@ -1066,16 +986,16 @@ void Cy_CapSense_DpProcessProximity(const cy_stc_capsense_widget_config_t * ptrW for (snsIndex = 0u; snsIndex < ((uint32_t)ptrWdConfig->numSns << 1u); snsIndex++) { /* - * Proximity - odd; Touch - even. Example: - * Bit 0 -> touch event - * Bit 1 -> proximity event + * Proximity - even; Touch - odd. Example: + * Bit [1] indicates that a touch is detected. + * Bit [0] indicates that a proximity is detected. */ - snsTh = ptrWdCxt->proxTh; - snsStMask = CY_CAPSENSE_SNS_PROX_STATUS_MASK; + snsTh = ptrWdCxt->fingerTh; + snsStMask = CY_CAPSENSE_SNS_TOUCH_PROX_STATUS_MASK; if (0u == (snsIndex & 0x01u)) { - snsTh = ptrWdCxt->fingerTh; - snsStMask = CY_CAPSENSE_SNS_TOUCH_STATUS_MASK; + snsTh = ptrWdCxt->proxTh; + snsStMask = CY_CAPSENSE_SNS_PROX_STATUS_MASK; } /* Calculate threshold based on current sensor state */ snsTh = (0u == (snsStMask & ptrSnsCxt->status)) ? @@ -1115,10 +1035,10 @@ void Cy_CapSense_DpProcessProximity(const cy_stc_capsense_widget_config_t * ptrW ptrDebounceCnt++; } } -#endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) */ +#endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_PROXIMITY_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpProcessSlider ****************************************************************************//** @@ -1202,17 +1122,15 @@ void Cy_CapSense_DpProcessSlider( { switch (ptrWdConfig->wdType) { - #if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_RADIAL_SLIDER_EN) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_RADIAL_SLIDER_EN) case (uint8_t)CY_CAPSENSE_WD_RADIAL_SLIDER_E: Cy_CapSense_DpCentroidRadial(&newTouch, ptrWdConfig); break; #endif - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_LINEAR_SLIDER_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_LINEAR_SLIDER_EN)) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_LINEAR_SLIDER_EN) case (uint8_t)CY_CAPSENSE_WD_LINEAR_SLIDER_E: - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_DIPLEX_SLIDER_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_DIPLEX_SLIDER_EN)) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_DIPLEX_SLIDER_EN) if ((0u != (ptrWdConfig->centroidConfig & CY_CAPSENSE_DIPLEXING_MASK))) { /* Run local maximum search for diplexed slider */ @@ -1252,7 +1170,7 @@ void Cy_CapSense_DpProcessSlider( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpProcessCsdMatrix ****************************************************************************//** @@ -1377,7 +1295,7 @@ void Cy_CapSense_DpProcessCsdMatrix( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpProcessCsdTouchpad ****************************************************************************//** @@ -1514,13 +1432,13 @@ void Cy_CapSense_DpProcessCsdTouchpad( ptrWdCxt->yDelta = delta.deltaY; } #else - (void) context; + (void)context; #endif } #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) */ -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) /******************************************************************************* * Function Name: Cy_CapSense_DpProcessCsxTouchpad ****************************************************************************//** @@ -1563,7 +1481,8 @@ void Cy_CapSense_DpProcessCsxTouchpad( } #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) */ -#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN)) /******************************************************************************* * Function Name: Cy_CapSense_RunMfsFiltering ****************************************************************************//** @@ -1587,18 +1506,20 @@ void Cy_CapSense_RunMfsFiltering( } #endif -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) -#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED) + +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED)) /******************************************************************************* -* Function Name: Cy_CapSense_ProcessWidgetMptxDeconvolution +* Function Name: Cy_CapSense_ProcessWidgetMpDeconvolution ****************************************************************************//** * -* Performs raw count deconvolution for the specified CSX widget when -* Multi-phase Tx is enabled. +* Performs raw count deconvolution for the specified widget: +* * CSD - when multi-phase Self is enabled +* * CSX - when multi-phase Tx is enabled * * This function decodes raw counts received after scanning into normal view by * performing deconvolution algorithm. If the function is called for a widget with -* disabled Multi-phase Tx, the function returns CY_CAPSENSE_STATUS_BAD_DATA. +* disabled multi-phase, the function returns CY_CAPSENSE_STATUS_BAD_DATA. * * No need to call this function from application layer since the * Cy_CapSense_ProcessAllWidgets() and Cy_CapSense_ProcessWidget() functions calls @@ -1606,8 +1527,8 @@ void Cy_CapSense_RunMfsFiltering( * * DAC auto-calibration when enabled performs sensor auto-calibration without * performing deconvolution. -* The deconvolution algorithm for even number of TX electrodes decreases raw count -* level twice (keeping the signal on the same level). +* For the CSX widgets, the deconvolution algorithm for even number of TX electrodes +* decreases raw count level twice (keeping the signal on the same level). * * If specific processing is implemented using the Cy_CapSense_ProcessWidgetExt() * and Cy_CapSense_ProcessSensorExt() function then a call of this function is @@ -1623,82 +1544,162 @@ void Cy_CapSense_RunMfsFiltering( * Returns the status of the processing operation. * *******************************************************************************/ -cy_capsense_status_t Cy_CapSense_ProcessWidgetMptxDeconvolution( +cy_capsense_status_t Cy_CapSense_ProcessWidgetMpDeconvolution( uint32_t widgetId, cy_stc_capsense_context_t * context) { const cy_stc_capsense_widget_config_t * ptrWdCfg; uint32_t idx; uint32_t sumIdx; - uint32_t ceIdx; uint32_t rotIdx; - /* Order of multi-TX sequence */ - uint32_t mptxOrderLocal; - int32_t localBuf[CY_CAPSENSE_MPTX_MAX_ORDER]; - int16_t deconvCoefRot[CY_CAPSENSE_MAX_TX_PATTERN_NUM * 2u]; + uint32_t snsIdx = 0u; + int32_t localBuf[CY_CAPSENSE_MULTIPHASE_MAX_ORDER]; + int16_t deconvCoefRot[CY_CAPSENSE_MULTIPHASE_MAX_ORDER * 4u]; + int16_t * ptrDeconvTable = &deconvCoefRot[0u]; int32_t accum; - uint32_t accumTmp; cy_capsense_status_t result = CY_CAPSENSE_STATUS_BAD_DATA; uint32_t freqChIndex; + uint32_t mpOrderLocal; + cy_stc_capsense_mp_table_t * ptrMpTable; + uint32_t accumTmp; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + int32_t accum_raw[CY_CAPSENSE_MPSC_MAX_ORDER]; + int32_t diff_buff[CY_CAPSENSE_MPSC_MAX_ORDER]; + int32_t min_diff; + int32_t sign; + #endif ptrWdCfg = &context->ptrWdConfig[widgetId]; - mptxOrderLocal = ptrWdCfg->mptxOrder; - if (mptxOrderLocal >= CY_CAPSENSE_MPTX_MIN_ORDER) + mpOrderLocal = ptrWdCfg->mpOrder; + ptrMpTable = ptrWdCfg->ptrMpTable; + + if (mpOrderLocal >= CY_CAPSENSE_MPTX_MIN_ORDER) { result = CY_CAPSENSE_STATUS_SUCCESS; - (void)memcpy(&deconvCoefRot[0], (const void *)&ptrWdCfg->ptrMptxTable->deconvCoef[0u], mptxOrderLocal * CY_CAPSENSE_BYTES_IN_16_BITS); - (void)memcpy(&deconvCoefRot[mptxOrderLocal], (const void *)&ptrWdCfg->ptrMptxTable->deconvCoef[0u], mptxOrderLocal * CY_CAPSENSE_BYTES_IN_16_BITS); + (void)memcpy((void *)&deconvCoefRot[0u], (const void *)&ptrMpTable->deconvCoef[0u], mpOrderLocal * CY_CAPSENSE_BYTES_IN_16_BITS); + (void)memcpy((void *)&deconvCoefRot[mpOrderLocal], (const void *)&ptrMpTable->deconvCoef[0u], mpOrderLocal * CY_CAPSENSE_BYTES_IN_16_BITS); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + { + ptrMpTable++; + (void)memcpy((void *)&deconvCoefRot[CY_CAPSENSE_MPSC_MAX_ORDER * 2u], (const void *)&ptrMpTable->deconvCoef[0u], ptrWdCfg->mpOrderRows * CY_CAPSENSE_BYTES_IN_16_BITS); + (void)memcpy((void *)&deconvCoefRot[(CY_CAPSENSE_MPSC_MAX_ORDER * 2u) + ptrWdCfg->mpOrderRows], (const void *)&ptrMpTable->deconvCoef[0u], ptrWdCfg->mpOrderRows * CY_CAPSENSE_BYTES_IN_16_BITS); + } + #endif - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { - ceIdx = (uint32_t)ptrWdCfg->numRows * ptrWdCfg->numCols; - while (ceIdx >= mptxOrderLocal) + while (snsIdx < ptrWdCfg->numSns) { - ceIdx -= mptxOrderLocal; - /* Copy vector formed by RX[rxIdx] and TX[txIdx..txIdx+mptxOrderLocal] - * from sensors to localBuf */ - idx = mptxOrderLocal; - while (0u != idx--) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + { + if (snsIdx >= ptrWdCfg->numCols) + { + ptrDeconvTable = &deconvCoefRot[CY_CAPSENSE_MPSC_MAX_ORDER * 2u]; + mpOrderLocal = ptrWdCfg->mpOrderRows; + } + } + #endif + + /* Copy vector from sensors to localBuf */ + for (idx = 0u; idx < mpOrderLocal; idx++) { - localBuf[idx] = (int32_t)ptrWdCfg->ptrSnsContext[idx + ceIdx + + localBuf[idx] = (int32_t)ptrWdCfg->ptrSnsContext[idx + snsIdx + (context->ptrCommonConfig->numSns * freqChIndex)].raw; } - /* Multiply vector stored in localBuf by the matrix of deconvolution coefficients. */ - idx = mptxOrderLocal; - while (0u != idx--) + /* Multiply vector stored in localBuf by the matrix of deconvolution coefficients */ + idx = 0u; + while (idx < mpOrderLocal) { accum = 0; - rotIdx = idx + mptxOrderLocal - 1u; - sumIdx = mptxOrderLocal; - while (0u != sumIdx--) + rotIdx = idx; + sumIdx = 0u; + while (sumIdx < mpOrderLocal) { - accum += localBuf[sumIdx] * deconvCoefRot[rotIdx]; - rotIdx--; + accum += localBuf[sumIdx] * ptrDeconvTable[rotIdx]; + sumIdx++; + rotIdx++; } - if (0 > accum) - { - accumTmp = 0u; - } - else + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + { + sign = (0 > accum) ? -1 : 1; + accum *= sign; + accumTmp = (uint32_t)accum; + + /* Shift the result in such a way that guarantees no overflow */ + accumTmp >>= CY_CAPSENSE_SCALING_SHIFT; + + /* Store to the temporary signed raw counts buffer */ + accum_raw[idx+snsIdx] = (int32_t)accumTmp; + accum_raw[idx+snsIdx] *= sign; + } + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) + if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) + { + if (0 > accum) + { + accumTmp = 0u; + } + else + { + accumTmp = (uint32_t)accum; + + /* Shift the result in such a way that guarantees no overflow */ + accumTmp >>= CY_CAPSENSE_SCALING_SHIFT; + + if ((uint32_t)UINT16_MAX < accumTmp) + { + accumTmp = UINT16_MAX; + } + } + + /* Convert the result to unsigned 16 bit and store in the target buffer */ + ptrWdCfg->ptrSnsContext[idx + snsIdx + + (context->ptrCommonConfig->numSns * freqChIndex)].raw = (uint16_t)accumTmp; + } + #endif /* CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED */ + + idx++; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) { - accumTmp = (uint32_t)accum; + /* Calculate diff counts */ + for (idx = 0u; idx < mpOrderLocal; idx++) + { + diff_buff[idx] = accum_raw[idx+snsIdx] - (int32_t)ptrWdCfg->ptrSnsContext[idx+snsIdx].bsln; + } - /* Shift the result in such a way that guarantees no overflow */ - accumTmp >>= CY_CAPSENSE_SCALING_SHIFT; + /* Find the lowest diff value */ + min_diff = diff_buff[0u]; + for (idx = 1u; idx < mpOrderLocal; idx++) + { + if (min_diff > diff_buff[idx]) + { + min_diff = diff_buff[idx]; + } + } - if ((uint32_t)UINT16_MAX < accumTmp) + /* Apply multi-phase sum0 alignment */ + for (idx = 0u; idx < mpOrderLocal; idx++) { - accumTmp = UINT16_MAX; + accum_raw[idx+snsIdx] -= min_diff; + ptrWdCfg->ptrSnsContext[idx+snsIdx].raw = (uint16_t)accum_raw[idx+snsIdx]; } } + #endif - /* Convert the result to unsigned 16 bit and store in the target buffer */ - ptrWdCfg->ptrSnsContext[idx + ceIdx + - (context->ptrCommonConfig->numSns * freqChIndex)].raw = (uint16_t)accumTmp; - } + snsIdx += mpOrderLocal; } } } @@ -1714,11 +1715,10 @@ cy_capsense_status_t Cy_CapSense_ProcessWidgetMptxDeconvolution( * Executes the pre-processing of scan raw data for specified widgets. * * This function is called prior any other processing function for -* the fifth CAPSENSE™ HW generation. The pre-processing routine implements -* the following operations: -* - Executes the CIC2 pre-processing if the filter mode is set to CIC2. +* the fifth CAPSENSE™ and fifth low power CAPSENSE™ HW generation. +* The pre-processing routine implements the following operations: * - Limits raw count to maximum value. -* - Executes the raw data inversion for the CSX sensors. +* - Executes the raw data inversion for the CSX ans ISX sensors. * * No need to call this function from application layer since the * Cy_CapSense_ProcessAllWidgets() and Cy_CapSense_ProcessWidget() functions @@ -1726,13 +1726,16 @@ cy_capsense_status_t Cy_CapSense_ProcessWidgetMptxDeconvolution( * * If specific processing is implemented using the Cy_CapSense_ProcessWidgetExt() * and Cy_CapSense_ProcessSensorExt() function then a call of this function is -* required prior doing the specific processing. If Multi-phase TX is enabled +* required prior doing the specific processing. If Multi-phase is enabled * then deconvolution should be executed after call of this function using -* the Cy_CapSense_ProcessWidgetMptxDeconvolution() function. +* the Cy_CapSense_ProcessWidgetMpDeconvolution() function. * * \param widgetId * The widget ID, for which the pre-processing should be executed. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -1741,21 +1744,30 @@ void Cy_CapSense_PreProcessWidget( uint32_t widgetId, const cy_stc_capsense_context_t * context) { - /* Adjusts raw count if CIC2 enabled */ - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) - Cy_CapSense_PreProcessWidgetCic2Raw(widgetId, context); - #endif - - /* Limit raw count to the maximum possible raw count value */ - Cy_CapSense_PreProcessWidgetLimitRaw(widgetId, context); - - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - /* Inverts raw count for CSX widgets */ - if(CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) - { - Cy_CapSense_PreProcessWidgetInvertRaw(widgetId, context); - } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; + #endif /* Suppress possible compiler warning */ + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + { + /* Limit raw count to the maximum possible raw count value */ + Cy_CapSense_PreProcessWidgetLimitRaw(widgetId, context); + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) + /* Inverts raw count for CSX widgets */ + if ((CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) || + (CY_CAPSENSE_ISX_GROUP == ptrWdCfg->senseMethod)) + { + Cy_CapSense_PreProcessWidgetInvertRaw(widgetId, context); + } + #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) */ + } } @@ -1766,11 +1778,10 @@ void Cy_CapSense_PreProcessWidget( * Executes the pre-processing of scan raw data for specified sensor. * * This function is called prior any other processing function for -* the fifth CAPSENSE™ HW generation. The pre-processing routine implements -* the following operations: -* - Executes the CIC2 pre-processing if the filter mode is set to CIC2. +* the fifth CAPSENSE™ and fifth low power HW generation. +* The pre-processing routine implements the following operations: * - Limits raw count to maximum value. -* - Executes the raw data inversion for the CSX sensors. +* - Executes the raw data inversion for the CSX and ISX sensors. * * No need to call this function from application layer since the * Cy_CapSense_ProcessAllWidgets() and Cy_CapSense_ProcessWidget() functions @@ -1778,14 +1789,17 @@ void Cy_CapSense_PreProcessWidget( * * If specific processing is implemented using the Cy_CapSense_ProcessWidgetExt() * and Cy_CapSense_ProcessSensorExt() function then a call of this function is -* required prior doing the specific processing. If Multi-phase TX is enabled +* required prior doing the specific processing. If Multi-phase is enabled * then deconvolution should be executed after pre-processing of all sensors -* of the specified widget using the Cy_CapSense_ProcessWidgetMptxDeconvolution() +* of the specified widget using the Cy_CapSense_ProcessWidgetMpDeconvolution() * function. * * \param widgetId * The widget ID, for which the pre-processing should be executed. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed. +* * \param sensorId * The sensor ID, for which the pre-processing should be executed. * @@ -1798,21 +1812,30 @@ void Cy_CapSense_PreProcessSensor( uint32_t sensorId, const cy_stc_capsense_context_t * context) { - /* Adjusts raw count if CIC2 enabled */ - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) - Cy_CapSense_PreProcessSensorCic2Raw(widgetId, sensorId, context); - #endif - - /* Limit raw count to the maximum possible raw count value */ - Cy_CapSense_PreProcessSensorLimitRaw(widgetId, sensorId, context); - - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - /* Inverts raw count for CSX widgets */ - if(CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) - { - Cy_CapSense_PreProcessSensorInvertRaw(widgetId, sensorId, context); - } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; + #endif /* Suppress possible compiler warning */ + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + { + /* Limit raw count to the maximum possible raw count value */ + Cy_CapSense_PreProcessSensorLimitRaw(widgetId, sensorId, context); + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) + /* Inverts raw count for CSX widgets */ + if ((CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) || + (CY_CAPSENSE_ISX_GROUP == ptrWdCfg->senseMethod)) + { + Cy_CapSense_PreProcessSensorInvertRaw(widgetId, sensorId, context); + } + #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) */ + } } @@ -1840,7 +1863,7 @@ void Cy_CapSense_PreProcessWidgetLimitRaw( cy_stc_capsense_sensor_context_t * ptrSnsCxt = &ptrWdCfg->ptrSnsContext[0u]; uint32_t maxCount = ptrWdCfg->ptrWdContext->maxRawCount; - for(snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && (ptrWdCfg->numCols <= snsIndex)) @@ -1849,7 +1872,7 @@ void Cy_CapSense_PreProcessWidgetLimitRaw( } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ - if((uint32_t)ptrSnsCxt->raw > maxCount) + if ((uint32_t)ptrSnsCxt->raw > maxCount) { ptrSnsCxt->raw = (uint16_t)maxCount; } @@ -1892,14 +1915,15 @@ void Cy_CapSense_PreProcessSensorLimitRaw( } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ - if((uint32_t)ptrSnsCxt->raw > maxCount) + if ((uint32_t)ptrSnsCxt->raw > maxCount) { ptrSnsCxt->raw = (uint16_t)maxCount; } } -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) /******************************************************************************* * Function Name: Cy_CapSense_PreProcessWidgetInvertRaw ****************************************************************************//** @@ -1923,7 +1947,7 @@ void Cy_CapSense_PreProcessWidgetInvertRaw( cy_stc_capsense_sensor_context_t * ptrSnsCxt = &ptrWdCfg->ptrSnsContext[0u]; uint32_t maxCount = ptrWdCfg->ptrWdContext->maxRawCount; - for(snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) { ptrSnsCxt->raw = (uint16_t)(maxCount - ptrSnsCxt->raw); ptrSnsCxt++; @@ -1959,187 +1983,12 @@ void Cy_CapSense_PreProcessSensorInvertRaw( ptrSnsCxt->raw = (uint16_t)(maxCount - ptrSnsCxt->raw); } -#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ - - -#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) -/******************************************************************************* -* Function Name: Cy_CapSense_PreProcessWidgetCic2Raw -****************************************************************************//** -* -* This internal function executes the pre-processing -* of raw data, for specified widgets produced by the fifth CAPSENSE™ HW generation with the -* filter mode set to CIC2. -* -* \param widgetId -* The widget ID, for which the pre-processing should be executed. -* -* \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. -* -*******************************************************************************/ -void Cy_CapSense_PreProcessWidgetCic2Raw( - uint32_t widgetId, - const cy_stc_capsense_context_t * context) -{ - uint32_t snsIndex; - uint32_t tmpVal; - uint32_t clkDivider; - uint32_t cic2Samples; - uint32_t cic2Divider; - - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) - uint32_t cic2SamplesRow; - uint32_t cic2DividerRow; - uint32_t twoDimWidget = 0u; - #endif - - const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; - cy_stc_capsense_sensor_context_t * ptrSnsCxt = &ptrWdCfg->ptrSnsContext[0u]; - - clkDivider = context->ptrWdContext[widgetId].snsClk; - cic2Samples = ((clkDivider * ptrWdCfg->ptrWdContext->numSubConversions / - ptrWdCfg->ptrWdContext->cicRate) - 1u) * ptrWdCfg->numChopCycles; - cic2Divider = Cy_CapSense_GetCIC2HwDivider(cic2Samples); - - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) - if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && - (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || - ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType))) - { - twoDimWidget = 1u; - clkDivider = context->ptrWdContext[widgetId].rowSnsClk; - cic2SamplesRow = ((clkDivider * ptrWdCfg->ptrWdContext->numSubConversions / - ptrWdCfg->ptrWdContext->cicRate) - 1u) * ptrWdCfg->numChopCycles; - cic2DividerRow = Cy_CapSense_GetCIC2HwDivider(cic2SamplesRow); - } - #endif - - for(snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) - { - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) - if ((0u != twoDimWidget) && (ptrWdCfg->numCols <= snsIndex)) - { - tmpVal = ((uint32_t)ptrSnsCxt->raw * cic2DividerRow) / cic2SamplesRow; - } - else - { - tmpVal = ((uint32_t)ptrSnsCxt->raw * cic2Divider) / cic2Samples; - } - #else - tmpVal = ((uint32_t)ptrSnsCxt->raw * cic2Divider) / cic2Samples; - #endif - - if (tmpVal > CY_CAPSENSE_16_BIT_MASK) - { - tmpVal = CY_CAPSENSE_16_BIT_MASK; - } - ptrSnsCxt->raw = (uint16_t)tmpVal; - ptrSnsCxt++; - } -} - - -/******************************************************************************* -* Function Name: Cy_CapSense_PreProcessSensorCic2Raw -****************************************************************************//** -* -* This internal function executes the pre-processing of raw data -* produced by the fifth CAPSENSE™ HW generation with the filter mode set -* to CIC2. -* -* \param widgetId -* The widget ID, for which the pre-processing should be executed. -* -* \param sensorId -* The sensor ID, for which the pre-processing should be executed. -* -* \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. -* -*******************************************************************************/ -void Cy_CapSense_PreProcessSensorCic2Raw( - uint32_t widgetId, - uint32_t sensorId, - const cy_stc_capsense_context_t * context) -{ - uint32_t tmpVal; - uint32_t clkDivider; - uint32_t cic2Samples; - uint32_t cic2Divider; - const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; - cy_stc_capsense_sensor_context_t * ptrSnsCxt = &ptrWdCfg->ptrSnsContext[sensorId]; - - clkDivider = context->ptrWdContext[widgetId].snsClk; - if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && (ptrWdCfg->numCols <= sensorId)) - { - clkDivider = context->ptrWdContext[widgetId].rowSnsClk; - } - - cic2Samples = ((clkDivider * ptrWdCfg->ptrWdContext->numSubConversions / - ptrWdCfg->ptrWdContext->cicRate) - 1u) * ptrWdCfg->numChopCycles; - cic2Divider = Cy_CapSense_GetCIC2HwDivider(cic2Samples); - - tmpVal = ((uint32_t)ptrSnsCxt->raw * cic2Divider) / cic2Samples; - if (tmpVal > CY_CAPSENSE_16_BIT_MASK) - { - tmpVal = CY_CAPSENSE_16_BIT_MASK; - } - ptrSnsCxt->raw = (uint16_t)tmpVal; -} - - -/******************************************************************************* -* Function Name: Cy_CapSense_GetCIC2HwDivider -****************************************************************************//** -* -* This internal function determines the value of the divider that will be -* applied to the data, accumulated by the CIC2 HW for the specified number of -* samples. -* -* \param cic2Samples -* The number of CIC2 samples for the specified sensing parameters. This value -* can be obtained by using the Cy_CapSense_GetCIC2SamplesNum function. -* -* \return -* The CIC2 HW divider value. -* -*******************************************************************************/ -uint32_t Cy_CapSense_GetCIC2HwDivider( - uint32_t cic2Samples) -{ - uint32_t cic2Divider; - - if(cic2Samples > CY_CAPSENSE_CIC2_DIVIDER_8) - { - cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_16; - } - else if(cic2Samples > CY_CAPSENSE_CIC2_DIVIDER_4) - { - cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_8; - } - else if(cic2Samples > CY_CAPSENSE_CIC2_DIVIDER_2) - { - cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_4; - } - else if(cic2Samples > CY_CAPSENSE_CIC2_DIVIDER_1) - { - cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_2; - } - else - { - cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_1; - } - - return(cic2Divider); -} -#endif /* #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) */ +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) */ -#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) && \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP))) /******************************************************************************* * Function Name: Cy_CapSense_RunMfsMedian ****************************************************************************//** @@ -2160,12 +2009,18 @@ uint32_t Cy_CapSense_GetCIC2HwDivider( * This function is needed to implement customer-specific use cases. * * \note -* This function is available only for the fifth-generation CAPSENSE™. +* This function is available for the fifth-generation CAPSENSE™ and +* fifth-generation low power CAPSENSE™. * * \param widgetId * Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed and +* \ref CY_CAPSENSE_STATUS_BAD_PARAM is returned +* if a widget of this type is passed. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -2190,37 +2045,43 @@ cy_capsense_status_t Cy_CapSense_RunMfsMedian( cy_stc_capsense_sensor_context_t * ptrSnsCxt2; /* Check parameter validity */ - if (widgetId < context->ptrCommonConfig->numWd) + if (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) { ptrWdCfg = &context->ptrWdConfig[widgetId]; - ptrSnsCxt0 = ptrWdCfg[CY_CAPSENSE_MFS_CH0_INDEX].ptrSnsContext; - ptrSnsCxt1 = ptrWdCfg[CY_CAPSENSE_MFS_CH1_INDEX].ptrSnsContext; - ptrSnsCxt2 = ptrWdCfg[CY_CAPSENSE_MFS_CH2_INDEX].ptrSnsContext; - if (((ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK) != 0u) && - ((ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK) == 0u)) + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ { - /* Calculate median */ - for (snsIndex = ptrWdCfg->numSns; snsIndex-- > 0u;) + ptrSnsCxt0 = ptrWdCfg[CY_CAPSENSE_MFS_CH0_INDEX].ptrSnsContext; + ptrSnsCxt1 = ptrWdCfg[CY_CAPSENSE_MFS_CH1_INDEX].ptrSnsContext; + ptrSnsCxt2 = ptrWdCfg[CY_CAPSENSE_MFS_CH2_INDEX].ptrSnsContext; + + if (((ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK) != 0u) && + ((ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK) == 0u)) { - ptrSnsCxt0->diff = (uint16_t)Cy_CapSense_FtMedian(ptrSnsCxt0->diff, - ptrSnsCxt1->diff, - ptrSnsCxt2->diff); - ptrSnsCxt0++; - ptrSnsCxt1++; - ptrSnsCxt2++; + /* Calculate median */ + for (snsIndex = ptrWdCfg->numSns; snsIndex-- > 0u;) + { + ptrSnsCxt0->diff = (uint16_t)Cy_CapSense_FtMedian(ptrSnsCxt0->diff, + ptrSnsCxt1->diff, + ptrSnsCxt2->diff); + ptrSnsCxt0++; + ptrSnsCxt1++; + ptrSnsCxt2++; + } + result = CY_CAPSENSE_STATUS_SUCCESS; } - result = CY_CAPSENSE_STATUS_SUCCESS; } } - return (result); + return result; } #endif -#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ /* [] END OF FILE */ diff --git a/cy_capsense_processing.h b/cy_capsense_processing.h index 3352f45..99617bd 100644 --- a/cy_capsense_processing.h +++ b/cy_capsense_processing.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_processing.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the function prototypes for the Data Processing module. @@ -27,7 +27,7 @@ #include "cy_capsense_structure.h" #include "cy_capsense_lib.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if defined(__cplusplus) @@ -44,8 +44,8 @@ extern "C" { /******************************************************************************/ #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_GESTURE_EN) uint32_t Cy_CapSense_DecodeWidgetGestures( - uint32_t widgetId, - const cy_stc_capsense_context_t * context); + uint32_t widgetId, + const cy_stc_capsense_context_t * context); #endif /** \} */ @@ -54,33 +54,35 @@ extern "C" { /******************************************************************************/ #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_GESTURE_EN) void Cy_CapSense_InitializeWidgetGestures( - uint32_t widgetId, - const cy_stc_capsense_context_t * context); + uint32_t widgetId, + const cy_stc_capsense_context_t * context); #endif + void Cy_CapSense_InitializeAllStatuses(const cy_stc_capsense_context_t * context); void Cy_CapSense_InitializeWidgetStatus( uint32_t widgetId, const cy_stc_capsense_context_t * context); -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED) - cy_capsense_status_t Cy_CapSense_ProcessWidgetMptxDeconvolution( - uint32_t widgetId, - cy_stc_capsense_context_t * context); +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED)) + cy_capsense_status_t Cy_CapSense_ProcessWidgetMpDeconvolution( + uint32_t widgetId, + cy_stc_capsense_context_t * context); #endif -void Cy_CapSense_PreProcessWidget( + + void Cy_CapSense_PreProcessSensor( + uint32_t widgetId, + uint32_t sensorId, + const cy_stc_capsense_context_t * context); + void Cy_CapSense_PreProcessWidget( uint32_t widgetId, const cy_stc_capsense_context_t * context); -void Cy_CapSense_PreProcessSensor( + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) + cy_capsense_status_t Cy_CapSense_RunMfsMedian( uint32_t widgetId, - uint32_t sensorId, const cy_stc_capsense_context_t * context); - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) - cy_capsense_status_t Cy_CapSense_RunMfsMedian( - uint32_t widgetId, - const cy_stc_capsense_context_t * context); - #endif -#endif + #endif /* CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN */ +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ /** \} */ @@ -88,66 +90,59 @@ void Cy_CapSense_PreProcessSensor( /** \cond SECTION_CAPSENSE_INTERNAL */ /** \addtogroup group_capsense_internal *//** \{ */ /******************************************************************************/ -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_BUTTON_EN) ||\ +#if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_BUTTON_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_MATRIX_EN)) void Cy_CapSense_DpProcessButton( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_TOUCHPAD_EN) void Cy_CapSense_DpProcessCsxTouchpad( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_PROXIMITY_EN) void Cy_CapSense_DpProcessProximity( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN) void Cy_CapSense_DpProcessCsdTouchpad( const cy_stc_capsense_widget_config_t * ptrWdConfig, const cy_stc_capsense_context_t * context); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN) void Cy_CapSense_DpProcessSlider( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) void Cy_CapSense_DpProcessCsdMatrix( const cy_stc_capsense_widget_config_t * ptrWdConfig); #endif +uint32_t Cy_CapSense_DpProcessWidgetRawCounts( + uint32_t widgetId, + const cy_stc_capsense_context_t * context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) void Cy_CapSense_DpProcessCsdWidgetStatus( const cy_stc_capsense_widget_config_t * ptrWdConfig, cy_stc_capsense_context_t * context); - -uint32_t Cy_CapSense_DpProcessCsdWidgetRawCounts( - uint32_t widgetId, - const cy_stc_capsense_context_t * context); - -uint32_t Cy_CapSense_DpProcessCsdSensorRawCountsExt( - const cy_stc_capsense_widget_config_t * ptrWdConfig, - cy_stc_capsense_sensor_context_t * ptrSnsContext, - uint16_t * ptrSnsRawHistory, - uint8_t * ptrSnsRawHistoryLow, - uint32_t mode, - uint16_t * ptrBslnInvSns, - const cy_stc_capsense_context_t * context); #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) void Cy_CapSense_DpProcessCsxWidgetStatus( const cy_stc_capsense_widget_config_t * ptrWdConfig); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ -uint32_t Cy_CapSense_DpProcessCsxWidgetRawCounts( - uint32_t widgetId, - const cy_stc_capsense_context_t * context); +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) +void Cy_CapSense_DpProcessIsxWidgetStatus( + const cy_stc_capsense_widget_config_t * ptrWdConfig); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ -uint32_t Cy_CapSense_DpProcessCsxSensorRawCountsExt( +uint32_t Cy_CapSense_DpProcessSensorRawCountsExt( const cy_stc_capsense_widget_config_t * ptrWdConfig, cy_stc_capsense_sensor_context_t * ptrSnsContext, uint16_t * ptrSnsRawHistory, @@ -155,7 +150,6 @@ uint32_t Cy_CapSense_DpProcessCsxSensorRawCountsExt( uint32_t mode, uint16_t * ptrSnsBslnInv, const cy_stc_capsense_context_t * context); -#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ void Cy_CapSense_DpUpdateDifferences( const cy_stc_capsense_widget_context_t * ptrWdContext, @@ -166,15 +160,17 @@ void Cy_CapSense_DpUpdateThresholds( const cy_stc_capsense_smartsense_csd_noise_envelope_t * ptrNoiseEnvelope, uint32_t startFlag); -#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN) +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_SCAN_EN)) void Cy_CapSense_RunMfsFiltering( cy_stc_capsense_sensor_context_t * ptrSnsContext, const cy_stc_capsense_context_t * context); #endif -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) void Cy_CapSense_PreProcessWidgetInvertRaw( uint32_t widgetId, const cy_stc_capsense_context_t * context); @@ -182,7 +178,8 @@ void Cy_CapSense_PreProcessSensorInvertRaw( uint32_t widgetId, uint32_t sensorId, const cy_stc_capsense_context_t * context); -#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) */ void Cy_CapSense_PreProcessWidgetLimitRaw( uint32_t widgetId, @@ -191,26 +188,15 @@ void Cy_CapSense_PreProcessSensorLimitRaw( uint32_t widgetId, uint32_t sensorId, const cy_stc_capsense_context_t * context); -#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) -void Cy_CapSense_PreProcessWidgetCic2Raw( - uint32_t widgetId, - const cy_stc_capsense_context_t * context); -void Cy_CapSense_PreProcessSensorCic2Raw( - uint32_t widgetId, - uint32_t sensorId, - const cy_stc_capsense_context_t * context); -uint32_t Cy_CapSense_GetCIC2HwDivider( - uint32_t cic2Samples); -#endif -#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ /** \} \endcond */ #if defined(__cplusplus) } #endif -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif /* CY_CAPSENSE_PROCESSING_H */ diff --git a/cy_capsense_selftest.c b/cy_capsense_selftest.c index 30e2b1e..db17830 100644 --- a/cy_capsense_selftest.c +++ b/cy_capsense_selftest.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_selftest.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the source code to the Built-in Self-test (BIST) @@ -18,12 +18,19 @@ #include #include +#include "cy_capsense_common.h" #include "cy_capsense_selftest.h" +#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + #include "cy_capsense_selftest_v2.h" +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_capsense_selftest_lp.h" +#else /* (CY_CAPSENSE_PSOC4_FIFTH_GEN) */ + #include "cy_capsense_selftest_v3.h" +#endif -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) - /******************************************************************************* * Function Name: Cy_CapSense_RunSelfTest ****************************************************************************//** @@ -38,21 +45,41 @@ * all the self-tests or any combination of the masks * (defined in testEnMask parameter) to specify the desired test list. * +* This function does not execute two tests: sensor raw count and +* baseline integrity. +* * To execute a single-element test (i.e. for one widget or one sensor), * the following low-level functions are available: -* for the fourth-generation CAPSENSE™: -* - Cy_CapSense_CheckCRCWidget() -* - Cy_CapSense_CheckIntegritySensorPins() -* - Cy_CapSense_MeasureCapacitanceSensor() -* - Cy_CapSense_MeasureCapacitanceShield() -* - Cy_CapSense_MeasureCapacitanceCap() -* - Cy_CapSense_MeasureVdda() -* for the fifth-generation CAPSENSE™: -* - Cy_CapSense_CheckCRCWidget() -* - Cy_CapSense_CheckIntegritySensorPins() -* - Cy_CapSense_MeasureCapacitanceSensorElectrode() -* - Cy_CapSense_MeasureCapacitanceSlotSensors() -* - Cy_CapSense_MeasureCapacitanceShieldElectrode() +* +* For the fourth-generation CAPSENSE™: +* * Cy_CapSense_CheckCRCWidget() +* * Cy_CapSense_CheckIntegritySensorRawcount() +* * Cy_CapSense_CheckIntegritySensorBaseline() +* * Cy_CapSense_CheckIntegritySensorPins() +* * Cy_CapSense_MeasureCapacitanceSensor() +* * Cy_CapSense_MeasureCapacitanceShield() +* * Cy_CapSense_MeasureCapacitanceCap() +* * Cy_CapSense_MeasureVdda() +* +* For the fifth-generation CAPSENSE™: +* * Cy_CapSense_CheckCRCWidget() +* * Cy_CapSense_CheckIntegritySensorRawcount() +* * Cy_CapSense_CheckIntegritySensorBaseline() +* * Cy_CapSense_CheckIntegritySensorPins() +* * Cy_CapSense_MeasureCapacitanceSensorElectrode() +* * Cy_CapSense_MeasureCapacitanceSlotSensors() +* * Cy_CapSense_MeasureCapacitanceShieldElectrode() +* +* For the fifth-generation low power CAPSENSE™: +* * Cy_CapSense_CheckCRCWidget() +* * Cy_CapSense_CheckIntegritySensorRawcount() +* * Cy_CapSense_CheckIntegritySensorBaseline() +* * Cy_CapSense_CheckIntegritySensorPins() +* * Cy_CapSense_MeasureCapacitanceSensorElectrode() +* * Cy_CapSense_MeasureCapacitanceSlotSensors() +* * Cy_CapSense_MeasureCapacitanceShieldElectrode() +* * Cy_CapSense_MeasureCapacitanceCap() +* * Cy_CapSense_MeasureVdda() * * Refer to these functions descriptions for detail information * on the corresponding test. @@ -73,8 +100,7 @@ * (only for the fourth-generation CAPSENSE™). * - CY_CAPSENSE_BIST_VDDA_MASK - Measures the VDDA voltage * (only for the fourth-generation CAPSENSE™). -* - CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK -* - Executes all available tests. +* - CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK - Executes all available tests. * * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. @@ -86,7 +112,7 @@ * testEnMask parameter or the context is * a NULL pointer. The function * was not performed. -* - CY_CAPSENSE_BIST_HW_BUSY_E - The CSD HW block is busy with a previous +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a previous * operation. The function was not performed. * - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during * the measurement, you may need to repeat @@ -102,13 +128,15 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest( { cy_en_capsense_bist_status_t result; - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - result = Cy_CapSense_RunSelfTest_V3(testEnMask, context); - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) result = Cy_CapSense_RunSelfTest_V2(testEnMask, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + result = Cy_CapSense_RunSelfTest_V3(testEnMask, context); + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + result = Cy_CapSense_RunSelfTest_V3Lp(testEnMask, context); #endif - return (result); + return result; } @@ -181,13 +209,15 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget( { cy_en_capsense_bist_status_t result; - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - result = Cy_CapSense_CheckCRCWidget_V3(widgetId, context); - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) result = Cy_CapSense_CheckCRCWidget_V2(widgetId, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + result = Cy_CapSense_CheckCRCWidget_V3(widgetId, context); + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + result = Cy_CapSense_CheckCRCWidget_V3Lp(widgetId, context); #endif - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) */ @@ -225,6 +255,10 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget( * mass-production or during an operation phase together with the * Cy_CapSense_CheckIntegritySensorRawcount() function. * +* The function should be called after sensors scanning and processing. Do not +* call the function before processing since processing changes sensor +* baselines. +* * \param widgetId * Specifies the ID number of the widget. * A macro for the widget ID can be found in the @@ -266,21 +300,18 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline( { cy_en_capsense_bist_status_t result; - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - result = Cy_CapSense_CheckIntegritySensorBaseline_V3(widgetId, - sensorId, - baselineHighLimit, - baselineLowLimit, - context); - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ - result = Cy_CapSense_CheckIntegritySensorBaseline_V2(widgetId, - sensorId, - baselineHighLimit, - baselineLowLimit, - context); + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + result = Cy_CapSense_CheckIntegritySensorBaseline_V2(widgetId, sensorId, + baselineHighLimit, baselineLowLimit, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + result = Cy_CapSense_CheckIntegritySensorBaseline_V3(widgetId, sensorId, + baselineHighLimit, baselineLowLimit, context); + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + result = Cy_CapSense_CheckIntegritySensorBaseline_V3Lp(widgetId, sensorId, + baselineHighLimit, baselineLowLimit, context); #endif - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN) */ @@ -308,6 +339,10 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline( * mass-production or during an operation phase together with the * Cy_CapSense_CheckIntegritySensorBaseline() function. * +* The function should be called after sensors scanning and processing. Do not +* call the function before processing since processing changes sensor +* raw counts. +* * \param widgetId * Specifies the ID number of the widget. * A macro for the widget ID can be found in the @@ -348,21 +383,18 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount( { cy_en_capsense_bist_status_t result; - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - result = Cy_CapSense_CheckIntegritySensorRawcount_V3(widgetId, - sensorId, - rawcountHighLimit, - rawcountLowLimit, - context); - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ - result = Cy_CapSense_CheckIntegritySensorRawcount_V2(widgetId, - sensorId, - rawcountHighLimit, - rawcountLowLimit, - context); + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + result = Cy_CapSense_CheckIntegritySensorRawcount_V2(widgetId, sensorId, + rawcountHighLimit, rawcountLowLimit, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + result = Cy_CapSense_CheckIntegritySensorRawcount_V3(widgetId, sensorId, + rawcountHighLimit, rawcountLowLimit, context); + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + result = Cy_CapSense_CheckIntegritySensorRawcount_V3Lp(widgetId, sensorId, + rawcountHighLimit, rawcountLowLimit, context); #endif - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_RAW_INTEGRITY_EN) */ @@ -446,6 +478,11 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount( * This test can be executed only if the CAPSENSE™ Middleware is in the IDLE * state. This function must not be called while CAPSENSE™ Middleware is busy. * +* \note +* Rx/Lx electrodes for ISX widgets are excluded from the test as +* they are electrically shorted to GND and the CY_CAPSENSE_BIST_BAD_PARAM_E result +* for such widgets is returned. +* * \param widgetId * Specifies the ID number of the widget. * A macro for the widget ID can be found in the @@ -480,7 +517,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount( * specified sensor. * - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. * The test was not executed. -* - CY_CAPSENSE_BIST_HW_BUSY_E - The CSD HW block is busy with a +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a * previous operation. The function * was not executed. * @@ -492,13 +529,15 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorPins( { cy_en_capsense_bist_status_t result; - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - result = Cy_CapSense_CheckIntegritySensorPins_V3(widgetId, sensorId, context); - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) result = Cy_CapSense_CheckIntegritySensorPins_V2(widgetId, sensorId, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + result = Cy_CapSense_CheckIntegritySensorPins_V3(widgetId, sensorId, context); + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + result = Cy_CapSense_CheckIntegritySensorPins_V3Lp(widgetId, sensorId, context); #endif - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) */ @@ -532,62 +571,74 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorPins( *******************************************************************************/ void Cy_CapSense_BistDsInitialize(cy_stc_capsense_context_t * context) { -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - Cy_CapSense_BistDsInitialize_V3(context); -#else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ - Cy_CapSense_BistDsInitialize_V2(context); -#endif + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + Cy_CapSense_BistDsInitialize_V2(context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + Cy_CapSense_BistDsInitialize_V3(context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + Cy_CapSense_BistDsInitialize_V3Lp(context); + #else + /* Supported platform not found */ + #endif } -#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) /******************************************************************************* * Function Name: Cy_CapSense_MeasureCapacitanceCap ****************************************************************************//** * -* Measures the capacitance in picofarads of the specified CAPSENSE™ integration -* (external) capacitor. +* Measures the capacitance in picofarads of the specified CAPSENSE™ +* integration (external) capacitor. * * The function measures the capacitance of the specified external capacitor * such as Cmod and returns the result through ptrValue, alternatively * the measurement result is stored in the corresponding field of the * \ref cy_stc_capsense_bist_context_t structure (either .cModCap, .cIntACap, -* .cIntBCap, or .cShieldCap). +* .cIntBCap, or .cShieldCap for the fourth-generation, and .cMod01Cap or +* .cMod02Cap the fifth-generation low power CAPSENSE™ HW blocks). * * The maximum measurement capacitance is 25nF. The measurement accuracy is -* up to 15%. The measurement resolution is 10 bit which corresponds to the -* maximum capacitance specified by the maxCapacitance parameter. The bigger -* specified maximum capacitance is, the bigger capacitance value is for -* one measured count. +* up to 15% for the fourth-generation and up to 30% for the fifth-generation low +* power CAPSENSE™ HW blocks. The measurement resolution is 10 bit +* which corresponds to the maximum capacitance specified +* by the maxCapacitance parameter. The bigger specified maximum capacitance is, +* the bigger capacitance value is for one measured count. * It is recommended to specify the maximum capacitance twice bigger as the * nominal capacitor capacitance. For example, if the nominal Cmod value * is 2.2nF, the maxCapacitance parameter is set to 4nF-5nF. * -* The function configures all CAPSENSE™ pins to Strong-drive-low mode that -* allows detecting a short of the measured capacitor to other pins. +* The function configures all CAPSENSE™ pins to Strong-drive-low mode +* that allows detecting a short of the measured capacitor to other pins. * * To measure all the available capacitors, the Cy_CapSense_RunSelfTest() -* function can be used with the CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK mask. The measured -* results are stored in the corresponding field of the +* function can be used with the CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK mask. +* The measured results are stored in the corresponding field of the * \ref cy_stc_capsense_bist_context_t structure. * * Measurement can be done only if the CAPSENSE™ Middleware is in the IDLE -* state. This function must not be called while the CAPSENSE™ Middleware is busy. -* The function is blocking, i.e. waits for the measurement to be completed -* prior to returning to the caller. +* state. This function must not be called while the CAPSENSE™ Middleware +* is busy. The function is blocking, i.e. waits for the measurement to be +* completed prior to returning to the caller. * * \note -* This function is available only for the fourth-generation CAPSENSE™. +* This function is available for the fourth-generation and fifth-generation +* low power CAPSENSE™. * * \param integrationCapId * Indexes of external capacitors to measure their capacitance. -* There are macros for each of them, namely: +* There are the enumeration list /ref cy_en_capsense_bist_external_cap_id_t +* for each of them. Their values could be for the fourth-generation +* CAPSENSE™ HW blocks: * * CY_CAPSENSE_BIST_CMOD_ID for the CSD method Cmod capacitor * * CY_CAPSENSE_BIST_CINTA_ID for the CSX method CintA capacitor * * CY_CAPSENSE_BIST_CINTB_ID for the CSX method CintB capacitor * * CY_CAPSENSE_BIST_CSH_ID for the CSD method Csh capacitor +* and for the fifth-generation low power CAPSENSE™ HW blocks: +* * CY_CAPSENSE_BIST_CMOD01_ID_E for the Cmod1 capacitor +* * CY_CAPSENSE_BIST_CMOD02_ID_E for the Cmod2 capacitor * * \param ptrValue * The pointer to the result of the measurement. The result is calculated as @@ -602,7 +653,8 @@ void Cy_CapSense_BistDsInitialize(cy_stc_capsense_context_t * context) * nanofarads in the range from 1 to 25 nF. * * \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. * * \return * Returns a status of the test execution: @@ -610,21 +662,26 @@ void Cy_CapSense_BistDsInitialize(cy_stc_capsense_context_t * context) * successfully, the result is valid. * - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. * The measurement was not executed. -* - CY_CAPSENSE_BIST_HW_BUSY_E - The CSD HW block is busy with -* a previous operation. The measurement -* was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy +* with a previous operation. +* The measurement was not executed. * - CY_CAPSENSE_BIST_LOW_LIMIT_E - The measurement was performed * but the scanning result is * below the minimum possible value. -* The measurement result could be invalid. -* The capacitor might be shorted to -* VDD or a PCB track -* is broken (open capacitor). +* The measurement result could be +* invalid. The capacitor might be +* shorted to VDD or a PCB track +* is broken (open capacitor) The return +* could occur only the fourth-generation +* CAPSENSE™. * - CY_CAPSENSE_BIST_HIGH_LIMIT_E - The measurement was performed but * the scanning result is above the * maximum possible value. -* The measurement result could be invalid. -* The capacitor might be shorted to GND. +* The measurement result could be +* invalid. The capacitor might be +* shorted to GND. The result could occur +* only for the fourth-generation +* CAPSENSE™. * - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during * the measurement. * @@ -637,12 +694,19 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap( { cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_SUCCESS_E; - bistStatus = Cy_CapSense_MeasureCapacitanceCap_V2(integrationCapId, - ptrValue, - maxCapacitance, - context); + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + bistStatus = Cy_CapSense_MeasureCapacitanceCap_V2(integrationCapId, + ptrValue, + maxCapacitance, + context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + bistStatus = Cy_CapSense_MeasureCapacitanceCap_V3Lp(integrationCapId, + ptrValue, + maxCapacitance, + context); + #endif - return (bistStatus); + return bistStatus; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) */ @@ -666,7 +730,8 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap( * prior to returning to the caller. * * \note -* This function is available only for the fourth-generation CAPSENSE™. +* This function is available only for the fourth-generation and fifth +* generation low power CAPSENSE™. * * \param ptrValue * The pointer to the uint32_t to store measured VDDA voltage value. @@ -691,14 +756,379 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureVdda( uint32_t * ptrValue, cy_stc_capsense_context_t * context) { - cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; - result = Cy_CapSense_MeasureVdda_V2(ptrValue, context); + cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + bistStatus = Cy_CapSense_MeasureVdda_V2(ptrValue, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + bistStatus = Cy_CapSense_MeasureVdda_V3Lp(ptrValue, context); + #endif - return (result); + return bistStatus; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) */ -#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ +#endif /* ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) */ + + +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceSensorElectrode +****************************************************************************//** +* +* Measures the specified CSD sensor / CSX electrode capacitance in femtofarads. +* +* This function measures the sensor capacitance for CSD widgets or the electrode +* capacitance for CSX +* widgets and returns the measurement status. For a CSX sensor, the +* measurement is done on either Rx or Tx electrode. +* For a CSD sensor, measurement is done on a sensor (refer to the +* eltdId parameter description). +* If the specified sensor (electrode) is a ganged sensor, the capacitance +* is measured for all the pins ganged together that belong to this sensor +* (electrode). +* +* The measured capacitance is stored in the .eltdCap[] array. +* The .ptrEltdCapacitance field of the +* \ref cy_stc_capsense_widget_config_t structure contains a pointer to +* the first widget sensor (electrode) element within the .eltdCap[] array. +* +* In addition to the measuring sensor (electrode) capacitance, this function +* is used to identify various fault conditions with sensors such +* as electrically-opened or -shorted sensors. For example, the PCB track is +* broken or shorted to other nodes in the system - in all of these conditions, +* this function returns changed capacitance which can be compared +* against predetermined capacitance for the sensor to detect a +* fault condition. +* +* The sensor capacitance is measured independently of the sensor scan +* configuration. For the capacitance measurement, the CSD sensing method is used. +* The default scanning parameters are the following: +* * SnsClk divider (256) is the divider for the sensor clock frequency. +* * NumConv (100) is the number of sub-conversions. +* * The reference CDAC capacitance (886 fF) is equivalent to CDAC Code of 100u. +* * The compensation CDAC is disabled. +* * The CIC2 filter is disabled. +* * The dithering is disabled. +* * The chopping is disabled. +* +* The raw count is converted into capacitance using the following equation: +* +* Cs = Rawcount * RefCDAC capacitance / NumConv +* +* where: +* * Cs is the sensor capacitance. +* * Rawcount is the measured raw count value. +* +* The minimum measurable input by this function is 1pF and the +* maximum is either 200pF or limited by the RC time constant +* (Cs < 1 / (2*5*SnsClk*R), where R is the total sensor series +* resistance that includes on-chip GPIO resistance ~500 Ohm and +* external series resistance). The measurement accuracy is about 30% and +* is defined by the RefCDAC tolerance. +* +* By default, all CAPSENSE™ sensors (electrodes) that are not being +* measured are set to the GND state for CSD measured electrodes (sensors) and +* to the HIGH-Z state for CSX measured electrodes (Rx and Tx). +* Shield electrodes are also configured to the GND state. +* The inactive state can be changed in run-time by using +* the Cy_CapSense_SetInactiveElectrodeState() function. +* +* By default, the both Cmod1 and Cmod2 capacitors are used for the measurement. +* +* The sensor measurement can be done on all the electrodes using +* the Cy_CapSense_RunSelfTest() function along with +* the CY_CAPSENSE_BIST_ELTD_CAP_MASK mask. +* +* This function must not be called while the CAPSENSE™ MW is busy +* by another scan. +* +* \note +* This function is available for the fifth-generation and fifth-generation +* low power CAPSENSE™. +* Rx/Lx electrodes for ISX widgets are excluded from the test as +* they are electrically shorted to GND and the CY_CAPSENSE_BIST_BAD_PARAM_E result +* for such widgets is returned. +* +* \param widgetId +* Specifies the ID number of the widget. +* A macro for the widget ID can be found in the +* CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__WDGT_ID. +* +* \param eltdId +* Specifies the ID of the electrode within the widget (sensorID for CSD +* widgets and Rx or Tx electrode ID for CSX widgets). +* +* For the CSD widgets, a macro for the sensor ID within the specified widget +* can be found in the CAPSENSE™ Configuration header file (cycfg_capsense.h) +* defined as CY_CAPSENSE__SNS_ID. +* +* For the CSX widgets, eltdId is an electrode ID and is defined as Rx ID +* or Tx ID. The first Rx in a widget corresponds to eltdId = 0, the +* second Rx in a widget corresponds to eltdId = 1, and so on. +* The last Tx in a widget corresponds to eltdId = (RxNum + TxNum - 1). +* Macros for Rx and Tx IDs can be found in the CAPSENSE™ Configuration header +* file (cycfg_capsense.h) defined as: +* * CapSense__RX_ID +* * CapSense__TX_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a +* previous operation. +* The measurement was not executed. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode( + uint32_t widgetId, + uint32_t eltdId, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + bistStatus = Cy_CapSense_MeasureCapacitanceSensorElectrode_V3(widgetId, eltdId, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + bistStatus = Cy_CapSense_MeasureCapacitanceSensorElectrode_V3Lp(widgetId, eltdId, context); + #endif + + return bistStatus; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceSlotSensors +****************************************************************************//** +* +* Measures the specified slot sensor capacitance in femtofarads. The function +* measures the Cp capacitance for CSD widgets and the Cm capacitance +* for CSX widgets. +* +* This function performs BIST slot scan with predefined parameters, +* back-calculates the slot sensor capacitances (Cp for CSD and Cm for CSX) +* by using the raw-count equation, stores the calculated capacitances +* to the sensor context structure, and returns the measurement status. +* If the specified slot has a ganged sensor, the capacitance +* is measured for all the pins ganged together that belong to this sensor. +* +* Besides the sensor capacitance measuring, this function could be +* used to identify various fault conditions with sensors such +* as electrically-opened or -shorted sensors. For example, the PCB track is +* broken or shorted to other nodes in the system - in all of these conditions, +* the function returns changed capacitance which can be compared +* against predetermined capacitance for the sensor to detect a +* fault condition. +* +* The sensor capacitance is measured independently of the sensor regular scan +* configuration. For the capacitance measurement, the BIST specific scan +* parameters are used. They can be found in the Electrode capacitance measurement +* macros group. +* The CDAC code for the CSD sensors is 100u and that provides about 0.886 pF +* of the CDAC value and for CSX sensors the CDAC code is 50u (0.443 pF). +* Compensation CDAC is disabled during the BIST scan. +* Another default scanning parameters are the following: +* * NumConv (100) is the number of sub-conversions. +* * SnsClk divider (256) is the divider for the sensor clock frequency. +* +* The raw count is converted into capacitance using the following equation: +* +* Cs = Rawcount * CDAC / 2 / NumConv / 2 +* +* where: +* * Cs is the sensor capacitance. +* * Rawcount is the measured raw count value. +* * The first divider of 2 is determined by the divided ref_clk frequency usage. +* * The second divider of 2 is used only for CSX sensors. +* +* The minimum measurable input by this function is 0.5 pF and the +* maximum is either 200pF or limited by the RC time constant +* (Cs < 1 / (2*10*SnsClk*R), where R is the total sensor series +* resistance that includes on-chip pin resistance ~500 Ohm and +* external series resistance). The measurement accuracy is about 30%. +* +* By default, all CAPSENSE™ sensors (electrodes) that are not being +* measured are set to the GND state for CSD measured electrodes (sensors) and +* to the HIGH-Z state for CSX measured electrodes (Rx and Tx). +* Shield electrodes are also configured to the GND state. +* The inactive state can be changed in run-time by using +* the Cy_CapSense_SetInactiveElectrodeState() function. +* +* By default, the both Cmod1 and Cmod2 capacitors are used for the measurement. +* +* Measured capacitance values (Cp for CSD widgets and Cm for CSX widgets) +* are stored in the .snsCap field of the \ref cy_stc_capsense_sensor_context_t +* structure. +* +* The all sensor measurement can be done on all the sensors using +* the Cy_CapSense_RunSelfTest() function along with +* the CY_CAPSENSE_BIST_SNS_CAP_MASK mask. +* +* This function must not be called while the CAPSENSE™ MW is busy +* by another scan. +* +* \note +* This function is available for the fifth-generation and fifth-generation +* low power CAPSENSE™. +* Rx/Lx electrodes for ISX widgets are excluded from the test as +* they are electrically shorted to GND and the CY_CAPSENSE_BIST_BAD_PARAM_E result +* for such widgets is returned. +* +* \param slotId +* Specifies the ID number of the slot to measure sensor capacitance. +* The slot ID should be in the admissible range. +* +* \param skipChMask +* Specifies the mask to skip some channels during the slot sensor capacitance +* measurement. If the bit N in the skipChMask is set to 1, the channel N +* will be excluded from measuring and all its pins will be set to the inactive +* sensor connection state (see the .eltdCapCsdISC field +* of the \ref cy_stc_capsense_bist_context_t structure for CSD widgets +* and the .eltdCapCsxISC field respectively for CSX widgets). +* For fifth-generation low power CAPSENSE™ this argument is kept for +* uniformity and backward compatibility and is not used. The function can be +* called with value 0u. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a +* previous operation. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors( + uint32_t slotId, + uint32_t skipChMask, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + bistStatus = Cy_CapSense_MeasureCapacitanceSlotSensors_V3(slotId, skipChMask, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + bistStatus = Cy_CapSense_MeasureCapacitanceSlotSensors_V3Lp(slotId, skipChMask, context); + #endif + + return bistStatus; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceShieldElectrode +****************************************************************************//** +* +* Measures shield electrode capacitances in femtofarads. +* +* This function measures the capacitances of all shield electrodes for all +* enabled MSCv3 channels and returns a status of this measurement. +* The function checks if there is any CSD widget in the project and +* if the shield is enabled. +* The measurement results in femtofarads are stored +* in the chShieldCap[CY_MSC_ENABLED_CH_NUMBER] array. +* The pointer to the array is in the .ptrChShieldCap field +* of the \ref cy_stc_capsense_bist_context_t structure, +* the CY_MSC_ENABLED_CH_NUMBER define is in the cycfg_peripherals.h file. +* If the any channel shield consists of several electrodes, the total +* capacitance of all the shield electrodes is measured. +* +* This function uses an algorithm identical to the electrode capacitance +* measurement. Refer to the Cy_CapSense_MeasureCapacitanceSensorElectrode() +* function for more details. +* +* In addition to measuring shield capacitance, this function is used to +* identify various fault conditions with shield electrodes such as an +* electrically-open or -short shield electrodes, e.g. the PCB track is broken or +* shorted to other nodes in the system - in all of these conditions, +* this function returns changed capacitance that can be compared +* against pre-determined capacitance for the shield electrode to +* detect a hardware fault. +* +* By default, all CAPSENSE™ sensors (electrodes) that are not being +* measured are set to the GND state. +* The inactive state can be changed in run-time by using +* the Cy_CapSense_SetInactiveElectrodeState() function. +* When the inactive sensor (electrode) connection is set +* to the CY_CAPSENSE_SNS_CONNECTION_SHIELD state, +* all the CAPSENSE™ electrodes are connected to the shield and +* the total capacitance are measured. +* +* By default, the both Cmod1 and Cmod2 capacitors are used for the measurement. +* +* This test can be executed using the CapSense_RunSelfTest() +* function with the CY_CAPSENSE_BIST_SHIELD_CAP_MASK mask. +* +* \note +* This function is available for the fifth-generation and fifth-generation +* low power CAPSENSE™. +* +* \param skipChMask +* Specifies the mask to skip some channels during the shield electrode +* capacitance measurement. If the bit N in the skipChMask is set to 1, +* the channel N will be excluded from measuring and all its shield pins will be +* set to the shield inactive sensor connection state (see the .shieldCapISC +* field of the \ref cy_stc_capsense_bist_context_t structure). +* For fifth-generation low power CAPSENSE™ this argument is kept for +* uniformity and backward compatibility and is not used. The function can be +* called with value 0u. +* +* \param context +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a +* previous operation. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_BAD_CONFIG_E - The shield is disabled. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode( + uint32_t skipChMask, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + bistStatus = Cy_CapSense_MeasureCapacitanceShieldElectrode_V3(skipChMask, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + bistStatus = Cy_CapSense_MeasureCapacitanceShieldElectrode_V3Lp(skipChMask, context); + #endif + + return bistStatus; +} +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) */ + + +#endif /* ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) */ #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) */ diff --git a/cy_capsense_selftest.h b/cy_capsense_selftest.h index 06f9e67..ef16b0e 100644 --- a/cy_capsense_selftest.h +++ b/cy_capsense_selftest.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_selftest.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the function prototypes of the BIST module. @@ -24,12 +24,16 @@ #include "cy_capsense_structure.h" #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) #include "cy_capsense_selftest_v2.h" -#else /* (CY_CAPSENSE_PSOC4_FIFTH_GEN) */ +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) #include "cy_capsense_selftest_v3.h" +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_capsense_selftest_lp.h" +#else + /* Supported platform not found */ #endif -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) @@ -87,16 +91,44 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest( cy_stc_capsense_context_t * context); #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) */ -#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) -cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap( - cy_en_capsense_bist_external_cap_id_t integrationCapId, - uint32_t * ptrValue, - uint32_t maxCapacitance, - cy_stc_capsense_context_t * context); -cy_en_capsense_bist_status_t Cy_CapSense_MeasureVdda( - uint32_t * ptrValue, - cy_stc_capsense_context_t * context); -#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap( + cy_en_capsense_bist_external_cap_id_t integrationCapId, + uint32_t * ptrValue, + uint32_t maxCapacitance, + cy_stc_capsense_context_t * context); + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureVdda( + uint32_t * ptrValue, + cy_stc_capsense_context_t * context); + #endif +#endif /* ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) */ + +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode( + uint32_t widgetId, + uint32_t eltdId, + cy_stc_capsense_context_t * context); + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors( + uint32_t slotId, + uint32_t skipChMask, + cy_stc_capsense_context_t * context); + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode( + uint32_t skipChMask, + cy_stc_capsense_context_t * context); + #endif +#endif /* ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) */ /** \} */ @@ -116,7 +148,7 @@ void Cy_CapSense_BistDsInitialize(cy_stc_capsense_context_t * context); #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) */ -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif /* CY_CAPSENSE_SELFTEST_H */ diff --git a/cy_capsense_selftest_lp.c b/cy_capsense_selftest_lp.c new file mode 100644 index 0000000..c866e2a --- /dev/null +++ b/cy_capsense_selftest_lp.c @@ -0,0 +1,4310 @@ +/***************************************************************************//** +* \file cy_capsense_selftest_lp.c +* \version 4.0 +* +* \brief +* This file provides the source code to the Built-in Self-test (BIST) +* functions. +* +******************************************************************************** +* \copyright +* Copyright 2021-2023, Cypress Semiconductor Corporation (an Infineon company) +* or an affiliate of Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +*******************************************************************************/ + +#include +#include +#include "cy_syslib.h" +#include "cy_sysclk.h" +#include "cycfg_capsense_defines.h" +#include "cycfg_peripherals.h" +#include "cy_capsense_common.h" +#include "cy_capsense_sensing.h" +#include "cy_capsense_sensing_lp.h" +#include "cy_capsense_generator_lp.h" +#include "cy_capsense_selftest_lp.h" +#include "cy_capsense_sm_base_full_wave_lp.h" +#include "cy_gpio.h" + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_msclp.h" +#endif + +#if (defined(CY_IP_M0S8MSCV3LP)) + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) + +/******************************************************************************* +* Common local definitions for self-test +*******************************************************************************/ + +/* Port Data Register macros for BIST */ +#define CY_CAPSENSE_BIST_DR_PIN2GND (0u) +#define CY_CAPSENSE_BIST_DR_PIN2VDD (1u) +/* Electrode capacitance measurement macros for BIST */ +#define CY_CAPSENSE_BIST_CAP_SLOT_SCAN (0u) +#define CY_CAPSENSE_BIST_CAP_ELTD_SCAN (1u) +#define CY_CAPSENSE_BIST_CAP_SHIELD_SCAN (2u) +/** The number of BIST sense mode configurations for capacitance measurements (CSD + CSX) */ +#define CY_CAPSENSE_BIST_SENSE_MODE_CONFIG_NUMBER (2u) +#define CY_CAPSENSE_BIST_ELTD_CAP_MODCLK_DIV_DEFAULT (1u) +#define CY_CAPSENSE_BIST_ELTD_CAP_MAX_MODCLK (48000000u) +#define CY_CAPSENSE_BIST_ELTD_CAP_SNSCLK_DIV_DEFAULT (256u) +#define CY_CAPSENSE_BIST_SHIELD_CAP_SNSCLK_DIV_DEFAULT (1024u) +#define CY_CAPSENSE_BIST_SNS_CLK_MIN_DIVIDER (4u) +#define CY_CAPSENSE_BIST_SNS_CLK_MAX_DIVIDER (4096u) +#define CY_CAPSENSE_BIST_ELTD_CAP_SUBCONV_NUM_DEFAULT (100u) +#define CY_CAPSENSE_BIST_SHIELD_CAP_REF_CDAC_DEFAULT (200u) +#define CY_CAPSENSE_BIST_ELTD_CAP_REF_CDAC_DEFAULT (100u) +#define CY_CAPSENSE_BIST_MUTUAL_CAP_REF_CDAC_DEFAULT (50u) +#define CY_CAPSENSE_BIST_WATCHDOG_MARGIN_COEFF (3u) +#define CY_CAPSENSE_BIST_CAP_MEAS_WDT_CYCLES_PER_LOOP (5u) +#define CY_CAPSENSE_BIST_V3_ELTD_CAP_CYCLES_NUM (1u) +#define CY_CAPSENSE_BIST_CAP_MEAS_CDAC_LSB_FF_DIV_1000 (8860u) +#define CY_CAPSENSE_BIST_CP_MAX_VALUE (200000u) +#define CY_CAPSENSE_BIST_CSH_MAX_VALUE (1600000u) +#define CY_CAPSENSE_BIST_PROMILLE_FACTOR (1000u) + +/******************************************************************************* +* Macros for the external capacitor capacitance measurement test +*******************************************************************************/ + +#define CY_CAPSENSE_BIST_EXT_CAP_REF_CDAC_DEFAULT (250u) +#define CY_CAPSENSE_BIST_EXT_CAP_NUM_SUB_DEFAULT (8u) +#define CY_CAPSENSE_BIST_EXT_CAP_IMO_CLK_MHZ (25u) +#define CY_CAPSENSE_BIST_EXT_CAP_WDT_FACTOR (5u) +#define CY_CAPSENSE_BIST_EXT_CAP_ACCURACY_FACTOR (1150u) +#define CY_CAPSENSE_BIST_EXT_CAP_DISCHARGE_FACTOR (2u) +#define CY_CAPSENSE_BIST_EXT_CAP_RESULT_FACTOR ((123uL * CY_CAPSENSE_REF_CDAC_LSB_X100 *\ + CY_CAPSENSE_BIST_EXT_CAP_REF_CDAC_DEFAULT) /\ + CY_CAPSENSE_CONVERSION_HECTO) +#define CY_CAPSENSE_BIST_EXT_CAP_RESULT_DIVIDER (CY_CAPSENSE_CONVERSION_KILO *\ + CY_CAPSENSE_CONVERSION_HECTO) +#define CY_CAPSENSE_BIST_EXT_CAP_MAX_CAP (25u) +#define CY_CAPSENSE_BIST_EXT_CAP_CMOD_MAX_VALUE (5u) + +/******************************************************************************* +* Macros for the BIST VDDA measurement test +*******************************************************************************/ + +#define CY_CAPSENSE_BIST_VDDA_MEAS_CMOD1_MAX_POSSIBLE_VALUE (20u) +#define CY_CAPSENSE_BIST_VDDA_MEAS_CMOD1_DISCHARGE_TIME ((CY_CAPSENSE_BIST_EXT_CAP_DISCHARGE_FACTOR *\ + CY_CAPSENSE_BIST_VDDA_MEAS_CMOD1_MAX_POSSIBLE_VALUE *\ + CY_CAPSENSE_BIST_EXT_CAP_SERIAL_RESISTANCE) /\ + CY_CAPSENSE_CONVERSION_KILO) +#define CY_CAPSENSE_BIST_VDDA_MEAS_MAX_RAW (((((CY_CAPSENSE_BIST_EXT_CAP_ACCURACY_FACTOR *\ + CY_CAPSENSE_BIST_VDDA_MEAS_CMOD1_MAX_POSSIBLE_VALUE) *\ + CY_CAPSENSE_CONVERSION_KILO) /\ + CY_CAPSENSE_BIST_EXT_CAP_REF_CDAC_DEFAULT) *\ + CY_CAPSENSE_CONVERSION_KILO) /\ + CY_CAPSENSE_BIST_CAP_MEAS_CDAC_LSB_FF_DIV_1000) +#define CY_CAPSENSE_BIST_VDDA_MEAS_NUM_SNS_CLK ((CY_CAPSENSE_BIST_VDDA_MEAS_MAX_RAW /\ + (MSCLP_SNS_SNS_CTL_SENSE_DIV_Msk >>\ + MSCLP_SNS_SNS_CTL_SENSE_DIV_Pos)) + 1u) +#define CY_CAPSENSE_BIST_VDDA_MEAS_BGREF_VALUE (1200u) +#define CY_CAPSENSE_BIST_VDDA_MEAS_RESULT_FACTOR (1715u) +#define CY_CAPSENSE_BIST_VDDA_MEAS_RESULT_SHIFT (710u) + +/******************************************************************************* +* Function Prototypes +*******************************************************************************/ + +/******************************************************************************/ +/** \cond SECTION_CAPSENSE_INTERNAL */ +/** \addtogroup group_capsense_internal *//** \{ */ +/******************************************************************************/ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) + static cy_en_capsense_bist_status_t Cy_CapSense_CheckAllWidgetCRC( + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) + static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckSensor( + uint32_t widgetId, + uint32_t sensorId, + uint32_t mode, + cy_stc_capsense_context_t * context); + static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckElectrode( + uint32_t widgetId, + uint32_t ioSnsId, + uint32_t mode, + const cy_stc_capsense_context_t * context); + static void Cy_CapSense_SnsShortUpdateTestResult( + uint32_t widgetId, + uint32_t sensorId, + cy_stc_capsense_context_t * context); + static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckAllSensors( + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) + static void Cy_CapSense_BistSwitchHwConfig( + cy_en_capsense_bist_hw_config_t hwCfg, + uint8_t bistSenseGroup, + uint8_t bistScanMode, + cy_stc_capsense_context_t * context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) + static void Cy_CapSense_BistSetPinDr( + cy_stc_capsense_pin_config_t const *ioPtr, + uint32_t value); + static void Cy_CapSense_BistSetPinPc( + cy_stc_capsense_pin_config_t const *ioPtr, + uint32_t value); + #endif + + static void Cy_CapSense_BistSwitchAllSnsPinState( + cy_en_capsense_bist_io_state_t desiredPinState, + const cy_stc_capsense_context_t * context); + static void Cy_CapSense_BistSwitchAllExternalCapPinState( + cy_en_capsense_bist_io_state_t desiredPinState, + const cy_stc_capsense_context_t * context); + void Cy_CapSense_BistSetAllSnsPinsState( + uint32_t desiredDriveMode, + uint32_t desiredPinOutput, + en_hsiom_sel_t desiredHsiom, + const cy_stc_capsense_context_t * context); + void Cy_CapSense_BistSetAllCmodPinsState( + uint32_t desiredDriveMode, + uint32_t desiredPinOutput, + en_hsiom_sel_t desiredHsiom, + const cy_stc_capsense_context_t * context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + static void Cy_CapSense_BistSwitchAllShieldPinState( + cy_en_capsense_bist_io_state_t desiredPinState, + const cy_stc_capsense_context_t * context); + void Cy_CapSense_BistSetAllShieldPinsState( + uint32_t desiredDriveMode, + uint32_t desiredPinOutput, + en_hsiom_sel_t desiredHsiom, + const cy_stc_capsense_context_t * context); + #endif + + static void Cy_CapSense_BistSetDmHsiomPinState( + cy_en_capsense_bist_io_state_t desiredPinState, + const cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) + static cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceAllElectrodes( + cy_stc_capsense_context_t * context); +#endif + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensorsInternal( + uint32_t slotId, + uint32_t snsFrameType, + cy_stc_capsense_context_t * context); + static cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceAllSensors( + cy_stc_capsense_context_t * context); +#endif + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) + static uint32_t Cy_CapSense_BistWatchdogPeriodCalc( + const cy_stc_capsense_context_t * context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) + static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( + uint32_t * cpPtr, + uint32_t snsFrameType, + cy_stc_capsense_context_t * context); + #endif + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) + static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSlot( + uint32_t slotId, + uint32_t snsFrameType, + cy_stc_capsense_context_t * context); + #endif + static void Cy_CapSense_BistGenerateBaseConfig( + cy_stc_capsense_context_t * context); + static void Cy_CapSense_BistGenerateSensorConfig( + uint32_t * ptrSensorCfg, + uint32_t snsFrameType, + cy_stc_capsense_context_t * context); + static void Cy_CapSense_BistGenerateSnsCfgMaskReg( + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t * ptrSensorCfg, + uint32_t cswFuncNum); +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) */ + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN)) + static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceCapRun( + uint32_t * ptrExtCapValue, + cy_stc_capsense_context_t * context); + static void Cy_CapSense_BistGenerateBaseCmodConfig( + cy_stc_capsense_context_t * context); + void Cy_CapSense_DischargeCmod( + GPIO_PRT_Type * portCmod, + uint32_t pinCmod, + cy_stc_capsense_context_t * context); +#endif + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) + static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceCapAll( + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) + /* Measure VDDA test-related functions */ + static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureVddaRun( + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) */ + +/** \} \endcond */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_RunSelfTest_V3Lp +****************************************************************************//** +* +* Runs built-in self-tests for specified by the test enable mask. +* +* The function performs various self-tests on all the enabled widgets +* and sensors in the project. Select the required set of tests +* using the bit-mask in testEnMask parameter. +* +* Use CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK to execute +* all the self-tests or any combination of the masks +* (defined in testEnMask parameter) to specify the desired test list. +* +* To execute a single-element test (i.e. for one widget or one sensor), +* the following low-level functions are available: +* * Cy_CapSense_CheckCRCWidget() +* * Cy_CapSense_CheckIntegritySensorRawcount() +* * Cy_CapSense_CheckIntegritySensorBaseline() +* * Cy_CapSense_CheckIntegritySensorPins() +* * Cy_CapSense_MeasureCapacitanceSensorElectrode() +* * Cy_CapSense_MeasureCapacitanceSlotSensors() +* * Cy_CapSense_MeasureCapacitanceShieldElectrode() +* * Cy_CapSense_MeasureCapacitanceCap() +* * Cy_CapSense_MeasureVdda() +* +* Refer to these functions descriptions for detail information +* on the corresponding test. +* +* \note +* The function is available only for the fifth-generation CAPSENSE™. +* +* \param testEnMask +* Specifies the tests to be executed. Each bit corresponds to one test. It is +* possible to launch the function with any combination of the available tests. +* - CY_CAPSENSE_BIST_CRC_WDGT_MASK - Verifies the RAM widget structure CRC +* for all the widgets. +* - CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK - Checks all the sensors for a short +* to GND / VDD / other sensors. +* - CY_CAPSENSE_BIST_SNS_CAP_MASK - Measures all the sensors capacitance. +* - CY_CAPSENSE_BIST_ELTD_CAP_MASK - Measures all the electrodes capacitance. +* - CY_CAPSENSE_BIST_SHIELD_CAP_MASK - Measures the shield capacitance. +* - CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK +* - Executes all available tests. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a bit-mask with a status of execution of the specified tests: +* - CY_CAPSENSE_BIST_SUCCESS_E - All the tests passed successfully. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - A non-defined test was requested in the +* testEnMask parameter or the context is +* a NULL pointer. The function +* was not performed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a previous +* operation. The function was not performed. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement, you may need to repeat +* the measurement. +* - CY_CAPSENSE_BIST_FAIL_E - Any of tests specified by the testEnMask +* parameters has faulted. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V3Lp( + uint32_t testEnMask, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; + + if (0u == (testEnMask & (~CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK))) + { + if (NULL != context) + { + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + { + result = CY_CAPSENSE_BIST_SUCCESS_E; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) + if (0u != (CY_CAPSENSE_BIST_CRC_WDGT_MASK & testEnMask)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_CheckAllWidgetCRC(context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_CRC_WDGT_MASK; + } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) + /* The next group of tests is hardware-dependent and they need to switch the configuration to BIST one */ + if (CY_CAPSENSE_STATUS_SUCCESS == Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY, context)) + { + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) + if (0u != (CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK & testEnMask)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_SnsShortCheckAllSensors(context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK; + } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) + if (0u != (CY_CAPSENSE_BIST_VDDA_MASK & testEnMask)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureVdda_V3Lp(NULL, context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_VDDA_MASK; + } + } + #endif + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN)) + if (0u != (CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK & testEnMask)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_BistMeasureCapacitanceCapAll(context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK; + } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) + if (0u != (CY_CAPSENSE_BIST_SNS_CAP_MASK & testEnMask)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceAllSensors(context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_SNS_CAP_MASK; + } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) + if (0u != (CY_CAPSENSE_BIST_ELTD_CAP_MASK & testEnMask)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceAllElectrodes(context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_ELTD_CAP_MASK; + } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) + if ((0u != (CY_CAPSENSE_BIST_SHIELD_CAP_MASK & testEnMask)) && + (CY_CAPSENSE_DISABLE != context->ptrCommonConfig->csdShieldMode)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceShieldElectrode_V3Lp(0u, context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_SHIELD_CAP_MASK; + } + } + #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) */ + } + else + { + result = CY_CAPSENSE_BIST_ERROR_E; + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ + } + else + { + result = CY_CAPSENSE_BIST_HW_BUSY_E; + } + } + } + + return result; +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_CheckCRCWidget_V3Lp +****************************************************************************//** +* +* Checks the stored CRC of the \ref cy_stc_capsense_widget_context_t data +* structure of the specified widget. +* +* This function validates the data integrity of the +* \ref cy_stc_capsense_widget_context_t data structure of the specified widget +* by calculating the CRC and comparing it with the stored CRC value of the +* specified widget. +* +* Initially, after the device power up, the Cy_CapSense_Enable() function +* calculates CRC for each widget and stores them in the .ptrWdgtCrc[] array +* of the \ref cy_stc_capsense_bist_context_t structure. The test execution +* compares this stored CRC value with the newly calculated and if the stored +* and calculated CRC values differ: +* 1. The calculated CRC is stored to the .wdgtCrcCalc field +* of the \ref cy_stc_capsense_bist_context_t data structure. +* 2. The widget ID is stored to the .crcWdgtId field. +* 3. The CY_CAPSENSE_BIST_CRC_WDGT_MASK bit is set in the .testResultMask field. +* +* The function never clears the CY_CAPSENSE_BIST_CRC_WDGT_MASK bit. +* If the CY_CAPSENSE_BIST_CRC_WDGT_MASK bit is set, the wdgtCrcCalc +* and .crcWdgtId fields are not updated. +* +* It is recommended to use the Cy_CapSense_SetParam() function to change +* the value of the \ref cy_stc_capsense_widget_context_t data structure elements +* as the CRC is updated by Cy_CapSense_SetParam() function. +* +* You can initiate this test by the Cy_CapSense_RunSelfTest() function with +* the CY_CAPSENSE_BIST_CRC_WDGT_MASK mask as an input. +* +* The function clears the CY_CAPSENSE_WD_WORKING_MASK bit of the .status +* field in \ref cy_stc_capsense_widget_context_t structure if the calculated +* CRC value differs to the stored CRC value. +* Those non-working widgets are skipped by the high-level scanning and +* processing functions. Restoring a widget to its working state should +* be done by the application level. +* +* For details of the used CRC algorithm, refer to the Cy_CapSense_GetCRC() +* function. +* +* \note +* This function is available only for the fifth-generation CAPSENSE™. +* +* \param widgetId +* Specifies the ID number of the widget. +* A macro for the widget ID can be found in the +* CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__WDGT_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The stored CRC matches +* the calculated CRC. +* - CY_CAPSENSE_BIST_FAIL_E - The widget CRC differs to +* the stored CRC. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameters are invalid. +* The test was not executed. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget_V3Lp( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + uint16_t crcValue; + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; + + if (NULL != context) + { + if (context->ptrCommonConfig->numWd > widgetId) + { + crcValue = Cy_CapSense_GetCrcWidget(widgetId, context); + if ((context->ptrBistContext->ptrWdgtCrc[widgetId]) != crcValue) + { + /* Write to the self-test data structure widgetId of the first badly-tested widget */ + if (0uL == (context->ptrBistContext->testResultMask & CY_CAPSENSE_BIST_CRC_WDGT_MASK)) + { + context->ptrBistContext->wdgtCrcCalc = crcValue; + context->ptrBistContext->crcWdgtId = (uint8_t)widgetId; + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_CRC_WDGT_MASK; + } + /* Marks widget non-working */ + (void)Cy_CapSense_SetWidgetStatus(widgetId, 0u, CY_CAPSENSE_WD_WORKING_MASK, context); + result = CY_CAPSENSE_BIST_FAIL_E; + } + else + { + result = CY_CAPSENSE_BIST_SUCCESS_E; + } + } + } + + return result; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_CheckAllWidgetCRC +****************************************************************************//** +* +* The internal function that checks CRC of all widget structures. +* +* The function calculates CRC of all widget structures and compare it +* to the stored CRCs. It is called by the Cy_CapSense_RunSelfTest() function. +* In the first case of failed comparison the function updates +* testResultMask and returns the status. Next widgets are not checked. +* The function use the Cy_CapSense_CheckCRCWidget() function. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the test processing: +* - CY_CAPSENSE_BIST_SUCCESS_E if all widget CRC are OK; +* - CY_CAPSENSE_BIST_FAIL_E if any widget CRC is wrong. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_CheckAllWidgetCRC( + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_SUCCESS_E; + uint32_t widgetId; + + for (widgetId = 0u; widgetId < context->ptrCommonConfig->numWd; widgetId++) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != (Cy_CapSense_CheckCRCWidget_V3Lp(widgetId, context))) + { + result = CY_CAPSENSE_BIST_FAIL_E; + break; + } + } + return result; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_UpdateCrcWidget +****************************************************************************//** +* +* The internal function updates the CRC +* of the \ref cy_stc_capsense_widget_context_t data structure +* for the specified widget. +* +* The function implements the following functionality: +* - Executes the Cy_CapSense_GetCRC() routine for the specified widget. +* - Updates the self-test CRC array with the CRC value, calculated for the +* specified widget. +* +* The CRC value is stored in the special wdgtCrc[CY_CAPSENSE_WIDGET_COUNT] array +* declared in the cycfg_capsense.c file. +* +* \param widgetId +* Specifies the ID number of the widget. +* A macro for the widget ID can be found in the +* CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__WDGT_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_UpdateCrcWidget( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + uint16_t crcValue; + + crcValue = Cy_CapSense_GetCrcWidget(widgetId, context); + + /* Write the calculated CRC value to the self-test CRC array */ + context->ptrBistContext->ptrWdgtCrc[widgetId] = crcValue; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_UpdateAllWidgetCrc +****************************************************************************//** +* +* The internal function that updates CRC of all widget structures. +* +* The function implements the following functionality: +* - Executes the Cy_CapSense_UpdateCrcWidget() for all widgets. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_UpdateAllWidgetCrc(cy_stc_capsense_context_t * context) +{ + uint32_t wdIndex; + uint32_t wdNum = (uint32_t)context->ptrCommonConfig->numWd; + + /* Initialize CRC and status for all widgets */ + for (wdIndex = 0u; wdIndex < wdNum; wdIndex++) + { + Cy_CapSense_UpdateCrcWidget(wdIndex, context); + } +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_CheckIntegritySensorBaseline_V3Lp +****************************************************************************//** +* +* Checks if the baseline of the specified sensor is not corrupted +* by comparing it with its inverse copy and checks if the baseline is +* within the specified range. +* +* The function checks whether or not the baseline binary inverted to +* its inverse copy is saved to the self-test baseline-inverse structure +* and is within the user-defined limits. If the baseline does +* not match its inverse copy or if the baseline is out of the user-defined +* limits, the function sets the CY_CAPSENSE_BIST_BSLN_INTEGRITY_MASK bit +* in the .testResultMask field of the \ref cy_stc_capsense_bist_context_t +* structure. +* +* The test is integrated into the CAPSENSE™ Middleware. All CAPSENSE™ +* processing functions like Cy_CapSense_ProcessAllWidgets() +* or Cy_CapSense_UpdateSensorBaseline() automatically verify the baseline +* value before using it and update its inverse copy after processing. +* If a baseline update fails, a CY_CAPSENSE_STATUS_BAD_DATA result +* is returned. The baseline initialization functions do not verify the +* baseline and update the baseline inverse copy. +* +* This function does not update the CY_CAPSENSE_WD_WORKING_MASK bit of +* the .status field in \ref cy_stc_capsense_widget_context_t structure +* and is not available in the Cy_CapSense_RunSelfTest() function. +* +* Use this function to verify the uniformity of sensors, for example, at +* mass-production or during an operation phase together with the +* Cy_CapSense_CheckIntegritySensorRawcount() function. +* +* \note +* This function is available only for the fifth-generation CAPSENSE™. +* +* \param widgetId +* Specifies the ID number of the widget. +* A macro for the widget ID can be found in the +* CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__WDGT_ID. +* +* \param sensorId +* Specifies the ID number of the sensor within the widget. +* A macro for the sensor ID within the specified widget can be found in +* the CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__SNS_ID. +* +* \param baselineHighLimit +* Specifies the upper limit for a baseline. +* +* \param baselineLowLimit +* Specifies the lower limit for a baseline. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The baseline is within the +* specified range. +* - CY_CAPSENSE_BIST_FAIL_E - The test failed and the baseline +* is not binary inverted to its inverse +* copy or is out of the specified limits. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The test was not executed. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline_V3Lp( + uint32_t widgetId, + uint32_t sensorId, + uint16_t baselineHighLimit, + uint16_t baselineLowLimit, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; + uint16_t bslnInv; + uint32_t cxtOffset; + const cy_stc_capsense_sensor_context_t *ptrSnsCxt; + cy_stc_capsense_widget_config_t const *ptrWdgtCfg; + + if (NULL != context) + { + if ((context->ptrCommonConfig->numWd > widgetId) && + (context->ptrWdConfig[widgetId].numSns > sensorId)) + { + /* Get a pointer to the specified widget configuration structure */ + ptrWdgtCfg = &context->ptrWdConfig[widgetId]; + /* Get a pointer to the specified sensor context structure */ + ptrSnsCxt = &ptrWdgtCfg->ptrSnsContext[sensorId]; + + /* Check baselines */ + + cxtOffset = sensorId; + bslnInv = (uint16_t)(~(ptrWdgtCfg->ptrBslnInv[cxtOffset])); + if ((ptrSnsCxt->bsln != bslnInv) || + (ptrSnsCxt->bsln > baselineHighLimit) || + (ptrSnsCxt->bsln < baselineLowLimit)) + { + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_BSLN_INTEGRITY_MASK; + result = CY_CAPSENSE_BIST_FAIL_E; + } + + if (CY_CAPSENSE_BIST_FAIL_E != result) + { + result = CY_CAPSENSE_BIST_SUCCESS_E; + } + } + } + + return result; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_RAW_INTEGRITY_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_CheckIntegritySensorRawcount_V3Lp +****************************************************************************//** +* +* Checks the raw count of the specified widget/sensor is within the specified +* range. +* +* The raw count is within a specific range (based on the calibration target) +* for good units. The function checks whether or not the raw count is within +* the user-defined limits in the ranges function arguments. +* If the raw count is out of limits, this function sets the +* CY_CAPSENSE_BIST_RAW_INTEGRITY_MASK bit in the .testResultMask field of the +* \ref cy_stc_capsense_bist_context_t structure. +* +* This function does not update the CY_CAPSENSE_WD_WORKING_MASK bit of +* the .status field in \ref cy_stc_capsense_widget_context_t structure +* and is not available in the Cy_CapSense_RunSelfTest() function. +* +* Use this function to verify the uniformity of sensors, for example, at +* mass-production or during an operation phase together with the +* Cy_CapSense_CheckIntegritySensorBaseline() function. +* +* \note +* This function is available only for the fifth-generation CAPSENSE™. +* +* \param widgetId +* Specifies the ID number of the widget. +* A macro for the widget ID can be found in the +* CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__WDGT_ID. +* +* \param sensorId +* Specifies the ID number of the sensor within the widget. +* A macro for the sensor ID within the specified widget can be found in +* the CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__SNS_ID. +* +* \param rawcountHighLimit +* Specifies the upper limit for the widget/sensor raw count. +* +* \param rawcountLowLimit +* Specifies the lower limit for the widget/sensor raw count. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The raw count is within the +* specified range. +* - CY_CAPSENSE_BIST_FAIL_E - The test failed and raw count is out +* of the specified limits. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The test was not executed. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount_V3Lp( + uint32_t widgetId, + uint32_t sensorId, + uint16_t rawcountHighLimit, + uint16_t rawcountLowLimit, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; + const cy_stc_capsense_sensor_context_t *ptrSnsCxt; + cy_stc_capsense_widget_config_t const *ptrWdgtCfg; + + if (NULL != context) + { + if ((context->ptrCommonConfig->numWd > widgetId) && + (context->ptrWdConfig[widgetId].numSns > sensorId)) + { + /* Find a pointer to the specified widget configuration structure */ + ptrWdgtCfg = &context->ptrWdConfig[widgetId]; + /* Find a pointer to the specified sensor context structure */ + ptrSnsCxt = &ptrWdgtCfg->ptrSnsContext[sensorId]; + /* Check raw counts */ + if ((ptrSnsCxt->raw > rawcountHighLimit) || + (ptrSnsCxt->raw < rawcountLowLimit)) + { + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_RAW_INTEGRITY_MASK; + result = CY_CAPSENSE_BIST_FAIL_E; + } + + if (CY_CAPSENSE_BIST_FAIL_E != result) + { + result = CY_CAPSENSE_BIST_SUCCESS_E; + } + } + } + + return result; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_RAW_INTEGRITY_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_CheckIntegritySensorPins_V3Lp +****************************************************************************//** +* +* Checks the specified widget/sensor for shorts to GND, VDD or other sensors. +* +* This function performs several sub-tests to verify the specified sensor +* is not electrically shorted and is in a good condition to reliably detect +* user interactions. +* +* This function performs tests to check if the specified sensor is shorted to: +* * GND +* * VDD +* * Other GPIOs used by CAPSENSE™ (such as sensors, Tx, Rx, +* shield electrodes, and external capacitors) +* * Other non-CAPSENSE™ GPIOs (only if they are configured +* in a strong high or low state during the test execution). +* +* The absolute resistance of an electrical short must be less than 1500 Ohm +* including all series resistors on a sensor for a short to be detected +* to GND, VDD or GPIOs. For example, if a series resistor on a sensor is +* 560 Ohm (as recommended) and the sensor is shorted with another sensor, +* the function can detect a short with a short resistance up to 380 Ohm as +* there are two 560 ohm resistors between the shorted sensor GPIOs. +* +* The function executes the following flow to detect a short: +* * Configures all CAPSENSE™ controlled GPIOs to strong-drive-high, +* and the specified sensor GPIO to resistive pull down mode. +* * Waits for a delay (defined by .snsIntgShortSettlingTime field +* of the \ref cy_stc_capsense_bist_context_t structure) to get established +* all transient processes. +* * Checks the status of the specified sensor for the expected state +* (logic low). +* * Configures all CAPSENSE™ controlled GPIOs to strong-drive-low, +* and the specified sensor GPIO to resistive pull up mode. +* * Waits for the above mentioned delay. +* * Checks the status of the specified sensor for the expected state +* (logic high). +* * Stores the test result in the CAPSENSE™ Data Structure. +* A short is reported only when the sensor status check returns +* an unexpected state. +* +* Due to the sensor parasitic capacitance and internal pull-up/down resistance, +* logic high-to-low (and vice versa) transitions require a settling time before +* checking the sensor status. A 2us delay is used as a settling time and can +* be changed using the .snsIntgShortSettlingTime field +* of the cy_stc_capsense_bist_context_t structure. +* +* If a short is detected this function updates the following statuses: +* * The widget ID is stored to the .shortedWdId field +* of the \ref cy_stc_capsense_bist_context_t structure. +* * The sensor ID is stored to the .shortedSnsId field +* of the \ref cy_stc_capsense_bist_context_t structure. +* * The CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK bit is set in the .testResultMask field +* of the \ref cy_stc_capsense_bist_context_t structure. +* * If CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK is already set due to a previously +* detected fault on any of the sensor, this function does not update +* the .shortedWdId and .shortedSnsId fields. For this reason, +* clear the CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK bit prior calling this function. +* * The widget is disabled by clearing the CY_CAPSENSE_WD_WORKING_MASK bit +* in the .status field of the \ref cy_stc_capsense_widget_context_t structure +* of the specified widget. +* The disabled widget is ignored by high-level functions of scanning / data +* processing. To restore the widget operation +* the application layer should manually set the CY_CAPSENSE_WD_WORKING_MASK +* bit in the .status field of the \ref cy_stc_capsense_widget_context_t structure +* of the specified widget. +* +* To check all the project sensors at once, use the Cy_CapSense_RunSelfTest() +* function with the CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK mask. +* +* To detect an electrical short or fault condition with resistance +* higher than 1500 ohm, the Cy_CapSense_MeasureCapacitanceSensorElectrode() function can +* be used as the fault condition affects the measured sensor capacitance. +* +* This test can be executed only if the CAPSENSE™ Middleware is in the IDLE +* state. This function must not be called while CAPSENSE™ Middleware is busy. +* +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* Rx/Lx electrodes for ISX widgets are excluded from the test as +* they are electrically shorted to GND and the CY_CAPSENSE_BIST_BAD_PARAM_E result +* for such widgets is returned. +* +* \param widgetId +* Specifies the ID number of the widget. +* A macro for the widget ID can be found in the +* CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__WDGT_ID. +* +* \param sensorId +* Specifies the ID of the sensor (electrode for CSX widgets) within the widget +* to be tested. +* +* For the CSD widgets, a macro for the sensor ID within the specified widget +* can be found in the CAPSENSE™ Configuration header file (cycfg_capsense.h) +* defined as CY_CAPSENSE__SNS_ID. +* +* For the CSX widgets, sensorId is an electrode ID and is defined as Rx ID +* or Tx ID. The first Rx in a widget corresponds to electrodeId = 0, the +* second Rx in a widget corresponds to electrodeId = 1, and so on. +* The last Tx in a widget corresponds to electrodeId = (RxNum + TxNum - 1). +* Macros for Rx and Tx IDs can be found in the CAPSENSE™ Configuration header +* file (cycfg_capsense.h) defined as: +* * CapSense__RX_ID +* * CapSense__TX_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - Sensor pin resistances are in defined range. +* - CY_CAPSENSE_BIST_FAIL_E - The test failed and Sensor pin resistances +* are out of the defined range. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The test was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a +* previous operation. The function +* was not executed. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorPins_V3Lp( + uint32_t widgetId, + uint32_t sensorId, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; + uint32_t numWdgtElectrodes; + + if (NULL != context) + { + if (context->ptrCommonConfig->numWd > widgetId) + { + if (CY_CAPSENSE_ISX_GROUP != context->ptrWdConfig[widgetId].senseMethod) + { + /* Get a total number of the widget elements: for CSX it is numRows + numCols, for CSD it is totalNumSns */ + if (CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) + { + /* For the CSX widgets, get the index of the Rx electrode */ + numWdgtElectrodes = context->ptrWdConfig[widgetId].numRows + + (uint32_t)context->ptrWdConfig[widgetId].numCols; + } + else + { + numWdgtElectrodes = context->ptrWdConfig[widgetId].numSns; + } + if (numWdgtElectrodes > sensorId) + { + /* Initialize the result */ + result = CY_CAPSENSE_BIST_SUCCESS_E; + /* Release previously-captured HW resources by the other mode and capture them for BIST */ + if ((uint32_t)CY_CAPSENSE_SUCCESS_E == Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY, context)) + { + /* Switch the HW resource configuration to the sensor short test */ + Cy_CapSense_BistSwitchHwConfig(CY_CAPSENSE_BIST_HW_SHORT_E, CY_CAPSENSE_UNDEFINED_GROUP, 0u, + context); + + /* Set all CAPSENSE™ pins to strong-high */ + Cy_CapSense_BistSwitchAllSnsPinState(CY_CAPSENSE_BIST_IO_STRONG_HIGH_E, context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_BistSwitchAllShieldPinState(CY_CAPSENSE_BIST_IO_STRONG_HIGH_E, context); + #endif + Cy_CapSense_BistSwitchAllExternalCapPinState(CY_CAPSENSE_BIST_IO_STRONG_HIGH_E, context); + + /* Wait for the maximum possible external capacitor charging time */ + Cy_SysLib_DelayUs(context->ptrBistContext->snsIntgShortSettlingTime); + + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_SnsShortCheckSensor(widgetId, sensorId, CY_CAPSENSE_BIST_DR_PIN2VDD, context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + } + + /* Set all CAPSENSE™ pins to strong-low */ + Cy_CapSense_BistSwitchAllSnsPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_BistSwitchAllShieldPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + #endif + Cy_CapSense_BistSwitchAllExternalCapPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + + /* Wait for the maximum possible external capacitor charging time */ + Cy_SysLib_DelayUs(context->ptrBistContext->snsIntgShortSettlingTime); + + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_SnsShortCheckSensor(widgetId, sensorId, CY_CAPSENSE_BIST_DR_PIN2GND, context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + } + } + else + { + result = CY_CAPSENSE_BIST_HW_BUSY_E; + } + } + } + } + } + + return result; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SnsShortCheckSensor +****************************************************************************//** +* +* The internal function checks if the specified sensor element is shorted +* to the VDD or GND level by configuring each of its electrodes to pull-up or +* pull-down and check their state. +* +* An additional delay is added between configuring the electrode and +* reading its state to establish the transition process for cases +* with big capacitance and short resistance. +* The function assumes all rest electrodes are set to strong drive mode, +* so the sensor-to-sensor short condition is also detected. +* +* \param widgetId +* Specifies the ID number of the widget. +* A macro for the widget ID can be found in the +* CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__WDGT_ID. +* +* \param sensorId +* Specifies the ID of the sensor element within the widget to change +* its pin state. +* * For the CSD widgets, use the sensor ID. A macro for the +* sensor ID within a specified widget can be found in the cycfg_capsense.h +* file defined as CY_CAPSENSE__SNS_ID. +* * For the CSX widgets use either Rx ID or Tx ID. +* The first Rx in a widget corresponds to sensorElement = 0; the second +* Rx in a widget corresponds to sensorElement = 1, and so on. +* The last Tx in a widget corresponds to sensorElement = (RxNum + TxNum - 1). +* A macro for the Rx ID or Tx ID can be found in the cycfg_capsense.h +* file defined as CY_CAPSENSE___ID. +* +* \param mode +* Specifies the test mode, either: +* * CY_CAPSENSE_BIST_DR_PIN2GND means sensor is configured +* to pull-up and checked for logical 0 +* * CY_CAPSENSE_BIST_DR_PIN2VDD means sensor is configured +* to pull-down and checked for logical 1 +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The sensor pin(s) are not shorted. +* - CY_CAPSENSE_BIST_FAIL_E - A short is detected on the specified sensor. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckSensor( + uint32_t widgetId, + uint32_t sensorId, + uint32_t mode, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t result; + uint32_t ioSnsId; + + if (CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) + { + /* For the CSX widgets, get the index of the Rx electrode */ + ioSnsId = sensorId / context->ptrWdConfig[widgetId].numRows; + result = Cy_CapSense_SnsShortCheckElectrode(widgetId, ioSnsId, mode, context); + if (CY_CAPSENSE_BIST_SUCCESS_E == result) + { + /* For the CSX widgets, get the index of the Tx electrode */ + ioSnsId = (uint32_t)(sensorId % context->ptrWdConfig[widgetId].numRows) + + (uint32_t)context->ptrWdConfig[widgetId].numCols; + result = Cy_CapSense_SnsShortCheckElectrode(widgetId, ioSnsId, mode, context); + } + } + else + { + result = Cy_CapSense_SnsShortCheckElectrode(widgetId, sensorId, mode, context); + } + + if (CY_CAPSENSE_BIST_SUCCESS_E != result) + { + Cy_CapSense_SnsShortUpdateTestResult(widgetId, sensorId, context); + } + return result; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SnsShortCheckElectrode +****************************************************************************//** +* +* This internal function checks if a sensor or Rx or Tx electrode is shorted +* to VDD or GND by configuring each of its pins to pull-up or pull-down +* and checks its state. +* +* An additional delay is added between configuring the electrode and +* reading its state to establish the transition process for cases +* with big capacitance and short resistance. +* The function assumes all rest electrodes are set to strong drive mode, +* so the sensor-to-sensor short condition is also detected. +* +* \param widgetId +* Specifies the ID number of the widget. +* A macro for the widget ID can be found in the +* CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__WDGT_ID. +* +* \param ioSnsId +* Specifies the ID number of the sensor (Rx or Tx electrode for CSX widgets) +* within the widget to be processed. +* +* \param mode +* Specifies the test mode, either: +* * CY_CAPSENSE_BIST_DR_PIN2GND means sensor is configured +* to pull-up and checked for logical 0 +* * CY_CAPSENSE_BIST_DR_PIN2VDD means sensor is configured +* to pull-down and checked for logical 1 +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The sensor pin(s) are not shorted. +* - CY_CAPSENSE_BIST_FAIL_E - A short is detected on the specified sensor. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckElectrode( + uint32_t widgetId, + uint32_t ioSnsId, + uint32_t mode, + const cy_stc_capsense_context_t * context) +{ + uint32_t i; + uint32_t eltdNum; + uint32_t eltdState; + uint32_t eltdDM = CY_GPIO_DM_PULLDOWN; + cy_en_capsense_bist_status_t result; + const cy_stc_capsense_pin_config_t *ioPtr = context->ptrWdConfig[widgetId].ptrEltdConfig[ioSnsId].ptrPin; + + if (CY_CAPSENSE_BIST_DR_PIN2GND == mode) + { + eltdDM = CY_GPIO_DM_PULLUP; + } + + eltdNum = context->ptrWdConfig[widgetId].ptrEltdConfig[ioSnsId].numPins; + + /* Loop through all electrodes of the specified sensor */ + for (i = 0u; i < eltdNum; i++) + { + /* Set pin Drive mode and data register */ + Cy_CapSense_BistSetPinDr(ioPtr, (mode ^ 0x01u)); + Cy_CapSense_BistSetPinPc(ioPtr, eltdDM); + /* Wait for establishing the transition process */ + Cy_SysLib_DelayUs((uint16_t)context->ptrBistContext->snsIntgShortSettlingTime); + /* Read the electrode state */ + eltdState = Cy_GPIO_Read(ioPtr->pcPtr, (uint32_t)ioPtr->pinNumber); + if (CY_CAPSENSE_BIST_DR_PIN2GND != eltdState) + { + eltdState = CY_CAPSENSE_BIST_DR_PIN2VDD; + } + /* Revert the electrode to the default Drive mode */ + Cy_CapSense_BistSetPinDr(ioPtr, mode); + Cy_CapSense_BistSetPinPc(ioPtr, CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF); + /* Check the electrode state */ + if (mode == eltdState) + { + result = CY_CAPSENSE_BIST_FAIL_E; + break; + } + else + { + result = CY_CAPSENSE_BIST_SUCCESS_E; + } + /* Get the next electrode */ + ioPtr++; + } + return result; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SnsShortUpdateTestResult +****************************************************************************//** +* The internal function updates the BIST data structure and Widget Working bit +* in the .status field of the cy_stc_capsense_widget_context_t structure. +* +* The function resets a Widget Working bit, checks the .testResultMask field +* of the cy_stc_capsense_bist_context_t structure +* for the CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK bit and if it was not set to 1, +* the function sets it and memorizes widgetId and sensorId +* in corresponding fields of the cy_stc_capsense_bist_context_t structure. +* +* \param widgetId +* Specifies the ID number of the widget to be processed. +* +* \param sensorId +* Specifies the ID number of the sensor within the widget which +* will be processed. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +static void Cy_CapSense_SnsShortUpdateTestResult( + uint32_t widgetId, + uint32_t sensorId, + cy_stc_capsense_context_t * context) +{ + /* Marks widget non-working */ + (void)Cy_CapSense_SetWidgetStatus(widgetId, 0u, CY_CAPSENSE_WD_WORKING_MASK, context); + if (0Lu == (context->ptrBistContext->testResultMask & CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK)) + { + /* Write to the BIST context structure widgetId and sensorId of the first shorted sensor */ + context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK; + context->ptrBistContext->shortedWdId = (uint8_t)widgetId; + context->ptrBistContext->shortedSnsId = (uint8_t)sensorId; + } +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SnsShortCheckAllSensors +****************************************************************************//** +* +* The internal function that checks for all the sensors short. +* +* The function that checks for shorts on VDD/GND or to another sensors of all +* sensor (not electrode) by using the Cy_CapSense_SnsShortCheckSensor() function. +* The function is called by the Cy_CapSense_RunSelfTest() function. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the test processing: +* - CY_CAPSENSE_BIST_SUCCESS_E if test passed successfully; +* - CY_CAPSENSE_BIST_FAIL_E if any sensor of any widget is +* shorted to VDD or GND. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckAllSensors( + cy_stc_capsense_context_t * context) +{ + uint32_t widgetId; + uint32_t sensorId; + uint32_t numWdgtElectrodes; + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_SUCCESS_E; + + /* Previously-captured HW resources were released by the other mode in the RunSelfTest function */ + /* Switch HW resource configuration to sensor short test */ + Cy_CapSense_BistSwitchHwConfig(CY_CAPSENSE_BIST_HW_SHORT_E, CY_CAPSENSE_UNDEFINED_GROUP, 0u, + context); + + Cy_CapSense_BistSwitchAllSnsPinState(CY_CAPSENSE_BIST_IO_STRONG_HIGH_E, context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_BistSwitchAllShieldPinState(CY_CAPSENSE_BIST_IO_STRONG_HIGH_E, context); + #endif + Cy_CapSense_BistSwitchAllExternalCapPinState(CY_CAPSENSE_BIST_IO_STRONG_HIGH_E, context); + + /* Wait for the maximum possible external capacitor charging time */ + Cy_SysLib_DelayUs(context->ptrBistContext->snsIntgShortSettlingTime); + + for (widgetId = 0u; widgetId < context->ptrCommonConfig->numWd; widgetId++) + { + if (CY_CAPSENSE_ISX_GROUP != context->ptrWdConfig[widgetId].senseMethod) + { + /* Get a total number of the widget elements: for CSX it is numRows + numCols, for CSD it is totalNumSns */ + if (CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) + { + /* For the CSX widgets, get the index of the Rx electrode */ + numWdgtElectrodes = context->ptrWdConfig[widgetId].numRows + + (uint32_t)context->ptrWdConfig[widgetId].numCols; + } + else + { + numWdgtElectrodes = context->ptrWdConfig[widgetId].numSns; + } + + for (sensorId = 0u; sensorId < numWdgtElectrodes; sensorId++) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_SnsShortCheckSensor(widgetId, sensorId, CY_CAPSENSE_BIST_DR_PIN2VDD, context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + break; + } + } + } + } + + Cy_CapSense_BistSwitchAllSnsPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_BistSwitchAllShieldPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + #endif + Cy_CapSense_BistSwitchAllExternalCapPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + + /* Wait for the maximum possible external capacitor charging time */ + Cy_SysLib_DelayUs(context->ptrBistContext->snsIntgShortSettlingTime); + + for (widgetId = 0u; widgetId < context->ptrCommonConfig->numWd; widgetId++) + { + /* Get a total number of the widget elements: for CSX it is numRows + numCols, for CSD it is totalNumSns */ + if (CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) + { + /* For the CSX widgets, get the index of the Rx electrode */ + numWdgtElectrodes = context->ptrWdConfig[widgetId].numRows + + (uint32_t)context->ptrWdConfig[widgetId].numCols; + } + else + { + numWdgtElectrodes = context->ptrWdConfig[widgetId].numSns; + } + + for (sensorId = 0u; sensorId < numWdgtElectrodes; sensorId++) + { + if (CY_CAPSENSE_ISX_GROUP != context->ptrWdConfig[widgetId].senseMethod) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_SnsShortCheckSensor(widgetId, sensorId, CY_CAPSENSE_BIST_DR_PIN2GND, context)) + { + result = CY_CAPSENSE_BIST_FAIL_E; + break; + } + } + } + } + + return result; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_BistSetPinDr +****************************************************************************//** +* +* The internal function that sets a certain pin output data register (DR). +* +* The function sets a pin output data register (DR) in a desired state. +* +* \param *ioPtr +* A pointer to the specified pin in the widget pin configuration structure. +* +* \param value +* A port output data which will be set for the pin. +* +*******************************************************************************/ +static void Cy_CapSense_BistSetPinDr( + cy_stc_capsense_pin_config_t const *ioPtr, + uint32_t value) +{ + uint32_t interruptState; + + /* Set a data register */ + interruptState = Cy_SysLib_EnterCriticalSection(); + Cy_GPIO_Write(ioPtr->pcPtr, (uint32_t)ioPtr->pinNumber, value); + Cy_SysLib_ExitCriticalSection(interruptState); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_BistSetPinPc +****************************************************************************//** +* +* The internal function that sets a certain pin output drive mode (PC). +* +* The function sets a pin port control register (PC) in a desired state. +* +* \param *ioPtr +* A pointer to the specified pin in the widget pin configuration structure. +* +* \param value +* Drive mode to be set for the pin. +* +*******************************************************************************/ +static void Cy_CapSense_BistSetPinPc( + cy_stc_capsense_pin_config_t const *ioPtr, + uint32_t value) +{ + uint32_t interruptState; + + /* Update the port configuration register (Drive mode) */ + interruptState = Cy_SysLib_EnterCriticalSection(); + Cy_GPIO_SetDrivemode(ioPtr->pcPtr, (uint32_t)ioPtr->pinNumber, value); + Cy_SysLib_ExitCriticalSection(interruptState); +} +#endif + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_BistSetAllSnsPinsState +****************************************************************************//** +* +* Sets all CAPSENSE™ pins into a desired state. +* +* Sets all the CSD/CSX IOs into a desired state. +* Default state: +* - HSIOM - Disconnected, the GPIO mode. +* - DM - Strong drive. +* - State - Zero. +* +* Do not call this function directly from the application program. +* +* \param desiredDriveMode +* Specifies the desired pin control port (PC) configuration. +* +* \param desiredPinOutput +* Specifies the desired pin output data register (DR) state. +* +* \param desiredHsiom +* Specifies the desired pin HSIOM state. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_BistSetAllSnsPinsState( + uint32_t desiredDriveMode, + uint32_t desiredPinOutput, + en_hsiom_sel_t desiredHsiom, + const cy_stc_capsense_context_t * context) +{ + uint32_t loopIndex; + const cy_stc_capsense_pin_config_t * ptrPinCfg = context->ptrPinConfig; + + /* Loop through all electrodes */ + for (loopIndex = 0u; loopIndex < context->ptrCommonConfig->numPin; loopIndex++) + { + Cy_CapSense_SsConfigPinRegisters(ptrPinCfg->pcPtr, + (uint32_t)ptrPinCfg->pinNumber, desiredDriveMode, desiredHsiom, CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN); + + if (0u != desiredPinOutput) + { + Cy_GPIO_Set(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber); + } + else + { + Cy_GPIO_Clr(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber); + } + /* Get next electrode */ + ptrPinCfg++; + } +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_BistSetAllShieldPinsState +****************************************************************************//** +* +* Sets all shield pins into a desired state. +* +* Sets all the dedicated shield electrodes into a desired state. +* Do not call this function directly from the application program. +* +* \param desiredDriveMode +* Specifies the desired pin control port (PC) configuration. +* +* \param desiredPinOutput +* Specifies the desired pin output data register (DR) state. +* +* \param desiredHsiom +* Specifies the desired pin HSIOM state. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_BistSetAllShieldPinsState( + uint32_t desiredDriveMode, + uint32_t desiredPinOutput, + en_hsiom_sel_t desiredHsiom, + const cy_stc_capsense_context_t * context) +{ + uint32_t loopIndex; + const cy_stc_capsense_pin_config_t * ptrPinCfg = context->ptrShieldPinConfig; + + /* Loop through all electrodes */ + for (loopIndex = 0u; loopIndex < context->ptrCommonConfig->csdShieldNumPin; loopIndex++) + { + Cy_CapSense_SsConfigPinRegisters(ptrPinCfg->pcPtr, + (uint32_t)ptrPinCfg->pinNumber, desiredDriveMode, desiredHsiom, CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN); + + if (0u != desiredPinOutput) + { + Cy_GPIO_Set(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber); + } + else + { + Cy_GPIO_Clr(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber); + } + /* Get next electrode */ + ptrPinCfg++; + } +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_BistSetAllCmodPinsState +****************************************************************************//** +* +* Sets all available MSC Cmod pins connected into a desired state . +* +* Sets all external capacitors connected into a desired state. +* Do not call this function directly from the application program. +* +* \param desiredDriveMode +* Specifies the desired pin control port (PC) configuration. +* +* \param desiredPinOutput +* Specifies the desired pin output data register (DR) state. +* +* \param desiredHsiom +* Specifies the desired pin HSIOM state. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_BistSetAllCmodPinsState( + uint32_t desiredDriveMode, + uint32_t desiredPinOutput, + en_hsiom_sel_t desiredHsiom, + const cy_stc_capsense_context_t * context) +{ + uint32_t curChIndex; + + uint8_t cmod1Pin; + uint8_t cmod2Pin; + + GPIO_PRT_Type * cmod1Port; + GPIO_PRT_Type * cmod2Port; + + const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; + + /* Loop through all electrodes */ + for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) + { + cmod1Port = ptrCommonCfg->ptrChConfig[curChIndex].portCmod1; + cmod1Pin = ptrCommonCfg->ptrChConfig[curChIndex].pinCmod1; + + cmod2Port = ptrCommonCfg->ptrChConfig[curChIndex].portCmod2; + cmod2Pin = ptrCommonCfg->ptrChConfig[curChIndex].pinCmod2; + + Cy_CapSense_SsConfigPinRegisters(cmod1Port, (uint32_t)cmod1Pin, desiredDriveMode, desiredHsiom, CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN); + Cy_CapSense_SsConfigPinRegisters(cmod2Port, (uint32_t)cmod2Pin, desiredDriveMode, desiredHsiom, CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN); + + if (0u != desiredPinOutput) + { + Cy_GPIO_Set(cmod1Port, (uint32_t)cmod1Pin); + } + else + { + Cy_GPIO_Clr(cmod1Port, (uint32_t)cmod1Pin); + } + + if (0u != desiredPinOutput) + { + Cy_GPIO_Set(cmod2Port, (uint32_t)cmod2Pin); + } + else + { + Cy_GPIO_Clr(cmod2Port, (uint32_t)cmod2Pin); + } + } +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceSensorElectrode_V3Lp +****************************************************************************//** +* +* Measures the specified CSD sensor / CSX electrode capacitance in femtofarads. +* +* This function measures the sensor capacitance for CSD widgets or the electrode +* capacitance for CSX +* widgets and returns the measurement status. For a CSX sensor, the +* measurement is done on either Rx or Tx electrode. +* For a CSD sensor, measurement is done on a sensor (refer to the +* eltdId parameter description). +* The function does not measure capacitances of Lx/Rx electrodes of the ISX widgets +* as they are electrically connected to the GND. +* The CY_CAPSENSE_BIST_BAD_PARAM_E status for such a widget is returned. +* If the specified sensor (electrode) is a ganged sensor, the capacitance +* is measured for all the pins ganged together that belong to this sensor +* (electrode). +* +* The measured capacitance is stored in the .eltdCap[] array. +* The .ptrEltdCapacitance field of the +* \ref cy_stc_capsense_widget_config_t structure contains a pointer to +* the first widget sensor (electrode) element within the .eltdCap[] array. +* +* In addition to the measuring sensor (electrode) capacitance, this function +* is used to identify various fault conditions with sensors such +* as electrically-opened or -shorted sensors. For example, the PCB track is +* broken or shorted to other nodes in the system - in all of these conditions, +* this function returns changed capacitance which can be compared +* against predetermined capacitance for the sensor to detect a +* fault condition. +* +* The sensor capacitance is measured independently of the sensor scan +* configuration. For the capacitance measurement, the CSD sensing method is used. +* The default scanning parameters are the following: +* * SnsClk divider (256) is the divider for the sensor clock frequency. +* * NumConv (100) is the number of sub-conversions. +* * The reference CDAC capacitance (886 fF) is equivalent to CDAC Code of 100u. +* * The compensation CDAC is disabled. +* * The CIC2 filter is disabled. +* * The dithering is disabled. +* * The chopping is disabled. +* +* The raw count is converted into capacitance using the following equation: +* +* Cs = Rawcount * RefCDAC capacitance / NumConv +* +* where: +* * Cs is the sensor capacitance. +* * Rawcount is the measured raw count value. +* +* The minimum measurable input by this function is 1pF and the +* maximum is either 200pF or limited by the RC time constant +* (Cs < 1 / (2*5*SnsClk*R), where R is the total sensor series +* resistance that includes on-chip GPIO resistance ~500 Ohm and +* external series resistance). The measurement accuracy is about 30% and +* is defined by the RefCDAC tolerance. +* +* By default, all CAPSENSE™ sensors (electrodes) that are not being +* measured are set to the GND state for CSD measured electrodes (sensors) and +* to the HIGH-Z state for CSX measured electrodes (Rx and Tx). +* Shield electrodes are also configured to the GND state. +* The inactive state can be changed in run-time by using +* the Cy_CapSense_SetInactiveElectrodeState() function. +* +* By default, the both Cmod1 and Cmod2 capacitors are used for the measurement. +* +* The sensor measurement can be done on all the electrodes using +* the Cy_CapSense_RunSelfTest() function along with +* the CY_CAPSENSE_BIST_ELTD_CAP_MASK mask. +* +* This function must not be called while the CAPSENSE™ MW is busy +* by another scan. +* +* \note +* This function is available only for the fifth-generation low power +* CAPSENSE™. +* +* \param widgetId +* Specifies the ID number of the widget. +* A macro for the widget ID can be found in the +* CAPSENSE™ Configuration header file (cycfg_capsense.h) defined as +* CY_CAPSENSE__WDGT_ID. +* +* \param eltdId +* Specifies the ID of the electrode within the widget (sensorID for CSD +* widgets and Rx or Tx electrode ID for CSX widgets). +* +* For the CSD widgets, a macro for the sensor ID within the specified widget +* can be found in the CAPSENSE™ Configuration header file (cycfg_capsense.h) +* defined as CY_CAPSENSE__SNS_ID. +* +* For the CSX widgets, eltdId is an electrode ID and is defined as Rx ID +* or Tx ID. The first Rx in a widget corresponds to eltdId = 0, the +* second Rx in a widget corresponds to eltdId = 1, and so on. +* The last Tx in a widget corresponds to eltdId = (RxNum + TxNum - 1). +* Macros for Rx and Tx IDs can be found in the CAPSENSE™ Configuration header +* file (cycfg_capsense.h) defined as: +* * CapSense__RX_ID +* * CapSense__TX_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a +* previous operation. +* The measurement was not executed. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode_V3Lp( + uint32_t widgetId, + uint32_t eltdId, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; + uint32_t numWdgtElectrodes = 0u; + uint32_t snsFrameType = CY_CAPSENSE_SNS_FRAME_ACTIVE; + + if (NULL != context) + { + if ((context->ptrCommonConfig->numWd > widgetId)) + { + /* Get the total widget electrode number: for CSX it is numRows + numCols, for CSD it is totalNumSns */ + switch (context->ptrWdConfig[widgetId].senseMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + result = CY_CAPSENSE_BIST_SUCCESS_E; + numWdgtElectrodes = context->ptrWdConfig[widgetId].numSns; + context->ptrBistContext->currentISC = context->ptrBistContext->intrEltdCapCsdISC; + break; + #endif + + /* For CSX and ISX widgets, get the sum of Rx and Tx electrode numbers */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + result = CY_CAPSENSE_BIST_SUCCESS_E; + numWdgtElectrodes = context->ptrWdConfig[widgetId].numRows + + (uint32_t)context->ptrWdConfig[widgetId].numCols; + context->ptrBistContext->currentISC = context->ptrBistContext->intrEltdCapCsxISC; + break; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_GROUP: + /* exit with CY_CAPSENSE_BIST_BAD_PARAM_E */ + #endif + default: + /* Do nothing */ + break; + } + + if ((numWdgtElectrodes > eltdId) && (CY_CAPSENSE_BIST_BAD_PARAM_E != result)) + { + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + { + /* Set the BUSY status and switch the HW configuration to BIST */ + context->ptrCommonContext->status = CY_CAPSENSE_BUSY | CY_CAPSENSE_MW_STATE_BIST_MASK; + (void)Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY, context); + /* Store the the pointer to the electrode pin configuration to the Bist context structure */ + context->ptrBistContext->curPtrEltdCfg = &context->ptrWdConfig[widgetId].ptrEltdConfig[eltdId]; + /* Switch the HW configuration to the sensor electrode capacitance measurement */ + Cy_CapSense_BistSwitchHwConfig(CY_CAPSENSE_BIST_HW_ELTD_CAP_E, + CY_CAPSENSE_CSD_GROUP, + CY_CAPSENSE_BIST_CAP_ELTD_SCAN, + context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == context->ptrWdConfig[widgetId].wdType) + { + snsFrameType = CY_CAPSENSE_SNS_FRAME_LOW_POWER; + } + #endif + result = Cy_CapSense_BistMeasureCapacitanceSensor( + &context->ptrWdConfig[widgetId].ptrEltdCapacitance[eltdId], + snsFrameType, + context); + /* Clear the BUSY flag */ + context->ptrCommonContext->status = CY_CAPSENSE_NOT_BUSY; + } + else + { + result = CY_CAPSENSE_BIST_HW_BUSY_E; + } + } + } + } + + return result; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceAllSensors +****************************************************************************//** +* +* This internal function measures all the sensor capacitances +* (Cp for CSD sensors and Cm for CSX sensors). +* +* This function measures capacitances of all the sensors by using the +* Cy_CapSense_MeasureCapacitanceSlotSensors() function. +* The function stores sensor capacitance values in femtofarads +* in the snsCap array defined +* in the cycfg_capsense.c file. The pointer to the first element of the snsCap +* array that contains the widget sensor capacitances is stored +* in the .ptrSnsCapacitance field of the cy_stc_capsense_widget_config_t +* structure. +* The function is called by the Cy_CapSense_RunSelfTest() function. +* +* \note +* Rx/Lx electrodes for ISX widgets are excluded from measuring. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the measuring process: +* - CY_CAPSENSE_BIST_SUCCESS_E if all the measurements passed successfully. +* - CY_CAPSENSE_BIST_FAIL_E if any measurement was failed. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceAllSensors( + cy_stc_capsense_context_t * context) +{ + uint32_t slotId; + uint32_t widgetId; + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_SUCCESS_E; + const cy_stc_capsense_scan_slot_t * ptrScanSlots = context->ptrScanSlots; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + const cy_stc_capsense_scan_slot_t * ptrLpScanSlots = context->ptrLpScanSlots; + #endif + + /* Loop through all the slots */ + for (slotId = 0u; slotId < CY_CAPSENSE_SLOT_COUNT; slotId++) + { + widgetId = ptrScanSlots[slotId].wdId; + if (CY_CAPSENSE_ISX_GROUP != context->ptrWdConfig[widgetId].senseMethod) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceSlotSensors_V3Lp(slotId, 0u, context)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E == result) + { + result = CY_CAPSENSE_BIST_FAIL_E; + } + } + } + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + for (slotId = 0u; slotId < CY_CAPSENSE_SLOT_LP_COUNT; slotId++) + { + widgetId = ptrLpScanSlots[slotId].wdId; + if (CY_CAPSENSE_ISX_GROUP != context->ptrWdConfig[widgetId].senseMethod) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceLpSlotSensors(slotId, context)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E == result) + { + result = CY_CAPSENSE_BIST_FAIL_E; + } + } + } + } + #endif + + return result; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceAllElectrodes +****************************************************************************//** +* +* This internal function measures all the electrodes (sensor for CSD widgets and +* Rx/Tx electrodes for CSX widgets) parasitic capacitance (Cp). +* +* This function measures Cp of all the electrodes by using the +* Cy_CapSense_MeasureCapacitanceSensorElectrode() function. +* The function stores the Cp values in femtofarads in the eltdCap array defined +* in the cycfg_capsense.c file. The pointer to the first element of the eltdCap +* array that contains the widget electrode capacitances is stored +* in the .ptrEltdCapacitance field of the cy_stc_capsense_widget_config_t +* structure. +* The function is called by the Cy_CapSense_RunSelfTest() function. +* +* \note +* Rx/Lx electrodes for ISX widgets are excluded from measuring. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the measuring process: +* - CY_CAPSENSE_BIST_SUCCESS_E if all the measurements passed successfully. +* - CY_CAPSENSE_BIST_FAIL_E if any measurement was failed. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceAllElectrodes( + cy_stc_capsense_context_t * context) +{ + uint32_t widgetId; + uint32_t electrodeId; + uint32_t numWdgtElectrodes; + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_SUCCESS_E; + + /* Loop through all the widgets */ + for (widgetId = 0u; widgetId < context->ptrCommonConfig->numWd; widgetId++) + { + if (CY_CAPSENSE_ISX_GROUP != context->ptrWdConfig[widgetId].senseMethod) + { + /* Get a total number of the widget elements: for CSX, it is numRows + numCols, for CSD, it is totalNumSns */ + if (CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) + { + numWdgtElectrodes = context->ptrWdConfig[widgetId].numRows + + (uint32_t)context->ptrWdConfig[widgetId].numCols; + } + else + { + numWdgtElectrodes = context->ptrWdConfig[widgetId].numSns; + } + /* Loop through all the sensor electrodes */ + for (electrodeId = 0u; electrodeId < numWdgtElectrodes; electrodeId++) + { + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceSensorElectrode_V3Lp(widgetId, electrodeId, context)) + { + if (CY_CAPSENSE_BIST_SUCCESS_E == result) + { + result = CY_CAPSENSE_BIST_FAIL_E; + } + } + } + } + } + + return result; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceSlotSensors_V3Lp +****************************************************************************//** +* +* Measures the specified slot sensor capacitance in femtofarads. The function +* measures the Cp capacitance for CSD widgets and the Cm capacitance +* for CSX widgets. +* +* This function performs BIST slot scan with predefined parameters, +* back-calculates the slot sensor capacitances (Cp for CSD and Cm for CSX) +* by using the raw-count equation, stores the calculated capacitances +* to the sensor context structure, and returns the measurement status. +* If the specified slot has a ganged sensor, the capacitance +* is measured for all the pins ganged together that belong to this sensor. +* The function does not measure capacitances of Lx/Rx electrodes of the ISX widgets +* as they are electrically connected to the GND. +* The CY_CAPSENSE_BIST_BAD_PARAM_E status for such a widget is returned. +* +* Besides the sensor capacitance measuring, this function could be +* used to identify various fault conditions with sensors such +* as electrically-opened or -shorted sensors. For example, the PCB track is +* broken or shorted to other nodes in the system - in all of these conditions, +* the function returns changed capacitance which can be compared +* against predetermined capacitance for the sensor to detect a +* fault condition. +* +* The sensor capacitance is measured independently of the sensor regular scan +* configuration. For the capacitance measurement, the BIST specific scan +* parameters are used. They can be found in the Electrode capacitance measurement +* macros group. +* The CDAC code for the CSD sensors is 100u and that provides about 0.886 pF +* of the CDAC value and for CSX sensors the CDAC code is 50u (0.443 pF). +* Compensation CDAC is disabled during the BIST scan. +* Another default scanning parameters are the following: +* * NumConv (100) is the number of sub-conversions. +* * SnsClk divider (256) is the divider for the sensor clock frequency. +* +* The raw count is converted into capacitance using the following equation: +* +* Cs = Rawcount * CDAC / 2 / NumConv / 2 +* +* where: +* * Cs is the sensor capacitance. +* * Rawcount is the measured raw count value. +* * The first divider of 2 is determined by the divided ref_clk frequency usage. +* * The second divider of 2 is used only for CSX sensors. +* +* The minimum measurable input by this function is 0.5 pF and the +* maximum is either 200pF or limited by the RC time constant +* (Cs < 1 / (2*10*SnsClk*R), where R is the total sensor series +* resistance that includes on-chip pin resistance ~500 Ohm and +* external series resistance). The measurement accuracy is about 30%. +* +* By default, all CAPSENSE™ sensors (electrodes) that are not being +* measured are set to the GND state for CSD measured electrodes (sensors) and +* to the HIGH-Z state for CSX measured electrodes (Rx and Tx). +* Shield electrodes are also configured to the GND state. +* The inactive state can be changed in run-time by using +* the Cy_CapSense_SetInactiveElectrodeState() function. +* +* By default, the both Cmod1 and Cmod2 capacitors are used for the measurement. +* +* Measured capacitance values (Cp for CSD widgets and Cm for CSX widgets) +* are stored in the .snsCap field of the \ref cy_stc_capsense_sensor_context_t +* structure. +* +* The all sensor measurement can be done on all the sensors using +* the Cy_CapSense_RunSelfTest() function along with +* the CY_CAPSENSE_BIST_SNS_CAP_MASK mask. +* +* This function must not be called while the CAPSENSE™ MW is busy +* by another scan. +* +* \note +* This function is available only for the fifth-generation low power +* CAPSENSE™. +* +* \param slotId +* Specifies the ID number of the slot to measure sensor capacitance. +* The slot ID should be in the admissible range. +* +* \param skipChMask +* This argument is kept for uniformity and backward compatibility +* and is not used. The function can be called with value NULL. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a +* previous operation. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors_V3Lp( + uint32_t slotId, + uint32_t skipChMask, + cy_stc_capsense_context_t * context) +{ + (void) skipChMask; + return Cy_CapSense_MeasureCapacitanceSlotSensorsInternal(slotId, CY_CAPSENSE_SNS_FRAME_ACTIVE, context); +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN)) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceLpSlotSensors +****************************************************************************//** +* +* Measures the specified low power slot sensor capacitance in femtofarads. +* The function measures the Cp capacitance for CSD widgets and the Cm +* capacitance for CSX widgets. +* +* This function performs BIST slot scan with predefined parameters, +* back-calculates the slot sensor capacitances (Cp for CSD and Cm for CSX) +* by using the raw-count equation, stores the calculated capacitances +* to the sensor context structure, and returns the measurement status. +* If the specified slot has a ganged sensor, the capacitance +* is measured for all the pins ganged together that belong to this sensor. +* +* Besides the sensor capacitance measuring, this function could be +* used to identify various fault conditions with sensors such +* as electrically-opened or -shorted sensors. For example, the PCB track is +* broken or shorted to other nodes in the system - in all of these conditions, +* the function returns changed capacitance which can be compared +* against predetermined capacitance for the sensor to detect a +* fault condition. +* +* The sensor capacitance is measured independently of the sensor regular scan +* configuration. For the capacitance measurement, the BIST specific scan +* parameters are used. They can be found in the Electrode capacitance measurement +* macros group. +* The CDAC code for the CSD sensors is 100u and that provides about 0.886 pF +* of the CDAC value and for CSX sensors the CDAC code is 50u (0.443 pF). +* Compensation CDAC is disabled during the BIST scan. +* Another default scanning parameters are the following: +* * NumConv (100) is the number of sub-conversions. +* * SnsClk divider (256) is the divider for the sensor clock frequency. +* +* The raw count is converted into capacitance using the following equation: +* +* Cs = Rawcount * CDAC / 2 / NumConv / 2 +* +* where: +* * Cs is the sensor capacitance. +* * Rawcount is the measured raw count value. +* * The first divider of 2 is determined by the divided ref_clk frequency usage. +* * The second divider of 2 is used only for CSX sensors. +* +* The minimum measurable input by this function is 0.5 pF and the +* maximum is either 200pF or limited by the RC time constant +* (Cs < 1 / (2*10*SnsClk*R), where R is the total sensor series +* resistance that includes on-chip pin resistance ~500 Ohm and +* external series resistance). The measurement accuracy is about 30%. +* +* By default, all CAPSENSE™ sensors (electrodes) that are not being +* measured are set to the GND state for CSD measured electrodes (sensors) and +* to the HIGH-Z state for CSX measured electrodes (Rx and Tx). +* Shield electrodes are also configured to the GND state. +* The inactive state can be changed in run-time by using +* the Cy_CapSense_SetInactiveElectrodeState() function. +* +* By default, the both Cmod1 and Cmod2 capacitors are used for the measurement. +* +* Measured capacitance values (Cp for CSD widgets and Cm for CSX widgets) +* are stored in the .snsCap field of the \ref cy_stc_capsense_sensor_context_t +* structure. +* +* The all sensor measurement can be done on all the sensors using +* the Cy_CapSense_RunSelfTest() function along with +* the CY_CAPSENSE_BIST_SNS_CAP_MASK mask. +* +* This function must not be called while the CAPSENSE™ MW is busy +* by another scan. +* +* \note +* This function is available for the fifth-generation and fifth-generation +* low power CAPSENSE™. +* +* \param slotId +* Specifies the ID number of the slot to measure sensor capacitance. +* The slot ID should be in the admissible range. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a +* previous operation. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceLpSlotSensors( + uint32_t slotId, + cy_stc_capsense_context_t * context) +{ + return Cy_CapSense_MeasureCapacitanceSlotSensorsInternal(slotId, CY_CAPSENSE_SNS_FRAME_LOW_POWER, context); +} +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN)) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceSlotSensorsInternal +****************************************************************************//** +* +* Internal function to measure the specified slot sensor capacitance in +* femtofarads. The function measures the Cp capacitance for CSD widgets and +* the Cm capacitance for CSX widgets. +* +* \param slotId +* Specifies the ID number of the slot to measure sensor capacitance. +* The slot ID should be in the admissible range. +* +* \param snsFrameType +* The Sensor Frame type: +* * CY_CAPSENSE_SNS_FRAME_ACTIVE - Sensor frame for Active slot +* * CY_CAPSENSE_SNS_FRAME_LOW_POWER - Sensor frame for Low Power slot +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a +* previous operation. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensorsInternal( + uint32_t slotId, + uint32_t snsFrameType, + cy_stc_capsense_context_t * context) +{ + uint32_t wdIndex; + uint32_t numSlots; + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + + if (NULL != context) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if (snsFrameType == CY_CAPSENSE_SNS_FRAME_ACTIVE) + { + ptrScanSlots = context->ptrScanSlots; + numSlots = CY_CAPSENSE_SLOT_COUNT; + } + else + { + ptrScanSlots = context->ptrLpScanSlots; + numSlots = CY_CAPSENSE_SLOT_LP_COUNT; + } + #else + ptrScanSlots = context->ptrScanSlots; + numSlots = CY_CAPSENSE_SLOT_COUNT; + (void)snsFrameType; + #endif + if (numSlots > slotId) + { + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + { + /* Set the BUSY status */ + context->ptrCommonContext->status = CY_CAPSENSE_BUSY | CY_CAPSENSE_MW_STATE_BIST_MASK; + (void)Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY, context); + /* Set the slot measurement mode for the BIST scan */ + context->ptrBistContext->eltdCapScanMode = CY_CAPSENSE_BIST_CAP_SLOT_SCAN; + /* Store the current slot for the BIST scan */ + context->ptrBistContext->curBistSlotId = (uint16_t)slotId; + /* Initializes the active sensor structure for the current sensor */ + wdIndex = ptrScanSlots[slotId].wdId; + /* Define the current ISC for BIST scan. + * The CSD or CSX group is the same for all slot sensors + */ + switch (context->ptrWdConfig[wdIndex].senseMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + result = CY_CAPSENSE_BIST_SUCCESS_E; + context->ptrBistContext->currentISC = context->ptrBistContext->intrEltdCapCsdISC; + break; + #endif + + /* For CSX widgets get the sum of Rx and Tx electrode numbers */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + result = CY_CAPSENSE_BIST_SUCCESS_E; + context->ptrBistContext->currentISC = context->ptrBistContext->intrEltdCapCsxISC; + break; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_GROUP: + /* exit with CY_CAPSENSE_BIST_BAD_PARAM_E */ + #endif + default: + /* Do nothing */ + break; + } + + if (CY_CAPSENSE_BIST_BAD_PARAM_E != result) + { + /* Switch the HW resource configuration to the sensor element capacitance measurement */ + Cy_CapSense_BistSwitchHwConfig(CY_CAPSENSE_BIST_HW_ELTD_CAP_E, + context->ptrWdConfig[wdIndex].senseMethod, + CY_CAPSENSE_BIST_CAP_SLOT_SCAN, + context); + result = Cy_CapSense_BistMeasureCapacitanceSlot(slotId, snsFrameType, context); + } + /* Clear the BUSY flag */ + context->ptrCommonContext->status = CY_CAPSENSE_NOT_BUSY; + } + else + { + result = CY_CAPSENSE_BIST_HW_BUSY_E; + } + } + } + + return result; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_BistMeasureCapacitanceSensor +****************************************************************************//** +* +* This internal function measures a capacitance attached to AMUXBUS. +* +* The function measures Cp of a certain electrode (CSD sensor or CSX +* Rx/Tx electrode) by using CSD FW mode and defined scan configuration, +* sense clock frequency and resolution. +* The range for sensor measuring is 1 to 200 pF. +* The function performs the CSD scan with the fixed CDAC value. This provides +* a possibility of classical raw counts formula usage for the capacitance +* calculation. The function stores the Cp value +* in the corresponding element of the eltdCap[CY_CAPSENSE_ELTD_COUNT] array. +* +* \param cpPtr +* The pointer to the uint32_t to store measured value of the capacitance. +* +* \param snsFrameType +* The Sensor Frame type: +* * CY_CAPSENSE_SNS_FRAME_ACTIVE - Sensor frame for Active slot +* * CY_CAPSENSE_SNS_FRAME_LOW_POWER - Sensor frame for Low Power slot +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement is completed +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_TIMEOUT_E - The scan reached the timeout. It can be caused +* by a measured capacitance short or HW block +* failure or invalid configuration. You may need +* to repeat the measurement after the issue fix. +* The result is set to zero. +* - CY_CAPSENSE_BIST_ERROR_E - The was an overflow or bad conversions during +* the scan. It can be caused +* by a measured capacitance short or HW block +* failure or invalid configuration. You may need +* to repeat the measurement after the issue fix. +* The result is set to zero. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( + uint32_t * cpPtr, + uint32_t snsFrameType, + cy_stc_capsense_context_t * context) +{ + uint32_t cp; + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_TIMEOUT_E; + const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; + MSCLP_Type * ptrHwBase = ptrCommonCfg->ptrChConfig->ptrHwBase; + uint32_t rawCountTmp; + uint32_t watchdog; + uint32_t sensorFrame[CY_MSCLP_6_SNS_REGS]; + + /* Setup scan parameters: Ref CDAC code for Cp measurement */ + context->ptrBistContext->eltdCapRefCdac = CY_CAPSENSE_BIST_ELTD_CAP_REF_CDAC_DEFAULT; + + Cy_CapSense_BistGenerateSensorConfig(&sensorFrame[0u], snsFrameType, context); + Cy_CapSense_StartCpuScan((const uint32_t *)sensorFrame, context); + + watchdog = Cy_CapSense_BistWatchdogPeriodCalc(context); + watchdog = Cy_CapSense_WaitEndOfCpuScan(watchdog, context); + + /* Check if the watchdog timeout happened */ + if(0u == watchdog) + { + result = CY_CAPSENSE_BIST_TIMEOUT_E; + } + else + { + /* Read raw counts */ + rawCountTmp = ptrHwBase->SNS.RESULT_FIFO_RD; + + /* Check for overflow */ + if (MSCLP_SNS_RESULT_FIFO_RD_OVERFLOW_Msk == (rawCountTmp & MSCLP_SNS_RESULT_FIFO_RD_OVERFLOW_Msk)) + { + result = CY_CAPSENSE_BIST_ERROR_E; + } + else + { + rawCountTmp &= MSCLP_SNS_RESULT_FIFO_RD_RAW_COUNT_Msk; + result = CY_CAPSENSE_BIST_SUCCESS_E; + } + } + + /* Disable HW IP */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Check for timeout and if no, then calculate capacitance and store the value to the data structure */ + if (CY_CAPSENSE_BIST_SUCCESS_E == result) + { + cp = CY_CAPSENSE_REF_CDAC_LSB_X100 * rawCountTmp; + cp /= context->ptrBistContext->eltdCapSubConvNum; + cp *= context->ptrBistContext->eltdCapRefCdac; + cp /= CY_CAPSENSE_CONVERSION_HECTO; + if (((uint32_t)CY_CAPSENSE_BIST_CP_MAX_VALUE) < cp) + { + cp = (uint32_t)CY_CAPSENSE_BIST_CP_MAX_VALUE; + } + *cpPtr = (uint32_t)cp; + } + else + { + *cpPtr = 0u; + } + + return result; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN_EN) */ + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) +/******************************************************************************* +* Function Name: Cy_CapSense_BistMeasureCapacitanceSlot +****************************************************************************//** +* +* This internal function measures slot sensor capacitances. +* +* The function measures Cp of a certain CSD sensor or shield +* or Cm of a certain CSX sensor by using the predefined scan configuration. +* The range for sensor measuring is 1 to 200 pF for CSD/CSX sensors and +* 1600 pF for shield electrodes. +* The function performs the CSD or CSX scan with fixed reference CDAC values +* (100u and 50u respectively) and 200u for shield electrodes' capacitance +* measurements. The function stores the Cp or Cm value +* in the corresponding element +* of the cy_capsense_snsCap[CY_CAPSENSE_SENSOR_COUNT] array and +* Cshield values for each channel +* in the corresponding element +* of the cy_capsense_shieldCap[CY_CAPSENSE_TOTAL_CH_NUMBER] array. +* The pointer to the first sensor capacitance value of a widget is +* in the .ptrSnsCapacitance field of the \ref cy_stc_capsense_widget_config_t +* structure. +* +* \param slotId +* Specifies the ID number of the slot to measure sensor capacitance. +* The slot ID should be in the admissible range. +* +* \param snsFrameType +* The Sensor Frame type: +* * CY_CAPSENSE_SNS_FRAME_ACTIVE - Sensor frame for Active slot +* * CY_CAPSENSE_SNS_FRAME_LOW_POWER - Sensor frame for Low Power slot +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* - CY_CAPSENSE_BIST_TIMEOUT_E - The scan reached the timeout. It can be caused +* by a measured capacitance short or The CAPSENSE™ HW block +* failure or invalid configuration. You may need to +* repeat the measurement after the issue fix. +* The result is not affected. +* - CY_CAPSENSE_BIST_ERROR_E - The was an overflow or bad conversions during +* the scan. It can be caused +* by a measured capacitance short or HW block +* failure or invalid configuration. You may need +* to repeat the measurement after the issue fix. +* The result is not affected. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSlot( + uint32_t slotId, + uint32_t snsFrameType, + cy_stc_capsense_context_t * context) +{ + + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_TIMEOUT_E; + const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + MSCLP_Type * ptrHwBase = ptrCommonCfg->ptrChConfig->ptrHwBase; + uint32_t cp; + uint32_t watchdog; + uint32_t rawCountTmp; + uint32_t wdIndex; + uint32_t snsIndex; + uint32_t sensorFrame[CY_MSCLP_6_SNS_REGS]; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + ptrScanSlots = (snsFrameType == CY_CAPSENSE_SNS_FRAME_ACTIVE) ? (context->ptrScanSlots) : (context->ptrLpScanSlots); + #else + ptrScanSlots = context->ptrScanSlots; + (void)snsFrameType; + #endif + wdIndex = ptrScanSlots[slotId].wdId; + snsIndex = ptrScanSlots[slotId].snsId; + ptrWdCfg = &context->ptrWdConfig[wdIndex]; + + /* Setup scan parameters: Ref CDAC code for shield or electrode Cp measurement */ + if (CY_CAPSENSE_BIST_CAP_SHIELD_SCAN == context->ptrBistContext->eltdCapScanMode) + { + context->ptrBistContext->eltdCapRefCdac = CY_CAPSENSE_BIST_SHIELD_CAP_REF_CDAC_DEFAULT; + } + /* The CSD or CSX group is the same for all slot sensors */ + else if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) + { + context->ptrBistContext->eltdCapRefCdac = CY_CAPSENSE_BIST_MUTUAL_CAP_REF_CDAC_DEFAULT; + } + else + { + context->ptrBistContext->eltdCapRefCdac = CY_CAPSENSE_BIST_ELTD_CAP_REF_CDAC_DEFAULT; + } + + Cy_CapSense_BistGenerateSensorConfig(&sensorFrame[0u], snsFrameType, context); + Cy_CapSense_StartCpuScan((const uint32_t *)sensorFrame, context); + + watchdog = Cy_CapSense_BistWatchdogPeriodCalc(context); + watchdog = Cy_CapSense_WaitEndOfCpuScan(watchdog, context); + + /* Check if the watchdog timeout happened */ + if(0u == watchdog) + { + result = CY_CAPSENSE_BIST_TIMEOUT_E; + } + else + { + /* Read raw counts */ + rawCountTmp = ptrHwBase->SNS.RESULT_FIFO_RD; + + /* Check for overflow */ + if (MSCLP_SNS_RESULT_FIFO_RD_OVERFLOW_Msk == (rawCountTmp & MSCLP_SNS_RESULT_FIFO_RD_OVERFLOW_Msk)) + { + result = CY_CAPSENSE_BIST_ERROR_E; + } + else + { + rawCountTmp &= MSCLP_SNS_RESULT_FIFO_RD_RAW_COUNT_Msk; + result = CY_CAPSENSE_BIST_SUCCESS_E; + } + } + + /* Disable HW IP */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Calculate capacitance and store the value to the data structure */ + if (CY_CAPSENSE_BIST_SUCCESS_E == result) + { + cp = CY_CAPSENSE_REF_CDAC_LSB_X100 * rawCountTmp; + cp /= context->ptrBistContext->eltdCapSubConvNum; + cp *= context->ptrBistContext->eltdCapRefCdac; + cp /= CY_CAPSENSE_CONVERSION_HECTO; + + /* Store the Cp value in the appropriate structure */ + if ((CY_CAPSENSE_BIST_CAP_SHIELD_SCAN != context->ptrBistContext->eltdCapScanMode)) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + /* Divide the result by 2 for the FW CSX scanning method */ + if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) + { + cp /= CY_CAPSENSE_DIVIDER_TWO; + } + #endif + + if (((uint32_t)CY_CAPSENSE_BIST_CP_MAX_VALUE) < cp) + { + cp = (uint32_t)CY_CAPSENSE_BIST_CP_MAX_VALUE; + } + ptrWdCfg->ptrSnsCapacitance[snsIndex] = (uint32_t)cp; + } + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + else + { + if (((uint32_t)CY_CAPSENSE_BIST_CSH_MAX_VALUE) < cp) + { + cp = (uint32_t)CY_CAPSENSE_BIST_CSH_MAX_VALUE; + } + *context->ptrBistContext->ptrChShieldCap = (uint32_t)cp; + } + #endif + } + + return result; +} +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) */ + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) +/******************************************************************************* +* Function Name: Cy_CapSense_BistGenerateBaseConfig +****************************************************************************//** +* +* Changes the configuration for all registers that have to be changed +* one-time to initialize the MSC block for BIST scan. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +static void Cy_CapSense_BistGenerateBaseConfig( + cy_stc_capsense_context_t * context) +{ + cy_stc_msclp_base_config_t cy_capsense_smTemplate = CY_CAPSENSE_SENSING_METHOD_BASE_TEMPLATE; + const cy_stc_msclp_mode_config_t modeArr[CY_CAPSENSE_REG_MODE_NUMBER] = CY_CAPSENSE_SM_MODES_ARR; + cy_stc_msclp_base_config_t * ptrTemplateCfg = &cy_capsense_smTemplate; + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + + /* Check for modClk divider value */ + if (1u == context->ptrBistContext->eltdCapModClk) + { + ptrTemplateCfg->ctl |= MSCLP_CTL_CLK_MSC_RATIO_Msk; + } + else + { + ptrTemplateCfg->ctl &= ~MSCLP_CTL_CLK_MSC_RATIO_Msk; + } + ptrTemplateCfg->imoCtl |= _VAL2FLD(MSCLP_IMO_CTL_CLOCK_MSC_DIV, (uint32_t)context->ptrBistContext->eltdCapModClk - 1u); + + /* Generating the common configuration for the BIST epilogue cycle number */ + if (0u < context->ptrBistContext->eltdCapNumEpiCycles) + { + ptrTemplateCfg->scanCtl2 |= (uint32_t)context->ptrBistContext->eltdCapNumEpiCycles << MSCLP_SCAN_CTL2_NUM_EPI_KREF_DELAY_Pos; + } + else + { + ptrTemplateCfg->scanCtl2 |= (uint32_t)(1uL << MSCLP_SCAN_CTL2_NUM_EPI_KREF_DELAY_Pos); + } + + /* Generating the common configuration for the coarse initialization and coarse short phase */ + ptrTemplateCfg->initCtl1 |= (uint32_t)context->ptrBistContext->eltdCapNumCoarseInitChargeCycles << + MSCLP_INIT_CTL1_NUM_INIT_CMOD_12_RAIL_CYCLES_Pos; + ptrTemplateCfg->initCtl1 |= (uint32_t)context->ptrBistContext->eltdCapNumCoarseInitSettleCycles << + MSCLP_INIT_CTL1_NUM_INIT_CMOD_12_SHORT_CYCLES_Pos; + ptrTemplateCfg->initCtl3 |= CY_CAPSENSE_CMOD12_PAIR_SELECTION << MSCLP_INIT_CTL3_CMOD_SEL_Pos; + ptrTemplateCfg->initCtl3 |= (uint32_t)context->ptrInternalContext->numProOffsetCycles << MSCLP_INIT_CTL3_NUM_PRO_OFFSET_CYCLES_Pos; + + /* + * Generating the common configuration for the number of sub-conversions to be run during the PRO_DUMMY phase and + * the modClk period number during the PRO_WAIT phase. + */ + ptrTemplateCfg->initCtl4 |= (((uint32_t)context->ptrBistContext->eltdCapNumFineInitCycles << + MSCLP_INIT_CTL4_NUM_PRO_DUMMY_SUB_CONVS_Pos) | + ((uint32_t)context->ptrBistContext->eltdCapNumFineInitWaitCycles << + MSCLP_INIT_CTL4_NUM_PRO_WAIT_KREF_DELAY_Pos)); + + /* Set switch control functions */ + ptrTemplateCfg->swSelCswFunc[CY_CAPSENSE_CTRLMUX_PIN_STATE_GND] = CY_CAPSENSE_SM_REG_SW_SEL_CSW0_GND_VALUE; + ptrTemplateCfg->swSelCswFunc[CY_CAPSENSE_CTRLMUX_PIN_STATE_HIGH_Z] = CY_CAPSENSE_SM_REG_SW_SEL_CSW1_HIGH_Z_VALUE; + ptrTemplateCfg->swSelCswFunc[CY_CAPSENSE_CTRLMUX_PIN_STATE_TX] = CY_CAPSENSE_SM_REG_SW_SEL_CSW3_CSX_TX_VALUE; + ptrTemplateCfg->swSelCswFunc[CY_CAPSENSE_CTRLMUX_PIN_STATE_RX] = CY_CAPSENSE_SM_REG_SW_SEL_CSW2_CSX_RX_VALUE; + ptrTemplateCfg->swSelCswFunc[CY_CAPSENSE_CTRLMUX_PIN_STATE_SNS] = CY_CAPSENSE_SM_REG_SW_SEL_CSW5_CSD_SNS_VALUE; + ptrTemplateCfg->swSelCswFunc[CY_CAPSENSE_CTRLMUX_PIN_STATE_VDDA2] = CY_CAPSENSE_SM_REG_SW_SEL_CSW10_VDDA2_VALUE; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + if (CY_CAPSENSE_SHIELD_ACTIVE == context->ptrCommonConfig->csdShieldMode) + { + /* Active Shield mode */ + ptrTemplateCfg->swSelCswFunc[CY_CAPSENSE_CTRLMUX_PIN_STATE_SHIELD] = CY_CAPSENSE_SM_REG_SW_SEL_CSW8_ACT_SHLD_VALUE; + } + else + { + /* Passive Shield mode */ + ptrTemplateCfg->swSelCswFunc[CY_CAPSENSE_CTRLMUX_PIN_STATE_SHIELD] = CY_CAPSENSE_SM_REG_SW_SEL_CSW9_PAS_SHLD_VALUE; + } + #endif + + /* Set mode configuration */ + ptrTemplateCfg->mode[CY_CAPSENSE_REG_MODE_CSD] = modeArr[CY_CAPSENSE_REG_MODE_CSD]; + ptrTemplateCfg->mode[CY_CAPSENSE_REG_MODE_CSX] = modeArr[CY_CAPSENSE_REG_MODE_CSX]; + ptrTemplateCfg->mode[CY_CAPSENSE_REG_MODE_ISX] = modeArr[CY_CAPSENSE_REG_MODE_ISX]; + if (CY_CAPSENSE_BIST_IO_VDDA2_E == context->ptrBistContext->currentISC) + { + if ((CY_CAPSENSE_BIST_CAP_ELTD_SCAN == context->ptrBistContext->eltdCapScanMode) || + (CY_CAPSENSE_CSD_GROUP == context->ptrBistContext->eltdCapSenseGroup)) + { + /* Close the reference to filter switch for CSD sensing mode */ + ptrTemplateCfg->mode[CY_CAPSENSE_REG_MODE_CSD].swSelSh |= MSCLP_MODE_SW_SEL_SH_SOMB_Msk; + } + else + { + /* Close the reference to filter switch for CSD sensing mode */ + ptrTemplateCfg->mode[CY_CAPSENSE_REG_MODE_CSX].swSelSh |= MSCLP_MODE_SW_SEL_SH_SOMB_Msk; + } + } + + (void)Cy_MSCLP_Configure(ptrHwBase, + ptrTemplateCfg, + CY_MSCLP_CAPSENSE_KEY, + context->ptrCommonConfig->ptrChConfig->ptrHwContext); + + Cy_CapSense_SetupCpuOperatingMode(context); + + Cy_SysLib_DelayUs(CY_CAPSENSE_ANALOG_SETTLING_TIME_US); +} +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) */ + + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) +/******************************************************************************* +* Function Name: Cy_CapSense_BistGenerateSensorConfig +****************************************************************************//** +* +* Generates the configuration for registers that have to be configured to start +* a scan for a single sensor. It is used the next sensor configuration for BIST +* scan: +* - CIC2 filter is off +* - is used mode structure 0u +* - Multi-channel mode is off +* - System level chopping is off +* - Coarse Init Bypass is off +* +* \param ptrSensorCfg +* Specifies the pointer to the sensor configuration to be filled. +* +* \param snsFrameType +* The Sensor Frame type: +* * CY_CAPSENSE_SNS_FRAME_ACTIVE - Sensor frame for Active slot +* * CY_CAPSENSE_SNS_FRAME_LOW_POWER - Sensor frame for Low Power slot +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +static void Cy_CapSense_BistGenerateSensorConfig( + uint32_t * ptrSensorCfg, + uint32_t snsFrameType, + cy_stc_capsense_context_t * context) +{ + uint32_t modeSel; + uint32_t snsClkVal; + uint32_t *ptrSensorCfgLocal = ptrSensorCfg; + uint32_t i; + uint32_t padMask = 0u; + uint32_t cswFuncNum = 0u; + uint32_t slotStcWdgtIdx; + uint32_t slotStcSnsIdx; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + const cy_stc_capsense_electrode_config_t * ptrEltdCfg; + const cy_stc_capsense_pin_config_t * ptrPinCfg = context->ptrPinConfig; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + ptrScanSlots = (snsFrameType == CY_CAPSENSE_SNS_FRAME_ACTIVE) ? (context->ptrScanSlots) : (context->ptrLpScanSlots); + #else + ptrScanSlots = context->ptrScanSlots; + (void)snsFrameType; + #endif + slotStcWdgtIdx = ptrScanSlots[context->ptrBistContext->curBistSlotId].wdId; + slotStcSnsIdx = ptrScanSlots[context->ptrBistContext->curBistSlotId].snsId; + ptrWdCfg = &context->ptrWdConfig[slotStcWdgtIdx]; + + /* Clear the sensor configuration structure */ + for (i = 0u; i < CY_MSCLP_6_SNS_REGS; i++) + { + ptrSensorCfg[i] = 0u; + } + + /* CapDAC configuration */ + ptrSensorCfgLocal[CY_CAPSENSE_SNS_CDAC_CTL_INDEX] = + (_VAL2FLD(MSCLP_SNS_SNS_CDAC_CTL_SEL_RE, context->ptrBistContext->eltdCapRefCdac) | + (CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_CLOCK_REF_RATE << MSCLP_SNS_SNS_CDAC_CTL_CLOCK_REF_RATE_Pos)); + + if ((CY_CAPSENSE_BIST_CAP_ELTD_SCAN == context->ptrBistContext->eltdCapScanMode) || + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod)) + { + modeSel = CY_CAPSENSE_REG_MODE_CSD; + } + else + { + modeSel = CY_CAPSENSE_REG_MODE_CSX; + } + + snsClkVal = context->ptrBistContext->eltdCapSnsClk; + if (CY_CAPSENSE_BIST_CAP_SHIELD_SCAN == context->ptrBistContext->eltdCapScanMode) + { + snsClkVal = CY_CAPSENSE_BIST_SHIELD_CAP_SNSCLK_DIV_DEFAULT; + } + snsClkVal--; + + ptrSensorCfgLocal[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] = _VAL2FLD(MSCLP_SNS_SNS_SCAN_CTL_NUM_SUB_CONVS, (uint32_t)context->ptrBistContext->eltdCapSubConvNum - 1u) | + _VAL2FLD(MSCLP_SNS_SNS_SCAN_CTL_COMP_DIV, (uint32_t)snsClkVal); /* Compensation CDAC Divider set to BIST Sns clock divider */ + ptrSensorCfgLocal[CY_CAPSENSE_SNS_CTL_INDEX] = _VAL2FLD(MSCLP_SNS_SNS_CTL_SENSE_MODE_SEL, modeSel) | + _VAL2FLD(MSCLP_SNS_SNS_CTL_SENSE_DIV, snsClkVal); + + /* Create mask for all project electrodes */ + for (i = 0u; i < context->ptrCommonConfig->numPin; i++) + { + padMask |= (0x01uL << ptrPinCfg->padNumber); + ptrPinCfg++; + } + + /* Add to mask all shield electrodes (if present) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + ptrPinCfg = context->ptrShieldPinConfig; + for (i = 0u; i < context->ptrCommonConfig->csdShieldNumPin; i++) + { + padMask |= (0x01uL << ptrPinCfg->padNumber); + ptrPinCfg++; + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) */ + + /* Change the control switch function depending on the current inactive sensor connection */ + switch (context->ptrBistContext->currentISC) + { + case CY_CAPSENSE_BIST_IO_HIGHZA_E: + cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_HIGH_Z; + break; + + case CY_CAPSENSE_BIST_IO_VDDA2_E: + cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_VDDA2; + break; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + case CY_CAPSENSE_BIST_IO_SHIELD_E: + cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_SHIELD; + break; + #endif + + default: + cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_GND; + break; + } + + /* Set the control mux switch registers for inactive pins */ + Cy_CapSense_CalculateMaskRegisters(padMask, cswFuncNum, ptrSensorCfg); + /* Initializes an active sensor (including ganged sensors) by SNS sensor state */ + if (CY_CAPSENSE_BIST_CAP_SHIELD_SCAN == context->ptrBistContext->eltdCapScanMode) + { + /* Generate CTRL_MUX masks for the electrode or CSD sensor connection */ + cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_SNS; + if (CY_CAPSENSE_BIST_IO_SHIELD_E != context->ptrBistContext->currentISC) + { + padMask = 0u; + for (i = 0u; i < context->ptrCommonConfig->csdShieldNumPin; i++) + { + padMask |= 0x01uL << context->ptrShieldPinConfig[i].padNumber; + } + } + Cy_CapSense_CalculateMaskRegisters(padMask, cswFuncNum, ptrSensorCfg); + } + else + { + if ((CY_CAPSENSE_BIST_CAP_ELTD_SCAN == context->ptrBistContext->eltdCapScanMode) || + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod)) + { + /* Generate CTRL_MUX masks for the electrode or CSD sensor connection */ + if (CY_CAPSENSE_BIST_CAP_ELTD_SCAN == context->ptrBistContext->eltdCapScanMode) + { + ptrEltdCfg = context->ptrBistContext->curPtrEltdCfg; + } + else + { + ptrEltdCfg = &ptrWdCfg->ptrEltdConfig[slotStcSnsIdx]; + } + cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_SNS; + Cy_CapSense_BistGenerateSnsCfgMaskReg(ptrEltdCfg, ptrSensorCfg, cswFuncNum); + } + else + { + /* RX ELECTRODE */ + cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_RX; + ptrEltdCfg = &ptrWdCfg->ptrEltdConfig[(slotStcSnsIdx / ptrWdCfg->numRows)]; + Cy_CapSense_BistGenerateSnsCfgMaskReg(ptrEltdCfg, ptrSensorCfg, cswFuncNum); + + /* TX ELECTRODE */ + cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_TX; + ptrEltdCfg = &ptrWdCfg->ptrEltdConfig[ptrWdCfg->numCols + (slotStcSnsIdx % ptrWdCfg->numRows)]; + Cy_CapSense_BistGenerateSnsCfgMaskReg(ptrEltdCfg, ptrSensorCfg, cswFuncNum); + } + } +} +#endif /*((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)))*/ + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) +/******************************************************************************* +* Function Name: Cy_CapSense_BistGenerateSnsCfgMaskReg +****************************************************************************//** +* +* Calculates the configuration for all sensor configuration mask registers that +* have to be changed to set the desired CTRL-MUX function +* for the specified electrode for BIST scan. +* +* \param ptrEltdCfg +* The pointer to the specified electrode configuration +* \ref cy_stc_capsense_electrode_config_t structure. +* +* \param ptrSensorCfg +* Specifies the pointer to the sensor configuration to be filled. +* +* \param cswFuncNum +* The desired CTRL-MUX Switch Control Global function. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +static void Cy_CapSense_BistGenerateSnsCfgMaskReg( + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t * ptrSensorCfg, + uint32_t cswFuncNum) +{ + uint32_t padMask = 0u; + uint32_t i; + + /* Loop through all pads for this electrode (ganged sensor) */ + for (i = 0u; i < ptrEltdCfg->numPins; i++) + { + padMask |= 0x01uL << ptrEltdCfg->ptrPin[i].padNumber; + } + Cy_CapSense_CalculateMaskRegisters(padMask, cswFuncNum, ptrSensorCfg); +} +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) */ + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceShieldElectrode_V3Lp +****************************************************************************//** +* +* Measures shield electrode capacitances in femtofarads. +* +* This function measures the capacitances of all shield electrodes for all +* enabled MSCv3 channels and returns a status of this measurement. +* The function checks if there is any CSD widget in the project and +* if the shield is enabled. +* The measurement results in femtofarads are stored +* in the chShieldCap[CY_MSC_ENABLED_CH_NUMBER] array. +* The pointer to the array is in the .ptrChShieldCap field +* of the \ref cy_stc_capsense_bist_context_t structure, +* the CY_MSC_ENABLED_CH_NUMBER define is in the cycfg_peripherals.h file. +* If the any channel shield consists of several electrodes, the total +* capacitance of all the shield electrodes is measured. +* +* This function uses an algorithm identical to the electrode capacitance +* measurement. Refer to the Cy_CapSense_MeasureCapacitanceSensorElectrode() +* function for more details. +* +* In addition to measuring shield capacitance, this function is used to +* identify various fault conditions with shield electrodes such as an +* electrically-open or -short shield electrodes, e.g. the PCB track is broken or +* shorted to other nodes in the system - in all of these conditions, +* this function returns changed capacitance that can be compared +* against pre-determined capacitance for the shield electrode to +* detect a hardware fault. +* +* By default, all CAPSENSE™ sensors (electrodes) that are not being +* measured are set to the GND state. +* The inactive state can be changed in run-time by using +* the Cy_CapSense_SetInactiveElectrodeState() function. +* When the inactive sensor (electrode) connection is set +* to the CY_CAPSENSE_SNS_CONNECTION_SHIELD state, +* all the CAPSENSE™ electrodes are connected to the shield and +* the total capacitance are measured. +* +* By default, the both Cmod1 and Cmod2 capacitors are used for the measurement. +* +* This test can be executed using the CapSense_RunSelfTest() +* function with the CY_CAPSENSE_BIST_SHIELD_CAP_MASK mask. +* +* \note +* This function is available only for the fifth-generation low power +* CAPSENSE™. +* +* \param skipChMask +* Specifies the mask to skip some channels during the shield electrode +* capacitance measurement. If the bit N in the skipChMask is set to 1, +* the channel N will be excluded from measuring and all its shield pins will be +* set to the shield inactive sensor connection state (see the .shieldCapISC +* field of the \ref cy_stc_capsense_bist_context_t structure). +* +* \param context +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a +* previous operation. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_BAD_CONFIG_E - The shield is disabled. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode_V3Lp( + uint32_t skipChMask, + cy_stc_capsense_context_t * context) +{ + (void)skipChMask; + cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; + + if (NULL != context) + { + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_SHIELD_EN)) + if ((0u < context->ptrCommonConfig->csdShieldNumPin) || + (CY_CAPSENSE_BIST_IO_SHIELD_E == context->ptrBistContext->intrEltdCapShieldISC)) + { + context->ptrBistContext->currentISC = context->ptrBistContext->intrEltdCapShieldISC; + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + { + /* Set the BUSY status */ + context->ptrCommonContext->status = CY_CAPSENSE_BUSY | CY_CAPSENSE_MW_STATE_BIST_MASK; + (void)Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY, context); + + /* Store the current slot and the skip channel mask for the BIST scan */ + context->ptrBistContext->curBistSlotId = 0u; + /* Switch the HW resource configuration to the electrode capacitance measurement */ + Cy_CapSense_BistSwitchHwConfig(CY_CAPSENSE_BIST_HW_ELTD_CAP_E, + CY_CAPSENSE_CSD_GROUP, + CY_CAPSENSE_BIST_CAP_SHIELD_SCAN, + context); + /* Perform the CSD BIST slot scan with connected all channel shields as active electrodes */ + result = Cy_CapSense_BistMeasureCapacitanceSlot(0u, CY_CAPSENSE_SNS_FRAME_ACTIVE, context); + /* Clear the BUSY flag */ + context->ptrCommonContext->status = CY_CAPSENSE_NOT_BUSY; + } + else + { + result = CY_CAPSENSE_BIST_HW_BUSY_E; + } + } + #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN)) */ + } + + return result; +} +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) */ + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN)) +/******************************************************************************* +* Function Name: Cy_CapSense_BistMeasureCapacitanceCapRun +****************************************************************************//** +* +* This internal function performs the specific scan for the external capacitor +* capacitance measurement. +* +* \param ptrExtCapValue +* The pointer to the result of the measurement as raw counts. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_ERROR_E - The raw counts reach overflow during the +* measuring scan. The measurement result is +* invalid. +* - CY_CAPSENSE_BIST_TIMEOUT_E - The measuring scan is not finished properly +* and reached the timeout. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceCapRun( + uint32_t * ptrExtCapValue, + cy_stc_capsense_context_t * context) +{ + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + uint32_t tempRawcount; + cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_TIMEOUT_E; + uint32_t watchdog; + uint32_t scanConfigTmp[CY_MSCLP_6_SNS_REGS]; + + /* + * The measurement will be performed with all the sensors disconnected. + * The code below sets up the configuration of the LO_MASK registers with 0x00uL. + */ + scanConfigTmp[CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK2_INDEX] = 0x00uL; + scanConfigTmp[CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK1_INDEX] = 0x00uL; + scanConfigTmp[CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK0_INDEX] = 0x00uL; + + scanConfigTmp[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] = + ((((uint32_t)context->ptrBistContext->extCapSubConvNum - 1u) << MSCLP_SNS_SNS_SCAN_CTL_NUM_SUB_CONVS_Pos) | + MSCLP_SNS_SNS_SCAN_CTL_INIT_BYPASS_Msk); + scanConfigTmp[CY_CAPSENSE_SNS_CDAC_CTL_INDEX] = + ((CY_CAPSENSE_BIST_EXT_CAP_REF_CDAC_DEFAULT << MSCLP_SNS_SNS_CDAC_CTL_SEL_RE_Pos) | + (CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_CLOCK_REF_RATE << MSCLP_SNS_SNS_CDAC_CTL_CLOCK_REF_RATE_Pos)); + scanConfigTmp[CY_CAPSENSE_SNS_CTL_INDEX] = MSCLP_SNS_SNS_CTL_SENSE_DIV_Msk; + + /* Initiate the scan in the CPU operating mode. */ + Cy_CapSense_StartCpuScan((const uint32_t *)scanConfigTmp, context); + + /* Calculate a watchdog time in us */ + watchdog = (((CY_CAPSENSE_BIST_EXT_CAP_WDT_FACTOR * + (MSCLP_SNS_SNS_CTL_SENSE_DIV_Msk >> MSCLP_SNS_SNS_CTL_SENSE_DIV_Pos)) * + (uint32_t)(context->ptrBistContext->extCapSubConvNum)) / CY_CAPSENSE_BIST_EXT_CAP_IMO_CLK_MHZ); + + watchdog = Cy_CapSense_WaitEndOfCpuScan(watchdog, context); + + if (0u != watchdog) + { + tempRawcount = ptrHwBase->SNS.RESULT_FIFO_RD; + /* Check for an overflow or bad conversions */ + if (0u == (tempRawcount & MSCLP_SNS_RESULT_FIFO_RD_OVERFLOW_Msk)) + { + tempRawcount &= MSCLP_SNS_RESULT_FIFO_RD_RAW_COUNT_Msk; + bistStatus = CY_CAPSENSE_BIST_SUCCESS_E; + } + else + { + bistStatus = CY_CAPSENSE_BIST_ERROR_E; + } + } + + /* Disable HW IP */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Check for timeout and if no, then calculate capacitance and store the value to the data structure */ + if (CY_CAPSENSE_BIST_SUCCESS_E == bistStatus) + { + /* Store raw counts */ + *ptrExtCapValue = tempRawcount; + } + else + { + *ptrExtCapValue = 0u; + } + + return bistStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_BistGenerateBaseCmodConfig +****************************************************************************//** +* +* Changes the configuration for all registers that have to be changed +* one-time to initialize the MSC block for BIST scan. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +static void Cy_CapSense_BistGenerateBaseCmodConfig(cy_stc_capsense_context_t * context) +{ + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + uint32_t i; + + ptrHwBase->CTL = + ((CY_CAPSENSE_SM_REG_CTL_FLD_SENSE_EN << MSCLP_CTL_SENSE_EN_Pos) | + (CY_CAPSENSE_SM_REG_CTL_FLD_MSCCMP_EN << MSCLP_CTL_MSCCMP_EN_Pos) | + (CY_CAPSENSE_SM_REG_CTL_FLD_OPERATING_MODE << MSCLP_CTL_OPERATING_MODE_Pos) | + (CY_CAPSENSE_SM_REG_CTL_FLD_BUF_MODE << MSCLP_CTL_BUF_MODE_Pos) | + (CY_CAPSENSE_SM_REG_CTL_FLD_CLK_MSC_RATIO << MSCLP_CTL_CLK_MSC_RATIO_Pos) | + (CY_CAPSENSE_SM_REG_CTL_FLD_ENABLED << MSCLP_CTL_ENABLED_Pos)); + ptrHwBase->SPARE = 0x00uL; + ptrHwBase->SCAN_CTL1 = (CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_RC_STORE_EN << MSCLP_SCAN_CTL1_RC_STORE_EN_Pos); + ptrHwBase->SCAN_CTL2 = + ((CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_REG_SCAN_CTL2_FLD_CHOP_POL << MSCLP_SCAN_CTL2_CHOP_POL_Pos) | + (CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_REG_SCAN_CTL2_FLD_NUM_EPI_KREF_DELAY << MSCLP_SCAN_CTL2_NUM_EPI_KREF_DELAY_Pos) | + (CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_REG_SCAN_CTL2_FLD_NUM_EPI_KREF_DELAY_PRS << MSCLP_SCAN_CTL2_NUM_EPI_KREF_DELAY_PRS_Pos)); + ptrHwBase->INIT_CTL1 = 0x00uL; + ptrHwBase->INIT_CTL2 = 0x00uL; + ptrHwBase->INIT_CTL3 = 0x00uL; + ptrHwBase->INIT_CTL4 = 0x00uL; + ptrHwBase->SENSE_DUTY_CTL = 0x00uL; + ptrHwBase->SENSE_PERIOD_CTL = 0x00uL; + ptrHwBase->FILTER_CTL = 0x00uL; + ptrHwBase->CCOMP_CDAC_CTL = 0x00uL; + ptrHwBase->DITHER_CDAC_CTL = 0x00uL; + ptrHwBase->MSCCMP_CTL = + ((CY_CAPSENSE_SM_REG_MSCCMP_CTL_FLD_PWR << MSCLP_MSCCMP_CTL_PWR_Pos) | + (CY_CAPSENSE_SM_REG_MSCCMP_CTL_FLD_FILT << MSCLP_MSCCMP_CTL_FILT_Pos)); + ptrHwBase->OBS_CTL = 0x00uL; + ptrHwBase->AOS_CTL = 0x00uL; + ptrHwBase->CE_CTL = 0x00uL; + + /* Check for the system VDDA value and enable PUMP if VDDA is less than the threshold */ + #if (CY_MSCLP_VDDA_PUMP_TRESHOLD > CY_CAPSENSE_VDDA_MV) + ptrHwBase->PUMP_CTL = MSCLP_PUMP_CTL_PUMP_MODE_Msk; + #endif + + /* Use 25 MHz IMO frequency for Cmod measurements */ + ptrHwBase->IMO_CTL = + ((CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_IMO_CTL_FREQ << MSCLP_IMO_CTL_FREQ_Pos) | + (CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_IMO_CTL_CLOCK_MSC_DIV << MSCLP_IMO_CTL_CLOCK_MSC_DIV_Pos)); + + ptrHwBase->WAKEUP_CMD = 0x00uL; + ptrHwBase->SW_SEL_GPIO = 0x00uL; + ptrHwBase->SW_SEL_CDAC_RE = + ((CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RETCC << MSCLP_SW_SEL_CDAC_RE_SW_RETCC_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RECD << MSCLP_SW_SEL_CDAC_RE_SW_RECD_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RETV << MSCLP_SW_SEL_CDAC_RE_SW_RETV_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RETG << MSCLP_SW_SEL_CDAC_RE_SW_RETG_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_REBV << MSCLP_SW_SEL_CDAC_RE_SW_REBV_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_REBG << MSCLP_SW_SEL_CDAC_RE_SW_REBG_Pos)); + ptrHwBase->SW_SEL_CDAC_CO = 0x00uL; + ptrHwBase->SW_SEL_CDAC_CF = 0x00uL; + ptrHwBase->SW_SEL_BGR = 0x00uL; + + /* Clear SW_SEL_CSW registers as not needed for BIST Cmod measurement */ + for (i = 0u; i < CY_MSCLP_SENSE_PAD_NUMBER; i++) + { + ptrHwBase->SW_SEL_CSW[i] = 0x00uL; + } + + /* Clear SW_SEL_CSW_FUNC registers as not needed for BIST Cmod measurement */ + for (i = 0u; i < MSCLP_CSW_GLOBAL_FUNC_NR; i++) + { + ptrHwBase->SW_SEL_CSW_FUNC[i] = 0x00uL; + } + + ptrHwBase->CSW_CTL_LO = 0x00uL; + ptrHwBase->CSW_CTL_HI = 0x00uL; + + /* Configure MODE[0u] for for BIST Cmod measurement */ + ptrHwBase->MODE[0u].SENSE_DUTY_CTL = 0x00uL; + ptrHwBase->MODE[0u].SW_SEL_CDAC_FL = 0x00uL; + ptrHwBase->MODE[0u].SW_SEL_TOP = + ((CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_CACC << MSCLP_MODE_SW_SEL_TOP_CACC_Pos) | + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_CBCD << MSCLP_MODE_SW_SEL_TOP_CBCD_Pos) | + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_AYA_CTL << MSCLP_MODE_SW_SEL_TOP_AYA_CTL_Pos) | + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_AYA_EN << MSCLP_MODE_SW_SEL_TOP_AYA_EN_Pos) | + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_RMF << MSCLP_MODE_SW_SEL_TOP_RMF_Pos)); + ptrHwBase->MODE[0u].SW_SEL_COMP = + ((CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos)); + ptrHwBase->MODE[0u].SW_SEL_SH = + ((CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_CBSO << MSCLP_MODE_SW_SEL_SH_CBSO_Pos) | + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_FSP << MSCLP_MODE_SW_SEL_SH_FSP_Pos) | + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_BUF_SEL << MSCLP_MODE_SW_SEL_SH_BUF_SEL_Pos) | + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_BUF_EN << MSCLP_MODE_SW_SEL_SH_BUF_EN_Pos)); + ptrHwBase->MODE[0u].SW_SEL_CMOD1 = 0x00uL; + ptrHwBase->MODE[0u].SW_SEL_CMOD2 = 0x00uL; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_DischargeCmod +****************************************************************************//** +* +* Discharges one of the CAPSENSE Cmod capacitors and restores its previous state. +* +* \param portCmod +* The pointer to the Cmod pin base port register. +* +* \param pinCmod +* The Cmod pin position (bit number) in the port. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_DischargeCmod( + GPIO_PRT_Type * portCmod, + uint32_t pinCmod, + cy_stc_capsense_context_t * context) +{ + en_hsiom_sel_t hsiomReg; + uint32_t pcReg; + uint32_t interruptState; + + /* Disconnect Ext Cap from AMUXBUS-A / AMUXBUSB using HSIOM registers */ + interruptState = Cy_SysLib_EnterCriticalSection(); + hsiomReg = Cy_GPIO_GetHSIOM(portCmod, pinCmod); + Cy_GPIO_SetHSIOM(portCmod, pinCmod, CY_CAPSENSE_HSIOM_SEL_GPIO); + Cy_SysLib_ExitCriticalSection(interruptState); + + /* Set port configuration register (drive mode) to STRONG mode */ + interruptState = Cy_SysLib_EnterCriticalSection(); + pcReg = Cy_GPIO_GetDrivemode(portCmod, pinCmod); + Cy_GPIO_Clr(portCmod, pinCmod); + Cy_GPIO_SetDrivemode(portCmod, pinCmod, CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF); + Cy_SysLib_ExitCriticalSection(interruptState); + + /* Now external CSD-related capacitors discharging */ + Cy_SysLib_DelayUs(context->ptrBistContext->extCapDischargeTime); + + /* Restore Ext Cap settings */ + interruptState = Cy_SysLib_EnterCriticalSection(); + Cy_GPIO_SetDrivemode(portCmod, pinCmod, pcReg); + Cy_GPIO_SetHSIOM(portCmod, pinCmod, hsiomReg); + Cy_SysLib_ExitCriticalSection(interruptState); +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureCapacitanceCap_V3Lp +****************************************************************************//** +* +* The internal function for the external capacitance measurements +* on the fifth-generation low power CAPSENSE™ devices. For details, see +* the Cy_CapSense_MeasureCapacitanceCap() description. +* +* \note +* This function is available only for the fifth-generation low power +* CAPSENSE™. +* +* \param integrationCapId +* Indexes of external capacitors to measure their capacitance. +* There are macros for each of them, namely: +* * CY_CAPSENSE_BIST_CMOD01_ID_E for the MSC0 Cmod1 capacitor +* * CY_CAPSENSE_BIST_CMOD02_ID_E for the MSC0 Cmod2 capacitor +* +* \param ptrValue +* The pointer to the result of the measurement. The result is calculated as +* a specified capacitor capacitance value in picofarads. The user +* declares a variable of the uint32_t type and passes the pointer to this +* variable as the function parameter. If the ptrValue parameter is NULL then +* the capacitance value is not returned through the parameter but stored to the +* corresponding field of the \ref cy_stc_capsense_bist_context_t structure. +* +* \param maxCapacitance +* An expected by the user maximum value of the measured capacitance in +* nanofarads in the range from 1 to 25 nF. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with +* a previous operation. The measurement +* was not executed. +* - CY_CAPSENSE_BIST_TIMEOUT_E - The timeout was reached during +* the measurement. +* The measurement result is zeroed. +* The capacitor might be shorted to +* GND. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap_V3Lp( + cy_en_capsense_bist_external_cap_id_t integrationCapId, + uint32_t * ptrValue, + uint32_t maxCapacitance, + cy_stc_capsense_context_t * context) +{ + uint32_t rawCounts = 0u; + GPIO_PRT_Type * portCmod; + uint32_t pinCmod; + uint16_t * ptrResult = NULL; + uint32_t nSub; + uint32_t maxRaw; + cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_SUCCESS_E; + + if ((NULL == context) || (CY_CAPSENSE_BIST_EXT_CAP_MAX_CAP < maxCapacitance) || (0u == maxCapacitance) || + (CY_CAPSENSE_BIST_CMOD02_ID_E < integrationCapId)) + { + bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; + } + + if (CY_CAPSENSE_BIST_SUCCESS_E == bistStatus) + { + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + { + /* Set the BUSY status and switch the HW resource configuration to the BIST mode */ + context->ptrCommonContext->status = CY_CAPSENSE_BUSY | CY_CAPSENSE_MW_STATE_BIST_MASK; + switch (integrationCapId) + { + case CY_CAPSENSE_BIST_CMOD01_ID_E: + portCmod = context->ptrCommonConfig->ptrChConfig->portCmod1; + pinCmod = (uint32_t)context->ptrCommonConfig->ptrChConfig->pinCmod1; + ptrResult = &context->ptrBistContext->cMod01Cap; + break; + case CY_CAPSENSE_BIST_CMOD02_ID_E: + portCmod = context->ptrCommonConfig->ptrChConfig->portCmod2; + pinCmod = (uint32_t)context->ptrCommonConfig->ptrChConfig->pinCmod2; + ptrResult = &context->ptrBistContext->cMod02Cap; + break; + default: + bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; + break; + } + if (CY_CAPSENSE_STATUS_SUCCESS != + Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY, context)) + { + bistStatus = CY_CAPSENSE_BIST_ERROR_E; + } + + if (CY_CAPSENSE_BIST_SUCCESS_E == bistStatus) + { + /* Generate the MSC base configuration for BIST scan and send it to the MSC HW block */ + Cy_CapSense_BistSwitchHwConfig(CY_CAPSENSE_BIST_HW_EXTERNAL_CAP_E, CY_CAPSENSE_UNDEFINED_GROUP, 0u, + context); + + /* Discharge the specified capacitor */ + context->ptrBistContext->extCapDischargeTime = (uint16_t)((CY_CAPSENSE_BIST_EXT_CAP_DISCHARGE_FACTOR * + maxCapacitance * + CY_CAPSENSE_BIST_EXT_CAP_SERIAL_RESISTANCE) / + CY_CAPSENSE_CONVERSION_KILO); + if (0u == context->ptrBistContext->extCapDischargeTime) + { + context->ptrBistContext->extCapDischargeTime = 1u; + } + + Cy_CapSense_DischargeCmod(portCmod, pinCmod, context); + + /* Calculate the needed max raw counts value */ + maxRaw = ((((CY_CAPSENSE_BIST_EXT_CAP_ACCURACY_FACTOR * maxCapacitance) * + CY_CAPSENSE_CONVERSION_KILO) / CY_CAPSENSE_BIST_EXT_CAP_REF_CDAC_DEFAULT) * + CY_CAPSENSE_CONVERSION_KILO) / CY_CAPSENSE_BIST_CAP_MEAS_CDAC_LSB_FF_DIV_1000; + + /* Calculate a corresponding number of sub-conversions for the measurement */ + nSub = (maxRaw / ((uint32_t)MSCLP_SNS_SNS_CTL_SENSE_DIV_Msk >> MSCLP_SNS_SNS_CTL_SENSE_DIV_Pos)) + + 1u; + if (CY_CAPSENSE_14_BIT_MASK < nSub) + { + nSub = CY_CAPSENSE_14_BIT_MASK; + } + + /* Number of sub-conversions variable initialization in BIST data structure */ + context->ptrBistContext->extCapSubConvNum = (uint16_t)nSub; + + /* Connect Cmod to AMuxBusA */ + Cy_CapSense_SsConfigPinRegisters(portCmod, pinCmod, + CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXA, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS); + + /* Perform the measurement */ + bistStatus = Cy_CapSense_BistMeasureCapacitanceCapRun(&rawCounts, context); + + /* Disconnect Cmod from AMuxBusA */ + Cy_CapSense_SsConfigPinRegisters(portCmod, pinCmod, + CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS); + + if (CY_CAPSENSE_BIST_SUCCESS_E == bistStatus) + { + /* Calculate the capacitance value in pF */ + *ptrResult = (uint16_t)((rawCounts * CY_CAPSENSE_BIST_EXT_CAP_RESULT_FACTOR) / + CY_CAPSENSE_BIST_EXT_CAP_RESULT_DIVIDER); + if (NULL != ptrValue) + { + *ptrValue = *ptrResult; + } + } + else + { + *ptrResult = 0u; + if (NULL != ptrValue) + { + *ptrValue = 0u; + } + } + } + + /* Clear the BUSY flag */ + context->ptrCommonContext->status = CY_CAPSENSE_NOT_BUSY; + } + else + { + bistStatus = CY_CAPSENSE_BIST_HW_BUSY_E; + } + } + + return bistStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_BistMeasureCapacitanceCapAll +****************************************************************************//** +* +* This internal function measures capacitance of all external capacitors. +* +* The function measures capacitances of all external capacitors Cmod1 and Cmod2. +* The function stores cap values in the corresponding registers. +* The function is called by the Cy_CapSense_RunSelfTest() function. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a previous +* operation. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement, you may need to repeat the measurement. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceCapAll( + cy_stc_capsense_context_t * context) +{ + uint32_t capCapacitance = 0u; + cy_en_capsense_bist_status_t tempStatus; + cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_SUCCESS_E; + + tempStatus = Cy_CapSense_MeasureCapacitanceCap_V3Lp(CY_CAPSENSE_BIST_CMOD01_ID_E, &capCapacitance, + CY_CAPSENSE_BIST_EXT_CAP_CMOD_MAX_VALUE, context); + if (CY_CAPSENSE_BIST_SUCCESS_E != tempStatus) + { + bistStatus = tempStatus; + } + + tempStatus = Cy_CapSense_MeasureCapacitanceCap_V3Lp(CY_CAPSENSE_BIST_CMOD02_ID_E, &capCapacitance, + CY_CAPSENSE_BIST_EXT_CAP_CMOD_MAX_VALUE, context); + if (CY_CAPSENSE_BIST_SUCCESS_E != tempStatus) + { + bistStatus = tempStatus; + } + + return bistStatus; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_MeasureVdda_V3Lp +****************************************************************************//** +* +* Measures a VDDA voltage, returns the measured voltage in +* millivolts through the ptrValue argument and stores it to the .vddaVoltage +* field of the \ref cy_stc_capsense_bist_context_t structure. +* +* This function measures the device analog supply voltage (VDDA) without need +* of explicitly connecting VDDA to any additional GPIO input. +* This capability can be used in various cases, for example to monitor +* the battery voltage. +* +* The function uses Cmod1 charging/discharging due to the measurement. +* As the charging is non-linear, the measurement accuracy is about 20%. +* +* A measurement can be done only if the CAPSENSE™ middleware is in the +* IDLE state. This function must not be called while the CAPSENSE™ +* middleware is busy. The function is blocking, i.e. waits for the conversion +* to be completed prior to returning to the caller. +* +* \note +* This function is available for the forth-generation and the fifth-generation +* low power CAPSENSE™. +* +* \param ptrValue +* The pointer to the uint32_t to store measured VDDA voltage value. +* If the ptrValue parameter is NULL then VDDA voltage value will not be returned +* through the parameter but still it will be stored in the .vddaVoltage +* field of the \ref cy_stc_capsense_bist_context_t structure. If the status +* of the test execution is not CY_CAPSENSE_BIST_SUCCESS_E the value +* the ptrValue parameter is pointed to will be zeroed. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement executed +* successfully. +* - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. +* The measurement was not executed. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement. +* +*******************************************************************************/ +cy_en_capsense_bist_status_t Cy_CapSense_MeasureVdda_V3Lp( + uint32_t * ptrValue, + cy_stc_capsense_context_t * context) +{ + cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; + + if (NULL != context) + { + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + { + /* Set the BUSY status and switch the HW resource configuration to the BIST mode */ + context->ptrCommonContext->status = CY_CAPSENSE_BUSY | CY_CAPSENSE_MW_STATE_BIST_MASK; + if (CY_CAPSENSE_STATUS_SUCCESS != Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY, context)) + { + bistStatus = CY_CAPSENSE_BIST_ERROR_E; + } + else + { + bistStatus = CY_CAPSENSE_BIST_SUCCESS_E; + } + if (CY_CAPSENSE_BIST_SUCCESS_E == bistStatus) + { + Cy_CapSense_BistSwitchHwConfig(CY_CAPSENSE_BIST_HW_VDDA_E, CY_CAPSENSE_UNDEFINED_GROUP, 0u, context); + + /* Perform two-phase VDDA measurement */ + bistStatus = Cy_CapSense_BistMeasureVddaRun(context); + + if (CY_CAPSENSE_BIST_SUCCESS_E == bistStatus) + { + if (NULL != ptrValue) + { + *ptrValue = context->ptrBistContext->vddaVoltage; + } + } + else + { + if (NULL != ptrValue) + { + *ptrValue = 0u; + } + } + } + /* Clear the BUSY flag */ + context->ptrCommonContext->status = CY_CAPSENSE_NOT_BUSY; + } + else + { + bistStatus = CY_CAPSENSE_BIST_HW_BUSY_E; + } + } + + return bistStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_BistMeasureVddaRun +****************************************************************************//** +* +* The internal function performs the two phase voltage measurement +* by converting the internal band gap reference Vbgref and Vdda/2 voltages +* to the raw counts and calculating the last one in millivolts. +* +* The function performs the following tasks: +* * Measures the time to bring Cmod1 up from Vssa to Vbgref +* * Measures the time to bring Cmod1 up from Vssa to Vdda/2 +* * Calculates the results of measurements in millivolts. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns a status of the test execution: +* - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes +* successfully, the result is valid. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement, you may need to repeat +* the measurement. +* +*******************************************************************************/ +static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureVddaRun( + cy_stc_capsense_context_t * context) +{ + uint32_t rawVref = 0u; + uint32_t rawVdda2 = 0u; + uint32_t vddaValue = 0u; + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + GPIO_PRT_Type * portCmod = context->ptrCommonConfig->ptrChConfig->portCmod1; + uint32_t pinCmod = (uint32_t)context->ptrCommonConfig->ptrChConfig->pinCmod1; + + cy_en_capsense_bist_status_t bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; + + /* + * Phase 1: + * Measures raw counts for Cmod1 charge from VSSA to BGVREF. + * The .extCapSubConvNum is initialized to the sense clock period number + * for Cmod measurement + * of the CY_CAPSENSE_BIST_VDDA_MEAS_CMOD1_MAX_POSSIBLE_VALUE + */ + context->ptrBistContext->extCapSubConvNum = (uint16_t)CY_CAPSENSE_BIST_VDDA_MEAS_NUM_SNS_CLK; + + /* Connect the Plus comparator terminal to the AmuxBusA and the Minus comparator terminal to the BandGapVref */ + ptrHwBase->MODE[0u].SW_SEL_COMP = + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos); + ptrHwBase->SW_SEL_BGR = (CY_CAPSENSE_BIST_CMOD_MEAS_SW_SEL_BGR_FLD_SW_BGRCM << MSCLP_SW_SEL_BGR_SW_BGRCM_Pos); + + /* Discharge the Cmod1 capacitor */ + context->ptrBistContext->extCapDischargeTime = (uint16_t)(CY_CAPSENSE_BIST_VDDA_MEAS_CMOD1_DISCHARGE_TIME); + if (0u == context->ptrBistContext->extCapDischargeTime) + { + context->ptrBistContext->extCapDischargeTime = 1u; + } + Cy_CapSense_DischargeCmod(portCmod, pinCmod, context); + + /* Connect Cmod to AMuxBusA */ + Cy_CapSense_SsConfigPinRegisters(portCmod, pinCmod, + CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXA, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS); + + /* Perform the measurement */ + bistStatus = Cy_CapSense_BistMeasureCapacitanceCapRun(&rawVref, context); + + /* Disconnect Cmod from AMuxBusA */ + Cy_CapSense_SsConfigPinRegisters(portCmod, pinCmod, + CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS); + + if (CY_CAPSENSE_BIST_SUCCESS_E == bistStatus) + { + /* + * Phase 2: + * Measures raw counts for Cmod1 charge from VSSA to VDDA/2 + */ + + /* Connect the Vdda/2 to the Minus comparator terminal */ + ptrHwBase->SW_SEL_BGR = 0u; + ptrHwBase->MODE[0u].SW_SEL_COMP = + ((CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CPMA << MSCLP_MODE_SW_SEL_COMP_CPMA_Pos) | + (CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CMF << MSCLP_MODE_SW_SEL_COMP_CMF_Pos)); + + /* Discharge Cmod1 to Vssa (GND) */ + Cy_CapSense_DischargeCmod(portCmod, pinCmod, context); + + /* Connect Cmod to AMuxBusA */ + Cy_CapSense_SsConfigPinRegisters(portCmod, pinCmod, + CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXA, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS); + + /* Perform the measurement */ + bistStatus = Cy_CapSense_BistMeasureCapacitanceCapRun(&rawVdda2, context); + + /* Disconnect Cmod from AMuxBusA */ + Cy_CapSense_SsConfigPinRegisters(portCmod, pinCmod, + CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS); + if (CY_CAPSENSE_BIST_SUCCESS_E == bistStatus) + { + /* + * Phase 3: + * Convert the results of measurements to millivolts taking into consideration that in Phase 2 + * Vdda/2 was measured. + */ + vddaValue = ((CY_CAPSENSE_BIST_VDDA_MEAS_RESULT_FACTOR * rawVdda2) / rawVref) + + CY_CAPSENSE_BIST_VDDA_MEAS_RESULT_SHIFT; + + /* Store the measured value */ + context->ptrBistContext->vddaVoltage = (uint16_t)vddaValue; + } + else + { + context->ptrBistContext->vddaVoltage = 0u; + } + } + + return bistStatus; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_BistInitialize +****************************************************************************//** +* +* The internal function initializes some critical parameters +* for Built-in Self-test (BIST) mode. +* +* This function prepares the resource capturing to execute the BIST functions. +* The HW resource configuring is performed by the Cy_CapSense_BistSwitchHwConfig() +* function depending on a the type of the test to be executed. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_BistInitialize(cy_stc_capsense_context_t * context) +{ + /* + * This function prepares the BIST HW and pins re-configuring by setting some + * critical internal parameters to undefined states. + * Use this function after switching from CSD or CSX sensing modes. + */ + context->ptrBistContext->hwConfig = CY_CAPSENSE_BIST_HW_UNDEFINED_E; + context->ptrBistContext->currentISC = CY_CAPSENSE_BIST_IO_UNDEFINED_E; + context->ptrBistContext->eltdCapSenseGroup = CY_CAPSENSE_UNDEFINED_GROUP; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_BistDsInitialize_V3Lp +****************************************************************************//** +* +* This internal function initializes the BIST cy_stc_capsense_bist_context_t +* data structure parameters to be used in the test execution. +* +* The function is called once at the CAPSENSE™ start and performs +* the \ref cy_stc_capsense_bist_context_t structure initialization based +* on the configured parameters. +* +* Some of the parameters of the \ref cy_stc_capsense_bist_context_t structure +* can be changed in the run-time, but some changes require repeating the call +* of this function to the re-calculate register values. +* Refer to description of the following functions which parameters are used +* as an input and which are outputs: +* * Cy_CapSense_BistMeasureCapacitanceSensorInit() +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_BistDsInitialize_V3Lp(cy_stc_capsense_context_t * context) +{ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) + uint32_t wdIndex; + uint32_t wdNum = (uint32_t)context->ptrCommonConfig->numWd; + + /* Initialize CRC for all widgets */ + for (wdIndex = 0u; wdIndex < wdNum; wdIndex++) + { + Cy_CapSense_UpdateCrcWidget(wdIndex, context); + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) + Cy_CapSense_BistMeasureCapacitanceSensorInit(context); + #endif + + context->ptrBistContext->hwConfig = CY_CAPSENSE_BIST_HW_UNDEFINED_E; + context->ptrBistContext->currentISC = CY_CAPSENSE_BIST_IO_UNDEFINED_E; + context->ptrBistContext->eltdCapSenseGroup = CY_CAPSENSE_UNDEFINED_GROUP; + context->ptrBistContext->intrEltdCapCsdISC = context->ptrBistContext->eltdCapCsdISC; + context->ptrBistContext->intrEltdCapCsxISC = context->ptrBistContext->eltdCapCsxISC; + context->ptrBistContext->intrEltdCapShieldISC = context->ptrBistContext->shieldCapISC; +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_BistDisableMode +****************************************************************************//** +* +* This internal function releases HW resources and pins captured by BIST +* to be used by other CAPSENSE™ modes. +* +* This function releases the shared HW resources like connection +* to the analog bus in the AMUX mode. +* The function does not configure HW block registers to the default state. +* It is used by the Cy_CapSense_SwitchHwConfiguration() function only at switching +* to another sensing mode. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_BistDisableMode(cy_stc_capsense_context_t * context) +{ + Cy_CapSense_BistSwitchAllSnsPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_BistSwitchAllShieldPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + #endif + Cy_CapSense_BistSwitchAllExternalCapPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + + context->ptrBistContext->hwConfig = CY_CAPSENSE_BIST_HW_UNDEFINED_E; + context->ptrBistContext->currentISC = CY_CAPSENSE_BIST_IO_UNDEFINED_E; +} + +/******************************************************************************* +* Function Name: Cy_CapSense_BistSwitchHwConfig +****************************************************************************//** +* +* This internal function switches the MSCv3 HW block configuration for +* BIST operations. +* +* The function checks the current MSCv3 HW block configuration. +* If it differs from a desired configuration, the function disables the current +* configuration and sets the desired one. +* +* \param hwCfg +* Specifies the desired configuration. +* +* \param bistSenseGroup +* Specifies the sense group to be scanned during the sensor or electrode +* capacitance measurement scan. +* The parameter does not matter for short tests. +* +* \param bistScanMode +* Specifies the scanning mode (by electrodes or by slots) during the sensor +* or electrode capacitance measurement scan. +* The parameter does not matter for short tests. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +static void Cy_CapSense_BistSwitchHwConfig( + cy_en_capsense_bist_hw_config_t hwCfg, + uint8_t bistSenseGroup, + uint8_t bistScanMode, + cy_stc_capsense_context_t * context) +{ + if ((context->ptrBistContext->hwConfig != hwCfg) || + (context->ptrBistContext->eltdCapSenseGroup != bistSenseGroup) || + (context->ptrBistContext->eltdCapScanMode != bistScanMode)) + { + context->ptrBistContext->hwConfig = hwCfg; + context->ptrBistContext->eltdCapSenseGroup = bistSenseGroup; + context->ptrBistContext->eltdCapScanMode = bistScanMode; + /* Enable the specified mode */ + switch (hwCfg) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) + case CY_CAPSENSE_BIST_HW_SHORT_E: + { + break; + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) + case CY_CAPSENSE_BIST_HW_ELTD_CAP_E: + { + Cy_CapSense_BistGenerateBaseConfig(context); + + Cy_CapSense_SetIOsInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, 0u, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN, context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_SetShieldPinsInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN, context); + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) */ + + Cy_CapSense_SetCmodInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN, context); + break; + } + #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) + case CY_CAPSENSE_BIST_HW_EXTERNAL_CAP_E: + { + Cy_CapSense_SetIOsInDesiredState(CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF, + CY_CAPSENSE_HSIOM_SEL_GPIO, 0u, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS, context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_SetShieldPinsInDesiredState(CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF, + CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS, context); + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) */ + + context->ptrActiveScanSns->currentSenseMethod = CY_CAPSENSE_UNDEFINED_GROUP; + Cy_CapSense_SetCmodInDesiredState(CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS, context); + Cy_CapSense_BistGenerateBaseCmodConfig(context); + Cy_CapSense_SetupCpuOperatingMode(context); + break; + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) */ + + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) + case CY_CAPSENSE_BIST_HW_VDDA_E: + { + Cy_CapSense_SetIOsInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, 0u, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS, context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_SetShieldPinsInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS, context); + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) */ + + context->ptrActiveScanSns->currentSenseMethod = CY_CAPSENSE_UNDEFINED_GROUP; + Cy_CapSense_SetCmodInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS, context); + + Cy_CapSense_BistGenerateBaseCmodConfig(context); + Cy_CapSense_SetupCpuOperatingMode(context); + break; + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) */ + + default: + { + /* Nothing to do */ + break; + } + } + } +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_BistMeasureCapacitanceSensorInit +****************************************************************************//** +* +* This internal function calculates the parameters for sensor, shield or +* electrode capacitance measurements. +* +* It is called by Cy_CapSense_BistDsInitialize() once at the CAPSENSE™ MW start. +* +* The following parameters of cy_stc_capsense_bist_context_t are used as +* an input for the calculation: +* * .eltdCapModClk +* * .eltdCapSnsClk +* +* The function checks for parameter limitations and corrects the values before +* the calculation if they exceed. +* +* The following parameters of cy_stc_capsense_bist_context_t are updated +* by the calculation: +* * .eltdCapModClk +* * .eltdCapSnsClk +* * .eltdCapSubConvNum +* +* Restarting CAPSENSE™ MW or calling of the Cy_CapSense_BistDsInitialize() +* function overwrites the output parameters. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_BistMeasureCapacitanceSensorInit( + cy_stc_capsense_context_t * context) +{ + cy_stc_capsense_bist_context_t * ptrBistCxt = context->ptrBistContext; + + /* ModClk */ + if (0u == ptrBistCxt->eltdCapModClk) + { + ptrBistCxt->eltdCapModClk = (uint16_t)CY_CAPSENSE_BIST_ELTD_CAP_MODCLK_DIV_DEFAULT; + } + + /* SnsClk */ + if (0u == ptrBistCxt->eltdCapSnsClk) + { + ptrBistCxt->eltdCapSnsClk = (uint16_t)CY_CAPSENSE_BIST_ELTD_CAP_SNSCLK_DIV_DEFAULT; + } + /* Check the snsClk divider value */ + if (CY_CAPSENSE_BIST_SNS_CLK_MIN_DIVIDER > ptrBistCxt->eltdCapSnsClk) + { + ptrBistCxt->eltdCapSnsClk = CY_CAPSENSE_BIST_SNS_CLK_MIN_DIVIDER; + } + if (CY_CAPSENSE_BIST_SNS_CLK_MAX_DIVIDER < ptrBistCxt->eltdCapSnsClk) + { + ptrBistCxt->eltdCapSnsClk = CY_CAPSENSE_BIST_SNS_CLK_MAX_DIVIDER; + } + /* NumSubConv */ + ptrBistCxt->eltdCapSubConvNum = (uint16_t)CY_CAPSENSE_BIST_ELTD_CAP_SUBCONV_NUM_DEFAULT; + /* NumEpiCycles and NumProWaitCycles depends on SnsClk divider */ + ptrBistCxt->eltdCapNumEpiCycles = ptrBistCxt->eltdCapSnsClk / CY_CAPSENSE_DIVIDER_TWO; + ptrBistCxt->eltdCapNumFineInitWaitCycles = ptrBistCxt->eltdCapNumEpiCycles; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) */ + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_BistSwitchAllSnsPinState +****************************************************************************//** +* +* This internal function sets all the port control (PC), data (DR) and HSIOM +* registers of all sensor pins to the desired state. +* +* The function sets the desired state for the pin port control register (PC), +* the output data register (DR) and the HSIOM register for all sensor pins +* (Drive Mode, output state, and HSIOM state). +* +* \param desiredPinState +* Specifies the desired pin state. See the possible states +* in the cy_en_capsense_bist_io_state_t enum description. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +static void Cy_CapSense_BistSwitchAllSnsPinState( + cy_en_capsense_bist_io_state_t desiredPinState, + const cy_stc_capsense_context_t * context) +{ + uint32_t desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; + + Cy_CapSense_BistSetDmHsiomPinState(desiredPinState, context); + if (CY_CAPSENSE_BIST_IO_STRONG_HIGH_E == desiredPinState) + { + desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2VDD; + } + Cy_CapSense_BistSetAllSnsPinsState(context->ptrBistContext->eltdInactiveDm, desiredPinOutput, + context->ptrBistContext->eltdInactiveHsiom, context); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_BistSetDmHsiomPinState +****************************************************************************//** +* +* This internal function changes the port control (PC) and HSIOM +* register values needed to set pins to the desired state. +* +* The function changes the .eltdInactiveDm and .eltdInactiveHsiom field values +* of the \ref cy_stc_capsense_bist_context_t structure on ones needed to set +* pins to the desired pin state (Drive Mode and HSIOM state). +* +* \param desiredPinState +* Specifies the desired pin state. See the possible states +* in the cy_en_capsense_bist_io_state_t enum description. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +static void Cy_CapSense_BistSetDmHsiomPinState( + cy_en_capsense_bist_io_state_t desiredPinState, + const cy_stc_capsense_context_t * context) +{ + context->ptrBistContext->eltdInactiveDm = CY_CAPSENSE_DM_GPIO_ANALOG; + context->ptrBistContext->eltdInactiveHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; + + /* Change Drive mode and HSIOM depending on the current inactive sensor connection */ + if ((CY_CAPSENSE_BIST_IO_STRONG_E == desiredPinState) || + (CY_CAPSENSE_BIST_IO_STRONG_HIGH_E == desiredPinState)) + { + context->ptrBistContext->eltdInactiveDm = CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + if (CY_CAPSENSE_BIST_IO_SHIELD_E == desiredPinState) + { + context->ptrBistContext->eltdInactiveHsiom = CY_CAPSENSE_HSIOM_SEL_CSD_SHIELD; + if (CY_CAPSENSE_SHIELD_PASSIVE == context->ptrCommonConfig->csdShieldMode) + { + context->ptrBistContext->eltdInactiveDm = CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF; + } + } + #endif +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN)) +/******************************************************************************* +* Function Name: Cy_CapSense_BistSwitchAllShieldPinState +****************************************************************************//** +* +* This internal function sets all the port control (PC), data (DR) and HSIOM +* registers of all shield pins to the desired state. +* +* The function sets the desired state for the pin port control register (PC), +* the output data register (DR) and the HSIOM register for all shield pins +* (Drive Mode, output state, and HSIOM state). +* +* \param desiredPinState +* Specifies the desired pin state. See the possible states +* in the cy_en_capsense_bist_io_state_t enum description. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +static void Cy_CapSense_BistSwitchAllShieldPinState( + cy_en_capsense_bist_io_state_t desiredPinState, + const cy_stc_capsense_context_t * context) +{ + uint32_t desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; + + if (0u < context->ptrCommonConfig->csdShieldNumPin) + { + Cy_CapSense_BistSetDmHsiomPinState(desiredPinState, context); + if (CY_CAPSENSE_BIST_IO_STRONG_HIGH_E == desiredPinState) + { + desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2VDD; + } + Cy_CapSense_BistSetAllShieldPinsState(context->ptrBistContext->eltdInactiveDm, desiredPinOutput, + context->ptrBistContext->eltdInactiveHsiom, context); + } +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN)) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_BistSwitchAllExternalCapPinState +****************************************************************************//** +* +* The internal function sets all the port control (PC), data (DR) and HSIOM +* registers of all external capacitor pins to the desired state. +* +* The function sets the desired state for the pin port control register (PC), +* the output data register (DR) and the HSIOM register for all external +* capacitor pins (Drive Mode, output state, and HSIOM state). +* +* \param desiredPinState +* Specifies the desired pin state. See the possible states +* in the cy_en_capsense_bist_io_state_t enum description. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +static void Cy_CapSense_BistSwitchAllExternalCapPinState( + cy_en_capsense_bist_io_state_t desiredPinState, + const cy_stc_capsense_context_t * context) +{ + uint32_t desiredDriveMode = CY_CAPSENSE_DM_GPIO_ANALOG; + en_hsiom_sel_t desiredHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; + uint32_t desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; + + /* Change Drive mode and HSIOM depending on the current inactive sensor connection */ + if (CY_CAPSENSE_BIST_IO_STRONG_E == desiredPinState) + { + desiredDriveMode = CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF; + desiredHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; + desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; + } + else if (CY_CAPSENSE_BIST_IO_STRONG_HIGH_E == desiredPinState) + { + desiredDriveMode = CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF; + desiredHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; + desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2VDD; + } + else + { + /* Do nothing */ + } + Cy_CapSense_BistSetAllCmodPinsState(desiredDriveMode, desiredPinOutput, desiredHsiom, context); +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) || \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) +/******************************************************************************* +* Function Name: Cy_CapSense_BistWatchdogPeriodCalc +****************************************************************************//** +* +* The internal function calculates the watch-dog period for BIST sensor +* capacity measurement scans in CPU cycles. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the calculated watch-dog period for BIST sensor capacity measurement +* scans in CPU cycles: +*******************************************************************************/ +static uint32_t Cy_CapSense_BistWatchdogPeriodCalc( + const cy_stc_capsense_context_t * context) +{ + uint64_t isBusyWatchdogTimeUs; + uint32_t modClkDivider = context->ptrBistContext->eltdCapModClk; + uint32_t watchdogPeriod; + + if (0u == modClkDivider) + { + modClkDivider = 1u; + } + + isBusyWatchdogTimeUs = ((uint64_t)context->ptrBistContext->eltdCapSnsClk) * + ((uint64_t)context->ptrBistContext->eltdCapSubConvNum); + isBusyWatchdogTimeUs *= (uint64_t)modClkDivider; + isBusyWatchdogTimeUs /= CY_CAPSENSE_IMO_CLK_25_MHZ; + if (0u == isBusyWatchdogTimeUs) + { + isBusyWatchdogTimeUs = 1u; + } + isBusyWatchdogTimeUs *= CY_CAPSENSE_BIST_WATCHDOG_MARGIN_COEFF; + watchdogPeriod = Cy_CapSense_WatchdogCyclesNum((uint32_t)isBusyWatchdogTimeUs, + context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA, + CY_CAPSENSE_BIST_CAP_MEAS_WDT_CYCLES_PER_LOOP); + return watchdogPeriod; +} +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN))) */ + +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) */ + +#endif /* (defined(CY_IP_M0S8MSCV3LP)) */ + + +/* [] END OF FILE */ diff --git a/cy_capsense_selftest_lp.h b/cy_capsense_selftest_lp.h new file mode 100644 index 0000000..a963d91 --- /dev/null +++ b/cy_capsense_selftest_lp.h @@ -0,0 +1,182 @@ +/***************************************************************************//** +* \file cy_capsense_selftest_lp.h +* \version 4.0 +* +* \brief +* This file provides the function prototypes of the BIST module. +* +******************************************************************************** +* \copyright +* Copyright 2021-2023, Cypress Semiconductor Corporation (an Infineon company) +* or an affiliate of Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +*******************************************************************************/ + + +#if !defined(CY_CAPSENSE_SELFTEST_LP_H) +#define CY_CAPSENSE_SELFTEST_LP_H + +#include "cy_syslib.h" +#include "cycfg_capsense_defines.h" +#include "cy_capsense_common.h" +#include "cy_capsense_structure.h" + +#if (defined(CY_IP_M0S8MSCV3LP)) + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) + +#if defined(__cplusplus) +extern "C" { +#endif + + +/******************************************************************************* +* CAPSENSE™ BIST Enumerated Types +*******************************************************************************/ + +/******************************************************************************/ +/** \addtogroup group_capsense_enums *//** \{ */ +/******************************************************************************/ + +/** Defines IDs of the external capacitors */ +typedef enum +{ + CY_CAPSENSE_BIST_CMOD01_ID_E = 0x00u, /**< ID for the MSC0 Cmod1 external capacitor */ + CY_CAPSENSE_BIST_CMOD02_ID_E = 0x01u, /**< ID for the MSC0 Cmod2 external capacitor */ +} cy_en_capsense_bist_external_cap_id_t; + +/** \} */ + + +/******************************************************************************* +* Function Prototypes +*******************************************************************************/ + + +/******************************************************************************/ +/** \addtogroup group_capsense_low_level *//** \{ */ +/******************************************************************************/ + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN)) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceLpSlotSensors( + uint32_t slotId, + cy_stc_capsense_context_t * context); +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN)) */ + +/** \} */ + +/******************************************************************************/ +/** \cond SECTION_CAPSENSE_INTERNAL */ +/** \addtogroup group_capsense_internal *//** \{ */ +/******************************************************************************/ + +cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V3Lp( + uint32_t testEnMask, + cy_stc_capsense_context_t * context); + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) + cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget_V3Lp( + uint32_t widgetId, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_RAW_INTEGRITY_EN) + cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount_V3Lp( + uint32_t widgetId, + uint32_t sensorId, + uint16_t rawcountHighLimit, + uint16_t rawcountLowLimit, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_RAW_INTEGRITY_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN) + cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline_V3Lp( + uint32_t widgetId, + uint32_t sensorId, + uint16_t baselineHighLimit, + uint16_t baselineLowLimit, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) + cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorPins_V3Lp( + uint32_t widgetId, + uint32_t sensorId, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) */ + +void Cy_CapSense_BistInitialize( + cy_stc_capsense_context_t * context); +void Cy_CapSense_BistDsInitialize_V3Lp( + cy_stc_capsense_context_t * context); + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) + void Cy_CapSense_BistDisableMode( + cy_stc_capsense_context_t * context); +#endif + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) + void Cy_CapSense_BistMeasureCapacitanceSensorInit( + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) + void Cy_CapSense_UpdateCrcWidget( + uint32_t widgetId, + cy_stc_capsense_context_t * context); + void Cy_CapSense_UpdateAllWidgetCrc( + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureVdda_V3Lp( + uint32_t * ptrValue, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode_V3Lp( + uint32_t widgetId, + uint32_t eltdId, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors_V3Lp( + uint32_t slotId, + uint32_t skipChMask, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode_V3Lp( + uint32_t skipChMask, + cy_stc_capsense_context_t * context); +#endif + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap_V3Lp( + cy_en_capsense_bist_external_cap_id_t integrationCapId, + uint32_t * ptrValue, + uint32_t maxCapacitance, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) */ + +/** \} \endcond */ + + +#if defined(__cplusplus) +} +#endif + +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) */ + +#endif /* (defined(CY_IP_M0S8MSCV3LP)) */ + +#endif /* CY_CAPSENSE_SELFTEST_LP_H */ + + +/* [] END OF FILE */ diff --git a/cy_capsense_selftest_v2.c b/cy_capsense_selftest_v2.c index 5db82f9..6e6fb19 100644 --- a/cy_capsense_selftest_v2.c +++ b/cy_capsense_selftest_v2.c @@ -1,6 +1,6 @@ /***************************************************************************//** -* \file cy_capsense_selftest.c -* \version 3.0.1 +* \file cy_capsense_selftest_v2.c +* \version 4.0 * * \brief * This file provides the source code to the Built-in Self-test (BIST) @@ -424,9 +424,9 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V2( if (0u == (testEnMask & (~CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK))) { - if(NULL != context) + if (NULL != context) { - if(CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) if (0u != (CY_CAPSENSE_BIST_CRC_WDGT_MASK & testEnMask)) @@ -442,7 +442,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V2( #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) /* The next group of tests is hardware-dependent, the request is to switch the sense method */ - if(CY_CAPSENSE_SUCCESS_E == Cy_CapSense_SwitchSensingMode(CY_CAPSENSE_BIST_GROUP, context)) + if (CY_CAPSENSE_SUCCESS_E == Cy_CapSense_SwitchSensingMode(CY_CAPSENSE_BIST_GROUP, context)) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) if (0u != (CY_CAPSENSE_BIST_VDDA_MASK & testEnMask)) @@ -470,8 +470,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V2( #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) - if ((0u != (CY_CAPSENSE_BIST_SHIELD_CAP_MASK & testEnMask)) && - (CY_CAPSENSE_ENABLE == context->ptrCommonConfig->csdShieldEn)) + if (0u != (CY_CAPSENSE_BIST_SHIELD_CAP_MASK & testEnMask)) { bistStatus = Cy_CapSense_MeasureCapacitanceShield(&tmpVal, context); if (CY_CAPSENSE_BIST_SUCCESS_E != bistStatus) @@ -525,7 +524,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V2( } } - return (result); + return result; } @@ -600,19 +599,15 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget_V2( cy_stc_capsense_context_t * context) { uint16_t crcValue; - cy_stc_capsense_widget_context_t * ptrWdCxt; cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; - if(NULL != context) + if (NULL != context) { if (context->ptrCommonConfig->numWd > widgetId) { crcValue = Cy_CapSense_GetCrcWidget(widgetId, context); if ((context->ptrBistContext->ptrWdgtCrc[widgetId]) != crcValue) { - /* Get a pointer to the specified widget context structure */ - ptrWdCxt = &context->ptrWdContext[widgetId]; - /* Write to the self-test data structure widgetId of the first badly-tested widget */ if (0Lu == (context->ptrBistContext->testResultMask & CY_CAPSENSE_BIST_CRC_WDGT_MASK)) { @@ -620,7 +615,8 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget_V2( context->ptrBistContext->crcWdgtId = (uint8_t)widgetId; context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_CRC_WDGT_MASK; } - ptrWdCxt->status &= (uint8_t)~CY_CAPSENSE_WD_WORKING_MASK; + /* Marks widget non-working */ + (void)Cy_CapSense_SetWidgetStatus(widgetId, 0u, CY_CAPSENSE_WD_WORKING_MASK, context); result = CY_CAPSENSE_BIST_FAIL_E; } else @@ -630,7 +626,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget_V2( } } - return (result); + return result; } @@ -669,7 +665,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_CheckAllWidgetCRC( break; } } - return (result); + return result; } @@ -796,7 +792,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline_V2( const cy_stc_capsense_sensor_context_t *ptrSnsCxt; cy_stc_capsense_widget_config_t const *ptrWdgtCfg; - if(NULL != context) + if (NULL != context) { if ((context->ptrCommonConfig->numWd > widgetId) && (context->ptrWdConfig[widgetId].numSns > sensorId)) @@ -806,7 +802,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline_V2( /* Get a pointer to the specified sensor context structure */ ptrSnsCxt = &ptrWdgtCfg->ptrSnsContext[sensorId]; /* Check baselines for all frequencies */ - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { cxtOffset = sensorId + (freqChIndex * context->ptrCommonConfig->numSns); bslnInv = (uint16_t)(~(ptrWdgtCfg->ptrBslnInv[cxtOffset])); @@ -829,7 +825,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline_V2( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN) */ @@ -903,7 +899,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount_V2( const cy_stc_capsense_sensor_context_t *ptrSnsCxt; cy_stc_capsense_widget_config_t const *ptrWdgtCfg; - if(NULL != context) + if (NULL != context) { if ((context->ptrCommonConfig->numWd > widgetId) && (context->ptrWdConfig[widgetId].numSns > sensorId)) @@ -913,7 +909,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount_V2( /* Find a pointer to the specified sensor context structure */ ptrSnsCxt = &ptrWdgtCfg->ptrSnsContext[sensorId]; /* Check raw counts for all frequencies */ - for(freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) + for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { if ((ptrSnsCxt->raw > rawcountHighLimit) || (ptrSnsCxt->raw < rawcountLowLimit)) @@ -933,7 +929,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount_V2( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_RAW_INTEGRITY_EN) */ @@ -1067,7 +1063,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorPins_V2( cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; uint32_t numWdgtElectrodes; - if(NULL != context) + if (NULL != context) { if (context->ptrCommonConfig->numWd > widgetId) { @@ -1133,7 +1129,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorPins_V2( } } - return (result); + return result; } @@ -1217,7 +1213,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckSensor( { Cy_CapSense_SnsShortUpdateTestResult(widgetId, sensorId, context); } - return (result); + return result; } @@ -1311,7 +1307,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckElectrode( /* Get the next electrode */ ioPtr++; } - return (result); + return result; } @@ -1343,7 +1339,8 @@ static void Cy_CapSense_SnsShortUpdateTestResult( uint32_t sensorId, cy_stc_capsense_context_t * context) { - context->ptrWdContext[widgetId].status &= (uint8_t)~CY_CAPSENSE_WD_WORKING_MASK; + /* Marks widget non-working */ + (void)Cy_CapSense_SetWidgetStatus(widgetId, 0u, CY_CAPSENSE_WD_WORKING_MASK, context); if (0Lu == (context->ptrBistContext->testResultMask & CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK)) { /* Write to the BIST context structure widgetId and sensorId of the first shorted sensor */ @@ -1425,7 +1422,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckAllSensors( } } - return (result); + return result; } @@ -1645,7 +1642,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensor( cy_en_capsense_bist_hw_config_t hwConfiguration; uint32_t convNumber; - if(NULL != context) + if (NULL != context) { if ((context->ptrCommonConfig->numWd > widgetId)) { @@ -1691,7 +1688,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensor( Cy_CapSense_BistSwitchAllSnsPinState(desiredIoState, context); #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) - Cy_CapSense_BistSwitchAllShieldPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + Cy_CapSense_BistSwitchAllShieldPinState(desiredIoState, context); #endif /* Set the divider value for the mod clock 1u lower than the desired divider */ @@ -1712,7 +1709,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensor( result = Cy_CapSense_BistMeasureCapacitanceSensor(&context->ptrWdConfig[widgetId].ptrEltdCapacitance[sensorId], context); Cy_CapSense_BistDisconnectElectrode(widgetId, sensorId, context); - if(NULL != ptrValue) + if (NULL != ptrValue) { *ptrValue = context->ptrWdConfig[widgetId].ptrEltdCapacitance[sensorId]; } @@ -1728,7 +1725,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensor( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ @@ -1821,9 +1818,9 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShield( cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; uint32_t convNumber; - if(NULL != context) + if (NULL != context) { - if((0u != context->ptrCommonConfig->csdShieldNumPin) || + if ((0u != context->ptrCommonConfig->csdShieldNumPin) || (CY_CAPSENSE_BIST_IO_SHIELD_E == context->ptrBistContext->intrEltdCapShieldISC)) { /* Release previously-captured HW resources by the other mode and capture them for BIST */ @@ -1833,7 +1830,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShield( context->ptrCommonContext->status = CY_CAPSENSE_BUSY; /* Set all sensor pins to an ISC */ - if(CY_CAPSENSE_BIST_IO_SHIELD_E == context->ptrBistContext->intrEltdCapShieldISC) + if (CY_CAPSENSE_BIST_IO_SHIELD_E == context->ptrBistContext->intrEltdCapShieldISC) { Cy_CapSense_BistSwitchAllSnsPinState(CY_CAPSENSE_BIST_IO_SENSE_E, context); } @@ -1861,7 +1858,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShield( context->ptrCommonConfig->ptrCsdBase->SEQ_NORM_CNT = convNumber; /* Measure and store the shield electrode(s) capacitance value, return the value and status */ result = Cy_CapSense_BistMeasureCapacitanceSensor(&context->ptrBistContext->shieldCap, context); - if(NULL != ptrValue) + if (NULL != ptrValue) { *ptrValue = context->ptrBistContext->shieldCap; } @@ -1876,7 +1873,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShield( } } - return (result); + return result; } #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN)) */ @@ -1995,7 +1992,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorExt( uint64_t isBusyWatchdogTimeUs; - if((NULL != context) && (NULL != ptrScanConfig)) + if ((NULL != context) && (NULL != ptrScanConfig)) { idacIdx = (uint32_t)ptrScanConfig->idacGainIndex; idacCode = (uint32_t)ptrScanConfig->idacMod; @@ -2037,7 +2034,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorExt( Cy_CapSense_BistSwitchHwConfig(hwConfiguration, context); Cy_CapSense_BistSwitchAllSnsPinState(desiredIoState, context); #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) - Cy_CapSense_BistSwitchAllShieldPinState(CY_CAPSENSE_BIST_IO_STRONG_E, context); + Cy_CapSense_BistSwitchAllShieldPinState(desiredIoState, context); #endif /* Calculate the VrefHigh voltage */ vRefMv = Cy_CapSense_GetVrefHighMv((uint32_t)ptrScanConfig->vrefGain, context); @@ -2074,7 +2071,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorExt( modClkDivider = ptrScanConfig->modClk; snsClkDivider = ptrScanConfig->snsClk; - if(0u == snsClkDivider) + if (0u == snsClkDivider) { snsClkDivider = 1u; } @@ -2083,7 +2080,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorExt( isBusyWatchdogTimeUs *= (uint64_t)snsClkDivider * modClkDivider * CY_CAPSENSE_CONVERSION_MEGA; isBusyWatchdogTimeUs /= context->ptrCommonConfig->periClkHz; - if(0u == isBusyWatchdogTimeUs) + if (0u == isBusyWatchdogTimeUs) { isBusyWatchdogTimeUs = 1u; } @@ -2104,7 +2101,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorExt( rawCountTmp = (context->ptrCommonConfig->ptrCsdBase->RESULT_VAL1 & CY_CAPSENSE_CSD_RESULT_VAL1_VALUE_MSK); /* Capacitance calculation and storage */ - if(NULL != ptrValue) + if (NULL != ptrValue) { cp = ((uint64_t)context->ptrCommonConfig->idacGainTable[idacIdx].gainValue) * (uint64_t)idacCode; cp *= (uint64_t)rawCountTmp; @@ -2137,7 +2134,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorExt( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ @@ -2218,7 +2215,7 @@ static void Cy_CapSense_BistMeasureCapacitanceSensorInit( ptrBistCxt->eltdCapSnsClkFreqHz = context->ptrCommonConfig->periClkHz / ptrBistCxt->eltdCapModClk / ptrBistCxt->eltdCapSnsClk; /* Reference Voltage */ - if(ptrBistCxt->eltdCapVrefMv == 0u) + if (ptrBistCxt->eltdCapVrefMv == 0u) { /* Get the recommended reference voltage */ temp = CY_CAPSENSE_BIST_CAP_MEAS_VREF_MV_DEFAULT; @@ -2341,13 +2338,12 @@ static void Cy_CapSense_BistMeasureCapacitanceSensorInit( #endif #endif - /* High-Speed Comparator initialization */ + /* High-Speed Comparator settings for scan */ ptrBistCxt->regHscmpScan = CY_CAPSENSE_CSD_HSCMP_HSCMP_EN_MSK; ptrBistCxt->regHscmpScanShield = CY_CAPSENSE_CSD_HSCMP_HSCMP_EN_MSK; #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) ptrBistCxt->regHscmpScan = 0u; - ptrBistCxt->regHscmpScanShield = 0u; #endif ptrBistCxt->regSwHsPSelCmodInit = 0u; @@ -2666,7 +2662,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( { modClkDivider = context->ptrBistContext->eltdCapModClk; - if(0u == modClkDivider) + if (0u == modClkDivider) { modClkDivider = 1u; } @@ -2675,7 +2671,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( isBusyWatchdogTimeUs *= (uint64_t)modClkDivider * CY_CAPSENSE_CONVERSION_MEGA; isBusyWatchdogTimeUs /= context->ptrCommonConfig->periClkHz; - if(0u == isBusyWatchdogTimeUs) + if (0u == isBusyWatchdogTimeUs) { isBusyWatchdogTimeUs = 1u; } @@ -2738,7 +2734,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( *cpPtr = (uint32_t)cp; } - return (result); + return result; } @@ -2865,7 +2861,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensorRun( result = CY_CAPSENSE_BIST_HW_BUSY_E; } - return (result); + return result; } #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN) ||\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN)) */ @@ -2928,7 +2924,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensorAll( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ @@ -2960,7 +2956,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensorAll( * allows detecting a short of the measured capacitor to other pins. * * To measure all the available capacitors, the Cy_CapSense_RunSelfTest() -* function can be used with the CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK mask. The measured +* function can be used with the CY_CAPSENSE_BIST_EXTERNAL_CAP_MASK mask. The measured * results are stored in the corresponding field of the * \ref cy_stc_capsense_bist_context_t structure. * @@ -3049,35 +3045,29 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap_V2( { switch (integrationCapId) { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) case CY_CAPSENSE_BIST_CMOD_ID_E: - if (CY_CAPSENSE_ENABLE != context->ptrCommonConfig->csdEn) - { - bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; - } ptrCapPort = context->ptrCommonConfig->portCmod; capacitorPin = (uint32_t)context->ptrCommonConfig->pinCmod; ptrResult = &context->ptrBistContext->cModCap; break; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) case CY_CAPSENSE_BIST_CINTA_ID_E: - if (CY_CAPSENSE_ENABLE != context->ptrCommonConfig->csxEn) - { - bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; - } ptrCapPort = context->ptrCommonConfig->portCintA; capacitorPin = (uint32_t)context->ptrCommonConfig->pinCintA; ptrResult = &context->ptrBistContext->cIntACap; break; case CY_CAPSENSE_BIST_CINTB_ID_E: - if (CY_CAPSENSE_ENABLE != context->ptrCommonConfig->csxEn) - { - bistStatus = CY_CAPSENSE_BIST_BAD_PARAM_E; - } ptrCapPort = context->ptrCommonConfig->portCintB; capacitorPin = (uint32_t)context->ptrCommonConfig->pinCintB; ptrResult = &context->ptrBistContext->cIntBCap; break; - #if((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && \ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_CAP_EN)) + #endif + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_CAP_EN)) case CY_CAPSENSE_BIST_CSH_ID_E: ptrCapPort = context->ptrCommonConfig->portCsh; capacitorPin = (uint32_t)context->ptrCommonConfig->pinCsh; @@ -3106,7 +3096,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap_V2( /* IDAC Gain - LSB */ tempIDAC = (tempIDAC + (CY_CAPSENSE_BIST_IDAC_MAX - 1u)) / CY_CAPSENSE_BIST_IDAC_MAX; /* Search for corresponding IDAC gain */ - while(idacIdx < (CY_CAPSENSE_IDAC_GAIN_NUMBER - 1u)) + while (idacIdx < (CY_CAPSENSE_IDAC_GAIN_NUMBER - 1u)) { if (context->ptrCommonConfig->idacGainTable[idacIdx].gainValue > (uint32_t)tempIDAC) { @@ -3142,7 +3132,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap_V2( if (CY_CAPSENSE_BIST_TIMEOUT_E != bistStatus) { *ptrResult = (uint16_t)extCapValue; - if(NULL != ptrValue) + if (NULL != ptrValue) { *ptrValue = extCapValue; } @@ -3150,7 +3140,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceCap_V2( /* Clear the BUSY flag */ context->ptrCommonContext->status = CY_CAPSENSE_NOT_BUSY; } - return (bistStatus); + return bistStatus; } @@ -3199,7 +3189,7 @@ static void Cy_CapSense_BistMeasureCapacitanceCapInit( ptrBistCxt->extCapModClk <<= 1u; } - if(ptrBistCxt->extCapVrefMv == 0u) + if (ptrBistCxt->extCapVrefMv == 0u) { /* Get the recommended reference voltage */ temp = CY_CAPSENSE_BIST_CAP_MEAS_VREF_MV_DEFAULT; @@ -3384,7 +3374,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceCapRun( *ptrExtCapValue = (uint32_t)tempCapacitance; } - return (bistStatus); + return bistStatus; } @@ -3463,7 +3453,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceCapAll( } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ - return (bistStatus); + return bistStatus; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) */ @@ -3535,7 +3525,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureVdda_V2( } } - return (result); + return result; } @@ -3585,7 +3575,7 @@ static void Cy_CapSense_BistMeasureVddaInit(cy_stc_capsense_context_t * context) { vrefValMv = (vddaValMv - CY_CAPSENSE_BIST_VDDA_MIN_DIFF); } - if(vrefValMv < CY_CAPSENSE_BIST_VDDA_VREF_MIN_MV) + if (vrefValMv < CY_CAPSENSE_BIST_VDDA_VREF_MIN_MV) { vrefValMv = CY_CAPSENSE_BIST_VDDA_VREF_MIN_MV; } @@ -3597,7 +3587,7 @@ static void Cy_CapSense_BistMeasureVddaInit(cy_stc_capsense_context_t * context) /* Update the nominal Vref to real Vref considering available trimming for SRSS */ #if (CY_CAPSENSE_PSOC6_FOURTH_GEN) - if(CY_CAPSENSE_VREF_SRSS == context->ptrCommonConfig->ssVrefSource) + if (CY_CAPSENSE_VREF_SRSS == context->ptrCommonConfig->ssVrefSource) { vrefValMv = Cy_CSD_GetVrefTrim(vrefValMv); } @@ -3785,7 +3775,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureVddaRun( conversionStatus = Cy_CSD_GetConversionStatus(ptrCsdHwBase, context->ptrCommonConfig->ptrCsdContext); watchdogCounter--; } - while((CY_CSD_BUSY == conversionStatus) && (0u != watchdogCounter)); + while ((CY_CSD_BUSY == conversionStatus) && (0u != watchdogCounter)); ptrCsdHwBase->INTR = CY_CAPSENSE_CSD_INTR_ALL_MSK; (void)ptrCsdHwBase->INTR; tVssa2Vref = ptrCsdHwBase->ADC_RES; @@ -3799,7 +3789,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureVddaRun( * Measures the time to bring Cref1 + Cref2 back up to Vrefhi * (after bringing them down for time A/2 cycles with IDACB sinking) */ - if(CY_CAPSENSE_BIST_SUCCESS_E == retStatus) + if (CY_CAPSENSE_BIST_SUCCESS_E == retStatus) { ptrCsdHwBase->ADC_CTL = (ptrCsdHwBase->ADC_CTL & ~CY_CAPSENSE_CSD_ADC_CTL_ADC_MODE_MSK) | ((uint32_t)CY_CAPSENSE_BIST_VDDA_MEASMODE_VREFBY2 & CY_CAPSENSE_CSD_ADC_CTL_ADC_MODE_MSK); @@ -3810,7 +3800,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureVddaRun( conversionStatus = Cy_CSD_GetConversionStatus(ptrCsdHwBase, context->ptrCommonConfig->ptrCsdContext); watchdogCounter--; } - while((CY_CSD_BUSY == conversionStatus) && (0u != watchdogCounter)); + while ((CY_CSD_BUSY == conversionStatus) && (0u != watchdogCounter)); ptrCsdHwBase->INTR = CY_CAPSENSE_CSD_INTR_ALL_MSK; (void)ptrCsdHwBase->INTR; tRecover = ptrCsdHwBase->ADC_RES; @@ -3824,7 +3814,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureVddaRun( * Phase 3: * Measures the time to bring Cref1 + Cref2 from Vdda to Vrefhi */ - if(CY_CAPSENSE_BIST_SUCCESS_E == retStatus) + if (CY_CAPSENSE_BIST_SUCCESS_E == retStatus) { /* Connect VDDA to csdbusb */ ptrCsdHwBase->SW_SHIELD_SEL = CY_CAPSENSE_CSD_SW_SHIELD_SEL_SW_HCBV_STATIC_CLOSE; @@ -3837,7 +3827,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureVddaRun( conversionStatus = Cy_CSD_GetConversionStatus(ptrCsdHwBase, context->ptrCommonConfig->ptrCsdContext); watchdogCounter--; } - while((CY_CSD_BUSY == conversionStatus) && (0u != watchdogCounter)); + while ((CY_CSD_BUSY == conversionStatus) && (0u != watchdogCounter)); ptrCsdHwBase->INTR = CY_CAPSENSE_CSD_INTR_ALL_MSK; (void)ptrCsdHwBase->INTR; tVdda2Vref = ptrCsdHwBase->ADC_RES; @@ -3851,7 +3841,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureVddaRun( * Phase 4: * Convert the results of measurements to millivolts. */ - if(CY_CAPSENSE_BIST_SUCCESS_E == retStatus) + if (CY_CAPSENSE_BIST_SUCCESS_E == retStatus) { tVssa2Vref &= CY_CAPSENSE_CSD_ADC_RES_VALUE_MSK; tRecover &= CY_CAPSENSE_CSD_ADC_RES_VALUE_MSK; @@ -3873,7 +3863,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureVddaRun( /* Clear the BUSY flag */ context->ptrCommonContext->status = CY_CAPSENSE_NOT_BUSY; - return (retStatus); + return retStatus; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN) */ @@ -3961,17 +3951,16 @@ void Cy_CapSense_BistDisableMode(cy_stc_capsense_context_t * context) *******************************************************************************/ void Cy_CapSense_BistDsInitialize_V2(cy_stc_capsense_context_t * context) { - uint32_t wdIndex; - uint32_t wdNum = (uint32_t)context->ptrCommonConfig->numWd; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) + uint32_t wdIndex; + uint32_t wdNum = (uint32_t)context->ptrCommonConfig->numWd; - /* Initialize CRC and status for all widgets */ - for (wdIndex = 0u; wdIndex < wdNum; wdIndex++) - { - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) + /* Initialize CRC for all widgets */ + for (wdIndex = 0u; wdIndex < wdNum; wdIndex++) + { Cy_CapSense_UpdateCrcWidget(wdIndex, context); - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) */ - context->ptrWdContext[wdIndex].status |= (uint8_t)CY_CAPSENSE_WD_WORKING_MASK; - } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) */ #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN) ||\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN)) @@ -3989,6 +3978,9 @@ void Cy_CapSense_BistDsInitialize_V2(cy_stc_capsense_context_t * context) context->ptrBistContext->hwConfig = CY_CAPSENSE_BIST_HW_UNDEFINED_E; context->ptrBistContext->currentISC = CY_CAPSENSE_BIST_IO_UNDEFINED_E; + context->ptrBistContext->intrEltdCapCsdISC = context->ptrBistContext->eltdCapCsdISC; + context->ptrBistContext->intrEltdCapCsxISC = context->ptrBistContext->eltdCapCsxISC; + context->ptrBistContext->intrEltdCapShieldISC = context->ptrBistContext->shieldCapISC; } @@ -4019,7 +4011,7 @@ static void Cy_CapSense_BistSwitchHwConfig( { context->ptrBistContext->hwConfig = hwCfg; /* Enable the specified mode */ - switch(hwCfg) + switch (hwCfg) { case CY_CAPSENSE_BIST_HW_SHORT_E: { @@ -4163,40 +4155,37 @@ static void Cy_CapSense_BistSwitchAllShieldPinState( en_hsiom_sel_t desiredHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; uint32_t desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; - if (CY_CAPSENSE_ENABLE == context->ptrCommonConfig->csdEn) + /* Change Drive mode and HSIOM depending on the current inactive sensor connection */ + if (CY_CAPSENSE_BIST_IO_STRONG_E == desiredPinState) { - /* Change Drive mode and HSIOM depending on the current inactive sensor connection */ - if (CY_CAPSENSE_BIST_IO_STRONG_E == desiredPinState) - { - desiredDriveMode = CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF; - desiredHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; - desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; - } - else if (CY_CAPSENSE_BIST_IO_SENSE_E == desiredPinState) - { - desiredDriveMode = CY_CAPSENSE_CSD_SCAN_PIN_DM; - desiredHsiom = CY_CAPSENSE_HSIOM_SEL_CSD_SENSE; - desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; - } - else if (CY_CAPSENSE_BIST_IO_SHIELD_E == desiredPinState) - { - desiredDriveMode = CY_CAPSENSE_DM_SHIELD; - desiredHsiom = CY_CAPSENSE_HSIOM_SEL_CSD_SHIELD; - desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; - } - else if (CY_CAPSENSE_BIST_IO_STRONG_HIGH_E == desiredPinState) - { - desiredDriveMode = CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF; - desiredHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; - desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2VDD; - } - else - { - /* Do nothing */ - } - /* Set all CAPSENSE™ pins to the desired state */ - Cy_CapSense_SetShieldPinState(desiredDriveMode, desiredPinOutput, desiredHsiom, context); + desiredDriveMode = CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF; + desiredHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; + desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; + } + else if (CY_CAPSENSE_BIST_IO_SENSE_E == desiredPinState) + { + desiredDriveMode = CY_CAPSENSE_CSD_SCAN_PIN_DM; + desiredHsiom = CY_CAPSENSE_HSIOM_SEL_CSD_SENSE; + desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; + } + else if (CY_CAPSENSE_BIST_IO_SHIELD_E == desiredPinState) + { + desiredDriveMode = CY_CAPSENSE_DM_SHIELD; + desiredHsiom = CY_CAPSENSE_HSIOM_SEL_CSD_SHIELD; + desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2GND; + } + else if (CY_CAPSENSE_BIST_IO_STRONG_HIGH_E == desiredPinState) + { + desiredDriveMode = CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF; + desiredHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; + desiredPinOutput = CY_CAPSENSE_BIST_DR_PIN2VDD; + } + else + { + /* Do nothing */ } + /* Set all CAPSENSE™ pins to the desired state */ + Cy_CapSense_SetShieldPinState(desiredDriveMode, desiredPinOutput, desiredHsiom, context); } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) */ @@ -4379,7 +4368,7 @@ static void Cy_CapSense_BistConnectElectrode( const cy_stc_capsense_pin_config_t * ptrPinCfg = ptrEltdCfg->ptrPin; /* Connect all electrode pins */ - for(i = 0u; i < ptrEltdCfg->numPins; i++) + for (i = 0u; i < ptrEltdCfg->numPins; i++) { Cy_CapSense_SsConfigPinRegisters(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber, CY_CAPSENSE_CSD_SCAN_PIN_DM, CY_CAPSENSE_HSIOM_SEL_CSD_SENSE); @@ -4453,7 +4442,7 @@ static void Cy_CapSense_BistDisconnectElectrode( break; case CY_CAPSENSE_BIST_IO_SHIELD_E: driveModeTmp = CY_CAPSENSE_DM_SHIELD; - hsiomTmp = CY_CAPSENSE_HSIOM_SEL_AMUXB; + hsiomTmp = CY_CAPSENSE_HSIOM_SEL_CSD_SHIELD; break; default: driveModeTmp = CY_CAPSENSE_DM_GPIO_ANALOG; @@ -4462,7 +4451,7 @@ static void Cy_CapSense_BistDisconnectElectrode( } /* Disconnect all electrode pins */ - for(i = 0u; i < ptrEltdCfg->numPins; i++) + for (i = 0u; i < ptrEltdCfg->numPins; i++) { Cy_CapSense_SsConfigPinRegisters(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber, driveModeTmp, hsiomTmp); Cy_GPIO_Clr(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber); @@ -4507,7 +4496,7 @@ static uint32_t Cy_CapSense_BistWaitEndOfScan( watchdogCounter--; } - return (watchdogCounter); + return watchdogCounter; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN) || \ diff --git a/cy_capsense_selftest_v2.h b/cy_capsense_selftest_v2.h index a9d29fb..02b8814 100644 --- a/cy_capsense_selftest_v2.h +++ b/cy_capsense_selftest_v2.h @@ -1,6 +1,6 @@ /***************************************************************************//** -* \file cy_capsense_selftest.h -* \version 3.0.1 +* \file cy_capsense_selftest_v2.h +* \version 4.0 * * \brief * This file provides the function prototypes of the BIST module. diff --git a/cy_capsense_selftest_v3.c b/cy_capsense_selftest_v3.c index c8aca23..22c907a 100644 --- a/cy_capsense_selftest_v3.c +++ b/cy_capsense_selftest_v3.c @@ -1,6 +1,6 @@ /***************************************************************************//** -* \file cy_capsense_selftest.c -* \version 3.0.1 +* \file cy_capsense_selftest_v3.c +* \version 4.0 * * \brief * This file provides the source code to the Built-in Self-test (BIST) @@ -21,6 +21,7 @@ #include "cy_syslib.h" #include "cy_sysclk.h" #include "cycfg_capsense_defines.h" +#include "cycfg_peripherals.h" #include "cy_capsense_common.h" #include "cy_capsense_sensing.h" #include "cy_capsense_sensing_v3.h" @@ -73,11 +74,11 @@ { \ .ctl = \ ((CY_CAPSENSE_SM_BASE_FULL_WAVE_REG_CTL_FLD_SENSE_EN << MSC_CTL_SENSE_EN_Pos) | \ - (CY_CAPSENSE_SM_BASE_FULL_WAVE_REG_CTL_FLD_MSCCMP_EN << MSC_CTL_MSCCMP_EN_Pos) | \ - ((uint32_t)CY_CAPSENSE_SCAN_MODE_INT_DRIVEN << MSC_CTL_OPERATING_MODE_Pos) | \ - (CY_CAPSENSE_SM_BASE_FULL_WAVE_REG_CTL_FLD_BUF_MODE << MSC_CTL_BUF_MODE_Pos) | \ - (CY_CAPSENSE_SM_BASE_FULL_WAVE_REG_CTL_FLD_CLK_MSC_RATIO << MSC_CTL_CLK_MSC_RATIO_Pos) | \ - (CY_CAPSENSE_SM_BASE_FULL_WAVE_REG_CTL_FLD_ENABLED << MSC_CTL_ENABLED_Pos)), \ + (CY_CAPSENSE_SM_BASE_FULL_WAVE_REG_CTL_FLD_MSCCMP_EN << MSC_CTL_MSCCMP_EN_Pos) | \ + ((uint32_t)CY_CAPSENSE_SCAN_MODE_INT_DRIVEN << MSC_CTL_OPERATING_MODE_Pos) | \ + (CY_CAPSENSE_SM_BASE_FULL_WAVE_REG_CTL_FLD_BUF_MODE << MSC_CTL_BUF_MODE_Pos) | \ + (CY_CAPSENSE_SM_BASE_FULL_WAVE_REG_CTL_FLD_CLK_MSC_RATIO << MSC_CTL_CLK_MSC_RATIO_Pos) | \ + (CY_CAPSENSE_SM_BASE_FULL_WAVE_REG_CTL_FLD_ENABLED << MSC_CTL_ENABLED_Pos)), \ .spare = 0x00uL, \ .scanCtl1 = 0x00uL, \ .scanCtl2 = 0x00uL, \ @@ -207,7 +208,7 @@ [CY_CAPSENSE_CTRLMUX_PIN_STATE_SNS] = (CY_CAPSENSE_SM_REG_SW_SEL_CSW3_SNS_VALUE), \ [CY_CAPSENSE_CTRLMUX_PIN_STATE_HIGH_Z] = (CY_CAPSENSE_SM_REG_SW_SEL_CSW5_HIGH_Z_VALUE), \ [CY_CAPSENSE_CTRLMUX_PIN_STATE_SHIELD] = 0x00uL, \ - [CY_CAPSENSE_CTRLMUX_PIN_STATE_VDDA2] = 0x00uL, \ + [CY_CAPSENSE_CTRLMUX_PIN_STATE_VDDA2] = (CY_CAPSENSE_SM_REG_SW_SEL_CSW6_VDDA2_VALUE), \ }, \ .mode = \ { \ @@ -358,6 +359,7 @@ uint8_t bistSenseGroup, uint8_t bistScanMode, cy_stc_capsense_context_t * context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) static void Cy_CapSense_BistSetPinDr( cy_stc_capsense_pin_config_t const *ioPtr, @@ -366,6 +368,7 @@ cy_stc_capsense_pin_config_t const *ioPtr, uint32_t value); #endif + static void Cy_CapSense_BistSwitchAllSnsPinState( cy_en_capsense_bist_io_state_t desiredPinState, const cy_stc_capsense_context_t * context); @@ -513,7 +516,7 @@ * testEnMask parameter or the context is * a NULL pointer. The function * was not performed. -* - CY_CAPSENSE_BIST_HW_BUSY_E - The CSD HW block is busy with a previous +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a previous * operation. The function was not performed. * - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during * the measurement, you may need to repeat @@ -530,9 +533,9 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V3( if (0u == (testEnMask & (~CY_CAPSENSE_BIST_RUN_AVAILABLE_SELF_TEST_MASK))) { - if(NULL != context) + if (NULL != context) { - if(CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) + if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) { result = CY_CAPSENSE_BIST_SUCCESS_E; @@ -549,7 +552,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V3( #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) /* The next group of tests is hardware-dependent and they need to switch the configuration to BIST one */ - if((uint32_t)CY_CAPSENSE_SUCCESS_E == Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY, context)) + if ((uint32_t)CY_CAPSENSE_SUCCESS_E == Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY, context)) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) @@ -590,7 +593,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V3( if ((0u != (CY_CAPSENSE_BIST_SHIELD_CAP_MASK & testEnMask)) && (CY_CAPSENSE_DISABLE != context->ptrCommonConfig->csdShieldMode)) { - if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceShieldElectrode(0u, context)) + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceShieldElectrode_V3(0u, context)) { result = CY_CAPSENSE_BIST_FAIL_E; context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_SHIELD_CAP_MASK; @@ -612,7 +615,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V3( } } - return (result); + return result; } @@ -661,7 +664,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_RunSelfTest_V3( * function. * * \note -* This function is available only for the fourth-generation CAPSENSE™. +* This function is available only for the fifth-generation CAPSENSE™. * * \param widgetId * Specifies the ID number of the widget. @@ -687,19 +690,15 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget_V3( cy_stc_capsense_context_t * context) { uint16_t crcValue; - cy_stc_capsense_widget_context_t * ptrWdCxt; cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; - if(NULL != context) + if (NULL != context) { if (context->ptrCommonConfig->numWd > widgetId) { crcValue = Cy_CapSense_GetCrcWidget(widgetId, context); if ((context->ptrBistContext->ptrWdgtCrc[widgetId]) != crcValue) { - /* Get a pointer to the specified widget context structure */ - ptrWdCxt = &context->ptrWdContext[widgetId]; - /* Write to the self-test data structure widgetId of the first badly-tested widget */ if (0Lu == (context->ptrBistContext->testResultMask & CY_CAPSENSE_BIST_CRC_WDGT_MASK)) { @@ -707,7 +706,8 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget_V3( context->ptrBistContext->crcWdgtId = (uint8_t)widgetId; context->ptrBistContext->testResultMask |= CY_CAPSENSE_BIST_CRC_WDGT_MASK; } - ptrWdCxt->status &= (uint8_t)~CY_CAPSENSE_WD_WORKING_MASK; + /* Marks widget non-working */ + (void)Cy_CapSense_SetWidgetStatus(widgetId, 0u, CY_CAPSENSE_WD_WORKING_MASK, context); result = CY_CAPSENSE_BIST_FAIL_E; } else @@ -717,7 +717,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckCRCWidget_V3( } } - return (result); + return result; } @@ -756,7 +756,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_CheckAllWidgetCRC( break; } } - return (result); + return result; } @@ -860,7 +860,7 @@ void Cy_CapSense_UpdateAllWidgetCrc(cy_stc_capsense_context_t * context) * Cy_CapSense_CheckIntegritySensorRawcount() function. * * \note -* This function is available only for the fourth-generation CAPSENSE™. +* This function is available only for the fifth-generation CAPSENSE™. * * \param widgetId * Specifies the ID number of the widget. @@ -907,10 +907,10 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline_V3( const cy_stc_capsense_sensor_context_t *ptrSnsCxt; cy_stc_capsense_widget_config_t const *ptrWdgtCfg; - if(NULL != context) + if (NULL != context) { - if ((context->ptrCommonConfig->numWd > widgetId) && - (context->ptrWdConfig[widgetId].numSns > sensorId)) + if (((uint32_t)context->ptrCommonConfig->numWd > widgetId) && + ((uint32_t)context->ptrWdConfig[widgetId].numSns > sensorId)) { /* Get a pointer to the specified widget configuration structure */ ptrWdgtCfg = &context->ptrWdConfig[widgetId]; @@ -936,7 +936,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline_V3( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_BSLN_INTEGRITY_EN) */ @@ -965,7 +965,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorBaseline_V3( * Cy_CapSense_CheckIntegritySensorBaseline() function. * * \note -* This function is available only for the fourth-generation CAPSENSE™. +* This function is available only for the fifth-generation CAPSENSE™. * * \param widgetId * Specifies the ID number of the widget. @@ -1009,10 +1009,10 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount_V3( const cy_stc_capsense_sensor_context_t *ptrSnsCxt; cy_stc_capsense_widget_config_t const *ptrWdgtCfg; - if(NULL != context) + if (NULL != context) { - if ((context->ptrCommonConfig->numWd > widgetId) && - (context->ptrWdConfig[widgetId].numSns > sensorId)) + if (((uint32_t)context->ptrCommonConfig->numWd > widgetId) && + ((uint32_t)context->ptrWdConfig[widgetId].numSns > sensorId)) { /* Find a pointer to the specified widget configuration structure */ ptrWdgtCfg = &context->ptrWdConfig[widgetId]; @@ -1033,7 +1033,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount_V3( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_RAW_INTEGRITY_EN) */ @@ -1154,7 +1154,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorRawcount_V3( * are out of the defined range. * - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. * The test was not executed. -* - CY_CAPSENSE_BIST_HW_BUSY_E - The CSD HW block is busy with a +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a * previous operation. The function * was not executed. * @@ -1167,9 +1167,9 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorPins_V3( cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; uint32_t numWdgtElectrodes; - if(NULL != context) + if (NULL != context) { - if (context->ptrCommonConfig->numWd > widgetId) + if ((uint32_t)context->ptrCommonConfig->numWd > widgetId) { /* Get a total number of the widget elements: for CSX it is numRows + numCols, for CSD it is totalNumSns */ if (CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) @@ -1231,7 +1231,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_CheckIntegritySensorPins_V3( } } - return (result); + return result; } @@ -1315,7 +1315,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckSensor( { Cy_CapSense_SnsShortUpdateTestResult(widgetId, sensorId, context); } - return (result); + return result; } @@ -1409,7 +1409,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckElectrode( /* Get the next electrode */ ioPtr++; } - return (result); + return result; } @@ -1441,7 +1441,8 @@ static void Cy_CapSense_SnsShortUpdateTestResult( uint32_t sensorId, cy_stc_capsense_context_t * context) { - context->ptrWdContext[widgetId].status &= (uint8_t)~CY_CAPSENSE_WD_WORKING_MASK; + /* Marks widget non-working */ + (void)Cy_CapSense_SetWidgetStatus(widgetId, 0u, CY_CAPSENSE_WD_WORKING_MASK, context); if (0Lu == (context->ptrBistContext->testResultMask & CY_CAPSENSE_BIST_SNS_INTEGRITY_MASK)) { /* Write to the BIST context structure widgetId and sensorId of the first shorted sensor */ @@ -1551,7 +1552,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_SnsShortCheckAllSensors( } } - return (result); + return result; } @@ -1763,11 +1764,11 @@ void Cy_CapSense_BistSetAllCmodPinsState( /* Loop through all electrodes */ for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - cmod1Port = ptrCommonCfg->ptrMscChConfig[curChIndex].portCmod1; - cmod1Pin = ptrCommonCfg->ptrMscChConfig[curChIndex].pinCmod1; + cmod1Port = ptrCommonCfg->ptrChConfig[curChIndex].portCmod1; + cmod1Pin = ptrCommonCfg->ptrChConfig[curChIndex].pinCmod1; - cmod2Port = ptrCommonCfg->ptrMscChConfig[curChIndex].portCmod2; - cmod2Pin = ptrCommonCfg->ptrMscChConfig[curChIndex].pinCmod2; + cmod2Port = ptrCommonCfg->ptrChConfig[curChIndex].portCmod2; + cmod2Pin = ptrCommonCfg->ptrChConfig[curChIndex].pinCmod2; Cy_CapSense_SsConfigPinRegisters(cmod1Port, (uint32_t)cmod1Pin, desiredDriveMode, desiredHsiom); Cy_CapSense_SsConfigPinRegisters(cmod2Port, (uint32_t)cmod2Pin, desiredDriveMode, desiredHsiom); @@ -1796,7 +1797,7 @@ void Cy_CapSense_BistSetAllCmodPinsState( #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) /******************************************************************************* -* Function Name: Cy_CapSense_MeasureCapacitanceSensorElectrode +* Function Name: Cy_CapSense_MeasureCapacitanceSensorElectrode_V3 ****************************************************************************//** * * Measures the specified CSD sensor / CSX electrode capacitance in femtofarads. @@ -1901,12 +1902,14 @@ void Cy_CapSense_BistSetAllCmodPinsState( * successfully, the result is valid. * - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. * The measurement was not executed. -* - CY_CAPSENSE_BIST_HW_BUSY_E - The CSD HW block is busy with a +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a * previous operation. * The measurement was not executed. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement. * *******************************************************************************/ -cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode( +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode_V3( uint32_t widgetId, uint32_t eltdId, cy_stc_capsense_context_t * context) @@ -1915,9 +1918,9 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode( uint32_t numWdgtElectrodes; const cy_stc_capsense_electrode_config_t * ptrEltdCfg; - if(NULL != context) + if (NULL != context) { - if ((context->ptrCommonConfig->numWd > widgetId)) + if ((uint32_t)context->ptrCommonConfig->numWd > widgetId) { /* Get the total widget electrode number: for CSX it is numRows + numCols, for CSD it is totalNumSns */ if ((uint8_t)CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) @@ -1926,11 +1929,13 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode( numWdgtElectrodes = context->ptrWdConfig[widgetId].numRows + (uint32_t)context->ptrWdConfig[widgetId].numCols; context->ptrBistContext->currentISC = context->ptrBistContext->intrEltdCapCsxISC; + context->ptrActiveScanSns[0u].currentSenseMethod = CY_CAPSENSE_CSX_GROUP; } else { numWdgtElectrodes = context->ptrWdConfig[widgetId].numSns; context->ptrBistContext->currentISC = context->ptrBistContext->intrEltdCapCsdISC; + context->ptrActiveScanSns[0u].currentSenseMethod = CY_CAPSENSE_CSD_GROUP; } if (numWdgtElectrodes > eltdId) { @@ -1942,9 +1947,10 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode( /* Find the pointer to the electrode pin configuration and the electrode channel */ ptrEltdCfg = &context->ptrWdConfig[widgetId].ptrEltdConfig[eltdId]; /* Store the necessary values to the Bist context structure */ + context->ptrBistContext->curPtrEltdCfg = ptrEltdCfg; context->ptrBistContext->curBistChId = ptrEltdCfg->chId; context->ptrBistContext->skipChannelMask = ~(1u << ptrEltdCfg->chId); - context->ptrBistContext->curPtrEltdCfg = ptrEltdCfg; + context->ptrBistContext->curBistWdId = (uint16_t)widgetId; /* Switch the HW resource configuration to the sensor element capacitance measurement */ Cy_CapSense_BistSwitchHwConfig(CY_CAPSENSE_BIST_HW_ELTD_CAP_E, CY_CAPSENSE_CSD_GROUP, @@ -1970,7 +1976,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ @@ -2011,7 +2017,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceAllSensors( /* Loop through all the slots */ for (slotId = 0u; slotId < CY_CAPSENSE_SLOT_COUNT; slotId++) { - if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceSlotSensors(slotId, 0u, context)) + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceSlotSensors_V3(slotId, 0u, context)) { if (CY_CAPSENSE_BIST_SUCCESS_E == result) { @@ -2020,7 +2026,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceAllSensors( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ @@ -2075,7 +2081,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceAllElectrodes( /* Loop through all the sensor electrodes */ for (electrodeId = 0u; electrodeId < numWdgtElectrodes; electrodeId++) { - if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceSensorElectrode(widgetId, electrodeId, context)) + if (CY_CAPSENSE_BIST_SUCCESS_E != Cy_CapSense_MeasureCapacitanceSensorElectrode_V3(widgetId, electrodeId, context)) { if (CY_CAPSENSE_BIST_SUCCESS_E == result) { @@ -2085,14 +2091,14 @@ static cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceAllElectrodes( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) /******************************************************************************* -* Function Name: Cy_CapSense_MeasureCapacitanceSlotSensors +* Function Name: Cy_CapSense_MeasureCapacitanceSlotSensors_V3 ****************************************************************************//** * * Measures the specified slot sensor capacitance in femtofarads. The function @@ -2185,14 +2191,14 @@ static cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceAllElectrodes( * successfully, the result is valid. * - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. * The measurement was not executed. -* - CY_CAPSENSE_BIST_HW_BUSY_E - The CSD HW block is busy with a +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a * previous operation. * The measurement was not executed. * - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during * the measurement. * *******************************************************************************/ -cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors( +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors_V3( uint32_t slotId, uint32_t skipChMask, cy_stc_capsense_context_t * context) @@ -2209,7 +2215,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors( const cy_stc_capsense_common_config_t * ptrCommonCfg; cy_en_capsense_bist_status_t result = CY_CAPSENSE_BIST_BAD_PARAM_E; - if(NULL != context) + if (NULL != context) { if (CY_CAPSENSE_SLOT_COUNT > slotId) { @@ -2232,7 +2238,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors( curSlotIndex = slotId + ((curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT); scanSlotIndexValid = curSlotIndex; wdIndex = context->ptrScanSlots[curSlotIndex].wdId; - if(CY_CAPSENSE_SLOT_EMPTY == wdIndex) + if (CY_CAPSENSE_SLOT_EMPTY == wdIndex) { #if (CY_CAPSENSE_TOTAL_CH_NUMBER > 1u) for (i = 0u; i < CY_CAPSENSE_TOTAL_CH_NUMBER; i++) @@ -2328,7 +2334,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors( if (((0x01uL << curChIndex) & skipChMask) == 0u) { curSlotIndex = slotId + ((curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT); - if((context->ptrScanSlots[curSlotIndex].wdId != CY_CAPSENSE_SLOT_EMPTY) && + if ((context->ptrScanSlots[curSlotIndex].wdId != CY_CAPSENSE_SLOT_EMPTY) && (context->ptrScanSlots[curSlotIndex].wdId != CY_CAPSENSE_SLOT_SHIELD_ONLY)) { Cy_CapSense_ConnectSensor(curChIndex, context); @@ -2343,7 +2349,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors( if (((0x01uL << curChIndex) & skipChMask) == 0u) { curSlotIndex = slotId + ((curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT); - if((context->ptrScanSlots[curSlotIndex].wdId != CY_CAPSENSE_SLOT_EMPTY) && + if ((context->ptrScanSlots[curSlotIndex].wdId != CY_CAPSENSE_SLOT_EMPTY) && (context->ptrScanSlots[curSlotIndex].wdId != CY_CAPSENSE_SLOT_SHIELD_ONLY)) { Cy_CapSense_DisconnectSensor(curChIndex, context); @@ -2362,7 +2368,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors( } } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ @@ -2395,14 +2401,16 @@ static cy_capsense_status_t Cy_CapSense_BistMeasureCapacitanceSensorEnable( /* Generate the MSC base configuration for BIST scan and send it to the MSC HW block */ for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - mscStatus = Cy_MSC_Configure(context->ptrCommonConfig->ptrMscChConfig[curChIndex].ptrMscBase, + mscStatus = Cy_MSC_Configure(context->ptrCommonConfig->ptrChConfig[curChIndex].ptrHwBase, &cy_capsense_BistBaseTemplate, CY_MSC_CAPSENSE_KEY, - context->ptrCommonConfig->ptrMscChConfig[curChIndex].ptrMscContext); + context->ptrCommonConfig->ptrChConfig[curChIndex].ptrHwContext); if (CY_MSC_SUCCESS != mscStatus) { capStatus = CY_CAPSENSE_STATUS_HW_BUSY; break; } + /* The time interval is required for settling analog part of the HW block. */ + Cy_SysLib_DelayUs(CY_CAPSENSE_ANALOG_SETTLING_TIME_US); Cy_CapSense_BistGenerateBaseConfig(curChIndex, context); } /* Check if all MSC channel is not busy and clear all pending interrupts */ @@ -2411,13 +2419,12 @@ static cy_capsense_status_t Cy_CapSense_BistMeasureCapacitanceSensorEnable( for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { /* Clear all pending interrupts of the MSC HW block */ - context->ptrCommonConfig->ptrMscChConfig[curChIndex].ptrMscBase->INTR = - CY_CAPSENSE_MSC_INTR_ALL_MSK; - (void)context->ptrCommonConfig->ptrMscChConfig[curChIndex].ptrMscBase->INTR; + context->ptrCommonConfig->ptrChConfig[curChIndex].ptrHwBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; + (void)context->ptrCommonConfig->ptrChConfig[curChIndex].ptrHwBase->INTR; } } - return (capStatus); + return capStatus; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) */ @@ -2452,6 +2459,13 @@ static cy_capsense_status_t Cy_CapSense_BistMeasureCapacitanceSensorEnable( * by a measured capacitance short or HW block * failure or invalid configuration. You may need * to repeat the measurement after the issue fix. +* The result is set to zero. +* - CY_CAPSENSE_BIST_ERROR_E - The was an overflow or bad conversions during +* the scan. It can be caused +* by a measured capacitance short or HW block +* failure or invalid configuration. You may need +* to repeat the measurement after the issue fix. +* The result is set to zero. * *******************************************************************************/ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( @@ -2471,7 +2485,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( Cy_CapSense_BistMeasureCapacitanceSensorRun(context); watchdogPeriod = Cy_CapSense_BistWatchdogPeriodCalc(context); /* Wait for the end of scan and get the raw count */ - while (((ptrCommonCfg->ptrMscChConfig[context->ptrBistContext->curBistChId].ptrMscBase->INTR & + while (((ptrCommonCfg->ptrChConfig[context->ptrBistContext->curBistChId].ptrHwBase->INTR & MSC_INTR_MASK_SCAN_Msk) == 0u) && (0u != watchdogPeriod)) { watchdogPeriod--; @@ -2479,17 +2493,26 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( if (0u != watchdogPeriod) { rawCountTmp = - ptrCommonCfg->ptrMscChConfig[context->ptrBistContext->curBistChId].ptrMscBase->RESULT_FIFO_RD; - result = CY_CAPSENSE_BIST_SUCCESS_E; + ptrCommonCfg->ptrChConfig[context->ptrBistContext->curBistChId].ptrHwBase->RESULT_FIFO_RD; + /* Check for an overflow or bad conversions */ + if (0u == (rawCountTmp & MSC_RESULT_FIFO_RD_OVERFLOW_Msk)) + { + rawCountTmp &= MSC_RESULT_FIFO_RD_RAW_COUNT_Msk; + result = CY_CAPSENSE_BIST_SUCCESS_E; + } + else + { + result = CY_CAPSENSE_BIST_ERROR_E; + } } /* Clear all pending interrupts of all MSC HW blocks */ for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) { - ptrCommonCfg->ptrMscChConfig[chIndex].ptrMscBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; - (void)ptrCommonCfg->ptrMscChConfig[chIndex].ptrMscBase->INTR; + ptrCommonCfg->ptrChConfig[chIndex].ptrHwBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; + (void)ptrCommonCfg->ptrChConfig[chIndex].ptrHwBase->INTR; } /* Check for timeout and if no, then calculate capacitance and store the value to the data structure */ - if ((CY_CAPSENSE_BIST_TIMEOUT_E != result)) + if (CY_CAPSENSE_BIST_SUCCESS_E == result) { cp = (uint64_t)CY_CAPSENSE_BIST_CAP_MEAS_CDAC_LSB_FF_DIV_1000 * context->ptrBistContext->eltdCapRefCdac; cp *= rawCountTmp; @@ -2501,8 +2524,12 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( } *cpPtr = (uint32_t)cp; } + else + { + *cpPtr = 0u; + } - return (result); + return result; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN_EN) */ @@ -2542,12 +2569,19 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSensor( * \return * Returns a status of the test execution: * - CY_CAPSENSE_BIST_SUCCESS_E - The measurement completes -* successfully, the result is valid. +* successfully, the result is valid. * - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. * - CY_CAPSENSE_BIST_TIMEOUT_E - The scan reached the timeout. It can be caused -* by a measured capacitance short or CSD HW block -* failure or invalid configuration. You may need to -* repeat the measurement after the issue fix. +* by a measured capacitance short or by CAPSENSE™ HW block +* failure or invalid configuration. You may need to +* repeat the measurement after the issue fix. +* The result is not affected. +* - CY_CAPSENSE_BIST_ERROR_E - The was an overflow or bad conversions during +* the scan. It can be caused +* by a measured capacitance short or HW block +* failure or invalid configuration. You may need +* to repeat the measurement after the issue fix. +* The result is not affected. * *******************************************************************************/ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSlot( @@ -2586,21 +2620,30 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSlot( watchdogPeriod = Cy_CapSense_BistWatchdogPeriodCalc(context); result = CY_CAPSENSE_BIST_TIMEOUT_E; /* Wait for the end of scan and get the raw count */ - while (((ptrCommonCfg->ptrMscChConfig[chIndex].ptrMscBase->INTR & MSC_INTR_MASK_SCAN_Msk) == 0u) && + while (((ptrCommonCfg->ptrChConfig[chIndex].ptrHwBase->INTR & MSC_INTR_MASK_SCAN_Msk) == 0u) && (0u != watchdogPeriod)) { watchdogPeriod--; } if (0u != watchdogPeriod) { - rawCountTmp = ptrCommonCfg->ptrMscChConfig[chIndex].ptrMscBase->RESULT_FIFO_RD; - result = CY_CAPSENSE_BIST_SUCCESS_E; + rawCountTmp = ptrCommonCfg->ptrChConfig[chIndex].ptrHwBase->RESULT_FIFO_RD; + /* Check for an overflow or bad conversions */ + if (0u == (rawCountTmp & MSC_RESULT_FIFO_RD_OVERFLOW_Msk)) + { + rawCountTmp &= MSC_RESULT_FIFO_RD_RAW_COUNT_Msk; + result = CY_CAPSENSE_BIST_SUCCESS_E; + } + else + { + result = CY_CAPSENSE_BIST_ERROR_E; + } } /* Clear all pending interrupts of the current MSC HW block */ - ptrCommonCfg->ptrMscChConfig[chIndex].ptrMscBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; - (void)ptrCommonCfg->ptrMscChConfig[chIndex].ptrMscBase->INTR; + ptrCommonCfg->ptrChConfig[chIndex].ptrHwBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; + (void)ptrCommonCfg->ptrChConfig[chIndex].ptrHwBase->INTR; /* Check for timeout and if no, then calculate capacitance and store the value to the data structure */ - if (CY_CAPSENSE_BIST_TIMEOUT_E != result) + if (CY_CAPSENSE_BIST_SUCCESS_E == result) { if (CY_CAPSENSE_BIST_CAP_SHIELD_SCAN != context->ptrBistContext->eltdCapScanMode) { @@ -2660,7 +2703,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSlot( } } - return (result); + return result; } #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) || \ ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) && \ @@ -2680,7 +2723,7 @@ static cy_en_capsense_bist_status_t Cy_CapSense_BistMeasureCapacitanceSlot( * * \return * Returns a status of the starting execution: -* - CY_CAPSENSE_BIST_HW_BUSY_E - The CSD HW block is successfully started +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is successfully started * and is busy with scanning. * - CY_CAPSENSE_BIST_TIMEOUT_E - The pre-charge of the integration capacitor * reached a timeout. @@ -2699,13 +2742,13 @@ static void Cy_CapSense_BistMeasureCapacitanceSensorRun( for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) { Cy_CapSense_SsConfigPinRegisters( - context->ptrCommonConfig->ptrMscChConfig[chIndex].portCmod1, - (uint32_t)context->ptrCommonConfig->ptrMscChConfig[chIndex].pinCmod1, + context->ptrCommonConfig->ptrChConfig[chIndex].portCmod1, + (uint32_t)context->ptrCommonConfig->ptrChConfig[chIndex].pinCmod1, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXA); Cy_CapSense_SsConfigPinRegisters( - context->ptrCommonConfig->ptrMscChConfig[chIndex].portCmod2, - (uint32_t)context->ptrCommonConfig->ptrMscChConfig[chIndex].pinCmod2, + context->ptrCommonConfig->ptrChConfig[chIndex].portCmod2, + (uint32_t)context->ptrCommonConfig->ptrChConfig[chIndex].pinCmod2, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXA); } #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) */ @@ -2714,13 +2757,13 @@ static void Cy_CapSense_BistMeasureCapacitanceSensorRun( for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) { /* Get the pointer to the MSC channel base register */ - ptrMscHwBase = ptrCommonCfg->ptrMscChConfig[chIndex].ptrMscBase; + ptrMscHwBase = ptrCommonCfg->ptrChConfig[chIndex].ptrHwBase; ptrMscHwBase->FRAME_CMD = MSC_FRAME_CMD_START_FRAME_Msk; } for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) { /* Get the pointer to the MSC channel base register */ - ptrMscHwBase = ptrCommonCfg->ptrMscChConfig[chIndex].ptrMscBase; + ptrMscHwBase = ptrCommonCfg->ptrChConfig[chIndex].ptrHwBase; /* Clear the sensor configuration structure */ (void)memset(&sensorFrame[0u], 0, sizeof(cy_stc_msc_sensor_config_t)); /* Get the sensor frame configuration and write it to the MSC HW block to start scan */ @@ -2753,17 +2796,17 @@ static void Cy_CapSense_BistGenerateBaseConfig( cy_stc_capsense_context_t * context) { uint32_t i; - MSC_Type * ptrBaseCfg = context->ptrCommonConfig->ptrMscChConfig[chIndex].ptrMscBase; + MSC_Type * ptrBaseCfg = context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase; MSC_MODE_Type * ptrBaseCfgMode; - const cy_stc_msc_channel_config_t * ptrMscChConfig = &context->ptrCommonConfig->ptrMscChConfig[chIndex]; + const cy_stc_capsense_channel_config_t * ptrChConfig = &context->ptrCommonConfig->ptrChConfig[chIndex]; #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) uint32_t cswFuncMode = 0uL; const cy_stc_capsense_pin_config_t * ptrPinCfg = context->ptrPinConfig; #endif - if((CY_CAPSENSE_MSC0_CMOD1PADD_PIN != ptrMscChConfig->pinCmod1) && - (CY_CAPSENSE_MSC1_CMOD1PADD_PIN != ptrMscChConfig->pinCmod1)) + if ((CY_CAPSENSE_MSC0_CMOD1PADD_PIN != ptrChConfig->pinCmod1) && + (CY_CAPSENSE_MSC1_CMOD1PADD_PIN != ptrChConfig->pinCmod1)) { ptrBaseCfg->SW_SEL_CMOD1 = 0u; ptrBaseCfg->SW_SEL_CMOD2 = 0u; @@ -2818,8 +2861,8 @@ static void Cy_CapSense_BistGenerateBaseConfig( ptrBaseCfg->MODE[i].SW_SEL_SH &= (~MSC_MODE_SW_SEL_SH_C1SHG_Msk); ptrBaseCfg->MODE[i].SW_SEL_SH &= (~MSC_MODE_SW_SEL_SH_C3SHG_Msk); - if((CY_CAPSENSE_MSC0_CMOD1PADD_PIN == ptrMscChConfig->pinCmod1) || - (CY_CAPSENSE_MSC1_CMOD1PADD_PIN == ptrMscChConfig->pinCmod1)) + if ((CY_CAPSENSE_MSC0_CMOD1PADD_PIN == ptrChConfig->pinCmod1) || + (CY_CAPSENSE_MSC1_CMOD1PADD_PIN == ptrChConfig->pinCmod1)) { ptrBaseCfg->MODE[i].SW_SEL_COMP |= MSC_MODE_SW_SEL_COMP_CPCS1_Msk; ptrBaseCfg->MODE[i].SW_SEL_COMP |= MSC_MODE_SW_SEL_COMP_CMCS2_Msk; @@ -2847,7 +2890,7 @@ static void Cy_CapSense_BistGenerateBaseConfig( } #endif - if(CY_CAPSENSE_BIST_IO_SHIELD_E == context->ptrBistContext->currentISC) + if (CY_CAPSENSE_BIST_IO_SHIELD_E == context->ptrBistContext->currentISC) { ptrBaseCfgMode = &ptrBaseCfg->MODE[0u]; ptrBaseCfgMode->SENSE_DUTY_CTL &= ~(MSC_MODE_SENSE_DUTY_CTL_PHASE_GAP_FS2_PH0_EN_Msk | @@ -2883,6 +2926,7 @@ static void Cy_CapSense_BistGenerateBaseConfig( (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ /* For CSX mode (#1u) swSelTop values should be generated */ ptrBaseCfgMode = &ptrBaseCfg->MODE[1u]; + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) ptrBaseCfgMode->SW_SEL_TOP = CY_CAPSENSE_CSX_FW_AMUX_MODE_SW_SEL_TOP_VALUE; #else /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) */ @@ -2939,8 +2983,8 @@ static void Cy_CapSense_BistGenerateBaseConfig( ptrBaseCfg->SCAN_CTL2 |= (uint32_t)(1uL << MSC_SCAN_CTL2_NUM_EPI_CYCLES_Pos); } /* Generating the common configuration for the coarse initialization and coarse short phase */ - if((CY_CAPSENSE_MSC0_CMOD1PADD_PIN == ptrMscChConfig->pinCmod1) || - (CY_CAPSENSE_MSC1_CMOD1PADD_PIN == ptrMscChConfig->pinCmod1)) + if ((CY_CAPSENSE_MSC0_CMOD1PADD_PIN == ptrChConfig->pinCmod1) || + (CY_CAPSENSE_MSC1_CMOD1PADD_PIN == ptrChConfig->pinCmod1)) { ptrBaseCfg->INIT_CTL1 |= (uint32_t)context->ptrBistContext->eltdCapNumCoarseInitChargeCycles << MSC_INIT_CTL1_NUM_INIT_CMOD_12_RAIL_CYCLES_Pos; @@ -3004,11 +3048,21 @@ static void Cy_CapSense_BistGenerateSensorConfig( uint32_t i; const cy_stc_capsense_electrode_config_t * ptrEltdCfg; uint32_t padMask = 0u; + uint32_t mode = 0u; uint32_t cswFuncNum; - uint32_t slotStcWdgtIdx = context->ptrScanSlots[context->ptrBistContext->curBistSlotId + - ((chIndex + context->ptrCommonConfig->channelOffset) * CY_CAPSENSE_SLOT_COUNT)].wdId; + uint32_t slotStcWdgtIdx; + if (CY_CAPSENSE_BIST_CAP_SLOT_SCAN == context->ptrBistContext->eltdCapScanMode) + { + slotStcWdgtIdx= (uint32_t)context->ptrScanSlots[context->ptrBistContext->curBistSlotId + + ((chIndex + context->ptrCommonConfig->channelOffset) * + CY_CAPSENSE_SLOT_COUNT)].wdId; + } + else + { + slotStcWdgtIdx = (uint32_t)context->ptrBistContext->curBistWdId; + } #else - (void) chIndex; + (void)chIndex; #endif /* Set the synchronization mode */ @@ -3041,6 +3095,10 @@ static void Cy_CapSense_BistGenerateSensorConfig( (CY_CAPSENSE_CSX_GROUP == context->ptrActiveScanSns[0u].currentSenseMethod)) { ptrSensorCfg[CY_CAPSENSE_SNS_CTL_INDEX] |= (1u << MSC_SNS_CTL_SENSE_MODE_SEL_Pos); + + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) + mode = 1u; + #endif } /* * CapDAC configuration: CapDAC dithering is off for BIST, @@ -3056,7 +3114,7 @@ static void Cy_CapSense_BistGenerateSensorConfig( #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) /* Get mask for all channel pins */ - padMask = context->ptrCommonConfig->ptrMscChConfig[chIndex].ptrMscBase->CSW_CTL; + padMask = context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase->CSW_CTL; /* Change the control switch function depending on the current inactive sensor connection */ cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_GND; if (CY_CAPSENSE_BIST_IO_HIGHZA_E == context->ptrBistContext->currentISC) @@ -3067,6 +3125,14 @@ static void Cy_CapSense_BistGenerateSensorConfig( { cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_SHIELD; } + else if (CY_CAPSENSE_BIST_IO_VDDA2_E == context->ptrBistContext->currentISC) + { + cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_VDDA2; + context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase->MODE[mode].SW_SEL_TOP |= + MSC_MODE_SW_SEL_TOP_RMF_Msk; + context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase->MODE[mode].SW_SEL_SH = + CY_CAPSENSE_FW_CSX_VDDA2_CTLMUX_MODE_SW_SEL_SH_VALUE; + } else { /* Do nothing */ @@ -3089,7 +3155,7 @@ static void Cy_CapSense_BistGenerateSensorConfig( cswFuncNum = CY_CAPSENSE_CTRLMUX_PIN_STATE_SNS; if (CY_CAPSENSE_BIST_IO_SHIELD_E == context->ptrBistContext->currentISC) { - padMask = context->ptrCommonConfig->ptrMscChConfig[chIndex].ptrMscBase->CSW_CTL; + padMask = context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase->CSW_CTL; } else { @@ -3198,7 +3264,7 @@ static void Cy_CapSense_BistGenerateSnsCfgMaskReg( #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) /******************************************************************************* -* Function Name: Cy_CapSense_MeasureCapacitanceShieldElectrode +* Function Name: Cy_CapSense_MeasureCapacitanceShieldElectrode_V3 ****************************************************************************//** * * Measures shield electrode capacitances in femtofarads. @@ -3245,11 +3311,8 @@ static void Cy_CapSense_BistGenerateSnsCfgMaskReg( * This function is available only for the fifth-generation CAPSENSE™. * * \param skipChMask -* Specifies the mask to skip some channels during the shield electrode -* capacitance measurement. If the bit N in the skipChMask is set to 1, -* the channel N will be excluded from measuring and all its shield pins will be -* set to the shield inactive sensor connection state (see the .shieldCapISC -* field of the \ref cy_stc_capsense_bist_context_t structure). +* This argument is kept for uniformity and backward compatibility +* and is not used. The function can be called with value NULL. * * \param context * The pointer to the CAPSENSE™ context @@ -3261,13 +3324,15 @@ static void Cy_CapSense_BistGenerateSnsCfgMaskReg( * successfully, the result is valid. * - CY_CAPSENSE_BIST_BAD_PARAM_E - The input parameter is invalid. * The measurement was not executed. -* - CY_CAPSENSE_BIST_HW_BUSY_E - The CSD HW block is busy with a +* - CY_CAPSENSE_BIST_HW_BUSY_E - The CAPSENSE™ HW block is busy with a * previous operation. * The measurement was not executed. * - CY_CAPSENSE_BIST_BAD_CONFIG_E - The shield is disabled. +* - CY_CAPSENSE_BIST_ERROR_E - An unexpected fault occurred during +* the measurement. * *******************************************************************************/ -cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode( +cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode_V3( uint32_t skipChMask, cy_stc_capsense_context_t * context) { @@ -3278,7 +3343,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode( const cy_stc_capsense_pin_config_t * ptrPinCfg; #endif - if(NULL != context) + if (NULL != context) { #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_SHIELD_EN)) @@ -3377,7 +3442,7 @@ cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode( (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN)) */ } - return (result); + return result; } #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) */ @@ -3410,10 +3475,10 @@ static void Cy_CapSense_BistConnectEltd( const cy_stc_capsense_pin_config_t * ptrActivePin = ptrEltdConfig->ptrPin; uint32_t i; - if((context->ptrBistContext->curBistChId + context->ptrCommonConfig->channelOffset) == ptrEltdConfig->chId) + if ((context->ptrBistContext->curBistChId + context->ptrCommonConfig->channelOffset) == ptrEltdConfig->chId) { /* Connect all pins of current sensors */ - for(i = 0u; i < ptrEltdConfig->numPins; i++) + for (i = 0u; i < ptrEltdConfig->numPins; i++) { Cy_CapSense_SsConfigPinRegisters(ptrActivePin->pcPtr, (uint32_t)ptrActivePin->pinNumber, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_CSD_SENSE); @@ -3453,7 +3518,7 @@ static void Cy_CapSense_BistDisconnectEltd( uint32_t desiredDriveMode = CY_CAPSENSE_DM_GPIO_ANALOG; en_hsiom_sel_t desiredHsiom = CY_CAPSENSE_HSIOM_SEL_GPIO; - if((context->ptrBistContext->curBistChId + context->ptrCommonConfig->channelOffset) == ptrEltdConfig->chId) + if ((context->ptrBistContext->curBistChId + context->ptrCommonConfig->channelOffset) == ptrEltdConfig->chId) { /* Change Drive mode and HSIOM depending on the current inactive sensor connection */ if (CY_CAPSENSE_BIST_IO_STRONG_E == desiredPinState) @@ -3475,7 +3540,7 @@ static void Cy_CapSense_BistDisconnectEltd( /* Do nothing */ } /* Disconnect all pins of the current sensor */ - for(i = 0u; i < ptrEltdConfig->numPins; i++) + for (i = 0u; i < ptrEltdConfig->numPins; i++) { Cy_CapSense_SsConfigPinRegisters(ptrActivePin->pcPtr, (uint32_t)ptrActivePin->pinNumber, desiredDriveMode, desiredHsiom); @@ -3540,17 +3605,16 @@ void Cy_CapSense_BistInitialize(cy_stc_capsense_context_t * context) *******************************************************************************/ void Cy_CapSense_BistDsInitialize_V3(cy_stc_capsense_context_t * context) { - uint32_t wdIndex; - uint32_t wdNum = (uint32_t)context->ptrCommonConfig->numWd; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) + uint32_t wdIndex; + uint32_t wdNum = (uint32_t)context->ptrCommonConfig->numWd; - /* Initialize CRC and status for all widgets */ - for (wdIndex = 0u; wdIndex < wdNum; wdIndex++) - { - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) + /* Initialize CRC for all widgets */ + for (wdIndex = 0u; wdIndex < wdNum; wdIndex++) + { Cy_CapSense_UpdateCrcWidget(wdIndex, context); - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) */ - context->ptrWdContext[wdIndex].status |= (uint8_t)CY_CAPSENSE_WD_WORKING_MASK; - } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) */ #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) Cy_CapSense_BistMeasureCapacitanceSensorInit(context); @@ -3642,15 +3706,15 @@ static void Cy_CapSense_BistSwitchHwConfig( context->ptrBistContext->eltdCapSenseGroup = bistSenseGroup; context->ptrBistContext->eltdCapScanMode = bistScanMode; /* Enable the specified mode */ - switch(hwCfg) + switch (hwCfg) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_SHORT_EN) case CY_CAPSENSE_BIST_HW_SHORT_E: { /* Configure all the MSC channels to perform pin integrity tests */ - for(curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) + for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - context->ptrCommonConfig->ptrMscChConfig[curChIndex].ptrMscBase->CSW_CTL = 0x00u; + context->ptrCommonConfig->ptrChConfig[curChIndex].ptrHwBase->CSW_CTL = 0x00u; } break; } @@ -3978,7 +4042,7 @@ static uint32_t Cy_CapSense_BistWatchdogPeriodCalc( uint32_t watchdogPeriod; modClkDivider = context->ptrBistContext->eltdCapModClk; - if(0u == modClkDivider) + if (0u == modClkDivider) { modClkDivider = 1u; } @@ -3987,7 +4051,7 @@ static uint32_t Cy_CapSense_BistWatchdogPeriodCalc( ((uint64_t)context->ptrBistContext->eltdCapSubConvNum); isBusyWatchdogTimeUs *= (uint64_t)modClkDivider * CY_CAPSENSE_CONVERSION_MEGA; isBusyWatchdogTimeUs /= context->ptrCommonConfig->periClkHz; - if(0u == isBusyWatchdogTimeUs) + if (0u == isBusyWatchdogTimeUs) { isBusyWatchdogTimeUs = 1u; } @@ -3995,7 +4059,7 @@ static uint32_t Cy_CapSense_BistWatchdogPeriodCalc( watchdogPeriod = Cy_CapSense_WatchdogCyclesNum((uint32_t)isBusyWatchdogTimeUs, context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA, CY_CAPSENSE_BIST_CAP_MEAS_WDT_CYCLES_PER_LOOP); - return (watchdogPeriod); + return watchdogPeriod; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) */ diff --git a/cy_capsense_selftest_v3.h b/cy_capsense_selftest_v3.h index c1b7611..45d8ba8 100644 --- a/cy_capsense_selftest_v3.h +++ b/cy_capsense_selftest_v3.h @@ -1,6 +1,6 @@ /***************************************************************************//** -* \file cy_capsense_selftest.h -* \version 3.0.1 +* \file cy_capsense_selftest_v3.h +* \version 4.0 * * \brief * This file provides the function prototypes of the BIST module. @@ -37,33 +37,6 @@ extern "C" { *******************************************************************************/ -/******************************************************************************/ -/** \addtogroup group_capsense_low_level *//** \{ */ -/******************************************************************************/ - -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) - cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode( - uint32_t widgetId, - uint32_t eltdId, - cy_stc_capsense_context_t * context); -#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ - -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) - cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors( - uint32_t slotId, - uint32_t skipChMask, - cy_stc_capsense_context_t * context); -#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ - -#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) - cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode( - uint32_t skipChMask, - cy_stc_capsense_context_t * context); -#endif - -/** \} */ - /******************************************************************************/ /** \cond SECTION_CAPSENSE_INTERNAL */ /** \addtogroup group_capsense_internal *//** \{ */ @@ -127,6 +100,26 @@ void Cy_CapSense_BistDsInitialize_V3( cy_stc_capsense_context_t * context); #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN) */ +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSensorElectrode_V3( + uint32_t widgetId, + uint32_t eltdId, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_ELTD_CAP_EN) */ + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceSlotSensors_V3( + uint32_t slotId, + uint32_t skipChMask, + cy_stc_capsense_context_t * context); +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SNS_CAP_EN) */ + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_SH_CAP_EN)) + cy_en_capsense_bist_status_t Cy_CapSense_MeasureCapacitanceShieldElectrode_V3( + uint32_t skipChMask, + cy_stc_capsense_context_t * context); +#endif /** \} \endcond */ diff --git a/cy_capsense_sensing.c b/cy_capsense_sensing.c index b920421..e40807b 100644 --- a/cy_capsense_sensing.c +++ b/cy_capsense_sensing.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_sensing.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file consists of common parts for different supported platforms @@ -22,21 +22,31 @@ #include "cy_gpio.h" #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) #include "cy_capsense_sensing_v2.h" +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_capsense_sensing_lp.h" + #include "cy_capsense_generator_lp.h" #else /* (CY_CAPSENSE_PSOC4_FIFTH_GEN) */ #include "cy_capsense_sensing_v3.h" #include "cy_capsense_generator_v3.h" #endif -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) /******************************************************************************* * Function Name: Cy_CapSense_ScanWidget ****************************************************************************//** * -* Initiates the scanning of all sensors in the widget. Scanning is -* initiated only if no scan is in progress. Scan finishing can be -* checked by the Cy_CapSense_IsBusy() function. +* Initiates the scanning of all sensors in the widget. + +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* +* For fifth-generation low power CAPSENSE™ the function initiates only +* Active widget scans. To initiate Low Power widget scan use +* the Cy_CapSense_ScanLpWidget() function. * * \note * For the fifth-generation CAPSENSE™ this function is available in @@ -61,6 +71,8 @@ cy_capsense_status_t Cy_CapSense_ScanWidget( { #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) return Cy_CapSense_ScanWidget_V3(widgetId, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + return Cy_CapSense_ScanWidget_V3Lp(widgetId, context); #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ return Cy_CapSense_ScanWidget_V2(widgetId, context); #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ @@ -70,9 +82,12 @@ cy_capsense_status_t Cy_CapSense_ScanWidget( * Function Name: Cy_CapSense_ScanSensor ****************************************************************************//** * -* Initiates the scanning of the selected sensor in the widget. Scanning is -* initiated only if no scan is in progress. Scan finishing can be -* checked by the Cy_CapSense_IsBusy() function. +* Initiates the scanning of the selected sensor in the widget. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. * * \note * For the fifth-generation CAPSENSE™ this function is available in @@ -103,33 +118,270 @@ cy_capsense_status_t Cy_CapSense_ScanSensor( { #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) return Cy_CapSense_ScanSensor_V3(widgetId, sensorId, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + return Cy_CapSense_ScanSensor_V3Lp(widgetId, sensorId, context); #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ return Cy_CapSense_ScanSensor_V2(widgetId, sensorId, context); #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ } +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)|| (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) +/******************************************************************************* +* Function Name: Cy_CapSense_ScanAllSlots +****************************************************************************//** +* +* Initiates the non-blocking scan of all Active slots and then exits. Scanning +* is initiated only if no scan is in progress. To initiate all Low Power slot +* scan use the Cy_CapSense_ScanAllLpSlots() function. +* +* \par +* * For fifth-generation low power CAPSENSE™ +* This function loads slots configurations into the internal buffer of the +* CAPSENSE™ hardware block and triggers scanning. +* If the scan frame doesn`t fit into the internal buffer it will be processed as +* the sequence of sub-frames. Next sub-frame will be loaded by the interrupt +* service routine(part of middleware) once scan of previous sub-frame is complete. +* The scanning process duration consists of a some +* pre-configured interval and a frame scan duration. The first slot scan starts +* after the pre-configured interval. The default duration of the interval is +* 1 ILO cycle. The interval duration can be changed +* by the Cy_CapSense_ConfigureMsclpTimer() function. +* If the "Enable external frame start" option is disabled in the CAPSENSE™ +* Configurator, the scanning process will be triggered immediately. +* If the "Enable external frame start" option is enabled in the CAPSENSE™ +* Configurator, the scanning process will be triggered by the first external +* synchronization signal after call of the function. +* The number of slots in frame in this case should not exceed the maximum +* possible slot number to fit into the internal buffer of the CAPSENSE™ +* hardware block. +* The External synchronization signal parameters should meet the following +* constraints: +* * - the interval between the return of the function and the rising edge +* of an external synchronization signal must not be less than 2 ILO cycles; +* * - the pulse duration of an external synchronization signal +* (i.e. signal is in High level) must not be less than 2 ILO cycles and more +* than the full scanning process duration. The full scanning process +* duration is the time between the rising edge of the external +* synchronization pulse and clearing of BUSY flag. The Cy_CapSense_IsBusy() +* function can be used to check BUSY flag; +* * - the interval between sub-sequent pulses should not be less than full +* scanning process duration. +* Disregarding the "Enable external frame start" option, the transition into +* system DEEP SLEEP mode is allowed after the scan process is started +* by the function. +* To decrease the start scan time when it is intended to scan the same frame, +* i.e. startSlotId and numberSlots parameters are the same, then the scan +* is performed without the MSC HW block reconfiguration. +* The number of slots in frame in this case should not exceed the maximum +* possible slot number to fit into the internal buffer of the CAPSENSE™ +* hardware block. +* +* \par +* * For fifth-generation CAPSENSE™ this function initiates a scan for +* the first slot for all channels and then exits. Scans for the remaining slots +* in the Interrupt-driven scan mode are initiated in the interrupt service +* routine (part of middleware) triggered at the end +* of each scan completion for each channel. If the syncMode field in the +* cy_stc_capsense_common_config_t structure is set to CY_CAPSENSE_SYNC_MODE_OFF, +* then the next slot scan for the channel with the fired interrupt, +* will start regardless of the another channel readiness for the next scan. +* If the syncMode field is set to CY_CAPSENSE_SYNC_INTERNAL (for single-chip projects) +* or to CY_CAPSENSE_SYNC_EXTERNAL (for multi-chip projects), +* then the next slot scan for the channel with the fired interrupt, +* will start in lockstep with another channels after they all are ready +* for the next scan (the next scan configuration is loaded into the channel MSC HW block). +* Scans for the remaining slots in CS-DMA scan mode are initiated +* by DMAC triggered at the end +* of each scan completion for each channel. The channel scan synchronization is +* performed as in Interrupt-driven scan mode. After all slots are scanned, +* the FRAME interrupt is fired and the interrupt service routine (part of middleware) +* updates the busy status. The transition into system DEEP SLEEP mode is allowed +* only when all scans are finished. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* +* \note +* This function is available for the fifth-generation and fifth-generation low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The HW is busy with the previous scan. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanAllSlots( + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + + if (NULL != context) + { + capStatus = Cy_CapSense_ScanSlots(0u, CY_CAPSENSE_SLOT_COUNT, context); + } + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanSlots +****************************************************************************//** +* +* Initiates the non-blocking scan of a specified regular slots set named "frame" +* and then exits. +* Scanning is initiated only if no scan is in progress. +* Check the status of the current scan using the Cy_CapSense_IsBusy() +* function. The application program should wait until the current frame scan is +* finished prior to start a next scan by using the function. +* +* \par +* * For fifth-generation low power CAPSENSE™ +* The function loads the frame configuration into the internal buffer of the +* CAPSENSE™ hardware block and triggers the scanning process. +* If the frame configuration does not fit into the internal buffer its scan will +* be processed as a sequence of sub-frame scans. A next sub-frame will be loaded +* by the interrupt service routine (part of the middleware) +* after the previous sub-frame scan is complete. +* The scanning process duration consists of a some +* pre-configured interval and a frame scan duration. The first slot scan starts +* after the pre-configured interval. The default duration of the interval is +* 1 ILO cycle. The interval duration can be changed +* by the Cy_CapSense_ConfigureMsclpTimer() function. +* If the "Enable external frame start" option is disabled in the CAPSENSE™ +* Configurator, the scanning process will be triggered immediately. +* If the "Enable external frame start" option is enabled in the CAPSENSE™ +* Configurator, the scanning process will be triggered by the first external +* synchronization signal after call of the function. +* The number of slots in frame in this case should not exceed the maximum +* possible slot number to fit into the internal buffer of the CAPSENSE™ +* hardware block. +* The External synchronization signal parameters should meet the following +* constraints: +* * - the interval between the return of the function and the rising edge +* of an external synchronization signal must not be less than 2 ILO cycles; +* * - the pulse duration of an external synchronization signal +* (i.e. signal is in High level) must not be less than 2 ILO cycles and more +* than the full scanning process duration. The full scanning process +* duration is the time between the rising edge of the external +* synchronization pulse and clearing of BUSY flag. The Cy_CapSense_IsBusy() +* function can be used to check BUSY flag; +* * - the interval between sub-sequent pulses should not be less than full +* scanning process duration. +* Disregarding the "Enable external frame start" option, the transition into +* system DEEP SLEEP mode is allowed after the scan process is started +* by the function. +* To decrease the start scan time when it is intended to scan the same frame, +* i.e. startSlotId and numberSlots parameters are the same, then the scan +* is performed without the MSC HW block reconfiguration. +* The number of slots in frame in this case should not exceed the maximum +* possible slot number to fit into the internal buffer of the CAPSENSE™ +* hardware block. +* +* \par +* * For fifth-generation CAPSENSE™ this function initiates a scan for +* the first slot for all channels and then exits. Scans for the remaining slots +* in the Interrupt-driven scan mode are initiated in the interrupt service +* routine (part of middleware) triggered at the end +* of each scan completion for each channel. If the syncMode field in the +* cy_stc_capsense_common_config_t structure is set to CY_CAPSENSE_SYNC_MODE_OFF, +* then the next slot scan for the channel with the fired interrupt, +* will start regardless of the another channel readiness for the next scan. +* If the syncMode field is set to CY_CAPSENSE_SYNC_INTERNAL (for single-chip +* projects) or to CY_CAPSENSE_SYNC_EXTERNAL (for multi-chip projects), +* then the next slot scan for the channel with the fired interrupt, +* will start in lockstep with another channels after they all are ready +* for the next scan. +* The scan for the remaining slots in CS-DMA scan mode are initiated +* by DMAC triggered at the end +* of each scan completion for each channel. The channel scan synchronization is +* performed as in Interrupt-driven scan mode. After all specified slots are +* scanned, the FRAME interrupt is fired and the interrupt service routine +* (part of middleware) updates the busy status. The transition into system +* DEEP SLEEP mode is allowed only when all specified scans are finished. +* To decrease the start scan time when it is intended to scan the same slot, +* i.e. the startSlotId parameter is the same and numberSlots = 1u, then the scan +* is performed without the MSC HW block reconfiguration. Also, in the legacy +* AMUX mode sensors are not disconnected. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* +* \note +* This function is available for the fifth-generation and fifth-generation +* low power CAPSENSE™. +* +* \param startSlotId +* The slot ID the scan of the specified frame will be started from. +* +* \param numberSlots +* The number of slots in the specified frame will be scanned. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The HW is busy with the previous scan. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanSlots( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context) +{ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + return Cy_CapSense_ScanSlots_V3(startSlotId, numberSlots, context); + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)*/ + return Cy_CapSense_ScanSlots_V3Lp(startSlotId, numberSlots, context); + #endif +} +#endif + + /******************************************************************************* * Function Name: Cy_CapSense_ScanAllWidgets ****************************************************************************//** * * Initiates scanning of all enabled widgets (and sensors) in the project. -* Scanning is initiated only if no scan is in progress. +* For fifth-generation low power CAPSENSE™ the function initiates only +* Active widget scans. To initiate Low Power widget scan use +* the Cy_CapSense_ScanAllLpWidgets() function. * * This function initiates a scan only for the first sensor in the first widget * for the fourth-generation CAPSENSE™ or a scan for the first slot -* for the fifth-generation CAPSENSE™ and then exits the function. The scan +* for the fifth-generation CAPSENSE™ and fifth-generation low power +* CAPSENSE™ and then exits the function. The scan * for the remaining sensors(slots) are initiated in the interrupt-driven mode * in the interrupt service routine (part of middleware) triggered at the end -* of each scan completion or by DMA controllers in the DMA mode. The status -* of the current scan should be checked by using the Cy_CapSense_IsBusy() and wait -* until all scans is finished prior to starting a next scan or initializing -* another widget. +* of each scan completion or by DMA controllers in the DMA mode for +* the fifth-generation CAPSENSE™. For the fifth-generation low power +* CAPSENSE™ the remaining sensor scans depend on the ACTIVE sensor +* quantity, for details see the Cy_CapSense_ScanAllSlots() function description. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* The application program should wait until the current frame scan is finished prior +* to start a next scan by using the function. * * \note -* For the fifth-generation CAPSENSE™ it is recommended to use -* the Cy_CapSense_ScanAllSlots() function instead for compatibility with -* further CAPSENSE™ middleware versions. +* For the fifth-generation CAPSENSE™ and fifth-generation low power +* CAPSENSE™ it is recommended to use the Cy_CapSense_ScanAllSlots() +* function instead for compatibility with further CAPSENSE™ +* middleware versions. * * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. @@ -143,28 +395,101 @@ cy_capsense_status_t Cy_CapSense_ScanAllWidgets( { #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) return Cy_CapSense_ScanAllWidgets_V3(context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + return Cy_CapSense_ScanAllWidgets_V3Lp(context); #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ return Cy_CapSense_ScanAllWidgets_V2(context); #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ } +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)|| (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) /******************************************************************************* -* Function Name: Cy_CapSense_IsBusy +* Function Name: Cy_CapSense_MwState ****************************************************************************//** * -* This function returns a status of the CAPSENSE™ middleware whether a scan is -* currently in progress or not. +* Returns a detailed state of the CAPSENSE™ middleware and MSC and +* MSCLP HW blocks in Single- or Multi-channel mode. This feature is useful in +* multi-thread applications or in ISR. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* If the middleware is busy, a new scan, setup widgets, any kind of reconfiguration, +* or parameter change should not be initiated. * -* If the middleware is busy, a new scan or setup widgets should not be initiated. -* -* Use the Cy_CapSense_MwState() function to check a detailed CAPSENSE™ middleware -* state for the fifth-generation CAPSENSE™. +* \note +* This function is available for the fifth-generation and fifth-generation +* low power CAPSENSE™. * * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * * \return +* Returns the state of the middleware as a sum of the state and status masks: +* +* - CY_CAPSENSE_BUSY_CH_MASK - The set [x] bit of the result +* means that the previously initiated +* scan for the [x] channel is in progress. +* The next scan frame cannot be started. +* - CY_CAPSENSE_MW_STATE_ACTIVE_WD_SCAN_MASK - The last or currently scanned widget +* type is Active widget. +* \note This field is available only +* for the fifth-generation low power +* CAPSENSE™. +* - CY_CAPSENSE_MW_STATE_LP_WD_SCAN_MASK - The last or currently scanned widget +* type is Low Power widget. +* \note This field is available only +* for the fifth-generation low power +* CAPSENSE™. +* - CY_CAPSENSE_BUSY - The previously initiated scan is +* in progress. +* - CY_CAPSENSE_MW_STATE_BIST_MASK - The BIST is in progress. +* The next scan frame cannot be started. +* - CY_CAPSENSE_MW_STATE_CALIBRATION_MASK - The auto-calibration is in progress. +* The next scan frame cannot be started. +* - CY_CAPSENSE_MW_STATE_SMARTSENSE_MASK - The smart sensing algorithm is +* in progress. +* The next scan frame cannot be started. +* - CY_CAPSENSE_MW_STATE_INITIALIZATION_MASK - Middleware initialization is +* in progress and the next scan frame +* cannot be initiated. +* - CY_CAPSENSE_MW_STATE_SCAN_SLOT_MASK[x] - The set [x] number of the result +* means that the previously initiated +* scan for the [x] slot is completed +* or in progress. In CS-DMA mode, this +* field is set only for the first +* scanned slot. +* +*******************************************************************************/ +cy_capsense_mw_state_t Cy_CapSense_MwState(const cy_stc_capsense_context_t * context) +{ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + return Cy_CapSense_MwState_V3(context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + return Cy_CapSense_MwState_V3Lp(context); + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ +} +#endif /* ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)|| (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_IsBusy +****************************************************************************//** +* +* This function returns a status whether MW executes HW scanning at a particular moment. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* If the middleware is busy, a new scan, setup widgets, any kind of reconfiguration, +* or parameter change should not be initiated. +* +* \param context +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. +* +* \return * Returns the status of the middleware as a sum of the masks. * - CY_CAPSENSE_NOT_BUSY - No scan is in progress and * a next scan can be initiated. @@ -175,11 +500,7 @@ cy_capsense_status_t Cy_CapSense_ScanAllWidgets( uint32_t Cy_CapSense_IsBusy( const cy_stc_capsense_context_t * context) { - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - return Cy_CapSense_IsBusy_V3(context); - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ - return Cy_CapSense_IsBusy_V2(context); - #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + return (context->ptrCommonContext->status & CY_CAPSENSE_BUSY); } @@ -187,30 +508,28 @@ uint32_t Cy_CapSense_IsBusy( * Function Name: Cy_CapSense_InterruptHandler ****************************************************************************//** * -* Implements interrupt service routine for CAPSENSE™ Middleware. +* Implements interrupt service routine for CAPSENSE™ middleware. * -* The MSC HW block generates an interrupt at end of every sensor scan. * The CAPSENSE™ middleware uses this interrupt to implement a * non-blocking sensor scan method, in which only the first sensor scan is -* initiated by the application program and subsequent sensor scans are +* initiated by the application program. Subsequent sensor scans are * initiated in the interrupt service routine as soon as the current scan -* is completed. The above stated interrupt service routine is implemented -* as a part of the CAPSENSE™ middleware. +* or current sub-frame is completed. * * The CAPSENSE™ middleware does not initialize or modify the priority -* of interrupts. For the operation of middleware, the application program -* must configure MSC interrupt and assign interrupt vector to -* the Cy_CapSense_InterruptHandler() function. Refer to function +* of interrupts. For the proper middleware operation, the application program +* must configure CAPSENSE™ block interrupt and assign the interrupt +* vector to the Cy_CapSense_InterruptHandler() function. Refer to function * usage example for details. * * The calls of the Start Sample and End Of Scan callbacks -* (see the \ref group_capsense_callbacks section for details) are the part of the -* Cy_CapSense_InterruptHandler() routine and they lengthen its execution. These -* callbacks will lengthen the ISR execution in case of a direct call of the -* Cy_CapSense_InterruptHandler() function from a ISR. +* (see the \ref group_capsense_callbacks section for details) are the part +* of the Cy_CapSense_InterruptHandler() routine and they lengthen its execution. +* These callbacks should not lengthen the ISR execution too much to prevent +* different interrupt overlaps. * * \param base -* The pointer to the base register address of the CSD HW block. +* The pointer to the base register address of the CAPSENSE™ HW block. * This argument is kept for uniformity and backward compatibility * and is not used. The function can be called with value NULL. * @@ -225,6 +544,9 @@ uint32_t Cy_CapSense_IsBusy( * program according to the examples below:
* For Core CM0+: * \snippet capsense/snippet/main.c snippet_m0p_capsense_interrupt_source_declaration +* \note MSCLP HW contains two interrupt sources. +* The CAPSENSE™ Middleware supports only the msclp_interrupt_lp_IRQn +* vector and therefore it should be used. * * For Core CM4: * \snippet capsense/snippet/main.c snippet_m4_capsense_interrupt_source_declaration @@ -237,12 +559,16 @@ uint32_t Cy_CapSense_IsBusy( * between calls of the Cy_CapSense_Init() and Cy_CapSense_Enable() functions: * \snippet capsense/snippet/main.c snippet_Cy_CapSense_Initialization * -* CapSense_HW is the pointer to the base register address of -* the CSD HW block. A macro for the pointer can be found in the cycfg_peripherals.h -* file defined as \_HW. If no name specified, -* the default name is used csd_\_csd_\_HW. +* The CapSense_HW is the pointer to the base register address of +* the CAPSENSE™ HW block. A macro for the pointer is in the cycfg_peripherals.h +* file defined as \_HW. If no name is specified, +* the following default names are used: +* * csd_\_csd_\_HW - for forth-generation CAPSENSE™ HW. +* * msc_\_msc_\_HW - for fifth-generation CAPSENSE™ HW. +* * msclp_\_msclp_\_HW - for fifth-generation low power CAPSENSE™ HW. * -* An example of sharing the CSD HW block by the CAPSENSE™ and CSDADC middleware.
+* An example of sharing the CSD HW block (fourth-generation CAPSENSE™) by the CAPSENSE™ +* middleware and CSDADC middleware.
* Declares the CapSense_ISR_cfg variable: * \snippet capsense/snippet/main.c snippet_m4_capsense_interrupt_source_declaration * @@ -250,7 +576,7 @@ uint32_t Cy_CapSense_IsBusy( * \snippet capsense/snippet/main.c snippet_m4_adc_interrupt_source_declaration * * Defines the CAPSENSE™ interrupt handler: -* \snippet capsense/snippet/main.c snippet_CapSense_Interrupt +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_IntHandler * * Defines the CSDADC interrupt handler: * \snippet capsense/snippet/main.c snippet_CSDADC_Interrupt @@ -266,6 +592,8 @@ void Cy_CapSense_InterruptHandler( (void)base; #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) Cy_CapSense_InterruptHandler_V3(NULL, context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + Cy_CapSense_InterruptHandler_V3Lp(NULL, context); #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ Cy_CapSense_InterruptHandler_V2(NULL, context); #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ @@ -276,17 +604,46 @@ void Cy_CapSense_InterruptHandler( * Function Name: Cy_CapSense_CalibrateAllWidgets ****************************************************************************//** * -* Executes the CapDAC/IDAC calibration for all the sensors in all widgets in -* the middleware to default target value. +* Executes CapDAC/IDAC auto-calibration for all the sensors in all widgets +* of some sensing groups (CSD, CSX, or ISX) if calibration is enabled +* for such group of widgets. The auto-calibration finds CapDAC/IDAC values +* to have raw counts close to configured target values. Use sensing and +* processing functions after auto-calibration to update all baselines and +* configured filters. +* +* Having enabled the CDAC auto-calibration algorithm is the most common use +* case. It helps to tune your system considering board-to-board variation, +* temperature drift, etc. CDAC auto-calibration is enabled by default. +* +* The default auto-calibration target values are defined as: +* * 85% of the maximum raw count for CSD widgets +* * 40% of the maximum raw count for CSX widgets. +* * 40% of the maximum raw count for ISX widgets. +* Use the Cy_CapSense_SetCalibrationTarget() function to change calibration targets . +* +* For fifth-generation low power CAPSENSE™ the function calibrates only +* Active widgets. For Low Power widgets use +* the Cy_CapSense_CalibrateAllLpWidgets() function. * * This function detects the sensing method used by each widget and performs -* a successive approximation search algorithm to find the appropriate modulator -* and compensation CapDAC/IDAC (if enabled) values for all sensors in CSD widgets +* a successive approximation search algorithm to find the appropriate Reference +* and Compensation CapDAC (if enabled) values for all sensors for +* the fifth-generation CAPSENSE™ and for all Active sensors for +* the fifth-generation low power CAPSENSE™. For the fifth-generation +* low power CAPSENSE™ if during the calibration process it is reached +* the Reference CapDAC value lower than /ref CY_CAPSENSE_CAL_REF_CDAC_MIN_CODE +* and Fine CapDAC usage is enabled in CAPSENSE™ Configurator then +* the FineCDAC calibration is performed with the reference CDAC value set to 0. +* +* For the the forth-generation +* CAPSENSE™ the function finds appropriate modulator and compensation +* IDAC (if enabled) values for all sensors in CSD widgets * and/or IDAC values for all sensors in CSX widgets to make sensor raw count * to the default value level. * * This function could be used only if Enable auto-calibration parameter -* is enabled for CSD and/or CSX widgets. +* is enabled for CSD and/or CSX (and/or ISX for fifth-generation low power +* CAPSENSE™) widgets. * * \note * For the fifth-generation CAPSENSE™ this function is available in @@ -304,20 +661,158 @@ void Cy_CapSense_InterruptHandler( cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets( cy_stc_capsense_context_t * context) { - #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - return Cy_CapSense_CalibrateAllWidgets_V3(context); - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ - return Cy_CapSense_CalibrateAllWidgets_V2(context); - #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + cy_capsense_status_t retVal = CY_CAPSENSE_STATUS_BAD_CONFIG; + + (void)context; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) + retVal = Cy_CapSense_CalibrateAllWidgets_V3(context); + #endif + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) + retVal = Cy_CapSense_CalibrateAllWidgets_V3Lp(context); + #endif + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) + retVal = Cy_CapSense_CalibrateAllWidgets_V2(context); + #endif + #endif + + return retVal; +} + + +#if (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) && \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN))) +/******************************************************************************* +* Function Name: Cy_CapSense_CalibrateAllSlots +****************************************************************************//** +* +* Executes CapDAC/IDAC auto-calibration for all the sensors in all widgets +* of some sensing groups (CSD, CSX, or ISX) if calibration is enabled +* for such group of widgets. The auto-calibration finds CapDAC/IDAC values +* to have raw counts close to configured target values. Use sensing and +* processing functions after auto-calibration to update all baselines and +* configured filters. +* +* Having enabled the CDAC auto-calibration algorithm is the most common use +* case. It helps to tune your system considering board-to-board variation, +* temperature drift, etc. CDAC auto-calibration is enabled by default. +* +* For fifth-generation low power CAPSENSE™ the function calibrates only +* Active widgets. For Low Power widgets use +* the Cy_CapSense_CalibrateAllLpWidgets() function. +* +* The function performs searching of Reference CDAC code, Compensation CDAC +* code Compensation Divider (whichever is enabled) by using a successive +* approximation method to make the sensor's raw count closest to the +* defined targets. The auto-calibration target values are defined +* (by default) as: +* * 85% of the maximum raw count for CSD widgets +* * 40% of the maximum raw count for CSX widgets. +* * 40% of the maximum raw count for ISX widgets. +* Use the Cy_CapSense_SetCalibrationTarget() function to change calibration targets . +* +* For the fifth-generation +* low power CAPSENSE™ if during the calibration process it is reached +* the Reference CapDAC value lower than /ref CY_CAPSENSE_CAL_REF_CDAC_MIN_CODE +* and Fine CapDAC usage is enabled in CAPSENSE™ Configurator then +* the FineCDAC calibration is performed with the reference CDAC value set to 0. +* +* \note +* This function is available for the fifth-generation CAPSENSE™ and +* fifth-generation low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_CALIBRATION_FAIL - The calibration is failed due to +* the issues with scanning (either +* watchdog timer, interrupt breaking, etc.). +* - CY_CAPSENSE_STATUS_CALIBRATION_CHECK_FAIL - The calibration is failed +* because of rawcount is out of the +* defined range. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_CalibrateAllSlots(cy_stc_capsense_context_t * context) +{ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + return Cy_CapSense_CalibrateAllSlots_V3(context); + #else + return Cy_CapSense_CalibrateAllSlots_V3Lp(context); + #endif +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SetCalibrationTarget +****************************************************************************//** +* +* Sets the CapDAC auto-calibration raw count target for CSD, CSX or ISX +* widgets. The function only updates the target value, use +* Cy_CapSense_CalibrateWidget() / Cy_CapSense_CalibrateAllWidgets() / +* Cy_CapSense_CalibrateAllLpWidgets() / Cy_CapSense_CalibrateAllSlots() to change +* raw counts according to the updated target. +* +* The function sets the specified raw count targets if CSD, CSX and/or ISX +* widgets are in the project and the auto-calibration is enabled for them. These +* targets will be used instead the configured ones by +* Cy_CapSense_CalibrateAllSlots(), Cy_CapSense_CalibrateAllWidgets() and +* Cy_CapSense_CalibrateWidget() functions. +* +* \note +* This function is available only for the fifth-generation CAPSENSE™ and +* fifth-generation low power CAPSENSE™. +* +* \param calibrTarget +* The raw counts target in percentage for the specified sensing method. +* It should be in range [1..99]. If the specified target is +* outside the range, then it will not be updated and the +* CY_CAPSENSE_STATUS_BAD_PARAM status will be returned. +* +* \param snsMethod +* Desired sensing method the calibration target should be updated for: +* * CY_CAPSENSE_CSD_GROUP - CSD sensing method +* * CY_CAPSENSE_CSX_GROUP - CSX sensing method +* * CY_CAPSENSE_ISX_GROUP - ISX sensing method +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - At least one of the input parameter is +* invalid. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_SetCalibrationTarget( + uint32_t calibrTarget, + uint32_t snsMethod, + cy_stc_capsense_context_t * context) +{ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + return Cy_CapSense_SetCalibrationTarget_V3(calibrTarget, snsMethod, context); #else - (void)context; - return CY_CAPSENSE_STATUS_BAD_CONFIG; + return Cy_CapSense_SetCalibrationTarget_V3Lp(calibrTarget, snsMethod, context); #endif } +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + -#if (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (1u == CY_CAPSENSE_TOTAL_CH_NUMBER)) || (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN)) +#if (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (1u == CY_CAPSENSE_TOTAL_CH_NUMBER)) ||\ + (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) /******************************************************************************* * Function Name: Cy_CapSense_CalibrateWidget ****************************************************************************//** @@ -326,7 +821,9 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets( * widget to the default target value. * * This function performs exactly the same tasks as -* Cy_CapSense_CalibrateAllWidgets(), but only for a specified widget. +* Cy_CapSense_CalibrateAllWidgets(), but only for a specified widget. Use +* sensing and processing functions after auto-calibration to update all +* baselines and configured filters. * * \note * For the fifth-generation CAPSENSE™ this function is available in @@ -349,24 +846,40 @@ cy_capsense_status_t Cy_CapSense_CalibrateWidget( uint32_t widgetId, cy_stc_capsense_context_t * context) { - #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - return Cy_CapSense_CalibrateWidget_V3(widgetId, context); - #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ - return Cy_CapSense_CalibrateWidget_V2(widgetId, context); - #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ - #else - (void)widgetId; - (void)context; - return CY_CAPSENSE_STATUS_BAD_CONFIG; - #endif + cy_capsense_status_t retVal = CY_CAPSENSE_STATUS_BAD_CONFIG; + + (void)widgetId; + (void)context; + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) + retVal = Cy_CapSense_CalibrateWidget_V3(widgetId, context); + #endif + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) + retVal = Cy_CapSense_CalibrateWidget_V3Lp(widgetId, context); + #endif + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) + retVal = Cy_CapSense_CalibrateWidget_V2(widgetId, context); + #endif + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + + return retVal; } -#endif /* (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (1u == CY_CAPSENSE_TOTAL_CH_NUMBER)) || (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN)) */ +#endif /* #if (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (1u == CY_CAPSENSE_TOTAL_CH_NUMBER)) ||\ + (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN || \ - ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD))) + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && \ + (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD))) /******************************************************************************* * Function Name: Cy_CapSense_SetPinState ****************************************************************************//** @@ -400,6 +913,11 @@ cy_capsense_status_t Cy_CapSense_CalibrateWidget( * callback (see the \ref group_capsense_callbacks section for details) * or with low-level functions that perform a single-sensor scanning. * +* The function is available for the fourth-generation and fifth-generation (only +* for CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) CAPSENSE™. For fifth-generation +* CAPSENSE&trade with CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD and for fifth- +* generation low power CAPSENSE&trade use Cy_CapSense_SlotPinState(). +* * \param widgetId * Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. @@ -452,6 +970,11 @@ cy_capsense_status_t Cy_CapSense_CalibrateWidget( * CY_CAPSENSE_TX_PIN, CY_CAPSENSE_NEGATIVE_TX_PIN or * CY_CAPSENSE_RX_PIN states. * +* \funcusage +* An example of using the Cy_CapSense_SetPinState() function to perform +* sensor state re-configuration: +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_SetPinState +* *******************************************************************************/ cy_capsense_status_t Cy_CapSense_SetPinState( uint32_t widgetId, @@ -465,20 +988,162 @@ cy_capsense_status_t Cy_CapSense_SetPinState( return Cy_CapSense_SetPinState_V2(widgetId, sensorElement, state, context); #endif } -#endif +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN || \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && \ + (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD))) */ + + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP || \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && \ + (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD))) +/******************************************************************************* +* Function Name: Cy_CapSense_SlotPinState +****************************************************************************//** +* +* Configures the specified electrode to the desired state in the specified +* slot (Active slot for fifth-generation low power +* CAPSENSE™) by updating the CAPSENSE™ configuration. +* +* This function changes / overwrites configuration of an electrode (several +* pins in case the electrode is ganged to more pins) with a state specified +* by the pinState parameter. The function does this only for the specified slot ID +* (Active slotID for fifth-generation low power CAPSENSE™). +* If the electrode should have the desired state during scans in another +* slots, the function should be called multiple times for each desired slot +* (Active slot for fifth-generation low power CAPSENSE™). +* +* The function call changes the pin states permanently and all further scans of +* the slot will have the electrode state as specified by the pinState parameter. +* Call the function again to change the electrode state to a new desired one or +* reinitialize CAPSENSE™ middleware by using the Cy_CapSense_Enable() function. +* +* The re-configuration is available only when +* parameter Sensor connection method = CTRLMUX. +* If parameter Sensor connection method = AMUXBUS, then the Cy_CapSense_SetPinState() +* function should be used. +* +* +* The function changes the configuration of an electrode without storing +* the previous state. A user is responsible to keep the previous state to +* revert to the default settings if needed. Also, the default settings +* can be configured again by calling Cy_CapSense_Enable() function that +* leads to repeating CAPSENSE™ Data Structure initialization, +* DAC auto-calibration, and baseline initialization. +* +* Using the function is recommended only for advanced users for specific use cases. +* For instance, to change the CAPSENSE™ default electrode configuration, +* the function could be called by using a CAPSENSE™ Data Structure +* Initialization callback ptrEODsInitCallback. For details of how to register +* the callback see the \ref group_capsense_callbacks section. That avoids repeating of +* DAC auto-calibration and baseline initialization since the callback is called after +* CAPSENSE™ Data Structure initialization but before the first initialization +* scan. +* +* You can also use this function to change the shield electrode state - call the function +* and pass the pointer to the shield electrode configuration as an input parameter. +* +* \note +* This function is available for the fifth-generation (only +* for CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) and fifth-generation low power +* CAPSENSE™. For fourth-generation CAPSENSE&trade and fifth-generation +* CAPSENSE&trade with for CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD use +* Cy_CapSense_SetPinState(). +* +* \param slotId +* The desired slot ID (Active slot ID for fifth-generation low power +* CAPSENSE™). +* +* \param ptrEltdCfg +* The pointer to an electrode the all pins states of which will be configured +* as pinState parameter. +* +* \param pinState +* The desired pins state for CSX widget electrodes could be: +* * CY_CAPSENSE_RX_PIN - Rx electrode +* * CY_CAPSENSE_TX_PIN - Tx electrode +* * CY_CAPSENSE_GROUND - Grounded +* * CY_CAPSENSE_NEGATIVE_TX_PIN - Negative Tx electrode +* (for multi-phase TX method) +* * CY_CAPSENSE_HIGHZ - Unconnected (High-Z) +* * CY_CAPSENSE_VDDA2 - Connected to VDDA/2. +* The desired pins state for CSD widget electrodes could be: +* * CY_CAPSENSE_SENSOR - Self-cap sensor +* * CY_CAPSENSE_HIGHZ - Unconnected (High-Z) +* * CY_CAPSENSE_GROUND - Grounded +* * CY_CAPSENSE_SHIELD - Shield is routed to the pin. +* The desired pins state for ISX widget electrodes could be: +* * CY_CAPSENSE_ISX_RX_PIN - ISX Rx electrode +* * CY_CAPSENSE_ISX_LX_PIN - ISX Lx electrode +* * CY_CAPSENSE_HIGHZ - Unconnected (High-Z) +* * CY_CAPSENSE_VDDA2 - Connected to VDDA/2. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - Indicates the successful electrode setting. +* - CY_CAPSENSE_STATUS_BAD_CONFIG - The function does not suppose to be +* called with the current CAPSENSE™ +* configuration. +* - CY_CAPSENSE_STATUS_BAD_PARAM - 1) widgetID, sensorElement or state +* are not valid; +* 2) the CSD sensing method is disabled for desired +* CY_CAPSENSE_SHIELD or CY_CAPSENSE_SENSOR states; +* 3) the CSX sensing method is disabled for desired +* CY_CAPSENSE_TX_PIN, CY_CAPSENSE_NEGATIVE_TX_PIN or +* CY_CAPSENSE_RX_PIN states. +* 4) the ISX sensing method is disabled for desired +* CY_CAPSENSE_ISX_RX_PIN or CY_CAPSENSE_ISX_LX_PIN +* states (Only for fifth-generation low power CAPSENSE™). +* +* \funcusage +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_SlotPinState +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_SlotPinState( + uint32_t slotId, + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t pinState, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t result = CY_CAPSENSE_STATUS_BAD_PARAM; + uint32_t localPinState; + + if ((NULL != context) && (NULL != ptrEltdCfg) && (CY_CAPSENSE_SLOT_COUNT > slotId)) + { + result = Cy_CapSense_ConvertPinState(pinState, &localPinState); + + if ((uint32_t)CY_CAPSENSE_SUCCESS_E == result) + { + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + result = Cy_CapSense_SlotPinState_V3(slotId, ptrEltdCfg, localPinState, context); + #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + result = Cy_CapSense_SlotPinState_V3Lp(slotId, ptrEltdCfg, localPinState, context); + #endif + } + } + + return result; +} +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP || \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && \ + (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD))) */ /******************************************************************************* * Function Name: Cy_CapSense_SetInactiveElectrodeState ****************************************************************************//** * -* Sets a desired state for all inactive CAPSENSE™-related electrodes for CSD -* or CSX scans. +* Sets a desired state for all inactive CAPSENSE™-related electrodes +* for CSD, CSX, ISX scans, or BIST measurement scans. * -* Use the function to set/change the desired state of all CAPSENSE™-related +* Use the function to set/change the desired state +* of all CAPSENSE™-related * electrodes which are not scanned during regular scans or BIST capacitance -* measurements. There are separate states for the CSX -* sensing method group, the CSD sensing method group, the BIST CSD sensor +* measurements. There are separate states for the CSD +* sensing method group, the CSX sensing method group, the ISX sensing method +* group, the BIST CSD sensor * (electrode) capacitance measurement, the BIST CSX sensor * (electrode) capacitance measurement, and the BIST shield electrode * capacitance measurement. For instance, it can be configured the GND state @@ -488,27 +1153,34 @@ cy_capsense_status_t Cy_CapSense_SetPinState( * The function updates some corresponding parameters in the CAPSENSE™ Data * Structure to provide the desired state and not changes pin state immediately. * The desired state will be applied to all inactive electrodes -* during the CSD or CSX scans or BIST capacitance measurements. +* during the CSD, CSX, ISX scans or BIST capacitance measurements. * It is not recommended to update the Data Structure registers directly. -* Additionally (only for fifth-generation CAPSENSE™), the function recalculates -* sensor frames in a case of the CTRLMUX sensor connection method. +* Additionally (only for fifth-generation CAPSENSE™), the function +* recalculates sensor frames in a case of the CTRLMUX sensor connection method. +* For fifth-generation low power CAPSENSE™, the function always +* recalculates all sensor frames including low-power sensors. +* +* \note ISX sensing method is only available for fifth-generation low power CAPSENSE™. * * \param inactiveState * Specifies the inactive CAPSENSE™ electrode state: * - CY_CAPSENSE_SNS_CONNECTION_HIGHZ * - CY_CAPSENSE_SNS_CONNECTION_SHIELD (only for CSD scan) * - CY_CAPSENSE_SNS_CONNECTION_GROUND +* - CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 (only for CSX scan) * * \param sensingGroup * Specifies the sensing group: * - CY_CAPSENSE_CSD_GROUP * - CY_CAPSENSE_CSX_GROUP +* - CY_CAPSENSE_ISX_GROUP * - CY_CAPSENSE_BIST_CSD_GROUP * - CY_CAPSENSE_BIST_CSX_GROUP * - CY_CAPSENSE_BIST_SHIELD_GROUP * * \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. * * \return * Returns the status of the operation \ref cy_capsense_status_t. @@ -526,39 +1198,101 @@ cy_capsense_status_t Cy_CapSense_SetInactiveElectrodeState( #endif #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) - cy_en_capsense_bist_io_state_t inactiveStateEn; + cy_en_capsense_bist_io_state_t inactiveStateBist; #endif if (NULL != context) { context->ptrActiveScanSns->currentSenseMethod = CY_CAPSENSE_UNDEFINED_GROUP; - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - (void) Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_UNDEFINED, context); + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + (void)Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_UNDEFINED, context); #endif + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) + switch (inactiveState) + { + case CY_CAPSENSE_SNS_CONNECTION_GROUND: + inactiveStateBist = CY_CAPSENSE_BIST_IO_STRONG_E; + break; + case CY_CAPSENSE_SNS_CONNECTION_HIGHZ: + inactiveStateBist = CY_CAPSENSE_BIST_IO_HIGHZA_E; + break; + case CY_CAPSENSE_SNS_CONNECTION_SHIELD: + inactiveStateBist = CY_CAPSENSE_BIST_IO_SHIELD_E; + break; + case CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2: + inactiveStateBist = CY_CAPSENSE_BIST_IO_VDDA2_E; + break; + default: + inactiveStateBist = CY_CAPSENSE_BIST_IO_UNDEFINED_E; + break; + } + + if ((CY_CAPSENSE_BIST_CSD_GROUP == sensingGroup) && + ((CY_CAPSENSE_SNS_CONNECTION_GROUND == inactiveState) || + (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState) || + (CY_CAPSENSE_SNS_CONNECTION_SHIELD == inactiveState))) + { + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + if (context->ptrBistContext->intrEltdCapCsdISC != inactiveStateBist) + { + context->ptrBistContext->intrEltdCapCsdISC = inactiveStateBist; + } + } + + if ((CY_CAPSENSE_BIST_CSX_GROUP == sensingGroup) && + ((CY_CAPSENSE_SNS_CONNECTION_GROUND == inactiveState) || + (CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 == inactiveState) || + (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState))) + { + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + if (context->ptrBistContext->intrEltdCapCsxISC != inactiveStateBist) + { + context->ptrBistContext->intrEltdCapCsxISC = inactiveStateBist; + } + } + + if ((CY_CAPSENSE_BIST_SHIELD_GROUP == sensingGroup) && + ((CY_CAPSENSE_SNS_CONNECTION_GROUND == inactiveState) || + (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState) || + (CY_CAPSENSE_SNS_CONNECTION_SHIELD == inactiveState))) + { + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + if (context->ptrBistContext->intrEltdCapShieldISC != inactiveStateBist) + { + context->ptrBistContext->intrEltdCapShieldISC = inactiveStateBist; + } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) if ((CY_CAPSENSE_CSD_GROUP == sensingGroup) && ((CY_CAPSENSE_SNS_CONNECTION_GROUND == inactiveState) || (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState) || (CY_CAPSENSE_SNS_CONNECTION_SHIELD == inactiveState))) { - if(context->ptrInternalContext->intrCsdInactSnsConn != (uint8_t)inactiveState) + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + if (context->ptrInternalContext->intrCsdInactSnsConn != (uint8_t)inactiveState) { context->ptrInternalContext->intrCsdInactSnsConn = (uint8_t)inactiveState; - Cy_CapSense_SetCsdInactiveState(context); + #if (!CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + Cy_CapSense_SetCsdInactiveState(context); + #else + capStatus = Cy_CapSense_GeneratePinFunctionConfig(context); + #endif } - capStatus = CY_CAPSENSE_STATUS_SUCCESS; } #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) if ((CY_CAPSENSE_CSX_GROUP == sensingGroup) && ((CY_CAPSENSE_SNS_CONNECTION_GROUND == inactiveState) || (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState) || ((CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 == inactiveState)))) { - if(context->ptrInternalContext->intrCsxInactSnsConn != (uint8_t)inactiveState) + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + if (context->ptrInternalContext->intrCsxInactSnsConn != (uint8_t)inactiveState) { /* There are MSC HW modules that should be enabled and the MSC HW internal switches * that should be closed only if VDDA/2 Inactive Sensor Connection is used. These @@ -566,101 +1300,67 @@ cy_capsense_status_t Cy_CapSense_SetInactiveElectrodeState( * The code below is intended to generate the Base MSC HW configuration depending * on the Inactive Sensor Connection selection. */ - if((CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 == context->ptrInternalContext->intrCsxInactSnsConn) || + if ((CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 == context->ptrInternalContext->intrCsxInactSnsConn) || (CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 == inactiveState)) { context->ptrInternalContext->intrCsxInactSnsConn = (uint8_t)inactiveState; - for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) - { - /* Generate base frame configurations for all enabled MSC channels, depending on - * the Inactive Sensor Connection selection. - */ - capStatus = Cy_CapSense_GenerateBaseConfig(curChIndex, context); - - if (CY_CAPSENSE_STATUS_SUCCESS != capStatus) + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - break; + /* Generate base frame configurations for all enabled MSC channels, depending on + * the Inactive Sensor Connection selection. + */ + capStatus = Cy_CapSense_GenerateBaseConfig(curChIndex, context); + + if (CY_CAPSENSE_STATUS_SUCCESS != capStatus) + { + break; + } } - } + Cy_CapSense_SetCsxInactiveState(context); + #else /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + capStatus |= Cy_CapSense_GenerateBaseConfig(context); + #endif } else { context->ptrInternalContext->intrCsxInactSnsConn = (uint8_t)inactiveState; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + capStatus = Cy_CapSense_GeneratePinFunctionConfig(context); + #else + Cy_CapSense_SetCsxInactiveState(context); + #endif } - - Cy_CapSense_SetCsxInactiveState(context); } - capStatus = CY_CAPSENSE_STATUS_SUCCESS; } - #else + #else /* CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN */ if ((CY_CAPSENSE_CSX_GROUP == sensingGroup) && ((CY_CAPSENSE_SNS_CONNECTION_GROUND == inactiveState) || (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState))) { - if(context->ptrInternalContext->intrCsxInactSnsConn != (uint8_t)inactiveState) + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + if (context->ptrInternalContext->intrCsxInactSnsConn != (uint8_t)inactiveState) { context->ptrInternalContext->intrCsxInactSnsConn = (uint8_t)inactiveState; Cy_CapSense_SetCsxInactiveState(context); } - - capStatus = CY_CAPSENSE_STATUS_SUCCESS; } - #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) - switch(inactiveState) + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) + if ((CY_CAPSENSE_ISX_GROUP == sensingGroup) && + (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState)) { - case CY_CAPSENSE_SNS_CONNECTION_GROUND: - inactiveStateEn = CY_CAPSENSE_BIST_IO_STRONG_E; - break; - case CY_CAPSENSE_SNS_CONNECTION_HIGHZ: - inactiveStateEn = CY_CAPSENSE_BIST_IO_HIGHZA_E; - break; - case CY_CAPSENSE_SNS_CONNECTION_SHIELD: - inactiveStateEn = CY_CAPSENSE_BIST_IO_SHIELD_E; - break; - default: - inactiveStateEn = CY_CAPSENSE_BIST_IO_UNDEFINED_E; - break; - } - - if ((CY_CAPSENSE_BIST_CSD_GROUP == sensingGroup) && - ((CY_CAPSENSE_SNS_CONNECTION_GROUND == inactiveState) || - (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState) || - (CY_CAPSENSE_SNS_CONNECTION_SHIELD == inactiveState))) - { - if(context->ptrBistContext->intrEltdCapCsdISC != inactiveStateEn) - { - context->ptrBistContext->intrEltdCapCsdISC = inactiveStateEn; - } capStatus = CY_CAPSENSE_STATUS_SUCCESS; - } - - if ((CY_CAPSENSE_BIST_CSX_GROUP == sensingGroup) && - ((CY_CAPSENSE_SNS_CONNECTION_GROUND == inactiveState) || - (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState))) - { - if(context->ptrBistContext->intrEltdCapCsxISC != inactiveStateEn) + if (context->ptrInternalContext->intrIsxInactSnsConn != (uint8_t)inactiveState) { - context->ptrBistContext->intrEltdCapCsxISC = inactiveStateEn; + context->ptrInternalContext->intrIsxInactSnsConn = (uint8_t)inactiveState; + capStatus = Cy_CapSense_GeneratePinFunctionConfig(context); } - capStatus = CY_CAPSENSE_STATUS_SUCCESS; } - - if ((CY_CAPSENSE_BIST_SHIELD_GROUP == sensingGroup) && - ((CY_CAPSENSE_SNS_CONNECTION_GROUND == inactiveState) || - (CY_CAPSENSE_SNS_CONNECTION_HIGHZ == inactiveState) || - (CY_CAPSENSE_SNS_CONNECTION_SHIELD == inactiveState))) - { - if(context->ptrBistContext->intrEltdCapShieldISC != inactiveStateEn) - { - context->ptrBistContext->intrEltdCapShieldISC = inactiveStateEn; - } - capStatus = CY_CAPSENSE_STATUS_SUCCESS; - } - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) */ + #endif #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) @@ -678,19 +1378,82 @@ cy_capsense_status_t Cy_CapSense_SetInactiveElectrodeState( #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) */ } + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + context->ptrActiveScanSns->currentSenseMethod = CY_CAPSENSE_UNDEFINED_GROUP; + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + switch (sensingGroup) + { + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + #endif /* CY_CAPSENSE_CSD_EN */ + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + #endif /* CY_CAPSENSE_CSX_EN */ + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_GROUP: + #endif /* CY_CAPSENSE_ISX_EN */ + + Cy_CapSense_GenerateAllSensorConfig(CY_CAPSENSE_SNS_FRAME_ACTIVE, context); + + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_LP_EN) + Cy_CapSense_GenerateAllSensorConfig(CY_CAPSENSE_SNS_FRAME_LOW_POWER, context); + #endif /* CY_CAPSENSE_LP_EN */ + + break; + + default: + /* Do nothing */ + break; + } + } #endif } - return (capStatus); + return capStatus; +} + +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)|| (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) +/******************************************************************************* +* Function Name: Cy_CapSense_ScanAbort +****************************************************************************//** +* +* This function sets the sequencer to the idle state by resetting the hardware, +* it can be used to abort current scan. +* +* \note +* This function is available for the fifth-generation CAPSENSE™ and +* fifth-generation low power CAPSENSE™. +* +* \note +* If this function is called from ISR during initialization or +* auto-calibration the operation of these functions will be corrupted. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation \ref cy_capsense_status_t. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanAbort(cy_stc_capsense_context_t * context) +{ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + return Cy_CapSense_ScanAbort_V3(context); + #elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + return Cy_CapSense_ScanAbort_V3Lp(context); + #endif } +#endif -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) && (!CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) /******************************************************************************* * Function Name: Cy_CapSense_SetCsdInactiveState ****************************************************************************//** * -* Sets a desired pin state for all inactive CAPSENSE™-related electrodes for CSD -* scans. +* Sets a desired pin state for all inactive CAPSENSE™-related electrodes +* for CSD scans. * * There is the internal function and it is not recommended to call it directly * from the application program. The function sets the desired state of all @@ -742,16 +1505,16 @@ void Cy_CapSense_SetCsdInactiveState( break; } } -#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) && (!CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) */ -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) && (!CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) /******************************************************************************* * Function Name: Cy_CapSense_SetCsxInactiveState ****************************************************************************//** * -* Sets a desired pin state for all inactive CAPSENSE™-related electrodes for CSX -* scans. +* Sets a desired pin state for all inactive CAPSENSE™-related electrodes +* for CSX scans. * * There is the internal function and it is not recommended to call it directly * from the application program. The function sets the desired state of all @@ -784,11 +1547,302 @@ void Cy_CapSense_SetCsxInactiveState( break; default: /* Set the default pin state: High-Z */ - context->ptrInternalContext->csdInactiveSnsDm = CY_CAPSENSE_DM_GPIO_ANALOG; + context->ptrInternalContext->csxInactiveSnsDm = CY_CAPSENSE_DM_GPIO_ANALOG; break; } } -#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) && (!CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) */ + + +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)) +/******************************************************************************* +* Function Name: Cy_CapSense_InitializeMaxRaw +****************************************************************************//** +* +* Initializes the maxRawCount and the maxRawCountRow fields of the +* cy_stc_capsense_widget_context_t structure for the specified widget. +* +* \param widgetId +* Specifies the ID number of the widget. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_TIMEOUT - A timeout reached during the scan time measurement. +* - CY_CAPSENSE_STATUS_BAD_PARAM - Not valid input parameter. +* - CY_CAPSENSE_STATUS_HW_BUSY - The MSCLP HW block is busy and cannot be +* switched to another mode. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_InitializeMaxRaw( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + uint32_t tmpVal; + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; + #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + uint32_t scanSlotId; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + #endif + + if(0u != (CY_CAPSENSE_WD_MAXCOUNT_CALC_MASK & ptrWdCfg->ptrWdContext->status)) + { + /* Prepare and execute the measurement to obtain the MAX raw count for the one-dimension widgets + * or columns for two-dimension widgets. + */ + tmpVal = ptrWdCfg->firstSlotId; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + capStatus |= Cy_CapSense_ExecuteSaturatedScan(&ptrWdCfg->ptrWdContext->maxRawCount, widgetId, + tmpVal, CY_CAPSENSE_SATURATED_MAX_COUNT, context); + #else + capStatus |= Cy_CapSense_ExecuteSaturatedScan(&ptrWdCfg->ptrWdContext->maxRawCount, + tmpVal, CY_CAPSENSE_SATURATED_MAX_COUNT, context); + #endif + } + + #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + if(CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + { + if(((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType)) + { + if(0u != (CY_CAPSENSE_WD_MAXCOUNT_ROW_CALC_MASK & ptrWdCfg->ptrWdContext->status)) + { + /* Prepare and execute the measurement to obtain the MAX raw count for rows for two-dimension widgets. */ + scanSlotId = (uint32_t)ptrWdCfg->firstSlotId + ptrWdCfg->numSlots - 1u; + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + capStatus |= Cy_CapSense_ExecuteSaturatedScan(&ptrWdCfg->ptrWdContext->maxRawCountRow, widgetId, + scanSlotId, CY_CAPSENSE_SATURATED_MAX_COUNT, context); + #else + capStatus |= Cy_CapSense_ExecuteSaturatedScan(&ptrWdCfg->ptrWdContext->maxRawCountRow, + scanSlotId, CY_CAPSENSE_SATURATED_MAX_COUNT, context); + #endif + + /* For the multi-channel mode, iterate through enabled channels and find the sensing channel that + * drives the sensor (not Shield only, Tx only, or Empty). + */ + for (tmpVal = 0u; tmpVal < CY_CAPSENSE_TOTAL_CH_NUMBER; tmpVal++) + { + ptrScanSlots = &context->ptrScanSlots[scanSlotId + (CY_CAPSENSE_SLOT_COUNT * tmpVal)]; + if(CY_CAPSENSE_SLOT_SHIELD_ONLY > ptrScanSlots->wdId) + { + break; + } + } + if(tmpVal >= CY_CAPSENSE_TOTAL_CH_NUMBER) + { + capStatus |= CY_CAPSENSE_STATUS_BAD_CONFIG; + } + + /* Swap the row and column MAX raw count values in case if rows are scanned before + * columns (the row's sensor is placed to the first slot of the widget). + */ + if (ptrWdCfg->numRows >= ptrScanSlots->snsId) + { + tmpVal = ptrWdCfg->ptrWdContext->maxRawCount; + ptrWdCfg->ptrWdContext->maxRawCount = ptrWdCfg->ptrWdContext->maxRawCountRow; + ptrWdCfg->ptrWdContext->maxRawCountRow = (uint16_t)tmpVal; + } + } + } + } + #endif + + return capStatus; +} +#endif /* ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)) */ + + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP || \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && \ + (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD))) +/******************************************************************************* +* Function Name: Cy_CapSense_ConvertPinState +****************************************************************************//** +* +* The internal function that converts specified electrode state to the +* internal format, depending on the used CAPSENSE™ platform. +* +* \note +* This function is available for the fifth-generation (only +* for CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) and fifth-generation low power +* CAPSENSE™. +* +* \param pinState +* The desired pins state for CSX widget electrodes could be: +* * CY_CAPSENSE_RX_PIN - Rx electrode +* * CY_CAPSENSE_TX_PIN - Tx electrode +* * CY_CAPSENSE_GROUND - Grounded +* * CY_CAPSENSE_NEGATIVE_TX_PIN - Negative Tx electrode +* (for multi-phase TX method) +* * CY_CAPSENSE_HIGHZ - Unconnected (High-Z) +* * CY_CAPSENSE_VDDA2 - Connected to VDDA/2. +* The desired pins state for CSD widget electrodes could be: +* * CY_CAPSENSE_SENSOR - Self-cap sensor +* * CY_CAPSENSE_HIGHZ - Unconnected (High-Z) +* * CY_CAPSENSE_GROUND - Grounded +* * CY_CAPSENSE_SHIELD - Shield is routed to the pin. +* The desired pins state for ISX widget electrodes could be: +* * CY_CAPSENSE_ISX_RX_PIN - ISX Rx electrode +* * CY_CAPSENSE_ISX_LX_PIN - ISX Lx electrode +* * CY_CAPSENSE_HIGHZ - Unconnected (High-Z) +* * CY_CAPSENSE_VDDA2 - Connected to VDDA/2. +* +* \param convertedPinState +* The pointer to the converted pins state value. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - Indicates the successful electrode setting conversion. +* - CY_CAPSENSE_STATUS_BAD_PARAM - 1) pinState is not valid; +* 2) the CSD sensing method is disabled for desired +* CY_CAPSENSE_SHIELD or CY_CAPSENSE_SENSOR states; +* 3) the CSX sensing method is disabled for desired +* CY_CAPSENSE_TX_PIN, CY_CAPSENSE_NEGATIVE_TX_PIN or +* CY_CAPSENSE_RX_PIN states; +* 4) the ISX sensing method is disabled for desired +* CY_CAPSENSE_ISX_RX_PIN or CY_CAPSENSE_ISX_LX_PIN +* states (Only for fifth-generation low power CAPSENSE™). +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ConvertPinState( + uint32_t pinState, + uint32_t * convertedPinState) +{ + cy_capsense_status_t result = CY_CAPSENSE_STATUS_BAD_PARAM; + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + switch (pinState) + { + case CY_CAPSENSE_GROUND: + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_GND; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + case CY_CAPSENSE_HIGHZ: + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_SENSOR: + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_CSD_SNS; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + case CY_CAPSENSE_SHIELD: + #if (CY_CAPSENSE_CSD_SHIELD_MODE == CY_CAPSENSE_SHIELD_ACTIVE) + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_ACT_SHIELD; + #else + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_PAS_SHIELD; + #endif + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + #endif + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_TX_PIN: + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_CSX_TX; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + case CY_CAPSENSE_RX_PIN: + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_CSX_RX; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + case CY_CAPSENSE_NEGATIVE_TX_PIN: + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_CSX_NEG_TX; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + case CY_CAPSENSE_VDDA2: + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_CSX_VDDA2; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_RX_PIN: + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_ISX_RX; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + case CY_CAPSENSE_ISX_LX_PIN: + *convertedPinState = CY_CAPSENSE_PIN_STATE_IDX_ISX_LX; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ + + default: + /* No action on other sensor states */ + break; + } + #else + switch (pinState) + { + case CY_CAPSENSE_GROUND: + *convertedPinState = CY_CAPSENSE_CTRLMUX_PIN_STATE_GND; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + case CY_CAPSENSE_HIGHZ: + *convertedPinState = CY_CAPSENSE_CTRLMUX_PIN_STATE_HIGH_Z; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_SENSOR: + *convertedPinState = CY_CAPSENSE_CTRLMUX_PIN_STATE_SNS; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + case CY_CAPSENSE_SHIELD: + *convertedPinState = CY_CAPSENSE_CTRLMUX_PIN_STATE_SHIELD; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + #endif + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_TX_PIN: + *convertedPinState = CY_CAPSENSE_CTRLMUX_PIN_STATE_TX; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + case CY_CAPSENSE_RX_PIN: + *convertedPinState = CY_CAPSENSE_CTRLMUX_PIN_STATE_RX; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + case CY_CAPSENSE_NEGATIVE_TX_PIN: + *convertedPinState = CY_CAPSENSE_CTRLMUX_PIN_STATE_TX_NEGATIVE; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + + case CY_CAPSENSE_VDDA2: + *convertedPinState = CY_CAPSENSE_CTRLMUX_PIN_STATE_VDDA2; + result = (uint32_t)CY_CAPSENSE_SUCCESS_E; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + + default: + /* No action on other sensor states */ + break; + } + #endif + + return result; +} +#endif -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ /* [] END OF FILE */ diff --git a/cy_capsense_sensing.h b/cy_capsense_sensing.h index d18fd22..b0f53c9 100644 --- a/cy_capsense_sensing.h +++ b/cy_capsense_sensing.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_sensing.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the common function prototypes for different supported @@ -22,7 +22,7 @@ #include "cy_capsense_common.h" #include "cy_capsense_structure.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if defined(__cplusplus) extern "C" { @@ -35,6 +35,16 @@ extern "C" { /******************************************************************************/ /** \addtogroup group_capsense_high_level *//** \{ */ /******************************************************************************/ +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)|| (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) +cy_capsense_status_t Cy_CapSense_ScanAllSlots( + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_ScanSlots( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context); +cy_capsense_mw_state_t Cy_CapSense_MwState( + const cy_stc_capsense_context_t * context); +#endif cy_capsense_status_t Cy_CapSense_ScanAllWidgets( cy_stc_capsense_context_t * context); cy_capsense_status_t Cy_CapSense_ScanWidget( @@ -52,24 +62,59 @@ void Cy_CapSense_InterruptHandler( /******************************************************************************/ cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets( cy_stc_capsense_context_t * context); -#if (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (1u == CY_CAPSENSE_TOTAL_CH_NUMBER)) || (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN)) + +#if (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) && \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN))) +cy_capsense_status_t Cy_CapSense_CalibrateAllSlots( + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_SetCalibrationTarget( + uint32_t calibrTarget, + uint32_t snsMethod, + cy_stc_capsense_context_t * context); +#endif + +#if (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (1u == CY_CAPSENSE_TOTAL_CH_NUMBER)) ||\ + (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) cy_capsense_status_t Cy_CapSense_CalibrateWidget( uint32_t widgetId, cy_stc_capsense_context_t * context); #endif + cy_capsense_status_t Cy_CapSense_ScanSensor( uint32_t widgetId, uint32_t sensorId, cy_stc_capsense_context_t * context); -cy_capsense_status_t Cy_CapSense_SetPinState( - uint32_t widgetId, - uint32_t sensorElement, - uint32_t state, - const cy_stc_capsense_context_t * context); + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN || \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD))) + cy_capsense_status_t Cy_CapSense_SetPinState( + uint32_t widgetId, + uint32_t sensorElement, + uint32_t state, + const cy_stc_capsense_context_t * context); +#endif + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP || \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && \ + (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD))) + cy_capsense_status_t Cy_CapSense_SlotPinState( + uint32_t slotId, + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t pinState, + cy_stc_capsense_context_t * context); +#endif + cy_capsense_status_t Cy_CapSense_SetInactiveElectrodeState( uint32_t inactiveState, uint32_t sensingGroup, cy_stc_capsense_context_t * context); + +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)|| (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) +cy_capsense_status_t Cy_CapSense_ScanAbort( + cy_stc_capsense_context_t * context); +#endif /** \} */ @@ -77,22 +122,52 @@ cy_capsense_status_t Cy_CapSense_SetInactiveElectrodeState( /** \cond SECTION_CAPSENSE_INTERNAL */ /** \addtogroup group_capsense_internal *//** \{ */ /******************************************************************************/ -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - void Cy_CapSense_SetCsdInactiveState( - cy_stc_capsense_context_t * context); +#if (!CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + void Cy_CapSense_SetCsdInactiveState( + cy_stc_capsense_context_t * context); + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + void Cy_CapSense_SetCsxInactiveState( + cy_stc_capsense_context_t * context); + #endif #endif -#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - void Cy_CapSense_SetCsxInactiveState( - cy_stc_capsense_context_t * context); +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)) +cy_capsense_status_t Cy_CapSense_InitializeMaxRaw( + uint32_t widgetId, + cy_stc_capsense_context_t * context); #endif + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP || \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) && \ + (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD))) +cy_capsense_status_t Cy_CapSense_ConvertPinState( + uint32_t pinState, + uint32_t * convertedPinState); +#endif + /** \} \endcond */ +/******************************************************************************* +* Local definition +*******************************************************************************/ + +/* Macro to optimize division operation */ +#define CY_CAPSENSE_DIV4_SHIFT (2u) + +/* Defines the KREF_PRS correcting shift, taking into account Sense Clock Divider + * adjustment in scope of the Cy_CapSense_AdjustSnsClkDivider() + * routine. + */ +#define CY_CAPSENSE_PRS_SNS_KREF_SHIFT (1u) + #if defined(__cplusplus) } #endif -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif/* CY_CAPSENSE_SENSING_H */ diff --git a/cy_capsense_sensing_lp.c b/cy_capsense_sensing_lp.c new file mode 100644 index 0000000..be68e86 --- /dev/null +++ b/cy_capsense_sensing_lp.c @@ -0,0 +1,6328 @@ +/***************************************************************************//** +* \file cy_capsense_sensing_lp.c +* \version 4.0 +* +* \brief +* This file contains the source of functions common for different scanning +* modes. +* +******************************************************************************** +* \copyright +* Copyright 2020-2023, Cypress Semiconductor Corporation (an Infineon company) +* or an affiliate of Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +*******************************************************************************/ + + +#include +#include +#include "cy_syslib.h" +#include "cy_sysclk.h" +#include "cy_gpio.h" +#include "cy_device_headers.h" +#include "cycfg_capsense.h" +#include "cycfg_capsense_defines.h" +#include "cycfg_peripherals.h" +#include "cy_capsense_common.h" +#include "cy_capsense_sensing.h" +#include "cy_capsense_sensing_lp.h" +#include "cy_capsense_generator_lp.h" +#include "cy_capsense_structure.h" +#include "cy_capsense_processing.h" +#include "cy_capsense_lib.h" +#include "cy_capsense_selftest.h" +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_msclp.h" +#endif + +#if (defined(CY_IP_M0S8MSCV3LP)) + +/******************************************************************************* +* Local definition +*******************************************************************************/ +#define CY_CAPSENSE_CSD_CCOMP_CALC_DIV (4u * CY_CAPSENSE_PERCENTAGE_100) +#define CY_CAPSENSE_CSX_CCOMP_CALC_DIV (8u * CY_CAPSENSE_PERCENTAGE_100) + +#define CY_CAPSENSE_EXT_FRAME_START_MODE_SCAN (1u) +#define CY_CAPSENSE_EXT_FRAME_START_MODE_LP_SCAN (2u) + +#define CY_CAPSENSE_CTL_OPERATING_MODE_CPU (0u) +#define CY_CAPSENSE_CTL_OPERATING_MODE_AS_MS (2u) +#define CY_CAPSENSE_CTL_OPERATING_MODE_LP_AOS (3u) + +#define CY_CAPSENSE_SCAN_ST_BSLN_RESET_MSK (0x01u) +#define CY_CAPSENSE_SCAN_ST_BSLN_VALID_MSK (0x02u) + +/* Offset in words to the first counted SNS registers */ +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + #define CY_CAPSENSE_CTL_CFG_OFFSET_VAL (0u) +#else + #define CY_CAPSENSE_CTL_CFG_OFFSET_VAL (8u) +#endif + +#define CY_CAPSENSE_CTL_SNS_CTL_OFFSET_VAL (CY_MSCLP_6_SNS_REGS - 1u) +#define CY_CAPSENSE_CTL_LP_SNS_CTL_OFFSET_VAL (CY_MSCLP_11_SNS_REGS - 1u) +#define CY_CAPSENSE_LP_AOS_SNS_CFG_REGS_NUM (5u) + +/* CIC2 Filter Divider */ +#define CY_CAPSENSE_CIC2_DIVIDER_MAX (256u) +/* CIC2 Filter Shift */ +#define CY_CAPSENSE_CIC2_SHIFT_MAX (15u) + +/* CIC2 Accumulator parameters */ +#define CY_CAPSENSE_CIC2_ACC_BIT_NUM (24u) +#define CY_CAPSENSE_CIC2_ACC_MAX_VAL ((1uL << CY_CAPSENSE_CIC2_ACC_BIT_NUM) - 1u) + +#define CY_CAPSENSE_AUTOTUNE_SIGPFC_PERCENTAGE (75u) + +/* CAPSENSE ILO compensation constants */ +#define CY_CAPSENSE_ILO_FACTOR_SHIFT (24u) +#define CY_CAPSENSE_ILO_COMPENSATE_DELAY (500u) + +/* The minimum allowed value of CDAC compensation divider */ +#define CY_CAPSENSE_CDAC_COMP_DIV_MIN_MSCLP (3u) + +#define CY_CAPSENSE_AOS_CTL_FR_TIMEOUT_INTERVAL_MAX_VALUE (MSCLP_AOS_CTL_FR_TIMEOUT_INTERVAL_Msk >> MSCLP_AOS_CTL_FR_TIMEOUT_INTERVAL_Pos) + +/******************************************************************************* +* Constants +*******************************************************************************/ +#if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_USE_CAPTURE) + const cy_stc_msclp_base_config_t cy_capsense_msclpCfg = CY_CAPSENSE_MSC_CONFIG_DEFAULT; +#endif + +/******************************************************************************/ +/** \cond SECTION_CAPSENSE_INTERNAL */ +/** \addtogroup group_capsense_internal *//** \{ */ +/******************************************************************************/ +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) +cy_capsense_status_t Cy_CapSense_MixedSensorsCheck( + uint32_t startSlotId, + uint32_t numberSlots, + uint32_t * ptrHwCfg, + cy_stc_capsense_context_t * context); +#endif + +cy_capsense_status_t Cy_CapSense_SlotPinStateInternal( + uint32_t * ptrSnsFrm, + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t pinState, + cy_stc_capsense_context_t * context); + +uint32_t Cy_CapSense_GetLfsrBitsAuto( + const cy_stc_capsense_widget_config_t * ptrWdConfig, + const cy_stc_capsense_context_t * context); + +uint32_t Cy_CapSense_GetClkSrcSSCAuto( + const cy_stc_capsense_widget_config_t * ptrWdConfig, + const cy_stc_capsense_context_t * context); + +uint32_t Cy_CapSense_GetClkSrcPRSAuto( + const cy_stc_capsense_widget_context_t * ptrWdContext, + const cy_stc_capsense_context_t * context); + +uint32_t Cy_CapSense_GetLfsrBitsNumber( + uint32_t snsClkDivider, + uint32_t snsClkDividerMin, + uint32_t ditherLimitPercents, + uint32_t lfsrScale); + +uint32_t Cy_CapSense_RunSSCAuto( + uint32_t autoSelMode, + uint32_t lfsrDitherCycles, + uint32_t ditherLimitCycles, + uint32_t lfsrPolySize, + uint32_t subConvNumber); + +uint32_t Cy_CapSense_GetPolySize(uint32_t lfsrPoly); + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) +void Cy_CapSense_SetCompDivider( + uint32_t widgetId, + cy_stc_capsense_context_t * context); +void Cy_CapSense_SetMaxCompCdac( + uint32_t widgetId, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_ScanSlotInternalCPU( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_CdacSuccessAppr( + uint32_t autoCalibrMode, + uint32_t calibConfigMsk, + uint32_t widgetId, + uint32_t target, + cy_stc_capsense_context_t * context); + +#endif + +void Cy_CapSense_TransferRawCounts( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context); + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) +void Cy_CapSense_TransferLpRawCounts( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context); +#endif + +cy_capsense_status_t Cy_CapSense_WaitMrssStatusChange( + uint32_t timeout, + uint32_t mrssStatus, + cy_stc_capsense_context_t * context); + +uint32_t Cy_CapSense_MsclpTimerCalcCycles( + uint32_t wakeupTimer, + cy_stc_capsense_context_t * context); + +/** \} \endcond */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanSlotsInternal +****************************************************************************//** +* +* Transfers sensor frame to Sensor Data RAM and initiates the non-blocking scan +* of specified slots. If the specified slots configuration does not fit into the +* HW SNS RAM then only the CY_CAPSENSE_FIFO_SNS_MAX_NUM number of sensors will +* be scanned. The remaining sensors will be scanned in the next sub-frame(s). +* +* This is an internal function. Do not call this function directly from +* the application program. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param startSlotId +* The slot ID scan will be started from. +* +* \param numberSlots +* The number of slots will be scanned. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_ScanSlotsInternal( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context) +{ + uint32_t index; + uint32_t * ptrSensorFrame; + __IOM uint32_t * ptrSensorData; + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + uint32_t numberSlotsLocal = (CY_CAPSENSE_FIFO_SNS_MAX_NUM > numberSlots) ? numberSlots : CY_CAPSENSE_FIFO_SNS_MAX_NUM; + context->ptrInternalContext->numSlots = (uint16_t)numberSlotsLocal; + + if (0u != numberSlotsLocal) + { + /* Initialize frame data pointer */ + ptrSensorFrame = &context->ptrSensorFrameContext[startSlotId * CY_CAPSENSE_SENSOR_FRAME_SIZE]; + + /* Initialize sensor data pointer */ + ptrSensorData = &ptrHwBase->SNS.SENSOR_DATA[0u]; + + /* Disable HW IP to allow MRSS operations */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Disable PUMP to save power during the Sensor Data copy */ + #if (CY_MSCLP_VDDA_PUMP_TRESHOLD > CY_CAPSENSE_VDDA_MV) + ptrHwBase->PUMP_CTL = 0u; + #endif + + /* Check if IMO is running */ + if (0u == (ptrHwBase->MRSS_STATUS & MSCLP_MRSS_STATUS_IMO_UP_Msk)) + { + /* Enable MRSS to provide access to the SNS_STC registers */ + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_START_Msk; + (void)Cy_CapSense_WaitMrssStatusChange(CY_MSCLP_CLK_LF_PERIOD_MAX * CY_MSCLP_MRSS_TIMEOUT_FULL, + CY_CAPSENSE_MRSS_IMO_TURN_ON, context); + } + else + { + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_PUMP_STOP_Msk; + } + + /* Copy sensor frame to Sensor Data RAM */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + for (index = 0u; index < numberSlotsLocal; index++) + { + /* Set raw count filter coefficient */ + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL0] = (ptrSensorFrame[CY_CAPSENSE_SNS_HW_IIR_INDEX] & + CY_CAPSENSE_RC_HW_IIR_FILTER_COEFF_MASK) >> CY_CAPSENSE_RC_HW_IIR_FILTER_COEFF_POS; + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL1] = 0u; + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL2] = 0u; + /* Set filtered raw count scaled */ + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL3] = ptrSensorFrame[CY_CAPSENSE_SNS_HW_IIR_INDEX] & CY_CAPSENSE_FRC_HW_IIR_FILTER_MASK; + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL4] = 0u; + /* Copy sensor frame to SEL and CTL registers */ + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_SW_SEL_CSW_LO_MASK2_INDEX] = ptrSensorFrame[CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK2_INDEX]; + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_SW_SEL_CSW_LO_MASK1_INDEX] = ptrSensorFrame[CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK1_INDEX]; + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_SW_SEL_CSW_LO_MASK0_INDEX] = ptrSensorFrame[CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK0_INDEX]; + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_SCAN_CTL_INDEX] = ptrSensorFrame[CY_CAPSENSE_SNS_SCAN_CTL_INDEX]; + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_CDAC_CTL_INDEX] = ptrSensorFrame[CY_CAPSENSE_SNS_CDAC_CTL_INDEX]; + ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_CTL_INDEX] = ptrSensorFrame[CY_CAPSENSE_SNS_CTL_INDEX]; + ptrSensorFrame += CY_CAPSENSE_SENSOR_FRAME_SIZE; + ptrSensorData += CY_CAPSENSE_LP_SENSOR_FRAME_SIZE; + } + #else + for (index = 0u; index < (numberSlotsLocal * CY_CAPSENSE_SENSOR_FRAME_SIZE); index++) + { + *ptrSensorData = *ptrSensorFrame; + ptrSensorData++; + ptrSensorFrame++; + } + #endif + + ptrSensorData--; + /* Configure the last slot */ + *ptrSensorData |= MSCLP_SNS_SNS_CTL_LAST_Msk; + + /* Configure Sensor Data RAM start and slot size */ + CY_REG32_CLR_SET(ptrHwBase->SCAN_CTL2, MSCLP_SCAN_CTL2_FRAME_CFG_START_ADDR, 0u); + CY_REG32_CLR_SET(ptrHwBase->CTL, MSCLP_CTL_CFG_OFFSET, CY_CAPSENSE_CTL_CFG_OFFSET_VAL); + + /* Configure FIFO */ + CY_REG32_CLR_SET(ptrHwBase->SCAN_CTL1, MSCLP_SCAN_CTL1_FRAME_RES_START_ADDR, + MSCLP_SNS_SRAM_WORD_SIZE - numberSlotsLocal); + + if ((NULL != context->ptrInternalContext->ptrSSCallback) && + (CY_CAPSENSE_ENABLE == context->ptrInternalContext->firstActSubFrame)) + { + context->ptrInternalContext->ptrSSCallback(context->ptrActiveScanSns); + } + + /* Stop MRSS_IMO only for the first sub-frame in LP_AOS mode after the callback as it can operate with SNS registers */ + if ((CY_CAPSENSE_ENABLE == context->ptrInternalContext->firstActSubFrame) && + (0u != (ptrHwBase->MRSS_STATUS & MSCLP_MRSS_STATUS_IMO_UP_Msk))) + { + /* Stop the MRSS_IMO to save power */ + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_STOP_Msk; + } + + /* Check for the system VDDA value and enable PUMP if VDDA is less than the threshold */ + #if (CY_MSCLP_VDDA_PUMP_TRESHOLD > CY_CAPSENSE_VDDA_MV) + ptrHwBase->PUMP_CTL = MSCLP_PUMP_CTL_PUMP_MODE_Msk; + #endif + + /* Check if an external start is enabled */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_EXT_FRM_START_EN) + if (0u == (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_INITIALIZATION_MASK)) + { + /* Set the external start scan mode to start LP_AOS sequencer */ + CY_REG32_CLR_SET(ptrHwBase->CTL, MSCLP_CTL_EXT_FRAME_START_MODE, + CY_CAPSENSE_EXT_FRAME_START_MODE_LP_SCAN); + + /* Enable HW IP to allow a scan frame start */ + ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + } + else + { + /* Enable HW IP to allow a scan frame start */ + ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + + /* Start LP_AOS scan */ + ptrHwBase->WAKEUP_CMD = MSCLP_WAKEUP_CMD_START_FRAME_AOS_Msk; + } + #else + /* Enable HW IP to allow a scan frame start */ + ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + + /* Start scan */ + ptrHwBase->WAKEUP_CMD = MSCLP_WAKEUP_CMD_START_FRAME_AOS_Msk; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_EXT_FRM_START_EN) */ + } +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) +/******************************************************************************* +* Function Name: Cy_CapSense_MixedSensorsCheck +****************************************************************************//** +* +* Initiates the check of specified slots. Widgets with enabled MPSC feature +* can't be scanned with the others in one scan. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param startSlotId +* The slot ID scan will be started from. +* +* \param numberSlots +* The number of slots will be scanned. +* +* \param ptrHwCfg +* Pointer to a hardware config variable. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_MIXED_SENSORS - Sensors with MPSC and w/o can't be scanned in one frame. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_MixedSensorsCheck(uint32_t startSlotId, + uint32_t numberSlots, + uint32_t * ptrHwCfg, + cy_stc_capsense_context_t * context) +{ + uint32_t curSlotIndex, wdIndex, snsIndex; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + uint32_t regularWdCnt = 0u; + uint32_t mpscWdCnt = 0u; + uint32_t lastSlot = startSlotId + numberSlots - 1u; + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + + ptrScanSlots = context->ptrScanSlots; + curSlotIndex = startSlotId; + + do + { + wdIndex = ptrScanSlots[curSlotIndex].wdId; + snsIndex = ptrScanSlots[curSlotIndex].snsId; + ptrWdCfg = &context->ptrWdConfig[wdIndex ]; + + if((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + (CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder)) + { + mpscWdCnt++; + } + else + { + regularWdCnt++; + } + + if ((0u != regularWdCnt) && (0u != mpscWdCnt)) + { + capStatus = CY_CAPSENSE_STATUS_MIXED_SENSORS; + break; + } + + /* Jump to the next widget */ + curSlotIndex += (ptrWdCfg->numSlots - snsIndex); + } while (curSlotIndex <= lastSlot); + + if ((CY_CAPSENSE_STATUS_SUCCESS == capStatus) && (0u < mpscWdCnt)) + { + *ptrHwCfg = CY_CAPSENSE_HW_CONFIG_MPSC_SCANNING; + } + + return capStatus; +} +#endif /* CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanSlots_V3Lp +****************************************************************************//** +* +* Initiates the non-blocking scan of specified slots. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* The transition into system DEEP SLEEP mode is allowed after the scan is started. +* +* This function initiates a scan only for the first number of slots that could +* be fit into the Sensor Data RAM and then exits. Scans for the remaining slots +* started in the interrupt service routine (part of middleware), which triggered +* at the end of the scan completion. +* +* If the /ref activeWakeupTimer parameter set by the Cy_CapSense_ConfigureMsclpTimer() +* function is more than 0u, the correspondent time interval will be inserted before +* the frame scan start to provide a desired refresh rate. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param startSlotId +* The slot ID scan will be started from. +* +* \param numberSlots +* The number of slots will be scanned. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - Any of input parameters is invalid. +* - CY_CAPSENSE_STATUS_CONFIG_OVERFLOW - The numberSlots parameter exceeds +* the maximum number of sensor configurations +* which is possible to be loaded into the +* internal buffer of the CAPSENSE&trade HW block. +* - CY_CAPSENSE_STATUS_HW_BUSY - The HW is busy with the previous scan. +* - CY_CAPSENSE_STATUS_HW_LOCKED - The MSCLP HW block is captured by another +* middleware. +* - CY_CAPSENSE_STATUS_TIMEOUT - A timeout reached during the MRSS start. +* - CY_CAPSENSE_STATUS_MIXED_SENSORS - Sensors with MPSC and w/o can't be scanned +* in one frame. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanSlots_V3Lp( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + uint32_t lastSlot; + cy_stc_capsense_internal_context_t * ptrIntrCxt; + MSCLP_Type * ptrHwBase; + uint32_t hwCfg = CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING; + + if ((NULL == context) || (0u == numberSlots) || (CY_CAPSENSE_SLOT_COUNT <= startSlotId)) + { + capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_EXT_FRM_START_EN) + if (CY_CAPSENSE_FIFO_SNS_MAX_NUM < numberSlots) + { + capStatus = CY_CAPSENSE_STATUS_CONFIG_OVERFLOW; + } + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + capStatus = Cy_CapSense_MixedSensorsCheck(startSlotId, numberSlots, &hwCfg, context); + } + #endif + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + lastSlot = startSlotId + numberSlots - 1u; + if (CY_CAPSENSE_SLOT_COUNT > lastSlot) + { + if (CY_CAPSENSE_BUSY == Cy_CapSense_IsBusy(context)) + { + /* Previous scan is not completed. Return the BUSY status */ + capStatus = CY_CAPSENSE_STATUS_HW_BUSY; + } + else + { + Cy_CapSense_SetBusyFlags(context); + + /* Set the Active widget scan status */ + ptrIntrCxt = context->ptrInternalContext; + ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + + ptrIntrCxt->repeatScanEn = CY_CAPSENSE_DISABLE; + + if (((CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING == ptrIntrCxt->hwConfigState) || + (CY_CAPSENSE_HW_CONFIG_MPSC_SCANNING == ptrIntrCxt->hwConfigState)) && + (ptrIntrCxt->startSlotIndex == startSlotId) && (ptrIntrCxt->numSlots == numberSlots) && + (CY_CAPSENSE_FIFO_SNS_MAX_NUM >= numberSlots) && + (0u == (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_CALIBRATION_MASK)) && + (0u != (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_ACTIVE_WD_SCAN_MASK))) + { + ptrIntrCxt->repeatScanEn = CY_CAPSENSE_ENABLE; + + /* Reset the start slot in the internal context structure */ + ptrIntrCxt->currentSlotIndex = (uint16_t)startSlotId; + + if (NULL != context->ptrInternalContext->ptrSSCallback) + { + context->ptrInternalContext->ptrSSCallback(context->ptrActiveScanSns); + } + + /* Check if the external start is enabled */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_EXT_FRM_START_EN) + if (0u == (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_INITIALIZATION_MASK)) + { + /* Set the External Start scan mode to start the LP_AOS sequencer */ + CY_REG32_CLR_SET(ptrHwBase->CTL, MSCLP_CTL_EXT_FRAME_START_MODE, + CY_CAPSENSE_EXT_FRAME_START_MODE_LP_SCAN); + /* Enable HW IP to allow the scan frame start */ + ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + } + else + { + /* Enable HW IP to allow the scan frame start */ + ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + /* Disable the External Start scan mode during initialization and start scans immediately */ + ptrHwBase->WAKEUP_CMD = MSCLP_WAKEUP_CMD_START_FRAME_AOS_Msk; + } + #else + /* Disable HW block per IFX 005467-513 */ + ptrHwBase->CTL &= ~MSCLP_CTL_ENABLED_Msk; + + /* Enable HW IP to allow the scan frame start */ + ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + + /* Start scanning */ + ptrHwBase->WAKEUP_CMD = MSCLP_WAKEUP_CMD_START_FRAME_AOS_Msk; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_EXT_FRM_START_EN) */ + } + else + { + capStatus = Cy_CapSense_SwitchHwConfiguration(hwCfg, context); + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + context->ptrCommonContext->status &= (uint32_t)~((uint32_t)CY_CAPSENSE_MW_STATE_WD_SCAN_MASK); + context->ptrCommonContext->status |= CY_CAPSENSE_MW_STATE_ACTIVE_WD_SCAN_MASK; + + /* Check for the needed MSCv3LP operating mode */ + ptrIntrCxt->operatingMode = CY_CAPSENSE_CTL_OPERATING_MODE_LP_AOS; + CY_REG32_CLR_SET(ptrHwBase->CTL, MSCLP_CTL_OPERATING_MODE, + CY_CAPSENSE_CTL_OPERATING_MODE_LP_AOS); + CY_REG32_CLR_SET(ptrHwBase->CTL, MSCLP_CTL_CFG_OFFSET, 0uL); + + ptrHwBase->AOS_CTL &= ~MSCLP_AOS_CTL_FR_TIMEOUT_INTERVAL_Msk; + ptrHwBase->AOS_CTL |= (uint32_t)(1uL << MSCLP_AOS_CTL_FR_TIMEOUT_INTERVAL_Pos); + + /* Set the active timer value */ + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL &= ~MSCLP_AOS_CTL_WAKEUP_TIMER_Msk; + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL |= + (context->ptrInternalContext->activeWakeupTimerCycles << MSCLP_AOS_CTL_WAKEUP_TIMER_Pos); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + /* Enable HW processing */ + ptrHwBase->CE_CTL = MSCLP_CE_CTL_ENABLED_Msk | ptrIntrCxt->hwIirInit; + #else + /* Disable HW processing */ + ptrHwBase->CE_CTL = 0uL; + #endif + + /* Unmask FRAME interrupt for ACTIVE and ALR modes (AS_MS and LP_AOS HW modes) */ + ptrHwBase->INTR_LP_MASK = MSCLP_INTR_LP_FRAME_Msk; + + /* Initialize internal context */ + ptrIntrCxt->startSlotIndex = (uint16_t)startSlotId; + ptrIntrCxt->currentSlotIndex = (uint16_t)startSlotId; + ptrIntrCxt->endSlotIndex = (uint16_t)lastSlot; + ptrIntrCxt->firstActSubFrame = CY_CAPSENSE_ENABLE; + + if (CY_CAPSENSE_FIFO_SNS_MAX_NUM >= numberSlots) + { + /* Set the repeat scan flag */ + ptrIntrCxt->repeatScanEn = CY_CAPSENSE_ENABLE; + } + + /* Initialize the scan */ + Cy_CapSense_ScanSlotsInternal(startSlotId, numberSlots, context); + } + } + } + } + else + { + capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + } + } + + return capStatus; +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_ScanLpSlots +****************************************************************************//** +* +* Initiates a non-blocking scan for specified low power slots and exits. +* Scanning is initiated only if no scan is in progress. +* Scans initiated by this function can be performed in different system power +* modes such as Active, Sleep or Deep Sleep. +* After all specified number of frames are scanned or if a touch is +* detected during the scan, the interrupt is fired, the CPU switches +* Power mode to Active and the interrupt service routine (part of middleware) +* transfers the last frame raw counts and clears the busy status. +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* The function clears the CY_CAPSENSE_MW_STATE_LP_ACTIVE_MASK status bit. It is +* set when a touch detect occurs during the low power slot scans and will remain +* set until the next Cy_CapSense_ScanLpSlots() function call. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param startLpSlotId +* The slot ID to start a scan from. +* +* \param numberLpSlots +* The number of slots to be scanned. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation completed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The hardware is busy with the previous scan. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanLpSlots( + uint32_t startLpSlotId, + uint32_t numberLpSlots, + cy_stc_capsense_context_t * context) +{ + uint32_t index; + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + cy_stc_capsense_internal_context_t * ptrIntrCxt; + uint32_t * ptrSensorFrameLp; + MSCLP_Type * ptrHwBase; + uint32_t lastLpSlot = startLpSlotId + numberLpSlots - 1u; + + if ((NULL != context) && (0u != numberLpSlots) && + (CY_CAPSENSE_FIFO_SNS_LP_MAX_NUM >= numberLpSlots) && (CY_CAPSENSE_SLOT_LP_COUNT > lastLpSlot)) + { + /* Clear the signal detect status for low power scans */ + context->ptrCommonContext->status &= (~((uint32_t)CY_CAPSENSE_MW_STATE_LP_ACTIVE_MASK)); + if (CY_CAPSENSE_BUSY == Cy_CapSense_IsBusy(context)) + { + /* Previous scan is not completed. Return the BUSY status */ + capStatus = CY_CAPSENSE_STATUS_HW_BUSY; + } + else + { + capStatus = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING, context); + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + Cy_CapSense_SetBusyFlags(context); + + ptrIntrCxt = context->ptrInternalContext; + ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + + /* Set the repeat scan flag */ + ptrIntrCxt->repeatScanEn = CY_CAPSENSE_ENABLE; + + if (((startLpSlotId != ptrIntrCxt->currentSlotIndex) || (lastLpSlot != ptrIntrCxt->endSlotIndex)) || + (0u == (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_LP_WD_SCAN_MASK))) + { + /* Initialize internal context */ + ptrIntrCxt->currentSlotIndex = (uint16_t)startLpSlotId; + ptrIntrCxt->endSlotIndex = (uint16_t)lastLpSlot; + ptrIntrCxt->numSlots = (uint16_t)numberLpSlots; + + /* Set the LP_AOS operating mode */ + ptrIntrCxt->operatingMode = CY_CAPSENSE_CTL_OPERATING_MODE_LP_AOS; + CY_REG32_CLR_SET(ptrHwBase->CTL, MSCLP_CTL_OPERATING_MODE, + CY_CAPSENSE_CTL_OPERATING_MODE_LP_AOS); + CY_REG32_CLR_SET(ptrHwBase->CTL, MSCLP_CTL_CFG_OFFSET, 0u); + + /* Enable HW processing */ + ptrHwBase->CE_CTL = MSCLP_CE_CTL_ENABLED_Msk | MSCLP_CE_CTL_BLSD_EN_Msk; + + #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_RC_IIR_FILTER_EN) + ptrHwBase->CE_CTL |= MSCLP_CE_CTL_RCF_EN_Msk; + #endif + + /* Disable HW IP to allow MRSS operations */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Check if IMO is running */ + if (0u == (ptrHwBase->MRSS_STATUS & MSCLP_MRSS_STATUS_IMO_UP_Msk)) + { + /* Enable only REF and IMO to provide access to the SNS_STC registers */ + #if (CY_MSCLP_VDDA_PUMP_TRESHOLD > CY_CAPSENSE_VDDA_MV) + ptrHwBase->PUMP_CTL = 0u; + #endif + + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_START_Msk; + capStatus = Cy_CapSense_WaitMrssStatusChange( + CY_MSCLP_CLK_LF_PERIOD_MAX * CY_MSCLP_MRSS_TIMEOUT_SMALL, + CY_CAPSENSE_MRSS_IMO_TURN_ON, context); + } + else + { + /* Stop the MRSS pump to save power */ + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_PUMP_STOP_Msk; + } + + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + /* Initialize frame data pointer */ + ptrSensorFrameLp = &context->ptrSensorFrameLpContext[startLpSlotId * CY_MSCLP_11_SNS_REGS]; + + /* Copy sensor frame to Sensor Data RAM */ + for(index = 0u; index < (numberLpSlots * CY_MSCLP_11_SNS_REGS); index++) + { + ptrHwBase->SNS.SENSOR_DATA[index] = ptrSensorFrameLp[index]; + } + + /* Configure the last slot */ + ptrHwBase->SNS.SENSOR_DATA[((numberLpSlots - 1u) * CY_MSCLP_11_SNS_REGS) + + CY_CAPSENSE_CTL_LP_SNS_CTL_OFFSET_VAL] |= MSCLP_SNS_SNS_CTL_LAST_Msk; + + /* Initialize channel engine to perform processing */ + ptrHwBase->SNS.CE_INIT_CTL |= MSCLP_SNS_CE_INIT_CTL_SENSOR_INIT_Msk; + + /* Check AHB2AHB bus response */ + if ((ptrHwBase->SNS.BRIDGE_STATUS & MSCLP_SNS_BRIDGE_STATUS_READY_Msk) == 0u) + { + capStatus = CY_CAPSENSE_STATUS_TIMEOUT; + } + + if (0u != (ptrHwBase->MRSS_STATUS & MSCLP_MRSS_STATUS_IMO_UP_Msk)) + { + /* Stop the MRSS to save power */ + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_STOP_Msk; + } + } + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + /* Configure Sensor Data RAM start and slot size */ + CY_REG32_CLR_SET(ptrHwBase->SCAN_CTL2, MSCLP_SCAN_CTL2_FRAME_CFG_START_ADDR, 0u); + CY_REG32_CLR_SET(ptrHwBase->CTL, MSCLP_CTL_CFG_OFFSET, 0u); + + /* Set AOS_CTL register with enabled MRSS power cycle */ + ptrHwBase->AOS_CTL &= (uint32_t)~MSCLP_AOS_CTL_FR_TIMEOUT_INTERVAL_Msk; + + /* Limit wotTimeout value to maximum if it exceeds range */ + if (CY_CAPSENSE_AOS_CTL_FR_TIMEOUT_INTERVAL_MAX_VALUE < (uint32_t)context->ptrInternalContext->wotTimeout) + { + context->ptrInternalContext->wotTimeout = (uint16_t)CY_CAPSENSE_AOS_CTL_FR_TIMEOUT_INTERVAL_MAX_VALUE; + } + ptrHwBase->AOS_CTL |= (uint32_t)((uint32_t)context->ptrInternalContext->wotTimeout << MSCLP_AOS_CTL_FR_TIMEOUT_INTERVAL_Pos); + ptrHwBase->AOS_CTL |= MSCLP_AOS_CTL_MRSS_PWR_CYCLE_EN_Msk; + + /* Set the WOT timer value */ + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL &= ~MSCLP_AOS_CTL_WAKEUP_TIMER_Msk; + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL |= + (context->ptrInternalContext->wotScanIntervalCycles << MSCLP_AOS_CTL_WAKEUP_TIMER_Pos); + + /* Check for system VDDA value and enable PUMP if VDDA is less then threshold */ + #if (CY_MSCLP_VDDA_PUMP_TRESHOLD > CY_CAPSENSE_VDDA_MV) + ptrHwBase->PUMP_CTL = MSCLP_PUMP_CTL_PUMP_MODE_Msk; + #endif + + /* Configure the start address of FIFO considering fractional part discarding after integer division */ + CY_REG32_CLR_SET(ptrHwBase->SCAN_CTL1, MSCLP_SCAN_CTL1_FRAME_RES_START_ADDR, + ((uint32_t)MSCLP_SNS_SRAM_WORD_SIZE - + ((((uint32_t)MSCLP_SNS_SRAM_WORD_SIZE / numberLpSlots) - CY_MSCLP_11_SNS_REGS) * numberLpSlots))); + } + } + else + { + if (0u != (ptrHwBase->MRSS_STATUS & MSCLP_MRSS_STATUS_MRSS_UP_Msk)) + { + /* Disable HW IP to allow MRSS operations */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Stop the MRSS to save power */ + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_STOP_Msk; + (void)Cy_CapSense_WaitMrssStatusChange((CY_MSCLP_CLK_LF_PERIOD_MAX * CY_CAPSENSE_MULTIPLIER_TWO), CY_CAPSENSE_MRSS_TURN_OFF, context); + } + } + + /* Set Low Power widget scan status */ + context->ptrCommonContext->status &= (uint32_t)~((uint32_t)CY_CAPSENSE_MW_STATE_WD_SCAN_MASK); + context->ptrCommonContext->status |= CY_CAPSENSE_MW_STATE_LP_WD_SCAN_MASK; + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + /* Start of scan callback */ + if (NULL != ptrIntrCxt->ptrSSCallback) + { + ptrIntrCxt->ptrSSCallback(context->ptrActiveScanSns); + } + + /* Disable HW block per IFX 005467-513 */ + ptrHwBase->CTL &= ~MSCLP_CTL_ENABLED_Msk; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_EXT_FRM_START_EN) + /* Clear the external start scan mode */ + ptrHwBase->CTL &= ~MSCLP_CTL_EXT_FRAME_START_MODE_Msk; + #endif + + /* Enable HW IP to allow scans */ + ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + + /* Un-mask FR_TIMEOUT and SIG_DETECT interrupts in LP-AOS mode */ + ptrHwBase->INTR_LP_MASK = MSCLP_INTR_LP_MASK_FR_TIMEOUT_Msk | MSCLP_INTR_LP_MASK_SIG_DET_Msk; + + /* Start scan */ + ptrHwBase->WAKEUP_CMD |= MSCLP_WAKEUP_CMD_START_FRAME_AOS_Msk; + } + } + } + } + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanAllLpWidgets +****************************************************************************//** +* +* Initiates a non-blocking scan for all low power widgets/sensors. +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* +* The function is the wrapper for the Cy_CapSense_ScanAllLpSlots() function. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The hardware is busy with the previous scan. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanAllLpWidgets( + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + + if (NULL != context) + { + capStatus = Cy_CapSense_ScanLpSlots(0u, CY_CAPSENSE_SLOT_LP_COUNT, context); + } + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanAllLpSlots +****************************************************************************//** +* +* Initiates a non-blocking scan of all low power slots and then exits. +* Scanning is initiated only if no scan is in progress. +* A scan initiated by this function can be performed in different power modes +* such as Active, Sleep or Deep Sleep. +* After all specified number of frames are scanned or if a touch is +* detected during the scan, the interrupt is fired, the CPU switches +* Power mode to Active and the interrupt service routine (part of middleware) +* updates the busy status. +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation completed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The hardware is busy with the previous scan. +* +* \funcusage +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_ScanAllLpSlots +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanAllLpSlots( + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + + if (NULL != context) + { + capStatus = Cy_CapSense_ScanLpSlots(0u, CY_CAPSENSE_SLOT_LP_COUNT, context); + } + + return capStatus; +} +#endif /* CY_CAPSENSE_LP_EN */ + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanAllWidgets_V3Lp +****************************************************************************//** +* +* Initiates the non-blocking scan for all widgets/sensors. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* +* The function is the wrapper for the Cy_CapSense_ScanAllSlots() function +* to provide the backward compatibility. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The HW is busy with the previous scan. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanAllWidgets_V3Lp(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + + if (NULL != context) + { + capStatus = Cy_CapSense_ScanSlots(0u, CY_CAPSENSE_SLOT_COUNT, context); + } + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanWidget_V3Lp +****************************************************************************//** +* +* Initiates the scanning of all sensors in the widget. +* If the widget is of a low power type it is scanned with the LP_AoS scanning mode +* (i.e. with the configured maximum number of frames and scan refresh interval). +* +* The function uses Cy_CapSense_ScanSlots() or Cy_CapSense_ScanLpSlots() function +* with the parameters of +* startSlotId and numberSlots retrieved from the firstSlotId and numSlots +* fields of the cy_stc_capsense_widget_config_t structure. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* This function is available in single-channel solution. +* +* \param widgetId +* Specifies the ID number of the widget. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The HW is busy with the previous scan. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanWidget_V3Lp( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + + if (NULL != context) + { + if (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == context->ptrWdConfig[widgetId].wdType) + { + capStatus = Cy_CapSense_ScanLpSlots(context->ptrWdConfig[widgetId].firstSlotId, + context->ptrWdConfig[widgetId].numSlots, context); + } + else + { + capStatus = Cy_CapSense_ScanSlots(context->ptrWdConfig[widgetId].firstSlotId, + context->ptrWdConfig[widgetId].numSlots, context); + } + #else + { + capStatus = Cy_CapSense_ScanSlots(context->ptrWdConfig[widgetId].firstSlotId, + context->ptrWdConfig[widgetId].numSlots, context); + } + #endif + } + } + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanSensor_V3Lp +****************************************************************************//** +* +* Initiates the scanning of the selected sensor in the widget. If the widget is +* of a low power type its sensor is scanned with the LP_AoS scanning mode +* (i.e. with the configured maximum number of frames and scan refresh interval). +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* The function uses Cy_CapSense_ScanSlots() or Cy_CapSense_ScanLpSlots() function. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* This function is available in single-channel solution. +* +* \param widgetId +* Specifies the ID number of the widget. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param sensorId +* Specifies the ID number of the sensor within the widget. A macro for the +* sensor ID within a specified widget can be found in the cycfg_capsense.h +* file defined as CY_CAPSENSE__SNS_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The HW is busy with the previous scan. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanSensor_V3Lp( + uint32_t widgetId, + uint32_t sensorId, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + + if ((NULL != context) && + (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) && + (sensorId < context->ptrWdConfig[widgetId].numSns)) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == context->ptrWdConfig[widgetId].wdType) + { + capStatus = Cy_CapSense_ScanLpSlots((sensorId + context->ptrWdConfig[widgetId].firstSlotId), 1u, + context); + } + else + { + capStatus = Cy_CapSense_ScanSlots((sensorId + context->ptrWdConfig[widgetId].firstSlotId), 1u, context); + } + #else + { + capStatus = Cy_CapSense_ScanSlots((sensorId + context->ptrWdConfig[widgetId].firstSlotId), 1u, context); + } + #endif + } + + return capStatus; +} + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) +/******************************************************************************* +* Function Name: Cy_CapSense_CalibrateAllSlots_V3Lp +****************************************************************************//** +* +* Calibrates CapDACs for all widgets. +* +* The function is the wrapper for the Cy_CapSense_CalibrateAllWidgets() function +* to provide the backward compatibility. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* This function is available in single-channel solution. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_CALIBRATION_FAIL - The calibration failed if software +* watchdog timeout occurred +* during any calibration scan, +* the scan was not completed, or +* resulted raw counts +* are outside the limits. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_CalibrateAllSlots_V3Lp(cy_stc_capsense_context_t * context) +{ + return Cy_CapSense_CalibrateAllWidgets_V3Lp(context); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SetCalibrationTarget_V3Lp +****************************************************************************//** +* +* Sets the CapDAC auto-calibration raw count targets for CSD, CSX and/or ISX +* widgets. +* +* The function sets the specified raw count targets if CSD, CSX and/or +* ISX widgets are in the project and the auto-calibration is enabled for them. +* These targets will be used instead the configured ones by +* Cy_CapSense_CalibrateAllSlots(), Cy_CapSense_CalibrateAllWidgets() and +* Cy_CapSense_CalibrateWidget() functions. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param calibrTarget +* The raw counts target in percentage for the specified sensing method. +* It should be more than 0u and less than 100u. If the specified target is +* outside the range, then it will not be updated and +* the CY_CAPSENSE_STATUS_BAD_PARAM status will be returned. +* +* \param snsMethod +* Desired sensing method the calibration target should be updated for: +* * CY_CAPSENSE_CSD_GROUP - CSD sensing method +* * CY_CAPSENSE_CSX_GROUP - CSX sensing method +* * CY_CAPSENSE_ISX_GROUP - ISX sensing method +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - At least one of the input parameter is +* invalid. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_SetCalibrationTarget_V3Lp( + uint32_t calibrTarget, + uint32_t snsMethod, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t calibStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + + if (NULL != context) + { + if ((CY_CAPSENSE_PERCENTAGE_100 > calibrTarget) && (0u < calibrTarget)) + { + switch (snsMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + context->ptrInternalContext->intrCsdRawTarget = (uint8_t)calibrTarget; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + context->ptrInternalContext->intrCsxRawTarget = (uint8_t)calibrTarget; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_GROUP: + context->ptrInternalContext->intrIsxRawTarget = (uint8_t)calibrTarget; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ + + default: + /* No action */ + break; + } + calibStatus = CY_CAPSENSE_STATUS_SUCCESS; + } + } + + return calibStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_CalibrateAllWidgets_V3Lp +****************************************************************************//** +* +* Executes CapDAC auto-calibration for all all relevant Active widgets if +* enabled. +* +* Having enabled the CDAC auto-calibration algorithm is the most common use +* case. It helps to tune your system considering board-to-board variation, +* temperature drift, etc. CDAC auto-calibration is enabled by default. +* +* The function performs searching of Reference CDAC code, Compensation CDAC +* code and Compensation Divider (whichever is enabled) by using a successive +* approximation method to make the sensor's raw count closest to the +* defined targets. The auto-calibration target values are defined +* (by default) as: +* * 85% of the maximum raw count for CSD widgets +* * 40% of the maximum raw count for CSX widgets. +* * 40% of the maximum raw count for ISX widgets. +* +* To change calibration targets use the Cy_CapSense_SetCalibrationTarget() function. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_CALIBRATION_FAIL - The calibration is failed due to +* the issues with scanning (either +* watchdog timer, interrupt breaking, etc.). +* - CY_CAPSENSE_STATUS_CALIBRATION_CHECK_FAIL - The calibration is failed +* because of rawcount is out of the +* defined range. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets_V3Lp(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t calibStatus = CY_CAPSENSE_STATUS_SUCCESS; + uint32_t widgetId; + + if (NULL != context) + { + for (widgetId = 0u; widgetId < context->ptrCommonConfig->numWd; widgetId++) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if(context->ptrWdConfig[widgetId].wdType != (uint8_t)CY_CAPSENSE_WD_LOW_POWER_E) + { + calibStatus |= Cy_CapSense_CalibrateWidget_V3Lp(widgetId, context); + } + #else + calibStatus |= Cy_CapSense_CalibrateWidget_V3Lp(widgetId, context); + #endif + } + } + + /* Disable repeated scans after calibrations */ + context->ptrInternalContext->repeatScanEn = CY_CAPSENSE_DISABLE; + context->ptrCommonContext->status &= (uint32_t)~((uint32_t)CY_CAPSENSE_MW_STATE_WD_SCAN_MASK); + + return calibStatus; +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_CalibrateAllLpSlots +****************************************************************************//** +* +* Calibrates CapDACs for all Low power widgets. +* +* The function is the wrapper for the Cy_CapSense_CalibrateAllLpWidgets() function +* to provide the backward compatibility. +* +* \note +* This function is available only for the fifth-generation +* low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_CALIBRATION_FAIL - The calibration failed if software +* watchdog timeout occurred +* during any calibration scan, +* the scan was not completed, or +* resulted raw counts +* are outside the limits. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_CalibrateAllLpSlots(cy_stc_capsense_context_t * context) +{ + return Cy_CapSense_CalibrateAllLpWidgets(context); +} +#endif + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_CalibrateAllLpWidgets +****************************************************************************//** +* +* Executes CapDAC auto-calibration for all relevant low power widgets if enabled. +* +* Having enabled the CDAC auto-calibration algorithm is the most common use +* case. It helps to tune your system considering board-to-board variation, +* temperature drift, etc. CDAC auto-calibration is enabled by default. +* +* The function performs searching of Reference CDAC code, Compensation CDAC +* code, Compensation Divider (whichever is enabled) by using a successive +* approximation method to make the sensor's raw count closest to the +* defined targets. The auto-calibration target values are defined +* (by default) as: +* * 85% of the maximum raw count for CSD widgets +* * 40% of the maximum raw count for CSX widgets. +* * 40% of the maximum raw count for ISX widgets. +* +* To change calibration targets use the Cy_CapSense_SetCalibrationTarget() function. +* +* \note +* This function is available only for the fifth-generation +* low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_CALIBRATION_FAIL - The calibration is failed due to +* the issues with scanning (either +* watchdog timer, interrupt breaking, etc.). +* - CY_CAPSENSE_STATUS_CALIBRATION_CHECK_FAIL - The calibration is failed +* because of rawcount is out of the +* defined range. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_CalibrateAllLpWidgets(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t calibStatus = CY_CAPSENSE_STATUS_SUCCESS; + uint32_t widgetId; + + if (NULL != context) + { + for (widgetId = 0u; widgetId < context->ptrCommonConfig->numWd; widgetId++) + { + if(context->ptrWdConfig[widgetId].wdType == (uint8_t)CY_CAPSENSE_WD_LOW_POWER_E) + { + calibStatus |= Cy_CapSense_CalibrateWidget_V3Lp(widgetId, context); + } + } + } + + /* Disable repeated scans after calibrations */ + context->ptrInternalContext->repeatScanEn = CY_CAPSENSE_DISABLE; + context->ptrCommonContext->status &= (uint32_t)~((uint32_t)CY_CAPSENSE_MW_STATE_WD_SCAN_MASK); + + return calibStatus; +} +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) */ + + +#endif /* + * ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + * (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + * (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) + */ + +/******************************************************************************* +* Function Name: Cy_CapSense_ConfigureMsclpTimer +****************************************************************************//** +* +* Configures the wakeup timer value for Active mode. The wakeup timer interval +* is introduced before each scan frame start. Use the function to implement +* different Active scan refresh rates (for instance an Active mode with +* the 128 Hz refresh rate and an Active Low Refresh Rate mode with the 32 Hz +* refresh rate). +* +* The minimum wakeup time value is corresponding to one ILO cycle (25us for +* 40KHz ILO). The maximum wakeup time value depends on actual ILO frequency and +* can be set to a value, corresponding to 2^16 ILO cycles (1638400us for +* 40KHz ILO). If the timer value exceeds 2^16 ILO cycles, it would be set to +* the maximum possible value. +* The real wakeup time interval depends on ILO frequency which have a big +* tolerance (above +/- 50 %), see device datasheets. In order to improve the +* timer accuracy, use Cy_CapSense_IloCompensate() function. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param wakeupTimer +* The desired wakeup timer value in microseconds. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* +* \funcusage +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_ConfigureMsclpTimer +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ConfigureMsclpTimer( + uint32_t wakeupTimer, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t result = CY_CAPSENSE_STATUS_BAD_PARAM; + + if (NULL != context) + { + result = CY_CAPSENSE_STATUS_SUCCESS; + context->ptrInternalContext->activeWakeupTimer = wakeupTimer; + + /* Calculate and store compensated wakeup timer value */ + context->ptrInternalContext->activeWakeupTimerCycles = + Cy_CapSense_MsclpTimerCalcCycles(wakeupTimer, context); + + if (0u != (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_ACTIVE_WD_SCAN_MASK)) + { + /* Update value for the wakeup timer */ + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL &= ~MSCLP_AOS_CTL_WAKEUP_TIMER_Msk; + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL |= + (uint32_t)(context->ptrInternalContext->activeWakeupTimerCycles << MSCLP_AOS_CTL_WAKEUP_TIMER_Pos); + } + } + return result; +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_ConfigureMsclpWotTimer +****************************************************************************//** +* +* Configures the wakeup timer value for Wake-On-Touch mode. The wakeup time is +* introduced before each scan frame. +* +* The minimum wakeup time value is corresponding to one ILO cycle (25us for +* 40KHz ILO). The maximum wakeup time value depends on actual ILO frequency and +* can be set to a value, corresponding to 2^16 ILO cycles (1638400us for +* 40KHz ILO). If the timer value exceeds 2^16 ILO cycles, it would be set to +* the maximum possible value. +* The real wakeup time interval depends on ILO frequency which have a big +* tolerance (above +/- 50 %), see device datasheets. In order to improve the +* timer accuracy, use Cy_CapSense_IloCompensate() function. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param wakeupTimer +* The desired wakeup timer value in microseconds. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* +* \funcusage +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_ScanAllLpSlots +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ConfigureMsclpWotTimer( + uint32_t wakeupTimer, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t result = CY_CAPSENSE_STATUS_BAD_PARAM; + + if (NULL != context) + { + result = CY_CAPSENSE_STATUS_SUCCESS; + context->ptrInternalContext->wotScanInterval = wakeupTimer; + + /* Calculate and store compensated wakeup timer value */ + context->ptrInternalContext->wotScanIntervalCycles = + Cy_CapSense_MsclpTimerCalcCycles(wakeupTimer, context); + + if (0u != (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_LP_WD_SCAN_MASK)) + { + /* Update value for the wakeup timer */ + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL &= ~MSCLP_AOS_CTL_WAKEUP_TIMER_Msk; + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL |= + (uint32_t)(context->ptrInternalContext->wotScanIntervalCycles << MSCLP_AOS_CTL_WAKEUP_TIMER_Pos); + } + } + return result; +} +#endif + + +/******************************************************************************* +* Function Name: Cy_CapSense_IloCompensate +****************************************************************************//** +* +* Measures the actual ILO frequency and calculates compensation factor for MSCLP +* Active and Wake-On-Touch mode timers. In order to keep timer intervals +* accurate, call this function periodically. +* To set Active and Wake-On-Touch mode timers, use +* Cy_CapSense_ConfigureMsclpTimer() and Cy_CapSense_ConfigureMsclpWotTimer() +* functions correspondingly. +* +* \note SysClk should be clocked by IMO, otherwise the +* Cy_CapSense_IloCompensate() function can work incorrectly. +* +* \note If the System clock frequency is changed in runtime, the +* mtb-pdl-cat2 SystemCoreClockUpdate() function should be called before +* calling Cy_CapSense_IloCompensate(). +* +* \note This function is blocking, function execution time is ~1ms, regardless +* of IMO frequency. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_IloCompensate(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t result = CY_CAPSENSE_STATUS_BAD_PARAM; + uint32_t dummyVar = CY_CAPSENSE_ILO_COMPENSATE_DELAY; + uint16_t trimCnt2Val; + + if (NULL != context) + { + /* Perform ILO measurement and get only the result of SRSSLT_TST_TRIM_CNTR2. + * The measurement counts number of ILO clocks per set number of IMO clocks, + * which corresponds to IMO frequency(Hz) / 1024, so measurement time is + * always equal to 1 / 1024 seconds and actual ILO frequency is equal to + * SRSSLT_TST_TRIM_CNTR2 value * 1024 or SRSSLT_TST_TRIM_CNTR2 value * 2^10. + */ + Cy_SysClk_IloStartMeasurement(); + while (CY_SYSCLK_SUCCESS != Cy_SysClk_IloCompensate(dummyVar, &dummyVar)) + { + /* Wait for the end of ILO measurement */ + } + trimCnt2Val = (uint16_t)SRSSLT_TST_TRIM_CNTR2; + Cy_SysClk_IloStopMeasurement(); + + /* Calculate ILO compensation factor using number of ILO clocks, measured + * by SRSSLT_TST_TRIM_CNTR2. Factor calculated as + * actual ILO frequency (Hz) * 2^14 / 1000000 or + * SRSSLT_TST_TRIM_CNTR2 * 2^24 / 1000000. + * Multiplier 2^14 is used for calculation optimization, so integer + * division by 1000000 can be performed during factor calculation. + */ + context->ptrInternalContext->iloCompensationFactor = + ((uint32_t)trimCnt2Val << CY_CAPSENSE_ILO_FACTOR_SHIFT) / + CY_CAPSENSE_1M_DIVIDER; + + /* Calculate and store active and wake-on-touch timer values */ + context->ptrInternalContext->activeWakeupTimerCycles = + Cy_CapSense_MsclpTimerCalcCycles(context->ptrInternalContext->activeWakeupTimer, context); + context->ptrInternalContext->wotScanIntervalCycles = + Cy_CapSense_MsclpTimerCalcCycles(context->ptrInternalContext->wotScanInterval, context); + + /* Select correct timer value */ + dummyVar = context->ptrInternalContext->activeWakeupTimerCycles; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if (0u != (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_LP_WD_SCAN_MASK)) + { + dummyVar = context->ptrInternalContext->wotScanIntervalCycles; + } + #endif + + /* Update AOS_CTL register with selected value */ + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL &= ~MSCLP_AOS_CTL_WAKEUP_TIMER_Msk; + context->ptrCommonConfig->ptrChConfig->ptrHwBase->AOS_CTL |= (uint32_t)(dummyVar << MSCLP_AOS_CTL_WAKEUP_TIMER_Pos); + + result = CY_CAPSENSE_STATUS_SUCCESS; + } + + return result; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_MsclpTimerCalcCycles +****************************************************************************//** +* +* Calculates the value of MSCLP wakeup timer in number of ILO clocks based on +* compensation factor, measured by Cy_CapSense_IloCompensate() function. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param wakeupTimer +* The desired wakeup timer value in microseconds. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* The wakeupTimer value in ILO cycles. +* +*******************************************************************************/ +uint32_t Cy_CapSense_MsclpTimerCalcCycles(uint32_t wakeupTimer, cy_stc_capsense_context_t * context) +{ + /* Calculate actual number of ILO clocks, based on iloCompensationFactor. + * Number of ILO cycles equal to wakeupTimer * actual ILO Frequency (Hz) / 1000000 or + * wakeupTimer * iloCompensationFactor / 2^14. + */ + uint32_t numIloClocks = ((wakeupTimer * context->ptrInternalContext->iloCompensationFactor) >> + CY_CAPSENSE_ILO_COMPENSATE_SHIFT); + + /* Check wakeup timer value ranges */ + if (0u < numIloClocks) + { + numIloClocks--; + } + if (((uint32_t)MSCLP_AOS_CTL_WAKEUP_TIMER_Msk >> MSCLP_AOS_CTL_WAKEUP_TIMER_Pos) < numIloClocks) + { + numIloClocks = (uint32_t)MSCLP_AOS_CTL_WAKEUP_TIMER_Msk >> MSCLP_AOS_CTL_WAKEUP_TIMER_Pos; + } + + return numIloClocks; +} + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) +/******************************************************************************* +* Function Name: Cy_CapSense_CalibrateWidget_V3Lp +****************************************************************************//** +* +* Executes the CapDAC calibration for all the sensors in the specified widget +* to the default target value. +* +* This function performs exactly the same tasks as +* Cy_CapSense_CalibrateAllWidgets(), but only for a specified widget. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* This function is available in single-channel solution. +* +* \param widgetId +* Specifies the ID number of the widget. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_CALIBRATION_FAIL - The calibration is failed due to +* the issues with scanning (either +* watchdog timer, interrupt breaking, etc.). +* - CY_CAPSENSE_STATUS_CALIBRATION_CHECK_FAIL - The calibration is failed +* because of rawcount is out of the +* defined range. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_CalibrateWidget_V3Lp( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t calibrationStatus = CY_CAPSENSE_STATUS_SUCCESS; + cy_stc_capsense_widget_config_t const * ptrWdCfg; + uint32_t calibConfigMsk = 0u; + uint32_t target; + MSCLP_Type * ptrHwBase; + + if ((NULL != context) && (CY_CAPSENSE_TOTAL_WIDGET_COUNT > widgetId) && + (0u != Cy_CapSense_IsWidgetEnabled(widgetId, context))) + { + ptrWdCfg = &context->ptrWdConfig[widgetId]; + ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + Cy_CapSense_SetupCpuOperatingMode(context); + switch (ptrWdCfg->senseMethod) + { + #if (CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE) + case CY_CAPSENSE_CSD_GROUP: + calibConfigMsk = CY_CAPSENSE_CSD_CALIBRATION_MODE_MSK; + target = context->ptrInternalContext->intrCsdRawTarget; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ + + #if (CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE) + case CY_CAPSENSE_CSX_GROUP: + calibConfigMsk = CY_CAPSENSE_CSX_CALIBRATION_MODE_MSK; + target = context->ptrInternalContext->intrCsxRawTarget; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ + + #if (CY_CAPSENSE_ISX_CDAC_CALIBRATION_USAGE) + case CY_CAPSENSE_ISX_GROUP: + calibConfigMsk = CY_CAPSENSE_ISX_CALIBRATION_MODE_MSK; + target = context->ptrInternalContext->intrIsxRawTarget; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ + + default: + /* Widget type is not valid */ + target = 0u; + break; + } + + /* Proceed widgets only if calibration for method is enabled */ + if (0u != (calibConfigMsk & CY_CAPSENSE_CALIBRATION_EN_MSK)) + { + context->ptrCommonContext->status |= CY_CAPSENSE_MW_STATE_CALIBRATION_MASK; + + /* Calibrate RefCDAC with disabled CompCDAC */ + #if (CY_CAPSENSE_CDAC_REF_AUTO_USAGE) + if(0u != (calibConfigMsk & CY_CAPSENSE_CDAC_REF_AUTO_USAGE_MSK)) + { + context->ptrCommonContext->status |= CY_CAPSENSE_MW_STATE_CALIBRATION_SINGLE_MASK; + + calibrationStatus |= Cy_CapSense_CdacSuccessAppr(CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR, calibConfigMsk, + widgetId, target, context); + + context->ptrCommonContext->status &= + (uint32_t)~((uint32_t)CY_CAPSENSE_MW_STATE_CALIBRATION_SINGLE_MASK); + } + #endif + + /* Find CompDivider with fixed Ref CDAC and maximum CompCDAC (for case #8 or #4) */ + #if (CY_CAPSENSE_CDAC_COMP_DIV_AUTO_USAGE) + if(0u != (calibConfigMsk & CY_CAPSENSE_CDAC_COMP_DIV_AUTO_USAGE_MSK)) + { + calibrationStatus |= Cy_CapSense_CalibrateCompDivider(widgetId, target, context); + } + #endif + + /* Calibrate CompCDAC with fixed Ref CDAC and fixed CompDivider (case #3 and #7) */ + #if (CY_CAPSENSE_CDAC_COMP_USAGE) + if(0u != (calibConfigMsk & CY_CAPSENSE_CDAC_COMP_USAGE_MSK)) + { + calibrationStatus |= Cy_CapSense_CdacSuccessAppr(CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR, calibConfigMsk, + widgetId, target, context); + } + #endif + + /* Check calibration result */ + calibrationStatus |= Cy_CapSense_VerifyCalibration(widgetId, context); + + /* Update CRC if BIST is enabled */ + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) + Cy_CapSense_UpdateCrcWidget(widgetId, context); + #endif + + if (CY_CAPSENSE_STATUS_SUCCESS != calibrationStatus) + { + calibrationStatus |= CY_CAPSENSE_STATUS_CALIBRATION_FAIL; + } + + + /* Disable HW IP to allow MRSS operations */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Disable PUMP */ + #if (CY_MSCLP_VDDA_PUMP_TRESHOLD > CY_CAPSENSE_VDDA_MV) + ptrHwBase->PUMP_CTL = 0u; + #endif + + if (0u != (ptrHwBase->MRSS_STATUS & MSCLP_MRSS_STATUS_MRSS_UP_Msk)) + { + /* Stop the MRSS to save power */ + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_STOP_Msk; + (void)Cy_CapSense_WaitMrssStatusChange((CY_MSCLP_CLK_LF_PERIOD_MAX * CY_CAPSENSE_MULTIPLIER_TWO), CY_CAPSENSE_MRSS_TURN_OFF, context); + } + + context->ptrCommonContext->status &= ~(uint32_t)CY_CAPSENSE_MW_STATE_CALIBRATION_MASK; + + (void)Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT, context); + } + } + else + { + calibrationStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + } + + return calibrationStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_CdacSuccessAppr +****************************************************************************//** +* +* The internal function that performs the specified CDAC successive +* approximation seek for the specified widget. +* +* The function performs some scans of the slots in specified widget in the CPU +* driven scan mode to seek a CDAC value which produce raw counts no more than +* the configured target. The CDAC is specified by the autoCalibrMode parameter. +* The number of scans is no more than the specified CDAC bit number plus one, +* if the fine CDAC enabled - additional 5 scans are added. +* The function also break the approximation process if raw counts are closer +* to the target less than a half of the configured calibration error. +* The function usage is limited by the CapDAC auto-calibration. +* +* \note +* This function is available only +* for the fifth-generation low power CAPSENSE™. +* +* \param autoCalibrMode +* Specifies the widget auto-calibration mode: +* - CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR - The successive approximation +* (up to 9 scans) of RefCDAC with disabled CompCDAC +* - CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR - The successive approximation +* (up to 9 scans) of CompCDAC with fixed RefCDAC +* +* \param calibConfigMsk +* Specifies the widget auto-calibration configuration mask. +* +* \param widgetId +* The widget ID scans will be done for. +* +* \param target +* The calibrated sensor raw target. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_CALIBRATION_FAIL - The calibration is failed due to +* the issues with scanning (either +* watchdog timer, interrupt breaking, etc.). +* - CY_CAPSENSE_STATUS_BAD_PARAM - The wrong CDAC is specified +* by the autoCalibrMode parameter. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_CdacSuccessAppr( + uint32_t autoCalibrMode, + uint32_t calibConfigMsk, + uint32_t widgetId, + uint32_t target, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t calibStatus = CY_CAPSENSE_STATUS_SUCCESS; + cy_stc_capsense_widget_config_t const * ptrWdCfg = &context->ptrWdConfig[widgetId]; + cy_stc_capsense_sensor_context_t * ptrSnsCxt; + + uint32_t calMaskNext; + uint32_t ii; + uint32_t rawTarget; + uint32_t snsIndex; + uint32_t sensingGroup = context->ptrWdConfig[widgetId].senseMethod; + uint32_t snsFrameType; + uint32_t * ptrSnsFrmCdacCtlReg; + uint32_t snsFrameIndex; + uint32_t numberOfScans; + uint32_t frameSize = CY_CAPSENSE_SENSOR_FRAME_SIZE; + uint32_t cdacMsk; + uint32_t csdScanEn = CY_CAPSENSE_DISABLE; + uint32_t rowFlag = CY_CAPSENSE_DISABLE; + uint32_t cdacVal; + uint8_t * cdacRefPtr = &ptrWdCfg->ptrWdContext->cdacRef; + uint8_t * rowCdacRefPtr = &ptrWdCfg->ptrWdContext->rowCdacRef; + #if (CY_CAPSENSE_CDAC_FINE_USAGE) + uint32_t fineVal; + uint8_t * cdacFinePtr = &ptrWdCfg->ptrWdContext->cdacFine; + uint8_t * rowCdacFinePtr = &ptrWdCfg->ptrWdContext->rowCdacFine; + #endif + + snsFrameType = CY_CAPSENSE_SNS_FRAME_ACTIVE; + ptrSnsFrmCdacCtlReg = context->ptrSensorFrameContext + CY_CAPSENSE_SNS_CDAC_CTL_INDEX; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if ((ptrWdCfg->wdType == (uint8_t)CY_CAPSENSE_WD_LOW_POWER_E)) + { + snsFrameType = CY_CAPSENSE_SNS_FRAME_LOW_POWER; + ptrSnsFrmCdacCtlReg = context->ptrSensorFrameLpContext + CY_CAPSENSE_FRM_LP_SNS_CDAC_CTL_INDEX; + frameSize = CY_MSCLP_11_SNS_REGS; + } + #endif + + /* Calculate raw target for current sensing method */ + rawTarget = context->ptrWdContext[widgetId].maxRawCount; + rawTarget = (rawTarget * target) / CY_CAPSENSE_PERCENTAGE_100; + /* Find number of scans */ + numberOfScans = CY_CAPSENSE_CAL_NUM_SCANS_VALUE; + + #if (CY_CAPSENSE_CDAC_REF_AUTO_USAGE) + if (CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR != autoCalibrMode) + { + ptrWdCfg->ptrWdContext->cdacRef = 0u; + ptrWdCfg->ptrWdContext->rowCdacRef = 0u; + #if (CY_CAPSENSE_CDAC_FINE_USAGE) + if (0u != (calibConfigMsk & CY_CAPSENSE_CDAC_CDAC_FINE_USAGE_MSK)) + { + numberOfScans = CY_CAPSENSE_CAL_FINE_NUM_SCANS_VALUE; + ptrWdCfg->ptrWdContext->cdacFine = 0u; + ptrWdCfg->ptrWdContext->rowCdacFine = 0u; + } + #endif + } + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + /* Dummy scan */ + if (CY_CAPSENSE_CSX_GROUP == sensingGroup) + { + calibStatus |= Cy_CapSense_ScanSlotInternalCPU(snsFrameType, (ptrWdCfg->firstSlotId), context); + } + #endif + + for (snsIndex = 0u; snsIndex < (uint32_t)ptrWdCfg->numSns; snsIndex++) + { + #if (CY_CAPSENSE_CDAC_FINE_USAGE) + fineVal = 0u; + #endif + cdacVal = 0u; + cdacMsk = CY_CAPSENSE_CAL_MIDDLE_VALUE; + calMaskNext = CY_CAPSENSE_CAL_MIDDLE_VALUE; + snsFrameIndex = frameSize * (ptrWdCfg->firstSlotId + snsIndex); + ptrSnsCxt = &ptrWdCfg->ptrSnsContext[snsIndex]; + + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + if ((rowFlag != CY_CAPSENSE_ENABLE) && + (CY_CAPSENSE_CSD_GROUP == sensingGroup) && + (ptrWdCfg->numCols <= snsIndex) && + (((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType) || + ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType))) + { + rowFlag = CY_CAPSENSE_ENABLE; + rawTarget = context->ptrWdContext[widgetId].maxRawCountRow; + rawTarget = (rawTarget * target) / CY_CAPSENSE_PERCENTAGE_100; + } + #endif + + if(CY_CAPSENSE_CSD_GROUP == sensingGroup) + { + /* Set CSD scan flag */ + csdScanEn = CY_CAPSENSE_ENABLE; + + /* Clear flag as compensation CapDAC code for MPSC widgets should be increased unlike reference CapDAC */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if ((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) && + (CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR == autoCalibrMode)) + { + csdScanEn = CY_CAPSENSE_DISABLE; + } + #endif + } + + /* Phase 1: Find DAC code to match raw target */ + for (ii = 0u; ii < numberOfScans; ii++) + { + cdacVal = (cdacMsk & CY_CAPSENSE_CAL_CDAC_Msk) >> CY_CAPSENSE_CAL_CDAC_Pos; + switch (autoCalibrMode) + { + #if (CY_CAPSENSE_CDAC_REF_AUTO_USAGE) + case CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR: + ptrSnsFrmCdacCtlReg[snsFrameIndex] &= (uint32_t)~(MSCLP_SNS_SNS_CDAC_CTL_SEL_RE_Msk | + MSCLP_SNS_SNS_CDAC_CTL_SEL_CO_Msk | + MSCLP_SNS_SNS_CDAC_CTL_SEL_CF_Msk); + + #if (CY_CAPSENSE_CDAC_FINE_USAGE) + if (ii >= CY_CAPSENSE_CAL_NUM_SCANS_VALUE) + { + fineVal = (cdacMsk & CY_CAPSENSE_CAL_FINE_CDAC_Msk); + ptrSnsFrmCdacCtlReg[snsFrameIndex] |= (fineVal << MSCLP_SNS_SNS_CDAC_CTL_SEL_CF_Pos); + } + else + #endif + { + ptrSnsFrmCdacCtlReg[snsFrameIndex] |= (cdacVal << MSCLP_SNS_SNS_CDAC_CTL_SEL_RE_Pos); + } + break; + #endif + + #if (CY_CAPSENSE_CDAC_COMP_USAGE) + case CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR: + ptrSnsFrmCdacCtlReg[snsFrameIndex] &= (uint32_t)~MSCLP_SNS_SNS_CDAC_CTL_SEL_CO_Msk; + ptrSnsFrmCdacCtlReg[snsFrameIndex] |= (uint32_t)(cdacVal << MSCLP_SNS_SNS_CDAC_CTL_SEL_CO_Pos); + break; + #endif + + default: + /* The auto-calibration mode is not valid */ + calibStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + break; + } + + calibStatus |= Cy_CapSense_ScanSlotInternalCPU(snsFrameType, (ptrWdCfg->firstSlotId + snsIndex), context); + Cy_CapSense_PreProcessSensor(widgetId, snsIndex, context); + + /* Update CapDACs based on scan result + * Bits [4..0] fine CapDAC + * Bits [12..5] reference CapDAC / compensation CapDAC + */ + if (((csdScanEn == CY_CAPSENSE_ENABLE) && ((uint32_t)ptrSnsCxt->raw < rawTarget)) || + ((csdScanEn == CY_CAPSENSE_DISABLE) && ((uint32_t)ptrSnsCxt->raw >= rawTarget))) + { + cdacMsk &= ~calMaskNext; + } + calMaskNext >>= 1u; + cdacMsk |= calMaskNext; + } + + /* In case of Comp CapDAC calibration - update data structure and go to the phase #4 */ + #if (CY_CAPSENSE_CDAC_COMP_USAGE) + if ((uint32_t)CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR == autoCalibrMode) + { + ptrSnsCxt->cdacComp = (uint8_t)cdacVal; + } + #endif + + /* Phase #2 - Find Max CapDAC Code across all sensors and populate it to the widget context structure */ + #if (CY_CAPSENSE_CDAC_REF_AUTO_USAGE) + if ((uint32_t)CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR == autoCalibrMode) + { + if (rowFlag == CY_CAPSENSE_ENABLE) + { + if (((uint8_t)cdacVal) > *rowCdacRefPtr) + { + *rowCdacRefPtr = (uint8_t)cdacVal; + } + #if (CY_CAPSENSE_CDAC_FINE_USAGE) + if (((uint8_t)fineVal) > *rowCdacFinePtr) + { + *rowCdacFinePtr = ((uint8_t)fineVal); + } + #endif + } + else + { + if (((uint8_t)cdacVal) > *cdacRefPtr) + { + *cdacRefPtr = (uint8_t)cdacVal; + } + #if (CY_CAPSENSE_CDAC_FINE_USAGE) + if (((uint8_t)fineVal) > *cdacFinePtr) + { + *cdacFinePtr = (uint8_t)fineVal; + } + #endif + } + } + #endif + } + + /* Phase #3 - Normalization */ + #if (CY_CAPSENSE_CDAC_REF_AUTO_USAGE) + if ((uint32_t)CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR == autoCalibrMode) + { + /* Decreases CapDAC twice if compensation is enabled */ + if(0u != (calibConfigMsk & CY_CAPSENSE_CDAC_COMP_USAGE_MSK)) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + /* Skip normalization for MPSC widgets*/ + if (!((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) && + (CY_CAPSENSE_CSD_GROUP == sensingGroup))) + #endif + { + /* Division with rounding up for both ref and fine CDAC */ + *cdacRefPtr = (*cdacRefPtr + 1u) >> 1u; + *rowCdacRefPtr = (*rowCdacRefPtr + 1u) >> 1u; + + #if (CY_CAPSENSE_CDAC_FINE_USAGE) + *cdacFinePtr = (*cdacFinePtr + 1u) >> 1u; + *rowCdacFinePtr = (*rowCdacFinePtr + 1u) >> 1u; + if (CY_CAPSENSE_CAL_REF_CDAC_MIN_CODE > *cdacRefPtr) + { + *cdacRefPtr = 0u; + } + else + { + *cdacFinePtr = 0u; + } + + if ((CY_CAPSENSE_CSD_GROUP == sensingGroup) && + (((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType) || + ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType))) + { + if (CY_CAPSENSE_CAL_REF_CDAC_MIN_CODE > *rowCdacRefPtr) + { + *rowCdacRefPtr = 0u; + } + else + { + *rowCdacFinePtr = 0u; + } + } + #endif + } + } + } + #endif + + /* Phase #4 - Populate CapDAC values to sensor frame structures */ + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + snsFrameIndex = frameSize * (ptrWdCfg->firstSlotId + snsIndex); + ptrSnsCxt = &ptrWdCfg->ptrSnsContext[snsIndex]; + + ptrSnsFrmCdacCtlReg[snsFrameIndex] &= (uint32_t)~(MSCLP_SNS_SNS_CDAC_CTL_SEL_RE_Msk | + MSCLP_SNS_SNS_CDAC_CTL_SEL_CO_Msk | + MSCLP_SNS_SNS_CDAC_CTL_SEL_CF_Msk); + ptrSnsFrmCdacCtlReg[snsFrameIndex] |= (((uint32_t)ptrSnsCxt->cdacComp) << MSCLP_SNS_SNS_CDAC_CTL_SEL_CO_Pos); + ptrSnsFrmCdacCtlReg[snsFrameIndex] |= (((uint32_t)*cdacRefPtr) << MSCLP_SNS_SNS_CDAC_CTL_SEL_RE_Pos); + #if (CY_CAPSENSE_CDAC_FINE_USAGE) + ptrSnsFrmCdacCtlReg[snsFrameIndex] |= (((uint32_t)*cdacFinePtr) << MSCLP_SNS_SNS_CDAC_CTL_SEL_CF_Pos); + #endif + + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + if ((CY_CAPSENSE_CSD_GROUP == sensingGroup) && + (ptrWdCfg->numCols <= snsIndex) && + (((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType) || + ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType))) + { + ptrSnsFrmCdacCtlReg[snsFrameIndex] &= (uint32_t)~(MSCLP_SNS_SNS_CDAC_CTL_SEL_RE_Msk | + MSCLP_SNS_SNS_CDAC_CTL_SEL_CF_Msk); + ptrSnsFrmCdacCtlReg[snsFrameIndex] |= (((uint32_t)*rowCdacRefPtr) << MSCLP_SNS_SNS_CDAC_CTL_SEL_RE_Pos); + #if (CY_CAPSENSE_CDAC_FINE_USAGE) + ptrSnsFrmCdacCtlReg[snsFrameIndex] |= (((uint32_t)*rowCdacFinePtr) << MSCLP_SNS_SNS_CDAC_CTL_SEL_CF_Pos); + #endif + } + #endif + } + + return calibStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanSlotInternalCPU +****************************************************************************//** +* +* Initiates the blocking scan of specified slot in CPU mode. +* +* This function initiates a scan of specified slot in the CPU driven scan +* mode, waits for operation completion and then exits. +* Use of this function is limited to the CapDAC auto-calibration. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param snsFrameType +* The Sensor Frame type: +* * CY_CAPSENSE_SNS_FRAME_ACTIVE - Sensor frame for Active slot +* * CY_CAPSENSE_SNS_FRAME_LOW_POWER - Sensor frame for Low Power slot +* +* \param scanSlotId +* The slot ID scans will be done for. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_CALIBRATION_FAIL - The calibration is failed due to +* the issues with scanning (either +* watchdog timer, interrupt breaking, etc.). +* - CY_CAPSENSE_STATUS_CALIBRATION_CHECK_FAIL - The calibration is failed +* because of rawcount is out of the +* defined range. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanSlotInternalCPU( + uint32_t snsFrameType, + uint32_t scanSlotId, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t result = CY_CAPSENSE_STATUS_SUCCESS; + cy_stc_capsense_internal_context_t * ptrIntrCxt = context->ptrInternalContext; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + cy_stc_capsense_sensor_context_t * ptrSnsCxt; + uint32_t * ptrSensorFrame; + uint32_t tmpRawCount; + uint32_t wdIndex; + uint32_t snsIndex; + uint32_t watchdog; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if (snsFrameType == CY_CAPSENSE_SNS_FRAME_LOW_POWER) + { + ptrSensorFrame = &context->ptrSensorFrameLpContext[(scanSlotId * CY_MSCLP_11_SNS_REGS) + CY_CAPSENSE_FRM_LP_SNS_SW_SEL_CSW_LO_MASK2_INDEX]; + ptrScanSlots = context->ptrLpScanSlots; + } + else + { + ptrSensorFrame = &context->ptrSensorFrameContext[scanSlotId * CY_CAPSENSE_SENSOR_FRAME_SIZE]; + ptrScanSlots = context->ptrScanSlots; + } + #else + ptrSensorFrame = &context->ptrSensorFrameContext[scanSlotId * CY_CAPSENSE_SENSOR_FRAME_SIZE]; + ptrScanSlots = context->ptrScanSlots; + (void) snsFrameType; + #endif + + wdIndex = ptrScanSlots[scanSlotId].wdId; + snsIndex = ptrScanSlots[scanSlotId].snsId; + ptrWdCfg = &context->ptrWdConfig[wdIndex]; + + if((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + (CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder)) + { + result = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_MPSC_SCANNING, context); + } + else + { + result = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING, context); + } + + Cy_CapSense_SetupCpuOperatingMode(context); + + /* Initialize internal context */ + ptrIntrCxt->currentSlotIndex = (uint16_t)scanSlotId; + ptrIntrCxt->endSlotIndex = (uint16_t)scanSlotId; + + /* Set sensor config registers (frame) */ + Cy_CapSense_StartCpuScan(ptrSensorFrame, context); + watchdog = Cy_CapSense_GetScanWatchdogTime(wdIndex, scanSlotId, context); + watchdog = Cy_CapSense_WaitEndOfCpuScan(watchdog, context); + + /* Check if the watchdog timeout happened */ + if(0u == watchdog) + { + result = CY_CAPSENSE_STATUS_CALIBRATION_FAIL; + } + + if (result == CY_CAPSENSE_STATUS_SUCCESS) + { + /* Read raw counts */ + tmpRawCount = ptrHwBase->SNS.RESULT_FIFO_RD; + + ptrSnsCxt = &context->ptrWdConfig[wdIndex].ptrSnsContext[snsIndex]; + ptrSnsCxt->status &= (uint8_t)~CY_CAPSENSE_SNS_OVERFLOW_MASK; + + if (MSCLP_SNS_RESULT_FIFO_RD_OVERFLOW_Msk == (tmpRawCount & MSCLP_SNS_RESULT_FIFO_RD_OVERFLOW_Msk)) + { + ptrSnsCxt->status |= CY_CAPSENSE_SNS_OVERFLOW_MASK; + } + tmpRawCount &= MSCLP_SNS_RESULT_FIFO_RD_RAW_COUNT_Msk; + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) && \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) || (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN))) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType) + { + if ((CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) || + (CY_CAPSENSE_ISX_GROUP == ptrWdCfg->senseMethod)) + { + /* Limit raw counts */ + if (tmpRawCount < ptrWdCfg->ptrWdContext->maxRawCount) + { + /* Invert raw counts for CSX/ISX widgets */ + tmpRawCount = (ptrWdCfg->ptrWdContext->maxRawCount - tmpRawCount); + } + else + { + tmpRawCount = 0u; + } + } + } + #endif + ptrSnsCxt->raw = (uint16_t)tmpRawCount; + } + + /* Disable HW IP */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + return result; +} +#endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_WatchdogCyclesNum +****************************************************************************//** +* +* Converts the specified time into number of CPU cycles. +* +* \param desiredTimeUs +* The time (delay) specified in us. +* +* \param cpuFreqMHz +* The CPU frequency in MHz. +* +* \param cyclesPerLoop +* The number of cycles per a loop. +* +*******************************************************************************/ +uint32_t Cy_CapSense_WatchdogCyclesNum( + uint32_t desiredTimeUs, + uint32_t cpuFreqMHz, + uint32_t cyclesPerLoop) +{ + uint32_t retVal; + + if (0uL != cyclesPerLoop) + { + retVal = (desiredTimeUs * cpuFreqMHz) / cyclesPerLoop; + } + else + { + retVal = 0xFFFFFFFFuL; + } + + return retVal; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SsInitialize +****************************************************************************//** +* +* Performs the hardware and firmware initialization required for proper operation +* of the CAPSENSE™ middleware. This function is called from +* the Cy_CapSense_Init() prior to calling any other function of the middleware. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return status +* Returns the status of the operation (different statuses can be combined): +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed +* successfully. +* - CY_CAPSENSE_STATUS_BAD_CLOCK_CONFIG - Sense Clock Divider is out +* of the valid range +* for the specified Clock source +* configuration. +* - CY_CAPSENSE_STATUS_BAD_PARAM - At least one of input parameters is +* not valid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The MSCLP HW block is busy and cannot be +* configured. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_SsInitialize(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; + uint32_t i; + + capStatus |= Cy_CapSense_InitializeSourceSenseClk(context); + + /* Initialize the MSCLP channel for scan */ + /* Reset the sense method */ + context->ptrActiveScanSns->currentSenseMethod = CY_CAPSENSE_UNDEFINED_GROUP; + context->ptrInternalContext->scanSingleSlot = CY_CAPSENSE_SCAN_MULTIPLE_SLOT; + + /* Configure inactive sensor states */ + context->ptrInternalContext->intrCsdInactSnsConn = ptrCommonCfg->csdInactiveSnsConnection; + context->ptrInternalContext->intrCsxInactSnsConn = ptrCommonCfg->csxInactiveSnsConnection; + context->ptrInternalContext->intrIsxInactSnsConn = ptrCommonCfg->isxInactiveSnsConnection; + + /* Generate base frame configurations for all enabled MSCLP channels */ + capStatus |= Cy_CapSense_GenerateBaseConfig(context); + + /* Generates sensor frame configuration */ + Cy_CapSense_GenerateAllSensorConfig(CY_CAPSENSE_SNS_FRAME_ACTIVE, context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + Cy_CapSense_GenerateAllSensorConfig(CY_CAPSENSE_SNS_FRAME_LOW_POWER, context); + #endif /* CY_CAPSENSE_LP_EN */ + + /* Assign the ISR for scan */ + context->ptrInternalContext->ptrISRCallback = &Cy_CapSense_ScanISR; + + /* Calculate and store wake-on-touch timer value */ + context->ptrInternalContext->wotScanIntervalCycles = + Cy_CapSense_MsclpTimerCalcCycles(context->ptrInternalContext->wotScanInterval, context); + + /* Check if an external start is enabled */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_EXT_FRM_START_EN) + Cy_GPIO_Pin_FastInit(CY_MSCLP0_EXT_FRM_START_PORT, CY_MSCLP0_EXT_FRM_START_PIN, + CY_GPIO_DM_HIGHZ, 0u, HSIOM_SEL_DS_1); + #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_EXT_FRM_START_EN) */ + + /* Call user's callback function if it is registered */ + if (NULL != context->ptrInternalContext->ptrEODsInitCallback) + { + context->ptrInternalContext->ptrEODsInitCallback(context); + } + + /* Resetting the HW configuration in order to trigger the base frame initialization in scope of the + * next Cy_CapSense_SwitchHwConfiguration() function call with the desired HW configuration. + */ + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + capStatus |= Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT, context); + } + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + capStatus |= Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING, context); + } + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_AUTO_EN)) + capStatus |= Cy_CapSense_InitializeCic2Shift(context); + #endif + + /* Find maximum raw count for each widget */ + for (i = 0u; i < CY_CAPSENSE_TOTAL_WIDGET_COUNT; i++) + { + if (0u != Cy_CapSense_IsWidgetEnabled(i, context)) + { + capStatus |= Cy_CapSense_InitializeMaxRaw(i, context); + } + } + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_InterruptHandler_V3Lp +****************************************************************************//** +* +* Implements the interrupt service routine (ISR) for the Fifth generation low power +* CAPSENSE™. +* +* At the end of the whole frame scan, the MSCLP HW block generates interrupts +* (for the frame while regular widget scanning and for the time-out number of frames +* or for signal detection while low power widget scanning). The ISR distinguishes +* these interrupts and reads raw counts into the Data structure respectively, and +* then exits if no other slots to scan left, +* Otherwise - starts a scan for the next set of regular sensors. The HW MRSS is turned +* off after the last regular widget scan. +* +* The CAPSENSE™ middleware uses this interrupt to implement the +* non-blocking sensor scan method, in which only the first frame scan is +* initiated in the interrupt service routine as soon as the current frame scan +* completes. The interrupt service routine is implemented +* as a part of the CAPSENSE™ middleware. +* +* The CAPSENSE™ middleware does not initialize or modify the priority +* of interrupts - instead, the application program +* configures an MSCLP interrupt and assigns the interrupt vector to +* the Cy_CapSense_InterruptHandler() function. For details, refer to the function +* usage example. +* +* \note +* This function is available only for the fifth-generation low power +* CAPSENSE™. +* +* The call of the End Of Scan callback (for details, see the \ref group_capsense_callbacks +* section) is the part of the Cy_CapSense_InterruptHandler() routine +* and that call lengthens its execution. Such a callback lengthens the MSCLP ISR execution +* in the case of a direct call of the Cy_CapSense_InterruptHandler() function +* from a MSCLP ISR. +* +* \param base +* The pointer to the base register address of the MSCLP HW block. +* This argument is kept for uniformity and backward compatibility +* and is not used. The function can be called with value NULL. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \funcusage +* +* An example of the ISR initialization: +* +* The CapSense_ISR_cfg variable should be declared by the application +* program according to the examples below:
+* For Core CM0+: +* \snippet capsense/snippet/main.c snippet_m0p_capsense_interrupt_source_declaration +* +* The CAPSENSE™ interrupt handler should be defined by the application program +* according to the example below: +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_IntHandler +* +* Then, the application program configures and enables the interrupt +* for each MSCLP HW block between calls of the Cy_CapSense_Init() and +* Cy_CapSense_Enable() functions: +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_Initialization +* +*******************************************************************************/ +void Cy_CapSense_InterruptHandler_V3Lp(const MSCLP_Type * base, cy_stc_capsense_context_t * context) +{ + (void)base; + context->ptrInternalContext->ptrISRCallback((void *)context); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanISR +****************************************************************************//** +* +* This is an internal ISR function to handle the MSCLP sensing +* in AS_MS and LP_AoS operating modes. +* +* \param capsenseContext +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_ScanISR(void * capsenseContext) +{ + cy_stc_capsense_context_t * cxt = (cy_stc_capsense_context_t *)capsenseContext; + MSCLP_Type * ptrHwBase = cxt->ptrCommonConfig->ptrChConfig->ptrHwBase; + cy_stc_capsense_internal_context_t * ptrIntrCxt = cxt->ptrInternalContext; + uint32_t numScanSlots; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + /* Check for interrupt source: MSCLP_INTR_LP_FRAME_Msk for ACTIVE widget scan */ + if (MSCLP_INTR_LP_FRAME_Msk != (ptrHwBase->INTR_LP & ptrHwBase->INTR_LP_MASK & MSCLP_INTR_LP_FRAME_Msk)) + { + /* It was the low power scan - check if a signal detection had occurred */ + if (MSCLP_INTR_LP_SIG_DET_Msk == (ptrHwBase->INTR_LP & MSCLP_INTR_LP_SIG_DET_Msk)) + { + cxt->ptrCommonContext->status |= (uint32_t)CY_CAPSENSE_MW_STATE_LP_ACTIVE_MASK; + } + + /* Clear all pending interrupts of the MSCLP HW block */ + ptrHwBase->INTR_LP = CY_CAPSENSE_MSCLP_INTR_LP_ALL_MSK; + + /* Read the last low power frame raw counts */ + if((cxt->ptrCommonContext->lpDataSt & CY_CAPSENSE_LP_PROCESS_ENABLED_MASK) != 0u) + { + Cy_CapSense_TransferLpRawCounts(ptrIntrCxt->currentSlotIndex, ptrIntrCxt->numSlots, cxt); + + /* Mark completion of low power scan cycle */ + cxt->ptrCommonContext->lpScanCounter++; + } + + /* Disable HW IP */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Stop the MRSS to save power */ + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_STOP_Msk; + + Cy_CapSense_ClrBusyFlags(cxt); + } + else + #endif + { + /* Clear all pending interrupts of the MSCLP HW block */ + ptrHwBase->INTR_LP = CY_CAPSENSE_MSCLP_INTR_LP_ALL_MSK; + + /* Read the last ACTIVE frame raw counts */ + Cy_CapSense_TransferRawCounts(ptrIntrCxt->currentSlotIndex, ptrIntrCxt->numSlots, cxt); + + ptrIntrCxt->currentSlotIndex += ptrIntrCxt->numSlots; + + /* Check for the last slot with multiple slot scan, if not - start the next slot scan */ + if (ptrIntrCxt->currentSlotIndex <= ptrIntrCxt->endSlotIndex) + { + numScanSlots = (uint32_t)ptrIntrCxt->endSlotIndex - (uint32_t)ptrIntrCxt->currentSlotIndex + 1uL; + + /* Disable delay before next scan */ + ptrHwBase->AOS_CTL &= ~MSCLP_AOS_CTL_WAKEUP_TIMER_Msk; + + /* Clear the first sub-frame flag */ + ptrIntrCxt->firstActSubFrame = CY_CAPSENSE_DISABLE; + + Cy_CapSense_ScanSlotsInternal(ptrIntrCxt->currentSlotIndex, numScanSlots, cxt); + } + else + { + /* Disable HW IP to allow MRSS operations */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Stop the MRSS to save power */ + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_STOP_Msk; + + /* Mark completion of active scan cycle */ + cxt->ptrCommonContext->scanCounter++; + + Cy_CapSense_ClrBusyFlags(cxt); + } + } +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SetCmodInDesiredState +****************************************************************************//** +* +* Sets all available MSCLP Cmod pins into a desired state. +* +The default state to provide the fifth generation low power CAPSENSE™ operation is: +* - HSIOM - Disconnected, the GPIO mode. +* - DM - High-Z Analog, Input off drive mode. +* - MSC_ANA - Enabled. +* +* Do not call this function directly from the application program. +* +* \param desiredDriveMode +* Specifies the desired pin control port (PC) configuration. +* +* \param desiredHsiom +* Specifies the desired pin HSIOM state. +* +* \param desiredMscCtrl +* Specifies the desired (MSC_ANA) control status of the IO port analog signaling by the MSC. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_SetCmodInDesiredState( + uint32_t desiredDriveMode, + en_hsiom_sel_t desiredHsiom, + uint32_t desiredMscCtrl, + const cy_stc_capsense_context_t * context) +{ + Cy_CapSense_SsConfigPinRegisters( + context->ptrCommonConfig->ptrChConfig->portCmod1, + (uint32_t)context->ptrCommonConfig->ptrChConfig->pinCmod1, + desiredDriveMode, desiredHsiom, desiredMscCtrl); + + Cy_CapSense_SsConfigPinRegisters( + context->ptrCommonConfig->ptrChConfig->portCmod2, + (uint32_t)context->ptrCommonConfig->ptrChConfig->pinCmod2, + desiredDriveMode, desiredHsiom, desiredMscCtrl); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SetIOsInDesiredState +****************************************************************************//** +* +* Sets all CAPSENSE™ pins into a desired state. +* +* The default state to provide the fifth generation low power CAPSENSE™ operation is: +* - HSIOM - Disconnected, the GPIO mode. +* - DM - Strong drive. +* - MSC_ANA - Enabled. +* - State - Zero. +* +* Do not call this function directly from the application program. +* +* \param desiredDriveMode +* Specifies the desired pin control port (PC) configuration. +* +* \param desiredHsiom +* Specifies the desired pin HSIOM state. +* +* \param desiredPinOutput +* Specifies the desired pin output data register (DR) state. +* +* \param desiredMscCtrl +* Specifies the desired (MSC_ANA) control status of the IO port analog signaling by the MSC. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_SetIOsInDesiredState( + uint32_t desiredDriveMode, + en_hsiom_sel_t desiredHsiom, + uint32_t desiredPinOutput, + uint32_t desiredMscCtrl, + const cy_stc_capsense_context_t * context) +{ + uint32_t loopIndex; + const cy_stc_capsense_pin_config_t * ptrPinCfg = context->ptrPinConfig; + + /* Loop through all electrodes */ + for (loopIndex = 0u; loopIndex < context->ptrCommonConfig->numPin; loopIndex++) + { + Cy_CapSense_SsConfigPinRegisters(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber, + desiredDriveMode, desiredHsiom, desiredMscCtrl); + + if (0u != desiredPinOutput) + { + Cy_GPIO_Set(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber); + } + else + { + Cy_GPIO_Clr(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber); + } + + /* Get next electrode */ + ptrPinCfg++; + } +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SetShieldPinsInDesiredState +****************************************************************************//** +* +* Sets all shield pins into a default state. +* +* Do not call this function directly from the application program. +* +* \param desiredDriveMode +* Specifies the desired pin control port (PC) configuration. +* +* \param desiredHsiom +* Specifies the desired pin HSIOM state. +* +* \param desiredMscCtrl +* Specifies the desired (MSC_ANA) control status of the IO port analog signaling by the MSC. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_SetShieldPinsInDesiredState( + uint32_t desiredDriveMode, + en_hsiom_sel_t desiredHsiom, + uint32_t desiredMscCtrl, + const cy_stc_capsense_context_t * context) +{ + uint32_t loopIndex; + const cy_stc_capsense_pin_config_t * ptrPinCfg = context->ptrShieldPinConfig; + + /* Loop through all shield electrodes */ + for (loopIndex = 0u; loopIndex < context->ptrCommonConfig->csdShieldNumPin; loopIndex++) + { + Cy_CapSense_SsConfigPinRegisters(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber, + desiredDriveMode, desiredHsiom, desiredMscCtrl); + + Cy_GPIO_Clr(ptrPinCfg->pcPtr, (uint32_t)ptrPinCfg->pinNumber); + ptrPinCfg++; + } +} + + + +/******************************************************************************* +* Function Name: Cy_CapSense_InitActivePtr +****************************************************************************//** +* +* Initializes active scan sensor structure with all available +* pointers for further faster access to widget/sensor parameters. +* +* \param widgetId +* Specifies the ID number of the widget. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param sensorId +* Specifies the ID number of the sensor within the widget. A macro for the +* sensor ID within a specified widget can be found in the cycfg_capsense.h +* file defined as CY_CAPSENSE__SNS_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_InitActivePtr( + uint32_t widgetId, + uint32_t sensorId, + cy_stc_capsense_context_t * context) +{ + Cy_CapSense_InitActivePtrWd(widgetId, context); + Cy_CapSense_InitActivePtrSns(sensorId, context); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_InitActivePtrSns +****************************************************************************//** +* +* Initializes active scan sensor structure with pointers to sensor +* for further faster access to widget/sensor parameters. +* +* This function supposes that the Cy_CapSense_InitActivePtrWd() function +* is called before. +* +* \param sensorId +* Specifies the ID number of the sensor within the widget. A macro for the +* sensor ID within a specified widget can be found in the cycfg_capsense.h +* file defined as CY_CAPSENSE__SNS_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_InitActivePtrSns( + uint32_t sensorId, + cy_stc_capsense_context_t * context) +{ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + #endif + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) + uint32_t widgetSenseGroup = ptrActive->currentSenseMethod; + ptrActive->connectedSnsState = CY_CAPSENSE_SNS_DISCONNECTED; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + uint32_t numberRows; + uint32_t numberCols; + #endif + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN)) + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[ptrActive->widgetIndex]; + #endif + #endif + + #if !(CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) + (void)context; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) + ptrActive->ptrSnsContext = &context->ptrWdConfig[ptrActive->widgetIndex].ptrSnsContext[sensorId]; + #else + (void)sensorId; + #endif + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) + switch (widgetSenseGroup) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case (uint8_t)CY_CAPSENSE_CSD_GROUP: + ptrActive->ptrEltdConfig = &ptrWdCfg->ptrEltdConfig[sensorId]; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case (uint8_t)CY_CAPSENSE_CSX_GROUP: + numberRows = ptrWdCfg->numRows; + numberCols = ptrWdCfg->numCols; + ptrActive->ptrRxConfig = &ptrWdCfg->ptrEltdConfig[sensorId / numberRows]; + ptrActive->ptrTxConfig = &ptrWdCfg->ptrEltdConfig[numberCols + (sensorId % numberRows)]; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + + default: + /* Widget type is not valid so nothing to do */ + break; + } + #endif +} + +/******************************************************************************* +* Function Name: Cy_CapSense_InitActivePtrWd +****************************************************************************//** +* +* Initializes active scan sensor structure with pointers to current widget +* for further faster access to widget/sensor parameters. +* +* This function does not update pointers to current sensor and the +* Cy_CapSense_InitActivePtrSns() function should be called after current one. +* +* \param widgetId +* Specifies the ID number of the widget. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_InitActivePtrWd( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN) + ptrActive->widgetIndex = (uint8_t)widgetId; + #endif + + ptrActive->currentSenseMethod = context->ptrWdConfig[widgetId].senseMethod; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SsConfigPinRegisters +****************************************************************************//** +* +* Configures drive mode and HSIOM state of a desired pin. The action +* is performed inside the critical section. +* +* \param base +* The pointer to the pin's port register base address. +* +* \param pinNum +* Position of the pin bit-field within the port register. +* +* \param dm +* Specifies drive mode of the pin. +* +* \param hsiom +* Specifies HSIOM state of the pin. +* * +* \param mscCtrl +* Specifies MSC_ANA control state of the IO port analog signaling by the MSC. +* +*******************************************************************************/ +void Cy_CapSense_SsConfigPinRegisters( + GPIO_PRT_Type * base, + uint32_t pinNum, + uint32_t dm, + en_hsiom_sel_t hsiom, + uint32_t mscCtrl) +{ + uint32_t interruptState = Cy_SysLib_EnterCriticalSection(); + if (CY_CAPSENSE_HSIOM_SEL_GPIO == hsiom) + { + Cy_GPIO_SetHSIOM(base, pinNum, hsiom); + Cy_GPIO_SetDrivemode(base, pinNum, dm); + } + else + { + Cy_GPIO_SetDrivemode(base, pinNum, dm); + Cy_GPIO_SetHSIOM(base, pinNum, hsiom); + } + + if (CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_DIS != mscCtrl) + { + Cy_GPIO_MscControlEnable(base, pinNum); + } + else + { + Cy_GPIO_MscControlDisable(base, pinNum); + } + Cy_SysLib_ExitCriticalSection(interruptState); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ScanAbort_V3Lp +****************************************************************************//** +* +* This function sets the sequencer to the idle state by resetting the hardware, +* it can be used to abort current active or low power scan. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \note +* If this function is called from ISR during initialization or +* auto-calibration the operation of these functions will be corrupted. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation \ref cy_capsense_status_t. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanAbort_V3Lp(cy_stc_capsense_context_t * context) +{ + uint32_t interruptState; + const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; + const cy_stc_capsense_channel_config_t * ptrChannelCfg = ptrCommonCfg->ptrChConfig; + + interruptState = Cy_SysLib_EnterCriticalSection(); + + /* Disable HW IP to allow MRSS operations */ + ptrChannelCfg->ptrHwBase->CTL &= ~MSCLP_CTL_ENABLED_Msk; + + /* Wait until ENABLE bit is cleared */ + while (0uL != (MSCLP_CTL_ENABLED_Msk & ptrChannelCfg->ptrHwBase->CTL)) {} + + /* Clear all pending interrupts of the MSCLP HW block */ + ptrChannelCfg->ptrHwBase->INTR_LP = CY_CAPSENSE_MSCLP_INTR_ALL_MSK; + (void)ptrChannelCfg->ptrHwBase->INTR_LP; + + Cy_SysLib_ExitCriticalSection(interruptState); + + /* Wait for possible MRSS status change */ + Cy_SysLib_DelayUs(CY_MSCLP_CLK_LF_PERIOD_MAX * CY_MSCLP_MRSS_TIMEOUT_FULL); + + /* Set required MRSS state */ + if (CY_CAPSENSE_MRSS_TURN_ON == context->ptrInternalContext->mrssStateAfterScan) + { + if (0u == (ptrCommonCfg->ptrChConfig->ptrHwBase->MRSS_STATUS & MSCLP_MRSS_STATUS_MRSS_UP_Msk)) + { + ptrCommonCfg->ptrChConfig->ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_START_Msk; + (void)Cy_CapSense_WaitMrssStatusChange(CY_MSCLP_CLK_LF_PERIOD_MAX * CY_MSCLP_MRSS_TIMEOUT_SMALL, CY_CAPSENSE_MRSS_TURN_ON, context); + } + } + else + { + if (0u != (ptrCommonCfg->ptrChConfig->ptrHwBase->MRSS_STATUS & MSCLP_MRSS_STATUS_MRSS_UP_Msk)) + { + ptrCommonCfg->ptrChConfig->ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_STOP_Msk; + (void)Cy_CapSense_WaitMrssStatusChange((CY_MSCLP_CLK_LF_PERIOD_MAX * CY_CAPSENSE_MULTIPLIER_TWO), CY_CAPSENSE_MRSS_TURN_OFF, context); + } + } + + context->ptrCommonContext->status = CY_CAPSENSE_NOT_BUSY; + + return CY_CAPSENSE_STATUS_SUCCESS; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_MwState_V3Lp +****************************************************************************//** +* +* This function returns a detailed state of the CAPSENSE™ middleware and MSC +* hardware in Single- or Multi-channel mode. This feature is useful in +* multi-thread applications or in ISR. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* If the middleware is busy, a new scan, setup widgets, any kind of reconfiguration, +* or parameter change should not be initiated. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the state of the middleware as a sum of the state and status masks: +* +* - CY_CAPSENSE_BUSY_CH_MASK - The set [x] bit of the result +* means that the previously initiated +* scan for the [x] channel is in progress. +* The next scan frame cannot be started. +* - CY_CAPSENSE_MW_STATE_ACTIVE_WD_SCAN_MASK - The last or currently scanned widget +* type is Active widget. +* - CY_CAPSENSE_MW_STATE_LP_WD_SCAN_MASK - The last or currently scanned widget +* type is Low Power widget +* - CY_CAPSENSE_BUSY - The previously initiated scan is +* in progress. +* - CY_CAPSENSE_MW_STATE_BIST_MASK - The BIST is in progress. +* The next scan frame cannot be started. +* - CY_CAPSENSE_MW_STATE_CALIBRATION_MASK - The auto-calibration is in progress. +* The next scan frame cannot be started. +* - CY_CAPSENSE_MW_STATE_SMARTSENSE_MASK - The smart sensing algorithm is +* in progress. +* The next scan frame cannot be started. +* - CY_CAPSENSE_MW_STATE_INITIALIZATION_MASK - Middleware initialization is +* in progress and the next scan frame +* cannot be initiated. +* - CY_CAPSENSE_MW_STATE_SCAN_SLOT_MASK[x] - The set [x] number of the result +* means that the previously initiated +* scan for the [x] slot is completed +* or in progress. +* +*******************************************************************************/ +cy_capsense_mw_state_t Cy_CapSense_MwState_V3Lp(const cy_stc_capsense_context_t * context) +{ + return ((context->ptrCommonContext->status & ~CY_CAPSENSE_MW_STATE_SCAN_SLOT_MASK) | + ((uint32_t)context->ptrInternalContext->currentSlotIndex << CY_CAPSENSE_MW_STATE_SCAN_SLOT_POS)); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SetBusyFlags +****************************************************************************//** +* +* Sets BUSY flags of the cy_capsense_context.status register specified +* by the flags parameter. +* +* This is an internal function. Do not call this function directly from +* the application program. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_SetBusyFlags(cy_stc_capsense_context_t * context) +{ + context->ptrCommonContext->status |= (((uint32_t)CY_CAPSENSE_BUSY_CH_MASK) | CY_CAPSENSE_BUSY); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ClrBusyFlags +****************************************************************************//** +* +* Clears BUSY flags of the cy_capsense_context.status register specified +* by the flags parameter. +* +* This is an internal function. Do not call this function directly from +* the application program. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_ClrBusyFlags(cy_stc_capsense_context_t * context) +{ + /* Clear busy flag for the current channel */ + context->ptrCommonContext->status &= (uint32_t)(~((uint32_t)CY_CAPSENSE_BUSY_CH_MASK)); + context->ptrCommonContext->status &= ~CY_CAPSENSE_BUSY; + + /* Check for EndOfScan callback */ + if (NULL != context->ptrInternalContext->ptrEOSCallback) + { + context->ptrInternalContext->ptrEOSCallback(NULL); + } +} + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) +/******************************************************************************* +* Function Name: Cy_CapSense_CalibrateCompDivider +****************************************************************************//** +* +* This function adjusts the compensation CDAC divider for the specified widget. +* +* The function scans all widget sensors with fixed reference CDAC and maximum +* compensation CDAC values starting from the compensation CDAC divider value +* equal to the snsClk divider (Kcomp = snsClkDiv / CompDiv = 1). If raw counts +* are over the raw target, the function decreases compensation CDAC divider +* value providing Kcomp as integer until raw counts are less than the raw +* target. +* +* The function does not consider multi-frequency feature. I.e. only the first +* (base) frequency channel is used. +* +* \param widgetId +* Specifies the desired widget ID. +* +* \param target +* The calibrated sensor raw target. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* The compensation CDAC divider is adjusted +* for the specified widget. +* - CY_CAPSENSE_STATUS_CALIBRATION_FAIL - The compensation CDAC divider can not be +* adjusted for the specified widget. +* - CY_CAPSENSE_STATUS_BAD_PARAM - Invalid parameter(s). +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_CalibrateCompDivider( + uint32_t widgetId, + uint32_t target, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t calibStatus = CY_CAPSENSE_STATUS_SUCCESS; + uint32_t curSlotIndex; + uint32_t numSlots; + uint32_t snsOverflow = 0u; + uint32_t snsIndex; + uint32_t rawTemp; + uint32_t frameType; + uint32_t rawTarget; + uint32_t j; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + uint32_t dummyScanFlagEn = 1u; + #endif + + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; + uint32_t compDivDefault = ptrWdCfg->ptrWdContext->snsClk; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType) + { + numSlots = CY_CAPSENSE_SLOT_LP_COUNT; + frameType = CY_CAPSENSE_SNS_FRAME_LOW_POWER; + ptrScanSlots = context->ptrLpScanSlots; + } + else + { + numSlots = CY_CAPSENSE_SLOT_COUNT; + frameType = CY_CAPSENSE_SNS_FRAME_ACTIVE; + ptrScanSlots = context->ptrScanSlots; + } + #else + numSlots = CY_CAPSENSE_SLOT_COUNT; + frameType = CY_CAPSENSE_SNS_FRAME_ACTIVE; + ptrScanSlots = context->ptrScanSlots; + #endif + + /* Sets Max CompCDAC Code within specified widget */ + for (j = 0u; j < ptrWdCfg->numSns; j++) + { + ptrWdCfg->ptrSnsContext[j].cdacComp = CY_CAPSENSE_CDAC_MAX_CODE; + } + Cy_CapSense_SetMaxCompCdac(widgetId, context); + + /* Defines initial value for Compensation Divider including rows and cols */ + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || + ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType))) + { + if (compDivDefault > ptrWdCfg->ptrWdContext->rowSnsClk) + { + compDivDefault = ptrWdCfg->ptrWdContext->rowSnsClk; + } + } + else + { + /* Initializes unused rowSnsClk for further optimization */ + ptrWdCfg->ptrWdContext->rowSnsClk = ptrWdCfg->ptrWdContext->snsClk; + } + #else + /* Initializes unused rowSnsClk for further optimization */ + ptrWdCfg->ptrWdContext->rowSnsClk = ptrWdCfg->ptrWdContext->snsClk; + #endif + + /* Recalculate maxRawCount accordingly to frequency channel */ + rawTarget = (target * ptrWdCfg->ptrWdContext->maxRawCount) / CY_CAPSENSE_PERCENTAGE_100; + + compDivDefault++; + + /* + * Loop through all Compensation Divider values in descending order. + * + * Loop ends when CompDiv value equal 1 or Calibration fails. + * Switches to the next iteration is done when kComp is not an integer + * or calibration overflows. + */ + do + { + /* Switches to the next possible divider */ + compDivDefault--; + /* Checks if divider is valid */ + if (((ptrWdCfg->ptrWdContext->snsClk % compDivDefault) != 0u) || + ((ptrWdCfg->ptrWdContext->rowSnsClk % compDivDefault) != 0u)) + { + continue; + } + + ptrWdCfg->ptrWdContext->cdacCompDivider = (uint16_t)compDivDefault; + Cy_CapSense_SetCompDivider(widgetId, context); + + snsOverflow = 0u; + for (curSlotIndex = 0u; curSlotIndex < numSlots; curSlotIndex++) + { + /* Checks only the specified widget in the current slot */ + if (widgetId == ptrScanSlots[curSlotIndex].wdId) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + /* Dummy scan */ + if ((0u != dummyScanFlagEn) && (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod)) + { + calibStatus |= Cy_CapSense_ScanSlotInternalCPU(frameType, curSlotIndex, context); + dummyScanFlagEn = 0u; + } + #endif + + calibStatus |= Cy_CapSense_ScanSlotInternalCPU(frameType, curSlotIndex, context); + + snsIndex = ptrScanSlots[curSlotIndex].snsId; + Cy_CapSense_PreProcessSensor(widgetId, snsIndex, context); + rawTemp = ptrWdCfg->ptrSnsContext[snsIndex].raw; + + switch (ptrWdCfg->senseMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + /* Skip the CSD case for MPSC widgets */ + if (CY_CAPSENSE_MPSC_MIN_ORDER > ptrWdCfg->mpOrder) + #endif + { + if (rawTemp > rawTarget) + { + snsOverflow = 1u; + } + break; + } + #endif + + default: + if (rawTemp <= rawTarget) + { + snsOverflow = 1u; + } + break; + } + + if (0u != snsOverflow) + { + /* If at least one sensor of the specified widget has + * Raw Count too high (no enough compensation level) + * then switch to the next compensation divider value. + */ + break; + } + } + } + /* Finish the searching if no overflow across all sensors of the specified widget */ + if (0u == snsOverflow) + { + break; + } + } while ((compDivDefault > CY_CAPSENSE_CDAC_COMP_DIV_MIN_MSCLP) && + (CY_CAPSENSE_STATUS_SUCCESS == calibStatus)); + + return calibStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_VerifyCalibration +****************************************************************************//** +* +* Verifies that the calibrated widgets meets the configured conditions. +* +* This function checks whether raw count of each sensor of the specified widgets +* is within the raw count range defined by raw count target and +/- calibration +* error. +* +* \param widgetId +* Specifies the desired widget ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_VerifyCalibration( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + uint32_t snsIndex; + uint32_t temp; + uint32_t lowerLimit; + uint32_t upperLimit; + uint32_t target; + uint32_t calibrationError; + uint32_t currSlot; + uint32_t frameType; + cy_capsense_status_t calibStatus = CY_CAPSENSE_STATUS_SUCCESS; + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; + const cy_stc_capsense_sensor_context_t * ptrSnsCxt = ptrWdCfg->ptrSnsContext; + + frameType = ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType) ? + (CY_CAPSENSE_SNS_FRAME_LOW_POWER) : (CY_CAPSENSE_SNS_FRAME_ACTIVE); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + /* Dummy scan */ + if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) + { + calibStatus |= Cy_CapSense_ScanSlotInternalCPU(frameType, ptrWdCfg->firstSlotId, context); + } + #endif + + for (currSlot = ptrWdCfg->firstSlotId; currSlot < ((uint32_t)ptrWdCfg->firstSlotId + ptrWdCfg->numSlots); currSlot++) + { + calibStatus |= Cy_CapSense_ScanSlotInternalCPU(frameType, currSlot, context); + } + + Cy_CapSense_PreProcessWidget(widgetId, context); + + if (CY_CAPSENSE_STATUS_SUCCESS == calibStatus) + { + /* Calculate acceptable raw count range based on the resolution, target and error */ + lowerLimit = 0u; + + /* Gets target in percentage */ + switch (ptrWdCfg->senseMethod) + { + #if (CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE) + case (uint8_t)CY_CAPSENSE_CSD_GROUP: + target = context->ptrInternalContext->intrCsdRawTarget; + calibrationError = context->ptrCommonConfig->csdCalibrationError; + break; + #endif + + #if (CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE) + case (uint8_t)CY_CAPSENSE_CSX_GROUP: + target = context->ptrInternalContext->intrCsxRawTarget; + calibrationError = context->ptrCommonConfig->csxCalibrationError; + break; + #endif + + #if (CY_CAPSENSE_ISX_CDAC_CALIBRATION_USAGE) + case (uint8_t)CY_CAPSENSE_ISX_GROUP: + target = context->ptrInternalContext->intrIsxRawTarget; + calibrationError = context->ptrCommonConfig->isxCalibrationError; + break; + #endif + + default: + /* Widget type is not valid */ + target = 0u; + calibrationError = 0u; + calibStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + break; + } + + if (target > calibrationError) + { + lowerLimit = target - calibrationError; + } + upperLimit = target + calibrationError; + if (upperLimit > CY_CAPSENSE_PERCENTAGE_100) + { + upperLimit = CY_CAPSENSE_PERCENTAGE_100; + } + + /* Finds max raw count value */ + temp = context->ptrWdContext[widgetId].maxRawCount; + + /* Checks raw count of each sensor */ + ptrSnsCxt = &ptrWdCfg->ptrSnsContext[0u]; + switch (ptrWdCfg->senseMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + for (snsIndex = 0u; snsIndex < ptrWdCfg->numCols; snsIndex++) + { + if ((ptrSnsCxt->raw < ((temp * lowerLimit) / CY_CAPSENSE_PERCENTAGE_100)) || + (ptrSnsCxt->raw > ((temp * upperLimit) / CY_CAPSENSE_PERCENTAGE_100))) + { + calibStatus |= CY_CAPSENSE_STATUS_CALIBRATION_CHECK_FAIL; + break; + } + ptrSnsCxt++; + } + temp = context->ptrWdContext[widgetId].maxRawCountRow; + + for (snsIndex = ptrWdCfg->numCols; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + if ((ptrSnsCxt->raw < ((temp * lowerLimit) / CY_CAPSENSE_PERCENTAGE_100)) || + (ptrSnsCxt->raw > ((temp * upperLimit) / CY_CAPSENSE_PERCENTAGE_100))) + { + calibStatus |= CY_CAPSENSE_STATUS_CALIBRATION_CHECK_FAIL; + break; + } + ptrSnsCxt++; + } + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) + case CY_CAPSENSE_CSX_GROUP: + case CY_CAPSENSE_ISX_GROUP: + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + if ((ptrSnsCxt->raw < ((temp * lowerLimit) / CY_CAPSENSE_PERCENTAGE_100)) || + (ptrSnsCxt->raw > ((temp * upperLimit) / CY_CAPSENSE_PERCENTAGE_100))) + { + calibStatus |= CY_CAPSENSE_STATUS_CALIBRATION_CHECK_FAIL; + break; + } + ptrSnsCxt++; + } + break; + #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) */ + + default: + calibStatus |= CY_CAPSENSE_STATUS_BAD_PARAM; + /* No action */ + break; + } + } + + return calibStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SetCompDivider +****************************************************************************//** +* +* Sets the desired Compensation divider into sensor frames. +* +* This function takes Compensation Divider value from widget structure and +* applies it to all widget's sensors in sensor frame structures. +* This function must not be called when AMUX mode is configured. +* +* \param widgetId +* Specifies widget ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_SetCompDivider( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + uint32_t i; + uint32_t * currentFramePtr; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + uint32_t compensationCdacDivider = context->ptrWdContext[widgetId].cdacCompDivider; + + if (0uL != compensationCdacDivider) + { + compensationCdacDivider--; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if (((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == context->ptrWdConfig[widgetId].wdType)) + { + ptrScanSlots = context->ptrLpScanSlots; + currentFramePtr = &context->ptrSensorFrameLpContext[CY_CAPSENSE_FRM_LP_SNS_SCAN_CTL_INDEX]; + + for (i = 0u; i < CY_CAPSENSE_SLOT_LP_COUNT; i++) + { + if (ptrScanSlots->wdId == widgetId) + { + *currentFramePtr &= ~MSCLP_SNS_SNS_SCAN_CTL_COMP_DIV_Msk; + *currentFramePtr |= (uint32_t)(compensationCdacDivider << MSCLP_SNS_SNS_SCAN_CTL_COMP_DIV_Pos); + } + ptrScanSlots++; + currentFramePtr = ¤tFramePtr[CY_MSCLP_11_SNS_REGS]; + } + } + else + #endif + { + ptrScanSlots = context->ptrScanSlots; + currentFramePtr = &context->ptrSensorFrameContext[CY_CAPSENSE_SNS_SCAN_CTL_INDEX]; + + for (i = 0u; i < CY_CAPSENSE_SLOT_COUNT; i++) + { + if (ptrScanSlots->wdId == widgetId) + { + *currentFramePtr &= ~MSCLP_SNS_SNS_SCAN_CTL_COMP_DIV_Msk; + *currentFramePtr |= (uint32_t)(compensationCdacDivider << MSCLP_SNS_SNS_SCAN_CTL_COMP_DIV_Pos); + } + ptrScanSlots++; + currentFramePtr = ¤tFramePtr[CY_CAPSENSE_SENSOR_FRAME_SIZE]; + } + } +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SetMaxCompCdac +****************************************************************************//** +* +* Sets the maximum Compensation CDAC code into sensor frames. +* +* This function applies maximum Compensation CDAC code for all +* sensors within specified widget in sensor frame structures. +* This function must not be called when AMUX mode is configured. +* +* \param widgetId +* Specifies widget ID. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* +*******************************************************************************/ +void Cy_CapSense_SetMaxCompCdac( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + uint32_t i; + uint32_t * currentFramePtr; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if (((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == context->ptrWdConfig[widgetId].wdType)) + { + ptrScanSlots = context->ptrLpScanSlots; + currentFramePtr = &context->ptrSensorFrameLpContext[CY_CAPSENSE_FRM_LP_SNS_CDAC_CTL_INDEX]; + + for (i = 0u; i < CY_CAPSENSE_SLOT_LP_COUNT; i++) + { + if (ptrScanSlots->wdId == widgetId) + { + *currentFramePtr |= MSCLP_SNS_SNS_CDAC_CTL_SEL_CO_Msk; + } + ptrScanSlots++; + currentFramePtr = ¤tFramePtr[CY_MSCLP_11_SNS_REGS]; + } + } + else + #endif + { + ptrScanSlots = context->ptrScanSlots; + currentFramePtr = &context->ptrSensorFrameContext[CY_CAPSENSE_SNS_CDAC_CTL_INDEX]; + + for (i = 0u; i < CY_CAPSENSE_SLOT_COUNT; i++) + { + if (ptrScanSlots->wdId == widgetId) + { + *currentFramePtr |= MSCLP_SNS_SNS_CDAC_CTL_SEL_CO_Msk; + } + ptrScanSlots++; + currentFramePtr = ¤tFramePtr[CY_CAPSENSE_SENSOR_FRAME_SIZE]; + } + } +} +#endif + + +/******************************************************************************* +* Function Name: Cy_CapSense_WaitEndScan +****************************************************************************//** +* +* Waits till end of scan or till the provided timeout. +* +* \param timeout +* Watchdog timeout in microseconds. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_TIMEOUT - The software watchdog timeout occurred +* during the scan, the scan was not completed. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_WaitEndScan( + uint32_t timeout, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t status = CY_CAPSENSE_STATUS_BAD_PARAM; + + /* Approximate duration of Wait For Scan */ + uint32_t isBusyLoopDuration = CY_CAPSENSE_APPROX_LOOP_DURATION; + + uint32_t cpuFreqMHz; + uint32_t watchdogCounter; + + if (NULL != context) + { + status = CY_CAPSENSE_STATUS_SUCCESS; + cpuFreqMHz = context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA; + + /* Init Watchdog Counter to prevent a hang */ + watchdogCounter = Cy_CapSense_WatchdogCyclesNum(timeout, cpuFreqMHz, isBusyLoopDuration); + while (CY_CAPSENSE_NOT_BUSY != Cy_CapSense_IsBusy(context)) + { + if (0uL == watchdogCounter) + { + status = CY_CAPSENSE_STATUS_TIMEOUT; + break; + } + watchdogCounter--; + } + } + + return status; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SlotPinStateInternal +****************************************************************************//** +* +* Configures the desired electrode to the specified state by +* updating the CAPSENSE™ configuration. +* +* See detailed descriptions for the Cy_CapSense_SlotPinState() and +* Cy_CapSense_LpSlotPinState() functions. +* +* \param ptrSnsFrm +* The pointer for sensor frame (Active or Low Power) context structure. +* +* \param ptrEltdCfg +* The pointer to an electrode the all pins states of which will be configured +* as pinState parameter. +* +* \param pinState +* The desired pins state for CSX widget electrodes: +* * CY_CAPSENSE_PIN_STATE_IDX_CSX_RX - Rx electrode. +* * CY_CAPSENSE_PIN_STATE_IDX_CSX_TX - Tx electrode. +* * CY_CAPSENSE_PIN_STATE_IDX_GND - Grounded. +* * CY_CAPSENSE_PIN_STATE_IDX_CSX_NEG_TX - Negative Tx electrode +* (for multi-phase TX method). +* * CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z - Unconnected (high-z). +* * CY_CAPSENSE_PIN_STATE_IDX_CSX_VDDA2 - Connected to VDDA/2. +* The desired pins state for CSD widget electrodes: +* * CY_CAPSENSE_PIN_STATE_IDX_CSD_SNS - Self-cap sensor. +* * CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z - Unconnected (high-z). +* * CY_CAPSENSE_PIN_STATE_IDX_GND - Grounded. +* * CY_CAPSENSE_PIN_STATE_IDX_ACT_SHIELD - Active shield is routed to the pin. +* * CY_CAPSENSE_PIN_STATE_IDX_PAS_SHIELD - Passive shield is routed to the pin. +* The desired pins state for ISX widget electrodes: +* * CY_CAPSENSE_PIN_STATE_IDX_ISX_LX - Lx electrode. +* * CY_CAPSENSE_PIN_STATE_IDX_ISX_RX - Rx electrode. +* * CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z - Unconnected (high-z). +* * CY_CAPSENSE_PIN_STATE_IDX_GND - Grounded. +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_CONFIG - The function does not suppose to be +* called with the current CAPSENSE™ +* configuration. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_SlotPinStateInternal( + uint32_t * ptrSnsFrm, + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t pinState, + cy_stc_capsense_context_t * context) +{ + uint32_t i; + uint32_t mask = 0u; + uint32_t * ptrCswFunc = &context->ptrBaseFrameContext->swSelCswFunc[0u]; + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_CONFIG; + const uint32_t pinStates[CY_CAPSENSE_CTRLMUX_PIN_STATE_NUMBER] = CY_CAPSENSE_PIN_STATES_ARR; + + /* Check if the desired pin state is assigned already */ + if ((context->ptrInternalContext->mapPinState[pinState] == CY_CAPSENSE_SCW_FUNC_PIN_STATE_IDX_UNDEFINED) && + (MSCLP_CSW_GLOBAL_FUNC_NR > context->ptrInternalContext->numFunc)) + { + context->ptrInternalContext->mapPinState[pinState] = context->ptrInternalContext->numFunc; + ptrCswFunc[context->ptrInternalContext->numFunc] = pinStates[pinState]; + context->ptrCommonConfig->ptrChConfig->ptrHwBase->SW_SEL_CSW_FUNC[context->ptrInternalContext->numFunc] = + pinStates[pinState]; + context->ptrInternalContext->numFunc += 1u; + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + if(CY_CAPSENSE_PIN_STATE_IDX_CSX_VDDA2 == pinState) + { + /* Close the reference to filter switch */ + context->ptrBaseFrameContext->mode[CY_CAPSENSE_REG_MODE_CSX].swSelSh |= MSCLP_MODE_SW_SEL_SH_SOMB_Msk; + } + #endif + } + else if (context->ptrInternalContext->mapPinState[pinState] != CY_CAPSENSE_SCW_FUNC_PIN_STATE_IDX_UNDEFINED) + { + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + } + else + { + /* Do nothing */ + } + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + /* Update SNS_SW_SEL_CSW_LO_MASK0 - SNS_SW_SEL_CSW_LO_MASK2 in the sensor frame */ + for (i = 0u; i < ptrEltdCfg->numPins; i++) + { + mask |= 0x01uL << ptrEltdCfg->ptrPin[i].padNumber; + } + + for (i = 0u; i < CY_CAPSENSE_CTRLMUX_PIN_STATE_MASK_NUMBER; i++) + { + ptrSnsFrm[i] &= ~mask; + if (0u != (context->ptrInternalContext->mapPinState[pinState] & + ((uint8_t)(1u << (CY_CAPSENSE_CTRLMUX_PIN_STATE_MASK_NUMBER - 1u - i))))) + { + ptrSnsFrm[i] |= mask; + } + } + + /* Force HW configuration update on the next scan */ + capStatus = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT, context); + } + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SlotPinState_V3Lp +****************************************************************************//** +* +* The internal function that configures the specified electrode to the desired state +* in the specified Active slot by updating the CAPSENSE™ configuration. +* +* See the Cy_CapSense_SlotPinState() description for details. +* +* \note +* This function is available for the fifth-generation (only +* for CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) and the fifth-generation +* low power CAPSENSE™. For the fourth-generation CAPSENSE™ and +* the fifth-generation CAPSENSE™ with +* CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD use Cy_CapSense_SetPinState(). +* For Low Power slots for the fifth-generation low power CAPSENSE™ +* use Cy_CapSense_LpSlotPinState(). +* +* \param slotId +* The slot ID to change the pin state for (Active slot ID for +* the fifth-generation low power CAPSENSE™). +* +* \param ptrEltdCfg +* The pointer to an electrode the all pins states of which will be configured +* as pinState parameter. +* +* \param pinState +* The parameter have different values for the fifth- and the fifth-generation +* low power CAPSENSE™. +* +* The desired pins state for CSX widget electrodes can be: +* * CY_CAPSENSE_PIN_STATE_IDX_CSX_RX - Rx electrode. +* * CY_CAPSENSE_PIN_STATE_IDX_CSX_TX - Tx electrode. +* * CY_CAPSENSE_PIN_STATE_IDX_GND - Grounded. +* * CY_CAPSENSE_PIN_STATE_IDX_CSX_NEG_TX - Negative Tx electrode +* (for multi-phase TX method). +* * CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z - Unconnected (high-z). +* * CY_CAPSENSE_PIN_STATE_IDX_CSX_VDDA2 - Connected to VDDA/2. +* +* The desired pins state for CSD widget electrodes can be: +* * CY_CAPSENSE_PIN_STATE_IDX_CSD_SNS - Self-cap sensor. +* * CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z - Unconnected (high-z). +* * CY_CAPSENSE_PIN_STATE_IDX_GND - Grounded. +* * CY_CAPSENSE_PIN_STATE_IDX_ACT_SHIELD - Active shield is routed to the pin. +* * CY_CAPSENSE_PIN_STATE_IDX_PAS_SHIELD - Passive shield is routed to the pin. +* +* The desired pins state for ISX widget electrodes can be: +* * CY_CAPSENSE_PIN_STATE_IDX_ISX_LX - Lx electrode. +* * CY_CAPSENSE_PIN_STATE_IDX_ISX_RX - Rx electrode. +* * CY_CAPSENSE_PIN_STATE_IDX_HIGH_Z - Unconnected (high-z). +* * CY_CAPSENSE_PIN_STATE_IDX_GND - Grounded. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_CONFIG - The function does not suppose to be +* called with the current CAPSENSE™ +* configuration. +* +* \funcusage +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_SlotPinState +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_SlotPinState_V3Lp( + uint32_t slotId, + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t pinState, + cy_stc_capsense_context_t * context) +{ + uint32_t * ptrSnsFrm = &context->ptrSensorFrameContext[slotId * CY_CAPSENSE_SENSOR_FRAME_SIZE]; + + return (Cy_CapSense_SlotPinStateInternal(ptrSnsFrm, ptrEltdCfg, pinState, context)); +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_LpSlotPinState +****************************************************************************//** +* +* Configures the specified electrode to the desired state in the specified Low Power +* slot by updating the CAPSENSE™ configuration. +* +* This function changes / overwrites configuration of an electrode (several +* pins in case the electrode is ganged to more pins) with a state specified +* by the pinState parameter. The function does this only for the specified Low Power +* slot ID. If the electrode should have the desired state during scans in another Low +* Power slots, the function should be called multiple times for each desired Low Power +* slot. +* +* The function call changes the pin states permanently and all further scans of +* the slot will have the electrode state as specified by the pinState parameter. +* Call the function again to change the electrode state to a new desired one or +* reinitialize CAPSENSE™ middleware by using the Cy_CapSense_Enable() function. +* +* The function changes the configuration of an electrode without storing +* the previous state. A user is responsible to keep the previous state to +* revert to the default settings if needed. Also, the default settings +* can be configured again by calling Cy_CapSense_Enable() function that +* leads to repeating CAPSENSE™ Data Structure initialization, +* DAC auto-calibration, and baseline initialization. +* +* Using the function is recommended only for advanced users for specific use cases. +* For instance, to change the CAPSENSE™ default electrode configuration, +* the function could be called by using a CAPSENSE™ Data Structure +* Initialization callback ptrEODsInitCallback. For details of how to register +* the callback see the \ref group_capsense_callbacks section. That avoids repeating of +* DAC auto-calibration and baseline initialization since the callback is called after +* CAPSENSE™ Data Structure initialization but before the first initialization +* scan. +* +* The function is a low-level function and does not perform an input parameter +* verification (like Low Power slot ID, pointers, etc.). For example, the +* CY_CAPSENSE_CTRLMUX_PIN_STATE_SHIELD pin state is not available if a shield is not +* configured in the project, but the function will set the pin state and the HW block +* behavior is unpredictable. +* +* \note +* This function is available only for the fifth-generation low power +* CAPSENSE™. For the fifth-generation (only for +* CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) and fifth-generation low power +* CAPSENSE™ Active slots use Cy_CapSense_SlotPinState(). For fourth-generation +* CAPSENSE&trade and fifth-generation CAPSENSE&trade with +* CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD use Cy_CapSense_SetPinState(). +* +* \param lpSlotId +* The desired Low Power slot ID. +* +* \param ptrEltdCfg +* The pointer to an electrode the all pins states of which will be configured +* as pinState parameter. +* +* \param pinState +* The desired pins state for CSX widget electrodes could be: +* * CY_CAPSENSE_RX_PIN - Rx electrode +* * CY_CAPSENSE_TX_PIN - Tx electrode +* * CY_CAPSENSE_GROUND - Grounded +* * CY_CAPSENSE_NEGATIVE_TX_PIN - Negative Tx electrode +* (for multi-phase TX method) +* * CY_CAPSENSE_HIGHZ - Unconnected (High-Z) +* * CY_CAPSENSE_VDDA2 - Connected to VDDA/2. +* The desired pins state for CSD widget electrodes could be: +* * CY_CAPSENSE_SENSOR - Self-cap sensor +* * CY_CAPSENSE_HIGHZ - Unconnected (High-Z) +* * CY_CAPSENSE_GROUND - Grounded +* * CY_CAPSENSE_SHIELD - Shield is routed to the pin. +* The desired pins state for ISX widget electrodes could be: +* * CY_CAPSENSE_ISX_RX_PIN - ISX Rx electrode +* * CY_CAPSENSE_ISX_LX_PIN - ISX Lx electrode +* * CY_CAPSENSE_HIGHZ - Unconnected (High-Z) +* * CY_CAPSENSE_VDDA2 - Connected to VDDA/2. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_CONFIG - The function does not suppose to be +* called with the current CAPSENSE™ +* configuration. +* - CY_CAPSENSE_STATUS_BAD_PARAM - 1) lpSlotId, sensorElement or pinState +* are not valid; +* 2) the CSD sensing method is disabled for desired +* CY_CAPSENSE_SHIELD or CY_CAPSENSE_SENSOR states; +* 3) the CSX sensing method is disabled for desired +* CY_CAPSENSE_TX_PIN, CY_CAPSENSE_NEGATIVE_TX_PIN or +* CY_CAPSENSE_RX_PIN states. +* 4) the ISX sensing method is disabled for desired +* CY_CAPSENSE_ISX_RX_PIN or CY_CAPSENSE_ISX_LX_PIN +* states. +* +* \funcusage +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_LpSlotPinState +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_LpSlotPinState( + uint32_t lpSlotId, + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t pinState, + cy_stc_capsense_context_t * context) +{ + uint32_t * ptrSnsFrm; + uint32_t localPinState; + cy_capsense_status_t result = CY_CAPSENSE_STATUS_BAD_PARAM; + + if ((NULL != context) && (NULL != ptrEltdCfg) && (CY_CAPSENSE_SLOT_LP_COUNT > lpSlotId)) + { + result = Cy_CapSense_ConvertPinState(pinState, &localPinState); + + if ((uint32_t)CY_CAPSENSE_SUCCESS_E == result) + { + ptrSnsFrm = &context->ptrSensorFrameLpContext[(lpSlotId * CY_MSCLP_11_SNS_REGS) + CY_MSCLP_5_SNS_REGS]; + result = Cy_CapSense_SlotPinStateInternal(ptrSnsFrm, ptrEltdCfg, localPinState, context); + } + } + return (result); +} +#endif /* CY_CAPSENSE_LP_EN */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_SwitchHwConfiguration +****************************************************************************//** +* +* Configures CAPSENSE™-related hardware to the specified state. +* +* \param configuration +* The state of CAPSENSE™-related hardware: +* * CY_CAPSENSE_HW_CONFIG_UNDEFINED. +* * CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT. +* * CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING. +* * CY_CAPSENSE_HW_CONFIG_MPSC_SCANNING. +* * CY_CAPSENSE_HW_CONFIG_CHANNEL_SATURATION +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_PARAM - At least one of input parameters is +* not valid. +* - CY_CAPSENSE_STATUS_HW_BUSY - The MSCLP HW block is busy and cannot be +* configured. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_SwitchHwConfiguration( + uint32_t configuration, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + cy_en_msclp_status_t msclpStatus; + const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; + MSCLP_Type * ptrHwBase = ptrCommonCfg->ptrChConfig->ptrHwBase; + + if (context->ptrInternalContext->hwConfigState != configuration) + { + /* Turn off the previous HW configuration */ + switch (context->ptrInternalContext->hwConfigState) + { + case CY_CAPSENSE_HW_CONFIG_UNDEFINED: + break; + case CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT: + break; + case CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING: + break; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) + case CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY: + Cy_CapSense_BistDisableMode(context); + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + case CY_CAPSENSE_HW_CONFIG_MPSC_SCANNING: + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) */ + case CY_CAPSENSE_HW_CONFIG_CHANNEL_SATURATION: + break; + case CY_CAPSENSE_HW_CONFIG_SMARTSENSE: + break; + default: + capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + break; + } + + /* Clear the repeat scan flag as the HW configuration is changed */ + context->ptrInternalContext->repeatScanEn = CY_CAPSENSE_DISABLE; + + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + /* Turn on the desired HW configuration */ + switch (configuration) + { + case CY_CAPSENSE_HW_CONFIG_UNDEFINED: + break; + case CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT: + break; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + case CY_CAPSENSE_HW_CONFIG_MPSC_SCANNING: /* fall through */ + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) */ + + case CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING: + Cy_CapSense_SetIOsInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, 0u, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN, context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_SetShieldPinsInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN, context); + #endif + + /* Reset last scanned widget type */ + context->ptrCommonContext->status &= (uint32_t)~((uint32_t)CY_CAPSENSE_MW_STATE_WD_SCAN_MASK); + context->ptrActiveScanSns->currentSenseMethod = CY_CAPSENSE_UNDEFINED_GROUP; + + Cy_CapSense_SetCmodInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN, context); + + msclpStatus = Cy_MSCLP_Configure(ptrHwBase, + context->ptrBaseFrameContext, + CY_MSCLP_CAPSENSE_KEY, + ptrCommonCfg->ptrChConfig->ptrHwContext); + if (CY_MSCLP_SUCCESS != msclpStatus) + { + capStatus = CY_CAPSENSE_STATUS_HW_BUSY; + break; + } + + /* Disable ACTIVE domain interrupts */ + ptrHwBase->INTR_MASK = 0x00u; + + /* Clear all pending interrupts */ + ptrHwBase->INTR_LP = CY_CAPSENSE_MSCLP_INTR_LP_ALL_MSK; + + /* Update Comp CDAC switch ctrl and replace CSD mode struct with the MPSC configuration */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + if (CY_CAPSENSE_HW_CONFIG_MPSC_SCANNING == configuration) + { + ptrHwBase->SW_SEL_CDAC_CO = ((CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COTCA << MSCLP_SW_SEL_CDAC_CO_SW_COTCA_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COCB << MSCLP_SW_SEL_CDAC_CO_SW_COCB_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COTV << MSCLP_SW_SEL_CDAC_CO_SW_COTV_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COTG << MSCLP_SW_SEL_CDAC_CO_SW_COTG_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COBG << MSCLP_SW_SEL_CDAC_CO_SW_COBV_Pos) | + (CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COBV << MSCLP_SW_SEL_CDAC_CO_SW_COBG_Pos)); + + if (CY_CAPSENSE_ENABLE == context->ptrInternalContext->csdCdacDitherEn) + { + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SENSE_DUTY_CTL = CY_CAPSENSE_MPSC_RM_DITHER_SENSE_DUTY_CTL; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_CDAC_FL = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_CDAC_FL; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_TOP = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_TOP; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_COMP = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_COMP; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_SH = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_SH; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_CMOD1 = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_CMOD1; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_CMOD2 = CY_CAPSENSE_MPSC_RM_DITHER_SW_SEL_CMOD2; + } + else + { + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SENSE_DUTY_CTL = CY_CAPSENSE_MPSC_RM_SENSE_DUTY_CTL; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_CDAC_FL = CY_CAPSENSE_MPSC_RM_SW_SEL_CDAC_FL; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_TOP = CY_CAPSENSE_MPSC_RM_SW_SEL_TOP; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_COMP = CY_CAPSENSE_MPSC_RM_SW_SEL_COMP; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_SH = CY_CAPSENSE_MPSC_RM_SW_SEL_SH; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_CMOD1 = CY_CAPSENSE_MPSC_RM_SW_SEL_CMOD1; + ptrHwBase->MODE[CY_CAPSENSE_REG_MODE_CSD].SW_SEL_CMOD2 = CY_CAPSENSE_MPSC_RM_SW_SEL_CMOD2; + } + } + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) */ + + /* The time interval is required for settling analog part of the HW block. */ + Cy_SysLib_DelayUs(CY_CAPSENSE_ANALOG_SETTLING_TIME_US); + + break; + case CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY: + Cy_CapSense_SetIOsInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, 0u, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN, context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_SetShieldPinsInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN, context); + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) */ + + context->ptrActiveScanSns->currentSenseMethod = CY_CAPSENSE_UNDEFINED_GROUP; + Cy_CapSense_SetCmodInDesiredState(CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO, + CY_CAPSENSE_MSCLP_GPIO_MSC_ANA_EN, context); + break; + case CY_CAPSENSE_HW_CONFIG_CHANNEL_SATURATION: + Cy_CapSense_ConfigureSaturationMode(context); + break; + case CY_CAPSENSE_HW_CONFIG_SMARTSENSE: + Cy_CapSense_SetupCpuOperatingMode(context); + break; + default: + capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + break; + } + } + if (CY_CAPSENSE_STATUS_SUCCESS == capStatus) + { + context->ptrInternalContext->hwConfigState = (uint8_t)configuration; + } + } + + return (capStatus); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_InitializeSourceSenseClk +****************************************************************************//** +* +* Performs the Sense Clock source and the LFSR auto-selection functionality. +* Validates the Sense Clock configuration. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_BAD_CLOCK_CONFIG - Sense Clock Divider is out of the valid +* range for the specified Clock source +* configuration. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk(const cy_stc_capsense_context_t * context) +{ + uint32_t wdIndex; + uint32_t snsClkSrc; + uint32_t snsClkDivMin = 0u; + uint32_t lfsrRange; + + cy_capsense_status_t retVal = CY_CAPSENSE_STATUS_SUCCESS; + + cy_stc_capsense_widget_context_t * ptrWdCxt; + const cy_stc_capsense_widget_config_t * ptrWdCfg = context->ptrWdConfig; + + for (wdIndex = 0u; wdIndex < CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex++) + { + ptrWdCxt = ptrWdCfg->ptrWdContext; + snsClkSrc = ptrWdCxt->snsClkSource; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN)) + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType)) + { + snsClkSrc = 0u; + } + #endif + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_LP_HW_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN)) + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType)) + { + snsClkSrc = 0u; + } + #endif + #endif + + if ((0u != (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_SSC_AUTO_MASK)) || + (CY_CAPSENSE_CLK_SOURCE_SSC == (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_MASK))) + { + if (0u != (ptrWdCxt->lfsrBits & CY_CAPSENSE_LFSR_BITS_AUTO_MASK)) + { + /* + * Execute the LFSR range auto-selection functionality when the + * Sense Clock source parameter is configured with the SSC or + * SSC-Auto option, and the LFSR range parameter is configured with + * the Auto option. + */ + ptrWdCxt->lfsrBits = (uint8_t)Cy_CapSense_GetLfsrBitsAuto(ptrWdCfg, context); + } + + if (0u != (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_SSC_AUTO_MASK)) + { + /* + * Execute SSC auto-selection functionality when the + * Sense Clock source parameter is configured with the SSC-Auto + * option. This routine performs checking if the SSC clock source + * is valid for the widget, specified by the input parameter. + */ + ptrWdCxt->snsClkSource = (uint8_t)Cy_CapSense_GetClkSrcSSCAuto(ptrWdCfg, context); + } + } + else if (0u != (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_PRS_AUTO_MASK)) + { + /* + * Execute PRS auto-selection functionality when the + * Sense Clock source parameter is configured with the PRS-Auto. + * This routine performs checking if the PRS clock source is valid + * for the widget, specified by the input parameter. + */ + ptrWdCxt->snsClkSource = (uint8_t)Cy_CapSense_GetClkSrcPRSAuto(ptrWdCxt, context); + } + else + { + /* + * No action required. The Sense Clock source and the LFSR range + * parameter are configured with the fixed option (Direct, PRS or + * SSC - for the Sense Clock source parameter and [-2; 1], [-4; 3], + * [-8; 7] and [-16; 15] - for the LFSR range parameter.) + */ + } + + /* Determine the MIN valid Sense Clock divider for the used sensing method. */ + switch (ptrWdCfg->senseMethod) + { + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) + case CY_CAPSENSE_CSD_GROUP: + case CY_CAPSENSE_ISX_GROUP: + snsClkDivMin = CY_CAPSENSE_4PH_DIRECT_SNS_CLOCK_DIVIDER_MIN; + break; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + snsClkDivMin = CY_CAPSENSE_2PH_DIRECT_SNS_CLOCK_DIVIDER_MIN; + break; + #endif + + default: + retVal = CY_CAPSENSE_STATUS_BAD_PARAM; + /* No action */ + break; + } + + /* + * Update the MIN valid Sense Clock divider with the used clock dithering + * range if the Sense Clock source parameter is configured with the SSC + * option. + */ + if (CY_CAPSENSE_CLK_SOURCE_SSC == (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_MASK)) + { + lfsrRange = ptrWdCxt->lfsrBits; + lfsrRange &= (uint32_t)(~((uint32_t)CY_CAPSENSE_LFSR_BITS_AUTO_MASK)); + snsClkDivMin += Cy_CapSense_GetLfsrDitherVal(lfsrRange, context->ptrInternalContext->lfsrScale); + } + + /* Perform validation if the Sense Clock divider is within the valid range. */ + if ((ptrWdCxt->snsClk < snsClkDivMin) || + (ptrWdCxt->snsClk > CY_CAPSENSE_DIRECT_SNS_CLOCK_DIVIDER_MAX)) + { + retVal = CY_CAPSENSE_STATUS_BAD_CLOCK_CONFIG; + } + + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || + ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType))) + { + if ((ptrWdCxt->rowSnsClk < snsClkDivMin) || + (ptrWdCxt->rowSnsClk > CY_CAPSENSE_DIRECT_SNS_CLOCK_DIVIDER_MAX)) + + { + retVal = CY_CAPSENSE_STATUS_BAD_CLOCK_CONFIG; + } + } + #endif + + if (CY_CAPSENSE_STATUS_BAD_CLOCK_CONFIG == retVal) + { + break; + } + + ptrWdCfg++; + } + + return retVal; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetLfsrBitsAuto +****************************************************************************//** +* +* Selects the number of LSB bits to use from the LSFR to provide the clock +* dithering variation on the base period if the snsClkSource member of the +* cy_stc_capsense_widget_context_t is configured with the +* CY_CAPSENSE_CLK_SOURCE_SSC_AUTO_MASK mask or with the or the +* CY_CAPSENSE_CLK_SOURCE_SSC value. +* +* \param ptrWdConfig +* Specifies the pointer to a widget configuration structure. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetLfsrBitsAuto( + const cy_stc_capsense_widget_config_t * ptrWdConfig, + const cy_stc_capsense_context_t * context) +{ + uint32_t lfsrScale; + uint32_t lfsrRange; + uint32_t ditherLimitPercents; + uint32_t snsClkDividerMin; + uint32_t snsClkDividerTmp; + + const cy_stc_capsense_widget_context_t * ptrWdCxt; + + ptrWdCxt = ptrWdConfig->ptrWdContext; + snsClkDividerTmp = ptrWdCxt->snsClk; + lfsrScale = context->ptrInternalContext->lfsrScale; + ditherLimitPercents = ptrWdConfig->lfsrDitherLimit; + + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + if ((CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) && + (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdConfig->wdType) || + ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdConfig->wdType))) + { + /* + * Obtain the MIN Sense Clock divider within the two-dimension CSD widget. + * The LFSR range should be determined, basing on the MIN Sense Clock + * divider in order to be sufficient for rows and columns. + */ + if (snsClkDividerTmp > ptrWdCxt->rowSnsClk) + { + snsClkDividerTmp = ptrWdCxt->rowSnsClk; + } + } + #endif + + /* Determine the MIN valid Sense Clock divider for the used sensing method. */ + switch (ptrWdConfig->senseMethod) + { + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN)) + case CY_CAPSENSE_CSD_GROUP: + case CY_CAPSENSE_ISX_GROUP: + snsClkDividerMin = CY_CAPSENSE_4PH_DIRECT_SNS_CLOCK_DIVIDER_MIN; + break; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + snsClkDividerMin = CY_CAPSENSE_2PH_DIRECT_SNS_CLOCK_DIVIDER_MIN; + break; + #endif + + default: + snsClkDividerMin = 0u; + break; + } + + /* + * Execute the LFSR range selection routine. This routine determines + * the LFSR_BITS option, required to provide the max clock dithering variation + * for the specified sense Clock divider, LFSR dither (in percents) and + * LFSR scale values. + */ + lfsrRange = Cy_CapSense_GetLfsrBitsNumber(snsClkDividerTmp, snsClkDividerMin, + ditherLimitPercents, lfsrScale); + + return (lfsrRange | CY_CAPSENSE_LFSR_BITS_AUTO_MASK); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetClkSrcSSCAuto +****************************************************************************//** +* +* Performs checking if the SSC clock source is valid for the widget, specified +* by the input parameter. +* +* \param ptrWdConfig +* Specifies the pointer to a widget configuration structure. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the valid clock source: +* - SSC -if SSC is valid for the specified widget configuration. +* - Direct -if SSC is not valid for the specified widget configuration. +* The CY_CAPSENSE_CLK_SOURCE_SSC_AUTO_MASK bit is always set in the return +* value. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetClkSrcSSCAuto( + const cy_stc_capsense_widget_config_t * ptrWdConfig, + const cy_stc_capsense_context_t * context) +{ + uint32_t lfsrRange; + uint32_t lfsrScale; + uint32_t snsClkSrc; + uint32_t autoSelMode; + uint32_t ditherLimitPercents; + uint32_t lfsrDitherCycles; + uint32_t ditherLimitCycles; + uint32_t lfsrPolySize; + uint32_t snsClkDivMin; + uint32_t subConvNumber; + const cy_stc_capsense_widget_context_t * ptrWdCxt; + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + uint32_t snsClkSrcRow; + #endif + + ptrWdCxt = ptrWdConfig->ptrWdContext; + + /* + * Determine the whole number of sub-conversion per scan (includes Dummy and + * Measurement conversions). + */ + subConvNumber = ptrWdCxt->numSubConversions; + subConvNumber += context->ptrInternalContext->numFineInitCycles; + if (CY_CAPSENSE_16_BIT_MASK < subConvNumber) + { + subConvNumber = CY_CAPSENSE_16_BIT_MASK; + } + lfsrRange = ((uint32_t)ptrWdCxt->lfsrBits & (uint32_t)(~((uint32_t)CY_CAPSENSE_LFSR_BITS_AUTO_MASK))); + lfsrScale = context->ptrInternalContext->lfsrScale; + autoSelMode = ptrWdConfig->snsClkSourceAutoSelMode; + ditherLimitPercents = ptrWdConfig->lfsrDitherLimit; + + /* + * Determine the polynomial duration in clock cycles, e.g. the duration of 8-bit + * polynomial is 255 clock cycles. + */ + lfsrPolySize = Cy_CapSense_GetPolySize(context->ptrInternalContext->lfsrPoly); + + /* + * Determine the clock dithering variation for the specifies LFSR range, + * e.g for the [-2; 1] range the clock variation will be 2 cycles. + */ + lfsrDitherCycles = Cy_CapSense_GetLfsrDitherVal(lfsrRange, lfsrScale); + + /* Determine the MIN valid Sense Clock divider for the used sensing method. */ + if ((CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) ||\ + (CY_CAPSENSE_ISX_GROUP == ptrWdConfig->senseMethod)) + { + snsClkDivMin = CY_CAPSENSE_4PH_DIRECT_SNS_CLOCK_DIVIDER_MIN; + } + else + { + snsClkDivMin = CY_CAPSENSE_2PH_DIRECT_SNS_CLOCK_DIVIDER_MIN; + } + + /* + * Determines the max allowed clock dithering variation for the specified + * Sense Clock divider, LFSR dither (in percents) and LFSR scale values. + */ + ditherLimitCycles = Cy_CapSense_GetLfsrDitherLimit(ptrWdCxt->snsClk, + snsClkDivMin, ditherLimitPercents, lfsrScale); + + /* + * Execute the SSC-Auto selection routine. This routine validates all the + * criteria, that are required for good SSC performance are met. + * The CY_CAPSENSE_CLK_SOURCE_SSC will be returned if all the criteria are met, + * the CY_CAPSENSE_CLK_SOURCE_DIRECT will be returned if not. + */ + snsClkSrc = Cy_CapSense_RunSSCAuto(autoSelMode, lfsrDitherCycles, + ditherLimitCycles, lfsrPolySize, subConvNumber); + + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + /* Repeat the SSC-Auto selection routine for the row of two-dimension CSD + * widget. + */ + if ((CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) && + (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdConfig->wdType) || + ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdConfig->wdType))) + { + if ((uint8_t)CY_CAPSENSE_CLK_SOURCE_DIRECT != snsClkSrc) + { + ditherLimitCycles = Cy_CapSense_GetLfsrDitherLimit(ptrWdCxt->rowSnsClk, + snsClkDivMin, ditherLimitPercents, lfsrScale); + snsClkSrcRow = Cy_CapSense_RunSSCAuto(autoSelMode, lfsrDitherCycles, + ditherLimitCycles, lfsrPolySize, (uint16_t)subConvNumber); + + if (snsClkSrc != snsClkSrcRow) + { + /* + * If the automatically determined Sense Clock sources for + * rows and columns are different, the widget Sense Clock + * source should be set to Direct. + */ + snsClkSrc = CY_CAPSENSE_CLK_SOURCE_DIRECT; + } + } + } + #endif + + return (snsClkSrc | CY_CAPSENSE_CLK_SOURCE_SSC_AUTO_MASK); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_RunSSCAuto +****************************************************************************//** +* +* Implements checking the following rules: +* 1. An LFSR value should be selected so that the max clock dither in percents +* is limited with the value, specified by the lfsrDitherLimit parameter. +* 2. At least one full spread spectrum polynomial should pass during the scan +* time. +* 3. The value of the number of conversions should be an integer multiple of the +* repeat period of the polynomial, that is specified by the +* Sense Clock LFSR Polynomial parameter. +* +* \param autoSelMode +* Defines set of rules, to be checked in order to decide if the SSC clock +* source is applicable for the specified parameters. +* +* \param lfsrDitherCycles +* Dintering variation in the number of Mod Clock cycles. +* +* \param ditherLimitCycles +* Max dither in percentage, the actual clock dithering variation should +* be limited with. +* +* \param lfsrPolySize +* Number of Sense Clock cycles, required to fully pass the configured +* polynomial. +* +* \param subConvNumber +* Number of sub-conversions(including Dummy). +* +* \return +* Returns the valid clock source: +* - CY_CAPSENSE_CLK_SOURCE_SSC -if SSC is valid for the specified widget +* configuration. +* - CY_CAPSENSE_CLK_SOURCE_DIRECT -if SSC is not valid for the specified widget +* configuration. +* +*******************************************************************************/ +uint32_t Cy_CapSense_RunSSCAuto( + uint32_t autoSelMode, + uint32_t lfsrDitherCycles, + uint32_t ditherLimitCycles, + uint32_t lfsrPolySize, + uint32_t subConvNumber) +{ + uint32_t snsClkSrc = CY_CAPSENSE_CLK_SOURCE_SSC; + + /* Check if the Sense Clock variation is lower than MAX allowed. */ + if (lfsrDitherCycles > ditherLimitCycles) + { + snsClkSrc = CY_CAPSENSE_CLK_SOURCE_DIRECT; + } + + /* + * Check if at least one whole polynomial period will be performed + * during the scan. This part of code is executed if the Clock Source + * auto selection mode is set to Medium or Strong. + */ + if (autoSelMode != CY_CAPSENSE_SNS_CLK_SOURCE_AUTO_SEL_MODE_WEAK) + { + if (subConvNumber < lfsrPolySize) + { + snsClkSrc = CY_CAPSENSE_CLK_SOURCE_DIRECT; + } + } + + /* + * Check if the integer number of the polynomial periods will be performed + * during the scan. This part of code is executed if the Clock Source + * auto selection mode is set to Strong. + */ + if (autoSelMode == CY_CAPSENSE_SNS_CLK_SOURCE_AUTO_SEL_MODE_STRONG) + { + if (0u != (subConvNumber % lfsrPolySize)) + { + snsClkSrc = CY_CAPSENSE_CLK_SOURCE_DIRECT; + } + } + + return snsClkSrc; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetClkSrcPRSAuto +****************************************************************************//** +* +* Performs checking if the PRS clock source is valid for the widget, specified +* by the input parameter. +* +* \param ptrWdContext +* Specifies the pointer to a widget context structure. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the valid clock source: +* - PRS -if SSC is valid for the specified widget configuration. +* - Direct -if SSC is not valid for the specified widget configuration. +* The CY_CAPSENSE_CLK_SOURCE_PRS_AUTO_MASK bit is always set in the return +* value. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetClkSrcPRSAuto( + const cy_stc_capsense_widget_context_t * ptrWdContext, + const cy_stc_capsense_context_t * context) +{ + uint32_t lfsrPolySize; + uint32_t risingEdgesNum; + uint32_t subConvNumber; + uint32_t snsClkSrc = CY_CAPSENSE_CLK_SOURCE_PRS; + + /* + * Determine the whole number of sub-conversion per scan (includes Dummy and + * Measurement conversions). + */ + subConvNumber = ptrWdContext->numSubConversions; + subConvNumber += context->ptrInternalContext->numFineInitCycles; + + /* + * Determine the polynomial duration in clock cycles, e.g. the duration of 8-bit + * polynomial is 255 clock cycles. + */ + lfsrPolySize = Cy_CapSense_GetPolySize(context->ptrInternalContext->lfsrPoly); + + /* + * The number of rising edges per one PRS period is (polyLength + 1) / 4. + * polyLength = 2^N - 1, where N is size of the shift register (8BIT, 12BIT, etc). + */ + risingEdgesNum = (lfsrPolySize + 1u) >> CY_CAPSENSE_4PH_PRS_SNS_CLOCK_DIVIDER_SHIFT; + + /* + * Check if at least one whole polynomial period will be performed + * during the scan. + */ + if (subConvNumber < risingEdgesNum) + { + snsClkSrc = CY_CAPSENSE_CLK_SOURCE_DIRECT; + } + + return (snsClkSrc | CY_CAPSENSE_CLK_SOURCE_PRS_AUTO_MASK); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetPolySize +****************************************************************************//** +* +* Calculates the number of Sense Clock cycles, required to fully pass the +* specified polynomial. +* +* \param lfsrPoly +* Specifies the polynomial the calculation should be performed for. +* +* \return +* Number of Sense Clock cycles, required to fully pass the specified +* polynomial. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetPolySize(uint32_t lfsrPoly) +{ + /* Initialization the msbIndex variable with the MAX possible size of polynomial */ + uint32_t polySize = 0xFFFFu; + uint32_t polyMsbMask = 0x8000u; + + while ((1u < polySize) && (0u == (lfsrPoly & polyMsbMask))) + { + polySize >>= 1u; + polyMsbMask >>= 1u; + } + + return polySize; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetLfsrBitsNumber +****************************************************************************//** +* +* Determines SNS_CTL.LFSR_BITS option, required to provide the max clock +* dithering variation for the specified parameters. +* +* \param snsClkDivider +* The divider value for the sense clock. +* +* \param snsClkDividerMin +* The minimal valid value of the sense clock divider. +* +* \param ditherLimitPercents +* Max dither in percentage, the actual clock dither should be limited with. +* +* \param lfsrScale +* Number of bits to shift the LFSR output left before adding to SENSE_DIV. +* +* \return +* The SNS_CTL.LFSR_BITS option: +* - CY_CAPSENSE_LFSR_BITS_RANGE_0 - Use 2 bits range: [-2,1] +* - CY_CAPSENSE_LFSR_BITS_RANGE_1 - Use 3 bits range: [-4,3] +* - CY_CAPSENSE_LFSR_BITS_RANGE_2 - Use 4 bits range: [-8,7] +* - CY_CAPSENSE_LFSR_BITS_RANGE_3 - Use 5 bits range: [-16,15] +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetLfsrBitsNumber( + uint32_t snsClkDivider, + uint32_t snsClkDividerMin, + uint32_t ditherLimitPercents, + uint32_t lfsrScale) +{ + uint32_t retVal; + uint32_t ditherLimitCycles; + + /* + * Determine the max allowed clock dithering variation for the specified + * Sense Clock divider, LFSR dither (in percents) and LFSR scale values. + */ + ditherLimitCycles = Cy_CapSense_GetLfsrDitherLimit(snsClkDivider, snsClkDividerMin, + ditherLimitPercents, lfsrScale); + + /* Based in the MAX allowed clock dithering, Determines the LFSR_BITS option. */ + if (CY_CAPSENSE_LFSR_RANGE_3_DITHER_MAX <= ditherLimitCycles) + { + retVal = CY_CAPSENSE_LFSR_BITS_RANGE_3; + } + else if (CY_CAPSENSE_LFSR_RANGE_2_DITHER_MAX <= ditherLimitCycles) + { + retVal = CY_CAPSENSE_LFSR_BITS_RANGE_2; + } + else if (CY_CAPSENSE_LFSR_RANGE_1_DITHER_MAX <= ditherLimitCycles) + { + retVal = CY_CAPSENSE_LFSR_BITS_RANGE_1; + } + else + { + retVal = CY_CAPSENSE_LFSR_BITS_RANGE_0; + } + + return retVal; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetLfsrDitherVal +****************************************************************************//** +* +* Determines the clock dithering variation for the specified parameters. +* +* \param lfsrBits +* The supported SNS_CTL.LFSR_BITS option: +* - CY_CAPSENSE_LFSR_BITS_RANGE_0 - Use 2 bits range: [-2,1] +* - CY_CAPSENSE_LFSR_BITS_RANGE_1 - Use 3 bits range: [-4,3] +* - CY_CAPSENSE_LFSR_BITS_RANGE_2 - Use 4 bits range: [-8,7] +* - CY_CAPSENSE_LFSR_BITS_RANGE_3 - Use 5 bits range: [-16,15] +* +* \param lfsrScale +* Number of bits to shift the LFSR output left before adding to SENSE_DIV. +* +* \return +* Dintering variation in the number of Mod Clock cycles. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetLfsrDitherVal( + uint32_t lfsrBits, + uint32_t lfsrScale) +{ + return (uint32_t)(1uL << (((lfsrBits & CY_CAPSENSE_LFSR_BITS_RANGE_MASK) + 1u) + lfsrScale)); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetLfsrDitherLimit +****************************************************************************//** +* +* Determines the max allowed clock dithering variation for the specified +* parameters. +* +* \param snsClkDivider +* The divider value for the sense clock. +* +* \param snsClkDividerMin +* The minimal valid value of the sense clock divider. +* +* \param ditherLimitPercents +* Max dither in percentage, the actual clock dither should be limited with. +* +* \param lfsrScale +* Number of bits to shift the LFSR output left before adding to SENSE_DIV. +* +* \return +* Dintering variation in the number of Mod Clock cycles. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetLfsrDitherLimit( + uint32_t snsClkDivider, + uint32_t snsClkDividerMin, + uint32_t ditherLimitPercents, + uint32_t lfsrScale) +{ + uint32_t ditherLimitCycles; + uint32_t ditherLimitCyclesMax; + + /* + * Determine the dither limit in clock cycles for the specified Dither limit + * in percents. + */ + ditherLimitCycles = ((ditherLimitPercents * snsClkDivider) / CY_CAPSENSE_PERCENTAGE_100); + ditherLimitCycles >>= lfsrScale; + + /* Determine MAX allowed dither in cycles for the specified Sense Clock divider. */ + ditherLimitCyclesMax = (snsClkDivider - snsClkDividerMin) / (1u << lfsrScale); + + /* + * Determine the minimal value to eliminate violation of allowed Sense Clock + * divider range. + */ + if (ditherLimitCycles > ditherLimitCyclesMax) + { + ditherLimitCycles = ditherLimitCyclesMax; + } + + return ditherLimitCycles; +} + + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_LP_HW_EN)) + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_SsSquareRoot16 +****************************************************************************//** +* +* Calculates square root of the specified value. +* +* The specified value is unsigned 16-bit value. The square root is rounded up. +* +* \param value +* Specifies a value the square root should be taken from. +* +* \return +* Returns the square root of the specified value. +* +*******************************************************************************/ +uint32_t Cy_CapSense_SsSquareRoot16(uint16_t value) +{ + uint32_t m = 0x4000u; + uint32_t y = 0u; + uint32_t b = 0u; + uint32_t x = value; + + while (m != 0u) + { + b = y | m; + y = y >> 1u; + if (x >= b) { + x = x - b; + y = y | m; + } + m >>= 2u; + } + if (value > (y * y)) + { + y++; + } + + return y; +} +#endif + + +/******************************************************************************* +* Function Name: Cy_CapSense_SsAutoTune +****************************************************************************//** +* +* Performs the parameters auto-tuning for the optimal CAPSENSE™ operation when +* smart sensing algorithm is enabled. +* +* This function performs the following tasks: +* - Tune the Sense Clock optimal value. +* - Calculate the number of sub-conversions for the optimal finger capacitance. +* - Calibrate Reference and Compensation CDACs. +* +* \note +* The function supposes final auto-calibration is called right after this +* function. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - Zero - All the SmartSense-configured widgets are auto-tuned successfully. +* - Non-zero - Auto-tuning failed for any widget. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_SsAutoTune(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t autoTuneStatus = CY_CAPSENSE_STATUS_SUCCESS; + + uint32_t wdIndex; + uint32_t snsIndex; + uint32_t scanSlotId; + uint32_t numberSubConv; + uint32_t rawCountMax; + cy_stc_capsense_hw_smartsense_config_t autoTuneConfig; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + cy_stc_capsense_widget_context_t * ptrWdCxt; + cy_stc_capsense_sensor_context_t * ptrSnsCxt; + const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; + cy_stc_capsense_common_context_t * ptrCommonCxt = context->ptrCommonContext; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + uint32_t cic2Decimation; + uint32_t cic2Sample; + + MSCLP_Type * msclpBase = ptrCommonCfg->ptrChConfig->ptrHwBase; + #endif + + ptrCommonCxt->status |= CY_CAPSENSE_MW_STATE_SMARTSENSE_MASK; + + /* Step #0: Checks if configuration is valid */ + if (ptrCommonCfg->counterMode != CY_CAPSENSE_COUNTER_MODE_SATURATE) + { + autoTuneStatus |= CY_CAPSENSE_STATUS_BAD_CONFIG; + } + + /* Step #1: Sets the default parameters for preliminary scans. + * If widget is disabled or non-working do initialization to have at + * least valid parameters stored in widget structure and sensor frame. + * However do not scan those widgets. + */ + ptrWdCfg = context->ptrWdConfig; + for (wdIndex = 0u; wdIndex < CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex++) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + /* Skip auto-tuning for MPSC widgets*/ + if (!((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) && + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod))) + #endif + { + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + ((((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) && + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN))) || + (((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType) && + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_LP_HW_EN)))) + { + /* + * Sets the Sense Clock source to Direct. + * Since the Number of Epilogue cycles is a common parameter, it is required + * to configure the Sense Clock source to Direct for all widgets (including CSX) + * in order to have correct number of Epilogue cycles for operation with + * the Direct clock.The setup of the Epilogue cycles number is the part of + * the Cy_CapSense_InitializeSourceSenseClk() routine. + */ + ptrWdCxt = ptrWdCfg->ptrWdContext; + ptrWdCxt->snsClkSource <<= CY_CAPSENSE_CLK_SOURCE_SMARTSENSE_POS; + ptrWdCxt->numSubConversions = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_NSUB; + ptrWdCxt->cdacRef = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_REF_CDAC; + ptrWdCxt->rowCdacRef = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_REF_CDAC; + ptrWdCxt->snsClk = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK; + ptrWdCxt->rowSnsClk = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK; + ptrSnsCxt = ptrWdCfg->ptrSnsContext; + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + ptrSnsCxt->cdacComp = 0u; + ptrSnsCxt++; + } + } + } + ptrWdCfg++; + } + autoTuneStatus |= Cy_CapSense_SsInitialize(context); + + autoTuneStatus |= Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING, context); + + /* Step #2: Executes preliminary scans */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + /* Sets FILTER_MODE to CIC1 */ + msclpBase->FILTER_CTL &= ~MSCLP_FILTER_CTL_FILTER_MODE_Msk; + #endif + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_EXT_FRM_START_EN) + /* Clear the external start scan mode */ + msclpBase->CTL &= ~MSCLP_CTL_EXT_FRAME_START_MODE_Msk; + #endif + + /* Performs preliminary scans for all active widgets */ + ptrScanSlots = context->ptrScanSlots; + for (scanSlotId = 0u; scanSlotId < CY_CAPSENSE_SLOT_COUNT; scanSlotId++) + { + ptrWdCfg = &context->ptrWdConfig[ptrScanSlots[scanSlotId].wdId]; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + /* Skip auto-tuning for MPSC widgets*/ + if (!((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) && + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod))) + #endif + { + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + { + /* Scans an active slot */ + autoTuneStatus |= Cy_CapSense_ScanSlotInternalCPU((uint32_t)CY_CAPSENSE_SNS_FRAME_ACTIVE, + scanSlotId, context); + } + } + } + + /* Performs preliminary scans for all LP widgets if SmartSense is configured for them */ + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_LP_HW_EN)) + ptrScanSlots = context->ptrLpScanSlots; + for (scanSlotId = 0u; scanSlotId < CY_CAPSENSE_SLOT_LP_COUNT; scanSlotId++) + { + ptrWdCfg = &context->ptrWdConfig[ptrScanSlots[scanSlotId].wdId]; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + /* Skip auto-tuning for MPSC widgets*/ + if (!((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) && + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod))) + #endif + { + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + { + /* Scans an LP slot */ + autoTuneStatus |= Cy_CapSense_ScanSlotInternalCPU((uint32_t)CY_CAPSENSE_SNS_FRAME_LOW_POWER, + scanSlotId, context); + } + } + } + #endif + + /* + * Step #3: Calculates sensor capacitances, sense clock dividers, and sub-conversion numbers depending on the configured + * serial resistances, and finger capacitances for each sensor. Sets the configured modClk value in Hz for calculations. + */ + #if (CY_CAPSENSE_IMO_FREQUENCY == CY_CAPSENSE_IMO_25_MHZ) + autoTuneConfig.modClock = CY_CAPSENSE_IMO_CLK_25_MHZ * CY_CAPSENSE_CONVERSION_MEGA / context->ptrInternalContext->modClk; + #elif (CY_CAPSENSE_IMO_FREQUENCY == CY_CAPSENSE_IMO_38_MHZ) + autoTuneConfig.modClock = CY_CAPSENSE_IMO_CLK_38_MHZ * CY_CAPSENSE_CONVERSION_MEGA / context->ptrInternalContext->modClk; + #else + autoTuneConfig.modClock = CY_CAPSENSE_IMO_CLK_46_MHZ * CY_CAPSENSE_CONVERSION_MEGA / context->ptrInternalContext->modClk; + #endif + + autoTuneConfig.snsResistance = ptrCommonCfg->csdRConst; + autoTuneConfig.correctionCoeff = 0u; + ptrWdCfg = context->ptrWdConfig; + for (wdIndex = 0u; wdIndex < CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex++) + { + if (0u != Cy_CapSense_IsWidgetEnabled(wdIndex, context)) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + /* Skip auto-tuning for MPSC widgets*/ + if (!((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) && + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod))) + #endif + { + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + ((((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) && + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN))) || \ + (((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType) && + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_LP_HW_EN)))) + { + ptrWdCxt = ptrWdCfg->ptrWdContext; + autoTuneConfig.kRef0 = ptrWdCxt->snsClk; + autoTuneConfig.nSub0 = ptrWdCxt->numSubConversions; + autoTuneConfig.refCdac = ptrWdCxt->cdacRef; + autoTuneConfig.fingerCap = ptrWdCxt->fingerCap; + + rawCountMax = 0u; + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + if (rawCountMax < ptrWdCfg->ptrSnsContext[snsIndex].raw) + { + rawCountMax = ptrWdCfg->ptrSnsContext[snsIndex].raw; + } + } + + autoTuneConfig.raw = (uint16_t)rawCountMax; + (void)Cy_CapSense_GetSmartSenseCapacitance(&autoTuneConfig); + autoTuneConfig.snsCapacitance /= ptrWdCfg->numChopCycles; + (void)Cy_CapSense_GetSmartSenseFrequencyDivider(&autoTuneConfig); + + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) + /* Checks for sub-widget */ + if(0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK)) + { + if(0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_CH_1_MASK)) + { + autoTuneConfig.kRef1 += CY_CAPSENSE_CSD_MFS_DIVIDER_OFFSET_F1; + } + + if(0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_CH_2_MASK)) + { + autoTuneConfig.kRef1 += CY_CAPSENSE_CSD_MFS_DIVIDER_OFFSET_F2; + } + } + #endif + + /* Configures widget sense clock divider by the calculated value */ + ptrWdCxt->snsClk = autoTuneConfig.kRef1; + ptrWdCxt->rowSnsClk = autoTuneConfig.kRef1; + + autoTuneConfig.refCdac = context->ptrInternalContext->intrCsdRawTarget; + (void)Cy_CapSense_GetSmartSenseNumSubconversions(&autoTuneConfig); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + + numberSubConv = autoTuneConfig.nSub1; + #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) + /* Decreases scan duration twice if Compensation CDAC enabled */ + numberSubConv >>= 1u; + #endif + + rawCountMax = numberSubConv * autoTuneConfig.kRef1; + + /* Finds Decimation Rate */ + cic2Decimation = CY_CAPSENSE_MAX_DECIMATION_RATE; + if ((CY_CAPSENSE_MAX_DECIMATION_RATE * CY_CAPSENSE_MAX_DECIMATION_RATE) > (rawCountMax / ptrWdCfg->numChopCycles)) + { + cic2Decimation = Cy_CapSense_SsSquareRoot16((uint16_t)(rawCountMax / ptrWdCfg->numChopCycles)); + } + cic2Decimation--; + + do + { + cic2Decimation++; + + /* Finds valid CIC2 sample number with rounding down */ + cic2Sample = Cy_CapSense_GetCIC2HwDivider(cic2Decimation); + if (cic2Sample > cic2Decimation) + { + cic2Sample >>= 1u; + } + + /* Switches to full sample numbers */ + cic2Sample++; + + /* Finds Nsub considering quantization we have with CIC2 sample number with rounding up */ + numberSubConv = ((cic2Decimation * cic2Sample) + (autoTuneConfig.kRef1 - 1u)) / autoTuneConfig.kRef1; + } + /* Checks if back-calculated CIC2 sample number is unchanged */ + while ((cic2Sample != ((numberSubConv * autoTuneConfig.kRef1) / cic2Decimation)) && + (cic2Decimation < CY_CAPSENSE_MAX_DECIMATION_RATE)); + + /* Calculates 75% of signal per desired finger capacitance */ + ptrWdCxt->sigPFC = (uint16_t)(((cic2Decimation * cic2Decimation) * autoTuneConfig.sigPFC) / rawCountMax); + ptrWdCxt->cicRate = (uint8_t)cic2Decimation; + ptrWdCxt->numSubConversions = (uint16_t)numberSubConv; + + #else /* #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) */ + + numberSubConv = autoTuneConfig.nSub1; + #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) + /* Decreases Nsub when CompCDAC is enabled as it increases the sensitivity approximately twice */ + numberSubConv >>= 1u; + #endif + + /* Limits Nsub to maximum possible value to avoid RawCount overflow */ + rawCountMax = ((uint32_t)MSCLP_SNS_RESULT_FIFO_RD_RAW_COUNT_Msk >> MSCLP_SNS_RESULT_FIFO_RD_RAW_COUNT_Pos) / autoTuneConfig.kRef1; + if (numberSubConv > rawCountMax) + { + numberSubConv = rawCountMax; + } + + /* Counts System Chopping */ + numberSubConv /= ptrWdCfg->numChopCycles; + + ptrWdCxt->numSubConversions = (uint16_t)numberSubConv; + + numberSubConv *= ptrWdCfg->numChopCycles; + #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) + numberSubConv <<= 1u; + #endif + + /* + * numberSubConv contains real value including chopping and compensation. + * autoTuneConfig.nSub1 contains initially calculated value. + * So, correcting the initially calculated sensitivity. + */ + ptrWdCxt->sigPFC = (uint16_t)((numberSubConv * autoTuneConfig.sigPFC) / autoTuneConfig.nSub1); + + #endif /* #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) */ + } + } + } + ptrWdCfg++; + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + /* Restores FILTER_MODE to CIC2 */ + msclpBase->FILTER_CTL |= MSCLP_FILTER_CTL_FILTER_MODE_Msk; + #endif + + /* Step #4: Assigns clock sources and restores project parameters */ + ptrWdCfg = context->ptrWdConfig; + for (wdIndex = 0u; wdIndex < CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex++) + { + if (0u != Cy_CapSense_IsWidgetEnabled(wdIndex, context)) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + /* Skip auto-tuning for MPSC widgets*/ + if (!((CY_CAPSENSE_MPSC_MIN_ORDER <= ptrWdCfg->mpOrder) && + (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod))) + #endif + { + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + ((((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != ptrWdCfg->wdType) && + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN))) || \ + (((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType) && + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_LP_HW_EN)))) + { + ptrWdCxt = ptrWdCfg->ptrWdContext; + /* Reverts back original customer's settings */ + ptrWdCxt->snsClkSource = (uint8_t)(((uint32_t)ptrWdCxt->snsClkSource >> CY_CAPSENSE_CLK_SOURCE_SMARTSENSE_POS) & + ~CY_CAPSENSE_CLK_SOURCE_SMARTSENSE_MASK); + } + } + } + ptrWdCfg++; + } + + autoTuneStatus |= Cy_CapSense_SsInitialize(context); + ptrCommonCxt->status &= ~CY_CAPSENSE_MW_STATE_SMARTSENSE_MASK; + + return autoTuneStatus; +} +#endif + + +/******************************************************************************* +* Function Name: Cy_CapSense_TransferRawCounts +****************************************************************************//** +* +* Transfers raw counts for specified sensors from internal MSCLP IP RAM to the +* corresponding field in the structure where the sensor data is stored. +* +* \param startSlotId +* The slot ID transfer will be started from. +* +* \param numberSlots +* The number of slots will be transferred. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_TransferRawCounts( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context) +{ + cy_stc_capsense_sensor_context_t * ptrSnsCxt; + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + uint32_t lastSlot; + uint32_t currSlot; + uint32_t tmpRawCount; + uint32_t wdIndex; + uint32_t snsIndex; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + /* Initialize frame data pointer */ + uint32_t * ptrSensorFrame = &context->ptrSensorFrameContext[startSlotId * CY_CAPSENSE_SENSOR_FRAME_SIZE]; + + /* Initialize sensor data pointer */ + __IOM uint32_t * ptrSensorData = &ptrHwBase->SNS.SENSOR_DATA[0u]; + #endif + + lastSlot = startSlotId + numberSlots - 1u; + + /* Reads the raw counts for last scan */ + for (currSlot = startSlotId; currSlot <= lastSlot; currSlot++) + { + wdIndex = context->ptrScanSlots[currSlot].wdId; + if (0u != Cy_CapSense_IsWidgetEnabled(wdIndex, context)) + { + snsIndex = context->ptrScanSlots[currSlot].snsId; + tmpRawCount = ptrHwBase->SNS.RESULT_FIFO_RD; + ptrSnsCxt = &context->ptrWdConfig[wdIndex].ptrSnsContext[snsIndex]; + ptrSnsCxt->status &= (uint8_t)~CY_CAPSENSE_SNS_OVERFLOW_MASK; + if (MSCLP_SNS_RESULT_FIFO_RD_OVERFLOW_Msk == (tmpRawCount & MSCLP_SNS_RESULT_FIFO_RD_OVERFLOW_Msk)) + { + ptrSnsCxt->status |= CY_CAPSENSE_SNS_OVERFLOW_MASK; + } + ptrSnsCxt->raw = (uint16_t)tmpRawCount; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + if (0u != context->ptrInternalContext->hwIirInit) + { + ptrSensorFrame[CY_CAPSENSE_SNS_HW_IIR_INDEX] &= ~CY_CAPSENSE_FRC_HW_IIR_FILTER_MASK; + ptrSensorFrame[CY_CAPSENSE_SNS_HW_IIR_INDEX] |= (ptrSensorData[CY_CAPSENSE_FRM_LP_SNS_LP_AOS_SNS_CTL3] & CY_CAPSENSE_FRC_HW_IIR_FILTER_MASK); + } + else + { + ptrSensorFrame[CY_CAPSENSE_SNS_HW_IIR_INDEX] &= ~CY_CAPSENSE_FRC_HW_IIR_FILTER_MASK; + ptrSensorFrame[CY_CAPSENSE_SNS_HW_IIR_INDEX] |= (uint32_t)((uint32_t)ptrSnsCxt->raw << CY_CAPSENSE_BYTE_SHIFT); + } + #endif + } + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + ptrSensorFrame += CY_CAPSENSE_SENSOR_FRAME_SIZE; + ptrSensorData += CY_MSCLP_11_SNS_REGS; + #endif + } +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_TransferLpRawCounts +****************************************************************************//** +* +* Transfers raw counts for the scanned low power sensors from internal MSCLP IP +* RAM to the raw count history. +* +* \param startSlotId +* The slot ID transfer will be started from. +* +* \param numberSlots +* The number of slots will be transferred. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_TransferLpRawCounts( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context) +{ + MSCLP_Type * ptrHwBase; + uint32_t lastSlot; + uint32_t currSlot; + uint32_t tmpRawCount; + uint32_t wdIndex; + uint32_t fifoSize; + uint32_t i; + uint8_t wdSnsMethod; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + cy_stc_capsense_common_context_t * ptrCommonCxt = context->ptrCommonContext; + cy_stc_capsense_lp_historic_context_t * ptrHistoricData = context->ptrLpHistoricContext; + + ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + lastSlot = startSlotId + numberSlots - 1u; + fifoSize = ptrHwBase->SNS.RESULT_FIFO_STATUS & MSCLP_SNS_RESULT_FIFO_STATUS_USED_Msk; + + /* Reset baseline after low power scan */ + if ((ptrHwBase->SNS.RESULT_FIFO_STATUS2 & MSCLP_SNS_RESULT_FIFO_STATUS2_FIFO_OVERFLOW_Msk) != 0uL) + { + ptrCommonCxt->lpScanSt = CY_CAPSENSE_SCAN_ST_BSLN_RESET_MSK; + } + else + { + /* Set valid mask for baseline */ + ptrCommonCxt->lpScanSt = CY_CAPSENSE_SCAN_ST_BSLN_RESET_MSK | CY_CAPSENSE_SCAN_ST_BSLN_VALID_MSK; + } + + ptrCommonCxt->lpFirstSnsId = (uint8_t)startSlotId; + ptrCommonCxt->lpSnsNumber = (uint8_t)numberSlots; + ptrCommonCxt->lpNumFrame = (uint8_t)(fifoSize / numberSlots); + + /* Reads raw counts history from MSCv3LP HW internal RAM to pop the FIFO */ + for (i = 0u; i < ptrCommonCxt->lpNumFrame; i++) + { + for (currSlot = startSlotId; currSlot <= lastSlot; currSlot++) + { + tmpRawCount = ptrHwBase->SNS.RESULT_FIFO_RD & MSCLP_SNS_RESULT_FIFO_RD_RAW_COUNT_Msk; + + wdIndex = context->ptrLpScanSlots[currSlot].wdId; + if (0u != Cy_CapSense_IsWidgetEnabled(wdIndex, context)) + { + ptrWdCfg = &context->ptrWdConfig[wdIndex]; + wdSnsMethod = ptrWdCfg->senseMethod; + + if ((CY_CAPSENSE_CSX_GROUP == wdSnsMethod) || + (CY_CAPSENSE_ISX_GROUP == wdSnsMethod)) + { + /* Limit raw counts */ + if (tmpRawCount < ptrWdCfg->ptrWdContext->maxRawCount) + { + /* Invert raw counts for CSX/ISX widgets */ + tmpRawCount = (ptrWdCfg->ptrWdContext->maxRawCount - tmpRawCount); + } + else + { + tmpRawCount = 0u; + } + } + + *ptrHistoricData = (cy_stc_capsense_lp_historic_context_t)tmpRawCount; + } + ptrHistoricData++; + } + } +} +#endif + + +/******************************************************************************* +* Function Name: Cy_CapSense_WaitMrssStatusChange +****************************************************************************//** +* +* Waits till end of MRSS status is changed or till the provided timeout. +* +* \param timeout +* Watchdog timeout in microseconds. +* +* \param mrssStatus +* MRSS status to be set +* - CY_CAPSENSE_MRSS_TURN_ON - MRSS should be turned on +* - CY_CAPSENSE_MRSS_TURN_OFF - MRSS should be turned off +* - CY_CAPSENSE_MRSS_IMO_TURN_ON - MRSS_IMO should be turned on +* - CY_CAPSENSE_MRSS_IMO_TURN_OFF - MRSS_IMO should be turned off +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_TIMEOUT - The software watchdog timeout occurred +* during the wait, the MRSS status change was not +* completed. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_WaitMrssStatusChange( + uint32_t timeout, + uint32_t mrssStatus, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t status = CY_CAPSENSE_STATUS_SUCCESS; + uint32_t waitTime = timeout; + uint32_t mrssMask = MSCLP_MRSS_STATUS_MRSS_UP_Msk; + uint32_t mrssStatusLocal = mrssStatus; + + if ((CY_CAPSENSE_MRSS_IMO_TURN_ON == mrssStatus) || (CY_CAPSENSE_MRSS_IMO_TURN_OFF == mrssStatus)) + { + mrssMask = MSCLP_MRSS_STATUS_IMO_UP_Msk; + mrssStatusLocal = (mrssStatusLocal & 0x1u) << MSCLP_MRSS_STATUS_IMO_UP_Pos; + } + + while (mrssStatusLocal == (context->ptrCommonConfig->ptrChConfig->ptrHwBase->MRSS_STATUS & mrssMask)) + { + if (0uL == waitTime) + { + status = CY_CAPSENSE_STATUS_TIMEOUT; + break; + } + /* Delay for 1us */ + Cy_SysLib_DelayUs(1u); + waitTime--; + } + + return status; +} + + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_GetCIC2SamplesMax +****************************************************************************//** +* +* This internal function determines the MAX number of CIC2 samples for specified +* decimation rate that can be accumulated in the internal CIC2 HW register +* with no overflow. +* +* \param cic2Rate +* CIC2 decimation rate. +* +* \return +* The MAX allowed number of CIC2 samples. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetCIC2SamplesMax( + uint32_t cic2Rate) +{ + uint32_t retVal; + + retVal = CY_CAPSENSE_CIC2_ACC_MAX_VAL / (cic2Rate * cic2Rate); + + return retVal; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetCIC2HwDivider +****************************************************************************//** +* +* This internal function determines the value of the divider that will be +* applied to the data, accumulated by the CIC2 HW for the specified number of +* samples. +* +* \param cic2Samples +* The number of valid (FullNumber - 1) CIC2 samples for the specified sensing +* parameters. This value can be obtained by using the Cy_CapSense_GetCIC2SamplesNum +* function. +* +* \return +* The CIC2 HW divider value. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetCIC2HwDivider( + uint32_t cic2Samples) +{ + uint32_t cic2Divider; + + cic2Divider = 1uL << Cy_CapSense_GetCIC2HwShift(cic2Samples); + + if (CY_CAPSENSE_CIC2_DIVIDER_MAX < cic2Divider) + { + cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_MAX; + } + + return cic2Divider; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetCIC2HwShift +****************************************************************************//** +* +* This internal function determines the value of the shift that will be +* applied to the data, accumulated by the CIC2 HW for the specified number of +* samples. +* +* \param cic2Samples +* The number of valid (FullNumber - 1) CIC2 samples for the specified sensing +* parameters. This value can be obtained by using the Cy_CapSense_GetCIC2SamplesNum +* function. +* +* \return +* The CIC2 HW Shift value. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetCIC2HwShift( + uint32_t cic2Samples) +{ + uint32_t cic2Shift = 0u; + + while (cic2Samples > (1uL << cic2Shift)) + { + cic2Shift++; + } + + if (CY_CAPSENSE_CIC2_SHIFT_MAX < cic2Shift) + { + cic2Shift = CY_CAPSENSE_CIC2_SHIFT_MAX; + } + + return cic2Shift; +} + + +#if (CY_CAPSENSE_CIC2_FILTER_AUTO_EN) +/******************************************************************************* +* Function Name: Cy_CapSense_InitializeCic2Shift +****************************************************************************//** +* +* Performs the auto-selection of CIC2 HW filter parameter. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_TIMEOUT - A timeout reached during the scan time measurement. +* - CY_CAPSENSE_STATUS_BAD_PARAM - Not valid input parameter. +* - CY_CAPSENSE_STATUS_HW_BUSY - The MSCLP HW block is busy and cannot be +* switched to another mode. +* - CY_CAPSENSE_STATUS_BAD_CONFIG - The parameters are out of specified range. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_InitializeCic2Shift( + cy_stc_capsense_context_t * context) +{ + uint32_t wdIndex; + uint32_t scanSlotId; + uint16_t tmpVal; + cy_capsense_status_t retVal = CY_CAPSENSE_STATUS_SUCCESS; + + cy_stc_capsense_widget_context_t * ptrWdCxt; + const cy_stc_capsense_widget_config_t * ptrWdCfg = context->ptrWdConfig; + + for (wdIndex = 0u; wdIndex < CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex++) + { + if (0u != Cy_CapSense_IsWidgetEnabled(wdIndex, context)) + { + ptrWdCxt = ptrWdCfg->ptrWdContext; + + if (0u != (ptrWdCxt->cicShift & CY_CAPSENSE_CIC_AUTO_MASK)) + { + scanSlotId = ptrWdCfg->firstSlotId; + + /* Obtain the scan duration in terms of Mod Clock cycles. */ + retVal |= Cy_CapSense_ExecuteSaturatedScan(&tmpVal, wdIndex, scanSlotId, CY_CAPSENSE_SATURATED_SCAN_TIME, context); + ptrWdCxt->cicShift = (uint8_t)Cy_CapSense_GetCIC2HwShift(tmpVal); + ptrWdCxt->cicShift |= CY_CAPSENSE_CIC_AUTO_MASK; + } + + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || \ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || + ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType))) + { + if (0u != (ptrWdCxt->rowCicShift & CY_CAPSENSE_CIC_AUTO_MASK)) + { + scanSlotId = (uint32_t)ptrWdCfg->firstSlotId + ptrWdCfg->numCols; + + /* Obtain the scan duration in terms of Mod Clock cycles. */ + retVal |= Cy_CapSense_ExecuteSaturatedScan(&tmpVal, wdIndex, scanSlotId, CY_CAPSENSE_SATURATED_SCAN_TIME, context); + + /* Obtain the number of valid (FullNumber - 1) CIC2 samples */ + ptrWdCxt->rowCicShift = (uint8_t)Cy_CapSense_GetCIC2HwShift(tmpVal); + ptrWdCxt->rowCicShift |= CY_CAPSENSE_CIC_AUTO_MASK; + } + } + #endif + } + ptrWdCfg++; + } + + /* Update Active frame configuration with new calculated CIC2 shift value. */ + Cy_CapSense_GenerateAllSensorConfig(CY_CAPSENSE_SNS_FRAME_ACTIVE, context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + /* Update LP frame configuration with new calculated CIC2 shift value. */ + Cy_CapSense_GenerateAllSensorConfig(CY_CAPSENSE_SNS_FRAME_LOW_POWER, context); + #endif /* CY_CAPSENSE_LP_EN */ + + /* Resetting the HW configuration in order to trigger the base frame initialization in scope of the + * next Cy_CapSense_SwitchHwConfiguration() function call with the desired HW configuration. + */ + if (CY_CAPSENSE_STATUS_SUCCESS == retVal) + { + retVal |= Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT, context); + } + + if (CY_CAPSENSE_STATUS_SUCCESS == retVal) + { + retVal |= Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING, context); + } + + return retVal; +} +#endif /* #if (CY_CAPSENSE_CIC2_FILTER_AUTO_EN) */ + +#endif /* #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_RepeatScan +****************************************************************************//** +* +* Triggers the scan of the frame, which is already configured in the MSCLP +* HW block. The function is available only for the single-channel solution. +* +* The function repeats the frame scan last configured and +* triggered by the Cy_CapSense_ScanSlots() or Cy_CapSense_ScanLpSlots() +* functions. +* +* The function can be used only with the following limitations: +* - the previous scan is completed; +* - the scan frame to repeat consists of less than 37 sensors; +* - there were regular scans previously performed, not BIST or calibration +* or SmartSense scans. +* +* The function can be used as many times as needed. +* +* \note +* The function is available only for the fifth-generation +* low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed +* successfully. +* - CY_CAPSENSE_STATUS_INVALID_STATE - The previous scan is not completed or +* it was a specific scan (BIST, +* SmartSense, etc.) and the MSCLP HW +* configuration was changed. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_RepeatScan(cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_INVALID_STATE; + + if ((CY_CAPSENSE_BUSY != Cy_CapSense_IsBusy(context)) && + (CY_CAPSENSE_ENABLE == context->ptrInternalContext->repeatScanEn)) + { + Cy_CapSense_SetBusyFlags(context); + context->ptrInternalContext->currentSlotIndex = context->ptrInternalContext->startSlotIndex; + context->ptrCommonConfig->ptrChConfig->ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + + #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_EXT_FRM_START_EN) + context->ptrCommonConfig->ptrChConfig->ptrHwBase->WAKEUP_CMD = MSCLP_WAKEUP_CMD_START_FRAME_AOS_Msk; + #endif + + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + } + + return capStatus; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_SetupCpuOperatingMode +****************************************************************************//** +* +* Configures the MSCLP HW block for operation in the CPU operating mode. +* Use the Cy_CapSense_StartCpuScan() function to trigger scan in the CPU operating +* mode. The end of the scan in the CPU operating mode can be detected by using the +* Cy_CapSense_WaitEndOfCpuScan() function. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_SetupCpuOperatingMode(cy_stc_capsense_context_t * context) +{ + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + + /* Disable HW IP to allow MRSS operations */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + /* Check for system VDDA value and enable PUMP if VDDA is less then threshold */ + #if (CY_MSCLP_VDDA_PUMP_TRESHOLD > CY_CAPSENSE_VDDA_MV) + ptrHwBase->PUMP_CTL = MSCLP_PUMP_CTL_PUMP_MODE_Msk; + #else + ptrHwBase->PUMP_CTL = 0x00u; + #endif + + /* Check if IMO is running for the calibration operation */ + if (0u == (context->ptrCommonConfig->ptrChConfig->ptrHwBase->MRSS_STATUS & MSCLP_MRSS_STATUS_MRSS_UP_Msk)) + { + /* Enable only REF and IMO to provide access to the SNS_STC registers */ + ptrHwBase->MRSS_CMD = MSCLP_MRSS_CMD_MRSS_START_Msk; + (void)Cy_CapSense_WaitMrssStatusChange( + CY_MSCLP_CLK_LF_PERIOD_MAX * CY_MSCLP_MRSS_TIMEOUT_SMALL, + CY_CAPSENSE_MRSS_TURN_ON, context); + } + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_EXT_FRM_START_EN) + /* Clear the external start scan mode */ + ptrHwBase->CTL &= ~MSCLP_CTL_EXT_FRAME_START_MODE_Msk; + #endif + + /* Enable HW IP to allow a scan frame start */ + ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + + /* Disable HW processing */ + ptrHwBase->CE_CTL = 0x00u; + + /* Disable all interrupts */ + ptrHwBase->INTR_LP_MASK = 0x00u; + + /* Clear all pending interrupts */ + ptrHwBase->INTR_LP = CY_CAPSENSE_MSCLP_INTR_LP_ALL_MSK; + ptrHwBase->INTR = CY_CAPSENSE_MSCLP_INTR_ALL_MSK; + + /* Set CPU operating mode */ + context->ptrInternalContext->operatingMode = CY_CAPSENSE_CTL_OPERATING_MODE_CPU; + CY_REG32_CLR_SET(ptrHwBase->CTL, MSCLP_CTL_OPERATING_MODE, CY_CAPSENSE_CTL_OPERATING_MODE_CPU); + + /* Set raw counts to store to FIFO */ + CY_REG32_CLR_SET(ptrHwBase->SCAN_CTL1, MSCLP_SCAN_CTL1_RC_STORE_EN, CY_CAPSENSE_ENABLE); +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_StartCpuScan +****************************************************************************//** +* +* Sets configuration of sensor frame registers of the MSCLP HW block and +* starts the scan. The end of the scan in the CPU operating mode can be detected +* by using the Cy_CapSense_WaitEndOfCpuScan() function. +* +* \note Call the Cy_CapSense_SetupCpuOperatingMode() function to switch the +* MSCLP HW block to the CPU operating mode before triggering CPU scan by using +* the Cy_CapSense_StartCpuScan() routine. +* +* \param scanConfig +* The pointer to a scan configuration structure. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_StartCpuScan(const uint32_t * scanConfig, cy_stc_capsense_context_t * context) +{ + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + + /* Enable HW IP */ + ptrHwBase->CTL |= MSCLP_CTL_ENABLED_Msk; + + /* Clear all pending interrupts */ + ptrHwBase->INTR_LP = CY_CAPSENSE_MSCLP_INTR_LP_ALL_MSK; + ptrHwBase->INTR = CY_CAPSENSE_MSCLP_INTR_ALL_MSK; + + /* Set sensor config registers (frame) */ + Cy_MSCLP_ConfigureScan(ptrHwBase, CY_MSCLP_6_SNS_REGS, scanConfig); + + /* Configure the last slot */ + ptrHwBase->SNS.SNS_CTL |= MSCLP_SNS_SNS_CTL_LAST_Msk | MSCLP_SNS_SNS_CTL_VALID_Msk; + + /* Start scanning with START_SCAN */ + ptrHwBase->SNS.SNS_CTL |= MSCLP_SNS_SNS_CTL_START_SCAN_Msk; + + /* Start FSM with START_FRAME */ + ptrHwBase->SNS.FRAME_CMD = MSCLP_SNS_FRAME_CMD_START_FRAME_Msk; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_WaitEndOfCpuScan +****************************************************************************//** +* +* This internal function checks for the scan status. If the scan ends before +* the software watch-dog triggering, the function returns a non-zero watch-dog +* cycles number. If the software watch-dog triggers during the scan, +* the function returns zero. +* +* Use the Cy_CapSense_GetScanWatchdogTime() or Cy_CapSense_CalcSampleWatchdogTime() +* function to calculate the watchdog time in microseconds for the scan with the +* specified parameters. +* +* \param watchdogTime +* A watch-dog time interval in microseconds. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns watch-dog counter. If it is equal to zero, it means timeout happened. +* +*******************************************************************************/ +uint32_t Cy_CapSense_WaitEndOfCpuScan(uint32_t watchdogTime, cy_stc_capsense_context_t * context) +{ + uint32_t tmpVal; + const uint32_t cpuCyclesPerLoop = 5u; + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + + tmpVal = context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA; + tmpVal = Cy_CapSense_WatchdogCyclesNum(watchdogTime, tmpVal, cpuCyclesPerLoop); + + while ((ptrHwBase->INTR & MSCLP_INTR_MASK_SCAN_Msk) == 0u) + { + if (0uL == tmpVal) + { + break; + } + tmpVal--; + } + + /* Clear all pending interrupts */ + ptrHwBase->INTR = CY_CAPSENSE_MSCLP_INTR_ALL_MSK; + + return tmpVal; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ExecuteSaturatedScan +****************************************************************************//** +* +* This internal function executes a scan with the saturated channel to obtain +* the MAX raw count or the scan duration for the specified scan slot. +* +* \param ptrMaxRaw +* Specifies the pointer to store the resulting MAX raw count value. +* +* \param widgetId +* Specifies the ID number of the widget. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param scanSlotId +* The slot ID scans will be done for. +* +* \param mode +* Saturated scan execution mode: +* - CY_CAPSENSE_SATURATED_MAX_COUNT - Used to obtain the MAX raw count. +* - CY_CAPSENSE_SATURATED_SCAN_TIME - Used to obtain the scan duration in terms of Mod Clock cycles. +* +* \param context +* The pointer to the context structure allocated by the user or middleware. +* +* \return +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_TIMEOUT - A timeout reached during the scan time measurement. +* - CY_CAPSENSE_STATUS_BAD_PARAM - Not valid input parameter. +* - CY_CAPSENSE_STATUS_HW_BUSY - The MSCLP HW block is busy and cannot be +* switched to another mode. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ExecuteSaturatedScan( + uint16_t * ptrMaxRaw, + uint32_t widgetId, + uint32_t scanSlotId, + uint32_t mode, + cy_stc_capsense_context_t * context) +{ + uint32_t tmpVal; + uint32_t slotFrameIdx; + uint32_t * ptrSnsFrame; + uint32_t scanConfigTmp[CY_MSCLP_6_SNS_REGS]; + + cy_capsense_status_t status; + + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + uint32_t kref; + uint32_t nsub; + #endif + + (void)mode; + + /* Configures the MSCLP HW block for operation with the permanently saturated channel. */ + status = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CHANNEL_SATURATION, context); + + /* Obtain the scan parameters offset in the cy_capsense_sensorFrameContext[] + * array for the slots that are part of Active widgets. + */ + slotFrameIdx = scanSlotId * CY_CAPSENSE_SENSOR_FRAME_SIZE; + ptrSnsFrame = &context->ptrSensorFrameContext[slotFrameIdx]; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if (context->ptrWdConfig[widgetId].wdType == (uint8_t)CY_CAPSENSE_WD_LOW_POWER_E) + { + /* Obtain the scan parameters offset in the cy_capsense_sensorFrameContext[] + * array for the slots that are part of Low power widgets. + */ + slotFrameIdx = scanSlotId * CY_MSCLP_11_SNS_REGS; + slotFrameIdx += CY_CAPSENSE_FRM_LP_SNS_SW_SEL_CSW_LO_MASK2_INDEX; + ptrSnsFrame = &context->ptrSensorFrameLpContext[slotFrameIdx]; + } + #endif + + /* The measurement with a saturated channel will be performed with all the sensors disconnected. + * The code below sets up the configuration of the LO_MASK registers with 0x00000000u. + * The SW_SEL_CSW_FUNC[0u] is configured in the scope of the Cy_CapSense_ConfigureSaturationMode() + * routine with all the switches open. + */ + scanConfigTmp[CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK2_INDEX] = 0x00u; /* Set up the SNS_SW_SEL_CSW_LO_MASK2 register configuration. */ + scanConfigTmp[CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK1_INDEX] = 0x00u; /* Set up the SNS_SW_SEL_CSW_LO_MASK1 register configuration. */ + scanConfigTmp[CY_CAPSENSE_SNS_SW_SEL_CSW_LO_MASK0_INDEX] = 0x00u; /* Set up the SNS_SW_SEL_CSW_LO_MASK0 register configuration. */ + + /* The code below sets up configuration of the sense control registers. */ + scanConfigTmp[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] = ptrSnsFrame[CY_CAPSENSE_SNS_SCAN_CTL_INDEX]; /* Set up the SNS_SCAN_CTL register configuration. */ + scanConfigTmp[CY_CAPSENSE_SNS_CDAC_CTL_INDEX] = ptrSnsFrame[CY_CAPSENSE_SNS_CDAC_CTL_INDEX]; /* Set up the SNS_CDAC_CTL register configuration. */ + scanConfigTmp[CY_CAPSENSE_SNS_CTL_INDEX] = ptrSnsFrame[CY_CAPSENSE_SNS_CTL_INDEX]; /* Set up the SNS_CTL register configuration. */ + + /* Disable system chopping */ + scanConfigTmp[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] &= ~MSCLP_SNS_SNS_SCAN_CTL_NUM_CONV_Msk; + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_AUTO_EN)) + if(CY_CAPSENSE_SATURATED_SCAN_TIME == mode) + { + /* Disable the CIC2 shift and set the decimation rate to 1 (DECIM_RATE = 0) to increment the + * CIC2 accumulator each Mod Clock cycle and then copy the result to FIFO without shifting. + * The final value in the FIFO fill is the equal number of Mod Clock cycles per scan minus 1 because + * the first CIC2 sample is invalid and will be skipped. This skipped Mod Clock cycle will be considered + * at the end of this function. + */ + scanConfigTmp[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] &= (uint32_t)(~MSCLP_SNS_SNS_SCAN_CTL_CIC2_SHIFT_Msk); + scanConfigTmp[CY_CAPSENSE_SNS_CTL_INDEX] &= (uint32_t)(~MSCLP_SNS_SNS_CTL_DECIM_RATE_Msk); + } + #endif + + if(status == CY_CAPSENSE_STATUS_SUCCESS) + { + /* Initiate the scan in the CPU operating mode. */ + Cy_CapSense_StartCpuScan((const uint32_t *)scanConfigTmp, context); + + tmpVal = Cy_CapSense_GetScanWatchdogTime(widgetId, scanSlotId, context); + tmpVal = Cy_CapSense_WaitEndOfCpuScan(tmpVal, context); + + if(0u == tmpVal) + { + status |= CY_CAPSENSE_STATUS_TIMEOUT; + } + } + + tmpVal = (ptrHwBase->SNS.RESULT_FIFO_RD & MSCLP_SNS_RESULT_FIFO_RD_RAW_COUNT_Msk) >> + MSCLP_SNS_RESULT_FIFO_RD_RAW_COUNT_Pos; + + /* Disable HW IP */ + ptrHwBase->CTL &= (~MSCLP_CTL_ENABLED_Msk); + + #if (CY_CAPSENSE_ENABLE != CY_CAPSENSE_CIC2_FILTER_EN) + tmpVal <<= (context->ptrWdConfig[widgetId].numChopCycles - 1u); + #elif ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_AUTO_EN)) + if(CY_CAPSENSE_SATURATED_SCAN_TIME == mode) + { + if (CY_CAPSENSE_CLK_SOURCE_PRS == ((uint32_t)context->ptrWdContext[widgetId].snsClkSource & CY_CAPSENSE_CLK_SOURCE_MASK)) + { + tmpVal >>= 1u; + } + /* The final value in the FIFO fill is the equal number of Mod Clock cycles per scan minus 1 because + * the first CIC2 sample is invalid and will be skipped. The code below takes into account this skipped + * Mod Clock cycle. + */ + tmpVal++; + /* Obtain the number of valid (FullNumber - 1) CIC2 samples */ + tmpVal = (tmpVal / context->ptrWdContext[widgetId].cicRate) - 1u; + } + else + { + kref = ((scanConfigTmp[CY_CAPSENSE_SNS_CTL_INDEX] & MSCLP_SNS_SNS_CTL_SENSE_DIV_Msk) >> MSCLP_SNS_SNS_CTL_SENSE_DIV_Pos) + 1u; + nsub = ((scanConfigTmp[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] & MSCLP_SNS_SNS_SCAN_CTL_NUM_SUB_CONVS_Msk) >> MSCLP_SNS_SNS_SCAN_CTL_NUM_SUB_CONVS_Pos) + 1u; + + tmpVal = (tmpVal * context->ptrWdConfig[widgetId].numChopCycles) + + (((kref * nsub) >> ((uint32_t)context->ptrWdContext[widgetId].cicShift & (uint32_t)(~(uint32_t)CY_CAPSENSE_CIC_AUTO_MASK))) * + (context->ptrWdConfig[widgetId].numChopCycles - 1u)); + } + #else + kref = ((scanConfigTmp[CY_CAPSENSE_SNS_CTL_INDEX] & MSCLP_SNS_SNS_CTL_SENSE_DIV_Msk) >> MSCLP_SNS_SNS_CTL_SENSE_DIV_Pos) + 1u; + nsub = ((scanConfigTmp[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] & MSCLP_SNS_SNS_SCAN_CTL_NUM_SUB_CONVS_Msk) >> MSCLP_SNS_SNS_SCAN_CTL_NUM_SUB_CONVS_Pos) + 1u; + + tmpVal = (tmpVal * context->ptrWdConfig[widgetId].numChopCycles) + + (((kref * nsub) >> ((uint32_t)context->ptrWdContext[widgetId].cicShift & (uint32_t)(~(uint32_t)CY_CAPSENSE_CIC_AUTO_MASK))) * + (context->ptrWdConfig[widgetId].numChopCycles - 1u)); + #endif + + *ptrMaxRaw = CY_CAPSENSE_16_BIT_MASK; + if(tmpVal <= CY_CAPSENSE_16_BIT_MASK) + { + *ptrMaxRaw = (uint16_t)tmpVal; + } + + return status; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ConfigureSaturationMode +****************************************************************************//** +* +* Configures the MSCLP HW block for operation with the permanently saturated +* channel. +* The raw data counter is continuously enabled from the beginning to the end of +* the scan. The scan is performed in the CPU operating mode. +* +* \param context +* The pointer to the context structure allocated by the user or middleware. +* +*******************************************************************************/ +void Cy_CapSense_ConfigureSaturationMode( + cy_stc_capsense_context_t * context) +{ + uint32_t i; + MSCLP_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig->ptrHwBase; + + Cy_CapSense_SetupCpuOperatingMode(context); + + /* Configure the Switch Control Global Function #0 to have all switches open. + * All the sensing electrodes will be disconnected during the MAX raw count measurement. + */ + ptrHwBase->SW_SEL_CSW_FUNC[0u] = 0x00u; + + /* Iterate through all the MODE structures and update them with the configuration, + * required to saturate the measurement channel. + */ + for(i = 0u; i < MSCLP_SENSE_MODE_NR; i++) + { + /* The 0x03 value of the RMF field enables the internal voltage divider and + * configures it to generate VDDA*0.8 voltage at the output. + */ + ptrHwBase->MODE[i].SW_SEL_TOP = _VAL2FLD(MSCLP_MODE_SW_SEL_TOP_RMF, 0x03u); + + /* Set the CPF and the CMG bits to get the positive comparator input connected + * to the VDDA*0.8 voltage level and the negative comparator input to the GND. + */ + ptrHwBase->MODE[i].SW_SEL_COMP = _VAL2FLD(MSCLP_MODE_SW_SEL_COMP_CPF, 0x01u) | + _VAL2FLD(MSCLP_MODE_SW_SEL_COMP_CMG, 0x01u); + } + +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetScanWatchdogTime +****************************************************************************//** +* +* This internal function calculates the watchdog time in microseconds for the +* specified slot. The calculated value is the duration of one sample with the +* five-time margin. +* +* WATCHDOG_TIME = (SCAN_CYCLES / MOD_CLK_FREQ) * 5; +* +* where: +* +* SCAN_CYCLES = (INIT_CYCLES + PRO_CYCLES + CONV_CYCLES + EPI_CYCLES) * NUM_CONV; +* INIT_CYCLES = INIT_CMOD_RAIL_CYCLES + INIT_CMOD_SHORT_CYCLES; +* PRO_CYCLES = PRO_OFFSET_CYCLES + (PRO_WAIT_KREF_DELAY * SENSE_DIV / 4); +* CONV_CYCLES = (PRO_DUMMY_SUB_CONVS + NUM_SUB_CONVS) * SENSE_DIV; +* EPI_CYCLES = EPI_KREF_DELAY * SENSE_DIV / 4; +* +* The corresponding parameters are listed below: +* - EPI_KREF_DELAY - The duration of EPILOGUE defined in relation to Kref. +* The value is interpreted as SENSE_DIV/4 increments. +* - INIT_CMOD_RAIL_CYCLES - Duration of the coarse initialization phase when +* Cmod1 is connected to VDDA and Cmod2 is connected to VSSA. The parameter is +* defined in terms of Mod Clock cycles. +* - INIT_CMOD_SHORT_CYCLES - Duration of the coarse short phase when +* Cmod1 and Cmod2 are shorted together. The parameter is defined in terms of +* Mod Clock cycles. +* - PRO_OFFSET_CYCLES - Maximum number of Mod Clock cycles to be assigned for +* the PRO_OFFSET state. If NUM_PRO_OFFSET_TRIPS are observed before this +* timeout, exit at that point. +* - PRO_DUMMY_SUB_CONVS - Number of sub-conversions (dummy cycles) to be run +* during PRO_DUMMY. +* - PRO_WAIT_KREF_DELAY - The duration of PRO_WAIT defined in relation to Kref. +* The value is interpreted as SENSE_DIV/4 increments. +* - SENSE_DIV - The length of one sub-conversion in terms of Mod Clock cycles. +* - NUM_SUB_CONVS - Number of sub-conversions. +* - NUM_CONV - Number of chop cycles. +* - MOD_CLK_FREQ - Modulation clock frequency. +* +* \param widgetId +* Specifies the ID number of the widget. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param scanSlotId +* The slot ID the watchdog time calculation will be done for. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns watch-dog time interval in microseconds. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetScanWatchdogTime( + uint32_t widgetId, + uint32_t scanSlotId, + cy_stc_capsense_context_t * context) +{ + uint32_t tmpVal; + uint32_t snsClkDivider; + uint32_t modClkFreqMhz; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_TOUCHPAD_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_MATRIX_EN)) + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + #endif /* CY_CAPSENSE_CSD_TOUCHPAD_EN || CY_CAPSENSE_CSD_MATRIX_EN */ + + /* Define the MARGIN_KOEFF = 5 */ + const uint32_t watchdogTimeMarginCoeff = 5u; + + (void)scanSlotId; + + /* Initialize the .modClkFreqMhz field with the MRSS IMO frequency value. */ + #if (CY_CAPSENSE_IMO_FREQUENCY == CY_CAPSENSE_IMO_25_MHZ) + modClkFreqMhz = CY_CAPSENSE_IMO_CLK_25_MHZ; + #elif (CY_CAPSENSE_IMO_FREQUENCY == CY_CAPSENSE_IMO_38_MHZ) + modClkFreqMhz = CY_CAPSENSE_IMO_CLK_38_MHZ; + #else /* (CY_CAPSENSE_IMO_FREQUENCY == CY_CAPSENSE_IMO_46_MHZ) */ + modClkFreqMhz = CY_CAPSENSE_IMO_CLK_46_MHZ; + #endif + + /* Initialize pointers with the configuration address for the specified scan slot and MSC channel #0 */ + ptrWdCfg = &context->ptrWdConfig[widgetId]; + + /* Initialize the .snsClkDivider field with the value for the slot that is + * specified by the scanSlotId parameter of the function. + */ + snsClkDivider = ptrWdCfg->ptrWdContext->snsClk; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + { + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_TOUCHPAD_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_MATRIX_EN)) + ptrScanSlots = &context->ptrScanSlots[scanSlotId]; + if (ptrWdCfg->numCols <= ptrScanSlots->snsId) + { + snsClkDivider = ptrWdCfg->ptrWdContext->rowSnsClk; + } + #endif /* CY_CAPSENSE_CSD_TOUCHPAD_EN || CY_CAPSENSE_CSD_MATRIX_EN */ + } + #endif /* CY_CAPSENSE_CSD_EN */ + + /* Calculate the INIT_CYCLES number. */ + tmpVal = ((uint32_t)context->ptrInternalContext->numCoarseInitChargeCycles + context->ptrInternalContext->numCoarseInitSettleCycles); + + /* Add the PRO_OFFSET_CYCLES number. */ + tmpVal += (uint32_t)context->ptrInternalContext->numProOffsetCycles; + + /* Add the sum of PRO_CYCLES and EPI_CYCLES. Shift by 2 is required because for the fifth-generation LP devices + * the .numEpiCycles parameter are interpreted as SENSE_DIV/4 increments. + */ + if (CY_CAPSENSE_CLK_SOURCE_PRS == (ptrWdCfg->ptrWdContext->snsClkSource & CY_CAPSENSE_CLK_SOURCE_MASK)) + { + tmpVal += ((uint32_t)context->ptrInternalContext->numProWaitKrefDelayPrs + context->ptrInternalContext->numEpiKrefDelayPrs) * (snsClkDivider >> 2u); + } + else + { + tmpVal += ((uint32_t)context->ptrInternalContext->numProWaitKrefDelay + context->ptrInternalContext->numEpiKrefDelay) * (snsClkDivider >> 2u); + } + + /* Add the CONV_CYCLES number. */ + tmpVal += ((uint32_t)context->ptrInternalContext->numFineInitCycles + ptrWdCfg->ptrWdContext->numSubConversions) * snsClkDivider; + + if (CY_CAPSENSE_CLK_SOURCE_PRS == (ptrWdCfg->ptrWdContext->snsClkSource & CY_CAPSENSE_CLK_SOURCE_MASK)) + { + /* Taking into account correction that is implemented in the Cy_CapSense_AdjustSnsClkDivider() function, + * the scan duration is two time longer if the PRS is used as the sense clock source. + */ + tmpVal <<= 1u; + } + + /* Calculate the SCAN_CYCLES number by multiplying the Mod Clock cycles number per one chop cycle by + * number of chop cycles. + */ + tmpVal *= ptrWdCfg->numChopCycles; + + /* Convert the calculated duration in terms of clk_mod cycles to the microseconds. */ + tmpVal /= modClkFreqMhz; + + /* Multiply the calculated value by the MARGIN_KOEFF value. */ + tmpVal *= watchdogTimeMarginCoeff; + + return tmpVal; +} + + +#endif /* CY_IP_M0S8MSCV3LP */ + + +/* [] END OF FILE */ diff --git a/cy_capsense_sensing_lp.h b/cy_capsense_sensing_lp.h new file mode 100644 index 0000000..ea5187d --- /dev/null +++ b/cy_capsense_sensing_lp.h @@ -0,0 +1,670 @@ +/***************************************************************************//** +* \file cy_capsense_sensing_lp.h +* \version 4.0 +* +* \brief +* This file provides the function prototypes specific to the scanning module. +* +******************************************************************************** +* \copyright +* Copyright 2020-2023, Cypress Semiconductor Corporation (an Infineon company) +* or an affiliate of Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +*******************************************************************************/ + + +#if !defined(CY_CAPSENSE_SENSING_LP_H) +#define CY_CAPSENSE_SENSING_LP_H + +#include "cy_syslib.h" +#include "cy_sysclk.h" +#include "cy_capsense_common.h" +#include "cy_capsense_structure.h" +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_msclp.h" +#endif + +#if (defined(CY_IP_M0S8MSCV3LP)) + +#if defined(__cplusplus) +extern "C" { +#endif + + +/******************************************************************************* +* Function Prototypes +*******************************************************************************/ + +/******************************************************************************/ +/** \addtogroup group_capsense_high_level *//** \{ */ +/******************************************************************************/ +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + cy_capsense_status_t Cy_CapSense_ScanLpSlots( + uint32_t startLpSlotId, + uint32_t numberLpSlots, + cy_stc_capsense_context_t * context); + cy_capsense_status_t Cy_CapSense_ScanAllLpSlots( + cy_stc_capsense_context_t * context); + cy_capsense_status_t Cy_CapSense_ScanAllLpWidgets( + cy_stc_capsense_context_t * context); + cy_capsense_status_t Cy_CapSense_ConfigureMsclpWotTimer( + uint32_t wakeupTimer, + cy_stc_capsense_context_t * context); +#endif /* CY_CAPSENSE_LP_EN */ + +cy_capsense_status_t Cy_CapSense_ConfigureMsclpTimer( + uint32_t wakeupTimer, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_IloCompensate( + cy_stc_capsense_context_t * context); +/** \} */ + + +/******************************************************************************/ +/** \addtogroup group_capsense_low_level *//** \{ */ +/******************************************************************************/ +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + cy_capsense_status_t Cy_CapSense_LpSlotPinState( + uint32_t lpSlotId, + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t pinState, + cy_stc_capsense_context_t * context); +#endif /* CY_CAPSENSE_LP_EN */ + +#if (((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) && \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN)) +cy_capsense_status_t Cy_CapSense_CalibrateAllLpWidgets( + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_CalibrateAllLpSlots( + cy_stc_capsense_context_t * context); +#endif +/** \} */ + + +/******************************************************************************/ +/** \cond SECTION_CAPSENSE_INTERNAL */ +/** \addtogroup group_capsense_internal *//** \{ */ +/******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ScanSlots_V3Lp( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context); +void Cy_CapSense_ScanSlotsInternal( + uint32_t startSlotId, + uint32_t numberSlots, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_ScanWidget_V3Lp( + uint32_t widgetId, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_ScanSensor_V3Lp( + uint32_t widgetId, + uint32_t sensorId, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_ScanAllWidgets_V3Lp( + cy_stc_capsense_context_t * context); +void Cy_CapSense_InterruptHandler_V3Lp( + const MSCLP_Type * base, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_RepeatScan( + cy_stc_capsense_context_t * context); +void Cy_CapSense_SetBusyFlags(cy_stc_capsense_context_t * context); +void Cy_CapSense_ClrBusyFlags(cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_SsInitialize( + cy_stc_capsense_context_t * context); +uint32_t Cy_CapSense_WatchdogCyclesNum( + uint32_t desiredTimeUs, + uint32_t cpuFreqMHz, + uint32_t cyclesPerLoop); +void Cy_CapSense_ScanISR(void * capsenseContext); +void Cy_CapSense_SetCmodInDesiredState( + uint32_t desiredDriveMode, + en_hsiom_sel_t desiredHsiom, + uint32_t desiredMscCtrl, + const cy_stc_capsense_context_t * context); +void Cy_CapSense_InitActivePtrSns( + uint32_t sensorId, + cy_stc_capsense_context_t * context); +void Cy_CapSense_InitActivePtrWd( + uint32_t widgetId, + cy_stc_capsense_context_t * context); +void Cy_CapSense_InitActivePtr( + uint32_t widgetId, + uint32_t sensorId, + cy_stc_capsense_context_t * context); +void Cy_CapSense_SetIOsInDesiredState( + uint32_t desiredDriveMode, + en_hsiom_sel_t desiredHsiom, + uint32_t desiredPinOutput, + uint32_t desiredMscCtrl, + const cy_stc_capsense_context_t * context); +void Cy_CapSense_SsConfigPinRegisters( + GPIO_PRT_Type * base, + uint32_t pinNum, + uint32_t dm, + en_hsiom_sel_t hsiom, + uint32_t mscCtrl); +cy_capsense_status_t Cy_CapSense_SlotPinState_V3Lp( + uint32_t slotId, + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t pinState, + cy_stc_capsense_context_t * context); + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) +cy_capsense_status_t Cy_CapSense_CalibrateCompDivider( + uint32_t widgetId, + uint32_t target, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_VerifyCalibration( + uint32_t widgetId, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets_V3Lp( + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_CalibrateAllSlots_V3Lp( + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_SetCalibrationTarget_V3Lp( + uint32_t calibrTarget, + uint32_t snsMethod, + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_CalibrateWidget_V3Lp( + uint32_t widgetId, + cy_stc_capsense_context_t * context); +#endif +cy_capsense_status_t Cy_CapSense_WaitEndScan( + uint32_t timeout, + cy_stc_capsense_context_t * context); +void Cy_CapSense_SetShieldPinsInDesiredState( + uint32_t desiredDriveMode, + en_hsiom_sel_t desiredHsiom, + uint32_t desiredMscCtrl, + const cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_SwitchHwConfiguration( + uint32_t configuration, + cy_stc_capsense_context_t * context); +uint32_t Cy_CapSense_GetLfsrDitherVal( + uint32_t lfsrBits, + uint32_t lfsrScale); +uint32_t Cy_CapSense_GetLfsrDitherLimit( + uint32_t snsClkDivider, + uint32_t snsClkDividerMin, + uint32_t ditherLimitPercents, + uint32_t lfsrScale); +cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk( + const cy_stc_capsense_context_t * context); + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_HW_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_LP_HW_EN)) + cy_capsense_status_t Cy_CapSense_SsAutoTune( + cy_stc_capsense_context_t * context); + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + uint32_t Cy_CapSense_SsSquareRoot16(uint16_t value); + #endif +#endif + +cy_capsense_mw_state_t Cy_CapSense_MwState_V3Lp( + const cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_ScanAbort_V3Lp( + cy_stc_capsense_context_t * context); + +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) + uint32_t Cy_CapSense_GetCIC2SamplesMax(uint32_t cic2Rate); + uint32_t Cy_CapSense_GetCIC2HwDivider(uint32_t cic2Samples); + uint32_t Cy_CapSense_GetCIC2HwShift(uint32_t cic2Samples); + #if (CY_CAPSENSE_CIC2_FILTER_AUTO_EN) + cy_capsense_status_t Cy_CapSense_InitializeCic2Shift( + cy_stc_capsense_context_t * context); + #endif +#endif /* #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) */ + +void Cy_CapSense_SetupCpuOperatingMode(cy_stc_capsense_context_t * context); +void Cy_CapSense_StartCpuScan(const uint32_t * scanConfig, cy_stc_capsense_context_t * context); +uint32_t Cy_CapSense_WaitEndOfCpuScan(uint32_t watchdogTime, cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_ExecuteSaturatedScan( + uint16_t * ptrMaxRaw, + uint32_t widgetId, + uint32_t scanSlotId, + uint32_t mode, + cy_stc_capsense_context_t * context); +void Cy_CapSense_ConfigureSaturationMode( + cy_stc_capsense_context_t * context); +uint32_t Cy_CapSense_GetScanWatchdogTime( + uint32_t widgetId, + uint32_t scanSlotId, + cy_stc_capsense_context_t * context); + +/** \} \endcond */ + + +/******************************************************************************* +* Local definition +*******************************************************************************/ +#define CY_CAPSENSE_MSCLP_INTR_ALL_MSK (MSCLP_INTR_MASK_SUB_SAMPLE_Msk |\ + MSCLP_INTR_MASK_SAMPLE_Msk |\ + MSCLP_INTR_MASK_SCAN_Msk |\ + MSCLP_INTR_MASK_INIT_Msk |\ + MSCLP_INTR_MASK_FRAME_Msk |\ + MSCLP_INTR_MASK_CONFIG_REQ_Msk |\ + MSCLP_INTR_MASK_FIFO_UNDERFLOW_Msk |\ + MSCLP_INTR_MASK_FIFO_OVERFLOW_Msk) + +#define CY_CAPSENSE_MSCLP_INTR_LP_ALL_MSK (MSCLP_INTR_LP_SIG_DET_Msk |\ + MSCLP_INTR_LP_FR_TIMEOUT_Msk |\ + MSCLP_INTR_LP_FRAME_Msk |\ + MSCLP_INTR_LP_CE_DONE_Msk |\ + MSCLP_INTR_LP_IMO_UP_Msk) + +#define CY_CAPSENSE_CDAC_MAX_CODE (0xFFu) +#define CY_CAPSENSE_CAL_REF_CDAC_MIN_CODE (0x7u) +#define CY_CAPSENSE_REF_CDAC_LSB_X100 (886u) +#define CY_CAPSENSE_MULTIPLIER_TWO (2u) + +#define CY_CAPSENSE_CAL_FINE_CDAC_Msk (0x1FUL) +#define CY_CAPSENSE_CAL_CDAC_Msk (0x1FE0UL) +#define CY_CAPSENSE_CAL_CDAC_Pos (5u) + +#define CY_CAPSENSE_CAL_MIDDLE_VALUE (0x1000u) +#define CY_CAPSENSE_CAL_NUM_SCANS_VALUE (8u) +#define CY_CAPSENSE_CAL_FINE_NUM_SCANS_VALUE (13u) + +#define CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR (0u) +#define CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR (2u) + +#define CY_CAPSENSE_MRSS_TURN_ON (0u) +#define CY_CAPSENSE_MRSS_TURN_OFF (1u) +#define CY_CAPSENSE_MRSS_IMO_TURN_ON (2u) +#define CY_CAPSENSE_MRSS_IMO_TURN_OFF (3u) + +#define CY_CAPSENSE_LFSR_RANGE_0_DITHER_MAX (2u) +#define CY_CAPSENSE_LFSR_RANGE_1_DITHER_MAX (4u) +#define CY_CAPSENSE_LFSR_RANGE_2_DITHER_MAX (8u) +#define CY_CAPSENSE_LFSR_RANGE_3_DITHER_MAX (16u) + +#define CY_CAPSENSE_2PH_PRS_SNS_CLOCK_DIVIDER_SHIFT (1u) +#define CY_CAPSENSE_4PH_PRS_SNS_CLOCK_DIVIDER_SHIFT (2u) + +#define CY_CAPSENSE_DIRECT_SNS_CLOCK_DIVIDER_MAX (4096u) +#define CY_CAPSENSE_2PH_DIRECT_SNS_CLOCK_DIVIDER_MIN (4u) +#define CY_CAPSENSE_4PH_DIRECT_SNS_CLOCK_DIVIDER_MIN (8u) + +#define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_NSUB (64u) +#define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK (256u) +#define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_REF_CDAC (100u) +#define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_WDT (1000000u) +#define CY_CAPSENSE_SMARTSENSE_WD_MAX_NUMBER (64u) + +#define CY_CAPSENSE_MAX_EPI_KREF_DELAY_PRS_NUMBER (255u) +#define CY_CAPSENSE_MAX_PRO_WAIT_KREF_DELAY_PRS_NUMBER (31u) + +#define CY_CAPSENSE_CALIBRATION_REF_CDAC_MASK (0x01u) +#define CY_CAPSENSE_CALIBRATION_COMP_DIV_MASK (0x02u) +#define CY_CAPSENSE_CALIBRATION_COMP_CDAC_MASK (0x04u) + +#define CY_CAPSENSE_SLOT_COUNT_MAX_VALUE (0xFFFFu) + +#define CY_CAPSENSE_RC_HW_IIR_FILTER_COEFF_POS (24u) +#define CY_CAPSENSE_RC_HW_IIR_FILTER_COEFF_MASK (0x0F000000u) +#define CY_CAPSENSE_FRC_HW_IIR_FILTER_MASK (0x00FFFFFFu) + +/* Max number of Low Power sensor historical raw counts to be stored in IP RAM */ +#define CY_CAPSENSE_FIFO_SNS_RAW_HISTORY_NUM (21uL) +/* Max number of Low Power sensors */ +#define CY_CAPSENSE_FIFO_SNS_LP_MAX_NUM (8u) +/* Max number of Active sensor configurations to be stored in IP RAM */ +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_RC_HW_IIR_FILTER_EN) + #define CY_CAPSENSE_FIFO_SNS_MAX_NUM (MSCLP_SNS_SRAM_WORD_SIZE / (CY_MSCLP_11_SNS_REGS + 1u)) +#else + #define CY_CAPSENSE_FIFO_SNS_MAX_NUM (MSCLP_SNS_SRAM_WORD_SIZE / (CY_MSCLP_6_SNS_REGS + 1u)) +#endif/* The wakeup timer maximum value for ACTIVE scan mode in milliseconds */ +#define CY_CAPSENSE_MAX_WAKEUP_TIMER_MS (2000u) + +/* CAPSENSE ILO compensation constants */ +#define CY_CAPSENSE_1M_DIVIDER (1000000uL) +#define CY_CAPSENSE_ILO_COMPENSATE_SHIFT (14u) + +/* The default compensation factor for nominal ILO frequency (40KHz) */ +#define CY_CAPSENSE_DEFAULT_ILO_FACTOR ((CY_SYSCLK_ILO_FREQ << CY_CAPSENSE_ILO_COMPENSATE_SHIFT) /\ + CY_CAPSENSE_1M_DIVIDER) + +/******************************************************************************* +* HSIOM and PC Macros redefinition platform dependent and for readability +*******************************************************************************/ +#define CY_CAPSENSE_HSIOM_SEL_GPIO (HSIOM_SEL_GPIO) +#define CY_CAPSENSE_HSIOM_SEL_CSD_SHIELD (HSIOM_SEL_CSD_SHIELD) +#define CY_CAPSENSE_HSIOM_SEL_CSD_SENSE (HSIOM_SEL_CSD_SENSE) +#define CY_CAPSENSE_HSIOM_SEL_AMUXA (HSIOM_SEL_AMUXA) +#define CY_CAPSENSE_HSIOM_SEL_AMUXB (HSIOM_SEL_AMUXB) +#define CY_CAPSENSE_DM_GPIO_ANALOG (CY_GPIO_DM_ANALOG) +#define CY_CAPSENSE_DM_GPIO_STRONG_IN_OFF (CY_GPIO_DM_STRONG_IN_OFF) + + +#if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_USE_CAPTURE) + +/******************************************************************************* +* Constant definition +*******************************************************************************/ +/* + * Definition of the default configuration of the MSCLP HW registers that is + * intended to be used on the MSCLP HW block capturing stage. + * The configuration includes: + * 1. Start of the analog settling process: + * - Enables the MSCLP HW block; + * - Enables all the sub-blocks of the MSCLP HW block; + * - Enables the Sense Modulator output; + * 2. Clear all of the pending interrupt requests of the MSCLP HW block; + * 3. Sets into default state the rest of the MSCLP HW block registers which are not related + * to actions #1 and #2. +*/ + + #define CY_CAPSENSE_MSC_CONFIG_DEFAULT \ + { \ + .ctl = MSCLP_CTL_SENSE_EN_Msk | \ + MSCLP_CTL_MSCCMP_EN_Msk | \ + MSCLP_CTL_ENABLED_Msk, \ + .scanCtl1 = 0x00uL, \ + .scanCtl2 = 0x00uL, \ + .initCtl1 = 0x00uL, \ + .initCtl2 = 0x00uL, \ + .initCtl3 = 0x00uL, \ + .initCtl4 = 0x00uL, \ + .senseDutyCtl = 0x00uL, \ + .sensePeriodCtl = 0x00uL, \ + .filterCtl = 0x00uL, \ + .ccompCdacCtl = 0x00uL, \ + .ditherCdacCtl = 0x00uL, \ + .mscCmpCtl = 0x00uL, \ + .obsCtl = 0x00uL, \ + .aosCtl = 0x00uL, \ + .ceCtl = 0x00uL, \ + .pumpCtl = 0x00uL, \ + .imoCtl = 0x00uL, \ + .intr = 0x00uL, \ + .intrSet = 0x00uL, \ + .intrMask = 0x00uL, \ + .intrLp = 0x00uL, \ + .intrLpSet = 0x00uL, \ + .intrLpMask = 0x00uL, \ + .swSelCdacRe = 0x00uL, \ + .swSelCdacCo = 0x00uL, \ + .swSelCdacCf = 0x00uL, \ + .swSelBgr = 0x00uL, \ + .swSelCswFunc[0u] = 0x00uL, \ + .swSelCswFunc[1u] = 0x00uL, \ + .swSelCswFunc[2u] = 0x00uL, \ + .swSelCswFunc[3u] = 0x00uL, \ + .swSelCswFunc[4u] = 0x00uL, \ + .swSelCswFunc[5u] = 0x00uL, \ + .swSelCswFunc[6u] = 0x00uL, \ + .swSelCswFunc[7u] = 0x00uL, \ + .mode[0u] = \ + { \ + .senseDutyCtl = 0x00uL, \ + .swSelCdacFl = 0x00uL, \ + .swSelTop = 0x00uL, \ + .swSelComp = 0x00uL, \ + .swSelSh = 0x00uL, \ + .swSelCmod1 = 0x00uL, \ + .swSelCmod2 = 0x00uL, \ + }, \ + .mode[1u] = \ + { \ + .senseDutyCtl = 0x00uL, \ + .swSelCdacFl = 0x00uL, \ + .swSelTop = 0x00uL, \ + .swSelComp = 0x00uL, \ + .swSelSh = 0x00uL, \ + .swSelCmod1 = 0x00uL, \ + .swSelCmod2 = 0x00uL, \ + }, \ + .mode[2u] = \ + { \ + .senseDutyCtl = 0x00uL, \ + .swSelCdacFl = 0x00uL, \ + .swSelTop = 0x00uL, \ + .swSelComp = 0x00uL, \ + .swSelSh = 0x00uL, \ + .swSelCmod1 = 0x00uL, \ + .swSelCmod2 = 0x00uL, \ + }, \ + .mode[3u] = \ + { \ + .senseDutyCtl = 0x00uL, \ + .swSelCdacFl = 0x00uL, \ + .swSelTop = 0x00uL, \ + .swSelComp = 0x00uL, \ + .swSelSh = 0x00uL, \ + .swSelCmod1 = 0x00uL, \ + .swSelCmod2 = 0x00uL, \ + }, \ + } + + extern const cy_stc_msclp_base_config_t cy_capsense_msclpCfg; +#endif + +#define CY_CAPSENSE_CSD_CDAC_COMP_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN)) +#define CY_CAPSENSE_CSD_CDAC_COMP_AUTO_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_EN)) +#define CY_CAPSENSE_CSD_CDAC_COMP_DIV_AUTO_USAGE (CY_CAPSENSE_CSD_CDAC_COMP_USAGE &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_DIV_AUTO_EN)) +#define CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN)) +#define CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE (CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_REF_AUTO_EN)) +#define CY_CAPSENSE_CSD_CDAC_FINE_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_FINE_EN)) + +#define CY_CAPSENSE_CSX_CDAC_COMP_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN)) +#define CY_CAPSENSE_CSX_CDAC_COMP_AUTO_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN)) +#define CY_CAPSENSE_CSX_CDAC_COMP_DIV_AUTO_USAGE ((CY_CAPSENSE_CSX_CDAC_COMP_USAGE) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_DIV_AUTO_EN)) +#define CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) +#define CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE (CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_REF_AUTO_EN)) +#define CY_CAPSENSE_CSX_CDAC_FINE_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_FINE_EN)) + +#define CY_CAPSENSE_ISX_CDAC_COMP_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_COMP_EN)) +#define CY_CAPSENSE_ISX_CDAC_COMP_AUTO_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_COMP_EN)) +#define CY_CAPSENSE_ISX_CDAC_COMP_DIV_AUTO_USAGE ((CY_CAPSENSE_ISX_CDAC_COMP_USAGE) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_COMP_DIV_AUTO_EN)) +#define CY_CAPSENSE_ISX_CDAC_CALIBRATION_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CALIBRATION_EN)) +#define CY_CAPSENSE_ISX_CDAC_REF_AUTO_USAGE (CY_CAPSENSE_ISX_CDAC_CALIBRATION_USAGE &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_REF_AUTO_EN)) +#define CY_CAPSENSE_ISX_CDAC_FINE_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_FINE_EN)) + +#define CY_CAPSENSE_CDAC_COMP_USAGE ((CY_CAPSENSE_CSD_CDAC_COMP_USAGE) ||\ + (CY_CAPSENSE_CSX_CDAC_COMP_USAGE) ||\ + (CY_CAPSENSE_ISX_CDAC_COMP_USAGE)) +#define CY_CAPSENSE_CDAC_COMP_AUTO_USAGE ((CY_CAPSENSE_CSD_CDAC_COMP_AUTO_USAGE) ||\ + (CY_CAPSENSE_CSX_CDAC_COMP_AUTO_USAGE) ||\ + (CY_CAPSENSE_ISX_CDAC_COMP_AUTO_USAGE)) +#define CY_CAPSENSE_CDAC_COMP_DIV_AUTO_USAGE ((CY_CAPSENSE_CSD_CDAC_COMP_DIV_AUTO_USAGE) ||\ + (CY_CAPSENSE_CSX_CDAC_COMP_DIV_AUTO_USAGE) ||\ + (CY_CAPSENSE_ISX_CDAC_COMP_DIV_AUTO_USAGE)) +#define CY_CAPSENSE_CDAC_REF_AUTO_USAGE ((CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE) ||\ + (CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE) ||\ + (CY_CAPSENSE_ISX_CDAC_REF_AUTO_USAGE)) +#define CY_CAPSENSE_CDAC_FINE_USAGE ((CY_CAPSENSE_CSD_CDAC_FINE_USAGE) ||\ + (CY_CAPSENSE_CSX_CDAC_FINE_USAGE) ||\ + (CY_CAPSENSE_ISX_CDAC_FINE_USAGE)) + +#define CY_CAPSENSE_CALIBRATION_EN_POS (0u) +#define CY_CAPSENSE_CDAC_COMP_USAGE_POS (1u) +#define CY_CAPSENSE_CDAC_COMP_DIV_AUTO_USAGE_POS (2u) +#define CY_CAPSENSE_CDAC_REF_AUTO_USAGE_POS (3u) +#define CY_CAPSENSE_CDAC_CDAC_FINE_USAGE_POS (4u) + +#define CY_CAPSENSE_CALIBRATION_EN_MSK (CY_CAPSENSE_ENABLE << CY_CAPSENSE_CALIBRATION_EN_POS) +#define CY_CAPSENSE_CDAC_COMP_USAGE_MSK (CY_CAPSENSE_ENABLE << CY_CAPSENSE_CDAC_COMP_USAGE_POS) +#define CY_CAPSENSE_CDAC_COMP_DIV_AUTO_USAGE_MSK (CY_CAPSENSE_ENABLE << CY_CAPSENSE_CDAC_COMP_DIV_AUTO_USAGE_POS) +#define CY_CAPSENSE_CDAC_REF_AUTO_USAGE_MSK (CY_CAPSENSE_ENABLE << CY_CAPSENSE_CDAC_REF_AUTO_USAGE_POS) +#define CY_CAPSENSE_CDAC_CDAC_FINE_USAGE_MSK (CY_CAPSENSE_ENABLE << CY_CAPSENSE_CDAC_CDAC_FINE_USAGE_POS) + +#if CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE + #define CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_CSD_CDAC_COMP_USAGE + #define CY_CAPSENSE_CSD_CDAC_COMP_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSD_CDAC_COMP_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_CSD_CDAC_COMP_DIV_AUTO_USAGE + #define CY_CAPSENSE_CSD_CDAC_COMP_DIV_AUTO_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSD_CDAC_COMP_DIV_AUTO_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE + #define CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_CSD_CDAC_FINE_USAGE + #define CY_CAPSENSE_CSD_CDAC_FINE_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSD_CDAC_FINE_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#define CY_CAPSENSE_CSD_CALIBRATION_EN_MSK (CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE_EN << CY_CAPSENSE_CALIBRATION_EN_POS) +#define CY_CAPSENSE_CSD_CDAC_COMP_USAGE_MSK (CY_CAPSENSE_CSD_CDAC_COMP_USAGE_EN << CY_CAPSENSE_CDAC_COMP_USAGE_POS) +#define CY_CAPSENSE_CSD_CDAC_COMP_DIV_AUTO_USAGE_MSK (CY_CAPSENSE_CSD_CDAC_COMP_DIV_AUTO_USAGE_EN << CY_CAPSENSE_CDAC_COMP_DIV_AUTO_USAGE_POS) +#define CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE_MSK (CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE_EN << CY_CAPSENSE_CDAC_REF_AUTO_USAGE_POS) +#define CY_CAPSENSE_CSD_CDAC_CDAC_FINE_USAGE_MSK (CY_CAPSENSE_CSD_CDAC_FINE_USAGE_EN << CY_CAPSENSE_CDAC_CDAC_FINE_USAGE_POS) + +#define CY_CAPSENSE_CSD_CALIBRATION_MODE_MSK ((CY_CAPSENSE_CSD_CALIBRATION_EN_MSK) |\ + (CY_CAPSENSE_CSD_CDAC_COMP_USAGE_MSK) |\ + (CY_CAPSENSE_CSD_CDAC_COMP_DIV_AUTO_USAGE_MSK) |\ + (CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE_MSK) |\ + (CY_CAPSENSE_CSD_CDAC_CDAC_FINE_USAGE_MSK)) + +#if CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE + #define CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_CSX_CDAC_COMP_USAGE + #define CY_CAPSENSE_CSX_CDAC_COMP_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSX_CDAC_COMP_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_CSX_CDAC_COMP_DIV_AUTO_USAGE + #define CY_CAPSENSE_CSX_CDAC_COMP_DIV_AUTO_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSX_CDAC_COMP_DIV_AUTO_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE + #define CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_CSX_CDAC_FINE_USAGE + #define CY_CAPSENSE_CSX_CDAC_FINE_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_CSX_CDAC_FINE_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#define CY_CAPSENSE_CSX_CALIBRATION_EN_MSK (CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE_EN << CY_CAPSENSE_CALIBRATION_EN_POS) +#define CY_CAPSENSE_CSX_CDAC_COMP_USAGE_MSK (CY_CAPSENSE_CSX_CDAC_COMP_USAGE_EN << CY_CAPSENSE_CDAC_COMP_USAGE_POS) +#define CY_CAPSENSE_CSX_CDAC_COMP_DIV_AUTO_USAGE_MSK (CY_CAPSENSE_CSX_CDAC_COMP_DIV_AUTO_USAGE_EN << CY_CAPSENSE_CDAC_COMP_DIV_AUTO_USAGE_POS) +#define CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE_MSK (CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE_EN << CY_CAPSENSE_CDAC_REF_AUTO_USAGE_POS) +#define CY_CAPSENSE_CSX_CDAC_CDAC_FINE_USAGE_MSK (CY_CAPSENSE_CSX_CDAC_FINE_USAGE_EN << CY_CAPSENSE_CDAC_CDAC_FINE_USAGE_POS) + +#define CY_CAPSENSE_CSX_CALIBRATION_MODE_MSK ((CY_CAPSENSE_CSX_CALIBRATION_EN_MSK) |\ + (CY_CAPSENSE_CSX_CDAC_COMP_USAGE_MSK) |\ + (CY_CAPSENSE_CSX_CDAC_COMP_DIV_AUTO_USAGE_MSK) |\ + (CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE_MSK) |\ + (CY_CAPSENSE_CSX_CDAC_CDAC_FINE_USAGE_MSK)) + +#if CY_CAPSENSE_ISX_CDAC_CALIBRATION_USAGE + #define CY_CAPSENSE_ISX_CDAC_CALIBRATION_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_ISX_CDAC_CALIBRATION_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_ISX_CDAC_COMP_USAGE + #define CY_CAPSENSE_ISX_CDAC_COMP_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_ISX_CDAC_COMP_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_ISX_CDAC_COMP_DIV_AUTO_USAGE + #define CY_CAPSENSE_ISX_CDAC_COMP_DIV_AUTO_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_ISX_CDAC_COMP_DIV_AUTO_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_ISX_CDAC_REF_AUTO_USAGE + #define CY_CAPSENSE_ISX_CDAC_REF_AUTO_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_ISX_CDAC_REF_AUTO_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#if CY_CAPSENSE_ISX_CDAC_FINE_USAGE + #define CY_CAPSENSE_ISX_CDAC_FINE_USAGE_EN (CY_CAPSENSE_ENABLE) +#else + #define CY_CAPSENSE_ISX_CDAC_FINE_USAGE_EN (CY_CAPSENSE_DISABLE) +#endif + +#define CY_CAPSENSE_ISX_CALIBRATION_EN_MSK (CY_CAPSENSE_ISX_CDAC_CALIBRATION_USAGE_EN << CY_CAPSENSE_CALIBRATION_EN_POS) +#define CY_CAPSENSE_ISX_CDAC_COMP_USAGE_MSK (CY_CAPSENSE_ISX_CDAC_COMP_USAGE_EN << CY_CAPSENSE_CDAC_COMP_USAGE_POS) +#define CY_CAPSENSE_ISX_CDAC_COMP_DIV_AUTO_USAGE_MSK (CY_CAPSENSE_ISX_CDAC_COMP_DIV_AUTO_USAGE_EN << CY_CAPSENSE_CDAC_COMP_DIV_AUTO_USAGE_POS) +#define CY_CAPSENSE_ISX_CDAC_REF_AUTO_USAGE_MSK (CY_CAPSENSE_ISX_CDAC_REF_AUTO_USAGE_EN << CY_CAPSENSE_CDAC_REF_AUTO_USAGE_POS) +#define CY_CAPSENSE_ISX_CDAC_CDAC_FINE_USAGE_MSK (CY_CAPSENSE_ISX_CDAC_FINE_USAGE_EN << CY_CAPSENSE_CDAC_CDAC_FINE_USAGE_POS) + +#define CY_CAPSENSE_ISX_CALIBRATION_MODE_MSK ((CY_CAPSENSE_ISX_CALIBRATION_EN_MSK) |\ + (CY_CAPSENSE_ISX_CDAC_COMP_USAGE_MSK) |\ + (CY_CAPSENSE_ISX_CDAC_COMP_DIV_AUTO_USAGE_MSK) |\ + (CY_CAPSENSE_ISX_CDAC_REF_AUTO_USAGE_MSK) |\ + (CY_CAPSENSE_ISX_CDAC_CDAC_FINE_USAGE_MSK)) + +/* CAPSENSE IMO clock values in MHz */ +#define CY_CAPSENSE_IMO_CLK_25_MHZ (25u) +#define CY_CAPSENSE_IMO_CLK_38_MHZ (38u) +#define CY_CAPSENSE_IMO_CLK_46_MHZ (46u) + +#define CY_CAPSENSE_CPU_CLK_MHZ (CY_CAPSENSE_CPU_CLK / CY_CAPSENSE_CONVERSION_MEGA) + +/* Used for the Cy_CapSense_ExecuteSaturatedScan() function to obtain the MAX raw count. */ +#define CY_CAPSENSE_SATURATED_MAX_COUNT (0u) +/* Used for the Cy_CapSense_ExecuteSaturatedScan() function to obtain the scan duration. */ +#define CY_CAPSENSE_SATURATED_SCAN_TIME (1u) + + +#if defined(__cplusplus) +} +#endif + +#endif /* CY_IP_M0S8MSCV3LP */ + +#endif /* CY_CAPSENSE_SENSING_LP_H */ + + +/* [] END OF FILE */ diff --git a/cy_capsense_sensing_v2.c b/cy_capsense_sensing_v2.c index 78654e3..4fc1966 100644 --- a/cy_capsense_sensing_v2.c +++ b/cy_capsense_sensing_v2.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_sensing_v2.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file contains the source of functions common for different sensing @@ -78,33 +78,6 @@ const cy_stc_csd_config_t cy_capsense_csdCfg = CY_CAPSENSE_CSD_CONFIG_DEFAULT; #endif -/******************************************************************************* -* Function Name: Cy_CapSense_IsBusy_V2 -****************************************************************************//** -* -* This function returns a status of the CAPSENSE™ middleware whether a scan is -* currently in progress or not. -* -* If the middleware is busy, a new scan or setup widgets should not be initiated. -* -* \note -* This function is available only for the fourth-generation CAPSENSE™. -* -* \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. -* -* \return -* Returns the status of the middleware: -* - CY_CAPSENSE_NOT_BUSY - No scan is in progress and a next scan -* can be initiated. -* - CY_CAPSENSE_BUSY - The previously initiated scan is in progress. -* -*******************************************************************************/ -uint32_t Cy_CapSense_IsBusy_V2(const cy_stc_capsense_context_t * context) -{ - return (context->ptrCommonContext->status & CY_CAPSENSE_BUSY); -} - /******************************************************************************* * Function Name: Cy_CapSense_SetBusyFlags @@ -149,7 +122,7 @@ void Cy_CapSense_ClrBusyFlags(cy_stc_capsense_context_t * context) /* Mark completion of scan cycle */ context->ptrCommonContext->scanCounter++; - if(NULL != context->ptrInternalContext->ptrEOSCallback) + if (NULL != context->ptrInternalContext->ptrEOSCallback) { context->ptrInternalContext->ptrEOSCallback(context->ptrActiveScanSns); } @@ -169,10 +142,7 @@ void Cy_CapSense_ClrBusyFlags(cy_stc_capsense_context_t * context) * CSD and CSX methods are used in a user's project. * 2. Initialize the CSD HW block with specific sensing configuration (e.g. * sensor clock, scan resolution) used by the widget. -* 3. Disconnect all previously connected electrodes, if the electrodes are -* connected by the Cy_CapSense_CSDSetupWidgetExt(), -* Cy_CapSense_CSXSetupWidgetExt(), or Cy_CapSense_CSDConnectSns() -* functions and are not disconnected. +* 3. Disconnect all previously connected electrodes. * * This function does not start sensor scanning. The Cy_CapSense_Scan() * function must be called to start the scan sensors in the widget. If this @@ -220,10 +190,10 @@ cy_capsense_status_t Cy_CapSense_SetupWidget( * set widgetStatus as good, if not, set widgetStatus as bad. */ else if ((context->ptrCommonConfig->numWd > widgetId) && - (0u == (context->ptrWdConfig[widgetId].ptrWdContext->status & CY_CAPSENSE_WD_DISABLE_MASK))) + (0u != Cy_CapSense_IsWidgetEnabled(widgetId, context))) { /* Check widget sensing method and call corresponding setup function */ - switch(context->ptrWdConfig[widgetId].senseMethod) + switch (context->ptrWdConfig[widgetId].senseMethod) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) case CY_CAPSENSE_CSD_GROUP: @@ -248,7 +218,7 @@ cy_capsense_status_t Cy_CapSense_SetupWidget( widgetStatus = CY_CAPSENSE_STATUS_BAD_PARAM; } - return (widgetStatus); + return widgetStatus; } @@ -296,7 +266,7 @@ cy_capsense_status_t Cy_CapSense_Scan(cy_stc_capsense_context_t * context) else { /* Check widget sensing method and call appropriate functions */ - switch(context->ptrActiveScanSns->ptrWdConfig->senseMethod) + switch (context->ptrActiveScanSns->ptrWdConfig->senseMethod) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) case CY_CAPSENSE_CSD_GROUP: @@ -315,7 +285,7 @@ cy_capsense_status_t Cy_CapSense_Scan(cy_stc_capsense_context_t * context) break; } } - return (scanStatus); + return scanStatus; } @@ -354,7 +324,7 @@ cy_capsense_status_t Cy_CapSense_Scan(cy_stc_capsense_context_t * context) ********************************************************************************/ cy_capsense_status_t Cy_CapSense_ScanWidget_V2(uint32_t widgetId, cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; cy_capsense_status_t scanStatus = CY_CAPSENSE_STATUS_SUCCESS; if (CY_CAPSENSE_BUSY == Cy_CapSense_IsBusy(context)) @@ -375,7 +345,7 @@ cy_capsense_status_t Cy_CapSense_ScanWidget_V2(uint32_t widgetId, cy_stc_capsens scanStatus = Cy_CapSense_Scan(context); } } - return (scanStatus); + return scanStatus; } @@ -419,6 +389,14 @@ cy_capsense_status_t Cy_CapSense_ScanWidget_V2(uint32_t widgetId, cy_stc_capsens * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * +* \return +* Returns the status of the widget setting up operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is successfully completed. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The widget is invalid or if the specified widget is +* disabled. +* - CY_CAPSENSE_STATUS_INVALID_STATE - The previous scanning is not completed and +* the CSD HW block is busy. +* **********************************************************************************/ cy_capsense_status_t Cy_CapSense_SetupWidgetExt( uint32_t widgetId, @@ -437,12 +415,13 @@ cy_capsense_status_t Cy_CapSense_SetupWidgetExt( * detect any fault conditions. If all conditions are met, * set widgetStatus as good, if not, set widgetStatus as bad. */ - else if (context->ptrCommonConfig->numWd > widgetId) + else if ((context->ptrCommonConfig->numWd > widgetId) && + (0u != Cy_CapSense_IsWidgetEnabled(widgetId, context))) { if (context->ptrWdConfig[widgetId].numSns > sensorId) { /* Check widget sensing method and call corresponding setup function */ - switch(context->ptrWdConfig[widgetId].senseMethod) + switch (context->ptrWdConfig[widgetId].senseMethod) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) case CY_CAPSENSE_CSD_GROUP: @@ -469,7 +448,7 @@ cy_capsense_status_t Cy_CapSense_SetupWidgetExt( /* Do nothing */ } - return (widgetStatus); + return widgetStatus; } @@ -521,7 +500,7 @@ cy_capsense_status_t Cy_CapSense_ScanExt(cy_stc_capsense_context_t * context) else { /* Check widget sensing method and call appropriate functions */ - switch(context->ptrActiveScanSns->ptrWdConfig->senseMethod) + switch (context->ptrActiveScanSns->ptrWdConfig->senseMethod) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) case CY_CAPSENSE_CSD_GROUP: @@ -540,7 +519,7 @@ cy_capsense_status_t Cy_CapSense_ScanExt(cy_stc_capsense_context_t * context) break; } } - return (scanStatus); + return scanStatus; } @@ -579,7 +558,7 @@ cy_capsense_status_t Cy_CapSense_ScanSensor_V2( uint32_t sensorId, cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; cy_capsense_status_t scanStatus = CY_CAPSENSE_STATUS_SUCCESS; if (CY_CAPSENSE_BUSY == Cy_CapSense_IsBusy(context)) @@ -601,7 +580,7 @@ cy_capsense_status_t Cy_CapSense_ScanSensor_V2( scanStatus = Cy_CapSense_ScanExt(context); } } - return (scanStatus); + return scanStatus; } @@ -641,7 +620,7 @@ cy_capsense_status_t Cy_CapSense_ScanSensor_V2( cy_capsense_status_t Cy_CapSense_ScanAllWidgets_V2(cy_stc_capsense_context_t * context) { uint32_t wdgtIndex; - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; cy_capsense_status_t scanStatus = CY_CAPSENSE_STATUS_UNKNOWN; if (CY_CAPSENSE_BUSY == Cy_CapSense_IsBusy(context)) @@ -670,7 +649,7 @@ cy_capsense_status_t Cy_CapSense_ScanAllWidgets_V2(cy_stc_capsense_context_t * c } } - return (scanStatus); + return scanStatus; } @@ -770,7 +749,7 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ context->ptrInternalContext->csdRegSwCmpNSel = CY_CAPSENSE_CSD_SW_CMP_N_SEL_SW_SCRH_STATIC_CLOSE; /* Defines the drive mode of pins depending on the Inactive sensor connection setting */ - (void) Cy_CapSense_SetInactiveElectrodeState(context->ptrCommonConfig->csdInactiveSnsConnection, + (void)Cy_CapSense_SetInactiveElectrodeState(context->ptrCommonConfig->csdInactiveSnsConnection, CY_CAPSENSE_CSD_GROUP, context); /* Prepares CONFIG register value */ @@ -979,7 +958,7 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ context->ptrInternalContext->csdIdacBConfig |= (CY_CAPSENSE_CSD_IDACB_LEG1_MODE_CSD_STATIC << CY_CAPSENSE_CSD_IDACB_LEG1_MODE_POS); context->ptrInternalContext->csdIdacBConfig |= (CY_CAPSENSE_CSD_IDACB_LEG2_MODE_CSD_STATIC << CY_CAPSENSE_CSD_IDACB_LEG2_MODE_POS); - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) context->ptrInternalContext->csdIdacBConfig |= (CY_CAPSENSE_CSD_IDACB_LEG1_EN_MSK); #endif @@ -1012,7 +991,7 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ #endif } - if(context->ptrCommonConfig->csdVref == 0u) + if (context->ptrCommonConfig->csdVref == 0u) { /* Get the recommended Vref voltage value if the Custom Vref option is not used */ temp = Cy_CapSense_GetVrefAutoMv(context); @@ -1021,7 +1000,7 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ { /* Initialize the Temp variable with the user defined Vref voltage */ temp = (uint32_t)context->ptrCommonConfig->csdVref; - if(temp > (uint32_t)((uint32_t)context->ptrCommonConfig->vdda - CY_CAPSENSE_VREF_VDDA_MIN_DIFF)) + if (temp > (uint32_t)((uint32_t)context->ptrCommonConfig->vdda - CY_CAPSENSE_VREF_VDDA_MIN_DIFF)) { temp = (uint32_t)context->ptrCommonConfig->vdda - CY_CAPSENSE_VREF_VDDA_MIN_DIFF; } @@ -1048,13 +1027,13 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ /* SW_RefGen_SEL initialization */ context->ptrInternalContext->csdRegSwRefGenSel = CSD_SW_REFGEN_SEL_SW_SGR_Msk; #if (CY_CAPSENSE_PSOC6_FOURTH_GEN) - if(CY_CAPSENSE_VREF_PASS == context->ptrCommonConfig->ssVrefSource) + if (CY_CAPSENSE_VREF_PASS == context->ptrCommonConfig->ssVrefSource) { context->ptrInternalContext->csdRegSwRefGenSel = CSD_SW_REFGEN_SEL_SW_SGRP_Msk; } #endif - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) context->ptrInternalContext->csdRegSwRefGenSel |= CSD_SW_REFGEN_SEL_SW_IAIB_Msk; #endif @@ -1083,12 +1062,12 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) /* CSX Initialization */ /* Defines the inactive electrode mode depending on the Inactive sensor connection setting */ - (void) Cy_CapSense_SetInactiveElectrodeState(context->ptrCommonConfig->csxInactiveSnsConnection, + (void)Cy_CapSense_SetInactiveElectrodeState(context->ptrCommonConfig->csxInactiveSnsConnection, CY_CAPSENSE_CSX_GROUP, context); context->ptrInternalContext->csxRegSwRefGenSel = CSD_SW_REFGEN_SEL_SW_SGR_Msk; #if (CY_CAPSENSE_PSOC6_FOURTH_GEN) - if(CY_CAPSENSE_VREF_PASS == context->ptrCommonConfig->ssVrefSource) + if (CY_CAPSENSE_VREF_PASS == context->ptrCommonConfig->ssVrefSource) { context->ptrInternalContext->csxRegSwRefGenSel = CSD_SW_REFGEN_SEL_SW_SGRP_Msk; } @@ -1098,7 +1077,7 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ context->ptrInternalContext->csxRegConfigInit = CY_CAPSENSE_DEFAULT_CSD_CONFIG_CFG; context->ptrInternalContext->csxRegConfigScan = CY_CAPSENSE_PRESCAN_CSD_CONFIG_CFG; #if (CY_CAPSENSE_PSOC6_FOURTH_GEN) - if(CY_CAPSENSE_IREF_PASS == context->ptrCommonConfig->ssIrefSource) + if (CY_CAPSENSE_IREF_PASS == context->ptrCommonConfig->ssIrefSource) { context->ptrInternalContext->csxRegConfigInit |= CY_CAPSENSE_CSD_CONFIG_IREF_SEL_MSK; context->ptrInternalContext->csxRegConfigScan |= CY_CAPSENSE_CSD_CONFIG_IREF_SEL_MSK; @@ -1110,11 +1089,11 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ { /* Calculate CSX modClk in Hz */ temp = context->ptrCommonConfig->periClkHz / (uint32_t) context->ptrCommonContext->modCsxClk; - if(temp <= CY_CAPSENSE_MOD_CSD_CLK_12000000_HZ) + if (temp <= CY_CAPSENSE_MOD_CSD_CLK_12000000_HZ) { context->ptrInternalContext->csxRegConfigScan |= CY_CAPSENSE_CSD_CONFIG_FILTER_DELAY_12MHZ; } - else if(temp <= CY_CAPSENSE_MOD_CSD_CLK_24000000_HZ) + else if (temp <= CY_CAPSENSE_MOD_CSD_CLK_24000000_HZ) { context->ptrInternalContext->csxRegConfigScan |= CY_CAPSENSE_CSD_CONFIG_FILTER_DELAY_24MHZ; } @@ -1173,7 +1152,7 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ } #else /* Initialize RefGen Gain and Vref switches for sensing operation */ - if(CY_CAPSENSE_VREF_PASS == context->ptrCommonConfig->ssVrefSource) + if (CY_CAPSENSE_VREF_PASS == context->ptrCommonConfig->ssVrefSource) { context->ptrInternalContext->csxRegRefgen = CY_CAPSENSE_PASS_CSD_REFGEN_CFG; } @@ -1184,7 +1163,7 @@ cy_capsense_status_t Cy_CapSense_InternalPreCalculation(cy_stc_capsense_context_ #endif #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ - return (initStatus); + return initStatus; } @@ -1230,7 +1209,7 @@ cy_capsense_status_t Cy_CapSense_SsInitialize(cy_stc_capsense_context_t * contex /* The CSD HW block is initialized in the Setup Widget functions based on widget sensing method */ (void)Cy_CapSense_SwitchSensingMode(CY_CAPSENSE_UNDEFINED_GROUP, context); - return (initStatus); + return initStatus; } @@ -1238,34 +1217,10 @@ cy_capsense_status_t Cy_CapSense_SsInitialize(cy_stc_capsense_context_t * contex * Function Name: Cy_CapSense_SetPinState_V2 ****************************************************************************//** * -* Sets the state (drive mode and HSIOM state) of the GPIO used by a sensor. -* -* The possible states are GND, Shield, High-Z, Tx, Rx, and Sensor. -* If the sensor specified in the input parameter is a ganged sensor, then -* the state of all GPIOs associated with the ganged sensor is updated. -* -* To access a sensor of CSD of button or slider widgets, use the sensor ID. -* To access a sensor of CSD matrix button or touchpad widgets, -* use either row ID or column ID as appropriate. -* To access sensor CSX widgets, use either Rx ID or Tx ID as appropriate. +* The internal function to set the state (drive mode and HSIOM state) of the GPIO used +* by a sensor. * -* This function accepts the CY_CAPSENSE_SHIELD and CY_CAPSENSE_SENSOR states -* as an input only if there is at least one CSD widget in the project. -* Similarly, this function accepts the CY_CAPSENSE_TX_PIN and -* CY_CAPSENSE_RX_PIN states as an input only if there is at least one -* CSX widget in the project. -* -* This function must not be called while the middleware is in the busy state. -* Calling this function directly from the application program is not -* recommended. This function is used to implement only the custom-specific -* use cases. -* -* Functions that perform a setup and scan of a sensor/widget automatically -* set the required pin states for a sensor as required and overwrite changes -* made by this function to a sensor that are going to be scanned. Therefore -* the Cy_CapSense_SetPinState() function could be called in StartSample -* callback (see the \ref group_capsense_callbacks section for details) -* or with low-level functions that perform a single-sensor scanning. +* See the Cy_CapSense_SetPinState() description for details. * * \note * This function is available only for the fourth-generation CAPSENSE™. @@ -1314,12 +1269,6 @@ cy_capsense_status_t Cy_CapSense_SsInitialize(cy_stc_capsense_context_t * contex * 3) the CSX sensing method is disabled for desired * CY_CAPSENSE_TX_PIN or CY_CAPSENSE_RX_PIN states. * -* \funcusage -* -* An example of using the Cy_CapSense_SetPinState() function to perform -* sensor state re-configuration: -* \snippet capsense/snippet/main.c snippet_Cy_CapSense_SetPinState -* *******************************************************************************/ cy_capsense_status_t Cy_CapSense_SetPinState_V2( uint32_t widgetId, @@ -1414,7 +1363,7 @@ cy_capsense_status_t Cy_CapSense_SetPinState_V2( } } } - return (connState); + return connState; } @@ -1456,63 +1405,68 @@ cy_en_capsense_return_status_t Cy_CapSense_SwitchSensingMode(uint8_t mode, cy_st if (context->ptrActiveScanSns->currentSenseMethod != mode) { /* Check the CSD HW lock status */ - if(CY_CSD_CAPSENSE_KEY == Cy_CSD_GetLockStatus(context->ptrCommonConfig->ptrCsdBase, + if (CY_CSD_CAPSENSE_KEY == Cy_CSD_GetLockStatus(context->ptrCommonConfig->ptrCsdBase, context->ptrCommonConfig->ptrCsdContext)) { if (CY_CAPSENSE_NOT_BUSY == Cy_CapSense_IsBusy(context)) { /* The requested mode differs from the current one. Disable the current mode. */ - switch(context->ptrActiveScanSns->currentSenseMethod) + switch (context->ptrActiveScanSns->currentSenseMethod) { - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - case CY_CAPSENSE_CSD_GROUP: - Cy_CapSense_CSDDisableMode(context); - break; - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + Cy_CapSense_CSDDisableMode(context); + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - case CY_CAPSENSE_CSX_GROUP: - Cy_CapSense_CSXDisableMode(context); - break; - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + Cy_CapSense_CSXDisableMode(context); + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) - case CY_CAPSENSE_BIST_GROUP: - Cy_CapSense_BistDisableMode(context); - break; - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) + case CY_CAPSENSE_BIST_GROUP: + Cy_CapSense_BistDisableMode(context); + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ default: /* No action for other sensing methods */ break; } - context->ptrActiveScanSns->currentSenseMethod = mode; - /* Enable the specified mode */ - switch(context->ptrActiveScanSns->currentSenseMethod) + switch (mode) { - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - case CY_CAPSENSE_CSD_GROUP: - Cy_CapSense_CSDInitialize(context); - break; - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + Cy_CapSense_CSDInitialize(context); + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - case CY_CAPSENSE_CSX_GROUP: - Cy_CapSense_CSXInitialize(context); - break; - #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + Cy_CapSense_CSXInitialize(context); + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) - case CY_CAPSENSE_BIST_GROUP: - Cy_CapSense_BistInitialize(context); - break; - #endif + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) + case CY_CAPSENSE_BIST_GROUP: + Cy_CapSense_BistInitialize(context); + break; + #endif default: /* No action for other sensing methods */ break; - } + } + + if (CY_CAPSENSE_UNDEFINED_GROUP == context->ptrActiveScanSns->currentSenseMethod) + { + /* The time interval is required for settling analog part of the HW block. */ + Cy_SysLib_DelayUs(CY_CAPSENSE_ANALOG_SETTLING_TIME_US); + } + context->ptrActiveScanSns->currentSenseMethod = mode; } else { @@ -1525,7 +1479,7 @@ cy_en_capsense_return_status_t Cy_CapSense_SwitchSensingMode(uint8_t mode, cy_st } } - return (switchStatus); + return switchStatus; } @@ -1646,7 +1600,7 @@ void Cy_CapSense_SsPostAllWidgetsScan(cy_stc_capsense_context_t * context) * 3. If all the widgets are not scanned, set up and scan next widget */ cy_capsense_status_t postScanStatus; - const cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + const cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; uint32_t widgetId = (uint32_t)ptrActive->widgetIndex + 1u; do @@ -1748,7 +1702,7 @@ void Cy_CapSense_SsPostAllWidgetsScan(cy_stc_capsense_context_t * context) * \snippet capsense/snippet/main.c snippet_m4_adc_interrupt_source_declaration * * Defines the CAPSENSE™ interrupt handler: -* \snippet capsense/snippet/main.c snippet_CapSense_Interrupt +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_IntHandler * * Defines the CSDADC interrupt handler: * \snippet capsense/snippet/main.c snippet_CSDADC_Interrupt @@ -1763,7 +1717,6 @@ void Cy_CapSense_InterruptHandler_V2(const CSD_Type * base, cy_stc_capsense_cont context->ptrInternalContext->ptrISRCallback((void *)context); } - #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) /******************************************************************************* @@ -1776,6 +1729,9 @@ void Cy_CapSense_InterruptHandler_V2(const CSD_Type * base, cy_stc_capsense_cont * This function performs exactly the same tasks as * Cy_CapSense_CalibrateAllWidgets(), but only for a specified widget. * +* The function skips disabled and non-working widget and reports +* CY_CAPSENSE_STATUS_INVALID_STATE. +* * \note * This function is available only for the fourth-generation CAPSENSE™. * @@ -1790,6 +1746,7 @@ void Cy_CapSense_InterruptHandler_V2(const CSD_Type * base, cy_stc_capsense_cont * Returns the status of the specified widget calibration: * - CY_CAPSENSE_STATUS_SUCCESS - The operation is successfully completed. * - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* - CY_CAPSENSE_STATUS_INVALID_STATE - The specified widget is disabled. * - CY_CAPSENSE_STATUS_BAD_DATA - The calibration failed and the middleware may not * operate as expected. * @@ -1800,27 +1757,33 @@ cy_capsense_status_t Cy_CapSense_CalibrateWidget_V2( { cy_capsense_status_t calibrateStatus = CY_CAPSENSE_STATUS_BAD_PARAM; - if(context->ptrCommonConfig->numWd > widgetId) + if (context->ptrCommonConfig->numWd > widgetId) { - switch(context->ptrWdConfig[widgetId].senseMethod) + /* Check widget enable status */ + if (0u == Cy_CapSense_IsWidgetEnabled(widgetId, context)) { - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) - case CY_CAPSENSE_CSD_GROUP: - calibrateStatus = Cy_CapSense_CSDCalibrateWidget( - widgetId, (uint32_t)context->ptrCommonConfig->csdRawTarget, context); - break; - #endif - - #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) - case CY_CAPSENSE_CSX_GROUP: - calibrateStatus = Cy_CapSense_CSXCalibrateWidget( - widgetId, (uint32_t)context->ptrCommonConfig->csxRawTarget, context); - break; - #endif - - default: - /* No action for other methods */ - break; + calibrateStatus = CY_CAPSENSE_STATUS_INVALID_STATE; + } + else + { + switch (context->ptrWdConfig[widgetId].senseMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) + case CY_CAPSENSE_CSD_GROUP: + calibrateStatus = Cy_CapSense_CSDCalibrateWidget( + widgetId, (uint32_t)context->ptrCommonConfig->csdRawTarget, context); + break; + #endif + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) + case CY_CAPSENSE_CSX_GROUP: + calibrateStatus = Cy_CapSense_CSXCalibrateWidget( + widgetId, (uint32_t)context->ptrCommonConfig->csxRawTarget, context); + break; + #endif + default: + /* No action for other methods */ + break; + } } } @@ -1848,12 +1811,14 @@ cy_capsense_status_t Cy_CapSense_CalibrateWidget_V2( * and/or IDAC values for all sensors in CSX widgets to make sensor raw count * to the default value level. * -* Calibration returns CY_CAPSENSE_STATUS_BAD_DATA if resulted raw count is outside -* the limits. +* Calibration returns CY_CAPSENSE_STATUS_BAD_DATA if the resulted raw count is +* outside the limits. * * This function could be used only if Enable IDAC auto-calibration parameter * is enabled for CSD and/or CSX widgets. * +* The function skips disabled and non-working widgets. +* * \note * This function is available only for the fourth-generation CAPSENSE™. * @@ -1869,15 +1834,21 @@ cy_capsense_status_t Cy_CapSense_CalibrateWidget_V2( *******************************************************************************/ cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets_V2(cy_stc_capsense_context_t * context) { - cy_capsense_status_t calibrateStatus = CY_CAPSENSE_STATUS_SUCCESS; + cy_capsense_status_t calibrateStatus = CY_CAPSENSE_STATUS_INVALID_STATE; + cy_capsense_status_t calibrateResult = CY_CAPSENSE_STATUS_SUCCESS; uint32_t wdgtIndex; for (wdgtIndex = 0u; wdgtIndex < context->ptrCommonConfig->numWd; wdgtIndex++) { - calibrateStatus |= Cy_CapSense_CalibrateWidget(wdgtIndex, context); + /* Check widget enable status */ + if (0u != Cy_CapSense_IsWidgetEnabled(wdgtIndex, context)) + { + calibrateStatus = CY_CAPSENSE_STATUS_SUCCESS; + calibrateResult |= Cy_CapSense_CalibrateWidget(wdgtIndex, context); + } } - return calibrateStatus; + return (calibrateStatus | calibrateResult); } #endif @@ -1896,6 +1867,8 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets_V2(cy_stc_capsense_context_ * This function performs exact same tasks of Cy_CapSense_CalibrateAllWidgets(), * but only for CSD widgets. * +* The function skips disabled and non-working widgets. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -1910,22 +1883,25 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllCsdWidgets(cy_stc_capsense_context_ uint32_t widgetId; cy_capsense_status_t calibrateStatus = CY_CAPSENSE_STATUS_SUCCESS; - for(widgetId = 0uL; widgetId < context->ptrCommonConfig->numWd; widgetId++) + for (widgetId = 0uL; widgetId < context->ptrCommonConfig->numWd; widgetId++) { - if(CY_CAPSENSE_CSD_GROUP == context->ptrWdConfig[widgetId].senseMethod) + if (CY_CAPSENSE_CSD_GROUP == context->ptrWdConfig[widgetId].senseMethod) { - calibrateStatus |= Cy_CapSense_CSDCalibrateWidget( - widgetId, (uint32_t)context->ptrCommonConfig->csdRawTarget, context); + /* Check widget enable status */ + if (0u != Cy_CapSense_IsWidgetEnabled(widgetId, context)) + { + calibrateStatus |= Cy_CapSense_CSDCalibrateWidget( + widgetId, (uint32_t)context->ptrCommonConfig->csdRawTarget, context); + } /* Update CRC if BIST is enabled */ #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) Cy_CapSense_UpdateCrcWidget(widgetId, context); - #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) && - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) */ + #endif } } - return(calibrateStatus); + return calibrateStatus; } #endif @@ -1944,6 +1920,8 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllCsdWidgets(cy_stc_capsense_context_ * This function performs the exact same tasks of Cy_CapSense_CalibrateAllWidgets(), * but only for CSX widgets. * +* The function skips disabled and non-working widgets. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -1958,22 +1936,25 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllCsxWidgets(cy_stc_capsense_context_ uint32_t widgetId; cy_capsense_status_t calibrateStatus = CY_CAPSENSE_STATUS_SUCCESS; - for(widgetId = 0uL; widgetId < context->ptrCommonConfig->numWd; widgetId++) + for (widgetId = 0uL; widgetId < context->ptrCommonConfig->numWd; widgetId++) { - if(CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) + if (CY_CAPSENSE_CSX_GROUP == context->ptrWdConfig[widgetId].senseMethod) { - calibrateStatus |= Cy_CapSense_CSXCalibrateWidget( - widgetId, (uint32_t)context->ptrCommonConfig->csxRawTarget, context); + /* Check widget enable status */ + if (0u != Cy_CapSense_IsWidgetEnabled(widgetId, context)) + { + calibrateStatus |= Cy_CapSense_CSXCalibrateWidget( + widgetId, (uint32_t)context->ptrCommonConfig->csxRawTarget, context); + } /* Update CRC if BIST is enabled */ #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) &&\ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) Cy_CapSense_UpdateCrcWidget(widgetId, context); - #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_BIST_EN) && - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) */ + #endif } } - return(calibrateStatus); + return calibrateStatus; } #endif @@ -1994,6 +1975,8 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllCsxWidgets(cy_stc_capsense_context_ * than 2*5*R*Cp. * - Calculate the resolution for the optimal finger capacitance. * +* The function skips disabled and non-working widgets. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -2012,7 +1995,11 @@ cy_capsense_status_t Cy_CapSense_SsAutoTune(cy_stc_capsense_context_t * context) { if (CY_CAPSENSE_CSD_GROUP == context->ptrWdConfig[wdIndex].senseMethod) { - autoTuneStatus |= Cy_CapSense_SsAutoTuneWidget(wdIndex, context); + /* Check widget enable status */ + if (0u != Cy_CapSense_IsWidgetEnabled(wdIndex, context)) + { + autoTuneStatus |= Cy_CapSense_SsAutoTuneWidget(wdIndex, context); + } } } @@ -2067,10 +2054,9 @@ cy_capsense_status_t Cy_CapSense_SsAutoTuneWidget( cy_stc_capsense_widget_context_t * ptrWdCxt = ptrWdCfg->ptrWdContext; const cy_stc_capsense_sensor_context_t * ptrSnsCtx; - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) uint32_t maxCpSnsId = 0u; - uint32_t maxCpRowSnsId = 0u; #endif /* Store sense clock source to be restored at the end of function */ @@ -2123,34 +2109,31 @@ cy_capsense_status_t Cy_CapSense_SsAutoTuneWidget( /* Find raw count and IDAC of a sensor with maximum Cp */ ptrSnsCtx = ptrWdCfg->ptrSnsContext; - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) - for (snsIndex = 0u; snsIndex < ptrWdCfg->numCols; snsIndex++) - { - if (maxIdacComp < ptrSnsCtx->idacComp) + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) + if ((maxIdacComp < ptrSnsCtx->idacComp) || + ((maxIdacComp == ptrSnsCtx->idacComp) && (maxRaw < ptrSnsCtx->raw))) { - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) - maxCpSnsId = snsIndex; - #endif maxIdacComp = ptrSnsCtx->idacComp; maxRaw = ptrSnsCtx->raw; + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + maxCpSnsId = snsIndex; + #endif } - ptrSnsCtx++; - } - #else - for (snsIndex = 0u; snsIndex < ptrWdCfg->numCols; snsIndex++) - { + #else if (maxRaw < ptrSnsCtx->raw) { - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + maxRaw = ptrSnsCtx->raw; + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) maxCpSnsId = snsIndex; #endif - maxRaw = ptrSnsCtx->raw; } - ptrSnsCtx++; - } - #endif + #endif + ptrSnsCtx++; + } /* Update auto-tuning configuration structure */ autoTuneConfig.iDacMod = ptrWdCxt->idacMod[CY_CAPSENSE_MFS_CH0_INDEX]; @@ -2169,63 +2152,7 @@ cy_capsense_status_t Cy_CapSense_SsAutoTuneWidget( { ptrWdCxt->snsClk = (uint16_t)minSnsClkDiv; } - - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) - if (((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType) || - ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType)) - { - /* Find a sensor with maximum Cp */ - maxRaw = 0u; - maxIdacComp = 0u; - - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_IDAC_COMP_EN) - for (snsIndex = 0u; snsIndex < ptrWdCfg->numCols; snsIndex++) - { - if (maxIdacComp < ptrSnsCtx->idacComp) - { - maxCpRowSnsId = snsIndex; - maxIdacComp = ptrSnsCtx->idacComp; - maxRaw = ptrSnsCtx->raw; - } - ptrSnsCtx++; - } - #else - for (snsIndex = 0u; snsIndex < ptrWdCfg->numCols; snsIndex++) - { - if (maxRaw < ptrSnsCtx->raw) - { - maxCpRowSnsId = snsIndex; - maxRaw = ptrSnsCtx->raw; - } - ptrSnsCtx++; - } - #endif - - /* Configure auto-tuning configuration structure */ - autoTuneConfig.iDacMod = ptrWdCxt->rowIdacMod[CY_CAPSENSE_MFS_CH0_INDEX]; - autoTuneConfig.iDacComp = (uint8_t)maxIdacComp; - autoTuneConfig.ptrSenseClk = &ptrWdCxt->rowSnsClk; - autoTuneConfig.calTarget = (uint16_t)((maxRaw * CY_CAPSENSE_CSD_AUTOTUNE_CAL_UNITS) / - ((uint32_t)(0x01uL << CY_CAPSENSE_AUTOTUNE_CALIBRATION_RESOLUTION) - 1u)); - - /* Find correct sense clock value */ - maxCp = Cy_CapSense_TunePrescalers_Lib(&autoTuneConfig); - /* Save maximum sensor Cp and corresponding sensor Id */ - if (autoTuneConfig.sensorCap < maxCp) - { - autoTuneConfig.sensorCap = maxCp; - maxCpSnsId = maxCpRowSnsId; - } - - /* Increase sensor clock divider to valid value */ - if (((uint32_t)ptrWdCxt->rowSnsClk) < minSnsClkDiv) - { - ptrWdCxt->rowSnsClk = (uint16_t)minSnsClkDiv; - } - } - #endif /* ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) || - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) */ + ptrWdCxt->rowSnsClk = ptrWdCxt->snsClk; /* Check tuning results */ if (CY_CAPSENSE_AUTOTUNE_CP_MAX < maxCp) @@ -2246,17 +2173,15 @@ cy_capsense_status_t Cy_CapSense_SsAutoTuneWidget( autoTuneConfig.iDacGain = context->ptrCommonConfig->idacGainTable[ptrWdCxt->idacGainIndex].gainValue; autoTuneConfig.iDacMod = ptrWdCxt->idacMod[CY_CAPSENSE_MFS_CH0_INDEX]; - autoTuneConfig.ptrSenseClk = &ptrWdCxt->snsClk; - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) if (((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType) || ((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType)) { if (maxCpSnsId >= ptrWdCfg->numCols) { autoTuneConfig.iDacMod = ptrWdCxt->rowIdacMod[CY_CAPSENSE_MFS_CH0_INDEX]; - autoTuneConfig.ptrSenseClk = &ptrWdCxt->rowSnsClk; } } #endif @@ -2310,7 +2235,7 @@ void Cy_CapSense_InitializeSourceSenseClk(const cy_stc_capsense_context_t * cont for (wdIndex = 0u; wdIndex < context->ptrCommonConfig->numWd; wdIndex++) { - switch(ptrWdCfg->senseMethod) + switch (ptrWdCfg->senseMethod) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) case CY_CAPSENSE_CSD_GROUP: @@ -2363,25 +2288,25 @@ uint32_t Cy_CapSense_SsCalcLfsrSize(uint32_t clkDivider, uint32_t conversionsNum { uint32_t lfsrSize = 0u; - if(CY_CAPSENSE_SNSCLK_LFSR_THRESHOLD <= clkDivider) + if (CY_CAPSENSE_SNSCLK_LFSR_THRESHOLD <= clkDivider) { /* Find LFSR value */ - if((CY_CAPSENSE_SNSCLK_SSC4_PERIOD <= conversionsNum) && + if ((CY_CAPSENSE_SNSCLK_SSC4_PERIOD <= conversionsNum) && (0uL == (conversionsNum % CY_CAPSENSE_SNSCLK_SSC4_PERIOD))) { lfsrSize = CY_CAPSENSE_CLK_SOURCE_SSC10; } - else if((CY_CAPSENSE_SNSCLK_SSC3_PERIOD <= conversionsNum) && + else if ((CY_CAPSENSE_SNSCLK_SSC3_PERIOD <= conversionsNum) && (0uL == (conversionsNum % CY_CAPSENSE_SNSCLK_SSC3_PERIOD))) { lfsrSize = CY_CAPSENSE_CLK_SOURCE_SSC9; } - else if((CY_CAPSENSE_SNSCLK_SSC2_PERIOD <= conversionsNum) && + else if ((CY_CAPSENSE_SNSCLK_SSC2_PERIOD <= conversionsNum) && (0uL == (conversionsNum % CY_CAPSENSE_SNSCLK_SSC2_PERIOD))) { lfsrSize = CY_CAPSENSE_CLK_SOURCE_SSC7; } - else if((CY_CAPSENSE_SNSCLK_SSC1_PERIOD <= conversionsNum) && + else if ((CY_CAPSENSE_SNSCLK_SSC1_PERIOD <= conversionsNum) && (0uL == (conversionsNum % CY_CAPSENSE_SNSCLK_SSC1_PERIOD))) { lfsrSize = CY_CAPSENSE_CLK_SOURCE_SSC6; @@ -2536,7 +2461,7 @@ void Cy_CapSense_InitActivePtrSns( uint32_t sensorId, cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) uint32_t numberRows; @@ -2544,7 +2469,7 @@ void Cy_CapSense_InitActivePtrSns( #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ ptrActive->mfsChannelIndex = 0u; - switch(context->ptrActiveScanSns->currentSenseMethod) + switch (context->ptrActiveScanSns->currentSenseMethod) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) case CY_CAPSENSE_CSD_GROUP: @@ -2599,7 +2524,7 @@ void Cy_CapSense_InitActivePtrWd( uint32_t widgetId, cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; + cy_stc_capsense_active_scan_sns_t * ptrActive = context->ptrActiveScanSns; ptrActive->widgetIndex = (uint8_t)widgetId; ptrActive->ptrWdConfig = &context->ptrWdConfig[widgetId]; @@ -2704,7 +2629,7 @@ void Cy_CapSense_SetClkDivider( cy_en_sysclk_divider_types_t dividerType; #endif - switch(context->ptrCommonConfig->periDividerType) + switch (context->ptrCommonConfig->periDividerType) { case (uint8_t)CY_SYSCLK_DIV_8_BIT: dividerType = CY_SYSCLK_DIV_8_BIT; @@ -2757,7 +2682,7 @@ uint32_t Cy_CapSense_WatchdogCyclesNum( { uint32_t retVal; - if(0uL != cyclesPerLoop) + if (0uL != cyclesPerLoop) { retVal = (desiredTimeUs * cpuFreqMHz) / cyclesPerLoop; } @@ -2766,7 +2691,7 @@ uint32_t Cy_CapSense_WatchdogCyclesNum( retVal = 0xFFFFFFFFuL; } - return(retVal); + return retVal; } @@ -2795,10 +2720,10 @@ uint32_t Cy_CapSense_WaitForSeqIdle( { uint32_t watchdogCounter = watchdogCycleNum; - while((0u != (CY_CAPSENSE_CSD_SEQ_START_START_MSK & + while ((0u != (CY_CAPSENSE_CSD_SEQ_START_START_MSK & context->ptrCommonConfig->ptrCsdBase->SEQ_START))) { - if(0uL == watchdogCounter) + if (0uL == watchdogCounter) { break; } @@ -2807,7 +2732,7 @@ uint32_t Cy_CapSense_WaitForSeqIdle( } - return (watchdogCounter); + return watchdogCounter; } @@ -2842,7 +2767,7 @@ uint32_t Cy_CapSense_WaitEndOfScan( watchdogCounter--; } - return (watchdogCounter); + return watchdogCounter; } @@ -2890,7 +2815,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateCheck( const cy_stc_capsense_sensor_context_t * ptrSnsCxt; /* Calculate acceptable raw count range based on the resolution, target and error */ - if(CY_CAPSENSE_CSD_GROUP == senseMethod) + if (CY_CAPSENSE_CSD_GROUP == senseMethod) { tmpRawcount = (1uL << context->ptrWdContext[widgetId].resolution) - 1u; calibrationError = context->ptrCommonConfig->csdCalibrationError; @@ -2919,7 +2844,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateCheck( for (freqChIndex = 0u; freqChIndex < CY_CAPSENSE_CONFIGURED_FREQ_NUM; freqChIndex++) { ptrSnsCxt = ptrChCxt; - for(snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) { tmpRawcount = ptrSnsCxt->raw; if ((tmpRawcount < lowerLimit) || (tmpRawcount > upperLimit)) @@ -2932,7 +2857,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateCheck( ptrChCxt += context->ptrCommonConfig->numSns; } - return (calibrateStatus); + return calibrateStatus; } #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) ||\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) */ @@ -2957,15 +2882,15 @@ uint32_t Cy_CapSense_GetVrefAutoMv(const cy_stc_capsense_context_t * context) uint32_t vrefHighVoltageMv; #if (CY_CAPSENSE_PSOC4_FOURTH_GEN) - if(vddaMv >= CY_CAPSENSE_VREF_RANGE_0) + if (vddaMv >= CY_CAPSENSE_VREF_RANGE_0) { vrefHighVoltageMv = CY_CAPSENSE_VREF_VALUE_0; } - else if(vddaMv >= CY_CAPSENSE_VREF_RANGE_1) + else if (vddaMv >= CY_CAPSENSE_VREF_RANGE_1) { vrefHighVoltageMv = CY_CAPSENSE_VREF_VALUE_1; } - else if(vddaMv >= CY_CAPSENSE_VREF_RANGE_2) + else if (vddaMv >= CY_CAPSENSE_VREF_RANGE_2) { vrefHighVoltageMv = CY_CAPSENSE_VREF_VALUE_2; } @@ -2974,11 +2899,11 @@ uint32_t Cy_CapSense_GetVrefAutoMv(const cy_stc_capsense_context_t * context) vrefHighVoltageMv = CY_CAPSENSE_VREF_VALUE_MIN; } #else - if(vddaMv >= CY_CAPSENSE_VREF_RANGE_0) + if (vddaMv >= CY_CAPSENSE_VREF_RANGE_0) { vrefHighVoltageMv = CY_CAPSENSE_VREF_VALUE_0; } - else if(vddaMv >= CY_CAPSENSE_VREF_RANGE_1) + else if (vddaMv >= CY_CAPSENSE_VREF_RANGE_1) { vrefHighVoltageMv = CY_CAPSENSE_VREF_VALUE_1; } @@ -2995,7 +2920,7 @@ uint32_t Cy_CapSense_GetVrefAutoMv(const cy_stc_capsense_context_t * context) } #endif - return(vrefHighVoltageMv); + return vrefHighVoltageMv; } @@ -3024,7 +2949,7 @@ uint32_t Cy_CapSense_GetVrefHighGain(uint32_t vrefDesiredMv, const cy_stc_capsen uint32_t vrefInputMv; #if (CY_CAPSENSE_PSOC4_FOURTH_GEN) - (void) context; + (void)context; vrefInputMv = CY_CAPSENSE_VREF_SRSS_MV; #else if (CY_CAPSENSE_VREF_PASS == context->ptrCommonConfig->ssVrefSource) @@ -3044,7 +2969,7 @@ uint32_t Cy_CapSense_GetVrefHighGain(uint32_t vrefDesiredMv, const cy_stc_capsen vferhiGain = (uint32_t)CY_CAPSENSE_VREF_GAIN_MAX - 1u; } - return (vferhiGain); + return vferhiGain; } @@ -3072,7 +2997,7 @@ uint32_t Cy_CapSense_GetVrefHighMv(uint32_t vrefGain, const cy_stc_capsense_cont uint32_t vrefInputMv; #if (CY_CAPSENSE_PSOC4_FOURTH_GEN) - (void) context; + (void)context; vrefInputMv = CY_CAPSENSE_VREF_SRSS_MV; #else if (CY_CAPSENSE_VREF_PASS == context->ptrCommonConfig->ssVrefSource) @@ -3087,7 +3012,7 @@ uint32_t Cy_CapSense_GetVrefHighMv(uint32_t vrefGain, const cy_stc_capsense_cont vrefHighMv = (CY_CAPSENSE_VREF_GAIN_MAX * vrefInputMv) / (vrefGain + 1u); - return (vrefHighMv); + return vrefHighMv; } #endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2)) */ diff --git a/cy_capsense_sensing_v2.h b/cy_capsense_sensing_v2.h index 697746b..82bccd4 100644 --- a/cy_capsense_sensing_v2.h +++ b/cy_capsense_sensing_v2.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_sensing_v2.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the function prototypes specific to the sensing module. @@ -74,8 +74,6 @@ cy_capsense_status_t Cy_CapSense_ScanSensor_V2( cy_stc_capsense_context_t * context); cy_capsense_status_t Cy_CapSense_ScanAllWidgets_V2( cy_stc_capsense_context_t * context); -uint32_t Cy_CapSense_IsBusy_V2( - const cy_stc_capsense_context_t * context); void Cy_CapSense_InterruptHandler_V2( const CSD_Type * base, cy_stc_capsense_context_t * context); @@ -372,7 +370,15 @@ uint32_t Cy_CapSense_WaitEndOfScan( #define CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_SCALE_MSK (CSD_SENSE_PERIOD_LFSR_SCALE_Msk) #define CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_CLEAR_MSK (CSD_SENSE_PERIOD_LFSR_CLEAR_Msk) #define CY_CAPSENSE_CSD_SENSE_PERIOD_SEL_LFSR_MSB_MSK (CSD_SENSE_PERIOD_SEL_LFSR_MSB_Msk) -#define CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_BITS_MSK (CSD_SENSE_PERIOD_LFSR_BITS_Msk) +#if (CY_CAPSENSE_PLATFORM_DEVICE_PSOC4) + #if (2u <= CY_IP_M0S8CSDV2_VERSION) + #define CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_BITS_MSK (CSD_SENSE_PERIOD_LFSR_BITS_Msk) + #else + #define CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_BITS_MSK (0u) + #endif +#else + #define CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_BITS_MSK (0u) +#endif /* CSD_SENSE_DUTY register masks */ #define CY_CAPSENSE_CSD_SENSE_DUTY_SENSE_WIDTH_MSK (CSD_SENSE_DUTY_SENSE_WIDTH_Msk) @@ -654,7 +660,7 @@ uint32_t Cy_CapSense_WaitEndOfScan( #define CY_CAPSENSE_HSIOM_SEL_CSD_SHIELD (HSIOM_SEL_CSD_SHIELD) #define CY_CAPSENSE_HSIOM_SEL_AMUXA (HSIOM_SEL_AMUXA) #define CY_CAPSENSE_HSIOM_SEL_AMUXB (HSIOM_SEL_AMUXB) - #define CY_CAPSENSE_DM_SHIELD (CY_GPIO_DM_ANALOG) + #define CY_CAPSENSE_DM_SHIELD (CY_GPIO_DM_ANALOG) #define CY_CAPSENSE_CSD_SCAN_PIN_DM (CY_GPIO_DM_ANALOG) #define CY_CAPSENSE_CSX_TX_SCAN_PIN_HSIOM (HSIOM_SEL_CSD_SENSE) #define CY_CAPSENSE_CSX_CINT_SCAN_PIN_HSIOM (HSIOM_SEL_AMUXA) @@ -664,7 +670,7 @@ uint32_t Cy_CapSense_WaitEndOfScan( #define CY_CAPSENSE_HSIOM_SEL_CSD_SHIELD (HSIOM_SEL_ACT_2) #define CY_CAPSENSE_HSIOM_SEL_AMUXA (HSIOM_SEL_AMUXA) #define CY_CAPSENSE_HSIOM_SEL_AMUXB (HSIOM_SEL_AMUXB) - #define CY_CAPSENSE_DM_SHIELD (CY_GPIO_DM_STRONG_IN_OFF) + #define CY_CAPSENSE_DM_SHIELD (CY_GPIO_DM_STRONG_IN_OFF) #define CY_CAPSENSE_CSD_SCAN_PIN_DM (CY_GPIO_DM_STRONG_IN_OFF) #define CY_CAPSENSE_CSX_TX_SCAN_PIN_HSIOM (HSIOM_SEL_ACT_2) #define CY_CAPSENSE_CSX_CINT_SCAN_PIN_HSIOM (HSIOM_SEL_GPIO) diff --git a/cy_capsense_sensing_v3.c b/cy_capsense_sensing_v3.c index 528d791..3570a97 100644 --- a/cy_capsense_sensing_v3.c +++ b/cy_capsense_sensing_v3.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_sensing_v3.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file contains the source of functions common for different scanning @@ -44,11 +44,19 @@ #define CY_CAPSENSE_CSD_CCOMP_CALC_DIV (4u * CY_CAPSENSE_PERCENTAGE_100) #define CY_CAPSENSE_CSX_CCOMP_CALC_DIV (8u * CY_CAPSENSE_PERCENTAGE_100) -/* Defines the KREF_PRS correcting shift, taking into account Sense Clock Divider - * adjustment in scope of the Cy_CapSense_AdjustSnsClkDivider() - * routine. - */ -#define CY_CAPSENSE_PRS_SNS_KREF_SHIFT (1u) +/* CIC2 Filter Divider */ +#define CY_CAPSENSE_CIC2_DIVIDER_1 (1u) +#define CY_CAPSENSE_CIC2_DIVIDER_2 (2u) +#define CY_CAPSENSE_CIC2_DIVIDER_4 (4u) +#define CY_CAPSENSE_CIC2_DIVIDER_8 (8u) +#define CY_CAPSENSE_CIC2_DIVIDER_16 (16u) + +/* CIC2 Accumulator parameters */ +#define CY_CAPSENSE_CIC2_ACC_BIT_NUM (20u) +#define CY_CAPSENSE_CIC2_ACC_MAX_VAL ((1uL << CY_CAPSENSE_CIC2_ACC_BIT_NUM) - 1u) + +/* The minimum allowed value of CDAC compensation divider */ +#define CY_CAPSENSE_CDAC_COMP_DIV_MIN_MSCV3 (3u) /******************************************************************************* @@ -110,8 +118,8 @@ void Cy_CapSense_SetMaxCompCdac( #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) */ #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) -#if((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) ||\ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE)) +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE)) void Cy_CapSense_AmuxUpdateCdacComp( MSC_Type * base, const cy_stc_capsense_sensor_context_t * ptrSnsContext); @@ -131,72 +139,10 @@ void Cy_CapSense_AmuxStartScan(MSC_Type * base); /******************************************************************************* -* Function Name: Cy_CapSense_ScanAllSlots -****************************************************************************//** -* -* Initiates the non-blocking scan of all slots. Scanning is -* initiated only if no scan is in progress. Scan finishing can be -* checked by the Cy_CapSense_IsBusy() function. -* -* This function initiates a scan only for the first slot for all channels -* and then exits. Scans for the remaining slots in the Interrupt-driven scan mode -* are initiated -* in the interrupt service routine (part of middleware) triggered at the end -* of each scan completion for each channel. If the syncMode field in the -* cy_stc_capsense_common_config_t structure is set to CY_CAPSENSE_SYNC_MODE_OFF, -* then the next slot scan for the channel with the fired interrupt, -* will start regardless of the another channel readiness for the next scan. -* If the syncMode field is set to CY_CAPSENSE_SYNC_INTERNAL (for single-chip projects) -* or to CY_CAPSENSE_SYNC_EXTERNAL (for multi-chip projects), -* then the next slot scan for the channel with the fired interrupt, -* will start in lockstep with another channels after they all are ready -* for the next scan (the next scan configuration is loaded into the channel MSC HW block). -* Scans for the remaining slots in CS-DMA scan mode are initiated -* by DMAC triggered at the end -* of each scan completion for each channel. The channel scan synchronization is -* performed as in Interrupt-driven scan mode. After all slots are scanned, -* the FRAME interrupt is fired and the interrupt service routine (part of middleware) -* updates the busy status. -* -* The status of the current scan should be -* checked using the Cy_CapSense_IsBusy() function, where there are separate busy bits for each -* channel and the application program waits until all scans are finished -* prior to starting a next scan by using this function. -* -* \note -* This function is available only for the fifth-generation CAPSENSE™. -* -* \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. -* -* \return -* Returns the status of the operation: -* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. -* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. -* - CY_CAPSENSE_STATUS_HW_BUSY - The HW is busy with the previous scan. -* -*******************************************************************************/ -cy_capsense_status_t Cy_CapSense_ScanAllSlots( - cy_stc_capsense_context_t * context) -{ - cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; - - if (NULL != context) - { - capStatus = Cy_CapSense_ScanSlots(0u, CY_CAPSENSE_SLOT_COUNT, context); - } - - return (capStatus); -} - - -/******************************************************************************* -* Function Name: Cy_CapSense_ScanSlots +* Function Name: Cy_CapSense_ScanSlots_V3 ****************************************************************************//** * -* Initiates the non-blocking scan of specified slots. Scanning is -* initiated only if no scan is in progress. Scan finishing can be -* checked by the Cy_CapSense_IsBusy() function. +* Initiates the non-blocking scan of specified slots. * * This function initiates a scan only for the first specified slot for all channels * and then exits. Scans for the remaining slots in the interrupt-driven scan mode @@ -222,6 +168,11 @@ cy_capsense_status_t Cy_CapSense_ScanAllSlots( * is performed without the MSC HW block reconfiguration. Also, in the AMUX mode * sensors are not disconnected. * +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* * \note * This function is available only for the fifth-generation CAPSENSE™. * @@ -241,7 +192,7 @@ cy_capsense_status_t Cy_CapSense_ScanAllSlots( * - CY_CAPSENSE_STATUS_HW_BUSY - The HW is busy with the previous scan. * *******************************************************************************/ -cy_capsense_status_t Cy_CapSense_ScanSlots( +cy_capsense_status_t Cy_CapSense_ScanSlots_V3( uint32_t startSlotId, uint32_t numberSlots, cy_stc_capsense_context_t * context) @@ -249,19 +200,21 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; uint32_t curChIndex; - uint32_t lastSlot = startSlotId + numberSlots - 1u; + uint32_t startSlotIdLocal = startSlotId; + uint32_t numberSlotsLocal = numberSlots; + uint32_t lastSlot = startSlotIdLocal + numberSlotsLocal - 1u; const cy_stc_capsense_common_config_t * ptrCommonCfg; cy_stc_capsense_internal_context_t * ptrIntrCxt; + uint32_t slotValue; + uint32_t curSlotIndex; #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) uint32_t wdIndex; uint32_t snsIndex; - uint32_t slotValue; - uint32_t curSlotIndex; uint32_t scanSlotIndexValid; #endif - #if((CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) || \ - (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD)) + #if ((CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) || \ + (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD)) uint32_t * ptrSensorFrame; #endif @@ -269,13 +222,43 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( uint32_t sensorFrame[CY_MSC_6_SNS_REGS] = {0u, 0u, 0u, 0u, 0u, 0u}; #endif - if ((NULL != context) && (0u != numberSlots)) + if ((NULL != context) && (0u != numberSlotsLocal)) { if (CY_CAPSENSE_SLOT_COUNT > lastSlot) { ptrIntrCxt = context->ptrInternalContext; ptrCommonCfg = context->ptrCommonConfig; + #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) + /* Finds the first enabled slot for scanning */ + while (0u < numberSlotsLocal) + { + if (0u != Cy_CapSense_IsSlotEnabled(startSlotIdLocal, context)) + { + break; + } + startSlotIdLocal++; + numberSlotsLocal--; + } + /* Finds the last valid slot */ + while (0u < numberSlotsLocal) + { + if (0u != Cy_CapSense_IsSlotEnabled(lastSlot, context)) + { + break; + } + lastSlot--; + numberSlotsLocal--; + } + #endif + + #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) + if (0u == numberSlotsLocal) + { + capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; + } + else + #endif if (CY_CAPSENSE_NOT_BUSY != Cy_CapSense_IsBusy(context)) { /* Previous widget is being scanned. Return error. */ @@ -284,7 +267,7 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( else { if ((CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING == ptrIntrCxt->hwConfigState) && - (ptrIntrCxt->currentSlotIndex == startSlotId) && (1u == numberSlots) && + (ptrIntrCxt->currentSlotIndex == startSlotIdLocal) && (1u == numberSlotsLocal) && (0u == (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_CALIBRATION_MASK)) && (ptrIntrCxt->scanSingleSlot == CY_CAPSENSE_SCAN_SNGL_SLOT)) { @@ -292,7 +275,7 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( /* Initiates the frame start for each channel in interrupt driven scan mode */ for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase->FRAME_CMD = + ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase->FRAME_CMD = MSC_FRAME_CMD_START_FRAME_Msk; } #endif /* (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ @@ -304,17 +287,17 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( if (NULL != ptrIntrCxt->ptrSSCallback) { - ptrIntrCxt->ptrSSCallback((cy_stc_active_scan_sns_t *)&context->ptrActiveScanSns[curChIndex]); + ptrIntrCxt->ptrSSCallback((cy_stc_capsense_active_scan_sns_t *)&context->ptrActiveScanSns[curChIndex]); } #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) - ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase->SNS_CTL = context->ptrInternalContext->snsCtlReg[curChIndex] | + ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase->SNS_CTL = context->ptrInternalContext->snsCtlReg[curChIndex] | (MSC_SNS_CTL_START_SCAN_Msk | MSC_SNS_CTL_LAST_Msk); #endif #if (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) context->ptrSensorFrameContext[((lastSlot + 1u + - (curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT) * + ((curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT)) * CY_MSC_6_SNS_REGS) - 1u] |= MSC_SNS_CTL_LAST_Msk; #endif } @@ -323,10 +306,11 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( /* Initiates the frame start for each channel in DMA driven scan mode */ for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase->FRAME_CMD = + ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase->FRAME_CMD = MSC_FRAME_CMD_START_FRAME_Msk; } #endif + capStatus = CY_CAPSENSE_STATUS_SUCCESS; } else { @@ -347,14 +331,39 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - context->ptrActiveScanSns[curChIndex].currentChannelSlotIndex = (uint16_t)startSlotId; + context->ptrActiveScanSns[curChIndex].currentChannelSlotIndex = (uint16_t)startSlotIdLocal; } #if (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) - if((ptrIntrCxt->currentSlotIndex != (uint16_t)startSlotId) || - (ptrIntrCxt->endSlotIndex != (uint16_t)lastSlot)) + /* Finds number of empty slots requested for scan within DMA raw array */ + slotValue = 0u; + for (curSlotIndex = 0u; curSlotIndex < startSlotIdLocal; curSlotIndex++) + { + if (0u == Cy_CapSense_IsSlotEnabled(curSlotIndex, context)) + { + slotValue++; + } + } + + /* Stores DMA raw array ID */ + ptrIntrCxt->firstValidSlot = (uint16_t)(startSlotIdLocal - slotValue); + + /* Finds number of valid slots to be scanned */ + slotValue = 0u; + for (curSlotIndex = startSlotIdLocal; curSlotIndex < (lastSlot + 1u); curSlotIndex++) + { + if (0u != Cy_CapSense_IsSlotEnabled(curSlotIndex, context)) + { + slotValue++; + } + } + + if ((ptrIntrCxt->currentSlotIndex != (uint16_t)startSlotIdLocal) || + (ptrIntrCxt->endSlotIndex != (uint16_t)lastSlot) || + (ptrIntrCxt->numValidSlots != (uint16_t)slotValue)) { - ptrIntrCxt->currentSlotIndex = (uint16_t)startSlotId; + ptrIntrCxt->numValidSlots = (uint16_t)slotValue; + ptrIntrCxt->currentSlotIndex = (uint16_t)startSlotIdLocal; ptrIntrCxt->endSlotIndex = (uint16_t)lastSlot; /* Configure DMA resources for each channel */ for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) @@ -364,18 +373,18 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( } #else /* (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ - ptrIntrCxt->currentSlotIndex = (uint16_t)startSlotId; + ptrIntrCxt->currentSlotIndex = (uint16_t)startSlotIdLocal; ptrIntrCxt->endSlotIndex = (uint16_t)lastSlot; /* Initiates the frame start for each channel in interrupt driven scan mode */ for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase->FRAME_CMD = + ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase->FRAME_CMD = MSC_FRAME_CMD_START_FRAME_Msk; } #endif /* (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ /* Set the single or multiple slot scan mode */ - if ((1u == numberSlots) && + if ((1u == numberSlotsLocal) && (0u == (context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_CALIBRATION_MASK))) { ptrIntrCxt->scanSingleSlot = CY_CAPSENSE_SCAN_SNGL_SLOT; @@ -391,13 +400,13 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( Cy_CapSense_SetBusyFlags(curChIndex, context); #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) - curSlotIndex = startSlotId + ((curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT); + curSlotIndex = startSlotIdLocal + ((curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT); slotValue = context->ptrScanSlots[curSlotIndex].wdId; scanSlotIndexValid = curSlotIndex; - if(CY_CAPSENSE_SLOT_EMPTY == slotValue) + if (CY_CAPSENSE_SLOT_EMPTY == slotValue) { #if (CY_CAPSENSE_TOTAL_CH_NUMBER > 1u) - if(curSlotIndex < CY_CAPSENSE_SLOT_COUNT) + if (curSlotIndex < CY_CAPSENSE_SLOT_COUNT) { scanSlotIndexValid += CY_CAPSENSE_SLOT_COUNT; } @@ -410,7 +419,7 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( else if (CY_CAPSENSE_SLOT_SHIELD_ONLY <= slotValue) { scanSlotIndexValid = ((uint32_t)context->ptrScanSlots[curSlotIndex].snsId * - CY_CAPSENSE_SLOT_COUNT) + startSlotId; + CY_CAPSENSE_SLOT_COUNT) + startSlotIdLocal; } else { @@ -427,7 +436,7 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( #endif /* (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) - if((slotValue != CY_CAPSENSE_SLOT_EMPTY) && + if ((slotValue != CY_CAPSENSE_SLOT_EMPTY) && (slotValue != CY_CAPSENSE_SLOT_SHIELD_ONLY)) { /* Connect the widget first sensor electrodes */ @@ -437,18 +446,18 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( ptrSensorFrame = &sensorFrame[0u]; (void)Cy_CapSense_GenerateSensorConfig(curChIndex, curSlotIndex, ptrSensorFrame, context); /* Configure the last slot */ - if (1u == numberSlots) + if (1u == numberSlotsLocal) { sensorFrame[CY_CAPSENSE_SNS_CTL_INDEX] |= MSC_SNS_CTL_LAST_Msk; } #else /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) */ /* Configure the last slot for each channel */ context->ptrSensorFrameContext[((lastSlot + 1u + - (curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT) * + ((curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT)) * CY_MSC_6_SNS_REGS) - 1u] |= MSC_SNS_CTL_LAST_Msk; #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) - ptrSensorFrame = &context->ptrSensorFrameContext[(startSlotId + + ptrSensorFrame = &context->ptrSensorFrameContext[(startSlotIdLocal + ((curChIndex + ptrCommonCfg->channelOffset) * CY_CAPSENSE_SLOT_COUNT)) * CY_MSC_6_SNS_REGS]; #endif @@ -457,14 +466,14 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( if (NULL != ptrIntrCxt->ptrSSCallback) { #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) - ptrIntrCxt->ptrSSCallback((cy_stc_active_scan_sns_t *)&context->ptrActiveScanSns[0u]); + ptrIntrCxt->ptrSSCallback((cy_stc_capsense_active_scan_sns_t *)&context->ptrActiveScanSns[0u]); #else ptrIntrCxt->ptrSSCallback(NULL); #endif } #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) - Cy_MSC_ConfigureScan(ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase, + Cy_MSC_ConfigureScan(ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase, CY_MSC_6_SNS_REGS, ptrSensorFrame); #endif } @@ -473,7 +482,7 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( /* Initiates the frame start for each channel in DMA driven scan mode */ for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase->FRAME_CMD = + ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase->FRAME_CMD = MSC_FRAME_CMD_START_FRAME_Msk; } #endif @@ -483,7 +492,7 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( } } - return (capStatus); + return capStatus; } @@ -491,9 +500,12 @@ cy_capsense_status_t Cy_CapSense_ScanSlots( * Function Name: Cy_CapSense_ScanAllWidgets_V3 ****************************************************************************//** * -* Initiates the non-blocking scan for all widgets/sensors. Scanning is -* initiated only if no scan is in progress. Scan finishing can be -* checked by the Cy_CapSense_IsBusy() function. +* Initiates the non-blocking scan for all widgets/sensors. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. * * The function is the wrapper for the Cy_CapSense_ScanAllSlots() function * to provide the backward compatibility. @@ -520,7 +532,7 @@ cy_capsense_status_t Cy_CapSense_ScanAllWidgets_V3(cy_stc_capsense_context_t * c capStatus = Cy_CapSense_ScanSlots(0u, CY_CAPSENSE_SLOT_COUNT, context); } - return (capStatus); + return capStatus; } @@ -528,14 +540,17 @@ cy_capsense_status_t Cy_CapSense_ScanAllWidgets_V3(cy_stc_capsense_context_t * c * Function Name: Cy_CapSense_ScanWidget_V3 ****************************************************************************//** * -* Initiates the scanning of all sensors in the widget. Scanning is -* initiated only if no scan is in progress. Scan finishing can be -* checked by the Cy_CapSense_IsBusy() function. +* Initiates the scanning of all sensors in the widget. * * The function uses the Cy_CapSense_ScanSlots() function with the parameters of * startSlotId and numberSlots retrieved from the firstSlotId and numSlots * fields of the cy_stc_capsense_widget_config_t structure. * +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* * \note * This function is available only for the fifth-generation CAPSENSE™. * This function is available in single-channel solution. @@ -569,11 +584,11 @@ cy_capsense_status_t Cy_CapSense_ScanWidget_V3( context->ptrWdConfig[widgetId].numSlots, context); } #else - (void) widgetId; + (void)widgetId; #endif /* (1u >= CY_CAPSENSE_TOTAL_CH_NUMBER) */ } - return (capStatus); + return capStatus; } @@ -581,9 +596,12 @@ cy_capsense_status_t Cy_CapSense_ScanWidget_V3( * Function Name: Cy_CapSense_ScanSensor_V3 ****************************************************************************//** * -* Initiates the scanning of the selected sensor in the widget. Scanning is -* initiated only if no scan is in progress. Scan finishing can be -* checked by the Cy_CapSense_IsBusy() function. +* Initiates the scanning of the selected sensor in the widget. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. * * \note * This function is available only for the fifth-generation CAPSENSE™. @@ -626,19 +644,19 @@ cy_capsense_status_t Cy_CapSense_ScanSensor_V3( } } #else - (void) widgetId; - (void) sensorId; + (void)widgetId; + (void)sensorId; #endif /* (1u >= CY_CAPSENSE_TOTAL_CH_NUMBER) */ } - return (capStatus); + return capStatus; } #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) /******************************************************************************* -* Function Name: Cy_CapSense_CalibrateAllSlots +* Function Name: Cy_CapSense_CalibrateAllSlots_V3 ****************************************************************************//** * * Executes CapDAC auto-calibration for all relevant widgets if enabled. @@ -655,10 +673,10 @@ cy_capsense_status_t Cy_CapSense_ScanSensor_V3( * * 85% of the maximum raw count for CSD widgets * * 40% of the maximum raw count for CSX widgets. * -* To change calibration targets use the Cy_CapSense_SetCalibrTarget() function. +* To change calibration targets use the Cy_CapSense_SetCalibrationTarget() function. * * \note -* This function is available only for the fifth-generation CAPSENSE™. +* This function is available only for the fifth-generation low power CAPSENSE™. * * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. @@ -675,12 +693,14 @@ cy_capsense_status_t Cy_CapSense_ScanSensor_V3( * defined range. * *******************************************************************************/ -cy_capsense_status_t Cy_CapSense_CalibrateAllSlots(cy_stc_capsense_context_t * context) +cy_capsense_status_t Cy_CapSense_CalibrateAllSlots_V3(cy_stc_capsense_context_t * context) { cy_capsense_status_t calibStatus = CY_CAPSENSE_STATUS_BAD_PARAM; const cy_stc_capsense_common_config_t * ptrCommonCfg; uint32_t curWdIndex; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) || \ @@ -772,7 +792,23 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllSlots(cy_stc_capsense_context_t * c { for (curWdIndex = 0u; curWdIndex < ptrCommonCfg->numWd; curWdIndex++) { - calibStatus |= Cy_CapSense_VerifyCalibration(curWdIndex, context); + ptrWdCfg = &context->ptrWdConfig[curWdIndex]; + switch (ptrWdCfg->senseMethod) + { + #if (CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE) + case CY_CAPSENSE_CSD_GROUP: + #endif + + #if (CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE) + case CY_CAPSENSE_CSX_GROUP: + #endif + + calibStatus |= Cy_CapSense_VerifyCalibration(curWdIndex, context); + break; + default: + /* Skip widget with disabled auto-calibration */ + break; + } } } @@ -791,7 +827,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllSlots(cy_stc_capsense_context_t * c context->ptrCommonContext->status &= ~(uint32_t)CY_CAPSENSE_MW_STATE_CALIBRATION_MASK; } - return (calibStatus); + return calibStatus; } #endif @@ -799,28 +835,31 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllSlots(cy_stc_capsense_context_t * c #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) /******************************************************************************* -* Function Name: Cy_CapSense_SetCalibrationTargets +* Function Name: Cy_CapSense_SetCalibrationTarget_V3 ****************************************************************************//** * -* Sets the CapDAC auto-calibration raw count targets for CSD and/or CSX widgets. +* Sets the CapDAC auto-calibration raw count targets for CSD, CSX and/or ISX +* widgets. * -* The function sets the specified raw count targets if CSD and/or CSX widgets are -* in the project and the auto-calibration is enabled for them. These targets will -* be used instead the configured ones by Cy_CapSense_CalibrateAllSlots(), +* The function sets the specified raw count targets if CSD, CSX and/or ISX widgets +* are in the project and the auto-calibration is enabled for them. These targets +* will be used instead the configured ones by Cy_CapSense_CalibrateAllSlots(), * Cy_CapSense_CalibrateAllWidgets() and Cy_CapSense_CalibrateWidget() functions. * * \note * This function is available only for the fifth-generation CAPSENSE™. * -* \param csdCalibrTarget -* The specified raw counts target for CSD widgets in percentage. It should be -* more than 0u and less than 100u. If the specified target is outside the range, -* then the configured target value will be used for the auto-calibration. +* \param calibrTarget +* The raw counts target in percentage for the specified sensing method. +* It should be more than 0u and less than 100u. If the specified target is outside the +* range, then it will not be updated and the CY_CAPSENSE_STATUS_BAD_PARAM status will be +* returned. * -* \param csxCalibrTarget -* The specified raw counts target for CSX widgets in percentage. It should be -* more than 0u and less than 100u. If the specified target is outside the range, -* then the configured target value will be used for the auto-calibration. +* \param snsMethod +* Desired sensing method the calibration target should be updated for: +* * CY_CAPSENSE_CSD_GROUP - CSD sensing method +* * CY_CAPSENSE_CSX_GROUP - CSX sensing method +* * CY_CAPSENSE_ISX_GROUP - ISX sensing method * * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. @@ -830,34 +869,48 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllSlots(cy_stc_capsense_context_t * c * - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. * - CY_CAPSENSE_STATUS_BAD_PARAM - At least one of the input parameter is * invalid. -* - CY_CAPSENSE_STATUS_BAD_CONFIG - The configuration parameter is invalid. * *******************************************************************************/ -cy_capsense_status_t Cy_CapSense_SetCalibrationTargets( - uint32_t csdCalibrTarget, - uint32_t csxCalibrTarget, +cy_capsense_status_t Cy_CapSense_SetCalibrationTarget_V3( + uint32_t calibrTarget, + uint32_t snsMethod, cy_stc_capsense_context_t * context) { cy_capsense_status_t calibStatus = CY_CAPSENSE_STATUS_BAD_PARAM; if (NULL != context) { - if ((CY_CAPSENSE_PERCENTAGE_100 > csdCalibrTarget) && - (CY_CAPSENSE_PERCENTAGE_100 > csxCalibrTarget) && - (0u < csdCalibrTarget) && (0u < csxCalibrTarget)) + if ((CY_CAPSENSE_PERCENTAGE_100 > calibrTarget) && (0u < calibrTarget)) { - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) - context->ptrInternalContext->intrCsdRawTarget = (uint8_t)csdCalibrTarget; - #endif + switch (snsMethod) + { + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + case CY_CAPSENSE_CSD_GROUP: + context->ptrInternalContext->intrCsdRawTarget = (uint8_t)calibrTarget; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) - context->ptrInternalContext->intrCsxRawTarget = (uint8_t)csxCalibrTarget; - #endif + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + case CY_CAPSENSE_CSX_GROUP: + context->ptrInternalContext->intrCsxRawTarget = (uint8_t)calibrTarget; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) + case CY_CAPSENSE_ISX_GROUP: + context->ptrInternalContext->intrIsxRawTarget = (uint8_t)calibrTarget; + break; + #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_EN) */ + + default: + /* No action */ + break; + } calibStatus = CY_CAPSENSE_STATUS_SUCCESS; } } - return (calibStatus); + return calibStatus; } #endif @@ -904,7 +957,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets_V3( #endif /* (1u >= CY_CAPSENSE_TOTAL_CH_NUMBER) */ } - return (calibStatus); + return calibStatus; } #endif @@ -961,7 +1014,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateWidget_V3( { ptrWdCfg = &context->ptrWdConfig[widgetId]; - switch(ptrWdCfg->senseMethod) + switch (ptrWdCfg->senseMethod) { #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) && (0u != CY_CAPSENSE_CSD_CALIBRATION_EN)) case CY_CAPSENSE_CSD_GROUP: @@ -1055,7 +1108,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateWidget_V3( context->ptrCommonContext->status &= ~(uint32_t)CY_CAPSENSE_MW_STATE_CALIBRATION_MASK; } - return (calibrationStatus); + return calibrationStatus; } #endif @@ -1083,7 +1136,7 @@ uint32_t Cy_CapSense_WatchdogCyclesNum( { uint32_t retVal; - if(0uL != cyclesPerLoop) + if (0uL != cyclesPerLoop) { retVal = (desiredTimeUs * cpuFreqMHz) / cyclesPerLoop; } @@ -1092,7 +1145,7 @@ uint32_t Cy_CapSense_WatchdogCyclesNum( retVal = 0xFFFFFFFFuL; } - return(retVal); + return retVal; } @@ -1117,9 +1170,9 @@ cy_capsense_status_t Cy_CapSense_SsInitialize(cy_stc_capsense_context_t * contex uint32_t curChIndex; cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; - const cy_stc_capsense_widget_config_t * ptrWdCfg; uint32_t i; + (void)ptrCommonCfg; capStatus |= Cy_CapSense_InitializeSourceSenseClk(context); /* Initialize all enabled MSC channels for scan */ @@ -1131,7 +1184,7 @@ cy_capsense_status_t Cy_CapSense_SsInitialize(cy_stc_capsense_context_t * contex /* Configure inactive sensor states */ #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - if(context->ptrInternalContext->intrCsdInactSnsConn != ptrCommonCfg->csdInactiveSnsConnection) + if (context->ptrInternalContext->intrCsdInactSnsConn != ptrCommonCfg->csdInactiveSnsConnection) { context->ptrInternalContext->intrCsdInactSnsConn = ptrCommonCfg->csdInactiveSnsConnection; Cy_CapSense_SetCsdInactiveState(context); @@ -1139,7 +1192,7 @@ cy_capsense_status_t Cy_CapSense_SsInitialize(cy_stc_capsense_context_t * contex #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) */ #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - if(context->ptrInternalContext->intrCsxInactSnsConn != ptrCommonCfg->csxInactiveSnsConnection) + if (context->ptrInternalContext->intrCsxInactSnsConn != ptrCommonCfg->csxInactiveSnsConnection) { context->ptrInternalContext->intrCsxInactSnsConn = ptrCommonCfg->csxInactiveSnsConnection; Cy_CapSense_SetCsxInactiveState(context); @@ -1166,23 +1219,6 @@ cy_capsense_status_t Cy_CapSense_SsInitialize(cy_stc_capsense_context_t * contex /* Assign the ISR for scan */ context->ptrInternalContext->ptrISRCallback = &Cy_CapSense_ScanISR; - /* Find maximum raw count for each widget */ - ptrWdCfg = &context->ptrWdConfig[0u]; - for (i = 0u; i < context->ptrCommonConfig->numWd; i++) - { - ptrWdCfg->ptrWdContext->maxRawCount = (uint16_t)Cy_CapSense_GetMaxRaw(ptrWdCfg->ptrWdContext->snsClk, ptrWdCfg, context); - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) - if((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && - (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || - ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType))) - { - ptrWdCfg->ptrWdContext->maxRawCountRow = (uint16_t)Cy_CapSense_GetMaxRaw(ptrWdCfg->ptrWdContext->rowSnsClk, ptrWdCfg, context); - } - #endif - ptrWdCfg++; - } - /* Call user's callback function if it is registered */ if (NULL != context->ptrInternalContext->ptrEODsInitCallback) { @@ -1202,7 +1238,13 @@ cy_capsense_status_t Cy_CapSense_SsInitialize(cy_stc_capsense_context_t * contex capStatus |= Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING, context); } - return (capStatus); + /* Find maximum raw count for each widget */ + for (i = 0u; i < context->ptrCommonConfig->numWd; i++) + { + capStatus |= Cy_CapSense_InitializeMaxRaw(i, context); + } + + return capStatus; } @@ -1268,42 +1310,16 @@ void Cy_CapSense_InterruptHandler_V3(const MSC_Type * base, cy_stc_capsense_cont context->ptrInternalContext->ptrISRCallback((void *)context); } - #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) /******************************************************************************* * Function Name: Cy_CapSense_SetPinState_V3 ****************************************************************************//** * -* Sets the state (drive mode and HSIOM state) of the GPIO used by a sensor. -* -* The possible states are GND, Shield, High-Z, Tx, Negative Tx, Rx, and Sensor. -* If the sensor specified in the input parameter is a ganged sensor, then -* the state of all GPIOs associated with the ganged sensor is updated. -* -* To access a sensor of CSD of button or slider widgets, use the sensor ID. -* To access a sensor of CSD matrix button or touchpad widgets, -* use either row ID or column ID as appropriate. -* To access sensor CSX widgets, use either Rx ID or Tx ID as appropriate. -* -* This function accepts the CY_CAPSENSE_SHIELD and CY_CAPSENSE_SENSOR states -* as an input only if there is at least one CSD widget in the project. -* Similarly, this function accepts the CY_CAPSENSE_TX_PIN and -* CY_CAPSENSE_RX_PIN states as an input only if there is at least one -* CSX widget in the project. -* -* This function must not be called while the middleware is in the busy state. -* Calling this function directly from the application program is not -* recommended. This function is used to implement only the custom-specific -* use cases. -* -* Functions that perform a setup and scan of a sensor/widget -* set the required pin states automatically for a sensor as required -* and overwrite changes made by this function to a sensor that are -* going to be scanned. Therefore the Cy_CapSense_SetPinState() function -* is called in StartSample callback -* (see the \ref group_capsense_callbacks section for details) -* or with low-level functions that perform a single-sensor scanning. +* The internal function to set the state (drive mode and HSIOM state) of the GPIO used +* by a sensor. * +* See the Cy_CapSense_SetPinState() description for details. + * \note * This function is available only for the fifth-generation CAPSENSE™ when * Sensor Connection Method = AMUX mode. @@ -1461,7 +1477,7 @@ cy_capsense_status_t Cy_CapSense_SetPinState_V3( } } } - return (connState); + return connState; } @@ -1473,7 +1489,7 @@ cy_capsense_status_t Cy_CapSense_SetPinState_V3( * * The function checks the widget type and performs connection of all sensor * electrodes (sns for CSD widgets and Tx/Rx for CSX ones) including ganged. -* The sensor and the current slot are specified in the cy_stc_active_scan_sns_t structure. +* The sensor and the current slot are specified in the cy_stc_capsense_active_scan_sns_t structure. * * \param chIndex * The channel index. @@ -1519,7 +1535,7 @@ void Cy_CapSense_ConnectSensor( * * The function checks the widget type and performs disconnection of all sensor * electrodes (sns for CSD widgets and Tx/Rx for CSX ones) including ganged. -* The sensor and the current slot are specified in the cy_stc_active_scan_sns_t structure. +* The sensor and the current slot are specified in the cy_stc_capsense_active_scan_sns_t structure. * * \param chIndex * The desired channel index. @@ -1565,7 +1581,7 @@ void Cy_CapSense_DisconnectSensor( * Connects a CSD sensor to the specified channel MSC HW block. * * The function connects all the sensor pins including ganged. -* The sensor and the current slot are specified in the cy_stc_active_scan_sns_t structure. +* The sensor and the current slot are specified in the cy_stc_capsense_active_scan_sns_t structure. * * \param chIndex * The desired channel index. @@ -1583,10 +1599,10 @@ void Cy_CapSense_CsdConnectSns( const cy_stc_capsense_pin_config_t * ptrActivePin = eltdPinCfg->ptrPin; uint32_t i; - if((chIndex + context->ptrCommonConfig->channelOffset) == eltdPinCfg->chId) + if ((chIndex + context->ptrCommonConfig->channelOffset) == eltdPinCfg->chId) { /* Connect all pins of current sensors */ - for(i = 0u; i < eltdPinCfg->numPins; i++) + for (i = 0u; i < eltdPinCfg->numPins; i++) { Cy_CapSense_SsConfigPinRegisters(ptrActivePin->pcPtr, (uint32_t)ptrActivePin->pinNumber, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_CSD_SENSE); @@ -1603,7 +1619,7 @@ void Cy_CapSense_CsdConnectSns( * Disconnects a CSD sensor from the specified channel MSC HW block. * * The function disconnects all the sensor pins including ganged. -* The sensor and the current slot are specified in the cy_stc_active_scan_sns_t structure. +* The sensor and the current slot are specified in the cy_stc_capsense_active_scan_sns_t structure. * * \param chIndex * The desired channel index. @@ -1625,7 +1641,7 @@ void Cy_CapSense_CsdDisconnectSns( if ((chIndex + context->ptrCommonConfig->channelOffset) == eltdPinCfg->chId) { /* Disconnect all pins of the current sensor */ - for(i = 0u; i < eltdPinCfg->numPins; i++) + for (i = 0u; i < eltdPinCfg->numPins; i++) { Cy_CapSense_SsConfigPinRegisters(ptrActivePin->pcPtr, (uint32_t)ptrActivePin->pinNumber, context->ptrInternalContext->csdInactiveSnsDm, @@ -1646,7 +1662,7 @@ void Cy_CapSense_CsdDisconnectSns( * Connects a CSX sensor Tx electrode to the specified channel MSC HW block. * * The function connects all the Tx electrode pins including ganged. -* The electrode and the current slot are specified in the cy_stc_active_scan_sns_t structure. +* The electrode and the current slot are specified in the cy_stc_capsense_active_scan_sns_t structure. * * \param chIndex * The desired channel index. @@ -1662,18 +1678,18 @@ void Cy_CapSense_CsxConnectTx( uint32_t pinIndex; en_hsiom_sel_t hsiomState = CY_CAPSENSE_HSIOM_SEL_CSD_SENSE; const cy_stc_capsense_electrode_config_t * ptrEltd; - const cy_stc_active_scan_sns_t * ptrActive = &context->ptrActiveScanSns[chIndex]; + const cy_stc_capsense_active_scan_sns_t * ptrActive = &context->ptrActiveScanSns[chIndex]; const cy_stc_capsense_pin_config_t * pinPointer; - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) uint32_t i; uint32_t pattern; uint32_t eltdMptxOrder; cy_stc_capsense_widget_config_t const * ptrWdCfg = &context->ptrWdConfig[ptrActive->widgetIndex]; - uint32_t mptxOrd = ptrWdCfg->mptxOrder; + uint32_t mptxOrd = ptrWdCfg->mpOrder; #endif - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) if (CY_CAPSENSE_MPTX_MIN_ORDER > mptxOrd) { ptrEltd = ptrActive->ptrTxConfig; @@ -1697,7 +1713,7 @@ void Cy_CapSense_CsxConnectTx( ptrEltd = &ptrWdCfg->ptrEltdConfig[i]; /* Finding the right vector / pattern for mptx operation */ - pattern = ptrWdCfg->ptrMptxTable->vector; + pattern = ptrWdCfg->ptrMpTable->vector; if (0u != eltdMptxOrder) { pattern = (pattern >> eltdMptxOrder) | (pattern << (mptxOrd - eltdMptxOrder)); @@ -1754,7 +1770,7 @@ void Cy_CapSense_CsxConnectTx( * Connects a CSX sensor Rx electrode to the specified channel MSC HW block. * * The function connects all the Rx electrode pins including ganged. -* The electrode and the current slot are specified in the cy_stc_active_scan_sns_t structure. +* The electrode and the current slot are specified in the cy_stc_capsense_active_scan_sns_t structure. * * \param chIndex * The desired channel index. @@ -1791,7 +1807,7 @@ void Cy_CapSense_CsxConnectRx( * Disconnects a CSX sensor Tx electrode from the specified channel MSC HW block. * * The function disconnects all the Tx electrode pins including ganged. -* The electrode and the current slot are specified in the cy_stc_active_scan_sns_t structure. +* The electrode and the current slot are specified in the cy_stc_capsense_active_scan_sns_t structure. * * \param chIndex * The desired channel index. @@ -1806,17 +1822,17 @@ void Cy_CapSense_CsxDisconnectTx( { uint32_t pinIndex; const cy_stc_capsense_electrode_config_t * ptrEltd; - const cy_stc_active_scan_sns_t * ptrActive = &context->ptrActiveScanSns[chIndex]; + const cy_stc_capsense_active_scan_sns_t * ptrActive = &context->ptrActiveScanSns[chIndex]; const cy_stc_capsense_pin_config_t * pinPointer = ptrActive->ptrTxConfig->ptrPin; - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) uint32_t i; uint32_t eltdMptxOrder; cy_stc_capsense_widget_config_t const * ptrWdCfg = &context->ptrWdConfig[ptrActive->widgetIndex]; - uint32_t mptxOrd = ptrWdCfg->mptxOrder; + uint32_t mptxOrd = ptrWdCfg->mpOrder; #endif - #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED) + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_TX_ENABLED) if (CY_CAPSENSE_MPTX_MIN_ORDER > mptxOrd) { ptrEltd = ptrActive->ptrTxConfig; @@ -1883,7 +1899,7 @@ void Cy_CapSense_CsxDisconnectTx( * Disconnects a CSX sensor Rx electrode from the specified channel MSC HW block. * * The function disconnects all the Rx electrode pins including ganged. -* The electrode and the current slot are specified in the cy_stc_active_scan_sns_t structure. +* The electrode and the current slot are specified in the cy_stc_capsense_active_scan_sns_t structure. * * \param chIndex * The desired channel index. @@ -1950,7 +1966,7 @@ void Cy_CapSense_ScanISR(void * capsenseContext) #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) uint32_t scanSlotIndexValid; - cy_stc_active_scan_sns_t * ptrActive; + cy_stc_capsense_active_scan_sns_t * ptrActive; cy_stc_capsense_internal_context_t * ptrIntrCxt = cxt->ptrInternalContext; uint32_t slotStcIndex; #endif /* (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ @@ -1966,14 +1982,14 @@ void Cy_CapSense_ScanISR(void * capsenseContext) /* Check which channel have fired the interrupt */ for (i = 0u; i < CY_CAPSENSE_TOTAL_CH_NUMBER; i++) { - if (0u != (ptrCommonCfg->ptrMscChConfig[i].ptrMscBase->INTR & intrMask)) + if (0u != (ptrCommonCfg->ptrChConfig[i].ptrHwBase->INTR & intrMask)) { curChIndex = i; break; } } - ptrMscHwBase = ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase; + ptrMscHwBase = ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase; if (curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER) { @@ -1987,7 +2003,8 @@ void Cy_CapSense_ScanISR(void * capsenseContext) ptrActive = &(cxt->ptrActiveScanSns[curChIndex]); slotValue = cxt->ptrScanSlots[slotStcIndex].wdId; - if(CY_CAPSENSE_SLOT_SHIELD_ONLY > slotValue) + /* Skips raw count update for empty slots or disabled/non-working widgets */ + if ((CY_CAPSENSE_SLOT_SHIELD_ONLY > slotValue) && (0u != Cy_CapSense_IsWidgetEnabled(slotValue, cxt))) { /* Read raw counts */ tmpRawCount = ptrMscHwBase->RESULT_FIFO_RD; @@ -2017,19 +2034,32 @@ void Cy_CapSense_ScanISR(void * capsenseContext) } #endif + /* Find the next enabled slot for scanning */ + ptrActive->currentChannelSlotIndex = ptrIntrCxt->currentSlotIndex; + while (ptrActive->currentChannelSlotIndex != ptrIntrCxt->endSlotIndex) + { + if (0u != Cy_CapSense_IsSlotEnabled((uint32_t)ptrActive->currentChannelSlotIndex + 1u, cxt)) + { + break; + } + /* Update active sensor structure */ + ptrActive->currentChannelSlotIndex++; + slotStcIndex++; + } + /* Check for the last slot with multiple slot scan, if not - start the next slot scan */ - if (ptrIntrCxt->currentSlotIndex != ptrIntrCxt->endSlotIndex) + if (ptrActive->currentChannelSlotIndex != ptrIntrCxt->endSlotIndex) { /* Update active sensor structure */ - ptrActive->currentChannelSlotIndex = ptrIntrCxt->currentSlotIndex + 1u; + ptrActive->currentChannelSlotIndex++; slotStcIndex++; slotValue = cxt->ptrScanSlots[slotStcIndex].wdId; scanSlotIndexValid = slotStcIndex; - if(CY_CAPSENSE_SLOT_EMPTY == slotValue) + if (CY_CAPSENSE_SLOT_EMPTY == slotValue) { #if (CY_CAPSENSE_TOTAL_CH_NUMBER > 1u) - if(slotStcIndex < CY_CAPSENSE_SLOT_COUNT) + if (slotStcIndex < CY_CAPSENSE_SLOT_COUNT) { scanSlotIndexValid += CY_CAPSENSE_SLOT_COUNT; } @@ -2058,7 +2088,7 @@ void Cy_CapSense_ScanISR(void * capsenseContext) Cy_CapSense_InitActivePtr(curChIndex, wdIndex, cxt->ptrScanSlots[scanSlotIndexValid].snsId, cxt); #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) - if((slotValue != CY_CAPSENSE_SLOT_EMPTY) && + if ((slotValue != CY_CAPSENSE_SLOT_EMPTY) && (slotValue != CY_CAPSENSE_SLOT_SHIELD_ONLY)) { /* Connect the widget first sensor electrodes */ @@ -2081,13 +2111,13 @@ void Cy_CapSense_ScanISR(void * capsenseContext) { break; } - ptrIntrCxt->currentSlotIndex++; + ptrIntrCxt->currentSlotIndex = cxt->ptrActiveScanSns[0u].currentChannelSlotIndex; } #endif /* (1u == CY_CAPSENSE_TOTAL_CH_NUMBER) */ if (NULL != ptrIntrCxt->ptrSSCallback) { - ptrIntrCxt->ptrSSCallback((cy_stc_active_scan_sns_t *)&cxt->ptrActiveScanSns[curChIndex]); + ptrIntrCxt->ptrSSCallback((cy_stc_capsense_active_scan_sns_t *)&cxt->ptrActiveScanSns[curChIndex]); } /* Start the next scan for the current channel */ @@ -2110,7 +2140,7 @@ void Cy_CapSense_ScanISR(void * capsenseContext) #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) -#if((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) ||\ +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) ||\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE)) /******************************************************************************* * Function Name: Cy_CapSense_AmuxUpdateCdacComp @@ -2165,19 +2195,19 @@ void Cy_CapSense_AmuxUpdateScanConfig( cy_stc_capsense_context_t * context) { uint32_t isSnsRow = 0u; - MSC_Type * ptrMscHwBase = context->ptrCommonConfig->ptrMscChConfig[chIndex].ptrMscBase; - cy_stc_active_scan_sns_t * ptrActive = &context->ptrActiveScanSns[chIndex]; + MSC_Type * ptrMscHwBase = context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase; + cy_stc_capsense_active_scan_sns_t * ptrActive = &context->ptrActiveScanSns[chIndex]; uint32_t sensorFrame[CY_MSC_6_SNS_REGS] = {0u, 0u, 0u, 0u, 0u, 0u}; - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) - if((CY_CAPSENSE_CSD_GROUP == ptrActive->currentSenseMethod) && + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + if ((CY_CAPSENSE_CSD_GROUP == ptrActive->currentSenseMethod) && (context->ptrWdConfig[ptrActive->widgetIndex].numCols <= ptrActive->sensorIndex)) { isSnsRow = 1u; } #endif - if((prevWdIndex != ptrActive->widgetIndex) || (0u != isSnsRow)) + if ((prevWdIndex != ptrActive->widgetIndex) || (0u != isSnsRow)) { (void)Cy_CapSense_GenerateSensorConfig(chIndex, scanSlot, &sensorFrame[0u], context); @@ -2195,13 +2225,13 @@ void Cy_CapSense_AmuxUpdateScanConfig( { if (CY_CAPSENSE_CSD_GROUP == ptrActive->currentSenseMethod) { - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) Cy_CapSense_AmuxUpdateCdacComp(ptrMscHwBase, ptrActive->ptrSnsContext); #endif } else { - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE) Cy_CapSense_AmuxUpdateCdacComp(ptrMscHwBase, ptrActive->ptrSnsContext); #endif } @@ -2256,12 +2286,12 @@ void Cy_CapSense_SetCmodInDefaultState( const cy_stc_capsense_context_t * context) { Cy_CapSense_SsConfigPinRegisters( - context->ptrCommonConfig->ptrMscChConfig[chIndex].portCmod1, - (uint32_t)context->ptrCommonConfig->ptrMscChConfig[chIndex].pinCmod1, + context->ptrCommonConfig->ptrChConfig[chIndex].portCmod1, + (uint32_t)context->ptrCommonConfig->ptrChConfig[chIndex].pinCmod1, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO); Cy_CapSense_SsConfigPinRegisters( - context->ptrCommonConfig->ptrMscChConfig[chIndex].portCmod2, - (uint32_t)context->ptrCommonConfig->ptrMscChConfig[chIndex].pinCmod2, + context->ptrCommonConfig->ptrChConfig[chIndex].portCmod2, + (uint32_t)context->ptrCommonConfig->ptrChConfig[chIndex].pinCmod2, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_GPIO); } @@ -2291,13 +2321,13 @@ void Cy_CapSense_SetCmodInAmuxModeState( const cy_stc_capsense_context_t * context) { Cy_CapSense_SsConfigPinRegisters( - context->ptrCommonConfig->ptrMscChConfig[chIndex].portCmod1, - (uint32_t)context->ptrCommonConfig->ptrMscChConfig[chIndex].pinCmod1, + context->ptrCommonConfig->ptrChConfig[chIndex].portCmod1, + (uint32_t)context->ptrCommonConfig->ptrChConfig[chIndex].pinCmod1, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXA); Cy_CapSense_SsConfigPinRegisters( - context->ptrCommonConfig->ptrMscChConfig[chIndex].portCmod2, - (uint32_t)context->ptrCommonConfig->ptrMscChConfig[chIndex].pinCmod2, + context->ptrCommonConfig->ptrChConfig[chIndex].portCmod2, + (uint32_t)context->ptrCommonConfig->ptrChConfig[chIndex].pinCmod2, CY_CAPSENSE_DM_GPIO_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXA); } #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) */ @@ -2465,7 +2495,7 @@ void Cy_CapSense_InitActivePtr( { Cy_CapSense_InitActivePtrWd(chIndex, widgetId, context); - if(CY_CAPSENSE_SLOT_SHIELD_ONLY > widgetId) + if (CY_CAPSENSE_SLOT_SHIELD_ONLY > widgetId) { Cy_CapSense_InitActivePtrSns(chIndex, sensorId, context); } @@ -2501,7 +2531,7 @@ void Cy_CapSense_InitActivePtrSns( { #if ((CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) - cy_stc_active_scan_sns_t * ptrActive = &context->ptrActiveScanSns[chIndex]; + cy_stc_capsense_active_scan_sns_t * ptrActive = &context->ptrActiveScanSns[chIndex]; #endif #if ((CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) || \ @@ -2516,7 +2546,7 @@ void Cy_CapSense_InitActivePtrSns( #endif #if ((CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) && \ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_ENABLED)) + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_PHASE_TX_ENABLED)) ptrActive->sensorIndex = (uint16_t)sensorId; #endif @@ -2535,7 +2565,7 @@ void Cy_CapSense_InitActivePtrSns( #if ((CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) - switch(widgetSenseGroup) + switch (widgetSenseGroup) { #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) case (uint8_t)CY_CAPSENSE_CSD_GROUP: @@ -2552,9 +2582,9 @@ void Cy_CapSense_InitActivePtrSns( break; #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) */ - default: - /* Widget type is not valid so nothing to do */ - break; + default: + /* Widget type is not valid so nothing to do */ + break; } #endif } @@ -2585,14 +2615,14 @@ void Cy_CapSense_InitActivePtrWd( uint32_t widgetId, cy_stc_capsense_context_t * context) { - cy_stc_active_scan_sns_t * ptrActive = &(context->ptrActiveScanSns[chIndex]); + cy_stc_capsense_active_scan_sns_t * ptrActive = &(context->ptrActiveScanSns[chIndex]); #if ((CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) || \ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_MEASUREMENT_GROUP_EN)) ptrActive->widgetIndex = (uint8_t)widgetId; #endif - if(CY_CAPSENSE_SLOT_SHIELD_ONLY > widgetId) + if (CY_CAPSENSE_SLOT_SHIELD_ONLY > widgetId) { ptrActive->currentSenseMethod = context->ptrWdConfig[widgetId].senseMethod; } @@ -2675,7 +2705,7 @@ void Cy_CapSense_EnableShieldElectrodes(uint32_t chIndex, cy_stc_capsense_contex *ptrSwSelCfg |= CY_CAPSENSE_FW_SHIELD_PASSIVE_AMUX_REG_SW_CSD_SHIELD_VALUE; } - context->ptrCommonConfig->ptrMscChConfig[chIndex].ptrMscBase->SW_SEL_GPIO = *ptrSwSelCfg; + context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase->SW_SEL_GPIO = *ptrSwSelCfg; for (shieldIndex = 0u; shieldIndex < context->ptrCommonConfig->csdShieldNumPin; shieldIndex++) { @@ -2723,7 +2753,7 @@ void Cy_CapSense_DisableShieldElectrodes(uint32_t chIndex, cy_stc_capsense_conte /* Reverts the .swSelGpio register state to default AMUX+CSX+MPTX */ context->ptrBaseFrameContext[chIndex].swSelGpio |= CY_CAPSENSE_FW_NEGATIVE_TX_AMUX_REG_SW_CSD_SHIELD_VALUE; - context->ptrCommonConfig->ptrMscChConfig[chIndex].ptrMscBase->SW_SEL_GPIO = + context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase->SW_SEL_GPIO = context->ptrBaseFrameContext[chIndex].swSelGpio; for (shieldIndex = 0u; shieldIndex < context->ptrCommonConfig->csdShieldNumPin; shieldIndex++) @@ -2743,7 +2773,7 @@ void Cy_CapSense_DisableShieldElectrodes(uint32_t chIndex, cy_stc_capsense_conte /******************************************************************************* -* Function Name: Cy_CapSense_ScanAbort +* Function Name: Cy_CapSense_ScanAbort_V3 ****************************************************************************//** * * This function sets the sequencer to the idle state by resetting the hardware, @@ -2763,31 +2793,31 @@ void Cy_CapSense_DisableShieldElectrodes(uint32_t chIndex, cy_stc_capsense_conte * Returns the status of the operation \ref cy_capsense_status_t. * *******************************************************************************/ -cy_capsense_status_t Cy_CapSense_ScanAbort(cy_stc_capsense_context_t * context) +cy_capsense_status_t Cy_CapSense_ScanAbort_V3(cy_stc_capsense_context_t * context) { uint32_t interruptState; uint32_t curChIndex; const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; - const cy_stc_msc_channel_config_t * ptrMscChan = ptrCommonCfg->ptrMscChConfig; + const cy_stc_capsense_channel_config_t * ptrMscChan = ptrCommonCfg->ptrChConfig; interruptState = Cy_SysLib_EnterCriticalSection(); /* Clear ENABLE bit for all channels */ for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - ptrMscChan[curChIndex].ptrMscBase->CTL &= ~MSC_CTL_ENABLED_Msk; + ptrMscChan[curChIndex].ptrHwBase->CTL &= ~MSC_CTL_ENABLED_Msk; } for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { /* Wait until ENABLE bit is cleared for all channels*/ - while (0u != (MSC_CTL_ENABLED_Msk & ptrMscChan[curChIndex].ptrMscBase->CTL)) + while (0u != (MSC_CTL_ENABLED_Msk & ptrMscChan[curChIndex].ptrHwBase->CTL)) {} /* Set ENABLE bit for all channels */ - ptrMscChan[curChIndex].ptrMscBase->CTL |= MSC_CTL_ENABLED_Msk; + ptrMscChan[curChIndex].ptrHwBase->CTL |= MSC_CTL_ENABLED_Msk; /* Clear all pending interrupts of the MSC HW block */ - ptrMscChan[curChIndex].ptrMscBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; - (void)ptrMscChan[curChIndex].ptrMscBase->INTR; + ptrMscChan[curChIndex].ptrHwBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; + (void)ptrMscChan[curChIndex].ptrHwBase->INTR; } Cy_SysLib_ExitCriticalSection(interruptState); @@ -2799,19 +2829,24 @@ cy_capsense_status_t Cy_CapSense_ScanAbort(cy_stc_capsense_context_t * context) /* Wait for initialization */ Cy_SysLib_DelayUs(ptrCommonCfg->analogWakeupDelay); - return(CY_CAPSENSE_STATUS_SUCCESS); + return CY_CAPSENSE_STATUS_SUCCESS; } /******************************************************************************* -* Function Name: Cy_CapSense_MwState +* Function Name: Cy_CapSense_MwState_V3 ****************************************************************************//** * * This function returns a detailed state of the CAPSENSE™ middleware and MSC * hardware in Single- or Multi-channel mode. This feature is useful in * multi-thread applications or in ISR. -* Use the Cy_CapSense_IsBusy() function to verify if HW is busy at a particular -* moment. +* +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* If the middleware is busy, a new scan, setup widgets, any kind of reconfiguration, +* or parameter change should not be initiated. * * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. @@ -2843,44 +2878,13 @@ cy_capsense_status_t Cy_CapSense_ScanAbort(cy_stc_capsense_context_t * context) * scanned slot. * *******************************************************************************/ -cy_capsense_mw_state_t Cy_CapSense_MwState(const cy_stc_capsense_context_t * context) +cy_capsense_mw_state_t Cy_CapSense_MwState_V3(const cy_stc_capsense_context_t * context) { return ((context->ptrCommonContext->status & ~CY_CAPSENSE_MW_STATE_SCAN_SLOT_MASK) | ((uint32_t)context->ptrInternalContext->currentSlotIndex << CY_CAPSENSE_MW_STATE_SCAN_SLOT_POS)); } -/******************************************************************************* -* Function Name: Cy_CapSense_IsBusy_V3 -****************************************************************************//** -* -* This function returns a status of the CAPSENSE™ middleware whether a scan is -* currently in progress or not. -* -* If the middleware is busy, a new scan or setup widgets should not be initiated. -* -* Use the Cy_CapSense_MwState() function to check a detailed CAPSENSE™ middleware -* state. -* -* \note -* This function is available only for the fifth-generation CAPSENSE™. -* -* \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. -* -* \return -* Returns the status of the middleware: -* - CY_CAPSENSE_NOT_BUSY - No scan is in progress and a next scan -* can be initiated. -* - CY_CAPSENSE_BUSY - The previously initiated scan is in progress. -* -*******************************************************************************/ -uint32_t Cy_CapSense_IsBusy_V3(const cy_stc_capsense_context_t * context) -{ - return (context->ptrCommonContext->status & CY_CAPSENSE_BUSY); -} - - /******************************************************************************* * Function Name: Cy_CapSense_SetBusyFlags ****************************************************************************//** @@ -2888,6 +2892,11 @@ uint32_t Cy_CapSense_IsBusy_V3(const cy_stc_capsense_context_t * context) * Sets BUSY flags of the cy_capsense_context.status register specified * by the flags parameter. * +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* * This is an internal function. Do not call this function directly from * the application program. * @@ -2914,6 +2923,11 @@ void Cy_CapSense_SetBusyFlags( * Clears BUSY flags of the cy_capsense_context.status register specified * by the flags parameter. * +* If the middleware is busy, do not initiate a new scan or set up widgets. +* Use the Cy_CapSense_IsBusy() function to check HW busyness at a particular moment. +* Use the Cy_CapSense_MwState() function to verify if MW executes any firmware +* tasks related to initialization, scanning, and processing at a particular moment. +* * This is an internal function. Do not call this function directly from * the application program. * @@ -2931,12 +2945,12 @@ void Cy_CapSense_ClrBusyFlags( #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) /* Clear Last flag inside sensor frame structure for the current channel */ uint32_t snsPos = context->ptrInternalContext->endSlotIndex + (context->ptrCommonConfig->numSlots * chIndex); - context->ptrSensorFrameContext[snsPos * CY_MSC_6_SNS_REGS + CY_CAPSENSE_SNS_CTL_INDEX] &= ~MSC_SNS_CTL_LAST_Msk; + context->ptrSensorFrameContext[(snsPos * CY_MSC_6_SNS_REGS) + CY_CAPSENSE_SNS_CTL_INDEX] &= ~MSC_SNS_CTL_LAST_Msk; #endif /* Clear busy flag for the current channel */ context->ptrCommonContext->status &= (uint32_t)(~(((uint32_t)CY_CAPSENSE_BUSY_CH_MASK) << chIndex)); - if(0u == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY_ALL_CH_MASK)) + if (0u == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY_ALL_CH_MASK)) { context->ptrCommonContext->status &= ~CY_CAPSENSE_BUSY; } @@ -2949,7 +2963,7 @@ void Cy_CapSense_ClrBusyFlags( if (NULL != context->ptrInternalContext->ptrEOSCallback) { #if (CY_CAPSENSE_SCAN_MODE_INT_DRIVEN == CY_CAPSENSE_SCAN_MODE) - context->ptrInternalContext->ptrEOSCallback((cy_stc_active_scan_sns_t *)&context->ptrActiveScanSns[0u]); + context->ptrInternalContext->ptrEOSCallback((cy_stc_capsense_active_scan_sns_t *)&context->ptrActiveScanSns[0u]); #else context->ptrInternalContext->ptrEOSCallback(NULL); #endif @@ -2983,12 +2997,12 @@ void Cy_CapSense_ConfigureAnalogMuxResource( uint32_t * ptrSwSelCfg; uint32_t prevSnsMethod = (uint32_t)context->ptrActiveScanSns[chIndex].currentSenseMethod; - if(snsMethod != prevSnsMethod) + if (snsMethod != prevSnsMethod) { ptrSwSelCfg = &context->ptrBaseFrameContext[chIndex].swSelGpio; *ptrSwSelCfg &= ~CY_CAPSENSE_CMOD_AMUX_MSK; - context->ptrCommonConfig->ptrMscChConfig[chIndex].ptrMscBase->SW_SEL_GPIO = *ptrSwSelCfg; + context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase->SW_SEL_GPIO = *ptrSwSelCfg; /* Enable the specified mode */ if (CY_CAPSENSE_CSD_GROUP == snsMethod) @@ -3010,7 +3024,7 @@ void Cy_CapSense_ConfigureAnalogMuxResource( #endif } - context->ptrCommonConfig->ptrMscChConfig[chIndex].ptrMscBase->SW_SEL_GPIO = *ptrSwSelCfg; + context->ptrCommonConfig->ptrChConfig[chIndex].ptrHwBase->SW_SEL_GPIO = *ptrSwSelCfg; } } #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) */ @@ -3033,7 +3047,7 @@ void Cy_CapSense_ConfigureAnalogMuxResource( cy_capsense_status_t Cy_CapSense_InitializeDmaResource( cy_stc_capsense_context_t * context) { - const cy_stc_msc_channel_config_t * ptrCurMscChCfg = context->ptrCommonConfig->ptrMscChConfig; + const cy_stc_capsense_channel_config_t * ptrCurMscChCfg = context->ptrCommonConfig->ptrChConfig; uint32_t curChIndex; uint8_t wrIdx; uint8_t rdIdx; @@ -3048,8 +3062,8 @@ cy_capsense_status_t Cy_CapSense_InitializeDmaResource( dmacBase = context->ptrCommonConfig->ptrDmacBase; for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - ptrCurMscChCfg = &(context->ptrCommonConfig->ptrMscChConfig[curChIndex]); - mscBase = ptrCurMscChCfg->ptrMscBase; + ptrCurMscChCfg = &(context->ptrCommonConfig->ptrChConfig[curChIndex]); + mscBase = ptrCurMscChCfg->ptrHwBase; wrIdx = ptrCurMscChCfg->dmaWrChIndex; wrChIdx = ptrCurMscChCfg->dmaChainWrChIndex; rdIdx = ptrCurMscChCfg->dmaRdChIndex; @@ -3134,7 +3148,7 @@ cy_capsense_status_t Cy_CapSense_InitializeDmaResource( } - return (capStatus); + return capStatus; } #endif /* (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ @@ -3160,7 +3174,7 @@ cy_capsense_status_t Cy_CapSense_ConfigureDmaResource( cy_stc_capsense_context_t * context) { cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; - const cy_stc_msc_channel_config_t * ptrCurMscChCfg = &(context->ptrCommonConfig->ptrMscChConfig[mscChIndex]); + const cy_stc_capsense_channel_config_t * ptrCurMscChCfg = &(context->ptrCommonConfig->ptrChConfig[mscChIndex]); DMAC_Type * dmacBase = context->ptrCommonConfig->ptrDmacBase; uint8_t chainWrChIndex = ptrCurMscChCfg->dmaChainWrChIndex; uint8_t chainRdChIndex = ptrCurMscChCfg->dmaChainRdChIndex; @@ -3172,17 +3186,122 @@ cy_capsense_status_t Cy_CapSense_ConfigureDmaResource( Cy_DMAC_Channel_Disable(dmacBase, chainRdChIndex); /* Configure the destination and data count for the Chain Write channel of DMAC */ - Cy_DMAC_Descriptor_SetSrcAddress(dmacBase, chainWrChIndex, CY_DMAC_DESCRIPTOR_PING, &context->ptrCommonConfig->ptrDmaWrChSnsCfgAddr[currSlotPos + currentSlotIndex]); + Cy_DMAC_Descriptor_SetSrcAddress(dmacBase, chainWrChIndex, CY_DMAC_DESCRIPTOR_PING, &context->ptrCommonConfig->ptrDmaWrChSnsCfgAddrLocal[currSlotPos + currentSlotIndex]); Cy_DMAC_Descriptor_SetDataCount(dmacBase, chainWrChIndex, CY_DMAC_DESCRIPTOR_PING, (endSlotIndex - currentSlotIndex + 1u)); /* Configure the destination and data count for the Chain Read channel of DMAC */ - Cy_DMAC_Descriptor_SetSrcAddress(dmacBase, chainRdChIndex, CY_DMAC_DESCRIPTOR_PING, &context->ptrCommonConfig->ptrDmaRdChSnsCfgAddr[currSlotPos + currentSlotIndex]); - Cy_DMAC_Descriptor_SetDataCount(dmacBase, chainRdChIndex, CY_DMAC_DESCRIPTOR_PING, (endSlotIndex - currentSlotIndex + 1u)); + Cy_DMAC_Descriptor_SetSrcAddress(dmacBase, chainRdChIndex, CY_DMAC_DESCRIPTOR_PING, &context->ptrCommonConfig->ptrDmaRdChSnsCfgAddrLocal[currSlotPos + context->ptrInternalContext->firstValidSlot]); + Cy_DMAC_Descriptor_SetDataCount(dmacBase, chainRdChIndex, CY_DMAC_DESCRIPTOR_PING, context->ptrInternalContext->numValidSlots); /* Enable DMAC channels to perform scanning */ Cy_DMAC_Channel_Enable(dmacBase, chainRdChIndex); - return (capStatus); + return capStatus; +} +#endif /* (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ + + +#if (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) +/******************************************************************************* +* Function Name: Cy_CapSense_InitializeDmaArrays +****************************************************************************//** +* +* Initializes DMA arrays used for scanning. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of operation. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_InitializeDmaArrays( + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + uint32_t slotIndex; + const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; + + for (slotIndex = 0u; slotIndex < (CY_CAPSENSE_SLOT_COUNT * CY_CAPSENSE_TOTAL_CH_NUMBER); slotIndex++) + { + ptrCommonCfg->ptrDmaWrChSnsCfgAddrLocal[slotIndex] = ptrCommonCfg->ptrDmaWrChSnsCfgAddr[slotIndex]; + ptrCommonCfg->ptrDmaRdChSnsCfgAddrLocal[slotIndex] = ptrCommonCfg->ptrDmaRdChSnsCfgAddr[slotIndex]; + } + + context->ptrInternalContext->numValidSlots = CY_CAPSENSE_SLOT_COUNT_MAX_VALUE; + + return capStatus; +} +#endif /* (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ + + +#if (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) +/******************************************************************************* +* Function Name: Cy_CapSense_ConfigureDmaArrays +****************************************************************************//** +* +* Configures DMA arrays used for scanning considering widget enable/disable +* and working/non-working statuses. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of operation. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_ConfigureDmaArrays( + cy_stc_capsense_context_t * context) +{ + uint32_t chIndex; + uint32_t slotOffset; + uint32_t slotIndex; + uint32_t slotStatus; + uint32_t wdIndex; + uint32_t rawPtrIndex = 0u; + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + const cy_stc_capsense_common_config_t * ptrCommonCfg = context->ptrCommonConfig; + cy_stc_capsense_internal_context_t * ptrIntrCxt = context->ptrInternalContext; + uint32_t * ptrSnsFrmCxt = &context->ptrSensorFrameContext[CY_CAPSENSE_SNS_CTL_INDEX]; + + ptrIntrCxt->numValidSlots = CY_CAPSENSE_SLOT_COUNT_MAX_VALUE; + + /* Loops across all slots within one enabled channel */ + for (slotIndex = 0u; slotIndex < CY_CAPSENSE_SLOT_COUNT; slotIndex++) + { + /* Gets status of a slot considering all channels */ + slotStatus = Cy_CapSense_IsSlotEnabled(slotIndex, context); + /* Loops across all configured channels */ + for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) + { + slotOffset = chIndex * (CY_CAPSENSE_SLOT_COUNT * CY_MSC_6_SNS_REGS); + /* Disable sensor */ + ptrSnsFrmCxt[slotOffset] &= (uint32_t)~MSC_SNS_CTL_VALID_Msk; + /* Mark sensors valid and store pointer to rawcount address */ + if (0u != slotStatus) + { + ptrSnsFrmCxt[slotOffset] |= MSC_SNS_CTL_VALID_Msk; + wdIndex = context->ptrScanSlots[(chIndex * CY_CAPSENSE_SLOT_COUNT) + slotIndex].wdId; + if (0u != Cy_CapSense_IsWidgetEnabled(wdIndex, context)) + { + ptrCommonCfg->ptrDmaRdChSnsCfgAddrLocal[(chIndex * CY_CAPSENSE_SLOT_COUNT) + rawPtrIndex] = + ptrCommonCfg->ptrDmaRdChSnsCfgAddr[(chIndex * CY_CAPSENSE_SLOT_COUNT) + slotIndex]; + } + else + { + ptrCommonCfg->ptrDmaRdChSnsCfgAddrLocal[(chIndex * CY_CAPSENSE_SLOT_COUNT) + rawPtrIndex] = + ptrCommonCfg->ptrEmptyRawCount; + } + } + } + if (0u != slotStatus) + { + rawPtrIndex++; + } + ptrSnsFrmCxt = &ptrSnsFrmCxt[CY_MSC_6_SNS_REGS]; + } + + return capStatus; } #endif /* (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ @@ -3216,7 +3335,7 @@ void Cy_CapSense_SetModClkDivider( } dividerValueLocal--; - switch(context->ptrCommonConfig->periDividerType) + switch (context->ptrCommonConfig->periDividerType) { case (uint8_t)CY_SYSCLK_DIV_8_BIT: dividerType = CY_SYSCLK_DIV_8_BIT; @@ -3264,8 +3383,6 @@ void Cy_CapSense_SetModClkDivider( * (8-9 scans) of RefCDAC with disabled CompCDAC * - CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR - The successive approximation * (8-9 scans) of CompCDAC with fixed RefCDAC -* - CY_CAPSENSE_CAL_MODE_COMP_CDAC_MAX_CODE - One scan with maximum -* CompCDAC and fixed RefCDAC * * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. @@ -3293,15 +3410,10 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( uint32_t wdIndex; uint32_t chIndex; uint32_t maxRawTmp; - uint32_t snsClkTmp; uint32_t calMaskNext = CY_CAPSENSE_CAL_MIDDLE_VALUE; uint32_t calMaskPast = 0u; uint32_t calibrationBitEn = 0u; uint32_t sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; - #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - uint32_t dummyScanFlagEn = 1u; - #endif - uint8_t * ptrCdac; uint32_t * ptrRawTarget; uint32_t rawTarget[CY_CAPSENSE_MAX_CH_NUM]; @@ -3314,72 +3426,75 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( uint32_t * ptrSnsFrmCxtArray[CY_CAPSENSE_MAX_CH_NUM]; #endif - /* Checks a slot for auto-calibration */ - for(chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) + if (0u != Cy_CapSense_IsSlotEnabled(scanSlotId, context)) { - wdIndex = context->ptrScanSlots[scanSlotId + (CY_CAPSENSE_SLOT_COUNT * chIndex)].wdId; - if (CY_CAPSENSE_SLOT_SHIELD_ONLY > wdIndex) + /* Checks a slot for auto-calibration */ + for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) { - /* Finds a sensing method for existing slot */ - sensingGroup = context->ptrWdConfig[wdIndex].senseMethod; - /* Checks if the auto-calibration is enabled for the current sense method */ - #if(CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) - if(CY_CAPSENSE_CSX_GROUP == sensingGroup) - { - sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; - } - #else - - #if(CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE) - if((CY_CAPSENSE_CSX_GROUP == sensingGroup) && (CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR == autoCalibrMode)) + wdIndex = context->ptrScanSlots[scanSlotId + (CY_CAPSENSE_SLOT_COUNT * chIndex)].wdId; + if (CY_CAPSENSE_SLOT_SHIELD_ONLY > wdIndex) + { + /* Finds a sensing method for existing slot */ + sensingGroup = context->ptrWdConfig[wdIndex].senseMethod; + /* Checks if the auto-calibration is enabled for the current sense method */ + #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) + if (CY_CAPSENSE_CSX_GROUP == sensingGroup) { sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; } - #endif + #else - #if(CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE) - if((CY_CAPSENSE_CSX_GROUP == sensingGroup) && (CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR == autoCalibrMode)) - { - sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; - } - #endif - #endif - - #if(CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) - if(CY_CAPSENSE_CSD_GROUP == sensingGroup) - { - sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; - } - #else + #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE) + if ((CY_CAPSENSE_CSX_GROUP == sensingGroup) && (CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR == autoCalibrMode)) + { + sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; + } + #endif - #if(CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE) - if((CY_CAPSENSE_CSD_GROUP == sensingGroup) && (CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR == autoCalibrMode)) - { - sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; - } + #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSX_CDAC_COMP_USAGE) + if ((CY_CAPSENSE_CSX_GROUP == sensingGroup) && (CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR == autoCalibrMode)) + { + sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; + } + #endif #endif - #if(CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) - if((CY_CAPSENSE_CSD_GROUP == sensingGroup) && (CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR == autoCalibrMode)) + #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) + if (CY_CAPSENSE_CSD_GROUP == sensingGroup) { sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; } + #else + + #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE) + if ((CY_CAPSENSE_CSD_GROUP == sensingGroup) && (CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR == autoCalibrMode)) + { + sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; + } + #endif + + #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) + if ((CY_CAPSENSE_CSD_GROUP == sensingGroup) && (CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR == autoCalibrMode)) + { + sensingGroup = CY_CAPSENSE_UNDEFINED_GROUP; + } + #endif #endif - #endif - /* Different sensing methods not allowed in a single slot */ - break; + /* Different sensing methods not allowed in a single slot */ + break; + } } } /* Skips non-auto-calibrated slots */ if (CY_CAPSENSE_UNDEFINED_GROUP != sensingGroup) { - for(chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) + for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) { /* Populates all sensors in widget */ wdIndex = context->ptrScanSlots[scanSlotId + (CY_CAPSENSE_SLOT_COUNT * chIndex)].wdId; - if(CY_CAPSENSE_SLOT_SHIELD_ONLY > wdIndex) + if (CY_CAPSENSE_SLOT_SHIELD_ONLY > wdIndex) { calibrationBitEn |= (uint32_t)(0x01uL << chIndex); @@ -3389,30 +3504,28 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( /* Gets target in percentage */ target = context->ptrInternalContext->intrCsdRawTarget; - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - if(CY_CAPSENSE_CSX_GROUP == sensingGroup) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) + if (CY_CAPSENSE_CSX_GROUP == sensingGroup) { target = context->ptrInternalContext->intrCsxRawTarget; } #endif - snsClkTmp = context->ptrWdContext[wdIndex].snsClk; - - #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + maxRawTmp = context->ptrWdContext[wdIndex].maxRawCount; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) if ((CY_CAPSENSE_CSD_GROUP == sensingGroup) && (ptrWdCfg->numCols <= snsIndex)) { - snsClkTmp = context->ptrWdContext[wdIndex].rowSnsClk; + maxRawTmp = context->ptrWdContext[wdIndex].maxRawCountRow; } #endif - maxRawTmp = Cy_CapSense_GetMaxRaw(snsClkTmp, ptrWdCfg, context); rawTarget[chIndex] = (uint16_t)((maxRawTmp * target) / CY_CAPSENSE_PERCENTAGE_100); ptrSnsCxtArray[chIndex] = &ptrWdCfg->ptrSnsContext[snsIndex]; ptrSnsCxtArray[chIndex]->cdacComp = 0u; #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) - ptrSnsFrmCxtArray[chIndex] = &context->ptrSensorFrameContext[CY_MSC_6_SNS_REGS * - (context->ptrCommonConfig->numSlots * chIndex + scanSlotId) + CY_CAPSENSE_SNS_CDAC_CTL_INDEX]; + ptrSnsFrmCxtArray[chIndex] = &context->ptrSensorFrameContext[(CY_MSC_6_SNS_REGS * + ((context->ptrCommonConfig->numSlots * chIndex) + scanSlotId)) + CY_CAPSENSE_SNS_CDAC_CTL_INDEX]; #endif } } @@ -3421,9 +3534,9 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( do { ptrRawTarget = &rawTarget[0u]; - for(chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) + for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) { - if(0u != (calibrationBitEn & (0x01uL << chIndex))) + if (0u != (calibrationBitEn & (0x01uL << chIndex))) { ptrSnsCxt = ptrSnsCxtArray[chIndex]; @@ -3432,7 +3545,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( #endif /* Update CDACs based on scan result */ ptrCdac = &ptrSnsCxt->cdacComp; - if(CY_CAPSENSE_CSD_GROUP == sensingGroup) + if (CY_CAPSENSE_CSD_GROUP == sensingGroup) { if ((uint32_t)ptrSnsCxt->raw < *ptrRawTarget) { @@ -3447,7 +3560,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( } } *ptrCdac |= (uint8_t)calMaskNext; - if(0u == *ptrCdac) + if (0u == *ptrCdac) { (*ptrCdac)++; } @@ -3456,12 +3569,12 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( if (CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR == autoCalibrMode) { *ptrSnsFrmCxt &= (uint32_t)~(MSC_SNS_CDAC_CTL_SEL_RE_Msk | MSC_SNS_CDAC_CTL_SEL_CO_Msk); - *ptrSnsFrmCxt |= (uint32_t)(*ptrCdac << MSC_SNS_CDAC_CTL_SEL_RE_Pos); + *ptrSnsFrmCxt |= (((uint32_t)(*ptrCdac)) << MSC_SNS_CDAC_CTL_SEL_RE_Pos); } else { *ptrSnsFrmCxt &= (uint32_t)~MSC_SNS_CDAC_CTL_SEL_CO_Msk; - *ptrSnsFrmCxt |= (uint32_t)(*ptrCdac << MSC_SNS_CDAC_CTL_SEL_CO_Pos); + *ptrSnsFrmCxt |= (((uint32_t)(*ptrCdac)) << MSC_SNS_CDAC_CTL_SEL_CO_Pos); } #else (void)autoCalibrMode; @@ -3473,11 +3586,10 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( /* CTRL_MUX + CSX */ #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) /* Dummy scan */ - if ((0u != dummyScanFlagEn) && (CY_CAPSENSE_CSX_GROUP == sensingGroup)) + if (CY_CAPSENSE_CSX_GROUP == sensingGroup) { calibStatus |= Cy_CapSense_ScanSlots(scanSlotId, 1u, context); calibStatus |= Cy_CapSense_WaitEndScan(CY_CAPSENSE_CALIBRATION_TIMEOUT, context); - dummyScanFlagEn = 0u; } #endif @@ -3485,10 +3597,10 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( calibStatus |= Cy_CapSense_ScanSlots(scanSlotId, 1u, context); calibStatus |= Cy_CapSense_WaitEndScan(CY_CAPSENSE_CALIBRATION_TIMEOUT, context); - for(chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) + for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) { wdIndex = context->ptrScanSlots[scanSlotId + (CY_CAPSENSE_SLOT_COUNT * chIndex)].wdId; - if(CY_CAPSENSE_SLOT_SHIELD_ONLY > wdIndex) + if (CY_CAPSENSE_SLOT_SHIELD_ONLY > wdIndex) { snsIndex = context->ptrScanSlots[scanSlotId + (CY_CAPSENSE_SLOT_COUNT * chIndex)].snsId; Cy_CapSense_PreProcessSensor(wdIndex, snsIndex, context); @@ -3503,7 +3615,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateSlot( while (calMaskPast != 0u); } - return (calibStatus); + return calibStatus; } #endif @@ -3554,18 +3666,18 @@ cy_capsense_status_t Cy_CapSense_NormalizeCdac( #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) { - for(i = 0u; i < ptrWdCfg->numCols; i++) + for (i = 0u; i < ptrWdCfg->numCols; i++) { - if(ptrSnsCxt->cdacComp > maxRefCdac) + if (ptrSnsCxt->cdacComp > maxRefCdac) { maxRefCdac = ptrSnsCxt->cdacComp; } ptrSnsCxt->cdacComp = 0u; ptrSnsCxt++; } - for(i = ptrWdCfg->numCols; i < ptrWdCfg->numSns; i++) + for (i = ptrWdCfg->numCols; i < ptrWdCfg->numSns; i++) { - if(ptrSnsCxt->cdacComp > maxRowRefCdac) + if (ptrSnsCxt->cdacComp > maxRowRefCdac) { maxRowRefCdac = ptrSnsCxt->cdacComp; } @@ -3599,9 +3711,9 @@ cy_capsense_status_t Cy_CapSense_NormalizeCdac( if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) { /* CSX Widget */ - for(i = 0u; i < ptrWdCfg->numSns; i++) + for (i = 0u; i < ptrWdCfg->numSns; i++) { - if(ptrSnsCxt->cdacComp > maxRefCdac) + if (ptrSnsCxt->cdacComp > maxRefCdac) { maxRefCdac = ptrSnsCxt->cdacComp; } @@ -3618,7 +3730,7 @@ cy_capsense_status_t Cy_CapSense_NormalizeCdac( #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) ptrSnsFrmCxt = &context->ptrSensorFrameContext[CY_CAPSENSE_SNS_CDAC_CTL_INDEX]; - for (i = 0u; i < CY_CAPSENSE_SLOT_COUNT * CY_CAPSENSE_TOTAL_CH_NUMBER; i++) + for (i = 0u; i < (CY_CAPSENSE_SLOT_COUNT * CY_CAPSENSE_TOTAL_CH_NUMBER); i++) { if (widgetId == context->ptrScanSlots[i].wdId) { @@ -3635,7 +3747,7 @@ cy_capsense_status_t Cy_CapSense_NormalizeCdac( } #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) */ - return (CY_CAPSENSE_STATUS_SUCCESS); + return CY_CAPSENSE_STATUS_SUCCESS; } #endif @@ -3688,10 +3800,6 @@ cy_capsense_status_t Cy_CapSense_CalibrateCompDivider( uint32_t rawTemp; uint32_t target; uint32_t j; - #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - uint32_t dummyScanFlagEn = 1u; - #endif - const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; uint32_t compDivDefault = ptrWdCfg->ptrWdContext->snsClk; @@ -3705,7 +3813,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateCompDivider( #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) */ /* Defines initial value for Compensation Divider including rows and cols */ - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || @@ -3727,7 +3835,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateCompDivider( #endif target = context->ptrInternalContext->intrCsdRawTarget; - if(CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) + if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) { target = context->ptrInternalContext->intrCsxRawTarget; } @@ -3778,11 +3886,10 @@ cy_capsense_status_t Cy_CapSense_CalibrateCompDivider( /* CTRL_MUX + CSX */ #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) /* Dummy scan */ - if ((0u != dummyScanFlagEn) && (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod)) + if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) { calibStatus |= Cy_CapSense_ScanSlots(curSlotIndex, 1u, context); calibStatus |= Cy_CapSense_WaitEndScan(CY_CAPSENSE_CALIBRATION_TIMEOUT, context); - dummyScanFlagEn = 0u; } #endif calibStatus |= Cy_CapSense_ScanSlots(curSlotIndex, 1u, context); @@ -3799,7 +3906,7 @@ cy_capsense_status_t Cy_CapSense_CalibrateCompDivider( rawTemp = ptrWdCfg->ptrSnsContext[snsIndex].raw; - if(CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) { if (rawTemp > target) { @@ -3830,9 +3937,10 @@ cy_capsense_status_t Cy_CapSense_CalibrateCompDivider( { break; } - } while ((compDivDefault > 1u) && (CY_CAPSENSE_STATUS_SUCCESS == calibStatus)); + } while ((compDivDefault > CY_CAPSENSE_CDAC_COMP_DIV_MIN_MSCV3) && + (CY_CAPSENSE_STATUS_SUCCESS == calibStatus)); - return (calibStatus); + return calibStatus; } #endif @@ -3876,13 +3984,11 @@ cy_capsense_status_t Cy_CapSense_VerifyCalibration( /* CTRL_MUX + CSX */ #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) && (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) - uint32_t dummyScanFlagEn = 1u; /* Dummy scan */ - if ((0u != dummyScanFlagEn) && (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod)) + if (CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) { calibStatus |= Cy_CapSense_ScanSlots(ptrWdCfg->firstSlotId, 1u, context); calibStatus |= Cy_CapSense_WaitEndScan(CY_CAPSENSE_CALIBRATION_TIMEOUT, context); - dummyScanFlagEn = 0u; } #endif @@ -3912,13 +4018,13 @@ cy_capsense_status_t Cy_CapSense_VerifyCalibration( } /* Finds max raw count value */ - temp = Cy_CapSense_GetMaxRaw(context->ptrWdContext[widgetId].snsClk, ptrWdCfg, context); + temp = context->ptrWdContext[widgetId].maxRawCount; /* Checks raw count of each sensor */ ptrSnsCxt = &ptrWdCfg->ptrSnsContext[0u]; if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) { - for(snsIndex = 0u; snsIndex < ptrWdCfg->numCols; snsIndex++) + for (snsIndex = 0u; snsIndex < ptrWdCfg->numCols; snsIndex++) { if ((ptrSnsCxt->raw < ((temp * lowerLimit) / CY_CAPSENSE_PERCENTAGE_100)) || (ptrSnsCxt->raw > ((temp * upperLimit) / CY_CAPSENSE_PERCENTAGE_100))) @@ -3928,9 +4034,9 @@ cy_capsense_status_t Cy_CapSense_VerifyCalibration( } ptrSnsCxt++; } - temp = Cy_CapSense_GetMaxRaw(context->ptrWdContext[widgetId].rowSnsClk, ptrWdCfg, context); + temp = context->ptrWdContext[widgetId].maxRawCountRow; - for(snsIndex = ptrWdCfg->numCols; snsIndex < ptrWdCfg->numSns; snsIndex++) + for (snsIndex = ptrWdCfg->numCols; snsIndex < ptrWdCfg->numSns; snsIndex++) { if ((ptrSnsCxt->raw < ((temp * lowerLimit) / CY_CAPSENSE_PERCENTAGE_100)) || (ptrSnsCxt->raw > ((temp * upperLimit) / CY_CAPSENSE_PERCENTAGE_100))) @@ -3943,7 +4049,7 @@ cy_capsense_status_t Cy_CapSense_VerifyCalibration( } else { - for(snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) { if ((ptrSnsCxt->raw < ((temp * lowerLimit) / CY_CAPSENSE_PERCENTAGE_100)) || (ptrSnsCxt->raw > ((temp * upperLimit) / CY_CAPSENSE_PERCENTAGE_100))) @@ -3956,7 +4062,7 @@ cy_capsense_status_t Cy_CapSense_VerifyCalibration( } } - return (calibStatus); + return calibStatus; } #endif @@ -3989,7 +4095,7 @@ void Cy_CapSense_SetCompDivider( const cy_stc_capsense_scan_slot_t * ptrScanSlots = context->ptrScanSlots; uint32_t compensationCdacDivider = context->ptrWdContext[widgetId].cdacCompDivider; - if (0 != compensationCdacDivider) + if (0u != compensationCdacDivider) { compensationCdacDivider--; } @@ -4094,7 +4200,7 @@ cy_capsense_status_t Cy_CapSense_WaitEndScan( watchdogCounter = Cy_CapSense_WatchdogCyclesNum(timeout, cpuFreqMHz, isBusyLoopDuration); while (CY_CAPSENSE_NOT_BUSY != Cy_CapSense_IsBusy(context)) { - if(0uL == watchdogCounter) + if (0uL == watchdogCounter) { status = CY_CAPSENSE_STATUS_TIMEOUT; break; @@ -4103,63 +4209,42 @@ cy_capsense_status_t Cy_CapSense_WaitEndScan( } } - return (status); + return status; } #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) /******************************************************************************* -* Function Name: Cy_CapSense_SlotPinState +* Function Name: Cy_CapSense_SlotPinState_V3 ****************************************************************************//** * -* Configures the desired electrode to the specified state by -* updating the CAPSENSE™ configuration. -* -* This function changes / overwrites configuration of an electrode (several -* pins in case the electrode is ganged to more pins) with a state provided -* by pinState parameter. The function does this only for the mentioned slot ID. -* If a pin should have the desired state during several scans, the function -* should be called multiple times for the each desired slot. -* -* The re-configuration is possible when -* parameter Sensor connection method = CTRLMUX. -* If parameter Sensor connection method = AMUXBUS, then the function -* returns CY_CAPSENSE_STATUS_BAD_CONFIG. In next releases -* the Cy_CapSense_SetPinState() function will be provided for the AMUXBUS -* configuration. -* -* The function changes the configuration of an electrode without storing -* the default state. A user is responsible to keep the default state to -* revert to the default settings if needed. Also, the default settings -* can be configured again by calling Cy_CapSense_Enable() function that -* leads to repeating CAPSENSE™ Data Structure initialization, repeating -* DAC auto-calibration and repeating base-lining. -* -* Using this function is not recommended. This function is used to -* implement only the user's specific use cases (as changing the CAPSENSE™ -* default configuration). -* -* Call this function from CAPSENSE™ Data Structure Initialization Callback -* ptrEODsInitCallback. For details of how to register callback see -* the \ref group_capsense_callbacks section. That avoids repeating of -* DAC auto-calibration and base-lining since the callback is called after -* CAPSENSE™ Data Structure initialization but before the first initialization -* scan. -* -* The function is a low-level function and does not perform verification of -* input parameters (like slot ID, pointers, etc.). For example, -* CY_CAPSENSE_CTRLMUX_PIN_STATE_SHIELD is not available if shield is not configured -* in the project. +* The internal function that configures the specified electrode to the desired state +* in the specified Active slot by updating the CAPSENSE™ configuration. +* +* See the Cy_CapSense_SlotPinState() description for details. +* +* \note +* This function is available for the fifth-generation (only +* for CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) and the fifth-generation +* low power CAPSENSE™. For the fourth-generation CAPSENSE™ and +* the fifth-generation CAPSENSE™ with +* CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD use Cy_CapSense_SetPinState(). +* For Low Power slots for the fifth-generation low power CAPSENSE™ +* use Cy_CapSense_LpSlotPinState(). * * \param slotId -* The desired slot ID. +* The slot ID to change the pin state for (Active slot ID for +* the fifth-generation low power CAPSENSE™). * * \param ptrEltdCfg * The pointer to an electrode the all pins states of which will be configured * as pinState parameter. * * \param pinState -* The desired pins state for CSX widget electrodes: +* The parameter have different values for the fifth- and the fifth-generation +* low power CAPSENSE™. +* +* The desired pins state for CSX widget electrodes can be: * * CY_CAPSENSE_CTRLMUX_PIN_STATE_RX - Rx electrode. * * CY_CAPSENSE_CTRLMUX_PIN_STATE_TX - Tx electrode. * * CY_CAPSENSE_CTRLMUX_PIN_STATE_GND - Grounded. @@ -4167,7 +4252,8 @@ cy_capsense_status_t Cy_CapSense_WaitEndScan( * (for multi-phase TX method). * * CY_CAPSENSE_CTRLMUX_PIN_STATE_HIGH_Z - Unconnected (high-z). * * CY_CAPSENSE_CTRLMUX_PIN_STATE_VDDA2 - Connected to VDDA/2. -* The desired pins state for CSD widget electrodes: +* +* The desired pins state for CSD widget electrodes can be: * * CY_CAPSENSE_CTRLMUX_PIN_STATE_SNS - Self-cap sensor. * * CY_CAPSENSE_CTRLMUX_PIN_STATE_HIGH_Z - Unconnected (high-z). * * CY_CAPSENSE_CTRLMUX_PIN_STATE_GND - Grounded. @@ -4183,34 +4269,44 @@ cy_capsense_status_t Cy_CapSense_WaitEndScan( * called with the current CAPSENSE™ * configuration. * +* \funcusage +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_SlotPinState +* *******************************************************************************/ -cy_capsense_status_t Cy_CapSense_SlotPinState( +cy_capsense_status_t Cy_CapSense_SlotPinState_V3( uint32_t slotId, const cy_stc_capsense_electrode_config_t * ptrEltdCfg, uint32_t pinState, cy_stc_capsense_context_t * context) { uint32_t i; - uint32_t mask = 0u; - uint32_t * ptrSnsFrm = &context->ptrSensorFrameContext[(((uint32_t)ptrEltdCfg->chId * - CY_CAPSENSE_SLOT_COUNT) + slotId) * CY_MSC_6_SNS_REGS]; - cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_SUCCESS; + uint32_t mask; + uint32_t * ptrSnsFrm; + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_CONFIG; + + mask = 0u; + ptrSnsFrm = &context->ptrSensorFrameContext[(((uint32_t)ptrEltdCfg->chId * CY_CAPSENSE_SLOT_COUNT) + slotId) * + CY_MSC_6_SNS_REGS]; + capStatus = CY_CAPSENSE_STATUS_SUCCESS; for (i = 0u; i < ptrEltdCfg->numPins; i++) { - mask |= 0x01uL << ptrEltdCfg->ptrPin->padNumber; + mask |= 0x01uL << ptrEltdCfg->ptrPin[i].padNumber; } for (i = 0u; i < CY_CAPSENSE_CTRLMUX_PIN_STATE_MASK_NUMBER; i++) { ptrSnsFrm[i] &= ~mask; - if (0u != (pinState & (1u << (CY_CAPSENSE_CTRLMUX_PIN_STATE_MASK_NUMBER - 1u - i)))) + if (0u != (pinState & (1uL << (CY_CAPSENSE_CTRLMUX_PIN_STATE_MASK_NUMBER - 1u - i)))) { ptrSnsFrm[i] |= mask; } } - return (capStatus); + /* Set undefined value to initiate frame re-configuration in Cy_CapSense_ScanSlots() function */ + context->ptrInternalContext->currentSlotIndex = CY_CAPSENSE_SLOT_COUNT_MAX_VALUE; + + return capStatus; } #endif @@ -4257,12 +4353,24 @@ cy_capsense_status_t Cy_CapSense_SwitchHwConfiguration( case CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT: break; case CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING: + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) + if (CY_CAPSENSE_SCAN_SNGL_SLOT == context->ptrInternalContext->scanSingleSlot) + { + for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) + { + /* Disconnect the scanned sensor */ + Cy_CapSense_DisconnectSensor(curChIndex, context); + } + } + #endif break; #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) case CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY: Cy_CapSense_BistDisableMode(context); break; #endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_HW_GROUP_EN) */ + case CY_CAPSENSE_HW_CONFIG_CHANNEL_SATURATION: + break; default: capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; break; @@ -4277,7 +4385,7 @@ cy_capsense_status_t Cy_CapSense_SwitchHwConfiguration( case CY_CAPSENSE_HW_CONFIG_CAPTURED_DEFAULT: break; case CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING: - Cy_CapSense_SetModClkDivider(context->ptrCommonContext->modClk, context); + Cy_CapSense_SetModClkDivider(context->ptrInternalContext->modClk, context); Cy_CapSense_SetIOsInDefaultState(context); #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) Cy_CapSense_SetShieldPinsInDefaultState(context); @@ -4300,10 +4408,10 @@ cy_capsense_status_t Cy_CapSense_SwitchHwConfiguration( #endif /* MSCv3 IP Block Base Register Configuration */ - mscStatus = Cy_MSC_Configure(ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase, + mscStatus = Cy_MSC_Configure(ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase, &context->ptrBaseFrameContext[curChIndex], CY_MSC_CAPSENSE_KEY, - ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscContext); + ptrCommonCfg->ptrChConfig[curChIndex].ptrHwContext); if (CY_MSC_SUCCESS != mscStatus) { capStatus = CY_CAPSENSE_STATUS_HW_BUSY; @@ -4311,22 +4419,32 @@ cy_capsense_status_t Cy_CapSense_SwitchHwConfiguration( } /* Clear all pending interrupts of the MSC HW block */ - ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; - (void)ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase->INTR; + ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; + (void)ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase->INTR; } + /* The time interval is required for settling analog part of the HW block. */ + Cy_SysLib_DelayUs(CY_CAPSENSE_ANALOG_SETTLING_TIME_US); break; case CY_CAPSENSE_HW_CONFIG_BIST_FUNCTIONALITY: Cy_CapSense_SetIOsInDefaultState(context); - Cy_CapSense_SetShieldPinsInDefaultState(context); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_SHIELD_EN) + Cy_CapSense_SetShieldPinsInDefaultState(context); + #endif for (curChIndex = 0u; curChIndex < context->ptrCommonConfig->numChannels; curChIndex++) { context->ptrActiveScanSns[curChIndex].currentSenseMethod = CY_CAPSENSE_UNDEFINED_GROUP; Cy_CapSense_SetCmodInDefaultState(curChIndex, context); /* Clear all pending interrupts of the MSC HW block */ - ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; - (void)ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase->INTR; + ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; + (void)ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase->INTR; } + /* The time interval is required for settling analog part of the HW block. */ + Cy_SysLib_DelayUs(CY_CAPSENSE_ANALOG_SETTLING_TIME_US); + break; + case CY_CAPSENSE_HW_CONFIG_CHANNEL_SATURATION: + Cy_CapSense_ConfigureSaturationMode(context); break; default: capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; @@ -4339,7 +4457,7 @@ cy_capsense_status_t Cy_CapSense_SwitchHwConfiguration( } } - return (capStatus); + return capStatus; } @@ -4379,10 +4497,10 @@ cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk(const cy_stc_capsense_ ptrWdCxt = ptrWdCfg->ptrWdContext; snsClkSrc = ptrWdCxt->snsClkSource; - if((0u != (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_SSC_AUTO_MASK)) || + if ((0u != (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_SSC_AUTO_MASK)) || (CY_CAPSENSE_CLK_SOURCE_SSC == (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_MASK))) { - if(0u != (ptrWdCxt->lfsrBits & CY_CAPSENSE_LFSR_BITS_AUTO_MASK)) + if (0u != (ptrWdCxt->lfsrBits & CY_CAPSENSE_LFSR_BITS_AUTO_MASK)) { /* * Execute the LFSR range auto-selection functionality when the @@ -4393,7 +4511,7 @@ cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk(const cy_stc_capsense_ ptrWdCxt->lfsrBits = (uint8_t)Cy_CapSense_GetLfsrBitsAuto(ptrWdCfg, context); } - if(0u != (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_SSC_AUTO_MASK)) + if (0u != (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_SSC_AUTO_MASK)) { /* * Execute SSC auto-selection functionality when the @@ -4404,7 +4522,7 @@ cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk(const cy_stc_capsense_ ptrWdCxt->snsClkSource = (uint8_t)Cy_CapSense_GetClkSrcSSCAuto(ptrWdCfg, context); } } - else if(0u != (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_PRS_AUTO_MASK)) + else if (0u != (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_PRS_AUTO_MASK)) { /* * Execute PRS auto-selection functionality when the @@ -4425,7 +4543,7 @@ cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk(const cy_stc_capsense_ } /* Determine the MIN valid Sense Clock divider for the used sensing method. */ - if(CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) { snsClkDivMin = CY_CAPSENSE_4PH_DIRECT_SNS_CLOCK_DIVIDER_MIN; } @@ -4439,27 +4557,27 @@ cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk(const cy_stc_capsense_ * range if the Sense Clock source parameter is configured with the SSC * option. */ - if(CY_CAPSENSE_CLK_SOURCE_SSC == (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_MASK)) + if (CY_CAPSENSE_CLK_SOURCE_SSC == (snsClkSrc & CY_CAPSENSE_CLK_SOURCE_MASK)) { lfsrRange = ptrWdCxt->lfsrBits; lfsrRange &= (uint32_t)(~((uint32_t)CY_CAPSENSE_LFSR_BITS_AUTO_MASK)); - snsClkDivMin += Cy_CapSense_GetLfsrDitherVal(lfsrRange, context->ptrCommonContext->lfsrScale); + snsClkDivMin += Cy_CapSense_GetLfsrDitherVal(lfsrRange, context->ptrInternalContext->lfsrScale); } /* Perform validation if the Sense Clock divider is within the valid range. */ - if((ptrWdCxt->snsClk < snsClkDivMin) || + if ((ptrWdCxt->snsClk < snsClkDivMin) || (ptrWdCxt->snsClk > CY_CAPSENSE_DIRECT_SNS_CLOCK_DIVIDER_MAX)) { retVal = CY_CAPSENSE_STATUS_BAD_CLOCK_CONFIG; } - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) - if((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdCfg->wdType) || ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdCfg->wdType))) { - if((ptrWdCxt->rowSnsClk < snsClkDivMin) || + if ((ptrWdCxt->rowSnsClk < snsClkDivMin) || (ptrWdCxt->rowSnsClk > CY_CAPSENSE_DIRECT_SNS_CLOCK_DIVIDER_MAX)) { @@ -4480,7 +4598,7 @@ cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk(const cy_stc_capsense_ ptrWdCfg++; } - if(CY_CAPSENSE_STATUS_SUCCESS == retVal) + if (CY_CAPSENSE_STATUS_SUCCESS == retVal) { /* Set pro wait and epi cycle number to max in case of PRS is configured at least for one widget */ if (0u != prsConfigured) @@ -4491,11 +4609,11 @@ cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk(const cy_stc_capsense_ else { context->ptrInternalContext->numEpiCycles = context->ptrCommonConfig->numEpiCycles; - context->ptrInternalContext->numFineInitWaitCycles = context->ptrCommonContext->numFineInitWaitCycles; + context->ptrInternalContext->numFineInitWaitCycles = CY_CAPSENSE_NUM_FINE_INIT_CYCLES; } } - return (retVal); + return retVal; } @@ -4530,12 +4648,12 @@ uint32_t Cy_CapSense_GetLfsrBitsAuto( ptrWdCxt = ptrWdConfig->ptrWdContext; snsClkDividerTmp = ptrWdCxt->snsClk; - lfsrScale = context->ptrCommonContext->lfsrScale; + lfsrScale = context->ptrInternalContext->lfsrScale; ditherLimitPercents = ptrWdConfig->lfsrDitherLimit; - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) - if((CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) && + if ((CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) && (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdConfig->wdType) || ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdConfig->wdType))) { @@ -4544,7 +4662,7 @@ uint32_t Cy_CapSense_GetLfsrBitsAuto( * The LFSR range should be determined, basing on the MIN Sense Clock * divider in order to be sufficient for rows and columns. */ - if(snsClkDividerTmp > ptrWdCxt->rowSnsClk) + if (snsClkDividerTmp > ptrWdCxt->rowSnsClk) { snsClkDividerTmp = ptrWdCxt->rowSnsClk; } @@ -4552,7 +4670,7 @@ uint32_t Cy_CapSense_GetLfsrBitsAuto( #endif /* Determine the MIN valid Sense Clock divider for the used sensing method. */ - if(CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) + if (CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) { snsClkDividerMin = CY_CAPSENSE_4PH_DIRECT_SNS_CLOCK_DIVIDER_MIN; } @@ -4610,7 +4728,7 @@ uint32_t Cy_CapSense_GetClkSrcSSCAuto( uint32_t snsClkDivMin; uint32_t subConvNumber; const cy_stc_capsense_widget_context_t * ptrWdCxt; - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) uint32_t snsClkSrcRow; #endif @@ -4622,13 +4740,13 @@ uint32_t Cy_CapSense_GetClkSrcSSCAuto( * Measurement conversions). */ subConvNumber = ptrWdCxt->numSubConversions; - subConvNumber += context->ptrCommonContext->numFineInitCycles; + subConvNumber += context->ptrInternalContext->numFineInitCycles; if (CY_CAPSENSE_16_BIT_MASK < subConvNumber) { subConvNumber = CY_CAPSENSE_16_BIT_MASK; } lfsrRange = ((uint32_t)ptrWdCxt->lfsrBits & (uint32_t)(~((uint32_t)CY_CAPSENSE_LFSR_BITS_AUTO_MASK))); - lfsrScale = context->ptrCommonContext->lfsrScale; + lfsrScale = context->ptrInternalContext->lfsrScale; autoSelMode = ptrWdConfig->snsClkSourceAutoSelMode; ditherLimitPercents = ptrWdConfig->lfsrDitherLimit; @@ -4636,7 +4754,7 @@ uint32_t Cy_CapSense_GetClkSrcSSCAuto( * Determine the polynomial duration in clock cycles, e.g. the duration of 8-bit * polynomial is 255 clock cycles. */ - lfsrPolySize = Cy_CapSense_GetPolySize(context->ptrCommonContext->lfsrPoly); + lfsrPolySize = Cy_CapSense_GetPolySize(context->ptrInternalContext->lfsrPoly); /* * Determine the clock dithering variation for the specifies LFSR range, @@ -4645,7 +4763,7 @@ uint32_t Cy_CapSense_GetClkSrcSSCAuto( lfsrDitherCycles = Cy_CapSense_GetLfsrDitherVal(lfsrRange, lfsrScale); /* Determine the MIN valid Sense Clock divider for the used sensing method. */ - if(CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) + if (CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) { snsClkDivMin = CY_CAPSENSE_4PH_DIRECT_SNS_CLOCK_DIVIDER_MIN; } @@ -4670,23 +4788,23 @@ uint32_t Cy_CapSense_GetClkSrcSSCAuto( snsClkSrc = Cy_CapSense_RunSSCAuto(autoSelMode, lfsrDitherCycles, ditherLimitCycles, lfsrPolySize, subConvNumber); - #if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ + #if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_TOUCHPAD_EN)) /* Repeat the SSC-Auto selection routine for the row of two-dimension CSD * widget. */ - if((CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) && + if ((CY_CAPSENSE_CSD_GROUP == ptrWdConfig->senseMethod) && (((uint8_t)CY_CAPSENSE_WD_MATRIX_BUTTON_E == ptrWdConfig->wdType) || ((uint8_t)CY_CAPSENSE_WD_TOUCHPAD_E == ptrWdConfig->wdType))) { - if((uint8_t)CY_CAPSENSE_CLK_SOURCE_DIRECT != snsClkSrc) + if ((uint8_t)CY_CAPSENSE_CLK_SOURCE_DIRECT != snsClkSrc) { ditherLimitCycles = Cy_CapSense_GetLfsrDitherLimit(ptrWdCxt->rowSnsClk, snsClkDivMin, ditherLimitPercents, lfsrScale); snsClkSrcRow = Cy_CapSense_RunSSCAuto(autoSelMode, lfsrDitherCycles, ditherLimitCycles, lfsrPolySize, (uint16_t)subConvNumber); - if(snsClkSrc != snsClkSrcRow) + if (snsClkSrc != snsClkSrcRow) { /* * If the automatically determined Sense Clock sources for @@ -4752,7 +4870,7 @@ uint32_t Cy_CapSense_RunSSCAuto( uint32_t snsClkSrc = CY_CAPSENSE_CLK_SOURCE_SSC; /* Check if the Sense Clock variation is lower than MAX allowed. */ - if(lfsrDitherCycles > ditherLimitCycles) + if (lfsrDitherCycles > ditherLimitCycles) { snsClkSrc = CY_CAPSENSE_CLK_SOURCE_DIRECT; } @@ -4762,9 +4880,9 @@ uint32_t Cy_CapSense_RunSSCAuto( * during the scan. This part of code is executed if the Clock Source * auto selection mode is set to Medium or Strong. */ - if(autoSelMode != CY_CAPSENSE_SNS_CLK_SOURCE_AUTO_SEL_MODE_WEAK) + if (autoSelMode != CY_CAPSENSE_SNS_CLK_SOURCE_AUTO_SEL_MODE_WEAK) { - if(subConvNumber < lfsrPolySize) + if (subConvNumber < lfsrPolySize) { snsClkSrc = CY_CAPSENSE_CLK_SOURCE_DIRECT; } @@ -4775,15 +4893,15 @@ uint32_t Cy_CapSense_RunSSCAuto( * during the scan. This part of code is executed if the Clock Source * auto selection mode is set to Strong. */ - if(autoSelMode == CY_CAPSENSE_SNS_CLK_SOURCE_AUTO_SEL_MODE_STRONG) + if (autoSelMode == CY_CAPSENSE_SNS_CLK_SOURCE_AUTO_SEL_MODE_STRONG) { - if(0u != (subConvNumber % lfsrPolySize)) + if (0u != (subConvNumber % lfsrPolySize)) { snsClkSrc = CY_CAPSENSE_CLK_SOURCE_DIRECT; } } - return (snsClkSrc); + return snsClkSrc; } @@ -4824,13 +4942,13 @@ uint32_t Cy_CapSense_GetClkSrcPRSAuto( * Measurement conversions). */ subConvNumber = ptrWdContext->numSubConversions; - subConvNumber += context->ptrCommonContext->numFineInitCycles; + subConvNumber += context->ptrInternalContext->numFineInitCycles; /* * Determine the polynomial duration in clock cycles, e.g. the duration of 8-bit * polynomial is 255 clock cycles. */ - lfsrPolySize = Cy_CapSense_GetPolySize(context->ptrCommonContext->lfsrPoly); + lfsrPolySize = Cy_CapSense_GetPolySize(context->ptrInternalContext->lfsrPoly); /* * The number of rising edges per one PRS period is (polyLength + 1) / 4. @@ -4842,7 +4960,7 @@ uint32_t Cy_CapSense_GetClkSrcPRSAuto( * Check if at least one whole polynomial period will be performed * during the scan. */ - if(subConvNumber < risingEdgesNum) + if (subConvNumber < risingEdgesNum) { snsClkSrc = CY_CAPSENSE_CLK_SOURCE_DIRECT; } @@ -4872,13 +4990,13 @@ uint32_t Cy_CapSense_GetPolySize(uint32_t lfsrPoly) uint32_t polySize = 0xFFFFu; uint32_t polyMsbMask = 0x8000u; - while((1u < polySize) && (0u == (lfsrPoly & polyMsbMask))) + while ((1u < polySize) && (0u == (lfsrPoly & polyMsbMask))) { polySize >>= 1u; polyMsbMask >>= 1u; } - return(polySize); + return polySize; } @@ -4926,15 +5044,15 @@ uint32_t Cy_CapSense_GetLfsrBitsNumber( ditherLimitPercents, lfsrScale); /* Based in the MAX allowed clock dithering, Determines the LFSR_BITS option. */ - if(CY_CAPSENSE_LFSR_RANGE_3_DITHER_MAX <= ditherLimitCycles) + if (CY_CAPSENSE_LFSR_RANGE_3_DITHER_MAX <= ditherLimitCycles) { retVal = CY_CAPSENSE_LFSR_BITS_RANGE_3; } - else if(CY_CAPSENSE_LFSR_RANGE_2_DITHER_MAX <= ditherLimitCycles) + else if (CY_CAPSENSE_LFSR_RANGE_2_DITHER_MAX <= ditherLimitCycles) { retVal = CY_CAPSENSE_LFSR_BITS_RANGE_2; } - else if(CY_CAPSENSE_LFSR_RANGE_1_DITHER_MAX <= ditherLimitCycles) + else if (CY_CAPSENSE_LFSR_RANGE_1_DITHER_MAX <= ditherLimitCycles) { retVal = CY_CAPSENSE_LFSR_BITS_RANGE_1; } @@ -4943,7 +5061,7 @@ uint32_t Cy_CapSense_GetLfsrBitsNumber( retVal = CY_CAPSENSE_LFSR_BITS_RANGE_0; } - return (retVal); + return retVal; } @@ -5021,12 +5139,12 @@ uint32_t Cy_CapSense_GetLfsrDitherLimit( * Determine the minimal value to eliminate violation of allowed Sense Clock * divider range. */ - if(ditherLimitCycles > ditherLimitCyclesMax) + if (ditherLimitCycles > ditherLimitCyclesMax) { ditherLimitCycles = ditherLimitCyclesMax; } - return (ditherLimitCycles); + return ditherLimitCycles; } @@ -5062,10 +5180,11 @@ cy_capsense_status_t Cy_CapSense_SsAutoTune(cy_stc_capsense_context_t * context) cy_capsense_status_t autoTuneStatus = CY_CAPSENSE_STATUS_SUCCESS; uint32_t i; uint32_t j; - uint32_t range; + uint32_t watchdogCounter; MSC_Type * mscBase; uint32_t curChIndex; uint32_t rawCountMax; + uint32_t numberSubConv; cy_stc_capsense_hw_smartsense_config_t autoTuneConfig; const cy_stc_capsense_widget_config_t * ptrWdCfg; cy_stc_capsense_widget_context_t * ptrWdCxt; @@ -5084,30 +5203,27 @@ cy_capsense_status_t Cy_CapSense_SsAutoTune(cy_stc_capsense_context_t * context) /* Step #0: Check if configuration is valid */ if ((ptrCommonCfg->counterMode != CY_CAPSENSE_COUNTER_MODE_SATURATE) || - ((ptrCommonCfg->csdCdacCompDivAutoEn != CY_CAPSENSE_ENABLE) && (ptrCommonCfg->csdCdacCompEn == CY_CAPSENSE_ENABLE)) || - (ptrCommonCfg->csdRefCdacAutoEn != CY_CAPSENSE_ENABLE) || (ptrCommonCfg->numWd > CY_CAPSENSE_SMARTSENSE_WD_MAX_NUMBER)) { autoTuneStatus |= CY_CAPSENSE_STATUS_BAD_CONFIG; } - /* Step #1: Sets the default parameters for the preliminary scanning */ + /* Step #1: Sets the default parameters for preliminary scans */ ptrWdCfg = context->ptrWdConfig; for (i = 0u; i < ptrCommonCfg->numWd; i++) { - /* - * Set the Sense Clock source set to Direct. - * Since the Number of Epilogue cycles is a common parameter, it is required - * to configure the Sense Clock source to Direct for all widgets (including CSX) - * in order to have correct number of Epilogue cycles for operation with - * the Direct clock.The setup of the Epilogue cycles number is the part of - * the Cy_CapSense_InitializeSourceSenseClk() routine. - */ - ptrWdCxt = ptrWdCfg->ptrWdContext; - ptrWdCxt->snsClkSource <<= CY_CAPSENSE_CLK_SOURCE_SMARTSENSE_POS; - if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) { + /* + * Set the Sense Clock source set to Direct. + * Since the Number of Epilogue cycles is a common parameter, it is required + * to configure the Sense Clock source to Direct for all widgets (including CSX) + * in order to have correct number of Epilogue cycles for operation with + * the Direct clock.The setup of the Epilogue cycles number is the part of + * the Cy_CapSense_InitializeSourceSenseClk() routine. + */ + ptrWdCxt = ptrWdCfg->ptrWdContext; + ptrWdCxt->snsClkSource <<= CY_CAPSENSE_CLK_SOURCE_SMARTSENSE_POS; ptrWdCxt->numSubConversions = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_NSUB; ptrWdCxt->cdacRef = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_REF_CDAC; ptrWdCxt->rowCdacRef = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_REF_CDAC; @@ -5126,7 +5242,7 @@ cy_capsense_status_t Cy_CapSense_SsAutoTune(cy_stc_capsense_context_t * context) for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) { - mscBase = ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase; + mscBase = ptrCommonCfg->ptrChConfig[curChIndex].ptrHwBase; mscBase->SCAN_CTL2 &= (uint32_t)~((uint32_t)MSC_SCAN_CTL2_NUM_EPI_CYCLES_Msk); mscBase->SCAN_CTL2 |= (uint32_t)((uint32_t)CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK << @@ -5138,65 +5254,29 @@ cy_capsense_status_t Cy_CapSense_SsAutoTune(cy_stc_capsense_context_t * context) } /* Step #2: Execute preliminary scan */ + autoTuneStatus |= Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_REGULAR_SCANNING, context); autoTuneStatus |= Cy_CapSense_ScanAllSlots(context); - while (CY_CAPSENSE_NOT_BUSY != Cy_CapSense_IsBusy(context)) {} - /* Step #3: Update settings for the widgets / sensors with low capacitance */ - ptrWdCfg = context->ptrWdConfig; - for (i = 0u; i < ptrCommonCfg->numWd; i++) - { - if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) - { - ptrWdCxt = ptrWdCfg->ptrWdContext; - range = 0u; - rawCountMax = ((uint32_t)ptrCommonCfg->csdRawTarget * context->ptrWdContext[i].maxRawCount) / - CY_CAPSENSE_PERCENTAGE_100; - for (j = 0u; j < ptrWdCfg->numSns; j++) - { - if (rawCountMax < ptrWdCfg->ptrSnsContext[j].raw) - { - /* Next Widget */ - range = 1u; - break; - } - } - /* Lower capacitance range */ - if (range == 0u) - { - ptrWdCxt->numSubConversions = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_NSUB_RANGE2; - ptrWdCxt->snsClk = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK_RANGE2; - ptrWdCxt->rowSnsClk = CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK_RANGE2; - } - } - ptrWdCfg++; - } - autoTuneStatus |= Cy_CapSense_SsInitialize(context); - - for (curChIndex = 0u; curChIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; curChIndex++) - { - mscBase = ptrCommonCfg->ptrMscChConfig[curChIndex].ptrMscBase; - - mscBase->SCAN_CTL2 &= (uint32_t)~((uint32_t)MSC_SCAN_CTL2_NUM_EPI_CYCLES_Msk); - mscBase->SCAN_CTL2 |= (uint32_t)((uint32_t)CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK << - MSC_SCAN_CTL2_NUM_EPI_CYCLES_Pos); - - mscBase->INIT_CTL4 &= (uint32_t)~((uint32_t)MSC_INIT_CTL4_NUM_PRO_WAIT_CYCLES_Msk); - mscBase->INIT_CTL4 |= (uint32_t)((uint32_t)CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK << - MSC_INIT_CTL4_NUM_PRO_WAIT_CYCLES_Pos); - } + /* Initialize the watchdog counter to prevent a hang */ + watchdogCounter = Cy_CapSense_WatchdogCyclesNum(CY_CAPSENSE_CALIBRATION_TIMEOUT, + (context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA), + CY_CAPSENSE_LOOP_DURATION_CYCLES); - /* Step #4: Execute 8-step calibration scan in single RefCDAC mode */ - (void)Cy_CapSense_CalibrateAllSlots(context); + /* Wait till the end of preliminary scans for the calculated timeout */ + autoTuneStatus |= Cy_CapSense_WaitEndScan(watchdogCounter, context); - /* Step #5: Within each widget find a sensor with max Cp / raw count */ - autoTuneConfig.modClock = ptrCommonCfg->periClkHz / ptrCommonCxt->modClk; + /* + * Step #3: Calculate sensor capacitances, sense clock dividers, and sub-conversion numbers depending on the configured + * serial resistances, and finger capacitances for each sensor + */ + autoTuneConfig.modClock = ptrCommonCfg->periClkHz / context->ptrInternalContext->modClk; autoTuneConfig.snsResistance = ptrCommonCfg->csdRConst; autoTuneConfig.correctionCoeff = CY_CAPSENSE_SENSOR_CONNECTION_MODE; ptrWdCfg = context->ptrWdConfig; - for (i = 0u; i < ptrCommonCfg->numWd; i++) + for (i = 0u; i < CY_CAPSENSE_WIDGET_COUNT; i++) { - if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && (0u != Cy_CapSense_IsWidgetEnabled(i, context))) { ptrWdCxt = ptrWdCfg->ptrWdContext; autoTuneConfig.kRef0 = ptrWdCxt->snsClk; @@ -5213,31 +5293,63 @@ cy_capsense_status_t Cy_CapSense_SsAutoTune(cy_stc_capsense_context_t * context) } } - /* Step #6: Calculates capacitance, clock divider and number of sub-conversions */ autoTuneConfig.raw = (uint16_t)rawCountMax; (void)Cy_CapSense_GetSmartSenseCapacitance(&autoTuneConfig); autoTuneConfig.snsCapacitance /= ptrWdCfg->numChopCycles; (void)Cy_CapSense_GetSmartSenseFrequencyDivider(&autoTuneConfig); + + #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) + /* Check for sub-widget */ + if(0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK)) + { + if(0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_CH_1_MASK)) + { + autoTuneConfig.kRef1 += CY_CAPSENSE_CSD_MFS_DIVIDER_OFFSET_F1; + } + + if(0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_CH_2_MASK)) + { + autoTuneConfig.kRef1 += CY_CAPSENSE_CSD_MFS_DIVIDER_OFFSET_F2; + } + } + #endif + + /* Configure widget sense clock divider by the calculated value */ + ptrWdCxt->snsClk = autoTuneConfig.kRef1; + ptrWdCxt->rowSnsClk = autoTuneConfig.kRef1; + (void)Cy_CapSense_GetSmartSenseNumSubconversions(&autoTuneConfig); - ptrWdCxt->numSubConversions = autoTuneConfig.nSub1 / ptrWdCfg->numChopCycles; - /* Perform adjusting of sense clock divider mainly for high Cp */ - autoTuneConfig.kRef1 = (autoTuneConfig.kRef1 * CY_CAPSENSE_SMARTSENSE_SCALING_DECI_VAL) / - CY_CAPSENSE_SMARTSENSE_CORRECTION; - autoTuneConfig.kRef1 = (autoTuneConfig.kRef1 + CY_CAPSENSE_SMARTSENSE_ROUND_UP_2_BITS_MASK) & - (uint32_t)~CY_CAPSENSE_SMARTSENSE_ROUND_UP_2_BITS_MASK; - if (CY_CAPSENSE_SMARTSENSE_MAX_KREF_VAL < autoTuneConfig.kRef1) + + /* Calculates max possible Nsub value */ + numberSubConv = MSC_RESULT_FIFO_RD_RAW_COUNT_Msk >> MSC_RESULT_FIFO_RD_RAW_COUNT_Pos; + numberSubConv /= autoTuneConfig.kRef1; + + /* Limits Nsub to avoid RawCount overflow */ + if ((uint16_t)numberSubConv > autoTuneConfig.nSub1) { - autoTuneConfig.kRef1 = CY_CAPSENSE_SMARTSENSE_MAX_KREF_VAL; + numberSubConv = autoTuneConfig.nSub1; } - ptrWdCxt->snsClk = autoTuneConfig.kRef1; - ptrWdCxt->rowSnsClk = autoTuneConfig.kRef1; + ptrWdCxt->numSubConversions = (uint16_t)numberSubConv / ptrWdCfg->numChopCycles; + /* Decrease Nsub when CompCDAC is enabled as it increases the sensitivity approximately twice */ + #if(CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_COMP_USAGE) + ptrWdCxt->numSubConversions >>= 1u; + numberSubConv = (uint32_t)ptrWdCxt->numSubConversions << 1u; + #endif + numberSubConv *= ptrWdCfg->numChopCycles; + + /* + * numberSubConv contains real value including chopping and compensation. + * autoTuneConfig.nSub1 contains initially calculated value. + * So, correcting the initially calculated sensitivity. + */ + autoTuneConfig.sigPFC = (uint16_t)((numberSubConv * autoTuneConfig.sigPFC) / autoTuneConfig.nSub1); ptrWdCxt->sigPFC = autoTuneConfig.sigPFC; } ptrWdCfg++; } - /* Step #6.b: Align SnsClkDiv and Nsub for multi-channel solution */ + /* Step #4: Align SnsClkDiv and Nsub for multi-channel solution */ #if (CY_CAPSENSE_TOTAL_CH_NUMBER > 1u) /* Implemented faster algorithm to align frequency across all slots */ ptrWdCfg = context->ptrWdConfig; @@ -5328,14 +5440,18 @@ cy_capsense_status_t Cy_CapSense_SsAutoTune(cy_stc_capsense_context_t * context) Cy_CapSense_SsAutoTuneScanDurationAlignment(wdIdMask, maxDivider, maxSubconversions, context); #endif /* (CY_CAPSENSE_TOTAL_CH_NUMBER > 1u) */ - /* Step #7: Assigning clock sources and restore project parameters */ + /* Step #5: Restore project parameters */ ptrWdCxt = context->ptrWdContext; - for (i = 0u; i < ptrCommonCfg->numWd; i++) + for (i = 0u; i < CY_CAPSENSE_WIDGET_COUNT; i++) { - /* Reverting back original customer's settings */ - ptrWdCxt->snsClkSource = (uint8_t)(((uint32_t)ptrWdCxt->snsClkSource >> CY_CAPSENSE_CLK_SOURCE_SMARTSENSE_POS) & - ~CY_CAPSENSE_CLK_SOURCE_SMARTSENSE_MASK); - ptrWdCxt++; + if ((CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) && (0u != Cy_CapSense_IsWidgetEnabled(i, context))) + { + ptrWdCxt = ptrWdCfg->ptrWdContext; + /* Reverting back original customer's settings */ + ptrWdCxt->snsClkSource = (uint8_t)(((uint32_t)ptrWdCxt->snsClkSource >> CY_CAPSENSE_CLK_SOURCE_SMARTSENSE_POS) & + ~CY_CAPSENSE_CLK_SOURCE_SMARTSENSE_MASK); + } + ptrWdCfg++; } autoTuneStatus |= Cy_CapSense_SsInitialize(context); @@ -5390,54 +5506,450 @@ void Cy_CapSense_SsAutoTuneScanDurationAlignment( #endif +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) /******************************************************************************* -* Function Name: Cy_CapSense_GetMaxRaw +* Function Name: Cy_CapSense_GetCIC2SamplesMax ****************************************************************************//** * -* Returns the theoretical MAX raw count for desired frequency channel. +* This internal function determines the MAX number of CIC2 samples for specified +* decimation rate that can be accumulated in the internal CIC2 HW register +* with no overflow. * -* \param snsClk -* The divider value for the sense clock. +* \param cic2Rate +* CIC2 decimation rate. * -* \param ptrWdConfig -* Specifies the pointer to a widget configuration structure. +* \return +* The MAX allowed number of CIC2 samples. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetCIC2SamplesMax( + uint32_t cic2Rate) +{ + uint32_t retVal; + + retVal = CY_CAPSENSE_CIC2_ACC_MAX_VAL / (cic2Rate * cic2Rate); + + return retVal; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetCIC2HwDivider +****************************************************************************//** +* +* This internal function determines the value of the divider that will be +* applied to the data, accumulated by the CIC2 HW for the specified number of +* samples. +* +* \param cic2Samples +* The number of CIC2 samples for the specified sensing parameters. This value +* can be obtained by using the Cy_CapSense_GetCIC2SamplesNum function. +* +* \return +* The CIC2 HW divider value. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetCIC2HwDivider( + uint32_t cic2Samples) +{ + uint32_t cic2Divider; + + if (cic2Samples > CY_CAPSENSE_CIC2_DIVIDER_8) + { + cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_16; + } + else if (cic2Samples > CY_CAPSENSE_CIC2_DIVIDER_4) + { + cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_8; + } + else if (cic2Samples > CY_CAPSENSE_CIC2_DIVIDER_2) + { + cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_4; + } + else if (cic2Samples > CY_CAPSENSE_CIC2_DIVIDER_1) + { + cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_2; + } + else + { + cic2Divider = CY_CAPSENSE_CIC2_DIVIDER_1; + } + + return cic2Divider; +} +#endif /* #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_ExecuteSaturatedScan +****************************************************************************//** +* +* This internal function executes a scan with the saturated channel to obtain +* the MAX raw count or the scan duration for the specified scan slot. +* +* \param ptrMaxRaw +* Specifies the pointer to store the resulting MAX raw count value. +* +* \param scanSlotId +* The slot ID scans will be done for. +* +* \param mode +* Saturated scan execution mode: +* - CY_CAPSENSE_SATURATED_MAX_COUNT - Used to obtain the MAX raw count. +* - CY_CAPSENSE_SATURATED_SCAN_TIME - Used to obtain the scan duration in terms of Mod Clock cycles. * * \param context -* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* The pointer to the context structure allocated by the user or middleware. * * \return -* Theoretical MAX raw count. +* Returns the status of the operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is performed successfully. +* - CY_CAPSENSE_STATUS_TIMEOUT - A timeout reached during the scan time measurement. +* - CY_CAPSENSE_STATUS_BAD_PARAM - Not valid input parameter. +* - CY_CAPSENSE_STATUS_HW_BUSY - The MSCLP HW block is busy and cannot be +* switched to another mode. * *******************************************************************************/ -uint32_t Cy_CapSense_GetMaxRaw( - uint32_t snsClk, - const cy_stc_capsense_widget_config_t * ptrWdConfig, - const cy_stc_capsense_context_t * context) +cy_capsense_status_t Cy_CapSense_ExecuteSaturatedScan( + uint16_t * ptrMaxRaw, + uint32_t scanSlotId, + uint32_t mode, + cy_stc_capsense_context_t * context) { - uint32_t maxRawTmp; + uint32_t tmpVal; + uint32_t watchdog; + uint32_t scanConfigTmp[CY_MSC_6_SNS_REGS]; + cy_capsense_status_t status; + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) + uint32_t * ptrSnsFrame; + #endif - #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_CIC2_FILTER_EN) - uint32_t snsClkTmp; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + uint32_t kref; + uint32_t nsub; + uint32_t decimRate; + uint32_t samples; + uint32_t hwDivider; #endif - #if (CY_CAPSENSE_DISABLE == CY_CAPSENSE_CIC2_FILTER_EN) - snsClkTmp = snsClk; - if(CY_CAPSENSE_CLK_SOURCE_PRS == (ptrWdConfig->ptrWdContext->snsClkSource & CY_CAPSENSE_CLK_SOURCE_MASK)) + const uint32_t cpuCyclesPerLoop = 5u; + MSC_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig[0u].ptrHwBase; + + (void)mode; + + /* Configures the MSC HW block for operation with the permanently saturated channel. */ + status = Cy_CapSense_SwitchHwConfiguration(CY_CAPSENSE_HW_CONFIG_CHANNEL_SATURATION, context); + + /* The MSC0 HW block will be used to perform measurements. Rest of MSC HW blocks will be disabled. */ + for (tmpVal = 1u; tmpVal < CY_CAPSENSE_TOTAL_CH_NUMBER; tmpVal++) + { + ptrHwBase = context->ptrCommonConfig->ptrChConfig[tmpVal].ptrHwBase; + ptrHwBase->CTL &= (~MSC_CTL_ENABLED_Msk); + } + + ptrHwBase = context->ptrCommonConfig->ptrChConfig[0u].ptrHwBase; + + /* Disable CIC2 filtering to measure the scan duration in in terms of Mod Clock cycles */ + ptrHwBase->FILTER_CTL &= (~MSC_FILTER_CTL_FILTER_MODE_Msk); + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + if(CY_CAPSENSE_SATURATED_MAX_COUNT == mode) { - snsClkTmp <<= CY_CAPSENSE_PRS_SNS_KREF_SHIFT; + /* Keep CIC2 filtering enabled if it is used in the current MW configuration + * to measure the MAX raw count. + */ + ptrHwBase->FILTER_CTL |= (MSC_FILTER_CTL_FILTER_MODE_Msk); } + #endif - maxRawTmp = (((uint32_t)context->ptrInternalContext->numEpiCycles * ptrWdConfig->numChopCycles) - 1u) + - (((uint32_t)ptrWdConfig->ptrWdContext->numSubConversions * ptrWdConfig->numChopCycles) * snsClkTmp); + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) + /* Obtain the scan parameters offset in the cy_capsense_sensorFrameContext[] + * array for the slots that are part of Active widgets. + */ + tmpVal = scanSlotId * CY_MSC_6_SNS_REGS; + /* The code below sets up configuration of the sense control registers. */ + ptrSnsFrame = &context->ptrSensorFrameContext[tmpVal]; + scanConfigTmp[3u] = ptrSnsFrame[3u]; /* Set up the SNS_SCAN_CTL register configuration. */ + scanConfigTmp[4u] = ptrSnsFrame[4u]; /* Set up the SNS_CDAC_CTL register configuration. */ + scanConfigTmp[5u] = ptrSnsFrame[5u]; /* Set up the SNS_CTL register configuration. */ #else - maxRawTmp = (uint32_t)ptrWdConfig->ptrWdContext->cicRate * ptrWdConfig->ptrWdContext->cicRate; - (void)snsClk; - (void)context; + for (tmpVal = 0u; tmpVal < CY_CAPSENSE_TOTAL_CH_NUMBER; tmpVal++) + { + context->ptrActiveScanSns[tmpVal].currentChannelSlotIndex = (uint16_t)scanSlotId; + } + (void)Cy_CapSense_GenerateSensorConfig(0u, scanSlotId, &scanConfigTmp[0u], context); #endif - maxRawTmp = (maxRawTmp > MSC_STATUS1_RAW_COUNT_Msk) ? - ((uint16_t)MSC_STATUS1_RAW_COUNT_Msk) : maxRawTmp; - return maxRawTmp; + /* The measurement with a saturated channel will be performed with all the sensors disconnected. + * The code below sets up the configuration of the MASK registers with 0x00000000u. + * The SW_SEL_CSW_FUNC[0u] is configured in the scope of the Cy_CapSense_ConfigureSaturationMode() + * routine with all the switches open. + */ + scanConfigTmp[0u] = 0x00u; /* Set up the SNS_SW_SEL_CSW_MASK2 register configuration. */ + scanConfigTmp[1u] = 0x00u; /* Set up the SNS_SW_SEL_CSW_MASK1 register configuration. */ + scanConfigTmp[2u] = 0x00u; /* Set up the SNS_SW_SEL_CSW_MASK0 register configuration. */ + + if(status == CY_CAPSENSE_STATUS_SUCCESS) + { + /* Initiate the scan in the CPU operating mode */ + Cy_MSC_ConfigureScan(ptrHwBase, CY_MSC_6_SNS_REGS, scanConfigTmp); + + /* Clear all pending interrupts */ + ptrHwBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; + + /* Set the multi-channel mode configuration to OFF */ + ptrHwBase->SNS_CTL &= (~MSC_SNS_CTL_MULTI_CH_MODE_Msk); + + /* Configure the last slot */ + ptrHwBase->SNS_CTL |= MSC_SNS_CTL_LAST_Msk | MSC_SNS_CTL_VALID_Msk; + + /* Start scanning with START_SCAN */ + ptrHwBase->SNS_CTL |= MSC_SNS_CTL_START_SCAN_Msk; + + /* Start FSM with START_FRAME */ + ptrHwBase->FRAME_CMD = MSC_FRAME_CMD_START_FRAME_Msk; + + watchdog = Cy_CapSense_GetScanWatchdogTime(scanSlotId, context); + tmpVal = context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_KILO; + watchdog = Cy_CapSense_WatchdogCyclesNum(watchdog, tmpVal, cpuCyclesPerLoop); + + while ((ptrHwBase->INTR & MSC_INTR_MASK_SCAN_Msk) == 0u) + { + if (0uL == watchdog) + { + break; + } + watchdog--; + } + + tmpVal = (uint16_t)ptrHwBase->RESULT_FIFO_RD; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CIC2_FILTER_EN) + if (1u != context->ptrWdConfig->numChopCycles) + { + kref = ((scanConfigTmp[CY_CAPSENSE_SNS_CTL_INDEX] & MSC_SNS_CTL_SENSE_DIV_Msk) >> MSC_SNS_CTL_SENSE_DIV_Pos) + 1u; + decimRate = ((scanConfigTmp[CY_CAPSENSE_SNS_CTL_INDEX] & MSC_SNS_CTL_DECIM_RATE_Msk) >> MSC_SNS_CTL_DECIM_RATE_Pos) + 1u; + nsub = ((scanConfigTmp[CY_CAPSENSE_SNS_SCAN_CTL_INDEX] & MSC_SNS_SCAN_CTL_NUM_SUB_CONVS_Msk) >> MSC_SNS_SCAN_CTL_NUM_SUB_CONVS_Pos) + 1u; + /* Valid Samples */ + samples = (((kref * nsub) / decimRate) - 1u) * context->ptrWdConfig->numChopCycles; + hwDivider = Cy_CapSense_GetCIC2HwDivider(samples); + tmpVal = ((((tmpVal * hwDivider) - (kref * nsub)) * context->ptrWdConfig->numChopCycles) + (kref * nsub)) / hwDivider; + } + #else + tmpVal *= context->ptrWdConfig->numChopCycles; + #endif + + *ptrMaxRaw = CY_CAPSENSE_16_BIT_MASK; + if(tmpVal <= CY_CAPSENSE_16_BIT_MASK) + { + *ptrMaxRaw = (uint16_t)tmpVal; + } + + /* Clear all pending interrupts */ + ptrHwBase->INTR = CY_CAPSENSE_MSC_INTR_ALL_MSK; + + if(0u == watchdog) + { + status |= CY_CAPSENSE_STATUS_TIMEOUT; + } + } + + return status; +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_ConfigureSaturationMode +****************************************************************************//** +* +* Configures the MSC HW block for operation with the permanently saturated +* channel. +* The raw data counter is continuously enabled from the beginning to the end of +* the scan. The scan is performed in the CPU operating mode. +* +* \param context +* The pointer to the context structure allocated by the user or middleware. +* +*******************************************************************************/ +void Cy_CapSense_ConfigureSaturationMode( + cy_stc_capsense_context_t * context) +{ + uint32_t i; + MSC_Type * ptrHwBase = context->ptrCommonConfig->ptrChConfig[0u].ptrHwBase; + + /* Enable HW IP to allow a scan frame start */ + ptrHwBase->CTL |= MSC_CTL_ENABLED_Msk; + + /* Disable all interrupts */ + ptrHwBase->INTR_MASK = 0x00u; + + /* The 0x00 value of the OPERATING_MODE field switches the HW to the CPU + * configures it to generate VDDA/2 voltage at the output. + */ + CY_REG32_CLR_SET(ptrHwBase->CTL, MSC_CTL_OPERATING_MODE, 0u); + + /* Configure the Switch Control Global Function #0 to have all switches open. + * All the sensing electrodes will be disconnected during the MAX raw count measurement. + */ + ptrHwBase->SW_SEL_CSW_FUNC[0u] = 0x00u; + + /* Iterate through all the MODE structures and update them with the configuration, + * required to saturate the measurement channel. + */ + for(i = 0u; i < MSC0_SENSE_MODE_NR; i++) + { + /* The 0x01 value of the RMF field enables the internal voltage divider and + * configures it to generate VDDA/2 voltage at the output. + */ + ptrHwBase->MODE[i].SW_SEL_TOP = _VAL2FLD(MSC_MODE_SW_SEL_TOP_RMF, 0x01u); + + /* Set the CPF and the CMG bits to get the positive comparator input connected + * to the VDDA/2 voltage level and the negative comparator input to the GND. + */ + ptrHwBase->MODE[i].SW_SEL_COMP = _VAL2FLD(MSC_MODE_SW_SEL_COMP_CPF, 0x01u) | + _VAL2FLD(MSC_MODE_SW_SEL_COMP_CMG, 0x01u); + } + +} + + +/******************************************************************************* +* Function Name: Cy_CapSense_GetScanWatchdogTime +****************************************************************************//** +* +* This internal function calculates the watchdog time in microseconds for the +* specified slot. The calculated value is the duration of one sample with the +* five-time margin. +* +* WATCHDOG_TIME = (SCAN_CYCLES / MOD_CLK_FREQ) * 5; +* +* where: +* +* SCAN_CYCLES = (INIT_CYCLES + PRO_CYCLES + CONV_CYCLES + EPI_CYCLES) * NUM_CONV; +* INIT_CYCLES = INIT_CMOD_RAIL_CYCLES + INIT_CMOD_SHORT_CYCLES; +* PRO_CYCLES = PRO_OFFSET_CYCLES + (PRO_WAIT_KREF_DELAY * SENSE_DIV / 4); +* CONV_CYCLES = (PRO_DUMMY_SUB_CONVS + NUM_SUB_CONVS) * SENSE_DIV; +* EPI_CYCLES = EPI_KREF_DELAY * SENSE_DIV / 4; +* +* The corresponding parameters are listed below: +* - EPI_KREF_DELAY - The duration of EPILOGUE defined in relation to Kref. +* The value is interpreted as SENSE_DIV/4 increments. +* - INIT_CMOD_RAIL_CYCLES - Duration of the coarse initialization phase when +* Cmod1 is connected to VDDA and Cmod2 is connected to VSSA. The parameter is +* defined in terms of Mod Clock cycles. +* - INIT_CMOD_SHORT_CYCLES - Duration of the coarse short phase when +* Cmod1 and Cmod2 are shorted together. The parameter is defined in terms of +* Mod Clock cycles. +* - PRO_OFFSET_CYCLES - Maximum number of Mod Clock cycles to be assigned for +* the PRO_OFFSET state. If NUM_PRO_OFFSET_TRIPS are observed before this +* timeout, exit at that point. +* - PRO_DUMMY_SUB_CONVS - Number of sub-conversions (dummy cycles) to be run +* during PRO_DUMMY. +* - PRO_WAIT_KREF_DELAY - The duration of PRO_WAIT defined in relation to Kref. +* The value is interpreted as SENSE_DIV/4 increments. +* - SENSE_DIV - The length of one sub-conversion in terms of Mod Clock cycles. +* - NUM_SUB_CONVS - Number of sub-conversions. +* - NUM_CONV - Number of chop cycles. +* - MOD_CLK_FREQ - Modulation clock frequency. +* +* \param scanSlotId +* The slot ID the watchdog time calculation will be done for. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns watch-dog time interval in microseconds. +* +*******************************************************************************/ +uint32_t Cy_CapSense_GetScanWatchdogTime( + uint32_t scanSlotId, + cy_stc_capsense_context_t * context) +{ + uint32_t tmpVal; + uint32_t snsClkDivider; + uint32_t modClkFreqMhz; + const cy_stc_capsense_widget_config_t * ptrWdCfg; + const cy_stc_capsense_scan_slot_t * ptrScanSlots; + + /* Define the MARGIN_KOEFF = 5 */ + const uint32_t watchdogTimeMarginCoeff = 5u; + + modClkFreqMhz = context->ptrCommonConfig->periClkHz; + modClkFreqMhz /= context->ptrInternalContext->modClk; + modClkFreqMhz /= CY_CAPSENSE_CONVERSION_MEGA; + + /* Initialize pointers with the configuration address for the specified scan slot and MSC channel #0 */ + ptrScanSlots = &context->ptrScanSlots[scanSlotId]; + ptrWdCfg = &context->ptrWdConfig[ptrScanSlots->wdId]; + + /* For the multi-channel mode, iterate through enabled channels and find the sensing channel that + * drives the sensor (not Shield only, Tx only, or Empty). + */ + #if (1u < CY_CAPSENSE_TOTAL_CH_NUMBER) + for (tmpVal = 0u; tmpVal < CY_CAPSENSE_TOTAL_CH_NUMBER; tmpVal++) + { + ptrScanSlots = &context->ptrScanSlots[scanSlotId + (CY_CAPSENSE_SLOT_COUNT * tmpVal)]; + if(CY_CAPSENSE_SLOT_SHIELD_ONLY > ptrScanSlots->wdId) + { + ptrWdCfg = &context->ptrWdConfig[ptrScanSlots->wdId]; + break; + } + } + #endif + + /* Initialize the .snsClkDivider field with the value for the slot that is + * specified by the scanSlotId parameter of the function. + */ + snsClkDivider = ptrWdCfg->ptrWdContext->snsClk; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) + if (CY_CAPSENSE_CSD_GROUP == ptrWdCfg->senseMethod) + { + #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_TOUCHPAD_EN) ||\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_MATRIX_EN)) + if (ptrWdCfg->numCols <= ptrScanSlots->snsId) + { + snsClkDivider = ptrWdCfg->ptrWdContext->rowSnsClk; + } + #endif /* CY_CAPSENSE_CSD_TOUCHPAD_EN || CY_CAPSENSE_CSD_MATRIX_EN */ + } + #endif /* CY_CAPSENSE_CSD_EN */ + + /* Calculate the INIT_CYCLES number. */ + tmpVal = ((uint32_t)context->ptrInternalContext->numCoarseInitChargeCycles + context->ptrInternalContext->numCoarseInitSettleCycles); + + /* Add the PRO_OFFSET_CYCLES number. */ + tmpVal += (uint32_t)context->ptrInternalContext->numProOffsetCycles; + + /* Add the sum of PRO_CYCLES and EPI_CYCLES. The .numFineInitWaitCycles and the .numEpiCycles parameters are defined in terms of + * Mod Clock cycles for the fifth-generation devices. + */ + tmpVal += ((uint32_t)context->ptrInternalContext->numFineInitWaitCycles + context->ptrInternalContext->numEpiCycles); + + /* Add the CONV_CYCLES number. */ + tmpVal += ((uint32_t)context->ptrInternalContext->numFineInitCycles + ptrWdCfg->ptrWdContext->numSubConversions); + tmpVal *= snsClkDivider; + + if (CY_CAPSENSE_CLK_SOURCE_PRS == (ptrWdCfg->ptrWdContext->snsClkSource & CY_CAPSENSE_CLK_SOURCE_MASK)) + { + /* Taking into account correction that is implemented in the Cy_CapSense_AdjustSnsClkDivider() function, + * the scan duration is two time longer if the PRS is used as the sense clock source. + */ + tmpVal <<= 1u; + } + + /* Calculate the SCAN_CYCLES number by multiplying the Mod Clock cycles number per one chop cycle by + * number of chop cycles. + */ + tmpVal *= ptrWdCfg->numChopCycles; + + /* Convert the calculated duration in terms of clk_mod cycles to the microseconds. */ + tmpVal /= modClkFreqMhz; + + /* Multiply the calculated value by the MARGIN_KOEFF value. */ + tmpVal *= watchdogTimeMarginCoeff; + + return tmpVal; } diff --git a/cy_capsense_sensing_v3.h b/cy_capsense_sensing_v3.h index bb591ca..39cf2e2 100644 --- a/cy_capsense_sensing_v3.h +++ b/cy_capsense_sensing_v3.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_sensing_v3.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the function prototypes specific to the scanning module. @@ -37,51 +37,14 @@ extern "C" { *******************************************************************************/ /******************************************************************************/ -/** \addtogroup group_capsense_high_level *//** \{ */ +/** \cond SECTION_CAPSENSE_INTERNAL */ +/** \addtogroup group_capsense_internal *//** \{ */ /******************************************************************************/ -cy_capsense_status_t Cy_CapSense_ScanAllSlots( - cy_stc_capsense_context_t * context); -cy_capsense_status_t Cy_CapSense_ScanSlots( + +cy_capsense_status_t Cy_CapSense_ScanSlots_V3( uint32_t startSlotId, uint32_t numberSlots, cy_stc_capsense_context_t * context); -cy_capsense_mw_state_t Cy_CapSense_MwState( - const cy_stc_capsense_context_t * context); -/** \} */ - - -/******************************************************************************/ -/** \addtogroup group_capsense_low_level *//** \{ */ -/******************************************************************************/ -#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) ||\ - (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) -cy_capsense_status_t Cy_CapSense_CalibrateAllSlots( - cy_stc_capsense_context_t * context); -cy_capsense_status_t Cy_CapSense_SetCalibrationTargets( - uint32_t csdCalibrTarget, - uint32_t csxCalibrTarget, - cy_stc_capsense_context_t * context); -cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets( - cy_stc_capsense_context_t * context); -#endif - -#if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) -cy_capsense_status_t Cy_CapSense_SlotPinState( - uint32_t slotId, - const cy_stc_capsense_electrode_config_t * ptrEltdCfg, - uint32_t pinState, - cy_stc_capsense_context_t * context); -#endif - -cy_capsense_status_t Cy_CapSense_ScanAbort( - cy_stc_capsense_context_t * context); -/** \} */ - - -/******************************************************************************/ -/** \cond SECTION_CAPSENSE_INTERNAL */ -/** \addtogroup group_capsense_internal *//** \{ */ -/******************************************************************************/ cy_capsense_status_t Cy_CapSense_ScanWidget_V3( uint32_t widgetId, cy_stc_capsense_context_t * context); @@ -91,8 +54,6 @@ cy_capsense_status_t Cy_CapSense_ScanSensor_V3( cy_stc_capsense_context_t * context); cy_capsense_status_t Cy_CapSense_ScanAllWidgets_V3( cy_stc_capsense_context_t * context); -uint32_t Cy_CapSense_IsBusy_V3( - const cy_stc_capsense_context_t * context); void Cy_CapSense_InterruptHandler_V3( const MSC_Type * base, cy_stc_capsense_context_t * context); @@ -109,13 +70,22 @@ cy_capsense_status_t Cy_CapSense_SetPinState_V3( (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) cy_capsense_status_t Cy_CapSense_CalibrateAllWidgets_V3( cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_CalibrateAllSlots_V3( + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_SetCalibrationTarget_V3( + uint32_t calibrTarget, + uint32_t snsMethod, + cy_stc_capsense_context_t * context); + #if (1u == CY_CAPSENSE_TOTAL_CH_NUMBER) cy_capsense_status_t Cy_CapSense_CalibrateWidget_V3( uint32_t widgetId, cy_stc_capsense_context_t * context); #endif /* (1u == CY_CAPSENSE_TOTAL_CH_NUMBER) */ + #endif /* ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) ||\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) */ + void Cy_CapSense_SetBusyFlags( uint32_t chIndex, cy_stc_capsense_context_t * context); @@ -128,19 +98,26 @@ uint32_t Cy_CapSense_WatchdogCyclesNum( uint32_t desiredTimeUs, uint32_t cpuFreqMHz, uint32_t cyclesPerLoop); + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) void Cy_CapSense_ConfigureAnalogMuxResource( uint32_t chIndex, uint32_t snsMethod, cy_stc_capsense_context_t * context); #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) */ + #if (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) cy_capsense_status_t Cy_CapSense_InitializeDmaResource( cy_stc_capsense_context_t * context); cy_capsense_status_t Cy_CapSense_ConfigureDmaResource( uint32_t mscChIndex, cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_InitializeDmaArrays( + cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_ConfigureDmaArrays( + cy_stc_capsense_context_t * context); #endif /* (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) */ + void Cy_CapSense_SetModClkDivider( uint32_t dividerValue, const cy_stc_capsense_context_t * context); @@ -148,11 +125,13 @@ void Cy_CapSense_ScanISR(void * capsenseContext); void Cy_CapSense_SetCmodInDefaultState( uint32_t chIndex, const cy_stc_capsense_context_t * context); + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) void Cy_CapSense_SetCmodInAmuxModeState( uint32_t chIndex, const cy_stc_capsense_context_t * context); #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) */ + void Cy_CapSense_InitActivePtrSns( uint32_t chIndex, uint32_t sensorId, @@ -166,6 +145,7 @@ void Cy_CapSense_InitActivePtr( uint32_t widgetId, uint32_t sensorId, cy_stc_capsense_context_t * context); + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) void Cy_CapSense_SetIOsInDesiredState( uint32_t desiredDriveMode, @@ -174,6 +154,7 @@ void Cy_CapSense_SetIOsInDesiredState( uint32_t chIndex, const cy_stc_capsense_context_t * context); #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) */ + void Cy_CapSense_SetIOsInDefaultState( const cy_stc_capsense_context_t * context); void Cy_CapSense_SsConfigPinRegisters( @@ -181,6 +162,7 @@ void Cy_CapSense_SsConfigPinRegisters( uint32_t pinNum, uint32_t dm, en_hsiom_sel_t hsiom); + #if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) void Cy_CapSense_ConnectSensor( uint32_t chIndex, @@ -221,6 +203,7 @@ void Cy_CapSense_DisableShieldElectrodes( uint32_t chIndex, cy_stc_capsense_context_t * context); #endif + #endif /* (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD) */ #if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) ||\ @@ -263,10 +246,36 @@ cy_capsense_status_t Cy_CapSense_InitializeSourceSenseClk( cy_capsense_status_t Cy_CapSense_SsAutoTune( cy_stc_capsense_context_t * context); #endif -uint32_t Cy_CapSense_GetMaxRaw( - uint32_t snsClk, - const cy_stc_capsense_widget_config_t * ptrWdConfig, + +cy_capsense_mw_state_t Cy_CapSense_MwState_V3( const cy_stc_capsense_context_t * context); +cy_capsense_status_t Cy_CapSense_ScanAbort_V3( + cy_stc_capsense_context_t * context); + +#if (CY_CAPSENSE_SENSOR_CONNECTION_MODE == CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD) +cy_capsense_status_t Cy_CapSense_SlotPinState_V3( + uint32_t slotId, + const cy_stc_capsense_electrode_config_t * ptrEltdCfg, + uint32_t pinState, + cy_stc_capsense_context_t * context); +#endif + +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) + uint32_t Cy_CapSense_GetCIC2SamplesMax(uint32_t cic2Rate); + uint32_t Cy_CapSense_GetCIC2HwDivider(uint32_t cic2Samples); +#endif /* #if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CIC2_FILTER_EN) */ + +cy_capsense_status_t Cy_CapSense_ExecuteSaturatedScan( + uint16_t * ptrMaxRaw, + uint32_t scanSlotId, + uint32_t mode, + cy_stc_capsense_context_t * context); +void Cy_CapSense_ConfigureSaturationMode( + cy_stc_capsense_context_t * context); +uint32_t Cy_CapSense_GetScanWatchdogTime( + uint32_t scanSlotId, + cy_stc_capsense_context_t * context); + /** \} \endcond */ @@ -291,6 +300,7 @@ uint32_t Cy_CapSense_GetMaxRaw( #define CY_CAPSENSE_FW_NEGATIVE_TX_AMUX_REG_SW_CSD_SHIELD_VALUE (0x00000060uL) #define CY_CAPSENSE_CALIBRATION_TIMEOUT (1000000uL) +#define CY_CAPSENSE_LOOP_DURATION_CYCLES (5u) #define CY_CAPSENSE_MAX_CH_NUM (4u) #define CY_CAPSENSE_CDAC_MAX_CODE (0xFFu) #define CY_CAPSENSE_CAL_MIDDLE_VALUE (0x80u) @@ -327,15 +337,8 @@ uint32_t Cy_CapSense_GetMaxRaw( #define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_NSUB (8u) #define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK (256u) -#define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_NSUB_RANGE2 (64u) -#define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_SNS_CLK_RANGE2 (32u) -#define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_REF_CDAC (10u) +#define CY_CAPSENSE_SMARTSENSE_PRELIMINARY_SCAN_REF_CDAC (100u) #define CY_CAPSENSE_SMARTSENSE_WD_MAX_NUMBER (64u) -#define CY_CAPSENSE_SMARTSENSE_PRO_EPI_CYCLE_NUMBER (119u) -#define CY_CAPSENSE_SMARTSENSE_ROUND_UP_2_BITS_MASK (0x03u) -#define CY_CAPSENSE_SMARTSENSE_MAX_KREF_VAL (2048u) -#define CY_CAPSENSE_SMARTSENSE_SCALING_DECI_VAL (10u) -#define CY_CAPSENSE_SMARTSENSE_CORRECTION (8u) #define CY_CAPSENSE_MAX_PRO_EPI_PRS_CYCLE_NUMBER (1023u) @@ -343,12 +346,6 @@ uint32_t Cy_CapSense_GetMaxRaw( #define CY_CAPSENSE_CALIBRATION_COMP_DIV_MASK (0x02u) #define CY_CAPSENSE_CALIBRATION_COMP_CDAC_MASK (0x04u) -#define CY_CAPSENSE_MFS_FREQ_CHANNELS_NUM_MASK (0xFu) -#define CY_CAPSENSE_MFS_EN_MASK (0x10u) -#define CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK (0x60u) -#define CY_CAPSENSE_MFS_WIDGET_FREQ_CH_1_MASK (0x20u) -#define CY_CAPSENSE_MFS_WIDGET_FREQ_CH_2_MASK (0x40u) - #define CY_CAPSENSE_SLOT_COUNT_MAX_VALUE (0xFFFFu) /******************************************************************************* @@ -377,7 +374,7 @@ uint32_t Cy_CapSense_GetMaxRaw( * - Enables all the sub-blocks of the MSC HW block; * - Enables the Sense Modulator output; * 2. Clear all of the pending interrupt requests of the MSC HW block; - * 3. Sets into default state the rest of the CSD HW block registers which are not related + * 3. Sets into default state the rest of the MSC HW block registers which are not related * to actions #1 and #2. */ @@ -512,6 +509,8 @@ uint32_t Cy_CapSense_GetMaxRaw( #define CY_CAPSENSE_CSD_CDAC_REF_AUTO_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_REF_AUTO_EN)) +#define CY_CAPSENSE_CSD_CDAC_CALIBRATION_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CALIBRATION_EN)) #define CY_CAPSENSE_CSX_CDAC_COMP_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_COMP_EN)) @@ -521,6 +520,13 @@ uint32_t Cy_CapSense_GetMaxRaw( #define CY_CAPSENSE_CSX_CDAC_REF_AUTO_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN) &&\ (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_REF_AUTO_EN)) +#define CY_CAPSENSE_CSX_CDAC_CALIBRATION_USAGE ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_EN) &&\ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CALIBRATION_EN)) + +/* Used for the Cy_CapSense_ExecuteSaturatedScan() function to obtain the MAX raw count. */ +#define CY_CAPSENSE_SATURATED_MAX_COUNT (0u) +/* Used for the Cy_CapSense_ExecuteSaturatedScan() function to obtain the scan duration. */ +#define CY_CAPSENSE_SATURATED_SCAN_TIME (1u) #if defined(__cplusplus) diff --git a/cy_capsense_sm_base_full_wave_lp.h b/cy_capsense_sm_base_full_wave_lp.h new file mode 100644 index 0000000..503b81c --- /dev/null +++ b/cy_capsense_sm_base_full_wave_lp.h @@ -0,0 +1,1514 @@ +/***************************************************************************//** +* \file cy_capsense_sm_base_full_wave_lp.h +* \version 4.0 +* +* \brief +* This file lists a set of macros for each register bit-field for the specified +* sensing method. +* +******************************************************************************** +* \copyright +* Copyright 2020-2023, Cypress Semiconductor Corporation (an Infineon company) +* or an affiliate of Cypress Semiconductor Corporation. All rights reserved. +* You may use this file only in accordance with the license, terms, conditions, +* disclaimers, and limitations in the end user license agreement accompanying +* the software package with which this file was provided. +*******************************************************************************/ + +#if !defined(CY_CAPSENSE_SM_BASE_FULL_WAVE_LP_H) +#define CY_CAPSENSE_SM_BASE_FULL_WAVE_LP_H + +#if defined(CY_IP_M0S8MSCV3LP) + +#if defined(__cplusplus) +extern "C" { +#endif + +/******************************************************************************* +* \note 23WW17.2 +*******************************************************************************/ + +/******************************************************************************* +* Base HW block configuration +*******************************************************************************/ + +/* CTL: Configuration and Control */ +#define CY_CAPSENSE_SM_REG_CTL_FLD_SENSE_EN (0x1uL) +#define CY_CAPSENSE_SM_REG_CTL_FLD_MSCCMP_EN (0x1uL) +#define CY_CAPSENSE_SM_REG_CTL_FLD_CLK_SYNC_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_CTL_FLD_EXT_FRAME_START_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_CTL_FLD_CFG_OFFSET (0x0uL) +#define CY_CAPSENSE_SM_REG_CTL_FLD_OPERATING_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_CTL_FLD_BUF_MODE (0x1uL) +#define CY_CAPSENSE_SM_REG_CTL_FLD_CLK_MSC_RATIO (0x0uL) +#define CY_CAPSENSE_SM_REG_CTL_FLD_DEBUG_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_CTL_FLD_ENABLED (0x0uL) + +/* SCAN_CTL1: Scan Control 1 */ +#define CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_NUM_AUTO_RESAMPLE (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_RESCAN_DEBUG_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_NUM_SAMPLES (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_RAW_COUNT_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_DEBUG_CONV_PH_SEL (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_FRAME_RES_START_ADDR (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_RC_STORE_EN (0x1uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL1_FLD_RC_STORE_MODE (0x0uL) + +/* SCAN_CTL2: Scan Control 2 */ +#define CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_NUM_EPI_KREF_DELAY_PRS (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_NUM_EPI_KREF_DELAY (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_CHOP_POL (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_CHOP_EVEN_HOLD_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_FRAME_CFG_START_ADDR (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_EXT_REF_CLK_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_SCAN_CTL2_FLD_INFINITE_SCAN_MODE (0x0uL) + +/* INIT_CTL1: Initialization Control 1 */ +#define CY_CAPSENSE_SM_REG_INIT_CTL1_FLD_NUM_INIT_CMOD_12_RAIL_CYCLES (0x0uL) +#define CY_CAPSENSE_SM_REG_INIT_CTL1_FLD_NUM_INIT_CMOD_12_SHORT_CYCLES (0x0uL) +#define CY_CAPSENSE_SM_REG_INIT_CTL1_FLD_PER_SAMPLE (0x0uL) + +/* INIT_CTL3: Initialization Control 3 */ +#define CY_CAPSENSE_SM_REG_INIT_CTL3_FLD_NUM_PRO_OFFSET_CYCLES (0x31uL) +#define CY_CAPSENSE_SM_REG_INIT_CTL3_FLD_NUM_PRO_OFFSET_TRIPS (0x0uL) +#define CY_CAPSENSE_SM_REG_INIT_CTL3_FLD_CMOD_SEL (0x0uL) +#define CY_CAPSENSE_SM_REG_INIT_CTL3_FLD_INIT_MODE (0x0uL) + +/* INIT_CTL4: Initialization Control 4 */ +#define CY_CAPSENSE_SM_REG_INIT_CTL4_FLD_NUM_PRO_DUMMY_SUB_CONVS (0x0uL) +#define CY_CAPSENSE_SM_REG_INIT_CTL4_FLD_NUM_PRO_WAIT_KREF_DELAY_PRS (0x0uL) +#define CY_CAPSENSE_SM_REG_INIT_CTL4_FLD_NUM_PRO_WAIT_KREF_DELAY (0x0uL) +#define CY_CAPSENSE_SM_REG_INIT_CTL4_FLD_PRO_BYPASS (0x0uL) + +/* SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_SENSE_DUTY_CTL_FLD_PHASE_WIDTH (0x0uL) +#define CY_CAPSENSE_SM_REG_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_CYCLES (0x1uL) +#define CY_CAPSENSE_SM_REG_SENSE_DUTY_CTL_FLD_PHASE_WIDTH_SEL (0x0uL) + +/* SENSE_PERIOD_CTL: Sense Clock Period Control */ +#define CY_CAPSENSE_SM_REG_SENSE_PERIOD_CTL_FLD_LFSR_POLY (0x0uL) +#define CY_CAPSENSE_SM_REG_SENSE_PERIOD_CTL_FLD_LFSR_SCALE (0x0uL) + +/* FILTER_CTL: Filter Control */ +#define CY_CAPSENSE_SM_REG_FILTER_CTL_FLD_BIT_FORMAT (0x0uL) +#define CY_CAPSENSE_SM_REG_FILTER_CTL_FLD_FILTER_MODE (0x0uL) + +/* CCOMP_CDAC_CTL: Compensation CAPDAC Control */ +#define CY_CAPSENSE_SM_REG_CCOMP_CDAC_CTL_FLD_SEL_CO_PRO_OFFSET (0xFuL) +#define CY_CAPSENSE_SM_REG_CCOMP_CDAC_CTL_FLD_COMP_BLANKING_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_CCOMP_CDAC_CTL_FLD_EPILOGUE_EN (0x0uL) + +/* DITHER_CDAC_CTL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_DITHER_CDAC_CTL_FLD_SEL_FL (0x0uL) +#define CY_CAPSENSE_SM_REG_DITHER_CDAC_CTL_FLD_LFSR_POLY_FL (0x0uL) + +/* MSCCMP_CTL: MSC Comparator Control */ +#define CY_CAPSENSE_SM_REG_MSCCMP_CTL_FLD_PWR (0x1uL) +#define CY_CAPSENSE_SM_REG_MSCCMP_CTL_FLD_FILT (0x1uL) + +/* AOS_CTL: Always On Scanning Control */ +#define CY_CAPSENSE_SM_REG_AOS_CTL_FLD_WAKEUP_TIMER (0x0uL) +#define CY_CAPSENSE_SM_REG_AOS_CTL_FLD_FR_TIMEOUT_INTERVAL (0x0uL) +#define CY_CAPSENSE_SM_REG_AOS_CTL_FLD_STOP_ON_SD (0x0uL) +#define CY_CAPSENSE_SM_REG_AOS_CTL_FLD_MRSS_PWR_CYCLE_EN (0x0uL) + +/* CE_CTL: Channel Engine Control */ +#define CY_CAPSENSE_SM_REG_CE_CTL_FLD_RCF_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_CE_CTL_FLD_BLSD_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_CE_CTL_FLD_CE_TEST_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_CE_CTL_FLD_ENABLED (0x0uL) + +/* PUMP_CTL: Local MRSS Pump Control */ +#define CY_CAPSENSE_SM_REG_PUMP_CTL_FLD_PUMP_MODE (0x0uL) + +/* IMO_CTL: Local MRSS IMO Control */ +#define CY_CAPSENSE_SM_REG_IMO_CTL_FLD_FREQ (0x0uL) +#define CY_CAPSENSE_SM_REG_IMO_CTL_FLD_CLOCK_SYNC_DIV (0x0uL) +#define CY_CAPSENSE_SM_REG_IMO_CTL_FLD_CLOCK_MSC_DIV (0x0uL) + +/* INTR: MSCv3 Interrupt Cause Register */ +#define CY_CAPSENSE_SM_REG_INTR_FLD_SUB_SAMPLE (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_FLD_SAMPLE (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_FLD_SCAN (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_FLD_INIT (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_FLD_FRAME (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_FLD_CIC2_ERROR (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_FLD_CONFIG_REQ (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_FLD_FIFO_UNDERFLOW (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_FLD_FIFO_OVERFLOW (0x0uL) + +/* INTR_SET: MSCv3 Interrupt Set Register */ +#define CY_CAPSENSE_SM_REG_INTR_SET_FLD_SUB_SAMPLE (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_SET_FLD_SAMPLE (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_SET_FLD_SCAN (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_SET_FLD_INIT (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_SET_FLD_FRAME (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_SET_FLD_CIC2_ERROR (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_SET_FLD_CONFIG_REQ (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_SET_FLD_FIFO_UNDERFLOW (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_SET_FLD_FIFO_OVERFLOW (0x0uL) + +/* INTR_LP: Low Power Interrupt Cause Register */ +#define CY_CAPSENSE_SM_REG_INTR_LP_FLD_SIG_DET (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_LP_FLD_FR_TIMEOUT (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_LP_FLD_FRAME (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_LP_FLD_CE_DONE (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_LP_FLD_IMO_UP (0x0uL) + +/* INTR_LP_SET: Low Power Interrupt Set Register */ +#define CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_SIG_DET (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_FR_TIMEOUT (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_FRAME (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_CE_DONE (0x0uL) +#define CY_CAPSENSE_SM_REG_INTR_LP_SET_FLD_IMO_UP (0x0uL) + +/* WAKEUP_CMD: Wakeup Command Register */ +#define CY_CAPSENSE_SM_REG_WAKEUP_CMD_FLD_START_FRAME_AOS (0x0uL) + +/* MRSS_CMD: MRSS Command Register */ +#define CY_CAPSENSE_SM_REG_MRSS_CMD_FLD_MRSS_START (0x0uL) +#define CY_CAPSENSE_SM_REG_MRSS_CMD_FLD_MRSS_STOP (0x0uL) +#define CY_CAPSENSE_SM_REG_MRSS_CMD_FLD_MRSS_PUMP_STOP (0x0uL) + +/* SW_SEL_GPIO: GPIO Switch Control */ +#define CY_CAPSENSE_SM_REG_SW_SEL_GPIO_FLD_SW_CSD_SENSE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_GPIO_FLD_SW_CSD_SHIELD (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_GPIO_FLD_SW_CSD_MUTUAL (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_GPIO_FLD_SW_CSD_POLARITY (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_GPIO_FLD_SW_CSD_CHARGE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_GPIO_FLD_SW_DSI_CMOD (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_GPIO_FLD_SW_DSI_CSH_TANK (0x0uL) + +/* SW_SEL_CDAC_RE: Reference CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RETCC (0x3uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RECD (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RETV (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_RETG (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_REBV (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_RE_FLD_SW_REBG (0x3uL) + +/* SW_SEL_CDAC_CO: Compensation CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COTCA (0x3uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COCB (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COTV (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COTG (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COBV (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CO_FLD_SW_COBG (0x3uL) + +/* SW_SEL_CDAC_CF: Fine CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFTCA (0x3uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFTCB (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFTV (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFTG (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFBV (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CDAC_CF_FLD_SW_CFBG (0x3uL) + +/* SW_SEL_BGR: Bandgap Reference Switch Control */ +#define CY_CAPSENSE_SM_REG_SW_SEL_BGR_FLD_SW_BGRCM (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_BGR_FLD_SW_IGMA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_BGR_FLD_SW_BGRMA (0x0uL) + +/* CSW_CTL_LO: CapSense Sensor Switch Control Low */ +#define CY_CAPSENSE_SM_REG_CSW_CTL_LO_FLD_CSW_FUNC_MODE (0x0uL) + +/* CSW_CTL_HI: CapSense Sensor Switch Control High */ +#define CY_CAPSENSE_SM_REG_CSW_CTL_HI_FLD_CSW_FUNC_MODE (0x0uL) + +/* DFT_CTL Register: DFT control register */ +#define CY_CAPSENSE_SM_REG_DFT_CTL_FLD_DDFT_SEL (0x0uL) + +/******************************************************************************* +* Use default trim bits from SFLASH. Do not override trim registers +*******************************************************************************/ + +/* TRIM_CTL: Trim Control */ +#define CY_CAPSENSE_SM_REG_TRIM_CTL_FLD_TRIM_IN (0x0uL) +#define CY_CAPSENSE_SM_REG_TRIM_CTL_FLD_TRIM_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_TRIM_CTL_FLD_TRIM_POLARITY (0x0uL) + +/* CLK_IMO_TRIM1: Local IMO Trim Register 1 */ +#define CY_CAPSENSE_SM_REG_CLK_IMO_TRIM1_FLD_OFFSET (0x0uL) + +/* CLK_IMO_TRIM2: Local IMO Trim Register 2 */ +#define CY_CAPSENSE_SM_REG_CLK_IMO_TRIM2_FLD_FSOFFSET (0x0uL) + +/* CLK_IMO_TRIM3: Local IMO Trim Register 3 */ +#define CY_CAPSENSE_SM_REG_CLK_IMO_TRIM3_FLD_TCTRIM (0x0uL) + +/* PWR_BG_TRIM1: Bandgap Trim Register 1 */ +#define CY_CAPSENSE_SM_REG_PWR_BG_TRIM1_FLD_REF_VTRIM (0x0uL) + +/* PWR_BG_TRIM2: Bandgap Trim Register 2 */ +#define CY_CAPSENSE_SM_REG_PWR_BG_TRIM2_FLD_REF_ITRIM (0x0uL) + +/* PWR_BG_TRIM3: Bandgap Trim Register 3 */ +#define CY_CAPSENSE_SM_REG_PWR_BG_TRIM3_FLD_REF_TCTRIM (0x0uL) + +/******************************************************************************* +* Sensor HW configuration +*******************************************************************************/ + +/* SNS_SNS_LP_AOS_SNS_CTL0: LP-AoS Sensor Control 0 */ +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL0_FLD_RC_COEFF (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL0_FLD_BL_COEFF_SLOW (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL0_FLD_BL_COEFF_FAST (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL0_FLD_LOW_BL_RESET (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL0_FLD_BL_UPDATE_DELAY (0x0uL) + +/* SNS_SNS_LP_AOS_SNS_CTL1: LP-AoS Sensor Control 1 */ +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL1_FLD_NOISE_THR (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL1_FLD_NOISE_THR_NEG (0x0uL) + +/* SNS_SNS_LP_AOS_SNS_CTL2: LP-AoS Sensor Control 2 */ +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL2_FLD_SIGNAL_THR (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL2_FLD_DEBOUNCE_THRESHOLD (0x3uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL2_FLD_SIGNAL_TYPE (0x0uL) + +/* SNS_SNS_LP_AOS_SNS_CTL3: LP-AoS Sensor Control 3 */ +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL3_FLD_SNS_FRC_SCALED (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL3_FLD_BL_UPDATE_TMR (0x10uL) + +/* SNS_SNS_LP_AOS_SNS_CTL4: LP-AoS Sensor Control 4 */ +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL4_FLD_SNS_BL (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL4_FLD_BL_RESET_TMR (0x30uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_LP_AOS_SNS_CTL4_FLD_SIG_DEBOUNCE_TMR (0x3uL) + +/* SNS_SNS_SCAN_CTL: Sensor Scan Control */ +#define CY_CAPSENSE_SM_REG_SNS_SNS_SCAN_CTL_FLD_NUM_SUB_CONVS (0x1uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_SCAN_CTL_FLD_COMP_DIV (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_SCAN_CTL_FLD_NUM_CONV (0x1uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_SCAN_CTL_FLD_INIT_BYPASS (0x0uL) + +/* SNS_SNS_CDAC_CTL: Sensor CAPDAC Control */ +#define CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_SEL_RE (0x3euL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_SEL_CO (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_SEL_CF (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_FINE_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_CLOCK_REF_RATE (0x1uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_FL_MODE (0x1uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_COMP_BLANKING_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_LFSR_SCALE_FL (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CDAC_CTL_FLD_LFSR_SCALE_TYPE_FL (0x0uL) + +/* SNS_SNS_CTL: Sense Control and Command Register */ +#define CY_CAPSENSE_SM_REG_SNS_SNS_CTL_FLD_START_SCAN (0x1uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CTL_FLD_VALID (0x1uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CTL_FLD_LAST (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CTL_FLD_MULTI_CH_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CTL_FLD_SENSE_MODE_SEL (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CTL_FLD_DECIM_RATE (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CTL_FLD_SENSE_DIV (0x2FuL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CTL_FLD_LFSR_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_SNS_CTL_FLD_LFSR_BITS (0x0uL) + +/* SNS_FRAME_CMD: Frame Command Register */ +#define CY_CAPSENSE_SM_REG_SNS_FRAME_CMD_FLD_START_FRAME (0x0uL) + +/* SNS_CE_CMD: Channel Engine Command */ +#define CY_CAPSENSE_SM_REG_SNS_CE_CMD_FLD_TEST_RAW_COUNT (0x0uL) +#define CY_CAPSENSE_SM_REG_SNS_CE_CMD_FLD_CE_START (0x0uL) + +/* SNS_FIFO_CMD: FIFO Command */ +#define CY_CAPSENSE_SM_REG_SNS_FIFO_CMD_FLD_FIFO_RESET (0x0uL) + +/* SNS_CE_INIT_CTL: Channel Engine Initialization Control */ +#define CY_CAPSENSE_SM_REG_SNS_CE_INIT_CTL_FLD_SENSOR_INIT (0x0uL) + +/******************************************************************************* +* Sensing method specific registers called MODE. +* They corresponds to MODE_STRUCTLP tab. +* Consists 7 registers per each supported mode: +* * MODE0: CSD RM +* * MODE1: CSX RM +* * MODE2: ISX 2 pin Flyback Ext VDDA/2 +* * MODE3: CSD RM with CapDAC dithering +* * MODE4: CSX RM with CapDAC dithering +* * MODE5: ISX RM with CapDAC dithering +* * MODE6: CSD RM + ACTIVE SHIELD +* * MODE7: CSD RM with CapDAC dithering + ACTIVE SHIELD +* * MODE8: CSD RM + PASIVE SHIELD +* * MODE9: CSD RM with CapDAC dithering + PASIVE SHIELD +* * MODE10: CSD MPSC-C or CSD MPSC-D +* * MODE11: CSD MPSC-C or CSD MPSC-D with CapDAC dithering(Dithering only wrt CsP) +* * MODE 12: CMOD/VDDA BIST Balancing Phase. Balancing to VDDA/2 +* * MODE 13: VDDA BIST Balancing Phase. Balancing to VBG +*******************************************************************************/ + +/********************************* CSD RM *************************************/ + +/* CSD RM - MODE0_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* CSD RM - MODE0_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSD RM - MODE0_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSD RM - MODE0_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSD RM - MODE0_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSD RM - MODE0_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_AMUXA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSD RM - MODE0_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_AMUXA (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE0_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************************* CSX RM *************************************/ + +/* CSX RM - MODE1_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE1_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x1uL) + +/* CSX RM - MODE1_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSX RM - MODE1_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSX RM - MODE1_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSX RM - MODE1_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSX RM - MODE1_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_AMUXA (0x2uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSX RM - MODE1_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_AMUXA (0x5uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE1_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************************* ISX RM *************************************/ + +/* ISX RM - MODE2_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* ISX RM - MODE2_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* ISX RM - MODE2_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* ISX RM - MODE2_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* ISX RM - MODE2_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* ISX RM - MODE2_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_AMUXA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* ISX RM - MODE2_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_AMUXA (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE2_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************* CSD RM with CapDAC (With Dithering) ***************************/ + +/* CSD RM w/dither - MODE3_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* CSD RM w/dither - MODE3_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x2uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x6uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSD RM w/dither - MODE3_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSD RM w/dither - MODE3_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSD RM w/dither - MODE3_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSD RM w/dither - MODE3_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_AMUXA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSD RM w/dither - MODE3_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_AMUXA (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE3_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************* CSX RM with CapDAC dithering ***************************/ + +/* CSX RM w/dither - MODE4_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE4_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x1uL) + +/* CSX RM w/dither - MODE4_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x5uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x5uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSX RM w/dither - MODE4_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSX RM w/dither - MODE4_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSX RM w/dither - MODE4_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSX RM w/dither - MODE4_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_AMUXA (0x2uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSX RM w/dither - MODE4_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_AMUXA (0x5uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE4_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************* ISX RM with CapDAC dithering ***************************/ + +/* ISX RM w/dither - MODE5_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* ISX RM w/dither - MODE5_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x5uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x2uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x2uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x5uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* ISX RM w/dither - MODE5_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* ISX RM w/dither - MODE5_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* ISX RM w/dither - MODE5_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* ISX RM w/dither - MODE5_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_AMUXA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* ISX RM w/dither - MODE5_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_AMUXA (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE5_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************* MODE6: CSD RM + ACTIVE SHIELD ***************************/ + +/* CSD RM + ACTIVE SHIELD - MODE6_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* CSD RM + ACTIVE SHIELD - MODE6_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSD RM + ACTIVE SHIELD - MODE6_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSD RM + ACTIVE SHIELD - MODE6_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSD RM + ACTIVE SHIELD - MODE6_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_SOMB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSD RM + ACTIVE SHIELD - MODE6_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD1_FLD_SW_AMUXA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSD RM + ACTIVE SHIELD - MODE6_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD2_FLD_SW_AMUXA (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE6_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************* MODE7: CSD RM with CapDAC dithering + ACTIVE SHIELD ***************************/ + +/* CSD RM w/dither + ACTIVE SHIELD - MODE7_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* CSD RM w/dither + ACTIVE SHIELD - MODE7_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x2uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x6uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSD RM w/dither + ACTIVE SHIELD - MODE7_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSD RM w/dither + ACTIVE SHIELD - MODE7_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSD RM w/dither + ACTIVE SHIELD - MODE7_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_SOMB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSD RM w/dither + ACTIVE SHIELD - MODE7_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD1_FLD_SW_AMUXA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSD RM w/dither + ACTIVE SHIELD - MODE7_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD2_FLD_SW_AMUXA (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE7_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************* MODE8: CSD RM + PASIVE SHIELD ***************************/ + +/* CSD RM + PASIVE SHIELD - MODE8_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* CSD RM + PASIVE SHIELD - MODE8_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSD RM + PASIVE SHIELD - MODE8_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSD RM + PASIVE SHIELD - MODE8_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSD RM + PASIVE SHIELD - MODE8_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSD RM + PASIVE SHIELD - MODE8_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD1_FLD_SW_AMUXA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSD RM + PASIVE SHIELD - MODE8_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD2_FLD_SW_AMUXA (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE8_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************* MODE9: CSD RM with CapDAC dithering + PASIVE SHIELD ***************************/ + +/* CSD RM w/dither + PASIVE SHIELD - MODE9_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* CSD RM w/dither + PASIVE SHIELD - MODE9_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x2uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x6uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSD RM w/dither + PASIVE SHIELD - MODE9_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSD RM w/dither + PASIVE SHIELD - MODE9_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSD RM w/dither + PASIVE SHIELD - MODE9_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSD RM w/dither + PASIVE SHIELD - MODE9_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD1_FLD_SW_AMUXA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSD RM w/dither + PASIVE SHIELD - MODE9_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD2_FLD_SW_AMUXA (0x4uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE9_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/********************************* MODE10: CSD MPSC-C or CSD MPSC-D *************************************/ + +/* CSD MPSC-C or CSD MPSC-D - MODE10_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D - MODE10_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D - MODE10_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D - MODE10_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D - MODE10_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSD MPSC-C or CSD MPSC-D - MODE10_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_AMUXA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D - MODE10_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_AMUXB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE10_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/***************************** MODE11: CSD MPSC-C or CSD MPSC-D with CapDAC dithering *********************************/ + +/* CSD MPSC-C or CSD MPSC-D w/dither - MODE11_SENSE_DUTY_CTL: Sense Clock Duty Cycle Control */ +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH2_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH3_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH0_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_FS2_PH1_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PH_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH0X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_GAP_PH1X_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHX_GAP_2CYCLE_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_SHIFT_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SENSE_DUTY_CTL_FLD_PHASE_MODE_SEL (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D w/dither - MODE11_SW_SEL_CDAC_FL: Flatspot/Dither CAPDAC Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLTCA (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLCB (0x2uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLTV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLTG (0x3uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLBV (0x6uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_SW_FLBG (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D w/dither - MODE11_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_CACC (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_CBCD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_AYA_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_AYA_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D w/dither - MODE11_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPCS1 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPMA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMCS2 (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_CMF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D w/dither - MODE11_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_CBSO (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* CSD MPSC-C or CSD MPSC-D w/dither - MODE11_SW_SEL_CMOD1: CMOD Switch Control 1 */ +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_AMUXA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_C1CA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_C1CC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD1_FLD_DDRV_EN (0x0uL) + +/* CSD MPSC-C or CSD MPSC-D w/dither - MODE11_SW_SEL_CMOD2: CMOD Switch Control 2 */ +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_AMUXB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_C2CB (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_C2CD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE11_SW_SEL_CMOD2_FLD_DDRV_EN (0x0uL) + +/******************************************************************************* +* Specific Base HW block configuration for BIST Cmod and VDDA measurement +* The HW configuration for CMOD/VDDA BIST Balancing Phase +* In Precharge Phase CMOD must be put to GROUND +*******************************************************************************/ + +/* SCAN_CTL2: Scan Control 2 -CMOD/VDDA BIST */ +#define CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_REG_SCAN_CTL2_FLD_NUM_EPI_KREF_DELAY_PRS (0x1uL) +#define CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_REG_SCAN_CTL2_FLD_NUM_EPI_KREF_DELAY (0x1uL) +#define CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_REG_SCAN_CTL2_FLD_CHOP_POL (0x1uL) + +/* IMO_CTL: Local MRSS IMO Control */ +#define CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_IMO_CTL_FREQ (0x6uL) +#define CY_CAPSENSE_BIST_CMOD_VDDA_MEAS_IMO_CTL_CLOCK_MSC_DIV (0x3uL) + +/* CMOD/VDDA BIST Balancing Phase; balance to VDDA/2 - MODE12_SW_SEL_TOP: Top Level Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_CACB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_CACC (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_CBCD (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_AYA_CTL (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_AYA_EN (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_AYB_CTL (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_AYB_EN (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_BYB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_BGRF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_RMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_TOP_FLD_MBF (0x0uL) + +/* CMOD/VDDA BIST Balancing Phase; balance to VDDA/2 - MODE12_SW_SEL_COMP: MSC Comparator Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CPMA (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CPCA (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CPCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CMCB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CPF (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CMCS2 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CMCS4 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CMV (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CMG (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_CMF (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_COMP_FLD_HALF_WAVE_EN (0x0uL) + +/* CMOD/VDDA BIST Balancing Phase; balance to VDDA/2 - MODE12_SW_SEL_SH: Shielding Switch Control */ +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_SOMB (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_CBSO (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_SPCS1 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_SPCS3 (0x0uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_FSP (0x1uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_BUF_SEL (0x7uL) +#define CY_CAPSENSE_SM_REG_MODE12_SW_SEL_SH_FLD_BUF_EN (0x1uL) + +/* SW_SEL_BGR: Bandgap Reference Switch Control */ +#define CY_CAPSENSE_BIST_CMOD_MEAS_SW_SEL_BGR_FLD_SW_BGRCM (0x1uL) +/******************************************************* +* Pin state specific registers. One register per state: +* * CSW_FUNC0: GND +* * CSW_FUNC1: HIGH-Z +* * CSW_FUNC2: CSX RX +* * CSW_FUNC3: CSX TX +* * CSW_FUNC4: CSX NTX +* * CSW_FUNC5: CSD SNS +* * CSW_FUNC6: ISX LX +* * CSW_FUNC7: ISX RX +* * CSW_FUNC8: SHIELD Active +* * CSW_FUNC9: SHIELD Passive +* * CSW_FUNC10: CSX VDDA/2 +* * CSW_FUNC11: MPSC CSP +* * CSW_FUNC12: MPSC CSN +* * CSW_FUNC13: MPSC CSZ +************************************************************************/ + +/*********** SW_SEL_CSW_FUNC0: GND *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_SW_PD (0x1uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_REF_MODE (0x1uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC0_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC1: High-Z *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_REF_MODE (0x1uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC1_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC2: CSX RX *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_SW_AMUXA (0x1uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC2_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC3: CSX TX *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_SW_PU (0x6uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_SW_PD (0x8uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC3_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC4: CSX TX_N *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_SW_PU (0x7uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_SW_PD (0x7uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC4_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC5: CSD *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_SW_AMUXA (0xauL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_SW_PU (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_SW_PD (0x4uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC5_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC6: ISX LX *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_SW_PU (0x4uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_SW_PD (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC6_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC7: ISX RX *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_SW_AMUXA (0xAuL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC7_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC8: CSD SHIELD Active *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_SW_AMUXB (0xauL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_SW_PU (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_SW_PD (0x4uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC8_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC9: CSD SHIELD Passive *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_SW_PU (0x8uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_SW_PD (0x9uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC9_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC10: CSX VDDA/2 *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_SW_AMUXB (0x1uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_SW_PU (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_SW_PD (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_REF_MODE (0x1uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC10_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC11: MPSC-D Positive *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_SW_AMUXA (0x3uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_SW_AMUXB (0x3uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_SW_PU (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_SW_PD (0x4uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC11_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC12: MPSC-D Negative *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_SW_AMUXA (0x4uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_SW_AMUXB (0x4uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_SW_PU (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_SW_PD (0x4uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC12_FLD_DDRV_EN (0x0uL) + +/*********** SW_SEL_CSW_FUNC13: MPSC-D Zero *************/ +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_SW_AMUXA (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_SW_AMUXB (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_SW_PU (0x2uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_SW_PD (0x4uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_REF_MODE (0x0uL) +#define CY_CAPSENSE_SM_REG_SW_SEL_CSW_FUNC13_FLD_DDRV_EN (0x0uL) + +#if defined(__cplusplus) +} +#endif + +#endif /* CY_IP_M0S8MSCV3LP */ + +#endif /* CY_CAPSENSE_SM_BASE_FULL_WAVE_LP_H */ + + +/* [] END OF FILE */ diff --git a/cy_capsense_sm_base_full_wave_v3.h b/cy_capsense_sm_base_full_wave_v3.h index cf1558d..83f55ca 100644 --- a/cy_capsense_sm_base_full_wave_v3.h +++ b/cy_capsense_sm_base_full_wave_v3.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_sm_base_full_wave_v3.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file lists a set of macros for each register bit-field for the specified @@ -352,19 +352,19 @@ extern "C" { /* MODE0_SW_SEL_CDAC_FL Register for CSD SM with CapDAC dithering */ #define CY_CAPSENSE_SM_CSD_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTCA (3uL) #define CY_CAPSENSE_SM_CSD_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLCB (2uL) -#define CY_CAPSENSE_SM_CSD_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTV (2uL) +#define CY_CAPSENSE_SM_CSD_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTV (0uL) #define CY_CAPSENSE_SM_CSD_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTG (3uL) #define CY_CAPSENSE_SM_CSD_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBV (6uL) #define CY_CAPSENSE_SM_CSD_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBG (7uL) #define CY_CAPSENSE_SM_CSD_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0uL) /* MODE0_SW_SEL_CDAC_FL Register for CSX SM with CapDAC dithering */ -#define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTCA (4uL) -#define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLCB (5uL) +#define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTCA (5uL) +#define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLCB (4uL) #define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTV (0uL) #define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLTG (0uL) -#define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBV (2uL) -#define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBG (3uL) +#define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBV (4uL) +#define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_SW_FLBG (5uL) #define CY_CAPSENSE_SM_CSX_DITH_FULL_WAVE_CTRL_MUX_REG_MODE0_SW_SEL_CDAC_FL_FLD_ACTIVATION_MODE (0uL) /* SW_SEL_GPIO Register for CSD SM */ diff --git a/cy_capsense_structure.c b/cy_capsense_structure.c index 54337d6..e5d9069 100644 --- a/cy_capsense_structure.c +++ b/cy_capsense_structure.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_structure.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file defines the data structure global variables and provides the @@ -27,12 +27,17 @@ #include "cy_capsense_selftest.h" #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) #include "cy_csd.h" + #include "cy_capsense_sensing_v2.h" +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_msclp.h" + #include "cy_capsense_generator_lp.h" #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ #include "cy_msc.h" + #include "cy_capsense_generator_v3.h" + #include "cy_capsense_sensing_v3.h" #endif -#include "cycfg_capsense_defines.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) /******************************************************************************* * Local definition @@ -49,6 +54,16 @@ #define CY_CAPSENSE_PARAM_WIDGET_OFFSET (16u) #define CY_CAPSENSE_PARAM_WIDGET_MASK (0xFFuL << CY_CAPSENSE_PARAM_WIDGET_OFFSET) +#if (defined(CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED)) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_PHASE_SELF_ENABLED) + #define CY_CAPSENSE_MPSC_EN (CY_CAPSENSE_ENABLE) + #else + #define CY_CAPSENSE_MPSC_EN (CY_CAPSENSE_DISABLE) + #endif +#else + #define CY_CAPSENSE_MPSC_EN (CY_CAPSENSE_DISABLE) +#endif + /******************************************************************************* * Function Name: Cy_CapSense_IsAnyWidgetActive @@ -61,6 +76,10 @@ * not process widget data but extracts previously processed results * from the \ref group_capsense_structures. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed, +* its status is not taken into account. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -75,15 +94,54 @@ uint32_t Cy_CapSense_IsAnyWidgetActive(const cy_stc_capsense_context_t * context uint32_t capStatus = 0u; uint32_t wdIndex; - for (wdIndex = context->ptrCommonConfig->numWd; wdIndex-- > 0u;) + for (wdIndex = CY_CAPSENSE_TOTAL_WIDGET_COUNT; wdIndex-- > 0u;) { - capStatus |= (uint32_t)context->ptrWdContext[wdIndex].status & CY_CAPSENSE_WD_ACTIVE_MASK; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != context->ptrWdConfig[wdIndex].wdType) + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + { + capStatus |= (uint32_t)context->ptrWdContext[wdIndex].status & CY_CAPSENSE_WD_ACTIVE_MASK; + } } return capStatus; } +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) +/******************************************************************************* +* Function Name: Cy_CapSense_IsAnyLpWidgetActive +****************************************************************************//** +* +* Reports whether any low power widget has detected a touch at the previous +* low power scan. +* +* This function reports whether any low power widget has detected a touch +* by extracting information from the common status register. The function does +* not process the widget data but extracts the result obtained at the previous +* low power widget scan. The result remains set up to the next low power widget +* scan and is reset with the low power scan start. +* +* \note +* This function is available only for the fifth-generation low power CAPSENSE™. +* +* \param context +* The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the touch detection status of all the widgets: +* - Zero - No touch is detected in any of the low power widgets or sensors +* - CY_CAPSENSE_MW_STATE_LP_ACTIVE_MASK - At least one low power widget or sensor +* has detected a touch at the previous scan +* +*******************************************************************************/ +uint32_t Cy_CapSense_IsAnyLpWidgetActive(const cy_stc_capsense_context_t * context) +{ + return ((uint32_t)context->ptrCommonContext->status & CY_CAPSENSE_MW_STATE_LP_ACTIVE_MASK); +} +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + + /******************************************************************************* * Function Name: Cy_CapSense_IsWidgetActive ****************************************************************************//** @@ -99,6 +157,9 @@ uint32_t Cy_CapSense_IsAnyWidgetActive(const cy_stc_capsense_context_t * context * Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed and a zero is returned. +* * \param context * The pointer to the CAPSENSE™ context structure \ref cy_stc_capsense_context_t. * @@ -116,9 +177,14 @@ uint32_t Cy_CapSense_IsWidgetActive( { uint32_t capStatus = 0uL; - if (widgetId < context->ptrCommonConfig->numWd) + if (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) { - capStatus = (uint32_t)context->ptrWdContext[widgetId].status & CY_CAPSENSE_WD_ACTIVE_MASK; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != context->ptrWdConfig[widgetId].wdType) + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + { + capStatus = (uint32_t)context->ptrWdContext[widgetId].status & CY_CAPSENSE_WD_ACTIVE_MASK; + } } return capStatus; } @@ -143,6 +209,9 @@ uint32_t Cy_CapSense_IsWidgetActive( * Specifies the ID number of the widget. A macro for the widget ID can be found * in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. * +* \note For the fifth-generation low power CAPSENSE™ widgets +* of the \ref CY_CAPSENSE_WD_LOW_POWER_E type are not processed and a zero is returned. +* * \param sensorId * Specifies the ID number of the sensor within the widget. A macro for the * sensor ID within a specified widget can be found in the cycfg_capsense.h @@ -167,9 +236,12 @@ uint32_t Cy_CapSense_IsSensorActive( { uint32_t capStatus = 0uL; - if (widgetId < context->ptrCommonConfig->numWd) + if ((widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) && + (sensorId < context->ptrWdConfig[widgetId].numSns)) { - if (sensorId < context->ptrWdConfig[widgetId].numSns) + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E != context->ptrWdConfig[widgetId].wdType) + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ { capStatus = context->ptrWdConfig[widgetId].ptrSnsContext[sensorId].status; } @@ -178,7 +250,7 @@ uint32_t Cy_CapSense_IsSensorActive( } -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) /******************************************************************************* * Function Name: Cy_CapSense_IsProximitySensorActive ****************************************************************************//** @@ -219,7 +291,7 @@ uint32_t Cy_CapSense_IsProximitySensorActive( { uint32_t capStatus = 0uL; - if (widgetId < context->ptrCommonConfig->numWd) + if (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) { if ((uint8_t)CY_CAPSENSE_WD_PROXIMITY_E == context->ptrWdConfig[widgetId].wdType) { @@ -235,9 +307,9 @@ uint32_t Cy_CapSense_IsProximitySensorActive( #endif /* (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) */ -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MATRIX_EN) ||\ - (CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN)) +#if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MATRIX_EN) ||\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN)) /******************************************************************************* * Function Name: Cy_CapSense_GetTouchInfo ****************************************************************************//** @@ -269,7 +341,7 @@ cy_stc_capsense_touch_t * Cy_CapSense_GetTouchInfo( const cy_stc_capsense_widget_config_t * ptrWdCfg; - if (widgetId < context->ptrCommonConfig->numWd) + if (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) { ptrWdCfg = &context->ptrWdConfig[widgetId]; switch (ptrWdCfg->wdType) @@ -319,7 +391,7 @@ cy_capsense_status_t Cy_CapSense_CheckConfigIntegrity(const cy_stc_capsense_cont const cy_stc_capsense_widget_config_t * ptrWdCfg = context->ptrWdConfig; const cy_stc_capsense_widget_context_t * ptrWdCxt = context->ptrWdContext; const cy_stc_capsense_pin_config_t * ptrPinCfg = context->ptrPinConfig; - const cy_stc_active_scan_sns_t * ptrActScanSns = context->ptrActiveScanSns; + const cy_stc_capsense_active_scan_sns_t * ptrActScanSns = context->ptrActiveScanSns; if (ptrCommonCfg == NULL) {capStatus = CY_CAPSENSE_STATUS_BAD_DATA;} if (ptrCommonCxt == NULL) {capStatus = CY_CAPSENSE_STATUS_BAD_DATA;} @@ -329,7 +401,7 @@ cy_capsense_status_t Cy_CapSense_CheckConfigIntegrity(const cy_stc_capsense_cont if (ptrPinCfg == NULL) {capStatus = CY_CAPSENSE_STATUS_BAD_DATA;} if (ptrActScanSns == NULL) {capStatus = CY_CAPSENSE_STATUS_BAD_DATA;} - return (capStatus); + return capStatus; } @@ -422,58 +494,87 @@ uint16_t Cy_CapSense_GetCrcWidget( { uint16_t crcValue; const cy_stc_capsense_widget_context_t * ptrWdCxt; - const cy_stc_capsense_widget_config_t * ptrWdCfg; cy_stc_capsense_widget_crc_data_t crcDataVal; - - /* Get a pointer to the specified widget config structure */ - ptrWdCfg = &context->ptrWdConfig[widgetId]; + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; + #endif /* Get a pointer to the specified widget context structure */ ptrWdCxt = &context->ptrWdContext[widgetId]; (void)memset((void*)&crcDataVal, 0, sizeof(crcDataVal)); - crcDataVal.fingerCapVal = ptrWdCxt->fingerCap; - crcDataVal.sigPFCVal = ptrWdCxt->sigPFC; - crcDataVal.lowBslnRstVal = ptrWdCxt->lowBslnRst; - crcDataVal.snsClkVal = ptrWdCxt->snsClk; - crcDataVal.rowSnsClkVal = ptrWdCxt->rowSnsClk; - crcDataVal.onDebounceVal = ptrWdCxt->onDebounce; - crcDataVal.snsClkSourceVal = ptrWdCxt->snsClkSource; + crcDataVal.fingerCapVal = ptrWdCxt->fingerCap; + crcDataVal.sigPFCVal = ptrWdCxt->sigPFC; + crcDataVal.lowBslnRstVal = ptrWdCxt->lowBslnRst; + crcDataVal.snsClkVal = ptrWdCxt->snsClk; + crcDataVal.rowSnsClkVal = ptrWdCxt->rowSnsClk; + crcDataVal.onDebounceVal = ptrWdCxt->onDebounce; + crcDataVal.snsClkSourceVal = ptrWdCxt->snsClkSource; + crcDataVal.maxRawCountVal = ptrWdCxt->maxRawCount; + crcDataVal.maxRawCountRowVal = ptrWdCxt->maxRawCountRow; + crcDataVal.bslnCoeffVal = ptrWdCxt->bslnCoeff; - if((CY_CAPSENSE_CSX_GROUP == ptrWdCfg->senseMethod) || - (CY_CAPSENSE_CSD_SS_DIS == context->ptrCommonConfig->csdAutotuneEn)) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_SMARTSENSE_FULL_EN) + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MPSC_EN) + if ((CY_CAPSENSE_CSD_GROUP != ptrWdCfg->senseMethod) || + ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType) || + (ptrWdCfg->mpOrder >= CY_CAPSENSE_MPSC_MIN_ORDER)) + #else + if ((CY_CAPSENSE_CSD_GROUP != ptrWdCfg->senseMethod) || + ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == ptrWdCfg->wdType)) + #endif + #endif { - crcDataVal.fingerThVal = ptrWdCxt->fingerTh; - crcDataVal.proxThVal = ptrWdCxt->proxTh; - crcDataVal.noiseThVal = ptrWdCxt->noiseTh; - crcDataVal.nNoiseThVal = ptrWdCxt->nNoiseTh; - crcDataVal.hysteresisVal = ptrWdCxt->hysteresis; + crcDataVal.fingerThVal = ptrWdCxt->fingerTh; + crcDataVal.proxThVal = ptrWdCxt->proxTh; + crcDataVal.noiseThVal = ptrWdCxt->noiseTh; + crcDataVal.nNoiseThVal = ptrWdCxt->nNoiseTh; + crcDataVal.hysteresisVal = ptrWdCxt->hysteresis; } #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) - crcDataVal.resolutionVal = ptrWdCxt->resolution; - crcDataVal.idacModVal[0u] = ptrWdCxt->idacMod[0u]; - crcDataVal.idacModVal[1u] = ptrWdCxt->idacMod[1u]; - crcDataVal.idacModVal[2u] = ptrWdCxt->idacMod[2u]; - crcDataVal.idacGainIndexVal = ptrWdCxt->idacGainIndex; + crcDataVal.resolutionVal = ptrWdCxt->resolution; + crcDataVal.idacModVal[0u] = ptrWdCxt->idacMod[0u]; + crcDataVal.idacModVal[1u] = ptrWdCxt->idacMod[1u]; + crcDataVal.idacModVal[2u] = ptrWdCxt->idacMod[2u]; + crcDataVal.idacGainIndexVal = ptrWdCxt->idacGainIndex; crcDataVal.rowIdacModVal[0u] = ptrWdCxt->rowIdacMod[0u]; crcDataVal.rowIdacModVal[1u] = ptrWdCxt->rowIdacMod[1u]; crcDataVal.rowIdacModVal[2u] = ptrWdCxt->rowIdacMod[2u]; #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - crcDataVal.resolutionVal = ptrWdCxt->numSubConversions; - crcDataVal.cdacRef = ptrWdCxt->cdacRef; - crcDataVal.rowCdacRef = ptrWdCxt->rowCdacRef; - crcDataVal.cdacCompDivider = ptrWdCxt->cdacCompDivider; - crcDataVal.cicRate = ptrWdCxt->cicRate; - crcDataVal.lfsrBits = ptrWdCxt->lfsrBits; + crcDataVal.cdacDitherEnVal = ptrWdCxt->cdacDitherEn; + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + crcDataVal.cicShiftVal = ptrWdCxt->cicShift; + crcDataVal.rowCicShiftVal = ptrWdCxt->rowCicShift; #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + crcDataVal.resolutionVal = ptrWdCxt->numSubConversions; + crcDataVal.cdacRefVal = ptrWdCxt->cdacRef; + crcDataVal.rowCdacRefVal = ptrWdCxt->rowCdacRef; + crcDataVal.cdacCompDividerVal = ptrWdCxt->cdacCompDivider; + crcDataVal.cicRateVal = ptrWdCxt->cicRate; + crcDataVal.lfsrBitsVal = ptrWdCxt->lfsrBits; + crcDataVal.cdacDitherValueVal = ptrWdCxt->cdacDitherValue; + crcDataVal.coarseInitBypassEnVal = ptrWdCxt->coarseInitBypassEn; + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) && \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_FINE_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_FINE_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_FINE_EN))) + crcDataVal.cdacFineVal = ptrWdCxt->cdacFine; + crcDataVal.rowCdacFineVal = ptrWdCxt->rowCdacFine; + #endif + crcValue = Cy_CapSense_GetCRC((uint8_t *)(&crcDataVal), sizeof(crcDataVal)); - return (crcValue); + return crcValue; } @@ -487,7 +588,7 @@ uint16_t Cy_CapSense_GetCrcWidget( * argument. The paramId for each register of cy_capsense_tuner is available * in the cycfg_capsense.h file as CY_CAPSENSE__PARAM_ID. * The paramId is a special enumerated value generated by the CAPSENSE™ -* Configurator. The format of paramId is as follows: +* Configurator tool. The format of paramId is as follows: * 1. [ byte 3 byte 2 byte 1 byte 0 ] * 2. [ RRRRRUTT IIIIIIII MMMMMMMM LLLLLLLL ] * 3. U - indicates if the parameter affects the RAM Widget Object CRC. @@ -509,7 +610,7 @@ uint16_t Cy_CapSense_GetCrcWidget( * * \param ptrTuner * The pointer to the cy_capsense_tuner variable of cy_stc_capsense_tuner_t. -* The cy_capsense_tuner is declared in CAPSENSE™ Configurator generated files: +* The cy_capsense_tuner is declared in CAPSENSE™ Configurator tool generated files: * * cycfg_capsense.c/h * * \param context @@ -584,7 +685,7 @@ cy_capsense_status_t Cy_CapSense_GetParam( * argument. The paramId for each register of cy_capsense_tuner is available * in the cycfg_capsense.h file as CY_CAPSENSE__PARAM_ID. * The paramId is a special enumerated value generated by the CAPSENSE™ -* Configurator. The format of paramId is as follows: +* Configurator tool. The format of paramId is as follows: * 1. [ byte 3 byte 2 byte 1 byte 0 ] * 2. [ RRRRRUTT IIIIIIII MMMMMMMM LLLLLLLL ] * 3. U - indicates if the parameter affects the RAM Widget Object CRC. @@ -614,7 +715,7 @@ cy_capsense_status_t Cy_CapSense_GetParam( * * \param ptrTuner * The pointer to the cy_capsense_tuner variable of cy_stc_capsense_tuner_t. -* The cy_capsense_tuner is declared in CAPSENSE™ Configurator generated files: +* The cy_capsense_tuner is declared in CAPSENSE™ Configurator tool generated files: * * cycfg_capsense.c/h * * \param context @@ -661,8 +762,7 @@ cy_capsense_status_t Cy_CapSense_SetParam( (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_WDGT_CRC_EN)) paramCrc = (paramId & CY_CAPSENSE_PARAM_CRC_MASK) >> CY_CAPSENSE_PARAM_CRC_OFFSET; paramWidget = (paramId & CY_CAPSENSE_PARAM_WIDGET_MASK) >> CY_CAPSENSE_PARAM_WIDGET_OFFSET; - if ((paramWidget > context->ptrCommonConfig->numWd) && - (0u != paramCrc)) + if ((paramWidget > context->ptrCommonConfig->numWd) && (0u != paramCrc)) { capStatus = CY_CAPSENSE_STATUS_BAD_PARAM; } @@ -716,7 +816,301 @@ cy_capsense_status_t Cy_CapSense_SetParam( } -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +/******************************************************************************* +* Function Name: Cy_CapSense_SetWidgetStatus +****************************************************************************//** +* +* Performs configuring of the selected widget. +* +* This function performs customized widget status configuration +* by the mode parameter. There are two general use cases for this function: +* 1. Make the specified widget Enabled/Disabled. This status is intended +* to define a set of widgets to be scanned/processed from the application +* layer. +* 2. Make the specified widget Working/Non-working. This status is +* integrated into the built-in self-test (BIST) library. If a test detects +* non-working widget, that widget status is set to non-working automatically +* by CAPSENSE™. BIST never resets a widget working mask and the user +* makes a decision what to do next with this non-working widget. +* +* Although other statuses can be changed by this function, this is not +* recommended to avoid impact on CAPSENSE™ operation and +* is needed to implement only specific use cases. +* +* By default, all widgets are enabled and working during CAPSENSE™ +* initialization. All disabled or non-working widgets are excluded +* from scanning and processing. +* +* Excluding a widget from a scanning flow happens +* immediately by re-generation a new scanning frame. This function does it +* for optimization, which means that scanning functions save +* CPU time by checking if any widget status was changed. +* +* Excluding from processing flow happens inside the process functions since they +* perform processing by widgets and not by slots. Therefore, changing +* the widget status should happen before a new scan and/or after processing. +* +* The Cy_CapSense_ProcessWidgetExt() and Cy_CapSense_ProcessSensorExt() +* functions ignore widget disable and non-working statuses and perform +* processing based on specified mode provided to those functions. +* +* The function also checks if there is at least one enabled and working widget. +* If no valid widgets are left for scanning, the function returns +* CY_CAPSENSE_STATUS_BAD_CONFIG separately for active and low-power +* widgets due to these groups' independent scanning frames. +* +* \note +* For the fifth generation and fifth-generation low power CAPSENSE™, +* if the specified widget has the enabled multi-frequency scan feature, +* then the status configuration happens to all the joined widgets: +* * Sub-widget channel 2 +* * Sub-widget channel 1 +* * Main widget channel 0 +* +* \param widgetId +* Specifies the widget ID number. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param mode +* Specifies the bit mask of widget status to be configured. It is allowed +* to configure several bits simultaneously. +* 1. Bit [0] - CY_CAPSENSE_WD_ACTIVE_MASK +* 2. Bit [1] - CY_CAPSENSE_WD_ENABLE_MASK +* 3. Bit [2] - CY_CAPSENSE_WD_WORKING_MASK +* 4. Bit [3] - CY_CAPSENSE_WD_MAXCOUNT_CALC_MASK +* 5. Bit [4] - CY_CAPSENSE_WD_MAXCOUNT_ROW_CALC_MASK. +* +* \param mask +* Specifies the value to be configured. All bit values not set by +* the mode parameter are ignored. +* +* \param context +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the widget processing operation: +* - CY_CAPSENSE_STATUS_SUCCESS - The operation is successful. +* - CY_CAPSENSE_STATUS_BAD_PARAM - The input parameter is invalid. +* +*******************************************************************************/ +cy_capsense_status_t Cy_CapSense_SetWidgetStatus( + uint32_t widgetId, + uint32_t mode, + uint32_t mask, + cy_stc_capsense_context_t * context) +{ + cy_capsense_status_t capStatus = CY_CAPSENSE_STATUS_BAD_CONFIG; + #if (((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) &&\ + (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN)) + const cy_stc_capsense_widget_config_t * ptrWdCfg = context->ptrWdConfig; + uint32_t wdIndex; + #endif + + /* Check parameter validity */ + if (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) + { + capStatus = CY_CAPSENSE_STATUS_SUCCESS; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + context->ptrWdContext[widgetId].status &= (uint8_t)~(uint8_t)mode; + context->ptrWdContext[widgetId].status |= ((uint8_t)mask & (uint8_t)mode); + (void)Cy_CapSense_SwitchSensingMode(CY_CAPSENSE_UNDEFINED_GROUP, context); + #else + /* Update scan flags for MSC platforms */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + context->ptrInternalContext->repeatScanEn = CY_CAPSENSE_DISABLE; + context->ptrCommonContext->status &= (uint32_t)~((uint32_t)CY_CAPSENSE_MW_STATE_WD_SCAN_MASK); + #endif + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_MULTI_FREQUENCY_WIDGET_EN) + /* Checks if MFS is enabled for particular widget */ + if (0u != (ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_EN_MASK)) + { + wdIndex = widgetId - (((uint32_t)ptrWdCfg->mfsConfig & CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_MASK) >> CY_CAPSENSE_MFS_WIDGET_FREQ_ALL_CH_POS); + context->ptrWdContext[wdIndex].status &= (uint8_t)~(uint8_t)mode; + context->ptrWdContext[wdIndex].status |= ((uint8_t)mask & (uint8_t)mode); + context->ptrWdContext[wdIndex + CY_CAPSENSE_MFS_CH1_INDEX].status &= (uint8_t)~(uint8_t)mode; + context->ptrWdContext[wdIndex + CY_CAPSENSE_MFS_CH1_INDEX].status |= ((uint8_t)mask & (uint8_t)mode); + context->ptrWdContext[wdIndex + CY_CAPSENSE_MFS_CH2_INDEX].status &= (uint8_t)~(uint8_t)mode; + context->ptrWdContext[wdIndex + CY_CAPSENSE_MFS_CH2_INDEX].status |= ((uint8_t)mask & (uint8_t)mode); + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + Cy_CapSense_SetSnsFrameValidity(wdIndex, context); + Cy_CapSense_SetSnsFrameValidity(wdIndex + CY_CAPSENSE_MFS_CH1_INDEX, context); + Cy_CapSense_SetSnsFrameValidity(wdIndex + CY_CAPSENSE_MFS_CH2_INDEX, context); + #endif + } + else + { + context->ptrWdContext[widgetId].status &= (uint8_t)~(uint8_t)mode; + context->ptrWdContext[widgetId].status |= ((uint8_t)mask & (uint8_t)mode); + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + Cy_CapSense_SetSnsFrameValidity(widgetId, context); + #endif + } + #else + context->ptrWdContext[widgetId].status &= (uint8_t)~(uint8_t)mode; + context->ptrWdContext[widgetId].status |= ((uint8_t)mask & (uint8_t)mode); + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + Cy_CapSense_SetSnsFrameValidity(widgetId, context); + #endif + #endif + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + context->ptrInternalContext->scanSingleSlot = CY_CAPSENSE_SCAN_MULTIPLE_SLOT; + #if (CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN == CY_CAPSENSE_SCAN_MODE) + (void)Cy_CapSense_ConfigureDmaArrays(context); + #endif + #endif + #endif + } + + return capStatus; +} + + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) +/******************************************************************************* +* Function Name: Cy_CapSense_SetSnsFrameValidity +****************************************************************************//** +* +* Performs sensor frame update for the specified widget. +* +* For the fifth generation and fifth-generation low power CAPSENSE™, +* if the specified widget has the enabled multi-frequency scan feature, +* then the frame update happens to the specified widget Id only. +* +* \param widgetId +* Specifies the widget ID number. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param context +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. +* +*******************************************************************************/ +void Cy_CapSense_SetSnsFrameValidity( + uint32_t widgetId, + cy_stc_capsense_context_t * context) +{ + uint32_t wdStatus = 0u; + uint32_t * ptrSnsFrmCxt; + uint32_t snsIndex; + const cy_stc_capsense_widget_config_t * ptrWdCfg = &context->ptrWdConfig[widgetId]; + uint32_t frameSize = CY_CAPSENSE_SENSOR_FRAME_SIZE; + + ptrSnsFrmCxt = &context->ptrSensorFrameContext[ + (ptrWdCfg->firstSlotId * frameSize) + CY_CAPSENSE_SNS_CTL_INDEX]; + + #if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_LP_EN) + if ((uint8_t)CY_CAPSENSE_WD_LOW_POWER_E == (ptrWdCfg->wdType)) + { + frameSize = CY_MSCLP_11_SNS_REGS; + ptrSnsFrmCxt = &context->ptrSensorFrameLpContext[ + (ptrWdCfg->firstSlotId * frameSize) + CY_CAPSENSE_FRM_LP_SNS_CTL_INDEX]; + } + #endif + + if (0u != Cy_CapSense_IsWidgetEnabled(widgetId, context)) + { + wdStatus = MSCLP_SNS_SNS_CTL_VALID_Msk; + } + + /* Update sensor frame structure */ + for (snsIndex = 0u; snsIndex < ptrWdCfg->numSns; snsIndex++) + { + *ptrSnsFrmCxt &= (uint32_t)~MSCLP_SNS_SNS_CTL_VALID_Msk; + *ptrSnsFrmCxt |= wdStatus; + ptrSnsFrmCxt = &ptrSnsFrmCxt[frameSize]; + } +} +#endif /* #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + + +/******************************************************************************* +* Function Name: Cy_CapSense_IsWidgetEnabled +****************************************************************************//** +* +* Returns widget enable/working status. +* +* \param widgetId +* Specifies the widget ID number. A macro for the widget ID can be found +* in the cycfg_capsense.h file defined as CY_CAPSENSE__WDGT_ID. +* +* \param context +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the widget: +* - Zero - The specified widget is disabled and / or non-working or +* the specified parameter is invalid. +* - Non-zero - The specified widget is enabled and working. +* +*******************************************************************************/ +uint32_t Cy_CapSense_IsWidgetEnabled( + uint32_t widgetId, + const cy_stc_capsense_context_t * context) +{ + uint32_t capStatus = 0u; + + if (widgetId < CY_CAPSENSE_TOTAL_WIDGET_COUNT) + { + if ((CY_CAPSENSE_WD_ENABLE_MASK | CY_CAPSENSE_WD_WORKING_MASK) == + (context->ptrWdContext[widgetId].status & + (CY_CAPSENSE_WD_ENABLE_MASK | CY_CAPSENSE_WD_WORKING_MASK))) + { + capStatus = 1u; + } + } + return capStatus; +} + + +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) +/******************************************************************************* +* Function Name: Cy_CapSense_IsSlotEnabled +****************************************************************************//** +* +* Returns slot enable/working status. +* +* \param slotId +* Specifies the slot ID number. +* +* \param context +* The pointer to the CAPSENSE™ context +* structure \ref cy_stc_capsense_context_t. +* +* \return +* Returns the status of the specified slot: +* - Zero - The specified slot has disabled and / or non-working widgets on all +* channels or the specified parameter is invalid. +* - Non-zero - The specified slot has at least one widget enabled and working. +* +*******************************************************************************/ +uint32_t Cy_CapSense_IsSlotEnabled( + uint32_t slotId, + const cy_stc_capsense_context_t * context) +{ + uint32_t capStatus = 0u; + uint32_t wdIndex; + uint32_t chIndex; + + for (chIndex = 0u; chIndex < CY_CAPSENSE_TOTAL_CH_NUMBER; chIndex++) + { + wdIndex = context->ptrScanSlots[(chIndex * CY_CAPSENSE_SLOT_COUNT) + slotId].wdId; + if (CY_CAPSENSE_SLOT_SHIELD_ONLY > wdIndex) + { + if (0u != Cy_CapSense_IsWidgetEnabled(wdIndex, context)) + { + capStatus = 1u; + break; + } + } + } + return capStatus; +} +#endif + + +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ /* [] END OF FILE */ diff --git a/cy_capsense_structure.h b/cy_capsense_structure.h index f11dd09..f01e49e 100644 --- a/cy_capsense_structure.h +++ b/cy_capsense_structure.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_structure.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the top-level declarations of the CAPSENSE™ data @@ -27,11 +27,13 @@ #include "cy_capsense_common.h" #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) #include "cy_csd.h" +#elif (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + #include "cy_msclp.h" #else /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ #include "cy_msc.h" #endif -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if defined(__cplusplus) extern "C" { @@ -61,11 +63,18 @@ typedef enum CY_CAPSENSE_TU_CMD_NONE_E = 0u, /**< No command */ CY_CAPSENSE_TU_CMD_SUSPEND_E = 1u, /**< Suspend command */ CY_CAPSENSE_TU_CMD_RESUME_E = 2u, /**< Resume command switches state from suspend to running */ - CY_CAPSENSE_TU_CMD_RESTART_E = 3u, /**< Restart command requests to perform CAPSENSE™ re-initialization */ + CY_CAPSENSE_TU_CMD_RESTART_E = 3u, /**< Restart command requests to perform CAPSENSE™ re-initialization and switches state to running */ CY_CAPSENSE_TU_CMD_RUN_SNR_TEST_E = 4u, /**< Reserved */ CY_CAPSENSE_TU_CMD_PING_E = 5u, /**< Ping command to check whether application program calls Cy_CapSense_RunTuner() */ CY_CAPSENSE_TU_CMD_ONE_SCAN_E = 6u, /**< Execute one scan cycle and then switch to suspend state */ CY_CAPSENSE_TU_CMD_WRITE_E = 7u, /**< Writes specified data with offset into cy_capsense_tuner */ + CY_CAPSENSE_TU_CMD_COMM_DIS_E = 8u, /**< Disables the communication mode (used in the fifth-generation low power CAPSENSE™ only): + * * Low power sensors rawcounts does not copied to communication structure + * * Communication of CapSense data structure to Tuner does not happen (in case of UART or protocol-agnostic method) */ + CY_CAPSENSE_TU_CMD_COMM_EN_E = 9u, /**< Enables the communication mode (used in the fifth-generation low power CAPSENSE™ only): + * * Low power sensors rawcounts are copied to communication structure + * * Data is transferred to Tuner (in case of UART or protocol-agnostic method) */ + CY_CAPSENSE_TU_CMD_RESTART_ONLY_E = 10u, /**< Restart command requests to perform CAPSENSE™ re-initialization and keeps state unchanged */ } cy_en_capsense_tuner_cmd_t; /** Defines widget types */ @@ -77,6 +86,7 @@ typedef enum CY_CAPSENSE_WD_MATRIX_BUTTON_E = 0x04u, /**< Matrix Buttons widget */ CY_CAPSENSE_WD_TOUCHPAD_E = 0x05u, /**< Touchpad widget */ CY_CAPSENSE_WD_PROXIMITY_E = 0x06u, /**< Proximity widget */ + CY_CAPSENSE_WD_LOW_POWER_E = 0x07u, /**< Low Power widget, used in the fifth-generation low power CAPSENSE™ only */ } cy_en_capsense_widget_type_t; /** Defines CAPSENSE™ return statuses types */ @@ -122,7 +132,7 @@ typedef enum /** Defines HW configurations types for BIST operations */ typedef enum { - CY_CAPSENSE_BIST_HW_UNDEFINED_E = 0x00u, /**< Initialization or releasing the CSD HW block */ + CY_CAPSENSE_BIST_HW_UNDEFINED_E = 0x00u, /**< Initialization or releasing of the CAPSENSE™ HW block */ CY_CAPSENSE_BIST_HW_SHORT_E = 0x01u, /**< Short tests */ CY_CAPSENSE_BIST_HW_ELTD_CAP_E = 0x02u, /**< Sensor and shield electrodes capacitance measurements with disabled shield */ CY_CAPSENSE_BIST_HW_EXTERNAL_CAP_E = 0x03u, /**< External capacitors capacitance measurements */ @@ -145,6 +155,8 @@ typedef enum * The HSIOM is set to CSD shield connection. */ CY_CAPSENSE_BIST_IO_STRONG_HIGH_E = 0x05u, /**< The drive mode is set to Strong in off - High. * The HSIOM is set to GPIO */ + CY_CAPSENSE_BIST_IO_VDDA2_E = 0x06u, /**< The drive mode is set to High-Z/Strong in off. + * The HSIOM is set to VDDA/2 */ } cy_en_capsense_bist_io_state_t; @@ -153,7 +165,7 @@ typedef enum { CY_CAPSENSE_BIST_SUCCESS_E = 0x00u, /**< The success test status */ CY_CAPSENSE_BIST_BAD_PARAM_E = 0x01u, /**< The bad input parameters test status */ - CY_CAPSENSE_BIST_HW_BUSY_E = 0x02u, /**< The CSD HW block is busy by previous operation */ + CY_CAPSENSE_BIST_HW_BUSY_E = 0x02u, /**< The CAPSENSE™ HW block is busy by previous operation */ CY_CAPSENSE_BIST_LOW_LIMIT_E = 0x03u, /**< The status for a low limit reached during the test */ CY_CAPSENSE_BIST_HIGH_LIMIT_E = 0x04u, /**< The status for a high limit reached during the test */ CY_CAPSENSE_BIST_ERROR_E = 0x05u, /**< The status for an error occurred during the test. @@ -224,8 +236,8 @@ typedef struct uint16_t bsln; /**< Sensor baseline */ uint16_t diff; /**< Sensor difference count */ uint8_t status; /**< Sensor status, contains masks: - * * bit[0] - Sensor Touched (CY_CAPSENSE_SNS_TOUCH_STATUS_MASK) - * * bit[1] - Proximity Sensor Touched (CY_CAPSENSE_SNS_PROX_STATUS_MASK) + * * bit[0] - Regular Sensor Touched (CY_CAPSENSE_SNS_TOUCH_STATUS_MASK) or Proximity Sensor is active (CY_CAPSENSE_SNS_PROX_STATUS_MASK) + * * bit[1] - Proximity Sensor Touched (CY_CAPSENSE_SNS_TOUCH_PROX_STATUS_MASK) * * bit[2] - Overflow during scanning (CY_CAPSENSE_SNS_OVERFLOW_MASK) */ uint8_t negBslnRstCnt; /**< Negative baseline reset counter */ #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) @@ -234,11 +246,11 @@ typedef struct */ #endif uint8_t bslnExt; /**< Sensor baseline fractional */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) uint8_t cdacComp; /**< Compensation CDAC - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - #endif + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ } cy_stc_capsense_sensor_context_t; /** CSX Touchpad touch tracking history */ @@ -307,7 +319,8 @@ typedef struct * * 1 - touch reported immediately as soon as detected * * 2 - touch reported on the second consecutive detection * * 3 - touch reported on the third consecutive detection */ - uint8_t snsClkSource; /**< Widget clock source: + uint8_t snsClkSource; /**< Widget clock source. + * For fourth-generation CAPSENSE™: * * bit[7] - Indicates auto mode of clock source selection * * bit[0:6] - Clock source: * * 0 - Direct (CY_CAPSENSE_CLK_SOURCE_DIRECT) @@ -316,7 +329,16 @@ typedef struct * * 3 - SSC9 (CY_CAPSENSE_CLK_SOURCE_SSC9) * * 4 - SSC10 (CY_CAPSENSE_CLK_SOURCE_SSC10) * * 5 - PRS8 (CY_CAPSENSE_CLK_SOURCE_PRS8) - * * 6 - PRS12 (CY_CAPSENSE_CLK_SOURCE_PRS12) */ + * * 6 - PRS12 (CY_CAPSENSE_CLK_SOURCE_PRS12) + * + * For fifth-generation and fifth-generation low power CAPSENSE™: + * bit[3] - Indicates auto mode of PRS clock source + * bit[2] - Indicates auto mode of SSC clock source + * * bit[0:1] - Clock source: + * * 0 - Direct (CY_CAPSENSE_CLK_SOURCE_DIRECT) + * * 1 - SSC (CY_CAPSENSE_CLK_SOURCE_SSC) + * * 2 - PRS (CY_CAPSENSE_CLK_SOURCE_PRS) + */ #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) uint8_t idacMod[CY_CAPSENSE_MAX_SUPPORTED_FREQ_NUM]; /**< Sets the current of the modulation IDAC for the CSD widgets. * For the CSD Touchpad and Matrix Button widgets sets the current of the @@ -332,39 +354,65 @@ typedef struct uint8_t bslnCoeff; /**< Baseline IIR filter coefficient. Lower value leads to higher filtering. */ uint8_t status; /**< Contains masks: * * bit[0] - Widget Active (CY_CAPSENSE_WD_ACTIVE_MASK) - * * bit[1] - Widget Disabled (CY_CAPSENSE_WD_DISABLE_MASK) - * * bit[2] - Widget Working (CY_CAPSENSE_WD_WORKING_MASK) */ + * * bit[1] - Widget Enable (CY_CAPSENSE_WD_ENABLE_MASK) + * * bit[2] - Widget Working (CY_CAPSENSE_WD_WORKING_MASK) + * * bit[3] - Widget maximum raw count calculation enabled (CY_CAPSENSE_WD_MAXCOUNT_CALC_MASK) + * * bit[4] - Widget row maximum raw count calculation enable (CY_CAPSENSE_WD_MAXCOUNT_ROW_CALC_MASK) */ cy_stc_capsense_touch_t wdTouch; /**< Widget touch structure used for Matrix Buttons, Sliders, and Touchpads */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) uint16_t numSubConversions; /**< Number of sub-conversions in a scan - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ uint8_t cdacRef; /**< Sets the capacitance of the reference CDAC - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - uint8_t rowCdacRef; /**< Sets the capacitance of the reference CDAC for CSD + uint8_t rowCdacRef; /**< Sets the capacitance of the row reference CDAC for CSD * Touchpad and CSD Matrix buttons widgets - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - uint8_t cicRate; /**< Sets decimation rate when CIC2 is enabled - * \note This field is available only for the fifth-generation CAPSENSE™. + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) && \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_FINE_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_FINE_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_FINE_EN))) + uint8_t cdacFine; /**< Sets the capacitance of the fine CDAC + * \note This field is available for the fifth-generation low power CAPSENSE™. */ - uint8_t cdacDitherEn; /**< Enabled CDAC dithering - * \note This field is available only for the fifth-generation CAPSENSE™. + uint8_t rowCdacFine; /**< Sets the capacitance of the row fine CDAC for CSD + * Touchpad and CSD Matrix buttons widgets + * \note This field is available for the fifth-generation low power CAPSENSE™. */ + #endif + + uint8_t cicRate; /**< Sets decimation rate when CIC2 is enabled + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + uint8_t cdacDitherEn; /**< Enabled CDAC dithering + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + uint8_t cdacDitherValue; /**< CDAC dither value in percentage - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ uint8_t coarseInitBypassEn; /**< Skip Cmod coarse initialization sensors scan within widget - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ uint16_t cdacCompDivider; /**< Number of time DAC switched in sense clock period - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ uint8_t lfsrBits; /**< Defines the number of LSB bits to use by the LSFR unit to achieve * the desired clock dithering variation. - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint8_t cicShift; /**< Sets the right shift value applied to CIC2 accumulator to form rawcounts when CIC2 is enabled + * \note This field is available for the fifth-generation low power CAPSENSE™. + */ + uint8_t rowCicShift; /**< Sets the right shift value applied to CIC2 accumulator to form rawcounts when CIC2 is enabled + * \note This field is available for the fifth-generation low power CAPSENSE™. */ #endif @@ -376,10 +424,13 @@ typedef struct GPIO_PRT_Type * pcPtr; /**< Pointer to the base port register of the IO */ uint8_t pinNumber; /**< Position of the IO in the port */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) uint8_t padNumber; /**< Control Mux pad number - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ + #endif + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) uint8_t chId; /**< Channel Id the pin belongs to * \note This field is available only for the fifth-generation CAPSENSE™. */ @@ -393,6 +444,7 @@ typedef struct const cy_stc_capsense_pin_config_t * ptrPin; /**< Pointer to pin configuration structure */ uint8_t type; /**< Electrode type \ref cy_en_capsense_eltd_t */ uint8_t numPins; /**< Total number of pins in this sensor */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) uint8_t chId; /**< Channel Id the electrode belongs to * \note This field is available only for the fifth-generation CAPSENSE™. @@ -426,15 +478,15 @@ typedef struct } cy_stc_capsense_advanced_touchpad_config_t; -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) -/** Multi-phase TX table for de-convolution structure - * \note This structure is available only for the fifth-generation CAPSENSE™. +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) +/** Multi-phase table for de-convolution structure + * \note This structure is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ typedef struct { - uint32_t vector; /**< TX vector / pattern */ + uint32_t vector; /**< Vector / pattern */ int16_t deconvCoef[32u]; /**< De-convolution coefficients */ -} cy_stc_capsense_mptx_table_t; +} cy_stc_capsense_mp_table_t; #endif @@ -445,11 +497,13 @@ typedef struct cy_stc_capsense_sensor_context_t * ptrSnsContext; /**< Pointer to the first object of sensor context structure that belongs to this widget */ const cy_stc_capsense_electrode_config_t * ptrEltdConfig; /**< Pointer to the first object of electrode configuration structure that belongs to this widget */ uint32_t * ptrEltdCapacitance; /**< Pointer to the first object in the electrode capacitance array that belongs to this widget */ -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - uint32_t * ptrSnsCapacitance; /**< Pointer to the first object in the sensor capacitance array that belongs to this widget. - * \note This field is available only for the fifth-generation CAPSENSE™. + + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + uint32_t * ptrSnsCapacitance; /**< Pointer to the first object in the sensor capacitance array that belongs to this widget. + * \note This field is available only for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ -#endif + #endif + uint16_t * ptrBslnInv; /**< Pointer to the first object in the sensor baseline inversion array that belongs to this widget */ cy_stc_capsense_smartsense_csd_noise_envelope_t * ptrNoiseEnvelope; @@ -466,14 +520,17 @@ typedef struct uint16_t yResolution; /**< For Touchpads Y-Axis maximum position */ uint16_t numSns; /**< The total number of sensors: * For CSD widgets: WD_NUM_ROWS + WD_NUM_COLS. - * For CSX widgets: WD_NUM_ROWS * WD_NUM_COLS. */ + * For CSX widgets: WD_NUM_ROWS * WD_NUM_COLS. + * For ISX widgets: (WD_NUM_ROWS + WD_NUM_COLS) / 2 */ uint8_t numCols; /**< For CSD Button and Proximity Widgets, the number of sensors. * For CSD Slider Widget, the number of segments. * For CSD Touchpad and Matrix Button, the number of the column sensors. - * For CSX Button, Slider, Touchpad, and Matrix Button, the number of the Rx electrodes. */ + * For CSX Button, Slider, Touchpad, and Matrix Button, the number of the Rx electrodes. + * For ISX Button and Linear Slider, the number of the Rx electrodes. */ uint8_t numRows; /**< For CSD Touchpad and Matrix Buttons, the number of the row sensors. * For the CSX Button and Slider, the number of the Tx electrodes (constant 1u). - * For CSX Touchpad and Matrix Button, the number of the Tx electrodes. */ + * For CSX Touchpad and Matrix Button, the number of the Tx electrodes. + * For ISX Button and Linear Slider, the number of the Lx electrodes. */ cy_stc_capsense_touch_t * ptrPosFilterHistory; /**< Pointer to the position filter history */ cy_stc_capsense_csx_touch_history_t * ptrCsxTouchHistory; /**< Pointer to the CSX touchpad history */ cy_stc_capsense_csx_touch_buffer_t * ptrCsxTouchBuffer; /**< Pointer to the single CSX buffer needed for CSX touchpad processing */ @@ -491,33 +548,42 @@ typedef struct uint32_t posFilterConfig; /**< Position filters configuration */ uint16_t rawFilterConfig; /**< Raw count filters configuration */ + uint16_t alpOnThreshold; /**< ALP Filter ON threshold */ + uint16_t alpOffThreshold; /**< ALP Filter OFF threshold */ + uint8_t senseMethod; /**< Specifies the widget sensing method: * * 0 - UNDEFINED (CY_CAPSENSE_UNDEFINED_GROUP) * * 1 - CSD (CY_CAPSENSE_CSD_GROUP) - * * 2 - CSX (CY_CAPSENSE_CSX_GROUP) */ + * * 2 - CSX (CY_CAPSENSE_CSX_GROUP) + * * 3 - ISX (CY_CAPSENSE_ISX_GROUP) */ uint8_t wdType; /**< Specifies the widget type */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - cy_stc_capsense_mptx_table_t * ptrMptxTable; /**< Pointer to the multi-phase TX vector and de-convolution coefficients - * \note This field is available only for the fifth-generation CAPSENSE™. + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + cy_stc_capsense_mp_table_t * ptrMpTable; /**< Pointer to the multi-phase vector and de-convolution coefficients + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ uint16_t firstSlotId; /**< The slot ID in the widget to start scan from - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ uint16_t numSlots; /**< The number of slots in the widget - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ uint8_t numChopCycles; /**< Defines number of chopping cycles. One cycle means the feature is disabled - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - uint8_t mptxOrder; /**< Multi-phase TX order - * \note This field is available only for the fifth-generation CAPSENSE™. + uint8_t mpOrder; /**< Multi-phase order + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint8_t mpOrderRows; /**< Multi-phase order for rows in CSD widgets + * \note This field is available for the fifth-generation low power CAPSENSE™. */ + #endif uint8_t lfsrDitherLimit; /**< Max dither in percentage. The input parameter for the LFSR range auto-selection algorithm - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™and fifth-generation low power CAPSENSE™. */ uint8_t snsClkSourceAutoSelMode; /**< Defines set of rules that are used by clock source auto-selection algorithm - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ uint8_t mfsConfig; /**< Multi-frequency Scan (MFS) widget configuration. ** Contains masks: @@ -529,9 +595,16 @@ typedef struct * * 0 - Base widget * * 1 - Frequency channel 1 widget (CY_CAPSENSE_MFS_WIDGET_FREQ_CH_1_MASK) * * 2 - Frequency channel 2 widget (CY_CAPSENSE_MFS_WIDGET_FREQ_CH_2_MASK) - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ #endif + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint8_t iirCoeffHw; /**< Raw count HW IIR filter coefficient. Smaller value leads to lower filtering. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + #endif + } cy_stc_capsense_widget_config_t; #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) @@ -545,9 +618,9 @@ typedef struct } cy_stc_capsense_idac_gain_table_t; #endif -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) /** Declares the scan order of widget and sensor - * \note This structure is available only for the fifth-generation CAPSENSE™. + * \note This structure is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ typedef struct { @@ -556,14 +629,29 @@ typedef struct } cy_stc_capsense_scan_slot_t; #endif -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) /** Declares MSC channel (HW block) configuration - * \note This structure is available only for the fifth-generation CAPSENSE™. + * \note This structure is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ typedef struct { - MSC_Type * ptrMscBase; /**< Pointer to the MSC HW block register */ - cy_stc_msc_context_t * ptrMscContext; /**< Pointer to the MSC driver context */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + MSC_Type * ptrHwBase; /**< Pointer to the MSC HW block register + * \note This structure is available only for the fifth-generation CAPSENSE™ + */ + cy_stc_msc_context_t * ptrHwContext; /**< Pointer to the MSC driver context + * \note This structure is available only for the fifth-generation CAPSENSE™ + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + MSCLP_Type * ptrHwBase; /**< Pointer to the MSCLP HW block register + * \note This structure is available only for the fifth-generation low power CAPSENSE™ + */ + cy_stc_msclp_context_t * ptrHwContext; /**< Pointer to the MSCLP driver context + * \note This structure is available only for the fifth-generation low power CAPSENSE™ + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ GPIO_PRT_Type * portCmod1; /**< The pointer to the Cmod1 pin base port register */ uint8_t pinCmod1; /**< The Cmod1 pin position (bit number) in the port */ @@ -571,12 +659,25 @@ typedef struct GPIO_PRT_Type * portCmod2; /**< The pointer to the Cmod2 pin base port register */ uint8_t pinCmod2; /**< The Cmod2 pin position (bit number) in the port */ - uint8_t dmaWrChIndex; /**< Specifies the DMA Write channel index */ - uint8_t dmaChainWrChIndex; /**< Specifies the DMA Chain Write channel index */ - uint8_t dmaRdChIndex; /**< Specifies the DMA Read channel index */ - uint8_t dmaChainRdChIndex; /**< Specifies the DMA Chain Read channel index */ -} cy_stc_msc_channel_config_t; -#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + uint8_t dmaWrChIndex; /**< Specifies the DMA Write channel index + * \note This structure is available only for the fifth-generation CAPSENSE™ + */ + uint8_t dmaChainWrChIndex; /**< Specifies the DMA Chain Write channel index + * \note This structure is available only for the fifth-generation CAPSENSE™ + */ + uint8_t dmaRdChIndex; /**< Specifies the DMA Read channel index + * \note This structure is available only for the fifth-generation CAPSENSE™ + */ + uint8_t dmaChainRdChIndex; /**< Specifies the DMA Chain Read channel index + * \note This structure is available only for the fifth-generation CAPSENSE™ + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + + const cy_stc_capsense_electrode_config_t * ptrShieldEltdConfig; /**< Pointer to the first object of shield electrode configuration */ + +} cy_stc_capsense_channel_config_t; +#endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ /** Common configuration structure */ @@ -584,21 +685,137 @@ typedef struct { uint32_t cpuClkHz; /**< CPU clock in Hz */ uint32_t periClkHz; /**< Peripheral clock in Hz */ - uint16_t vdda; /**< VDDA in mV */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + cy_stc_capsense_idac_gain_table_t idacGainTable[CY_CAPSENSE_IDAC_GAIN_TABLE_SIZE]; + /**< Table with the supported IDAC gains and corresponding register values + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + CSD_Type * ptrCsdBase; /**< Pointer to the CSD HW block register + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + cy_stc_csd_context_t * ptrCsdContext; /**< Pointer to the CSD driver context + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + GPIO_PRT_Type * portCmod; /**< Pointer to the base port register of the Cmod pin + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + GPIO_PRT_Type * portCsh; /**< Pointer to the base port register of the Csh pin + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + GPIO_PRT_Type * portCintA; /**< Pointer to the base port register of the CintA pin + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + GPIO_PRT_Type * portCintB; /**< Pointer to the base port register of the CintB pin + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN */ + + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + cy_stc_capsense_channel_config_t * ptrChConfig; /**< The pointer to the CAPSENSE™ enabled channel (HW block) configuration + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + DMAC_Type * ptrDmacBase; /**< Pointer to the DMAC HW block base register + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + const uint32_t * const * ptrDmaWrChSnsCfgAddr; /**< Pointer to the array containing the addresses of sensor configurations + * used as a source for the DMA Chain Write channel + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + const uint16_t * const * ptrDmaRdChSnsCfgAddr; /**< Pointer to the array containing the addresses of sensor configurations + * used as a source for the DMA Chain Read channel + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + const uint32_t ** ptrDmaWrChSnsCfgAddrLocal; /**< Pointer to the array containing the addresses of sensor configurations + * used as a source for the DMA Chain Write channel + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + const uint16_t ** ptrDmaRdChSnsCfgAddrLocal; /**< Pointer to the array containing the addresses of sensor configurations + * used as a source for the DMA Chain Read channel + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + uint16_t * ptrEmptyRawCount; /**< Pointer to the empty storage for raw count in case widget is disabled. + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + uint16_t numPin; /**< Total number of IOs. */ uint16_t numSns; /**< The total number of sensors. It is equal to the number of objects with raw count. * * For CSD widgets: WD_NUM_ROWS + WD_NUM_COLS * * For CSX widgets: WD_NUM_ROWS * WD_NUM_COLS */ - uint8_t numWd; /**< Total number of widgets */ + uint16_t proxTouchCoeff; /**< Proximity touch coefficient in percentage used in smart sensing algorithm */ + uint16_t csdRConst; /**< Sensor resistance in series used by smart sensing algorithm */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + uint16_t vdda; /**< VDDA in mV */ + uint16_t csdVref; /**< Vref for CSD method + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN */ + + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + uint16_t numEpiCycles; /**< Number of clk_mod cycles to be run during EPILOGUE + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + uint16_t numCoarseInitChargeCycles; /**< Configure duration of Cmod initialization, phase 1 + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + uint16_t numCoarseInitSettleCycles; /**< Configure duration of Cmod initialization, phase 2 + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + uint16_t numSlots; /**< Total number of slots + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ - uint8_t csdEn; /**< CSD sensing method enabled, at least one CSD widget is configured */ - uint8_t csxEn; /**< CSX sensing method enabled, at least one CSX widget is configured */ - uint8_t positionFilterEn; /**< Position filtering enabled */ - uint8_t bistEn; /**< Built-in Self-test (BIST) enabled */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint16_t numProWaitKrefDelayPrs; /**< Number of Kref/4 ProDummy Wait Cycles if PRS is enabled + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint16_t numProWaitKrefDelay; /**< Number of Kref/4 ProDummy Wait Cycles if PRS is disabled + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint16_t numEpiKrefDelayPrs; /**< Number of Kref/4 cycles to be run during EPILOGUE if PRS is enabled + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint16_t numEpiKrefDelay; /**< Number of Kref/4 cycles to be run during EPILOGUE if PRS is disabled + * \note This field is available only for the fifth-generation pow power CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + uint8_t numWd; /**< Total number of widgets */ uint8_t periDividerType; /**< Peripheral clock type (8- or 16-bit type) */ uint8_t periDividerIndex; /**< Peripheral divider index */ - uint8_t analogWakeupDelay; /**< Time needed to establish correct operation of the CSD HW block after power up or System Deep Sleep. */ + uint8_t analogWakeupDelay; /**< Time needed to establish correct operation of CAPSENSE™ HW block block after power up or System Deep Sleep. */ + uint8_t swSensorAutoResetEn; /**< Sensor auto reset enabled */ + + uint8_t csdInactiveSnsConnection; /**< Inactive sensor connection for CSD scan: + * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ + * * CY_CAPSENSE_SNS_CONNECTION_SHIELD + * * CY_CAPSENSE_SNS_CONNECTION_GROUND */ + uint8_t csxInactiveSnsConnection; /**< Inactive sensor connection for CSX scan: + * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ + * * CY_CAPSENSE_SNS_CONNECTION_GROUND + * * CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 + * + * CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 is only available for fifth-generation + * and fifth-generation low power CAPSENSE™. + */ + uint8_t isxInactiveSnsConnection; /**< Inactive sensor connection for ISX scan: + * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ + * + * Applicable only for fifth-generation low power CAPSENSE™. + */ + uint8_t csdShieldNumPin; /**< Number of shield IOs */ + + uint8_t csxRawTarget; /**< Raw count target in percentage for CSX calibration */ + uint8_t csxCalibrationError; /**< Acceptable calibration error */ + uint8_t csdRawTarget; /**< Raw count target in percentage for CSD calibration */ + uint8_t csdCalibrationError; /**< Acceptable calibration error */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) uint8_t ssIrefSource; /**< Iref source * \note This field is available only for the fourth-generation CAPSENSE™. @@ -606,10 +823,6 @@ typedef struct uint8_t ssVrefSource; /**< Vref source * \note This field is available only for the fourth-generation CAPSENSE™. */ - #endif - uint16_t proxTouchCoeff; /**< Proximity touch coefficient in percentage used in smart sensing algorithm */ - uint8_t swSensorAutoResetEn; /**< Sensor auto reset enabled */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) uint8_t portCmodPadNum; /**< Number of port of dedicated Cmod pad * \note This field is available only for the fourth-generation CAPSENSE™. */ @@ -637,28 +850,6 @@ typedef struct uint8_t portCmodNum; /**< Number of port of Cmod pin * \note This field is available only for the fourth-generation CAPSENSE™. */ - cy_stc_capsense_idac_gain_table_t idacGainTable[CY_CAPSENSE_IDAC_GAIN_NUMBER]; - /**< Table with the supported IDAC gains and corresponding register values - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - CSD_Type * ptrCsdBase; /**< Pointer to the CSD HW block register - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - cy_stc_csd_context_t * ptrCsdContext; /**< Pointer to the CSD driver context - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - GPIO_PRT_Type * portCmod; /**< Pointer to the base port register of the Cmod pin - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - GPIO_PRT_Type * portCsh; /**< Pointer to the base port register of the Csh pin - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - GPIO_PRT_Type * portCintA; /**< Pointer to the base port register of the CintA pin - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - GPIO_PRT_Type * portCintB; /**< Pointer to the base port register of the CintB pin - * \note This field is available only for the fourth-generation CAPSENSE™. - */ uint8_t pinCmod; /**< Position of the Cmod pin in the port * \note This field is available only for the fourth-generation CAPSENSE™. */ @@ -674,33 +865,9 @@ typedef struct uint8_t pinCintB; /**< Position of the CintB pin in the port * \note This field is available only for the fourth-generation CAPSENSE™. */ - uint8_t csdShieldEn; /**< Shield enabled - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - #endif - uint8_t csdInactiveSnsConnection; /**< Inactive sensor connection for CSD scan: - * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ - * * CY_CAPSENSE_SNS_CONNECTION_SHIELD - * * CY_CAPSENSE_SNS_CONNECTION_GROUND */ - uint8_t csxInactiveSnsConnection; /**< Inactive sensor connection for CSD scan: - * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ - * * CY_CAPSENSE_SNS_CONNECTION_GROUND */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) uint8_t csdShieldDelay; /**< Shield signal delay * \note This field is available only for the fourth-generation CAPSENSE™. */ - uint16_t csdVref; /**< Vref for CSD method - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - #endif - uint16_t csdRConst; /**< Sensor resistance in series used by smart sensing algorithm */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) - uint8_t csdCTankShieldEn; /**< Csh enabled - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - #endif - uint8_t csdShieldNumPin; /**< Number of shield IOs */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) uint8_t csdShieldSwRes; /**< Shield switch resistance * \note This field is available only for the fourth-generation CAPSENSE™. */ @@ -710,35 +877,15 @@ typedef struct uint8_t csdChargeTransfer; /**< IDAC sensing configuration * \note This field is available only for the fourth-generation CAPSENSE™. */ - #endif - uint8_t csdRawTarget; /**< Raw count target in percentage for CSD calibration */ - uint8_t csdAutotuneEn; /**< smart sensing algorithm enabled */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) - uint8_t csdIdacAutocalEn; /**< CSD IDAC calibration enabled - * \note This field is available only for the fourth-generation CAPSENSE™. - */ uint8_t csdIdacGainInitIndex; /**< IDAC gain index per \ref idacGainTable * \note This field is available only for the fourth-generation CAPSENSE™. */ - uint8_t csdIdacAutoGainEn; /**< IDAC gain auto-calibration enabled - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - #endif - uint8_t csdCalibrationError; /**< Acceptable calibration error */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) uint8_t csdIdacMin; /**< Min acceptable IDAC value in CSD calibration * \note This field is available only for the fourth-generation CAPSENSE™. */ - uint8_t csdIdacCompEn; /**< Compensation IDAC enabled - * \note This field is available only for the fourth-generation CAPSENSE™. - */ uint8_t csdFineInitTime; /**< Number of dummy SnsClk periods at fine initialization * \note This field is available only for the fourth-generation CAPSENSE™. */ - uint8_t csdIdacRowColAlignEn; /**< Row-Column alignment enabled. It adjusts modulator IDAC for rows - * and for columns to achieve the similar sensitivity. - * \note This field is available only for the fourth-generation CAPSENSE™. - */ uint8_t csdMfsDividerOffsetF1; /**< Frequency divider offset for channel 1. This value is added to * base (channel 0) SnsClk divider to form channel 1 frequency * \note This field is available only for the fourth-generation CAPSENSE™. @@ -747,21 +894,6 @@ typedef struct * base (channel 0) SnsClk divider to form channel 2 frequency * \note This field is available only for the fourth-generation CAPSENSE™. */ - #endif - uint8_t csxRawTarget; /**< Raw count target in percentage for CSX calibration */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) - uint8_t csxIdacGainInitIndex; /**< IDAC gain for CSX method - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint8_t csxRefGain; /**< Refgen gain for CSX method - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint8_t csxIdacAutocalEn; /**< CSX IDAC calibration enabled - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - #endif - uint8_t csxCalibrationError; /**< Acceptable calibration error */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) uint8_t csxFineInitTime; /**< Number of dummy TX periods at fine initialization * \note This field is available only for the fourth-generation CAPSENSE™. */ @@ -787,143 +919,70 @@ typedef struct */ #endif - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - cy_stc_msc_channel_config_t * ptrMscChConfig; /**< The pointer to the CAPSENSE™ enabled MSC channel (HW block) configuration - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - - DMAC_Type * ptrDmacBase; /**< Pointer to the DMAC HW block base register - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - const uint32_t ** ptrDmaWrChSnsCfgAddr; /**< Pointer to the array containing the addresses of sensor configurations - * used as a source for the DMA Chain Write channel - * \note This field is available only for the fifth-generation CAPSENSE™. + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + uint8_t isxRawTarget; /**< Raw count target in percentage for ISX calibration + * \note This structure is available only for the fifth-generation low power CAPSENSE™ + */ + uint8_t isxCalibrationError; /**< Acceptable calibration error + * \note This structure is available only for the fifth-generation low power CAPSENSE™ + */ + uint8_t csdShieldMode; /**< Shield mode + * * CY_CAPSENSE_SHIELD_DISABLED + * * CY_CAPSENSE_SHIELD_ACTIVE + * * CY_CAPSENSE_SHIELD_PASSIVE + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - const uint16_t ** ptrDmaRdChSnsCfgAddr; /**< Pointer to the array containing the addresses of sensor configurations - * used as a source for the DMA Chain Read channel - * \note This field is available only for the fifth-generation CAPSENSE™. + uint8_t numProOffsetCycles; /**< Maximum number of clk_mod cycles for the PRO_OFFSET state. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - - uint16_t numEpiCycles; /**< Number of clk_mod cycles to be run during EPILOGUE + uint8_t proOffsetCdacComp; /**< Compensation CAPDAC size during PRO_OFFSET. * \note This field is available only for the fifth-generation CAPSENSE™. */ - uint16_t numCoarseInitChargeCycles; /**< Configure duration of Cmod initialization, phase 1 - * \note This field is available only for the fifth-generation CAPSENSE™. + uint8_t chopPolarity; /**< Select polarity for system level chopping + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - uint16_t numCoarseInitSettleCycles; /**< Configure duration of Cmod initialization, phase 2 - * \note This field is available only for the fifth-generation CAPSENSE™. + uint8_t numBadScans; /**< 1 to 7, repeat scan upon "bad" scan. Disabled = 0. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - uint16_t numSlots; /**< Total number of slots - * \note This field is available only for the fifth-generation CAPSENSE™. + uint8_t counterMode; /**< Select overflow or saturate mode for raw count: + * * 0 - CY_CAPSENSE_COUNTER_MODE_SATURATE + * * 1 - CY_CAPSENSE_COUNTER_MODE_OVERFLOW + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) */ - uint8_t csdShieldMode; /**< Shield mode - * * CY_CAPSENSE_SHIELD_DISABLED - * * CY_CAPSENSE_SHIELD_ACTIVE - * * CY_CAPSENSE_SHIELD_PASSIVE + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + uint8_t sensorConnection; /**< Sensor Connection. In CS-DMA mode, sensor connection always set to CTRLMUX. + * * 0 - CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD: + * All AMUX capable GPIOs available as sensor. + * * 1 - CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD: + * Only dedicated GPIO available as sensor. * \note This field is available only for the fifth-generation CAPSENSE™. */ - uint8_t sensorConnection; /**< Sensor Connection. In CS-DMA mode, sensor connection always set to CTRLMUX. - * * 0 - CY_CAPSENSE_AMUX_SENSOR_CONNECTION_METHOD: - * All AMUX capable GPIOs available as sensor. - * * 1 - CY_CAPSENSE_CTRLMUX_SENSOR_CONNECTION_METHOD: - * Only dedicated GPIO available as sensor. - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t csdCdacAutocalEn; /**< CSD CDAC calibration enabled + uint8_t syncClockEn; /**< Enable external synchronization signals * \note This field is available only for the fifth-generation CAPSENSE™. */ - uint8_t csdRefCdacAutoEn; /**< CSD Reference CDAC auto-calibration enabled + uint8_t syncMode; /**< Synchronization mode: + * * 0 - CY_CAPSENSE_SYNC_MODE_OFF + * * 1 - CY_CAPSENSE_SYNC_EXTERNAL + * * 2 - CY_CAPSENSE_SYNC_INTERNAL * \note This field is available only for the fifth-generation CAPSENSE™. */ - uint8_t csdCdacCompEn; /**< CSD Compensation CDAC enabled + uint8_t masterChannelId; /**< The ID of the Master channel MULTI-CHIP solution. + * This channel will generate msc_ext_frm_start_out + * and msc_ext_sync_clk_out signals * \note This field is available only for the fifth-generation CAPSENSE™. */ - uint8_t csdCdacCompDivAutoEn; /**< CSD Compensation CDAC divider auto-calibration enabled + uint8_t numChannels; /**< The number of CAPSENSE™ enabled MSCv3 blocks in the current chip * \note This field is available only for the fifth-generation CAPSENSE™. */ - uint8_t csdCdacAutoCalibMin; /**< Min acceptable CDAC value in CSD auto-calibration + uint8_t channelOffset; /**< The ID of the first channel that belongs to the current chip * \note This field is available only for the fifth-generation CAPSENSE™. */ - uint8_t csdRefCdacRowColumnAlignEn; /**< Row-Column alignment enabled. It adjusts reference CDAC for rows - * and for columns in two-dimension CSD widgets to achieve - * the similar sensitivity - * \note This field is available only for the fifth-generation CAPSENSE™. + uint8_t syncFrameStartEn; /**< Enable external synchronization signals + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - uint8_t csxCdacAutocalEn; /**< CSX CDAC calibration enabled - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t csxRefCdacAutoEn; /**< CSX Reference CDAC auto-calibration enabled - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t csxCdacCompEn; /**< CSX Compensation CDAC enabled - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t csxCdacCompDivAutoEn; /**< CSX Compensation CDAC divider auto-calibration enabled - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t csxCdacAutoCalibMin; /**< Min acceptable CDAC value in CSX auto-calibration - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t csxAutotuneEn; /**< CSX smart sensing algorithm enabled - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t numProOffsetCycles; /**< Maximum number of clk_mod cycles for the PRO_OFFSET state. - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t proOffsetCdacComp; /**< Compensation CAPDAC size during PRO_OFFSET. - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t scanningMode; /**< Scanning Mode: - * * 0 - CY_CAPSENSE_SCAN_MODE_INT_DRIVEN - * * 1 - CY_CAPSENSE_SCAN_MODE_DMA_DRIVEN - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t mptxEn; /**< Multi-phase TX enabled - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t chopPolarity; /**< Select polarity for system level chopping - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t cicFilterMode; /**< CIC filter mode - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t numBadScans; /**< 1 to 7, repeat scan upon "bad" scan. Disabled = 0. - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t counterMode; /**< Select overflow or saturate mode for raw count: - * * 0 - CY_CAPSENSE_COUNTER_MODE_SATURATE - * * 1 - CY_CAPSENSE_COUNTER_MODE_OVERFLOW - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t syncFrameStartEn; /**< Enable external synchronization signals - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t syncClockEn; /**< Enable external synchronization signals - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t syncMode; /**< Synchronization mode: - * * 0 - CY_CAPSENSE_SYNC_MODE_OFF - * * 1 - CY_CAPSENSE_SYNC_EXTERNAL - * * 2 - CY_CAPSENSE_SYNC_INTERNAL - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t masterChannelId; /**< The ID of the Master channel MULTI-CHIP solution. - * This channel will generate msc_ext_frm_start_out - * and msc_ext_sync_clk_out signals - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t numChips; /**< The chip number for MULTI-CHIP solution. For SINGLE-CHIP is equal to 1u - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t numChannels; /**< The number of CAPSENSE™ enabled MSCv3 blocks in the current chip - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t channelOffset; /**< The ID of the first channel that belongs to the current chip - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - #endif - + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ } cy_stc_capsense_common_config_t; @@ -959,12 +1018,18 @@ typedef struct */ #endif -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) uint32_t * ptrChShieldCap; /**< The pointer to the channel shield capacitance measurement result array * \note This field is available only for the fifth-generation CAPSENSE™. */ #endif +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + uint16_t vddaVoltage; /**< The result of VDDA measurement in millivolts + * \note This field is available only for the fourth-generation CAPSENSE™. + */ +#endif + uint32_t eltdCapSnsClkFreqHz; /**< The value of the SnsClk frequency is Hz */ uint16_t * ptrWdgtCrc; /**< The pointer to the widget CRC array */ @@ -973,6 +1038,13 @@ typedef struct uint16_t eltdCapModClk; /**< The ModClk divider for electrode capacitance measurement scans */ uint16_t eltdCapSnsClk; /**< The SnsClk divider for electrode capacitance measurement scans */ +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + uint16_t curBistWdId; /**< The current widget ID for BIST operations + * \note This field is available only for the fifth- + * generation CAPSENSE™. + */ +#endif + uint8_t eltdCapSenseGroup; /**< The sensor group for capacitance measurement: * * 0 - UNDEFINED (CY_CAPSENSE_UNDEFINED_GROUP) * * 1 - CSD (CY_CAPSENSE_CSD_GROUP) @@ -1036,9 +1108,6 @@ typedef struct uint16_t capacitorSettlingTime; /**< The maximum possible external capacitor charge/discharge time in microseconds * \note This field is available only for the fourth-generation CAPSENSE™. */ - uint16_t vddaVoltage; /**< The result of VDDA measurement in millivolts - * \note This field is available only for the fourth-generation CAPSENSE™. - */ uint16_t vddaModClk; /**< The ModClk divider for VDDA measurements * \note This field is available only for the fourth-generation CAPSENSE™. */ @@ -1075,7 +1144,7 @@ typedef struct */ #endif -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) const cy_stc_capsense_electrode_config_t * curPtrEltdCfg; /**< The pointer to the current electrode configuration for BIST operations * \note This field is available only for the fifth-generation CAPSENSE™. */ @@ -1083,23 +1152,113 @@ typedef struct en_hsiom_sel_t eltdInactiveHsiom; /**< Internal pre-calculated data for faster operation */ uint16_t curBistSlotId; /**< The current slot ID for BIST operations - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. */ uint16_t eltdCapSubConvNum; /**< The sub-conversion number for electrode capacitance measurement scans - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. */ uint16_t eltdCapNumEpiCycles; /**< Number of clk_mod cycles to be run during EPILOGUE - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. */ uint16_t eltdCapNumCoarseInitChargeCycles; /**< Configure duration of Cmod initialization, phase 1 - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. */ uint16_t eltdCapNumCoarseInitSettleCycles; /**< Configure duration of Cmod initialization, phase 2 - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. */ - uint16_t eltdCapNumFineInitWaitCycles; /**< Number of ProDummy Wait Cycles - * \note This field is available only for the fifth-generation CAPSENSE™. + uint16_t eltdCapNumFineInitWaitCycles; /**< Number of ProDummy Wait Cycles + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. + */ + +#if ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_VDDA_EN)) + uint16_t extCapDischargeTime; /**< The discharging time in us needed to discharge + * the external capacitor before the measurement + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. + */ + uint16_t extCapSubConvNum; /**< The sub-conversion number for Cmod measurement + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. + */ +#endif + +#if (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) + uint16_t extCapWDT; /**< The SW watchdog timeout used to prevent a hang + * in case of short the external capacitor + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. + */ + uint16_t cMod01Cap; /**< The MSC0 Cmod1 capacitance measurement result + * in picofarads + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. + */ + uint16_t cMod02Cap; /**< The MSC0 Cmod2 capacitance measurement result + * in picofarads + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. + */ + +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) && (1u == MSCLP_CMOD34_PRESENT))) + uint16_t cMod03Cap; /**< The MSC0 Cmod3 capacitance measurement result + * in picofarads + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. + */ + uint16_t cMod04Cap; /**< The MSC0 Cmod4 capacitance measurement result + * in picofarads + * \note This field is available only for the fifth- + * generation CAPSENSE™ and fifth-generation + * low power CAPSENSE™. + */ +#endif /* ((CY_CAPSENSE_PLATFORM_BLOCK_FORTH_GEN_LP) || \ + ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) && (MSCLP_CMOD34_PRESENT))) */ + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + uint16_t cMod11Cap; /**< The MSC1 Cmod1 capacitance measurement result + * in picofarads + * \note This field is available only for the fifth- + * generation CAPSENSE™. + */ + uint16_t cMod12Cap; /**< The MSC1 Cmod2 capacitance measurement result + * in picofarads + * \note This field is available only for the fifth- + * generation CAPSENSE™. + */ + uint16_t cMod13Cap; /**< The MSC1 Cmod3 capacitance measurement result + * in picofarads + * \note This field is available only for the fifth- + * generation CAPSENSE™. */ + uint16_t cMod14Cap; /**< The MSC1 Cmod4 capacitance measurement result + * in picofarads + * \note This field is available only for the fifth- + * generation CAPSENSE™. + */ +#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FORTH_GEN) */ + +#endif /* (CY_CAPSENSE_ENABLE == CY_CAPSENSE_TST_EXTERNAL_CAP_EN) */ + uint8_t eltdCapNumFineInitCycles; /**< Number of ProDummy SubConversions * \note This field is available only for the fifth-generation CAPSENSE™. */ @@ -1177,23 +1336,23 @@ typedef struct uint8_t widgetIndex; /**< Current widget ID */ uint8_t currentSenseMethod; /**< Current sensing method */ uint8_t connectedSnsState; /**< Shows if the current sensor is connected to analog bus */ -} cy_stc_active_scan_sns_t; +} cy_stc_capsense_active_scan_sns_t; /** * Provides the typedef for the callback function that is intended to be called when * the \ref cy_en_capsense_callback_event_t events occurs. */ -typedef void (*cy_capsense_callback_t)(cy_stc_active_scan_sns_t * ptrActiveScan); +typedef void (*cy_capsense_callback_t)(cy_stc_capsense_active_scan_sns_t * ptrActiveScan); -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) /** * Provides the typedef for the callback function that is called by the * Cy_CapSense_Enable() function to change the CAPSENSE™ configuration from * the default configuration to the user's specific use cases. * Refer to \ref group_capsense_callbacks section. * - * \note This callback function is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ typedef void (*cy_capsense_ds_init_callback_t)(void * context); #endif @@ -1202,6 +1361,8 @@ typedef void (*cy_capsense_callback_t)(cy_stc_active_scan_sns_t * ptrActiveScan) * Provides the typedef for the callback function that is called by the * Cy_CapSense_RunTuner() function to establish communication with * the CAPSENSE™ Tuner tool to monitor CAPSENSE™ operation. +* For the fifth-generation low power CAPSENSE™ the callback is called only once for each new scan. +* For the previous CAPSENSE™ generations the callback is called once per scan cycle or periodically if device is in suspended mode. * Refer to \ref group_capsense_callbacks section. */ typedef void (*cy_capsense_tuner_send_callback_t)(void * context); @@ -1218,196 +1379,327 @@ typedef void (*cy_capsense_tuner_receive_callback_t)(uint8_t ** commandPacket, u /** Declares internal Context Data Structure */ typedef struct { - uint8_t intrCsdInactSnsConn; /**< Internal inactive electrode connection for CSD scan: - * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ - * * CY_CAPSENSE_SNS_CONNECTION_SHIELD - * * CY_CAPSENSE_SNS_CONNECTION_GROUND */ - uint8_t intrCsxInactSnsConn; /**< Internal inactive electrode connection for CSX scan: - * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ - * * CY_CAPSENSE_SNS_CONNECTION_GROUND */ - uint32_t csdInactiveSnsDm; /**< Internal pre-calculated data for faster operation */ - en_hsiom_sel_t csdInactiveSnsHsiom; /**< Internal pre-calculated data for faster operation */ + cy_capsense_callback_t ptrSSCallback; /**< Pointer to a user's Start Sample callback function. Refer to \ref group_capsense_callbacks section */ + cy_capsense_callback_t ptrEOSCallback; /**< Pointer to a user's End Of Scan callback function. Refer to \ref group_capsense_callbacks section */ + cy_capsense_tuner_send_callback_t ptrTunerSendCallback; /**< Pointer to a user's tuner callback function. Refer to \ref group_capsense_callbacks section */ + cy_capsense_tuner_receive_callback_t ptrTunerReceiveCallback; /**< Pointer to a user's tuner callback function. Refer to \ref group_capsense_callbacks section */ - uint32_t csxInactiveSnsDm; /**< Internal pre-calculated data for faster operation */ - en_hsiom_sel_t csxInactiveSnsHsiom; /**< Internal pre-calculated data for faster operation */ + void (* ptrISRCallback)(void * context); /**< Pointer to the scan interrupt handler */ - cy_capsense_callback_t ptrSSCallback; /**< Pointer to a user's Start Sample callback function. Refer to \ref group_capsense_callbacks section */ - cy_capsense_callback_t ptrEOSCallback; /**< Pointer to a user's End Of Scan callback function. Refer to \ref group_capsense_callbacks section */ - cy_capsense_tuner_send_callback_t ptrTunerSendCallback; /**< Pointer to a user's tuner callback function. Refer to \ref group_capsense_callbacks section */ - cy_capsense_tuner_receive_callback_t ptrTunerReceiveCallback; /**< Pointer to a user's tuner callback function. Refer to \ref group_capsense_callbacks section */ - - void (* ptrISRCallback)(void * context); /**< Pointer to the scan interrupt handler */ + #if (!CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint32_t csdInactiveSnsDm; /**< Internal pre-calculated data for faster operation */ + uint32_t csxInactiveSnsDm; /**< Internal pre-calculated data for faster operation */ + #endif #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) - uint32_t csdRegConfig; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwHsPSelScan; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwHsPSelCmodInit; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwHsPSelCtankInit; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwBypSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwResScan; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwResInit; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwDsiSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegAmuxbufInit; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwAmuxbufSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwShieldSelScan; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegHscmpInit; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegHscmpScan; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdIdacAConfig; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdIdacBConfig; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwCmpPSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwCmpNSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegIoSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegRefgen; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csdRegSwRefGenSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ + uint32_t csdRegConfig; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwHsPSelScan; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwHsPSelCmodInit; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwHsPSelCtankInit; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwBypSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwResScan; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwResInit; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwDsiSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegAmuxbufInit; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwAmuxbufSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwShieldSelScan; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegHscmpInit; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegHscmpScan; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdIdacAConfig; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdIdacBConfig; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwCmpPSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwCmpNSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegIoSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegRefgen; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csdRegSwRefGenSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ - uint32_t csxRegConfigInit; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csxRegConfigScan; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csxRegSwResInit; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csxRegSwResPrech; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csxRegSwResScan; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csxRegAMuxBuf; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csxRegRefgen; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csxRegRefgenSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csxRegSwCmpNSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint32_t csxRegSwRefGenSel; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ + uint32_t csxRegConfigInit; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csxRegConfigScan; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csxRegSwResInit; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csxRegSwResPrech; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csxRegSwResScan; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csxRegAMuxBuf; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csxRegRefgen; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csxRegRefgenSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csxRegSwCmpNSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint32_t csxRegSwRefGenSel; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint16_t csdVrefVoltageMv; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint8_t csdCmodConnection; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint8_t csdCshConnection; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + uint8_t csdVrefGain; /**< Internal pre-calculated data for faster operation + * \note This field is available only for the fourth-generation CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN */ - uint8_t csdCmodConnection; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint8_t csdCshConnection; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint8_t csdVrefGain; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint16_t csdVrefVoltageMv; /**< Internal pre-calculated data for faster operation - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - #endif + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + cy_capsense_ds_init_callback_t ptrEODsInitCallback; /**< Pointer to a user's End Of Data Structure Initialization callback function. Refer to \ref group_capsense_callbacks section + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + uint32_t snsCtlReg[CY_CAPSENSE_TOTAL_CH_NUMBER]; /**< Keeps value of non-retention SNS_CTL register for LFT mode */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint32_t snsCtlReg; /**< Keeps value of non-retention SNS_CTL register for LFT mode */ + uint32_t activeWakeupTimer; /**< The wakeup timer value for the ACTIVE scan mode in microseconds + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint32_t activeWakeupTimerCycles; /**< The wakeup timer value for the ACTIVE scan mode in ILO cycles + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint32_t wotScanInterval; /**< Scan refresh interval (us) while in Wake-on-Touch mode. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint32_t wotScanIntervalCycles; /**< The scan refresh interval value for the Wake-on-Touch scan mode in ILO cycles + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint32_t iloCompensationFactor; /**< The ILO compensation factor value, calculated as actual ILO frequency (Hz) * 2^14 / 1000000 + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - cy_capsense_ds_init_callback_t ptrEODsInitCallback; /**< Pointer to a user's End Of Data Structure Initialization callback function. Refer to \ref group_capsense_callbacks section - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint32_t snsCtlReg[CY_CAPSENSE_TOTAL_CH_NUMBER]; /**< Keeps value of non-retention SNS_CTL register for LFT mode */ - uint16_t numEpiCycles; /**< Number of clk_mod cycles to be run during EPILOGUE - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint16_t numCoarseInitChargeCycles; /**< Configure duration of Cmod initialization, phase 1 - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint16_t numCoarseInitSettleCycles; /**< Configure duration of Cmod initialization, phase 2 - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint16_t numFineInitWaitCycles; /**< Number of ProDummy Wait Cycles - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint16_t currentSlotIndex; /**< Current slot ID - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint16_t endSlotIndex; /**< The last slot ID for the current frame - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t scanSingleSlot; /**< Request of scanning just one slot with keeping HW configuration after scan: - * * CY_CAPSENSE_SCAN_SNGL_SLOT - Single slot scanning - * * CY_CAPSENSE_SCAN_MULTIPLE_SLOT - Multiple slot scanning - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t numSenseMethod; /**< The number of sense methods, used in the project - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t mapSenseMethod[CY_CAPSENSE_REG_MODE_NUMBER]; /**< The map array of sense methods, used in the project - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t numProOffsetCycles; /**< Maximum number of clk_mod cycles for the PRO_OFFSET state. - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t proOffsetCdacComp; /**< Compensation CAPDAC size during PRO_OFFSET. - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t hwConfigState; /**< Contains the current hw state, it is configured or not and if yes then to what operation - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t slotAutoCalibrMode; /**< The slot auto-calibration mode: - * * 0 - CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR - * * 2 - CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR - * * 3 - CY_CAPSENSE_CAL_MODE_COMP_CDAC_MAX_CODE - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t intrCsdRawTarget; /**< Internal auto-calibration target in percentage for CSD widgets - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t intrCsxRawTarget; /**< Internal auto-calibration target in percentage for CSX widgets - * \note This field is available only for the fifth-generation CAPSENSE™. - */ + uint16_t numCoarseInitChargeCycles; /**< Configure duration of Cmod initialization, phase 1 + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint16_t numCoarseInitSettleCycles; /**< Configure duration of Cmod initialization, phase 2 + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint16_t currentSlotIndex; /**< Current slot ID + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint16_t endSlotIndex; /**< The last slot ID for the current frame + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint16_t numValidSlots; /**< Number of valid slots + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint16_t firstValidSlot; /**< The first valid slots ID + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint16_t lfsrPoly; /**< LFSR Polynomial + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + uint16_t numFineInitWaitCycles; /**< Number of ProDummy Wait Cycles + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + uint16_t numEpiCycles; /**< Number of clk_mod cycles to be run during EPILOGUE + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint16_t numProWaitKrefDelayPrs; /**< Number of Kref/4 ProDummy Wait Cycles if PRS is enabled + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint16_t numProWaitKrefDelay; /**< Number of Kref/4 ProDummy Wait Cycles if PRS is disabled + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint16_t numEpiKrefDelayPrs; /**< Number of Kref/4 cycles to be run during EPILOGUE if PRS is enabled + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint16_t numEpiKrefDelay; /**< Number of Kref/4 cycles to be run during EPILOGUE if PRS is disabled + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint16_t numSlots; /**< The number of slots in the current frame + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint16_t startSlotIndex; /**< The start slot ID for the current scan + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint16_t wotTimeout; /**< The number of frames to be scanned in Wake-on-Touch mode when there is no touch. + * The maximum value is limited to the 14 bits, the applicable range is [1..16383]. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + + uint8_t intrIsxInactSnsConn; /**< Internal inactive electrode connection for ISX scan: + * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ + * * CY_CAPSENSE_SNS_CONNECTION_GROUND */ + uint8_t numFineInitCycles; /**< Number of ProDummy SubConversions + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + uint8_t lfsrScale; /**< LFSR Scale value + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + uint8_t cdacDitherSeed; /**< Dither CDAC Seed + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + uint8_t cdacDitherPoly; /**< Dither CDAC Polynomial + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + uint8_t modClk; /**< The modulator clock divider + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + uint8_t scanSingleSlot; /**< Request of scanning just one slot with keeping HW configuration after scan: + * * CY_CAPSENSE_SCAN_SNGL_SLOT - Single slot scanning + * * CY_CAPSENSE_SCAN_MULTIPLE_SLOT - Multiple slot scanning + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint8_t numProOffsetCycles; /**< Maximum number of clk_mod cycles for the PRO_OFFSET state. + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint8_t proOffsetCdacComp; /**< Compensation CAPDAC size during PRO_OFFSET. + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint8_t hwConfigState; /**< Contains the current hw state, it is configured or not and if yes then to what operation + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint8_t slotAutoCalibrMode; /**< The slot auto-calibration mode: + * * 0 - CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR + * * 2 - CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR + * * 3 - CY_CAPSENSE_CAL_MODE_FINE_CDAC_SUC_APPR + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint8_t intrCsdRawTarget; /**< Internal auto-calibration target in percentage for CSD widgets + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint8_t intrCsxRawTarget; /**< Internal auto-calibration target in percentage for CSX widgets + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™. + */ + uint8_t intrIsxRawTarget; /**< Internal auto-calibration target in percentage for ISX widgets + * \note This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™ + */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + uint8_t numSenseMethod; /**< The number of sense methods, used in the project + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + uint8_t mapSenseMethod[CY_CAPSENSE_REG_MODE_NUMBER]; /**< The map array of sense methods, used in the project + * \note This field is available only for the fifth-generation CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint8_t csdCdacDitherEn; /**< Enabled CDAC dithering for CSD sensing method + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t csxCdacDitherEn; /**< Enabled CDAC dithering for CSX sensing method + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t isxCdacDitherEn; /**< Enabled CDAC dithering for ISX sensing method + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t bslnCoefSlow; /**< Baseline IIR filter coefficient (slow) for Low power widget. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t bslnCoefFast; /**< Baseline IIR filter coefficient (fast) for Low power widget. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t bslnUpdateDelay; /**< Specifies the value from which timer is decremented from on consecutive scans where the baseline update IIR produces a zero. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t iirCoeffLp; /**< Rawcount IIR filter coefficient for Low power widget + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + + uint8_t firstActSubFrame; /**< The flag for a first Active sub-frame. It is used for Active Low Refresh-rate scans + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t numFunc; /**< The number of pin functions, used in the project + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t mapPinState[CY_CAPSENSE_CTRLMUX_PIN_STATE_NUMBER]; /**< The map array of CTRLMUX pin functions, used in the project + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t operatingMode; /**< The internal fifth-generation low power CAPSENSE™ HW block operating mode + * * 0 - CY_CAPSENSE_CTL_OPERATING_MODE_CPU + * * 2 - CY_CAPSENSE_CTL_OPERATING_MODE_AS_MS + * * 3 - CY_CAPSENSE_CTL_OPERATING_MODE_LP_AOS + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t mrssStateAfterScan; /**< Defines the MRSS state after scan frame is complete. By default MRSS is left enabled */ + uint8_t repeatScanEn; /**< Defines if repeating the previous scan is allowed for the RepeatScan() function usage */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + + #if (!CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + en_hsiom_sel_t csxInactiveSnsHsiom; /**< Internal pre-calculated data for faster operation */ + en_hsiom_sel_t csdInactiveSnsHsiom; /**< Internal pre-calculated data for faster operation */ #endif + uint8_t intrCsdInactSnsConn; /**< Internal inactive electrode connection for CSD scan: + * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ + * * CY_CAPSENSE_SNS_CONNECTION_SHIELD + * * CY_CAPSENSE_SNS_CONNECTION_GROUND */ + uint8_t intrCsxInactSnsConn; /**< Internal inactive electrode connection for CSX scan: + * * CY_CAPSENSE_SNS_CONNECTION_HIGHZ + * * CY_CAPSENSE_SNS_CONNECTION_GROUND + * * CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2 */ + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) && (0u != CY_CAPSENSE_RC_HW_IIR_FILTER_EN)) + uint8_t hwIirInit; /**< Flag to reset/initialize HW IIR filter for active widgets during calibration, first scan, etc. */ + #endif }cy_stc_capsense_internal_context_t; /** Declares the structure that is intended to store the \ref cy_stc_capsense_widget_context_t * data structure fields, the CRC checking should be applied for. - * \note This structure is available only for the fourth-generation CAPSENSE™. */ typedef struct { @@ -1419,41 +1711,47 @@ typedef struct uint16_t lowBslnRstVal; /**< The value of the .lowBslnRst field of the \ref cy_stc_capsense_widget_context_t structure */ uint16_t snsClkVal; /**< The value of the .snsClk field of the \ref cy_stc_capsense_widget_context_t structure */ uint16_t rowSnsClkVal; /**< The value of the .rowSnsClk field of the \ref cy_stc_capsense_widget_context_t structure */ - uint16_t noiseThVal; /**< The value of the .noiseTh field of the \ref cy_stc_capsense_widget_context_t structure */ - uint16_t nNoiseThVal; /**< The value of the .nNoiseTh field of the \ref cy_stc_capsense_widget_context_t structure */ - uint16_t hysteresisVal; /**< The value of the .hysteresis field of the \ref cy_stc_capsense_widget_context_t structure */ - uint8_t onDebounceVal; /**< The value of the .onDebounce field of the \ref cy_stc_capsense_widget_context_t structure */ - uint8_t snsClkSourceVal; /**< The value of the .snsClkSource field of the \ref cy_stc_capsense_widget_context_t structure */ + uint16_t noiseThVal; /**< The value of the .noiseTh field of the \ref cy_stc_capsense_widget_context_t structure */ + uint16_t nNoiseThVal; /**< The value of the .nNoiseTh field of the \ref cy_stc_capsense_widget_context_t structure */ + uint16_t hysteresisVal; /**< The value of the .hysteresis field of the \ref cy_stc_capsense_widget_context_t structure */ + uint16_t maxRawCountVal; /**< The value of the .maxRawCount field of the \ref cy_stc_capsense_widget_context_t structure */ + uint16_t maxRawCountRowVal; /**< The value of the .maxRawCountRow field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t onDebounceVal; /**< The value of the .onDebounce field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t snsClkSourceVal; /**< The value of the .snsClkSource field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t bslnCoeffVal; /**< The value of the .bslnCoeff field of the \ref cy_stc_capsense_widget_context_t structure */ -#if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) - uint8_t idacModVal[CY_CAPSENSE_MAX_SUPPORTED_FREQ_NUM]; /**< The value of the .idacMod field of the \ref cy_stc_capsense_widget_context_t structure - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint8_t idacGainIndexVal; /**< The value of the .idacGainIndex field of the \ref cy_stc_capsense_widget_context_t structure - * \note This field is available only for the fourth-generation CAPSENSE™. - */ - uint8_t rowIdacModVal[CY_CAPSENSE_MAX_SUPPORTED_FREQ_NUM]; /**< The value of the .rowIdacMod field of the \ref cy_stc_capsense_widget_context_t structure - * \note This field is available only for the fourth-generation CAPSENSE™. - */ -#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) + uint8_t idacModVal[CY_CAPSENSE_MAX_SUPPORTED_FREQ_NUM]; /**< The value of the .idacMod field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t idacGainIndexVal; /**< The value of the .idacGainIndex field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t rowIdacModVal[CY_CAPSENSE_MAX_SUPPORTED_FREQ_NUM]; /**< The value of the .rowIdacMod field of the \ref cy_stc_capsense_widget_context_t structure */ + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) */ -#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - uint16_t cdacCompDivider; /**< The value of the .cdacCompDivider field of the \ref cy_stc_capsense_widget_context_t structure - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t cdacRef; /**< The value of the .cdacRef field of the \ref cy_stc_capsense_widget_context_t structure - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t rowCdacRef; /**< The value of the .rowCdacRef field of the \ref cy_stc_capsense_widget_context_t structure - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t cicRate; /**< The value of the .cicRate field of the \ref cy_stc_capsense_widget_context_t structure - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t lfsrBits; /**< The value of the .lfsrBits field of the \ref cy_stc_capsense_widget_context_t structure - * \note This field is available only for the fifth-generation CAPSENSE™. - */ -#endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) + uint8_t cdacDitherEnVal; /**< The value of the .cdacDitherEn field of the \ref cy_stc_capsense_widget_context_t structure */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint8_t cicShiftVal; /**< The value of the .cicShift field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t rowCicShiftVal; /**< The value of the .rowCicShift field of the \ref cy_stc_capsense_widget_context_t structure */ + #endif + + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) && \ + ((CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSD_CDAC_FINE_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_CSX_CDAC_FINE_EN) || \ + (CY_CAPSENSE_ENABLE == CY_CAPSENSE_ISX_CDAC_FINE_EN))) + uint8_t cdacFineVal; /**< The value of the .cdacFine field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t rowCdacFineVal; /**< The value of the .rowCdacFine field of the \ref cy_stc_capsense_widget_context_t structure */ + #endif + + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + uint16_t cdacCompDividerVal; /**< The value of the .cdacCompDivider field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t cdacRefVal; /**< The value of the .cdacRef field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t rowCdacRefVal; /**< The value of the .rowCdacRef field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t cicRateVal; /**< The value of the .cicRate field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t lfsrBitsVal; /**< The value of the .lfsrBits field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t cdacDitherValueVal; /**< The value of the .cdacDitherValue field of the \ref cy_stc_capsense_widget_context_t structure */ + uint8_t coarseInitBypassEnVal; /**< The value of the .coarseInitBypassEn field of the \ref cy_stc_capsense_widget_context_t structure */ + #endif /* (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) */ }cy_stc_capsense_widget_crc_data_t; /** \} */ @@ -1469,11 +1767,33 @@ typedef struct * Used by the CAPSENSE™ Tuner tool to identify if the FW corresponds to the specific user configuration. */ uint16_t tunerCmd; /**< Tuner Command Register \ref cy_en_capsense_tuner_cmd_t. * Used for the communication between the CAPSENSE™ Tuner tool and the middleware */ - uint16_t scanCounter; /**< This counter increments after each scan. */ + uint16_t scanCounter; /**< This counter increments after each scan of active widgets. */ uint8_t tunerSt; /**< State of CAPSENSE™ middleware tuner module. \ref cy_en_capsense_tuner_state_t */ uint8_t initDone; /**< Keep information whether initialization was done or not */ - volatile uint32_t status; /**< Middleware status information, scan in progress (1) or not (0). - * For MSCv3 each bit shows the correspondent channel status */ + volatile uint32_t status; /**< Middleware status information: + * * Bit[0-3] - The set [x] bit of the result means that the previously initiated scan for the [x] channel is in progress. + * For MSCv3 each bit shows a busyness of a corresponding sensing channel. + * The next scan frame cannot be started (CY_CAPSENSE_BUSY_ALL_CH_MASK) + * * Bit[4] - The last or currently scanned widget type is Active widget (CY_CAPSENSE_MW_STATE_ACTIVE_WD_SCAN_MASK) + * * Bit[5] - The last or currently scanned widget type is Low Power widget (CY_CAPSENSE_MW_STATE_LP_WD_SCAN_MASK) + * * Bit[6] - Reserved + * * Bit[7] - The previously initiated scan is in progress (CY_CAPSENSE_BUSY) + * * Bit[8] - Reserved + * * Bit[9] - Reserved + * * Bit[10] - A touch is detected on any low power widget. + * The bit is automatically cleared when a new low power scan triggered (CY_CAPSENSE_MW_STATE_LP_ACTIVE_MASK) + * * Bit[11] - CapSense Middleware performs BIST functionality which might include multiple HW scanning + * and result processing (CY_CAPSENSE_MW_STATE_BIST_MASK) + * * Bit[12] - The auto-calibration in Single CDAC mode (CY_CAPSENSE_MW_STATE_CALIBRATION_SINGLE_MASK) + * * Bit[13] - The auto-calibration is in progress. The next scan frame cannot be started (CY_CAPSENSE_MW_STATE_CALIBRATION_MASK) + * * Bit[14] - The smart sensing algorithm is in progress. The next scan frame cannot be started (CY_CAPSENSE_MW_STATE_SMARTSENSE_MASK) + * * Bit[15] - Middleware initialization is in progress and the next + * scan frame cannot be initiated (CY_CAPSENSE_MW_STATE_INITIALIZATION_MASK) + * * Bit[16-31] - The set [x] number of the result means that the previously initiated + * scan for the [x] slot is completed or in progress. In CS-DMA mode, this field is set only for the first + * scanned slot (CY_CAPSENSE_MW_STATE_SCAN_SLOT_MASK[x]) + * \note For the the forth-generation CAPSENSE™ only Bit[7] is available. + */ uint32_t timestampInterval; /**< Timestamp interval used at increasing the timestamp by Cy_CapSense_IncrementGestureTimestamp() */ uint32_t timestamp; /**< Current timestamp should be kept updated and operational, which is vital for the * operation of Gesture and Ballistic multiplier features */ @@ -1488,32 +1808,42 @@ typedef struct uint8_t tunerCnt; /**< Command counter of CAPSENSE™ middleware tuner module */ - #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) - uint8_t numFineInitCycles; /**< Number of ProDummy SubConversions - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint16_t numFineInitWaitCycles; /**< Number of ProDummy Wait Cycles - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint16_t lfsrPoly; /**< LFSR Polynomial - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t lfsrScale; /**< LFSR Scale value - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t cdacDitherSeed; /**< Dither CDAC Seed - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t cdacDitherPoly; /**< Dither CDAC Polynomial - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - uint8_t modClk; /**< The modulator clock divider - * \note This field is available only for the fifth-generation CAPSENSE™. - */ - #endif + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint16_t lpDataSt; /**< State of Low Power data processing: + * * Bit[0] = 0 (Default) - data is not copied and cannot be transmitted to Tuner + * * Bit[0] = 1 - data copied by CAPSENSE™ and transmitted to Tuner. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t lpFirstSnsId; /**< The first scanned low power sensor within LP frame. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t lpSnsNumber; /**< The number of consecutive scanned low power sensors from the .lpFirstSnsID. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t lpNumFrame; /**< The number of fully scanned low power frames available in the packet. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t lpScanCounter; /**< This counter increments after each scan of low power widgets. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + uint8_t lpScanSt; /**< The state / status of low power sensor baselines: + * * Bit[0] = 0 - baseline reset: does not happen + * * Bit[0] = 1 - baseline reset: happen + * * Bit[1] = 0 - baseline is not valid due to FIFO overflow + * * Bit[1] = 1 - baseline is valid. + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + } cy_stc_capsense_common_context_t; +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + /** Declares historic rawcount low power sensors */ + typedef uint16_t cy_stc_capsense_lp_historic_context_t; +#endif + + /** Declares top-level CAPSENSE™ context data structure */ typedef struct { @@ -1524,19 +1854,51 @@ typedef struct cy_stc_capsense_widget_context_t * ptrWdContext; /**< Pointer to the widget context structure */ const cy_stc_capsense_pin_config_t * ptrPinConfig; /**< Pointer to the pin configuration structure */ const cy_stc_capsense_pin_config_t * ptrShieldPinConfig; /**< Pointer to the shield pin configuration structure */ - cy_stc_active_scan_sns_t * ptrActiveScanSns; /**< Pointer to the current active sensor structure */ + cy_stc_capsense_active_scan_sns_t * ptrActiveScanSns; /**< Pointer to the current active sensor structure */ cy_stc_capsense_bist_context_t * ptrBistContext; /**< Pointer to the BIST context structure */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) cy_stc_msc_base_config_t * ptrBaseFrameContext; /**< Pointer to the first member of the context structure of base configuration array * \note This field is available only for the fifth-generation CAPSENSE™. */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + cy_stc_msclp_base_config_t * ptrBaseFrameContext; /**< Pointer to the first member of the context structure of base configuration array + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) uint32_t * ptrSensorFrameContext; /**< Pointer to the context structure of sensor configuration - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint32_t * ptrSensorFrameLpContext; /**< Pointer to the context structure of low power sensor configuration + * \note This field is available only for the fifth-generation low power CAPSENSE™. */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) const cy_stc_capsense_scan_slot_t * ptrScanSlots; /**< Pointer to the scan order slot structure - * \note This field is available only for the fifth-generation CAPSENSE™. + * \note This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™. */ - #endif + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + const cy_stc_capsense_scan_slot_t * ptrLpScanSlots; /**< Pointer to the low power scan order slot structure + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN || CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + cy_stc_capsense_lp_historic_context_t * ptrLpHistoricContext; + /**< Pointer to the low power historic data + * \note This field is available only for the fifth-generation low power CAPSENSE™. + */ + #endif /* CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP */ } cy_stc_capsense_context_t; /** \} */ @@ -1551,6 +1913,11 @@ typedef struct /******************************************************************************/ uint32_t Cy_CapSense_IsAnyWidgetActive(const cy_stc_capsense_context_t * context); + +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint32_t Cy_CapSense_IsAnyLpWidgetActive(const cy_stc_capsense_context_t * context); +#endif + uint32_t Cy_CapSense_IsWidgetActive( uint32_t widgetId, const cy_stc_capsense_context_t * context); @@ -1558,20 +1925,19 @@ uint32_t Cy_CapSense_IsSensorActive( uint32_t widgetId, uint32_t sensorId, const cy_stc_capsense_context_t * context); -#if(CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) +#if (CY_CAPSENSE_DISABLE != CY_CAPSENSE_CSD_PROXIMITY_EN) uint32_t Cy_CapSense_IsProximitySensorActive( uint32_t widgetId, uint32_t sensorId, const cy_stc_capsense_context_t * context); #endif -#if((CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) ||\ +#if ((CY_CAPSENSE_DISABLE != CY_CAPSENSE_TOUCHPAD_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_MATRIX_EN) ||\ (CY_CAPSENSE_DISABLE != CY_CAPSENSE_SLIDER_EN)) cy_stc_capsense_touch_t * Cy_CapSense_GetTouchInfo( uint32_t widgetId, const cy_stc_capsense_context_t * context); #endif - /** \} */ @@ -1592,7 +1958,11 @@ cy_capsense_status_t Cy_CapSense_SetParam( uint16_t Cy_CapSense_GetCRC( const uint8_t *ptrData, uint32_t len); - +cy_capsense_status_t Cy_CapSense_SetWidgetStatus( + uint32_t widgetId, + uint32_t mode, + uint32_t value, + cy_stc_capsense_context_t * context); /** \} */ @@ -1606,6 +1976,19 @@ cy_capsense_status_t Cy_CapSense_CheckConfigIntegrity( uint16_t Cy_CapSense_GetCrcWidget( uint32_t widgetId, cy_stc_capsense_context_t * context); +uint32_t Cy_CapSense_IsWidgetEnabled( + uint32_t widgetId, + const cy_stc_capsense_context_t * context); +#if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + void Cy_CapSense_SetSnsFrameValidity( + uint32_t widgetId, + cy_stc_capsense_context_t * context); +#endif +#if ((CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP)) + uint32_t Cy_CapSense_IsSlotEnabled( + uint32_t slotId, + const cy_stc_capsense_context_t * context); +#endif /** This enumeration is obsolete and should not be used further. * Instead some of the following macros with the _GROUP suffix should be used: @@ -1620,6 +2003,12 @@ typedef enum } cy_en_capsense_sensing_method_t; +/** This structure is obsolete and should not be used further. + * Instead cy_stc_capsense_active_scan_sns_t should be used. + */ +#define cy_stc_active_scan_sns_t cy_stc_capsense_active_scan_sns_t + + /** \} \endcond */ @@ -1627,7 +2016,7 @@ typedef enum } #endif -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif /* CY_CAPSENSE_STRUCTURE_H */ diff --git a/cy_capsense_tuner.c b/cy_capsense_tuner.c index 367da54..173b480 100644 --- a/cy_capsense_tuner.c +++ b/cy_capsense_tuner.c @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_tuner.c -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides the source code for the Tuner module functions. @@ -22,7 +22,7 @@ #include "cy_capsense_control.h" #include "cy_capsense_common.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) /******************************************************************************* @@ -37,6 +37,10 @@ void Cy_CapSense_TuInitialize(cy_stc_capsense_context_t * context) volatile cy_stc_capsense_common_context_t * ptrCommonCxt = context->ptrCommonContext; ptrCommonCxt->tunerCmd = (uint16_t)CY_CAPSENSE_TU_CMD_NONE_E; ptrCommonCxt->tunerSt = (uint8_t)CY_CAPSENSE_TU_FSM_RUNNING; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + ptrCommonCxt->lpDataSt = 0u; + ptrCommonCxt->lpScanSt = 0u; + #endif } @@ -83,8 +87,7 @@ void Cy_CapSense_TuInitialize(cy_stc_capsense_context_t * context) * Periodical calling the Cy_CapSense_RunTuner() function is: * * mandatory for operation of a UART-based tuner interface. The middleware * operation is always synchronous to the Tuner tool. -* * optional to periodically call Cy_CapSense_RunTuner() for EZI2C based -* interface. +* * optional for EZI2C based interface. * * If the Cy_CapSense_RunTuner() function is not periodically called by * the application program, the middleware operation is asynchronous to @@ -95,8 +98,9 @@ void Cy_CapSense_TuInitialize(cy_stc_capsense_context_t * context) * a scan multiply. Result - noise and SNR measurement are not accurate. * * The CAPSENSE™ Tuner tool and Host controller should not change the * parameters via the Tuner interface - in async mode this leads to -* abnormal behavior. +* abnormal behaviour. * * Displaying detected gestures may be missed. +* * The raw counts of CSX and/or ISX sensors may be non-inverted. * * \warning * This function executes received commands. Two commands @@ -119,26 +123,65 @@ void Cy_CapSense_TuInitialize(cy_stc_capsense_context_t * context) * * \funcusage * -* An example of synchronization with the Tuner tool using EzI2C: -* \snippet capsense/snippet/main.c snippet_Cy_CapSense_Tuner_EzI2C -* -* An example of synchronization with the Tuner tool using UART.
-* Tuner Send callback implementation: Transmitting data through UART interface: -* \snippet capsense/snippet/main.c snippet_TunerSend -* -* Tuner Receive callback implementation: Receiving data from UART interface: -* \snippet capsense/snippet/main.c snippet_TunerReceive +* An example of synchronization with the Tuner tool using EzI2C interface: +* +* -# In the Device Configurator, enable the SCB resource in the EzI2C mode +* with the "EZI2C" name. Configure interface parameters, assign required +* clock source and pins. Note that in the CapSense Tuner tool, I2C +* interface settings should match device EzI2C configuration. +* +* -# Declare EzI2C interface context: +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_EZI2C_Context +* +* -# Setup EzI2C interrupt handler: +* \snippet capsense/snippet/main.c snippet_Tuner_EzI2C_Isr +* +* -# Configure EzI2C buffer and use EzI2C as the tuner interface: +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_Tuner_EzI2C * -* A part of the main.c FW flow with registering callbacks: -* \snippet capsense/snippet/main.c snippet_Cy_CapSense_Tuner_UART +* +* An example of synchronization with the Tuner tool using UART interface: +* +* -# In the Device Configurator, enable the SCB resource in the UART mode +* with the "UART" name. Configure interface parameters, assign required +* clock source and pins. Note that in the CapSense Tuner tool, UART +* interface settings should match device UART configuration. +* +* -# Declare UART interface context: +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_UART_Context +* +* -# Setup UART interrupt handler: +* \snippet capsense/snippet/main.c snippet_Tuner_Uart_Isr +* +* -# Add Send callback implementation: +* \snippet capsense/snippet/main.c snippet_TunerSend +* +* -# Add Receive callback implementation: +* \snippet capsense/snippet/main.c snippet_TunerReceive +* +* -# Configure UART RX ring buffer and register Send and Receive callbacks +* as a part of the main.c FW flow: +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_Tuner_UART * * Refer to the \ref group_capsense_callbacks section for details. -* +* +* \note +* For the fifth-generation Low Power CAPSENSE™ you may encounter issue with +* the Tuner tool connection establishment for both EZI2C and UART interfaces. +* This may happen due to usage of the Sleep or Deep Sleep power modes during +* the scan operation. Depending on the project configuration, scan length may +* exceed the Tuner tool connection timeout. +* Since the Tuner tool resets the device during the connection establishment, +* you can add following code to your application after the communication interface +* initialization and before the main loop to eliminate the issue: +* +* \snippet capsense/snippet/main.c snippet_Cy_CapSense_Tuner_Delay +* *******************************************************************************/ uint32_t Cy_CapSense_RunTuner(cy_stc_capsense_context_t * context) { uint32_t interruptState; - uint32_t updateFlag = 0uL; + uint32_t updateFlag = 0u; uint32_t tunerStatus = CY_CAPSENSE_STATUS_RESTART_NONE; uint16_t tunerCommand; uint32_t cmdOffset; @@ -153,9 +196,13 @@ uint32_t Cy_CapSense_RunTuner(cy_stc_capsense_context_t * context) cy_capsense_tuner_send_callback_t sendCallback = context->ptrInternalContext->ptrTunerSendCallback; cy_capsense_tuner_receive_callback_t receiveCallback = context->ptrInternalContext->ptrTunerReceiveCallback; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + uint32_t sendDataFlag = 1u; + #endif + do { - /* + /* * ONE_SCAN command could be interpreted as two commands: * RESUME till next call of this function and then * SUSPEND till next command receiving. @@ -169,10 +216,12 @@ uint32_t Cy_CapSense_RunTuner(cy_stc_capsense_context_t * context) } /* Send Data to the CAPSENSE™ Tuner tool */ - if(NULL != sendCallback) - { - sendCallback((void *)context); - } + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)) + if (NULL != sendCallback) + { + sendCallback((void *)context); + } + #endif /* Command can come from EzI2C by direct writing into data structure */ tunerCommand = context->ptrCommonContext->tunerCmd; @@ -200,71 +249,95 @@ uint32_t Cy_CapSense_RunTuner(cy_stc_capsense_context_t * context) /* Check command register */ switch (tunerCommand) { - case (uint16_t)CY_CAPSENSE_TU_CMD_SUSPEND_E: - tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_SUSPENDED; - updateFlag = 1u; - break; - - case (uint16_t)CY_CAPSENSE_TU_CMD_RESUME_E: - tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_RUNNING; - updateFlag = 1u; - break; - - case (uint16_t)CY_CAPSENSE_TU_CMD_RESTART_E: - (void)Cy_CapSense_Enable(context); - tunerStatus = CY_CAPSENSE_STATUS_RESTART_DONE; - tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_RUNNING; - updateFlag = 1u; - break; - - case (uint16_t)CY_CAPSENSE_TU_CMD_PING_E: - tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_RUNNING; - updateFlag = 1u; - break; - - case (uint16_t)CY_CAPSENSE_TU_CMD_ONE_SCAN_E: - tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_ONE_SCAN; - updateFlag = 0u; - break; - - case (uint16_t)CY_CAPSENSE_TU_CMD_WRITE_E: - if((NULL != receiveCallback) && (NULL != commandPacket) && (NULL != tunerStructure)) - { - /* Tuner state is not changed */ - cmdOffset = (uint32_t)((uint32_t)commandPacket[CY_CAPSENSE_COMMAND_OFFS_0_IDX] << CY_CAPSENSE_MSB_SHIFT) | - (uint32_t)commandPacket[CY_CAPSENSE_COMMAND_OFFS_1_IDX]; - cmdSize = commandPacket[CY_CAPSENSE_COMMAND_SIZE_0_IDX]; + case (uint16_t)CY_CAPSENSE_TU_CMD_SUSPEND_E: + tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_SUSPENDED; + updateFlag = 1u; + break; - if (1u == cmdSize) - { - tunerStructure[cmdOffset] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 3u]; - } - else if (2u == cmdSize) - { - tunerStructure[cmdOffset + 1u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 2u]; - tunerStructure[cmdOffset + 0u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 3u]; - } - else - { - tunerStructure[cmdOffset + 3u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 0u]; - tunerStructure[cmdOffset + 2u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 1u]; - tunerStructure[cmdOffset + 1u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 2u]; - tunerStructure[cmdOffset + 0u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 3u]; - } + case (uint16_t)CY_CAPSENSE_TU_CMD_RESUME_E: + tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_RUNNING; + updateFlag = 1u; + break; + case (uint16_t)CY_CAPSENSE_TU_CMD_RESTART_E: + (void)Cy_CapSense_Enable(context); + tunerStatus = CY_CAPSENSE_STATUS_RESTART_DONE; + tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_RUNNING; updateFlag = 1u; - } - break; + break; - default: - /* No action on other commands */ - break; + case (uint16_t)CY_CAPSENSE_TU_CMD_RESTART_ONLY_E: + (void)Cy_CapSense_Enable(context); + tunerStatus = CY_CAPSENSE_STATUS_RESTART_DONE; + updateFlag = 1u; + break; + + case (uint16_t)CY_CAPSENSE_TU_CMD_PING_E: + #if ((CY_CAPSENSE_PLATFORM_BLOCK_FOURTH_GEN) || (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN)) + tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_RUNNING; + #endif + updateFlag = 1u; + break; + + case (uint16_t)CY_CAPSENSE_TU_CMD_ONE_SCAN_E: + tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_ONE_SCAN; + updateFlag = 0u; + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + sendDataFlag = 0u; + #endif + break; + + case (uint16_t)CY_CAPSENSE_TU_CMD_WRITE_E: + if ((NULL != receiveCallback) && (NULL != commandPacket) && (NULL != tunerStructure)) + { + /* Tuner state is not changed */ + cmdOffset = (uint32_t)((uint32_t)commandPacket[CY_CAPSENSE_COMMAND_OFFS_0_IDX] << CY_CAPSENSE_MSB_SHIFT) | + (uint32_t)commandPacket[CY_CAPSENSE_COMMAND_OFFS_1_IDX]; + cmdSize = commandPacket[CY_CAPSENSE_COMMAND_SIZE_0_IDX]; + + if (1u == cmdSize) + { + tunerStructure[cmdOffset] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 3u]; + } + else if (2u == cmdSize) + { + tunerStructure[cmdOffset + 1u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 2u]; + tunerStructure[cmdOffset + 0u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 3u]; + } + else + { + tunerStructure[cmdOffset + 3u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 0u]; + tunerStructure[cmdOffset + 2u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 1u]; + tunerStructure[cmdOffset + 1u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 2u]; + tunerStructure[cmdOffset + 0u] = commandPacket[CY_CAPSENSE_COMMAND_DATA_0_IDX + 3u]; + } + + updateFlag = 1u; + } + break; + + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + case (uint16_t)CY_CAPSENSE_TU_CMD_COMM_DIS_E: + context->ptrCommonContext->lpDataSt &= (uint16_t)(~CY_CAPSENSE_LP_PROCESS_ENABLED_MASK); + updateFlag = 1u; + break; + + case (uint16_t)CY_CAPSENSE_TU_CMD_COMM_EN_E: + context->ptrCommonContext->lpDataSt |= (uint16_t)CY_CAPSENSE_LP_PROCESS_ENABLED_MASK; + tunerState = (uint8_t)CY_CAPSENSE_TU_FSM_SUSPENDED; + updateFlag = 1u; + break; + #endif + + default: + /* No action on other commands */ + break; } ptrCommonCxt->tunerSt = tunerState; /* Set Complete flag in command register if needed */ - if (0uL != updateFlag) + if (0u != updateFlag) { interruptState = Cy_SysLib_EnterCriticalSection(); /* Check that command wasn't overwritten with new command */ @@ -274,11 +347,22 @@ uint32_t Cy_CapSense_RunTuner(cy_stc_capsense_context_t * context) ptrCommonCxt->tunerCnt = cmdCounter; } Cy_SysLib_ExitCriticalSection(interruptState); - updateFlag = 0uL; } + /* Send Data to the CAPSENSE™ Tuner tool */ + #if (CY_CAPSENSE_PLATFORM_BLOCK_FIFTH_GEN_LP) + if ((NULL != sendCallback) && + ((0u != updateFlag) || (0u != sendDataFlag))) + { + sendCallback((void *)context); + sendDataFlag = 0u; + } + #endif + + updateFlag = 0u; + } while ((uint8_t)CY_CAPSENSE_TU_FSM_SUSPENDED == tunerState); - + return tunerStatus; } @@ -353,7 +437,7 @@ uint32_t Cy_CapSense_CheckTunerCmdIntegrity(const uint8_t * commandPacket) { cmdCheckStatus = CY_CAPSENSE_WRONG_TAIL; } - else if (((uint8_t)CY_CAPSENSE_TU_CMD_WRITE_E) < commandPacket[CY_CAPSENSE_COMMAND_CODE_0_IDX]) + else if (((uint8_t)CY_CAPSENSE_TU_CMD_RESTART_ONLY_E) < commandPacket[CY_CAPSENSE_COMMAND_CODE_0_IDX]) { cmdCheckStatus = CY_CAPSENSE_WRONG_CODE; } @@ -370,7 +454,7 @@ uint32_t Cy_CapSense_CheckTunerCmdIntegrity(const uint8_t * commandPacket) return cmdCheckStatus; } -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ /* [] END OF FILE */ diff --git a/cy_capsense_tuner.h b/cy_capsense_tuner.h index 54e4a86..c8e42e0 100644 --- a/cy_capsense_tuner.h +++ b/cy_capsense_tuner.h @@ -1,6 +1,6 @@ /***************************************************************************//** * \file cy_capsense_tuner.h -* \version 3.0.1 +* \version 4.0 * * \brief * This file provides CAPSENSE™ MW Tuner module function prototypes. @@ -21,7 +21,7 @@ #include "cy_syslib.h" #include "cy_capsense_structure.h" -#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) +#if (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) #if defined(__cplusplus) extern "C" { @@ -135,7 +135,7 @@ __STATIC_INLINE uint16_t Cy_CapSense_CalculateCrc16(const uint8_t *ptrData, uint } #endif -#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3)) */ +#endif /* (defined(CY_IP_MXCSDV2) || defined(CY_IP_M0S8CSDV2) || defined(CY_IP_M0S8MSCV3) || defined(CY_IP_M0S8MSCV3LP)) */ #endif /* CY_CAPSENSE_TUNER_H */ diff --git a/docs/capsense_api_reference_manual/html/CAPSENSE_SOLUTION_MSCLP.png b/docs/capsense_api_reference_manual/html/CAPSENSE_SOLUTION_MSCLP.png new file mode 100644 index 0000000000000000000000000000000000000000..a8531217c5f6d9febb8a3ad916a425db3d2b9381 GIT binary patch literal 68379 zcmb@uby!tv^FF=+0ToFRkd#nRTIm!)u;^|Ol@hkn4GKzww9=uZl+ukzw}5n)f^_$H zHlFi--uJqGfBv{Ummc=sYprLVd1mgp=br7WASZ)=p7K0`Ao%z1Nhu)+);NM-vY*9) z-&`4MCWF7uy||}ojUZ%K(f?uGS7KU)UlQBg)v!@UJ+rYlw0eptTbjNww6=MwOWrXG zpF{3TNvJr){uy<2xoCSVzN#KtRPgCdq?5;$&56&{H&o9MlWJW`S~$=CO`ceaXo z^J~@{Wek_RlFN02{BX-#yD|0e&X`FAy~f4Pm|aag=W{+M60JI!I?72EZ*XmRDseIfzqG0V%Wz|pG8Wl{iCJ5^<{t5KUZQlDz;uX z`C}({`Z9a1;%IH;|Gl;*`}b2bPv9N2fukL#S5Lp1H!S#%Dg5(yul>E0)lIU0?;+RV zT-BVi7XSA`X6GvAV@}uW(^RkFa*>!=@#}u8{xPPw_}`^6k=h9}2RB;IOU-0oz`=6b z{&Nl)_-ahJT(QwXrd#cD7%}bR?_c*bTU-12QKi$?YrR~VyLa#UXJ14JXhnPs>)vY0 zy6^u^TU#z)DKcS`l42q#Lf^(Qy*-AXk%NOEBqU@Y&(JfgZjG|~a2*es7(Y4Yzj5P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{_U6*#@y@wx@&8G6zjqH zf2&LZ&nx(-(cL@&%0oMs7?h9w;kP9vCtf?y(El~T^lzW?zg)|Ief9sTc4x7;y??C! zMZ4VY#dqlc@E4o?<-*#5_zgRj^F@K##oun^e>GYGb@gL84n7mchc9P<3-$j*RL?u{ z_x!pCvER9+r7Ph7h9&U@ka`%j>C^E3*`?sX2bYSdtgP(Z{QLx|fO!kdt&YAvWdF`# z#-rwBe>|^$q&#{tiCYw0?-2adwu-&F$S7$3bef(8T -CAPSENSE™ Middleware Library 3.0.1: Data Structures +CAPSENSE™ Middleware Library 4.0: Data Structures @@ -30,7 +30,7 @@ Logo -

CAPSENSE™ Middleware Library 3.0.1
+
CAPSENSE™ Middleware Library 4.0
@@ -86,7 +86,7 @@
Here are the data structures with brief descriptions:
- + @@ -98,40 +98,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 Ccy_stc_active_scan_sns_tDeclares active sensor details
 Ccy_stc_capsense_active_scan_sns_tDeclares active sensor details
 Ccy_stc_capsense_adaptive_filter_config_tDeclares Adaptive Filter configuration parameters
 Ccy_stc_capsense_advanced_centroid_config_tDeclares Advanced Centroid configuration parameters
 Ccy_stc_capsense_advanced_touchpad_config_tConfiguration structure of advanced touchpad
 Ccy_stc_capsense_ballistic_delta_tDeclares Ballistic Displacement structure
 Ccy_stc_capsense_bist_context_tDeclares BIST Context Data Structure
 Ccy_stc_capsense_bist_custom_parameters_tDeclares the BIST structure with custom scan parameters
 Ccy_stc_capsense_common_config_tCommon configuration structure
 Ccy_stc_capsense_common_context_tDeclares top-level Context Data Structure
 Ccy_stc_capsense_context_tDeclares top-level CAPSENSE™ context data structure
 Ccy_stc_capsense_csx_touch_buffer_tInternal CSX Touchpad buffer structure for CSX for Touchpads' processing
 Ccy_stc_capsense_csx_touch_history_tCSX Touchpad touch tracking history
 Ccy_stc_capsense_electrode_config_tElectrode objects configuration structure
 Ccy_stc_capsense_gesture_config_tGesture configuration structure
 Ccy_stc_capsense_gesture_context_tGesture global context structure
 Ccy_stc_capsense_gesture_position_tGesture position structure
 Ccy_stc_capsense_hw_smartsense_config_tDeclares HW smart sensing algorithm data structure for CSD widgets for fifth-generation CAPSENSE™
 Ccy_stc_capsense_idac_gain_table_tDeclares the IDAC gain table
 Ccy_stc_capsense_internal_context_tDeclares internal Context Data Structure
 Ccy_stc_capsense_mptx_table_tMulti-phase TX table for de-convolution structure
 Ccy_stc_capsense_ofcd_context_tGesture One Finger Click and Drag context structure
 Ccy_stc_capsense_ofdc_context_tGesture One Finger Double Click context structure
 Ccy_stc_capsense_ofes_context_tGesture One Finger Edge Swipe context structure
 Ccy_stc_capsense_offl_context_tGesture One Finger Flick context structure
 Ccy_stc_capsense_ofrt_context_tGesture One Finger Rotate context structure
 Ccy_stc_capsense_ofsc_context_tGesture One Finger Single Click context structure
 Ccy_stc_capsense_ofsl_context_tGesture One Finger Scroll context structure
 Ccy_stc_capsense_pin_config_tLegacy mode pin configuration structure
 Ccy_stc_capsense_position_tDeclares position structure that keep information of a single touch
 Ccy_stc_capsense_scan_slot_tDeclares the scan order of widget and sensor
 Ccy_stc_capsense_sensor_context_tSensor context structure
 Ccy_stc_capsense_smartsense_csd_noise_envelope_tDeclares Noise envelope data structure for CSD widgets when smart sensing algorithm is enabled
 Ccy_stc_capsense_smartsense_update_thresholds_tDeclares Update Thresholds structure
 Ccy_stc_capsense_tfsc_context_tGesture Two Finger Single Click context structure
 Ccy_stc_capsense_tfsl_context_tGesture Two Finger Scroll context structure
 Ccy_stc_capsense_tfzm_context_tGesture Two Finger Zoom context structure
 Ccy_stc_capsense_touch_tDeclares touch structure used to store positions of Touchpad, Matrix buttons and Slider widgets
 Ccy_stc_capsense_widget_config_tWidget configuration structure
 Ccy_stc_capsense_widget_context_tWidget context structure
 Ccy_stc_capsense_widget_crc_data_tDeclares the structure that is intended to store the cy_stc_capsense_widget_context_t data structure fields, the CRC checking should be applied for
 Ccy_stc_msc_channel_config_tDeclares MSC channel (HW block) configuration
 Ccy_stc_capsense_channel_config_tDeclares MSC channel (HW block) configuration
 Ccy_stc_capsense_common_config_tCommon configuration structure
 Ccy_stc_capsense_common_context_tDeclares top-level Context Data Structure
 Ccy_stc_capsense_context_tDeclares top-level CAPSENSE™ context data structure
 Ccy_stc_capsense_csx_touch_buffer_tInternal CSX Touchpad buffer structure for CSX for Touchpads' processing
 Ccy_stc_capsense_csx_touch_history_tCSX Touchpad touch tracking history
 Ccy_stc_capsense_electrode_config_tElectrode objects configuration structure
 Ccy_stc_capsense_gesture_config_tGesture configuration structure
 Ccy_stc_capsense_gesture_context_tGesture global context structure
 Ccy_stc_capsense_gesture_position_tGesture position structure
 Ccy_stc_capsense_hw_smartsense_config_tDeclares HW smart sensing algorithm data structure for CSD widgets for fifth-generation CAPSENSE™
 Ccy_stc_capsense_idac_gain_table_tDeclares the IDAC gain table
 Ccy_stc_capsense_internal_context_tDeclares internal Context Data Structure
 Ccy_stc_capsense_mp_table_tMulti-phase table for de-convolution structure
 Ccy_stc_capsense_ofcd_context_tGesture One Finger Click and Drag context structure
 Ccy_stc_capsense_ofdc_context_tGesture One Finger Double Click context structure
 Ccy_stc_capsense_ofes_context_tGesture One Finger Edge Swipe context structure
 Ccy_stc_capsense_offl_context_tGesture One Finger Flick context structure
 Ccy_stc_capsense_oflp_context_tGesture One Finger Long Press context structure
 Ccy_stc_capsense_ofrt_context_tGesture One Finger Rotate context structure
 Ccy_stc_capsense_ofsc_context_tGesture One Finger Single Click context structure
 Ccy_stc_capsense_ofsl_context_tGesture One Finger Scroll context structure
 Ccy_stc_capsense_pin_config_tLegacy mode pin configuration structure
 Ccy_stc_capsense_position_tDeclares position structure that keep information of a single touch
 Ccy_stc_capsense_scan_slot_tDeclares the scan order of widget and sensor
 Ccy_stc_capsense_sensor_context_tSensor context structure
 Ccy_stc_capsense_smartsense_csd_noise_envelope_tDeclares Noise envelope data structure for CSD widgets when smart sensing algorithm is enabled
 Ccy_stc_capsense_smartsense_update_thresholds_tDeclares Update Thresholds structure
 Ccy_stc_capsense_tfsc_context_tGesture Two Finger Single Click context structure
 Ccy_stc_capsense_tfsl_context_tGesture Two Finger Scroll context structure
 Ccy_stc_capsense_tfzm_context_tGesture Two Finger Zoom context structure
 Ccy_stc_capsense_touch_tDeclares touch structure used to store positions of Touchpad, Matrix buttons and Slider widgets
 Ccy_stc_capsense_widget_config_tWidget configuration structure
 Ccy_stc_capsense_widget_context_tWidget context structure
 Ccy_stc_capsense_widget_crc_data_tDeclares the structure that is intended to store the cy_stc_capsense_widget_context_t data structure fields, the CRC checking should be applied for
@@ -140,7 +141,7 @@ @@ -230,8 +227,24 @@

-

Middleware status information, scan in progress (1) or not (0).

-

For MSCv3 each bit shows the correspondent channel status

+

Middleware status information:

+
    +
  • Bit[0-3] - The set [x] bit of the result means that the previously initiated scan for the [x] channel is in progress. For MSCv3 each bit shows a busyness of a corresponding sensing channel. The next scan frame cannot be started (CY_CAPSENSE_BUSY_ALL_CH_MASK)
  • +
  • Bit[4] - The last or currently scanned widget type is Active widget (CY_CAPSENSE_MW_STATE_ACTIVE_WD_SCAN_MASK)
  • +
  • Bit[5] - The last or currently scanned widget type is Low Power widget (CY_CAPSENSE_MW_STATE_LP_WD_SCAN_MASK)
  • +
  • Bit[6] - Reserved
  • +
  • Bit[7] - The previously initiated scan is in progress (CY_CAPSENSE_BUSY)
  • +
  • Bit[8] - Reserved
  • +
  • Bit[9] - Reserved
  • +
  • Bit[10] - A touch is detected on any low power widget. The bit is automatically cleared when a new low power scan triggered (CY_CAPSENSE_MW_STATE_LP_ACTIVE_MASK)
  • +
  • Bit[11] - CapSense Middleware performs BIST functionality which might include multiple HW scanning and result processing (CY_CAPSENSE_MW_STATE_BIST_MASK)
  • +
  • Bit[12] - The auto-calibration in Single CDAC mode (CY_CAPSENSE_MW_STATE_CALIBRATION_SINGLE_MASK)
  • +
  • Bit[13] - The auto-calibration is in progress. The next scan frame cannot be started (CY_CAPSENSE_MW_STATE_CALIBRATION_MASK)
  • +
  • Bit[14] - The smart sensing algorithm is in progress. The next scan frame cannot be started (CY_CAPSENSE_MW_STATE_SMARTSENSE_MASK)
  • +
  • Bit[15] - Middleware initialization is in progress and the next scan frame cannot be initiated (CY_CAPSENSE_MW_STATE_INITIALIZATION_MASK)
  • +
  • Bit[16-31] - The set [x] number of the result means that the previously initiated scan for the [x] slot is completed or in progress. In CS-DMA mode, this field is set only for the first scanned slot (CY_CAPSENSE_MW_STATE_SCAN_SLOT_MASK[x])
    Note
    For the the forth-generation CAPSENSE™ only Bit[7] is available.
    +
  • +
@@ -269,122 +282,115 @@

-

◆ numFineInitCycles

+ +

◆ lpDataSt

- +
uint8_t cy_stc_capsense_common_context_t::numFineInitCyclesuint16_t cy_stc_capsense_common_context_t::lpDataSt
-

Number of ProDummy SubConversions.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

State of Low Power data processing:

+
    +
  • Bit[0] = 0 (Default) - data is not copied and cannot be transmitted to Tuner
  • +
  • Bit[0] = 1 - data copied by CAPSENSE™ and transmitted to Tuner.
    Note
    This field is available only for the fifth-generation low power CAPSENSE™.
    +
  • +
- -

◆ numFineInitWaitCycles

+ +

◆ lpFirstSnsId

- +
uint16_t cy_stc_capsense_common_context_t::numFineInitWaitCyclesuint8_t cy_stc_capsense_common_context_t::lpFirstSnsId
-

Number of ProDummy Wait Cycles.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

The first scanned low power sensor within LP frame.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
- -

◆ lfsrPoly

+ +

◆ lpSnsNumber

- +
uint16_t cy_stc_capsense_common_context_t::lfsrPolyuint8_t cy_stc_capsense_common_context_t::lpSnsNumber
-

LFSR Polynomial.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

The number of consecutive scanned low power sensors from the .lpFirstSnsID.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
- -

◆ lfsrScale

+ +

◆ lpNumFrame

- +
uint8_t cy_stc_capsense_common_context_t::lfsrScaleuint8_t cy_stc_capsense_common_context_t::lpNumFrame
-

LFSR Scale value.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

The number of fully scanned low power frames available in the packet.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
- -

◆ cdacDitherSeed

+ +

◆ lpScanCounter

- +
uint8_t cy_stc_capsense_common_context_t::cdacDitherSeeduint8_t cy_stc_capsense_common_context_t::lpScanCounter
-

Dither CDAC Seed.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

This counter increments after each scan of low power widgets.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
- -

◆ cdacDitherPoly

+ +

◆ lpScanSt

- +
uint8_t cy_stc_capsense_common_context_t::cdacDitherPolyuint8_t cy_stc_capsense_common_context_t::lpScanSt
-

Dither CDAC Polynomial.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
- -
-
- -

◆ modClk

- -
-
- - - - -
uint8_t cy_stc_capsense_common_context_t::modClk
-
- -

The modulator clock divider.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

The state / status of low power sensor baselines:

+
    +
  • Bit[0] = 0 - baseline reset: does not happen
  • +
  • Bit[0] = 1 - baseline reset: happen
  • +
  • Bit[1] = 0 - baseline is not valid due to FIFO overflow
  • +
  • Bit[1] = 1 - baseline is valid.
    Note
    This field is available only for the fifth-generation low power CAPSENSE™.
    +
  • +
@@ -394,7 +400,7 @@

diff --git a/docs/capsense_api_reference_manual/html/structcy__stc__capsense__context__t.html b/docs/capsense_api_reference_manual/html/structcy__stc__capsense__context__t.html index 4c085a8..dd8ad2f 100644 --- a/docs/capsense_api_reference_manual/html/structcy__stc__capsense__context__t.html +++ b/docs/capsense_api_reference_manual/html/structcy__stc__capsense__context__t.html @@ -6,7 +6,7 @@ -CAPSENSE™ Middleware Library 3.0.1: cy_stc_capsense_context_t Struct Reference +CAPSENSE™ Middleware Library 4.0: cy_stc_capsense_context_t Struct Reference @@ -30,7 +30,7 @@
Logo -
CAPSENSE™ Middleware Library 3.0.1
+
CAPSENSE™ Middleware Library 4.0
@@ -119,10 +119,10 @@ const cy_stc_capsense_pin_config_tptrShieldPinConfig  Pointer to the shield pin configuration structure.
  - -cy_stc_active_scan_sns_tptrActiveScanSns - Pointer to the current active sensor structure.
-  + +cy_stc_capsense_active_scan_sns_tptrActiveScanSns + Pointer to the current active sensor structure.
cy_stc_capsense_bist_context_tptrBistContext  Pointer to the BIST context structure.
@@ -130,16 +130,28 @@ cy_stc_msc_base_config_t * ptrBaseFrameContext  Pointer to the first member of the context structure of base configuration array. More...
  +cy_stc_msclp_base_config_t * ptrBaseFrameContext + Pointer to the first member of the context structure of base configuration array. More...
+  uint32_t * ptrSensorFrameContext  Pointer to the context structure of sensor configuration. More...
  +uint32_t * ptrSensorFrameLpContext + Pointer to the context structure of low power sensor configuration. More...
+  const cy_stc_capsense_scan_slot_tptrScanSlots  Pointer to the scan order slot structure. More...
  +const cy_stc_capsense_scan_slot_tptrLpScanSlots + Pointer to the low power scan order slot structure. More...
+  +cy_stc_capsense_lp_historic_context_tptrLpHistoricContext + Pointer to the low power historic data. More...

Field Documentation

-

◆ ptrBaseFrameContext

+

◆ ptrBaseFrameContext [1/2]

+ +

◆ ptrBaseFrameContext [2/2]

+ +
+
+ + + + +
cy_stc_msclp_base_config_t* cy_stc_capsense_context_t::ptrBaseFrameContext
+
+ +

Pointer to the first member of the context structure of base configuration array.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+
@@ -168,7 +197,24 @@

Pointer to the context structure of sensor configuration.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
+ + + +
+

◆ ptrSensorFrameLpContext

+ +
+
+ + + + +
uint32_t* cy_stc_capsense_context_t::ptrSensorFrameLpContext
+
+ +

Pointer to the context structure of low power sensor configuration.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
@@ -185,7 +231,41 @@

Pointer to the scan order slot structure.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
+ + + +
+

◆ ptrLpScanSlots

+ +
+
+ + + + +
const cy_stc_capsense_scan_slot_t* cy_stc_capsense_context_t::ptrLpScanSlots
+
+ +

Pointer to the low power scan order slot structure.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ ptrLpHistoricContext

+ +
+
+ + + + +
cy_stc_capsense_lp_historic_context_t* cy_stc_capsense_context_t::ptrLpHistoricContext
+
+ +

Pointer to the low power historic data.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
@@ -195,7 +275,7 @@

diff --git a/docs/capsense_api_reference_manual/html/structcy__stc__capsense__csx__touch__buffer__t.html b/docs/capsense_api_reference_manual/html/structcy__stc__capsense__csx__touch__buffer__t.html index 15d6f73..945ce82 100644 --- a/docs/capsense_api_reference_manual/html/structcy__stc__capsense__csx__touch__buffer__t.html +++ b/docs/capsense_api_reference_manual/html/structcy__stc__capsense__csx__touch__buffer__t.html @@ -6,7 +6,7 @@ -CAPSENSE™ Middleware Library 3.0.1: cy_stc_capsense_csx_touch_buffer_t Struct Reference +CAPSENSE™ Middleware Library 4.0: cy_stc_capsense_csx_touch_buffer_t Struct Reference @@ -30,7 +30,7 @@
Logo -
CAPSENSE™ Middleware Library 3.0.1
+
CAPSENSE™ Middleware Library 4.0
@@ -142,7 +142,7 @@ - -

◆ scanSingleSlot

+ +

◆ numValidSlots

- +
uint8_t cy_stc_capsense_internal_context_t::scanSingleSlotuint16_t cy_stc_capsense_internal_context_t::numValidSlots
-

Request of scanning just one slot with keeping HW configuration after scan:

-
    -
  • CY_CAPSENSE_SCAN_SNGL_SLOT - Single slot scanning
  • -
  • CY_CAPSENSE_SCAN_MULTIPLE_SLOT - Multiple slot scanning
    Note
    This field is available only for the fifth-generation CAPSENSE™.
    -
  • -
+

Number of valid slots.

+
Note
This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™.
- -

◆ numSenseMethod

+ +

◆ firstValidSlot

- +
uint8_t cy_stc_capsense_internal_context_t::numSenseMethoduint16_t cy_stc_capsense_internal_context_t::firstValidSlot
-

The number of sense methods, used in the project.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

The first valid slots ID.

+
Note
This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™.
- -

◆ mapSenseMethod

+ +

◆ lfsrPoly

- +
uint8_t cy_stc_capsense_internal_context_t::mapSenseMethod[CY_CAPSENSE_REG_MODE_NUMBER]uint16_t cy_stc_capsense_internal_context_t::lfsrPoly
-

The map array of sense methods, used in the project.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

LFSR Polynomial.

+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
- -

◆ numProOffsetCycles

+ +

◆ numFineInitWaitCycles

- +
uint8_t cy_stc_capsense_internal_context_t::numProOffsetCyclesuint16_t cy_stc_capsense_internal_context_t::numFineInitWaitCycles
-

Maximum number of clk_mod cycles for the PRO_OFFSET state.

+

Number of ProDummy Wait Cycles.

Note
This field is available only for the fifth-generation CAPSENSE™.
- -

◆ proOffsetCdacComp

+ +

◆ numEpiCycles

- +
uint8_t cy_stc_capsense_internal_context_t::proOffsetCdacCompuint16_t cy_stc_capsense_internal_context_t::numEpiCycles
-

Compensation CAPDAC size during PRO_OFFSET.

+

Number of clk_mod cycles to be run during EPILOGUE.

Note
This field is available only for the fifth-generation CAPSENSE™.
- -

◆ hwConfigState

+ +

◆ numProWaitKrefDelayPrs

- +
uint8_t cy_stc_capsense_internal_context_t::hwConfigStateuint16_t cy_stc_capsense_internal_context_t::numProWaitKrefDelayPrs
-

Contains the current hw state, it is configured or not and if yes then to what operation.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

Number of Kref/4 ProDummy Wait Cycles if PRS is enabled.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
- -

◆ slotAutoCalibrMode

+ +

◆ numProWaitKrefDelay

- +
uint8_t cy_stc_capsense_internal_context_t::slotAutoCalibrModeuint16_t cy_stc_capsense_internal_context_t::numProWaitKrefDelay
-

The slot auto-calibration mode:

-
    -
  • 0 - CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR
  • -
  • 2 - CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR
  • -
  • 3 - CY_CAPSENSE_CAL_MODE_COMP_CDAC_MAX_CODE
    Note
    This field is available only for the fifth-generation CAPSENSE™.
    -
  • -
+

Number of Kref/4 ProDummy Wait Cycles if PRS is disabled.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
- -

◆ intrCsdRawTarget

+ +

◆ numEpiKrefDelayPrs

- +
uint8_t cy_stc_capsense_internal_context_t::intrCsdRawTargetuint16_t cy_stc_capsense_internal_context_t::numEpiKrefDelayPrs
-

Internal auto-calibration target in percentage for CSD widgets.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

Number of Kref/4 cycles to be run during EPILOGUE if PRS is enabled.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
- -

◆ intrCsxRawTarget

+ +

◆ numEpiKrefDelay

- +
uint8_t cy_stc_capsense_internal_context_t::intrCsxRawTargetuint16_t cy_stc_capsense_internal_context_t::numEpiKrefDelay
-

Internal auto-calibration target in percentage for CSX widgets.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

Number of Kref/4 cycles to be run during EPILOGUE if PRS is disabled.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ numSlots

+ +
+
+ + + + +
uint16_t cy_stc_capsense_internal_context_t::numSlots
+
+ +

The number of slots in the current frame.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ startSlotIndex

+ +
+
+ + + + +
uint16_t cy_stc_capsense_internal_context_t::startSlotIndex
+
+ +

The start slot ID for the current scan.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ wotTimeout

+ +
+
+ + + + +
uint16_t cy_stc_capsense_internal_context_t::wotTimeout
+
+ +

The number of frames to be scanned in Wake-on-Touch mode when there is no touch.

+

The maximum value is limited to the 14 bits, the applicable range is [1..16383].

Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ intrIsxInactSnsConn

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::intrIsxInactSnsConn
+
+ +

Internal inactive electrode connection for ISX scan:

+
    +
  • CY_CAPSENSE_SNS_CONNECTION_HIGHZ
  • +
  • CY_CAPSENSE_SNS_CONNECTION_GROUND
  • +
+ +
+
+ +

◆ numFineInitCycles

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::numFineInitCycles
+
+ +

Number of ProDummy SubConversions.

+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ lfsrScale

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::lfsrScale
+
+ +

LFSR Scale value.

+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ cdacDitherSeed

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::cdacDitherSeed
+
+ +

Dither CDAC Seed.

+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ cdacDitherPoly

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::cdacDitherPoly
+
+ +

Dither CDAC Polynomial.

+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ modClk

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::modClk
+
+ +

The modulator clock divider.

+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ scanSingleSlot

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::scanSingleSlot
+
+ +

Request of scanning just one slot with keeping HW configuration after scan:

+
    +
  • CY_CAPSENSE_SCAN_SNGL_SLOT - Single slot scanning
  • +
  • CY_CAPSENSE_SCAN_MULTIPLE_SLOT - Multiple slot scanning
    Note
    This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™.
    +
  • +
+ +
+
+ +

◆ numProOffsetCycles

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::numProOffsetCycles
+
+ +

Maximum number of clk_mod cycles for the PRO_OFFSET state.

+
Note
This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ proOffsetCdacComp

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::proOffsetCdacComp
+
+ +

Compensation CAPDAC size during PRO_OFFSET.

+
Note
This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ hwConfigState

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::hwConfigState
+
+ +

Contains the current hw state, it is configured or not and if yes then to what operation.

+
Note
This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ slotAutoCalibrMode

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::slotAutoCalibrMode
+
+ +

The slot auto-calibration mode:

+
    +
  • 0 - CY_CAPSENSE_CAL_MODE_REF_CDAC_SUC_APPR
  • +
  • 2 - CY_CAPSENSE_CAL_MODE_COMP_CDAC_SUC_APPR
  • +
  • 3 - CY_CAPSENSE_CAL_MODE_FINE_CDAC_SUC_APPR
    Note
    This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™.
    +
  • +
+ +
+
+ +

◆ intrCsdRawTarget

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::intrCsdRawTarget
+
+ +

Internal auto-calibration target in percentage for CSD widgets.

+
Note
This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ intrCsxRawTarget

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::intrCsxRawTarget
+
+ +

Internal auto-calibration target in percentage for CSX widgets.

+
Note
This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ intrIsxRawTarget

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::intrIsxRawTarget
+
+ +

Internal auto-calibration target in percentage for ISX widgets.

+
Note
This field is available only for the fifth-generation and for the fifth-generation low power CAPSENSE™
+ +
+
+ +

◆ numSenseMethod

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::numSenseMethod
+
+ +

The number of sense methods, used in the project.

+
Note
This field is available only for the fifth-generation CAPSENSE™.
+ +
+
+ +

◆ mapSenseMethod

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::mapSenseMethod[CY_CAPSENSE_REG_MODE_NUMBER]
+
+ +

The map array of sense methods, used in the project.

+
Note
This field is available only for the fifth-generation CAPSENSE™.
+ +
+
+ +

◆ csdCdacDitherEn

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::csdCdacDitherEn
+
+ +

Enabled CDAC dithering for CSD sensing method.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ csxCdacDitherEn

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::csxCdacDitherEn
+
+ +

Enabled CDAC dithering for CSX sensing method.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ isxCdacDitherEn

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::isxCdacDitherEn
+
+ +

Enabled CDAC dithering for ISX sensing method.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ bslnCoefSlow

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::bslnCoefSlow
+
+ +

Baseline IIR filter coefficient (slow) for Low power widget.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ bslnCoefFast

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::bslnCoefFast
+
+ +

Baseline IIR filter coefficient (fast) for Low power widget.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ bslnUpdateDelay

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::bslnUpdateDelay
+
+ +

Specifies the value from which timer is decremented from on consecutive scans where the baseline update IIR produces a zero.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ iirCoeffLp

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::iirCoeffLp
+
+ +

Rawcount IIR filter coefficient for Low power widget.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ firstActSubFrame

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::firstActSubFrame
+
+ +

The flag for a first Active sub-frame.

+

It is used for Active Low Refresh-rate scans

Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ numFunc

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::numFunc
+
+ +

The number of pin functions, used in the project.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ mapPinState

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::mapPinState[CY_CAPSENSE_CTRLMUX_PIN_STATE_NUMBER]
+
+ +

The map array of CTRLMUX pin functions, used in the project.

+
Note
This field is available only for the fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ operatingMode

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::operatingMode
+
+ +

The internal fifth-generation low power CAPSENSE™ HW block operating mode.

+
    +
  • 0 - CY_CAPSENSE_CTL_OPERATING_MODE_CPU
  • +
  • 2 - CY_CAPSENSE_CTL_OPERATING_MODE_AS_MS
  • +
  • 3 - CY_CAPSENSE_CTL_OPERATING_MODE_LP_AOS
    Note
    This field is available only for the fifth-generation low power CAPSENSE™.
    +
  • +
+ +
+
+ +

◆ mrssStateAfterScan

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::mrssStateAfterScan
+
+ +

Defines the MRSS state after scan frame is complete.

+

By default MRSS is left enabled

+ +
+
+ +

◆ intrCsdInactSnsConn

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::intrCsdInactSnsConn
+
+ +

Internal inactive electrode connection for CSD scan:

+
    +
  • CY_CAPSENSE_SNS_CONNECTION_HIGHZ
  • +
  • CY_CAPSENSE_SNS_CONNECTION_SHIELD
  • +
  • CY_CAPSENSE_SNS_CONNECTION_GROUND
  • +
+ +
+
+ +

◆ intrCsxInactSnsConn

+ +
+
+ + + + +
uint8_t cy_stc_capsense_internal_context_t::intrCsxInactSnsConn
+
+ +

Internal inactive electrode connection for CSX scan:

+
    +
  • CY_CAPSENSE_SNS_CONNECTION_HIGHZ
  • +
  • CY_CAPSENSE_SNS_CONNECTION_GROUND
  • +
  • CY_CAPSENSE_SNS_CONNECTION_VDDA_BY_2
  • +
@@ -1259,7 +1936,7 @@

diff --git a/docs/capsense_api_reference_manual/html/structcy__stc__capsense__mptx__table__t.html b/docs/capsense_api_reference_manual/html/structcy__stc__capsense__mp__table__t.html similarity index 70% rename from docs/capsense_api_reference_manual/html/structcy__stc__capsense__mptx__table__t.html rename to docs/capsense_api_reference_manual/html/structcy__stc__capsense__mp__table__t.html index d771526..7990cf0 100644 --- a/docs/capsense_api_reference_manual/html/structcy__stc__capsense__mptx__table__t.html +++ b/docs/capsense_api_reference_manual/html/structcy__stc__capsense__mp__table__t.html @@ -6,7 +6,7 @@ -CAPSENSE™ Middleware Library 3.0.1: cy_stc_capsense_mptx_table_t Struct Reference +CAPSENSE™ Middleware Library 4.0: cy_stc_capsense_mp_table_t Struct Reference @@ -30,7 +30,7 @@
Logo -
CAPSENSE™ Middleware Library 3.0.1
+
CAPSENSE™ Middleware Library 4.0
@@ -62,7 +62,7 @@
@@ -83,23 +83,23 @@
-
cy_stc_capsense_mptx_table_t Struct Reference
+
cy_stc_capsense_mp_table_t Struct Reference

Description

-

Multi-phase TX table for de-convolution structure.

-
Note
This structure is available only for the fifth-generation CAPSENSE™.
+

Multi-phase table for de-convolution structure.

+
Note
This structure is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
- - - - - - + + + + + +

Data Fields

-uint32_t vector
 TX vector / pattern.
 
-int16_t deconvCoef [32u]
 De-convolution coefficients.
 
+uint32_t vector
 Vector / pattern.
 
+int16_t deconvCoef [32u]
 De-convolution coefficients.
 
@@ -107,7 +107,7 @@ @@ -386,25 +400,26 @@

-

◆ ptrMptxTable

+ +

◆ ptrMpTable

- +
cy_stc_capsense_mptx_table_t* cy_stc_capsense_widget_config_t::ptrMptxTablecy_stc_capsense_mp_table_t* cy_stc_capsense_widget_config_t::ptrMpTable
-

Pointer to the multi-phase TX vector and de-convolution coefficients.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

Pointer to the multi-phase vector and de-convolution coefficients.

+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
@@ -421,7 +436,7 @@

The slot ID in the widget to start scan from.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
@@ -438,7 +453,7 @@

The number of slots in the widget.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
@@ -455,24 +470,41 @@

Defines number of chopping cycles.

-

One cycle means the feature is disabled

Note
This field is available only for the fifth-generation CAPSENSE™.
+

One cycle means the feature is disabled

Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
-
-

◆ mptxOrder

+ +

◆ mpOrder

- +
uint8_t cy_stc_capsense_widget_config_t::mptxOrderuint8_t cy_stc_capsense_widget_config_t::mpOrder
-

Multi-phase TX order.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+

Multi-phase order.

+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
+ +
+
+ +

◆ mpOrderRows

+ +
+
+ + + + +
uint8_t cy_stc_capsense_widget_config_t::mpOrderRows
+
+ +

Multi-phase order for rows in CSD widgets.

+
Note
This field is available for the fifth-generation low power CAPSENSE™.
@@ -489,7 +521,7 @@

Max dither in percentage.

-

The input parameter for the LFSR range auto-selection algorithm

Note
This field is available only for the fifth-generation CAPSENSE™.
+

The input parameter for the LFSR range auto-selection algorithm

Note
This field is available for the fifth-generation CAPSENSE™and fifth-generation low power CAPSENSE™.
@@ -506,7 +538,7 @@

Defines set of rules that are used by clock source auto-selection algorithm.

-
Note
This field is available only for the fifth-generation CAPSENSE™.
+
Note
This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
@@ -533,12 +565,29 @@

Note
This field is available only for the fifth-generation CAPSENSE™.
+
  • 2 - Frequency channel 2 widget (CY_CAPSENSE_MFS_WIDGET_FREQ_CH_2_MASK)
    Note
    This field is available for the fifth-generation CAPSENSE™ and fifth-generation low power CAPSENSE™.
  • + + +
    +

    ◆ iirCoeffHw

    + +
    +
    + + + + +
    uint8_t cy_stc_capsense_widget_config_t::iirCoeffHw
    +
    + +

    Raw count HW IIR filter coefficient.

    +

    Smaller value leads to lower filtering.

    Note
    This field is available only for the fifth-generation low power CAPSENSE™.
    +
    @@ -547,7 +596,7 @@

    diff --git a/docs/capsense_api_reference_manual/html/structcy__stc__capsense__widget__context__t.html b/docs/capsense_api_reference_manual/html/structcy__stc__capsense__widget__context__t.html index 9b9070f..4ebde14 100644 --- a/docs/capsense_api_reference_manual/html/structcy__stc__capsense__widget__context__t.html +++ b/docs/capsense_api_reference_manual/html/structcy__stc__capsense__widget__context__t.html @@ -6,7 +6,7 @@ -CAPSENSE™ Middleware Library 3.0.1: cy_stc_capsense_widget_context_t Struct Reference +CAPSENSE™ Middleware Library 4.0: cy_stc_capsense_widget_context_t Struct Reference @@ -30,7 +30,7 @@
    Logo -
    CAPSENSE™ Middleware Library 3.0.1
    +
    CAPSENSE™ Middleware Library 4.0
    @@ -160,7 +160,7 @@  Widget Debounce for the signal above the finger threshold 1 to 255. More...
      uint8_t snsClkSource - Widget clock source: More...
    + Widget clock source. More...
      uint8_t idacMod [CY_CAPSENSE_MAX_SUPPORTED_FREQ_NUM]  Sets the current of the modulation IDAC for the CSD widgets. More...
    @@ -188,8 +188,14 @@  Sets the capacitance of the reference CDAC. More...
      uint8_t rowCdacRef - Sets the capacitance of the reference CDAC for CSD Touchpad and CSD Matrix buttons widgets. More...
    + Sets the capacitance of the row reference CDAC for CSD Touchpad and CSD Matrix buttons widgets. More...
      +uint8_t cdacFine + Sets the capacitance of the fine CDAC. More...
    +  +uint8_t rowCdacFine + Sets the capacitance of the row fine CDAC for CSD Touchpad and CSD Matrix buttons widgets. More...
    +  uint8_t cicRate  Sets decimation rate when CIC2 is enabled. More...
      @@ -208,6 +214,12 @@ uint8_t lfsrBits  Defines the number of LSB bits to use by the LSFR unit to achieve the desired clock dithering variation. More...
      +uint8_t cicShift + Sets the right shift value applied to CIC2 accumulator to form rawcounts when CIC2 is enabled. More...
    +  +uint8_t rowCicShift + Sets the right shift value applied to CIC2 accumulator to form rawcounts when CIC2 is enabled. More...

    Field Documentation

    @@ -294,8 +306,8 @@

    -

    Widget clock source:

    -