Bar Logo Dual Active Bridge Development Board (Part-No. )
 
Content
     
Loading...
Searching...
No Matches
clc1.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#include <stddef.h>
40#include "../clc1.h"
41
42// Section: File specific functions
43
44static void (*CLC1_PositiveEdgeHandler)(void) = NULL;
45static void (*CLC1_NegativeEdgeHandler)(void) = NULL;
46
47// Section: File specific data type definitions
48
49//Defines an object for CLC_INTERFACE
50
51const struct CLC_INTERFACE CLC1 = {
53 .Deinitialize = &CLC1_Deinitialize,
54 .Enable = &CLC1_Enable,
55 .Disable = &CLC1_Disable,
56 .OutputStatusGet =&CLC1_OutputStatusGet,
57 .PositiveEdgeCallbackRegister = &CLC1_PositiveEdgeCallbackRegister,
58 .NegativeEdgeCallbackRegister = &CLC1_NegativeEdgeCallbackRegister,
59 .Tasks = &CLC1_Tasks,
60};
61// Section: Driver Interface Function Definitions
62
64{
65 // Set the CLC1 to the options selected in the User Interface
66
67 // LCEN enabled; LCINTN disabled; LCPOL non_inverted; LCOUT Low; LCINTP disabled; LCMODE OR-XOR; LCOE enabled;
68 CLC1CONL = 0x8081;
69 // LCG1POL non_inverted; LCG2POL non_inverted; LCG3POL non_inverted; LCG4POL non_inverted;
70 CLC1CONH = 0x0;
71 // LCD2S CMP1 output; LCD1S CLCINA I/O pin; LCD4S CMP3 output; LCD3S CLCINC I/O pin;
72 CLC1SELL = 0x2020;
73 // LCG1D1T disabled; LCG1D3T disabled; LCG2D2T enabled; LCG1D2T enabled; LCG2D1T disabled; LCG2D4T disabled; LCG1D4T disabled; LCG2D3T disabled; LCG1D1N disabled; LCG1D3N disabled; LCG2D2N disabled; LCG1D2N disabled; LCG2D1N disabled; LCG2D4N disabled; LCG1D4N disabled; LCG2D3N disabled;
74 CLC1GLSL = 0x808;
75 // LCG3D1T disabled; LCG3D2T disabled; LCG4D1T disabled; LCG3D3T disabled; LCG4D2T disabled; LCG3D4T enabled; LCG4D3T disabled; LCG4D4T enabled; LCG3D1N disabled; LCG3D2N disabled; LCG4D1N disabled; LCG3D3N disabled; LCG4D2N disabled; LCG3D4N disabled; LCG4D3N disabled; LCG4D4N disabled;
76 CLC1GLSH = 0x8080;
77
80
82
83}
84
86{
88
89 CLC1CONL = 0x0;
90 CLC1CONH = 0x0;
91 CLC1SELL = 0x0;
92 CLC1GLSL = 0x0;
93 CLC1GLSH = 0x0;
94}
95
96void CLC1_PositiveEdgeCallbackRegister(void (*handler)(void))
97{
98 if(NULL != handler)
99 {
100 CLC1_PositiveEdgeHandler = handler;
101 }
102}
103
105{
106
107}
108
109void CLC1_NegativeEdgeCallbackRegister(void (*handler)(void))
110{
111 if(NULL != handler)
112 {
113 CLC1_NegativeEdgeHandler = handler;
114 }
115}
116
117void __attribute__ ((weak)) CLC1_NegativeEdgeCallback ( void )
118{
119
120}
121
122
123
124void CLC1_Tasks( void )
125{
126 if(IFS7bits.CLC1PIF == 1)
127 {
128 if(NULL != CLC1_PositiveEdgeHandler)
129 {
130 (*CLC1_PositiveEdgeHandler)();
131 }
132
133 // Clear the CLC1 Positive Edge Interrupt flag
134 IFS7bits.CLC1PIF = 0;
135 }
136 if(IFS11bits.CLC1NIF == 1)
137 {
138 if(NULL != CLC1_NegativeEdgeHandler)
139 {
140 (*CLC1_NegativeEdgeHandler)();
141 }
142
143 // Clear the CLC1 Negative Edge Interrupt flag
144 IFS11bits.CLC1NIF = 0;
145 }
146}
147
149{
150 return(CLC1CONLbits.LCOUT);
151
152}
void __attribute__((weak))
Definition clc1.c:104
static void(* CLC1_PositiveEdgeHandler)(void)
Definition clc1.c:44
static void(* CLC1_NegativeEdgeHandler)(void)
Definition clc1.c:45
void CLC1_Deinitialize(void)
Deinitializes the CLC1 to POR values.
Definition clc1.c:85
void CLC1_PositiveEdgeCallback(void)
This is the default callback with weak attribute. The user can override and implement the default cal...
static void CLC1_Disable(void)
This inline function disables the CLC1 module.
Definition clc1.h:110
static void CLC1_Enable(void)
This inline function enables the CLC1 module.
Definition clc1.h:97
void CLC1_Initialize(void)
Initializes the CLC1 module.
Definition clc1.c:63
void CLC1_Tasks(void)
Implements the tasks for polled implementations where the hardware supports dedicated event for Posit...
Definition clc1.c:124
void CLC1_NegativeEdgeCallbackRegister(void(*handler)(void))
This function can be used to override default callback and to define custom callback for CLC1 Negativ...
Definition clc1.c:109
void CLC1_PositiveEdgeCallbackRegister(void(*handler)(void))
This function can be used to override default callback and to define custom callback for CLC1 Positiv...
Definition clc1.c:96
void CLC1_NegativeEdgeCallback(void)
This is the default callback with weak attribute. The user can override and implement the default cal...
const struct CLC_INTERFACE CLC1
Structure object of type CLC_INTERFACE with the custom name given by the user in the Melody Driver Us...
Definition clc1.c:51
bool CLC1_OutputStatusGet(void)
Returns output pin status of the CLC1 module.
Definition clc1.c:148
Structure containing the function pointers of CLC driver.
void(* Initialize)(void)
Pointer to CLCx_Initialize e.g. CLC1_Initialize.