forked from Infineon/capsense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcy_capsense_csx.c
1336 lines (1177 loc) · 58.4 KB
/
cy_capsense_csx.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_csx.c
* \version 2.0
*
* \brief
* This file defines the data structure global variables and provides
* implementation for the low-level functions of the CSX part of
* the Sensing module. The file contains the functions used for the CSD HW block
* initialization, calibration, and scanning.
*
********************************************************************************
* \copyright
* Copyright 2018-2019, 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 "cy_syslib.h"
#include "cy_sysclk.h"
#include "cy_gpio.h"
#include "cy_csd.h"
#include "cy_device_headers.h"
#include "cy_capsense_common.h"
#include "cy_capsense_structure.h"
#include "cy_capsense_csx.h"
#include "cy_capsense_sensing.h"
#if defined(CY_IP_MXCSDV2)
/*******************************************************************************
* Local function declarations
*******************************************************************************/
/******************************************************************************/
/** \cond SECTION_CAPSENSE_INTERNAL */
/** \addtogroup group_capsense_internal *//** \{ */
/******************************************************************************/
static void Cy_CapSense_CSXChangeClkFreq(uint32_t channelIndex, cy_stc_capsense_context_t * context);
static void Cy_CapSense_CSXStartSample(cy_stc_capsense_context_t * context);
static void Cy_CapSense_CSXInitNextChScan(cy_stc_capsense_context_t * context);
static void Cy_CapSense_CSXInitNextScan(cy_stc_capsense_context_t * context);
__STATIC_INLINE void Cy_CapSense_CSXStartSampleExt(cy_stc_capsense_context_t * context);
/** \} \endcond */
/*******************************************************************************
* Function Name: Cy_CapSense_CSXInitialize
****************************************************************************//**
*
* Performs hardware and firmware initialization required for the CSX operation
* of the CapSense middleware.
*
* This function initializes hardware to perform the CSX sensing operation.
* If both CSX and CSD sensing methods are used in the
* middleware, this function is called by the Cy_CapSense_SetupWidget() to
* change hardware configured for CSD sensing method to re-initialize for the
* CSX sensing method.
*
* If the CSD and CSX widgets are used in the middleware, do not
* mix the CSD widgets between the CSX widgets. Instead, place all
* CSX widgets in the required scanning order and then place the CSD widgets
* in the CapSense Configurator tool.
* For the middleware, this action will eliminate the need for changing
* the CSD HW block configuration for every widget scan and will increase the
* execution speed in the Cy_CapSense_ScanAllWidgets() when the function is
* called.
*
* Similarly, set up and scan all the CSX widgets in such
* a sequence that the Cy_CapSense_SetupWidget() does not need to perform
* hardware sensing-configuration switches.
*
* 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_CSXInitialize(cy_stc_capsense_context_t * context)
{
uint32_t interruptState;
uint32_t tmpRegVal;
cy_stc_capsense_fptr_config_t * ptrFptrCfg = (cy_stc_capsense_fptr_config_t *)context->ptrFptrConfig;
Cy_CapSense_DischargeExtCapacitors(context);
interruptState = Cy_SysLib_EnterCriticalSection();
Cy_GPIO_SetDrivemode(context->ptrCommonConfig->portCintA, (uint32_t)context->ptrCommonConfig->pinCintA, CY_GPIO_DM_ANALOG);
Cy_GPIO_SetDrivemode(context->ptrCommonConfig->portCintB, (uint32_t)context->ptrCommonConfig->pinCintB, CY_GPIO_DM_ANALOG);
Cy_SysLib_ExitCriticalSection(interruptState);
/* Clear all pending interrupts of the CSD HW block */
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_INTR, CY_CAPSENSE_CSD_INTR_ALL_MSK);
/* Enable the End Of Scan interrupt */
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_INTR_MASK, CY_CAPSENSE_DEFAULT_CSD_INTR_MASK_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_HSCMP, CY_CAPSENSE_DEFAULT_CSD_HSCMP_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_AMBUF, CY_CAPSENSE_DEFAULT_CSD_AMBUF_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_REFGEN, context->ptrInternalContext->csxRegRefgen );
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_CSDCMP, CY_CAPSENSE_DEFAULT_CSD_CSDCMP_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_IDACA, CY_CAPSENSE_DEFAULT_CSD_IDACA_CFG);
if (0u != context->ptrCommonConfig->csdIdacCompEn)
{
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_IDACB, CY_CAPSENSE_DEFAULT_CSD_IDACB_CFG);
}
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_RES,context->ptrInternalContext->csxRegSwResInit);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SENSE_DUTY, CY_CAPSENSE_DEFAULT_CSD_SENSE_DUTY_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_HS_P_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_HS_P_SEL_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_HS_N_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_HS_N_SEL_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_SHIELD_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_SHIELD_SEL_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_AMUXBUF_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_AMUXBUF_SEL_CFG);
tmpRegVal = Cy_CSD_ReadReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_BYP_SEL);
tmpRegVal &= ~(CY_CAPSENSE_CSD_SW_BYP_SEL_SW_BYA_MSK);
tmpRegVal |= CY_CAPSENSE_DEFAULT_CSD_SW_BYP_SEL_CFG;
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_BYP_SEL, tmpRegVal);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_CMP_P_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_CMP_P_SEL_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_CMP_N_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_CMP_N_SEL_CFG);
tmpRegVal = Cy_CSD_ReadReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_REFGEN_SEL);
tmpRegVal &= ~CY_CAPSENSE_DEFAULT_CSD_SW_REFGEN_SEL_MSK;
tmpRegVal |= context->ptrInternalContext->regSwRefGenSel ;
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_REFGEN_SEL, tmpRegVal);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_FW_MOD_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_FW_MOD_SEL_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_FW_TANK_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_FW_TANK_SEL_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SW_DSI_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_DSI_SEL_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_IO_SEL, CY_CAPSENSE_DEFAULT_CSD_SW_IO_SEL_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SEQ_TIME, 0u);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SEQ_INIT_CNT, (uint32_t)context->ptrCommonConfig->csxFineInitTime);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SEQ_NORM_CNT, CY_CAPSENSE_DEFAULT_CSD_SEQ_NORM_CNT_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_ADC_CTL, CY_CAPSENSE_DEFAULT_CSD_ADC_CTL_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SEQ_START, CY_CAPSENSE_DEFAULT_CSD_SEQ_START_CFG);
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_CONFIG, context->ptrInternalContext->csxRegConfigInit);
Cy_CapSense_SetClkDivider((uint32_t)context->ptrCommonContext->modCsxClk - 1u, context);
/* Set all IO states to the default state */
Cy_CapSense_SetIOsInDefaultState(context);
/* Enable the CSD HW block interrupt and set interrupt vector to CSX sensing method */
if(NULL != ptrFptrCfg->fptrCSXScanISR)
{
context->ptrActiveScanSns->ptrISRCallback = ptrFptrCfg->fptrCSXScanISR;
}
context->ptrActiveScanSns->mfsChannelIndex = 0u;
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXElectrodeCheck
****************************************************************************//**
*
* Check whether electrodes were previously connected using
* the Cy_CapSense_CSXSetupWidgetExt() function and if yes, disconnect them.
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXElectrodeCheck(cy_stc_capsense_context_t * context)
{
if (CY_CAPSENSE_SNS_CONNECTED == context->ptrActiveScanSns->connectedSnsState)
{
/* Disconnect all Tx pins */
Cy_CapSense_CSXDisconnectTxExt(context);
/* Disconnect all Rx pins */
Cy_CapSense_CSXDisconnectRxExt(context);
/* Mark the current sensor as disconnected */
context->ptrActiveScanSns->connectedSnsState = CY_CAPSENSE_SNS_DISCONNECTED;
}
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXDisableMode
****************************************************************************//**
*
* This function disables CSX mode.
*
* To disable CSX mode, the following tasks are performed:
* 1. Disconnect previous CSX electrode if it has been connected.
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXDisableMode(cy_stc_capsense_context_t * context)
{
/* Disconnect previous CSX electrode if it has been connected */
Cy_CapSense_CSXElectrodeCheck(context);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXSetupWidget
****************************************************************************//**
*
* Performs the initialization required to scan the specified CSX widget.
*
* \note This function is obsolete and kept for backward compatibility only.
* The Cy_CapSense_SetupWidget() function should be used instead.
*
* This function prepares the middleware to scan all the sensors in the
* specified CSX widget by executing the following tasks:
* 1. Configure the CSD HW block if it is not configured to perform the
* CSX sensing method used by the specified widget.
* 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
* connected by the Cy_CapSense_CSDSetupWidgetExt(),
* Cy_CapSense_CSXSetupWidgetExt() functions are not disconnected.
*
* This function does not start sensor scanning. The Cy_CapSense_CSXScan()
* function must be called to start the scan sensors in the widget. If this
* function is called more than once, it does not break the middleware
* operation, but only the last initialized widget is in effect.
* Calling this function directly from the application program is not
* recommended. This function is used to implement only the user's specific
* use cases (for example faster execution).
*
* The status of a sensor scan must be checked using the Cy_CapSense_IsBusy()
* function prior to starting a next scan or setting up another 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_<WIDGET_NAME>_WDGT_ID.
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXSetupWidget(uint32_t widgetId, cy_stc_capsense_context_t * context)
{
/* variable to access widget details */
uint32_t snsClkDivider;
uint32_t snsClkSrc;
uint32_t tmpRegVal;
Cy_CapSense_SwitchSensingMode((uint8_t)CY_CAPSENSE_SENSE_METHOD_CSX_E, context);
/*
* Check whether CSX electrodes were previously connected using
* Cy_CapSense_CSXSetupWidgetExt and if yes, disconnect them
*/
Cy_CapSense_CSXElectrodeCheck(context);
/* Set up widget and its first sensor IDs and pointers to have assess to them after scanning */
Cy_CapSense_InitActivePtr(widgetId, 0u, context);
/* Number of conversion and maxRawCount setup */
tmpRegVal = (uint32_t)context->ptrActiveScanSns->ptrWdContext->resolution;
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SEQ_NORM_CNT, tmpRegVal);
context->ptrActiveScanSns->ptrWdContext->maxRawCount = (uint16_t)tmpRegVal *
(context->ptrActiveScanSns->ptrWdContext->snsClk - CY_CAPSENSE_CSX_DEADBAND_CYCLES_NUMBER);
/* SnsClk setup */
snsClkDivider = (uint32_t) context->ptrActiveScanSns->ptrWdContext->snsClk;
/* Check divider value */
if (0u == snsClkDivider)
{
snsClkDivider = 1u;
}
snsClkSrc = (uint32_t)context->ptrActiveScanSns->ptrWdContext->snsClkSource & (uint32_t)~((uint32_t)CY_CAPSENSE_CLK_SOURCE_AUTO_MASK);
tmpRegVal = ((snsClkSrc << CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_SIZE_POS) | (snsClkDivider - 1u) |
CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_CLEAR_MSK | CY_CAPSENSE_CSD_SENSE_PERIOD_LFSR_BITS_MSK);
/* Update reg value with divider and configuration */
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_SENSE_PERIOD, tmpRegVal);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXSetupWidgetExt
****************************************************************************//**
*
* Performs extended initialization required to scan a specified sensor in
* a widget using CSX sensing method.
*
* \note This function is obsolete and kept for backward compatibility only.
* The Cy_CapSense_SetupWidgetExt() function should be used instead.
*
* This function performs the same tasks of Cy_CapSense_CSXSetupWidget() and
* also connects and configures specified sensor for scan. Hence this
* function, along with Cy_CapSense_CSXScanExt() function, can be used to
* scan a specific sensor in the widget.
*
* This function should be called for a widget that is configured to use
* CSX sensing method. Using this function on a non-CSX sensing widget
* would cause an unexpected result.
*
* This function requires using the Cy_CapSense_CSXScanExt() function to
* initiate a scan.
*
* Calling this function directly from the application program is not
* recommended. This function is used to implement only the user's
* specific use cases (for example faster execution).
*
* \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_<WIDGET_NAME>_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_<WIDGET_NAME>_SNS<SENSOR_NUMBER>_ID.
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXSetupWidgetExt(
uint32_t widgetId,
uint32_t sensorId,
cy_stc_capsense_context_t * context)
{
/* Initialize widget */
Cy_CapSense_CSXSetupWidget_Call(widgetId, context);
/* Initialize sensor data structure pointer to appropriate address */
Cy_CapSense_InitActivePtrSns(sensorId, context);
/* Connect current sensor`s Tx and Rx IOs for scan
* and set flag to indicate that IOs should be disconnected */
Cy_CapSense_CSXConnectTxExt(context);
Cy_CapSense_CSXConnectRxExt(context);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXScan
****************************************************************************//**
*
* This function initiates a scan for the sensors of the widget initialized
* by the Cy_CapSense_CSXSetupWidget() function.
*
* \note This function is obsolete and kept for backward compatibility only.
* The Cy_CapSense_Scan() function should be used instead.
*
* This function does the following tasks:
* 1. Connects the first sensor of the widget.
* 2. Configures the IDAC value.
* 3. Starts scanning for the first sensor in the widget.
*
* This function is called by the Cy_CapSense_Scan() if the given
* widget uses the CSX sensing method.
*
* Calling this function directly from the application program is not
* recommended. This function is used to implement only the user's specific
* use cases (for example faster execution).
*
* This function is called when no scanning is in progress. I.e.
* Cy_CapSense_IsBusy() returns a non-busy status and the widget must be
* preconfigured using the Cy_CapSense_CSXSetupWidget() function prior
* to calling this function.
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXScan(cy_stc_capsense_context_t * context)
{
Cy_CapSense_InitActivePtrSns(0u, context);
/* Connect electrodes */
Cy_CapSense_CSXConnectTxExt(context);
Cy_CapSense_CSXConnectRxExt(context);
/* Set Start of scan flag */
Cy_CapSense_SetBusyFlags(context);
/* Set scope flag */
context->ptrActiveScanSns->scanScopeSns = CY_CAPSENSE_SCAN_SCOPE_ALL_SNS;
Cy_CapSense_CSXStartSample(context);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXScanExt()
****************************************************************************//**
*
* Starts the CSD conversion on the preconfigured sensor.
*
* \note This function is obsolete and kept for backward compatibility only.
* The Cy_CapSense_ScanExt() function should be used instead.
*
* This function performs scanning of a specific sensor in the widget
* previously initialized using the Cy_CapSense_CSXSetupWidgetExt() function.
*
* This function is called when no scanning is in progress.
* I.e. Cy_CapSense_IsBusy() returns a non-busy status and the widget must
* be preconfigured using Cy_CapSense_CSXSetupWidgetExt() function prior
* to calling this function. Calling this function directly from
* the application program is not recommended. This function is used to
* implement only the user's specific use cases (for example faster execution).
*
* This function does not disconnect sensor GPIOs from CSD HW block at the
* end of a scan, therefore making subsequent scan of the same sensor is faster.
* If sensor must be disconnected after the scan,
* the Cy_CapSense_CSXDisconnectTx() or Cy_CapSense_CSXDisconnectRx() functions
* can be used.
*
* Calling Cy_CapSense_SetupWidget(), Cy_CapSense_CSXSetupWidget(),
* Cy_CapSense_ScanAllWidgets(), or if Cy_CapSense_RunTuner() returns
* CY_CAPSENSE_STATUS_RESTART_DONE status invalidated initialization
* made by this function.
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXScanExt(cy_stc_capsense_context_t * context)
{
cy_stc_active_scan_sns_t * ptrActive = context->ptrActiveScanSns;
/* Set MFS channel index to 0 */
ptrActive->mfsChannelIndex = 0u;
/* Initialize the Active Context pointer with the CH0 context */
ptrActive->ptrSnsContext = &ptrActive->ptrWdConfig->ptrSnsContext[ptrActive->sensorIndex];
/* Set busy flag and start conversion */
Cy_CapSense_SetBusyFlags(context);
/* Set scope flag */
context->ptrActiveScanSns->scanScopeSns = CY_CAPSENSE_SCAN_SCOPE_SGL_SNS;
Cy_CapSense_CSXStartSample(context);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXCalibrateWidget
****************************************************************************//**
*
* Executes the IDAC calibration for all the sensors in the widget specified in
* the input.
*
* \note This function is obsolete and kept for backward compatibility only.
* The Cy_CapSense_CalibrateWidget() function should be used instead.
*
* Performs a successive approximation search algorithm to find appropriate
* IDAC values for all sensors in the specified widget that provide
* the raw count to the level specified by the target parameter.
*
* Calibration returns CYRET_BAD_DATA if the achieved raw count is outside
* of the range specified by the target and acceptable calibration deviation
* parameters.
*
* This function could be used when the CSX Enable IDAC auto-calibration
* parameter is enabled.
*
* \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_<WIDGET_NAME>_WDGT_ID.
*
* \param target
* Specifies the calibration target in percentages of the maximum raw count.
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
* \return
* Returns the status of the specified widget calibration:
* - CYRET_SUCCESS - The operation is successfully completed.
* - CYRET_BAD_PARAM - The input parameter is invalid.
* - CYRET_BAD_DATA - The calibration failed and CapSense may not operate
* as expected.
* - CYRET_INVALID_STATE - The previous scanning is not completed, and
* the CapSense middleware is busy.
*
*******************************************************************************/
cy_status Cy_CapSense_CSXCalibrateWidget(
uint32_t widgetId,
uint32_t target,
cy_stc_capsense_context_t * context)
{
uint32_t cpuFreqMHz;
uint32_t watchdogCounter;
uint32_t freqChIndex;
uint32_t freqChNumber;
cy_status calibrateStatus = CY_RET_SUCCESS;
const cy_stc_capsense_widget_config_t * ptrWdCfg;
cy_stc_capsense_sensor_context_t * ptrActSnsContext;
uint32_t rawTarget;
uint32_t totalSns;
uint32_t calibrationIndex;
/* Currently used IDAC-bit */
uint8_t curIdacMask = CY_CAPSENSE_CAL_MIDDLE_VALUE;
/* Next used IDAC-bit */
uint8_t nextIdacMask = (curIdacMask >> 1u);
/* Approximate duration of Wait For Init loop */
const uint32_t isBusyLoopDuration = 5uL;
/* Wait For Init watchdog timeout in microseconds */
const uint32_t isBusyWatchdogTimeUs = 200000uL;
if((context->ptrCommonConfig->numWd <= widgetId) ||
(CY_CAPSENSE_DISABLE == context->ptrCommonConfig->csxIdacAutocalEn))
{
calibrateStatus = CY_RET_BAD_PARAM;
}
if((uint8_t)CY_CAPSENSE_SENSE_METHOD_CSX_E != context->ptrWdConfig[widgetId].senseMethod)
{
calibrateStatus = CY_RET_BAD_PARAM;
}
if(CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY))
{
/* Previous widget is being scanned, return error */
calibrateStatus = CYRET_INVALID_STATE;
}
if(CY_RET_SUCCESS == calibrateStatus)
{
ptrWdCfg = &context->ptrWdConfig[widgetId];
ptrWdCfg->ptrWdContext->idacGainIndex = context->ptrCommonConfig->csxIdacGainInitIndex;
ptrActSnsContext = ptrWdCfg->ptrSnsContext;
totalSns = ptrWdCfg->numSns;
/* Calculate target raw count */
rawTarget = ((uint32_t)context->ptrWdContext[widgetId].maxRawCount * target) / CY_CAPSENSE_PERCENTAGE_100;
freqChNumber = (CY_CAPSENSE_ENABLE == context->ptrCommonConfig->mfsEn) ? 3u : 1u;
for(freqChIndex = 0u; freqChIndex < freqChNumber; freqChIndex++)
{
/* Clear raw count registers and IDAC registers of all the sensors/nodes */
for (calibrationIndex = 0u; calibrationIndex < totalSns; calibrationIndex++)
{
ptrActSnsContext[calibrationIndex + (freqChIndex * context->ptrCommonConfig->numSns)].raw = 0u;
ptrActSnsContext[calibrationIndex + (freqChIndex * context->ptrCommonConfig->numSns)].idacComp = curIdacMask;
}
}
/* Perform binary search for accurate IDAC value for each sensor/node */
do
{
/* Scan all the sensors/nodes in widget */
(void)Cy_CapSense_SetupWidget(widgetId, context);
(void)Cy_CapSense_Scan(context);
cpuFreqMHz = context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA;
watchdogCounter = Cy_CapSense_WatchdogCyclesNum(isBusyWatchdogTimeUs, cpuFreqMHz, isBusyLoopDuration);
/* Wait for EOS */
while (CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY))
{
if(0uL == watchdogCounter)
{
break;
}
watchdogCounter--;
}
/* Set pointer to the widget's first sensor data */
ptrActSnsContext = ptrWdCfg->ptrSnsContext;
for (freqChIndex = 0u; freqChIndex < freqChNumber; freqChIndex++)
{
/* Check raw count and adjust IDAC, loop through all the sensors/nodes */
for (calibrationIndex = 0u; calibrationIndex < totalSns; calibrationIndex++)
{
/* Check whether the current raw count is above target.
* If yes, clear the MS bit of bit.
* If no, keep the MS bit and set next bit.
*/
if (ptrActSnsContext[calibrationIndex + (freqChIndex * context->ptrCommonConfig->numSns)].raw > rawTarget)
{
ptrActSnsContext[calibrationIndex + (freqChIndex * context->ptrCommonConfig->numSns)].idacComp &= (uint8_t)(~curIdacMask);
}
ptrActSnsContext[calibrationIndex + (freqChIndex * context->ptrCommonConfig->numSns)].idacComp |= nextIdacMask;
}
}
/* Shift both current IDAC and pre IDAC values to the right by 1 */
curIdacMask = nextIdacMask;
nextIdacMask = nextIdacMask >> 1u;
}
while (curIdacMask != 0u);
calibrateStatus = CY_RET_SUCCESS;
}
if(CY_RET_SUCCESS == calibrateStatus)
{
/* Perform specified widget scan to check calibration result */
/* Scan all the sensors/nodes in widget */
(void)Cy_CapSense_SetupWidget(widgetId, context);
(void)Cy_CapSense_Scan(context);
cpuFreqMHz = context->ptrCommonConfig->cpuClkHz / CY_CAPSENSE_CONVERSION_MEGA;
watchdogCounter = Cy_CapSense_WatchdogCyclesNum(isBusyWatchdogTimeUs, cpuFreqMHz, isBusyLoopDuration);
/* Wait for EOS */
while (CY_CAPSENSE_BUSY == (context->ptrCommonContext->status & CY_CAPSENSE_BUSY))
{
if(0uL == watchdogCounter)
{
calibrateStatus = CY_RET_TIMEOUT;
break;
}
watchdogCounter--;
}
calibrateStatus = Cy_CapSense_CalibrateCheck(widgetId, target, (uint32_t)CY_CAPSENSE_SENSE_METHOD_CSX_E, context);
}
return(calibrateStatus);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXSetUpIdacs
****************************************************************************//**
*
* Configures IDAC for the CSX sensing method.
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXSetUpIdacs(cy_stc_capsense_context_t * context)
{
uint32_t tmpRegVal;
/* Set IDAC gain */
tmpRegVal = context->ptrCommonConfig->idacGainTable[context->ptrActiveScanSns->ptrWdContext->idacGainIndex].gainReg;
/* Set IDAC code */
tmpRegVal |= (uint32_t)context->ptrActiveScanSns->ptrSnsContext->idacComp & CY_CAPSENSE_CSD_IDACA_VAL_MSK;
tmpRegVal |= CY_CAPSENSE_DEFAULT_CSD_IDACA_CFG;
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_IDACA, tmpRegVal);
}
/*******************************************************************************
* Function Name: Cy_CapSense_SsCSXStartSample
****************************************************************************//**
*
* Starts scanning for the CSX widget.
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
static void Cy_CapSense_CSXStartSample(cy_stc_capsense_context_t * context)
{
/* Set up IDAC Value */
Cy_CapSense_CSXSetUpIdacs(context);
/* Clear previous interrupts */
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_INTR, CY_CAPSENSE_CSD_INTR_ALL_MSK);
(void)Cy_CSD_ReadReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_INTR);
/* Enable interrupt */
Cy_CSD_WriteReg(context->ptrCommonConfig->ptrCsdBase, CY_CSD_REG_OFFSET_INTR_MASK, CY_CAPSENSE_CSD_INTR_MASK_SAMPLE_MSK);
if(NULL != context->ptrCommonContext->ptrSSCallback)
{
context->ptrCommonContext->ptrSSCallback(context->ptrActiveScanSns);
}
Cy_CapSense_CSXStartSampleExt(context);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXConnectRx
****************************************************************************//**
*
* Connects port pin (an Rx electrode) to the CSD HW block using AMUX bus.
*
* This function can be used to customize the default sensor connection
* by connecting one or more pins to an existing sensor as an Rx electrode
* prior to initiating scan of the sensor.
*
* The function ignores whether the sensor is a ganged sensor and
* connects only a specified port pin to the CSD HW block. This function can
* only use GPIOs that is already assigned to CapSense middleware.
*
* The functions that perform a setup and scan of a sensor/widget do not
* take into account changes in the design made by
* the Cy_CapSense_CSXConnectRx() function. Hence all GPIOs connected
* using this function must be disconnected using
* the Cy_CapSense_CSXDisconnectRx() function prior to initializing
* new widgets. Use this function in StartSample
* callback (see the \ref group_capsense_callbacks section for details)
* or with low-level functions that perform a single-sensor scanning.
*
* Scanning should be completed before calling this function.
*
* \param rxPtr
* Specifies the pointer to the cy_stc_capsense_pin_config_t object belonging to
* a sensor which to be connected to the CSD HW block as an Rx electrode.
*
* \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,
cy_stc_capsense_context_t * context)
{
Cy_CapSense_SsConfigPinRegisters(rxPtr->pcPtr, (uint32_t)rxPtr->pinNumber, CY_GPIO_DM_ANALOG, CY_CAPSENSE_HSIOM_SEL_AMUXA);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXConnectTx
****************************************************************************//**
*
* Connects port pin (a Tx electrode) to the CSD HW block.
*
* This function can be used to customize the default sensor connection
* by connecting one or more pins to an existing sensor as a Tx electrode
* prior to initiating scan of the sensor.
*
* The function ignores whether the sensor is a ganged sensor and
* connects only a specified port pin to the CSD HW block. This function can
* only use GPIOs that is already assigned to CapSense middleware.
*
* The functions that perform a setup and scan of a sensor/widget do not
* take into account changes in the design made by
* the Cy_CapSense_CSXConnectTx() function. Hence all GPIOs connected
* using this function must be disconnected using
* the Cy_CapSense_CSXDisconnectTx() function prior to initializing
* new widgets. Use this function in StartSample
* callback (see the \ref group_capsense_callbacks section for details)
* or with low-level functions that perform a single-sensor scanning.
*
* Scanning should be completed before calling this function.
*
* \param txPtr
* Specifies the pointer to the cy_stc_capsense_pin_config_t object belonging to
* a sensor which to be connected to the CSD HW block as a Tx electrode.
*
* \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,
cy_stc_capsense_context_t * context)
{
Cy_CapSense_SsConfigPinRegisters(txPtr->pcPtr, (uint32_t)txPtr->pinNumber, CY_GPIO_DM_STRONG_IN_OFF, CY_CAPSENSE_HSIOM_SEL_CSD_SHIELD);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXDisconnectRx
****************************************************************************//**
*
* Disconnects port pin (an Rx electrode) from the CSD HW block by disconnecting
* it from the AMUX bus.
*
* This function can be used to disconnect a sensor connected
* using the Cy_CapSense_CSXConnectRx() function. In addition, this
* function can be used to customize default sensor connection by
* disconnecting one or more already connected sensors prior to
* initiating scan of the sensor.
*
* This function works identically to the Cy_CapSense_CSDConnectRx() function
* except it disconnects the specified port pin used by the sensor.
*
* Scanning should be completed before calling this function.
*
* \param rxPtr
* Specifies the pointer to the cy_stc_capsense_pin_config_t object belonging
* to an Rx pin sensor to be disconnected from the CSD HW block.
*
* \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,
cy_stc_capsense_context_t * context)
{
uint32_t interruptState;
Cy_CapSense_SsConfigPinRegisters(rxPtr->pcPtr, (uint32_t)rxPtr->pinNumber, CY_GPIO_DM_STRONG_IN_OFF, CY_CAPSENSE_HSIOM_SEL_GPIO);
interruptState = Cy_SysLib_EnterCriticalSection();
Cy_GPIO_Clr(rxPtr->pcPtr, (uint32_t)rxPtr->pinNumber);
Cy_SysLib_ExitCriticalSection(interruptState);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXDisconnectTx
****************************************************************************//**
*
* Disconnects port pin (a Tx electrode) from the CSD HW block.
*
* This function can be used to disconnect a sensor connected
* using the Cy_CapSense_CSXConnectTx() function. In addition, this
* function can be used to customize default sensor connection by
* disconnecting one or more already connected sensors prior to
* initiating scan of the sensor.
*
* This function works identically to the Cy_CapSense_CSDConnectTx() function
* except it disconnects the specified port pin used by the sensor.
*
* Scanning should be completed before calling this function.
*
* \param txPtr
* Specifies the pointer to the cy_stc_capsense_pin_config_t object belonging
* to a Tx pin sensor to be disconnected from the CSD HW block.
*
* \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,
cy_stc_capsense_context_t * context)
{
Cy_CapSense_SsConfigPinRegisters(txPtr->pcPtr, (uint32_t)txPtr->pinNumber, CY_GPIO_DM_STRONG_IN_OFF, CY_CAPSENSE_HSIOM_SEL_GPIO);
Cy_GPIO_Clr(txPtr->pcPtr, (uint32_t)txPtr->pinNumber);
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXConnectTxExt
****************************************************************************//**
*
* Connects a current Tx electrode to the CSX scanning hardware.
*
* This function connects all current Tx electrode's pins to the CSD_SENSE signal.
* It is assumed that drive mode of the port pin is already set to STRONG
* in the HSIOM_PORT_SELx register.
*
* Calling this function directly from the application program is not
* recommended. This function is used to implement only the user's specific
* use cases (for faster execution time when there is only one port pin for an
* electrode for example).
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXConnectTxExt(cy_stc_capsense_context_t * context)
{
uint32_t pinIndex;
const cy_stc_capsense_pin_config_t * pinPointer = context->ptrActiveScanSns->ptrTxConfig->ptrPin;
for (pinIndex = context->ptrActiveScanSns->ptrTxConfig->numPins; pinIndex-- > 0u;)
{
Cy_CapSense_CSXConnectTx(pinPointer, context);
pinPointer++;
}
context->ptrActiveScanSns->connectedSnsState = CY_CAPSENSE_SNS_CONNECTED;
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXConnectRxExt
****************************************************************************//**
*
* Connects a current Rx electrode to the CSX scanning hardware.
*
* This function connects all current Rx electrode's pins to the CSD_SENSE signal.
* It is assumed that drive mode of the port pin is already set to STRONG
* in the HSIOM_PORT_SELx register.
*
* Calling this function directly from the application program is not
* recommended. This function is used to implement only the user's specific
* use cases (for faster execution time when there is only one port pin for an
* electrode for example).
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXConnectRxExt(cy_stc_capsense_context_t * context)
{
uint32_t pinIndex;
const cy_stc_capsense_pin_config_t * pinPointer = context->ptrActiveScanSns->ptrRxConfig->ptrPin;
for (pinIndex = context->ptrActiveScanSns->ptrRxConfig->numPins; pinIndex-- > 0u;)
{
Cy_CapSense_CSXConnectRx(pinPointer, context);
pinPointer++;
}
context->ptrActiveScanSns->connectedSnsState = CY_CAPSENSE_SNS_CONNECTED;
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXDisconnectTxExt
****************************************************************************//**
*
* Disconnects a current Tx electrode from the CSX scanning hardware.
*
* This function connects all current Tx electrode's pins to the CSD_SENSE signal.
* It is assumed that drive mode of the port pin is already set to STRONG
* in the HSIOM_PORT_SELx register.
*
* Calling this function directly from the application program is not
* recommended. This function is used to implement only the user's specific
* use cases (for faster execution time when there is only one port pin for an
* electrode for example).
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXDisconnectTxExt(cy_stc_capsense_context_t * context)
{
uint32_t pinIndex;
const cy_stc_capsense_pin_config_t * pinPointer = context->ptrActiveScanSns->ptrTxConfig->ptrPin;
for (pinIndex = context->ptrActiveScanSns->ptrTxConfig->numPins; pinIndex-- > 0u;)
{
Cy_CapSense_CSXDisconnectTx(pinPointer, context);
pinPointer++;
}
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXDisconnectRxExt
****************************************************************************//**
*
* Connects a current Tx electrode to the CSX scanning hardware.
*
* This function connects all current Tx electrode's pins to the CSD_SENSE signal.
* It is assumed that drive mode of the port pin is already set to STRONG
* in the HSIOM_PORT_SELx register.
*
* Calling this function directly from the application program is not
* recommended. This function is used to implement only the user's specific
* use cases (for faster execution time when there is only one port pin for an
* electrode for example).
*
* \param context
* The pointer to the CapSense context structure \ref cy_stc_capsense_context_t.
*
*******************************************************************************/
void Cy_CapSense_CSXDisconnectRxExt(cy_stc_capsense_context_t * context)
{
uint32_t pinIndex;
const cy_stc_capsense_pin_config_t * pinPointer = context->ptrActiveScanSns->ptrRxConfig->ptrPin;
for (pinIndex = context->ptrActiveScanSns->ptrRxConfig->numPins; pinIndex-- > 0u;)
{
Cy_CapSense_CSXDisconnectRx(pinPointer, context);
pinPointer++;
}
}
/*******************************************************************************
* Function Name: Cy_CapSense_CSXSetWidgetTxClkSrc
****************************************************************************//**
*
* Sets a source for the Tx clock for a widget.
*
* \param ptrWdConfig
* The pointer to the cy_stc_capsense_widget_context_t structure.
*
*******************************************************************************/
void Cy_CapSense_CSXSetWidgetTxClkSrc(const cy_stc_capsense_widget_config_t * ptrWdConfig)
{
cy_stc_capsense_widget_context_t * ptrWdCxt = ptrWdConfig->ptrWdContext;
if (0u != (ptrWdCxt->snsClkSource & CY_CAPSENSE_CLK_SOURCE_AUTO_MASK))
{