-
Notifications
You must be signed in to change notification settings - Fork 4
/
cy_capsense_selftest_lp.c
4310 lines (3981 loc) · 192 KB
/
cy_capsense_selftest_lp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/***************************************************************************//**
* \file cy_capsense_selftest_lp.c
* \version 5.0
*
* \brief
* This file provides the source code to the Built-in Self-test (BIST)
* functions.
*
********************************************************************************
* \copyright
* Copyright 2021-2024, 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 <stddef.h>
#include <string.h>
#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)
#define CY_CAPSENSE_BIST_ELTD_CAP_NUM_EPI_CYCLES (2u)
/*******************************************************************************
* 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 sensor pins 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_<WidgetName>_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_<WidgetName>_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_<WidgetName>_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_<WidgetName>_SNS<SensorNumber>_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_<WidgetName>_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_<WidgetName>_SNS<SensorNumber>_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_<WidgetName>_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_<WidgetName>_SNS<SensorNumber>_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_<WidgetName>_RX<RXNumber>_ID
* * CapSense_<WidgetName>_TX<TXNumber>_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)