Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches
sccp2.c
Go to the documentation of this file.
1
17/*
18© [2024] Microchip Technology Inc. and its subsidiaries.
19
20 Subject to your compliance with these terms, you may use Microchip
21 software and any derivatives exclusively with Microchip products.
22 You are responsible for complying with 3rd party license terms
23 applicable to your use of 3rd party software (including open source
24 software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
25 NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
26 SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
27 MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
28 WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
29 INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
30 KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
31 MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
32 FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
33 TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
34 EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
35 THIS SOFTWARE.
36*/
37
38// Section: Included Files
39
40#include <stddef.h>
41#include "../sccp2.h"
42#include "../timer_interface.h"
43
44// Section: Data Type Definitions
45
46#define MASK_32_BIT_LOW 0x0000FFFFU
47#define MASK_32_BIT_HIGH 0xFFFF0000U
48
49// Section: File specific functions
50
51static void (*SCCP2_TimeoutHandler)(void) = NULL;
52
53// Section: Driver Interface
54
55// Defines an object for TIMER_INTERFACE
56
59 .Deinitialize = &SCCP2_Timer_Deinitialize,
60 .Start = &SCCP2_Timer_Start,
61 .Stop = &SCCP2_Timer_Stop,
62 #if TIMER_PERIODCOUNTSET_API_SUPPORT
63 .PeriodCountSet = &SCCP2_Timer_PeriodCountSet,
64 #endif
65 .PeriodSet = &SCCP2_Timer_PeriodSet,
66 .CounterGet = &SCCP2_Timer_CounterGet,
67 .PeriodGet = &SCCP2_Timer_PeriodGet,
68 .InterruptPrioritySet = &SCCP2_Timer_InterruptPrioritySet,
69 .TimeoutCallbackRegister = &SCCP2_Timer_TimeoutCallbackRegister,
70 .Tasks = &SCCP2_Timer_Tasks,
71};
72
73// Section: Driver Interface Function Definitions
74
76{
77 // MOD ; CCSEL disabled; TMR32 16 Bit; TMRPS 1:1; CLKSEL FOSC/2; TMRSYNC disabled; CCPSLP disabled; CCPSIDL disabled; CCPON disabled;
78 CCP2CON1L = 0x0; //The module is disabled, till other settings are configured
79 //SYNC None; ALTSYNC disabled; ONESHOT disabled; TRIGEN disabled; IOPS Each Time Base Period Match; RTRGEN disabled; OPSRC Timer Interrupt Event;
80 CCP2CON1H = 0x0;
81 //ASDG 0x0; SSDG disabled; ASDGM disabled; PWMRSEN disabled;
82 CCP2CON2L = 0x0;
83 //ICSEL ; AUXOUT Disabled; ICGSM Level-Sensitive mode; OCAEN disabled; OENSYNC disabled;
84 CCP2CON2H = 0x0;
85 //PSSACE Tri-state; POLACE disabled; OSCNT None; OETRIG disabled;
86 CCP2CON3H = 0x0;
87 //ICOV disabled; ICDIS disabled; SCEVT disabled; ASEVT disabled; TRCLR disabled; TRSET disabled; ICGARM disabled;
88 CCP2STATL = 0x0;
89 //TMRL 0x0000;
90 CCP2TMRL = 0x0;
91 //TMRH 0x0000;
92 CCP2TMRH = 0x0;
93 //PRL 3599;
94 CCP2PRL = 0xE0F;
95 //PRH 0;
96 CCP2PRH = 0x0;
97 //CMPA 0;
98 CCP2RA = 0x0;
99 //CMPB 0;
100 CCP2RB = 0x0;
101 //BUFL 0x0000;
102 CCP2BUFL = 0x0;
103 //BUFH 0x0000;
104 CCP2BUFH = 0x0;
105
107
108
109}
110
112{
113 CCP2CON1Lbits.CCPON = 0;
114
115 CCP2CON1L = 0x0;
116 CCP2CON1H = 0x0;
117 CCP2CON2L = 0x0;
118 CCP2CON2H = 0x100;
119 CCP2CON3H = 0x0;
120 CCP2STATL = 0x0;
121 CCP2TMRL = 0x0;
122 CCP2TMRH = 0x0;
123 CCP2PRL = 0xFFFF;
124 CCP2PRH = 0xFFFF;
125 CCP2RA = 0x0;
126 CCP2RB = 0x0;
127 CCP2BUFL = 0x0;
128 CCP2BUFH = 0x0;
129}
130
132{
133 CCP2CON1Lbits.CCPON = 1;
134}
135
137{
138 CCP2CON1Lbits.CCPON = 0;
139}
140
141void SCCP2_Timer_PeriodSet(uint32_t count)
142{
143 if(count > 0xFFFFU)
144 {
145 CCP2PRL = (uint16_t)(count & MASK_32_BIT_LOW);
146 CCP2PRH = (uint16_t)((count & MASK_32_BIT_HIGH) >> 16);
147 CCP2CON1Lbits.T32 = 1;
148 }
149 else
150 {
151 CCP2PRL = (uint16_t)(count & MASK_32_BIT_LOW);
152 CCP2CON1Lbits.T32 = 0;
153 }
154}
155
156void SCCP2_Timer_InterruptPrioritySet(enum INTERRUPT_PRIORITY priority)
157{
158 IPC6bits.CCT2IP = priority;
159}
160
161void SCCP2_Timer_TimeoutCallbackRegister(void (*handler)(void))
162{
163 if(NULL != handler)
164 {
165 SCCP2_TimeoutHandler = handler;
166 }
167}
168
170{
171 if(NULL != handler)
172 {
173 SCCP2_TimeoutHandler = handler;
174 }
175}
176
177void __attribute__ ((weak)) SCCP2_TimeoutCallback (void)
178{
179
180}
181
183{
184 if(IFS1bits.CCT2IF == 1)
185 {
186 if(NULL != SCCP2_TimeoutHandler)
187 {
188 (*SCCP2_TimeoutHandler)();
189 }
190 IFS1bits.CCT2IF = 0;
191 }
192}
193
195{
196 CCP2PRL = (uint16_t)(count & MASK_32_BIT_LOW);
197 CCP2CON1Lbits.T32 = 0;
198}
199
This is the generated driver header file for the SCCP2-TIMER driver.
#define MASK_32_BIT_HIGH
Definition sccp2.c:47
static void(* SCCP2_TimeoutHandler)(void)
Definition sccp2.c:51
void SCCP2_Timer_PeriodCountSet(size_t count)
Definition sccp2.c:194
#define MASK_32_BIT_LOW
Definition sccp2.c:46
static uint32_t SCCP2_Timer_PeriodGet(void)
This inline function gets the SCCP2-Timer period count value.
Definition sccp2.h:179
const struct TIMER_INTERFACE SPI_Timeout_40us_Timer
Structure object of type TIMER_INTERFACE with the custom name given by the user in the Melody Driver ...
Definition sccp2.c:57
void SCCP2_Timer_Tasks(void)
Used in polling method of timeout event.
Definition sccp2.c:182
void SCCP2_Timer_Start(void)
Starts the timer.
Definition sccp2.c:131
static uint32_t SCCP2_Timer_CounterGet(void)
This inline function gets the SCCP2-Timer elapsed count value.
Definition sccp2.h:197
void SCCP2_Timer_TimeoutCallbackRegister(void(*handler)(void))
This function can be used to override default callback and to define custom callback for SCCP2 Timeou...
Definition sccp2.c:161
void SCCP2_Timer_Initialize(void)
Initializes the SCCP2 module.
Definition sccp2.c:75
void SCCP2_Timer_Stop(void)
Stops the timer.
Definition sccp2.c:136
void SCCP2_Timer_InterruptPrioritySet(enum INTERRUPT_PRIORITY priority)
Sets the Interrupt Priority Value.
Definition sccp2.c:156
void SCCP2_Timer_PeriodSet(uint32_t count)
Sets the SCCP2-Timer period count value.
Definition sccp2.c:141
void SCCP2_TimeoutCallback(void)
This is the default callback with weak attribute. The user can override and implement the default cal...
Definition sccp2.c:177
void SCCP2_TimeoutCallbackRegister(void *handler)
This function can be used to override default callback and to define custom callback for SCCP2 Timeou...
Definition sccp2.c:169
void SCCP2_Timer_Deinitialize(void)
Deinitializes the SCCP2 to POR values.
Definition sccp2.c:111
Structure containing the function pointers of TIMER driver.
void(* Initialize)(void)
Pointer to MCCPx_Timer_Initialize or SCCPx_Timer_Initialize or TMRx_Initialize e.g....