Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches
sccp1.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 "../sccp1.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 (*SCCP1_TimeoutHandler)(void) = NULL;
52
53// Section: Driver Interface
54
55// Defines an object for TIMER_INTERFACE
56
59 .Deinitialize = &SCCP1_Timer_Deinitialize,
60 .Start = &SCCP1_Timer_Start,
61 .Stop = &SCCP1_Timer_Stop,
62 #if TIMER_PERIODCOUNTSET_API_SUPPORT
63 .PeriodCountSet = &SCCP1_Timer_PeriodCountSet,
64 #endif
65 .PeriodSet = &SCCP1_Timer_PeriodSet,
66 .CounterGet = &SCCP1_Timer_CounterGet,
67 .PeriodGet = &SCCP1_Timer_PeriodGet,
68 .InterruptPrioritySet = &SCCP1_Timer_InterruptPrioritySet,
69 .TimeoutCallbackRegister = &SCCP1_Timer_TimeoutCallbackRegister,
70 .Tasks = &SCCP1_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 CCP1CON1L = 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 CCP1CON1H = 0x0;
81 //ASDG 0x0; SSDG disabled; ASDGM disabled; PWMRSEN disabled;
82 CCP1CON2L = 0x0;
83 //ICSEL ; AUXOUT Disabled; ICGSM Level-Sensitive mode; OCAEN disabled; OENSYNC disabled;
84 CCP1CON2H = 0x0;
85 //PSSACE Tri-state; POLACE disabled; OSCNT None; OETRIG disabled;
86 CCP1CON3H = 0x0;
87 //ICOV disabled; ICDIS disabled; SCEVT disabled; ASEVT disabled; TRCLR disabled; TRSET disabled; ICGARM disabled;
88 CCP1STATL = 0x0;
89 //TMRL 0x0000;
90 CCP1TMRL = 0x0;
91 //TMRH 0x0000;
92 CCP1TMRH = 0x0;
93 //PRL 89;
94 CCP1PRL = 0x59;
95 //PRH 0;
96 CCP1PRH = 0x0;
97 //CMPA 0;
98 CCP1RA = 0x0;
99 //CMPB 0;
100 CCP1RB = 0x0;
101 //BUFL 0x0000;
102 CCP1BUFL = 0x0;
103 //BUFH 0x0000;
104 CCP1BUFH = 0x0;
105
107
108
109}
110
112{
113 CCP1CON1Lbits.CCPON = 0;
114
115 CCP1CON1L = 0x0;
116 CCP1CON1H = 0x0;
117 CCP1CON2L = 0x0;
118 CCP1CON2H = 0x100;
119 CCP1CON3H = 0x0;
120 CCP1STATL = 0x0;
121 CCP1TMRL = 0x0;
122 CCP1TMRH = 0x0;
123 CCP1PRL = 0xFFFF;
124 CCP1PRH = 0xFFFF;
125 CCP1RA = 0x0;
126 CCP1RB = 0x0;
127 CCP1BUFL = 0x0;
128 CCP1BUFH = 0x0;
129}
130
132{
133 CCP1CON1Lbits.CCPON = 1;
134}
135
137{
138 CCP1CON1Lbits.CCPON = 0;
139}
140
141void SCCP1_Timer_PeriodSet(uint32_t count)
142{
143 if(count > 0xFFFFU)
144 {
145 CCP1PRL = (uint16_t)(count & MASK_32_BIT_LOW);
146 CCP1PRH = (uint16_t)((count & MASK_32_BIT_HIGH) >> 16);
147 CCP1CON1Lbits.T32 = 1;
148 }
149 else
150 {
151 CCP1PRL = (uint16_t)(count & MASK_32_BIT_LOW);
152 CCP1CON1Lbits.T32 = 0;
153 }
154}
155
156void SCCP1_Timer_InterruptPrioritySet(enum INTERRUPT_PRIORITY priority)
157{
158 IPC1bits.CCT1IP = priority;
159}
160
161void SCCP1_Timer_TimeoutCallbackRegister(void (*handler)(void))
162{
163 if(NULL != handler)
164 {
165 SCCP1_TimeoutHandler = handler;
166 }
167}
168
170{
171 if(NULL != handler)
172 {
173 SCCP1_TimeoutHandler = handler;
174 }
175}
176
177void __attribute__ ((weak)) SCCP1_TimeoutCallback (void)
178{
179
180}
181
183{
184 if(IFS0bits.CCT1IF == 1)
185 {
186 if(NULL != SCCP1_TimeoutHandler)
187 {
188 (*SCCP1_TimeoutHandler)();
189 }
190 IFS0bits.CCT1IF = 0;
191 }
192}
193
195{
196 CCP1PRL = (uint16_t)(count & MASK_32_BIT_LOW);
197 CCP1CON1Lbits.T32 = 0;
198}
199
This is the generated driver header file for the SCCP1-TIMER driver.
void SCCP1_Timer_PeriodCountSet(size_t count)
Definition sccp1.c:194
#define MASK_32_BIT_HIGH
Definition sccp1.c:47
static void(* SCCP1_TimeoutHandler)(void)
Definition sccp1.c:51
#define MASK_32_BIT_LOW
Definition sccp1.c:46
void SCCP1_Timer_Stop(void)
Stops the timer.
Definition sccp1.c:136
void SCCP1_Timer_PeriodSet(uint32_t count)
Sets the SCCP1-Timer period count value.
Definition sccp1.c:141
void SCCP1_TimeoutCallback(void)
This is the default callback with weak attribute. The user can override and implement the default cal...
Definition sccp1.c:177
const struct TIMER_INTERFACE SPI_BusIdle_1us_Timer
Structure object of type TIMER_INTERFACE with the custom name given by the user in the Melody Driver ...
Definition sccp1.c:57
static uint32_t SCCP1_Timer_PeriodGet(void)
This inline function gets the SCCP1-Timer period count value.
Definition sccp1.h:179
void SCCP1_Timer_Deinitialize(void)
Deinitializes the SCCP1 to POR values.
Definition sccp1.c:111
void SCCP1_Timer_TimeoutCallbackRegister(void(*handler)(void))
This function can be used to override default callback and to define custom callback for SCCP1 Timeou...
Definition sccp1.c:161
void SCCP1_Timer_Tasks(void)
Used in polling method of timeout event.
Definition sccp1.c:182
void SCCP1_Timer_Start(void)
Starts the timer.
Definition sccp1.c:131
static uint32_t SCCP1_Timer_CounterGet(void)
This inline function gets the SCCP1-Timer elapsed count value.
Definition sccp1.h:197
void SCCP1_Timer_Initialize(void)
Initializes the SCCP1 module.
Definition sccp1.c:75
void SCCP1_Timer_InterruptPrioritySet(enum INTERRUPT_PRIORITY priority)
Sets the Interrupt Priority Value.
Definition sccp1.c:156
void SCCP1_TimeoutCallbackRegister(void *handler)
This function can be used to override default callback and to define custom callback for SCCP1 Timeou...
Definition sccp1.c:169
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....