-
Notifications
You must be signed in to change notification settings - Fork 0
/
hal_ccp.c
669 lines (612 loc) · 21.4 KB
/
hal_ccp.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
/*
* File : hal_ccp.c
* Author : Mohamed Ahmed Abdel Wahab
* LinkedIn : https://www.linkedin.com/in/mohamed-abdel-wahab-162413253/
* Github : https://github.com/moabdelwahab6611
* Created on June 10, 2023, 3:50 PM
*/
/**************************Includes-Section*****************************/
#include "hal_ccp.h"
/***********************************************************************/
/*****************Helper Functions Declarations-Section*****************/
/*
* @Brief : Callback pointer to function.
*/
#if CCP1_INTERRUPT_FEATURE_ENABLE==INTERRUPT_FEATURE_ENABLE
static void (*CCP1_InterruptHandler)(void) = NULL; /* @Brief : CCP1 Interrupt Handler. */
#endif
/*
* @Brief : Callback pointer to function.
*/
#if CCP2_INTERRUPT_FEATURE_ENABLE==INTERRUPT_FEATURE_ENABLE
static void (*CCP2_InterruptHandler)(void) = NULL; /* @Brief : CCP2 Interrupt Handler. */
#endif
/*
* @Brief : PMW mode configuration for CCP1 or CCP2.
* @Param _ccp_obj : Pointer to the CCP module configurations.
*/
static void CCP_PMW_MODE_CONFIG(const ccp_t *_ccp_obj);
/*
* @Brief : To enable or disable the interrupt feature for CCP1 or CCP2.
* @Param _ccp_obj : Pointer to the CCP module configurations.
*/
static void CCP_Interrupt_Config(const ccp_t *_ccp_obj);
/*
* @Brief : Timer selection in the Capture or Compare modes clock source for the CCP module.
* @Param _ccp_obj : Pointer to the CCP module configurations.
*/
static void CCP_Mode_Timer_Selection(const ccp_t *_ccp_obj);
/*
* @Brief : CCP1 or CCP2 Capture mode config.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
static Std_ReturnType CCP_Capture_Mode_Config(const ccp_t *_ccp_obj);
/*
* @Brief : CCP1 or CCP2 Compare mode config.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
static Std_ReturnType CCP_Compare_Mode_Config(const ccp_t *_ccp_obj);
/***********************************************************************/
/*****************Software Interfaces Functions-Section*****************/
/*
* @Brief : To initialize the CCP.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType CCP_Init(const ccp_t *_ccp_obj)
{
Std_ReturnType ret = E_NOT_OK;
if(NULL == _ccp_obj)
{
ret = E_NOT_OK;
}
else
{
if(CCP1_INST == _ccp_obj->ccp_inst)
{
/* @Brief : Disable CCP1. */
CCP1_SET_MODE(CCP_DISABLE_MODULE);
}
else if(CCP2_INST == _ccp_obj->ccp_inst)
{
/* @Brief : Disable CCP2. */
CCP2_SET_MODE(CCP_DISABLE_MODULE);
}
else{/*****Nothing*****/}
/* @Brief : CCP Capture mode initialization. */
if(CCP_CAPTURE_MODE_CFG == _ccp_obj->ccp1_mode)
{
ret = CCP_Capture_Mode_Config(_ccp_obj);
}
/* @Brief : CCP Compare mode initialization. */
else if(CCP_COMPARE_MODE_CFG == _ccp_obj->ccp1_mode)
{
ret = CCP_Compare_Mode_Config(_ccp_obj);
}
#if (CCP1_CFG_SELECTED_MODE==CCP_CFG_PWM_MODE_SELECTED)|| (CCP2_CFG_SELECTED_MODE==CCP_CFG_PWM_MODE_SELECTED)
/* @Brief : CCP PWM mode initialization. */
else if(CCP_PWM_MODE_CFG == _ccp_obj->ccp1_mode)
{
}
else{/*****Nothing*****/}
#endif
/* @Brief : CCP pin configurations. */
ret = gpio_pin_intialize(&(_ccp_obj->ccp_pin));
/* @Brief : CCP interrupt configurations for CCP1 and CCP2. */
CCP_Interrupt_Config(_ccp_obj);
/* @Brief : CCP PWM mode configurations for CCP1 and CCP2. */
CCP_PMW_MODE_CONFIG(_ccp_obj);
ret = E_OK;
}
return ret;
}
/*
* @Brief : To de-initialize the CCP.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType CCP_DeInit(const ccp_t *_ccp_obj)
{
Std_ReturnType ret = E_NOT_OK;
if(NULL == _ccp_obj)
{
ret = E_NOT_OK;
}
else
{
if(CCP1_INST == _ccp_obj->ccp_inst)
{
CCP1_SET_MODE(CCP_DISABLE_MODULE); /* @Brief : Disable CCP1. */
#if CCP1_INTERRUPT_FEATURE_ENABLE==INTERRUPT_FEATURE_ENABLE
CCP1_InterruptDisable(); /* @Brief : Interrupt configuration. */
#endif
}
else if(CCP2_INST == _ccp_obj->ccp_inst)
{
CCP2_SET_MODE(CCP_DISABLE_MODULE); /* @Brief : Disable CCP2. */
#if CCP2_INTERRUPT_FEATURE_ENABLE==INTERRUPT_FEATURE_ENABLE
CCP2_InterruptDisable(); /* @Brief : Interrupt configuration. */
#endif
}
else{/*****Nothing*****/}
ret = E_OK;
}
return ret;
}
#if(CCP1_CFG_SELECTED_MODE==CCP_CFG_CAPTURE_MODE_SELECTED)
/*
* @Brief : To check Capture mode data status.
* @Param _capture_status : Pointer to the CCP Capture mode data status.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType CCP_IsCapturedDataReady(uint8 *_capture_status)
{
Std_ReturnType ret = E_NOT_OK;
if(NULL == _capture_status)
{
ret = E_NOT_OK;
}
else
{
if(CCP_CAPTURE_MODE_READY == PIR1bits.CCP1IF)
{
*_capture_status = CCP_CAPTURE_MODE_READY;
CCP1_InterruptFlagClear();
}
else
{
*_capture_status = CCP_CAPTURE_MODE_NOT_READY;
}
ret = E_OK;
}
return ret;
}
/*
* @Brief : To read Capture mode value.
* @Param capture_value : Pointer to the CCP Capture mode value.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType CCP_Read_Capture_Mode_Value(uint16 *capture_value)
{
Std_ReturnType ret = E_NOT_OK;
CCP_REG_T capture_temp_value = {.ccpr_low = 0, .ccpr_high = 0};
if(NULL == capture_value)
{
ret = E_NOT_OK;
}
else
{
capture_temp_value.ccpr_low = CCPR1L;
capture_temp_value.ccpr_high = CCPR1H;
*capture_value = capture_temp_value.ccpr_16bit;
ret = E_OK;
}
return ret;
}
#endif
#if(CCP1_CFG_SELECTED_MODE==CCP_CFG_COMPARE_MODE_SELECTED)
/*
* @Brief : To check Compare mode Compare status if completed or not.
* @Param _compare_status : Pointer to the CCP Compare mode data status.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType CCP_IsCompareCompleted(uint8 *_compare_status)
{
Std_ReturnType ret = E_NOT_OK;
if(NULL == _compare_status)
{
ret = E_NOT_OK;
}
else
{
if(CCP_COMPARE_MODE_READY == PIR1bits.CCP1IF)
{
*_compare_status = CCP_COMPARE_MODE_READY;
CCP1_InterruptFlagClear();
}
else
{
*_compare_status = CCP_COMPARE_MODE_NOT_READY;
}
ret = E_OK;
}
return ret;
}
/*
* @Brief : To read Compare mode value.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Param compare_value
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType CCP_Set_Compare_Mode_Value(const ccp_t *_ccp_obj, uint16 compare_value)
{
Std_ReturnType ret = E_NOT_OK;
CCP_REG_T capture_temp_value = {.ccpr_low = 0, .ccpr_high = 0};
if(NULL == _ccp_obj)
{
ret = E_NOT_OK;
}
else
{
capture_temp_value.ccpr_16bit = compare_value;
if(CCP1_INST == _ccp_obj->ccp_inst)
{
CCPR1L = capture_temp_value.ccpr_low;
CCPR1H = capture_temp_value.ccpr_high;
}
else if(CCP2_INST == _ccp_obj->ccp_inst)
{
CCPR2L = capture_temp_value.ccpr_low;
CCPR2H = capture_temp_value.ccpr_high;
}
else{/*****Nothing*****/}
ret = E_OK;
}
return ret;
}
#endif
#if(CCP1_CFG_SELECTED_MODE==CCP_CFG_PWM_MODE_SELECTED)
/*
* @Brief : To set duty cycle for PWM mode.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Param _duty
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType CCP_Set_PWM_Duty(const ccp_t *_ccp_obj, const uint16 _duty)
{
Std_ReturnType ret = E_NOT_OK;
uint16 l_duty_temp = 0;
if(NULL == _ccp_obj)
{
ret = E_NOT_OK;
}
else
{
l_duty_temp = (uint16)(4 * (PR2 + 1) * (_duty / 100.0));
if(CCP1_INST == _ccp_obj->ccp_inst)
{
CCP1CONbits.DC1B = (uint8)(l_duty_temp & 0x0003);
CCPR1L = (uint8)(l_duty_temp >> 2);
}
else if(CCP2_INST == _ccp_obj->ccp_inst)
{
CCP2CONbits.DC2B = (uint8)(l_duty_temp & 0x0003);
CCPR2L = (uint8)(l_duty_temp >> 2);
}
else{/*****Nothing*****/}
ret = E_OK;
}
return ret;
}
/*
* @Brief : To start PWM mode.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType CCP_Start_PWM(const ccp_t *_ccp_obj)
{
Std_ReturnType ret = E_NOT_OK;
if(NULL == _ccp_obj)
{
ret = E_NOT_OK;
}
else
{
if(CCP1_INST == _ccp_obj->ccp_inst)
{
CCP1CONbits.CCP1M = CCP_PWM_MODE;
}
else if(CCP2_INST == _ccp_obj->ccp_inst)
{
CCP2CONbits.CCP2M = CCP_PWM_MODE;
}
else{/*****Nothing*****/}
ret = E_OK;
}
return ret;
}
/*
* @Brief : To stop PWM mode.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
Std_ReturnType CCP_Stop_PWM(const ccp_t *_ccp_obj)
{
Std_ReturnType ret = E_NOT_OK;
if(NULL == _ccp_obj)
{
ret = E_NOT_OK;
}
else
{
if(CCP1_INST == _ccp_obj->ccp_inst)
{
CCP1CONbits.CCP1M = CCP_DISABLE_MODULE;
}
else if(CCP2_INST == _ccp_obj->ccp_inst)
{
CCP2CONbits.CCP2M = CCP_DISABLE_MODULE;
}
else{/*****Nothing*****/}
}
ret = E_OK;
return ret;
}
#endif
/*
* @Brief : Callback pointer to function to CCP1 interrupt service routine.
*/
void CCP1_ISR(void)
{
CCP1_InterruptFlagClear();
if(CCP1_InterruptHandler)
{
CCP1_InterruptHandler();
}
else{/*****Nothing*****/}
}
/*
* @Brief : Callback pointer to function to CCP2 interrupt service routine.
*/
void CCP2_ISR(void)
{
CCP2_InterruptFlagClear();
if(CCP2_InterruptHandler)
{
CCP2_InterruptHandler();
}
else{/*****Nothing*****/}
}
#if (CCP1_CFG_SELECTED_MODE==CCP_CFG_PWM_MODE_SELECTED)|| (CCP2_CFG_SELECTED_MODE==CCP_CFG_PWM_MODE_SELECTED)
/*
* @Brief : PMW mode configuration for CCP1 or CCP2.
* @Param _ccp_obj : Pointer to the CCP module configurations.
*/
static void CCP_PMW_MODE_CONFIG(const ccp_t *_ccp_obj)
{
if(CCP1_INST == _ccp_obj->ccp_inst)
{
/* Brief : CCP1 PWM mode variant initialization. */
if(CCP_PWM_MODE == _ccp_obj->ccp_mode_variant)
{
CCP1_SET_MODE(CCP_PWM_MODE);
}
else{/*****Nothing*****/}
}
else if(CCP2_INST == _ccp_obj->ccp_inst)
{
/* Brief : CCP2 PWM mode variant initialization. */
if(CCP_PWM_MODE == _ccp_obj->ccp_mode_variant)
{
CCP2_SET_MODE(CCP_PWM_MODE);
}
else{/*****Nothing*****/}
}
else{/*****Nothing*****/}
/* Brief : CCP PWM mode frequency initialization. */
PR2 = (uint8)((_XTAL_FREQ / (_ccp_obj->pwm_frequency * 4.0 * _ccp_obj->timer2_prescaler_value *
_ccp_obj->timer2_postscaler_value)) - 1);
}
#endif
/*
* @Brief : To enable or disable the interrupt feature for CCP1 or CCP2.
* @Param _ccp_obj : Pointer to the CCP module configurations.
*/
static void CCP_Interrupt_Config(const ccp_t *_ccp_obj)
{
/* @Brief : CCP1 Interrupt configuration. */
#if CCP1_INTERRUPT_FEATURE_ENABLE==INTERRUPT_FEATURE_ENABLE
CCP1_InterruptEnable();
CCP1_InterruptFlagClear();
CCP1_InterruptHandler = _ccp_obj->CCP1_InterruptHandler;
/* @Brief : CCP1 Priority configuration. */
#if INTERRUPT_PRIORITY_LEVELS_ENABLE==INTERRUPT_FEATURE_ENABLE
INTERRUPT_PriorityLevelsEnable();
if(INTERRUPT_HIGH_PRIORITY == _ccp_obj->CCP1_priority)
{
INTERRUPT_GlobalInterruptHighEnable();
CCP1_HighPrioritySet();
}
else if(INTERRUPT_LOW_PRIORITY == _ccp_obj->CCP1_priority)
{
INTERRUPT_GlobalInterruptLowEnable();
CCP1_LowPrioritySet();
}
else{/*****Nothing*****/}
#else
INTERRUPT_GlobalInterruptEnable();
INTERRUPT_PeripheralInterruptEnable();
#endif
#endif
/* Brief : CCP2 Interrupt configuration. */
#if CCP2_INTERRUPT_FEATURE_ENABLE==INTERRUPT_FEATURE_ENABLE
CCP2_InterruptEnable();
CCP2_InterruptFlagClear();
CCP2_InterruptHandler = _ccp_obj->CCP2_InterruptHandler;
/* Brief : CCP2 Priority configuration. */
#if INTERRUPT_PRIORITY_LEVELS_ENABLE==INTERRUPT_FEATURE_ENABLE
INTERRUPT_PriorityLevelsEnable();
if(INTERRUPT_HIGH_PRIORITY == _ccp_obj->CCP2_priority)
{
INTERRUPT_GlobalInterruptHighEnable();
CCP2_HighPrioritySet();
}
else if(INTERRUPT_LOW_PRIORITY == _ccp_obj->CCP2_priority)
{
INTERRUPT_GlobalInterruptLowEnable();
CCP2_LowPrioritySet();
}
else{/*****Nothing*****/}
#else
INTERRUPT_GlobalInterruptEnable();
INTERRUPT_PeripheralInterruptEnable();
#endif
#endif
}
/*
* @Brief : Timer selection in the Capture or Compare modes clock source for the CCP module.
* @Param _ccp_obj : Pointer to the CCP module configurations.
*/
static void CCP_Mode_Timer_Selection(const ccp_t *_ccp_obj)
{
if(CCP1_CCP2_TIMER3 == _ccp_obj->ccp_capture_timer)
{
/* @Brief : Timer3 is the Capture clock source for the CCP module. */
T3CONbits.T3CCP1 = 0;
T3CONbits.T3CCP2 = 1;
}
else if (CCP1_TIMER1_CCP2_TIMER3 == _ccp_obj->ccp_capture_timer)
{
/* @Brief : Timer1 is the Capture clock source for the CCP1 and Timer3 for the CCP2 module. */
T3CONbits.T3CCP1 = 1;
T3CONbits.T3CCP2 = 0;
}
else if (CCP1_CCP2_TIMER1 == _ccp_obj->ccp_capture_timer)
{
/* @Brief : Timer1 is the Capture clock source for the CCP module. */
T3CONbits.T3CCP1 = 0;
T3CONbits.T3CCP2 = 0;
}
else{/*****Nothing*****/}
}
/*
* @Brief : CCP1 or CCP2 Capture mode config.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
static Std_ReturnType CCP_Capture_Mode_Config(const ccp_t *_ccp_obj)
{
Std_ReturnType ret = E_OK;
if(CCP1_INST == _ccp_obj->ccp_inst)
{
/* @Brief : CCP1 Capture mode variants initialization. */
switch(_ccp_obj->ccp_mode_variant)
{
case CCP_CAPTURE_MODE_1_FALLING_EDGE :
CCP1_SET_MODE(CCP_CAPTURE_MODE_1_FALLING_EDGE);
break;
case CCP_CAPTURE_MODE_1_RISING_EDGE :
CCP1_SET_MODE(CCP_CAPTURE_MODE_1_RISING_EDGE);
break;
case CCP_CAPTURE_MODE_4_RISING_EDGE :
CCP1_SET_MODE(CCP_CAPTURE_MODE_4_RISING_EDGE);
break;
case CCP_CAPTURE_MODE_16_FALLING_EDGE :
CCP1_SET_MODE(CCP_CAPTURE_MODE_16_FALLING_EDGE);
break;
default : ret = E_NOT_OK; /*****Not supported variant*****/
}
}
else if(CCP2_INST == _ccp_obj->ccp_inst)
{
/* @Brief : CCP2 Capture mode variants initialization. */
switch(_ccp_obj->ccp_mode_variant)
{
case CCP_CAPTURE_MODE_1_FALLING_EDGE :
CCP2_SET_MODE(CCP_CAPTURE_MODE_1_FALLING_EDGE);
break;
case CCP_CAPTURE_MODE_1_RISING_EDGE :
CCP2_SET_MODE(CCP_CAPTURE_MODE_1_RISING_EDGE);
break;
case CCP_CAPTURE_MODE_4_RISING_EDGE :
CCP2_SET_MODE(CCP_CAPTURE_MODE_4_RISING_EDGE);
break;
case CCP_CAPTURE_MODE_16_FALLING_EDGE :
CCP2_SET_MODE(CCP_CAPTURE_MODE_16_FALLING_EDGE);
break;
default : ret = E_NOT_OK; /*****Not supported variant*****/
}
}
else{/*****Nothing*****/}
/* @Brief : CCP1 or CCP2 Capture mode Timer clock source selection. */
CCP_Mode_Timer_Selection(_ccp_obj);
return ret;
}
/*
* @Brief : CCP1 or CCP2 Compare mode config.
* @Param _ccp_obj : Pointer to the CCP module configurations.
* @Return Status of the function.
* (E_OK) : The function done successfully.
* (E_NOT_OK) : The function has issue while performing this action.
*/
static Std_ReturnType CCP_Compare_Mode_Config(const ccp_t *_ccp_obj)
{
Std_ReturnType ret = E_OK;
if(CCP1_INST == _ccp_obj->ccp_inst)
{
/* @Brief : CCP1 Compare mode variants initialization. */
switch(_ccp_obj->ccp_mode_variant)
{
case CCP_COMPARE_MODE_SET_PIN_LOW :
CCP1_SET_MODE(CCP_COMPARE_MODE_SET_PIN_LOW);
break;
case CCP_COMPARE_MODE_SET_PIN_HIGH :
CCP1_SET_MODE(CCP_COMPARE_MODE_SET_PIN_HIGH);
break;
case CCP_COMPARE_MODE_TOGGLE_ON_MATCH :
CCP1_SET_MODE(CCP_COMPARE_MODE_TOGGLE_ON_MATCH);
break;
case CCP_COMPARE_MODE_GEN_SW_INTERRUPT :
CCP1_SET_MODE(CCP_COMPARE_MODE_GEN_SW_INTERRUPT);
break;
case CCP_COMPARE_MODE_GEN_EVENT :
CCP1_SET_MODE(CCP_COMPARE_MODE_GEN_EVENT);
break;
default : ret = E_NOT_OK; /*****Not supported variant*****/
}
}
else if(CCP2_INST == _ccp_obj->ccp_inst)
{
/* @Brief : CCP2 Compare mode variants initialization. */
switch(_ccp_obj->ccp_mode_variant)
{
case CCP_COMPARE_MODE_SET_PIN_LOW :
CCP2_SET_MODE(CCP_COMPARE_MODE_SET_PIN_LOW);
break;
case CCP_COMPARE_MODE_SET_PIN_HIGH :
CCP2_SET_MODE(CCP_COMPARE_MODE_SET_PIN_HIGH);
break;
case CCP_COMPARE_MODE_TOGGLE_ON_MATCH :
CCP2_SET_MODE(CCP_COMPARE_MODE_TOGGLE_ON_MATCH);
break;
case CCP_COMPARE_MODE_GEN_SW_INTERRUPT :
CCP2_SET_MODE(CCP_COMPARE_MODE_GEN_SW_INTERRUPT);
break;
case CCP_COMPARE_MODE_GEN_EVENT :
CCP2_SET_MODE(CCP_COMPARE_MODE_GEN_EVENT);
break;
default : ret = E_NOT_OK; /*****Not supported variant*****/
}
}
else{/*****Nothing*****/}
/* @Brief : CCP1 or CCP2 Compare mode Timer clock source selection. */
CCP_Mode_Timer_Selection(_ccp_obj);
return ret;
}
/***********************************************************************/