Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Voltage Mode Control Example
p33c_dac.h
1 /* Microchip Technology Inc. and its subsidiaries. You may use this software
2  * and any derivatives exclusively with Microchip products.
3  *
4  * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
5  * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
6  * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
7  * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
8  * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
9  *
10  * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
11  * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
12  * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
13  * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
14  * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS
15  * IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF
16  * ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
17  *
18  * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
19  * TERMS.
20  */
21 
22 
33 // This is a guard condition so that contents of this file are not included
34 // more than once.
35 #ifndef P33C_DAC_SFR_ABSTRACTION_H
36 #define P33C_DAC_SFR_ABSTRACTION_H
37 
38 // Include standard header files
39 #include <xc.h> // include processor files - each processor file is guarded.
40 #include <stdint.h> // include standard integer data types
41 #include <stdbool.h> // include standard boolean data types
42 #include <stddef.h> // include standard definition data types
43 
44 
45 // GENERIC PDM DAC MODULE SPECIAL FUNCTION REGISTER SET
46 #ifndef P33C_DAC_MODULE_s
47 
48 
61  union {
62  volatile struct tagDACCTRL1LBITS bits; // Register bit-field
63  volatile uint16_t value; // 16-bit wide register value
64  } DacModuleCtrl1L; // (DACCTRL1L) DAC CONTROL 1 REGISTER LOW
65  volatile unsigned : 16; // (reserved)
66  union {
67  volatile struct tagDACCTRL2LBITS bits; // Register bit-field
68  volatile uint16_t value; // 16-bit wide register value
69  } DacModuleCtrl2L; // (DACCTRL2L) DAC CONTROL 2 REGISTER LOW
70  union {
71  volatile struct tagDACCTRL2HBITS bits; // Register bit-field
72  volatile uint16_t value; // 16-bit wide register value
73  } DacModuleCtrl2H; // (DACCTRL2H) DAC CONTROL 2 REGISTER HIGH
74  } __attribute__((packed));
75  typedef struct P33C_DAC_MODULE_s P33C_DAC_MODULE_t; // PDM DAC MODULE REGISTER SET
76 
77 #endif
78 
79 // GENERIC PDM DAC INSTANCE SPECIAL FUNCTION REGISTER SET
80 #ifndef P33C_DAC_INSTANCE_s
81 
82 
95  union {
96  volatile struct tagDAC1CONLBITS bits; // Register bit-field
97  volatile uint16_t value; // 16-bit wide register value
98  } DACxCONL; // DACxCONL: DACx CONTROL LOW REGISTER
99  union {
100  volatile struct tagDAC1CONHBITS bits; // Register bit-field
101  volatile uint16_t value; // 16-bit wide register value
102  } DACxCONH; // DACxCONH: DACx CONTROL HIGH REGISTER
103  union {
104  volatile struct tagDAC1DATLBITS bits; // Register bit-field
105  volatile uint16_t value; // 16-bit wide register value
106  } DACxDATL; // DACxDATL: DACx DATA LOW REGISTER
107  union {
108  volatile struct tagDAC1DATHBITS bits; // Register bit-field
109  volatile uint16_t value; // 16-bit wide register value
110  } DACxDATH; // DACxDATH: DACx DATA HIGH REGISTER
111  union {
112  volatile struct tagSLP1CONLBITS bits; // Register bit-field
113  volatile uint16_t value; // 16-bit wide register value
114  } SLPxCONL; // SLPxCONL: DACx SLOPE CONTROL LOW REGISTER
115  union {
116  volatile struct tagSLP1CONHBITS bits; // Register bit-field
117  volatile uint16_t value; // 16-bit wide register value
118  } SLPxCONH; // SLPxCONH: DACx SLOPE CONTROL HIGH REGISTER
119  union {
120  volatile struct tagSLP1DATBITS bits; // Register bit-field
121  volatile uint16_t value; // 16-bit wide register value
122  } SLPxDAT; // SLPxDAT: DACx SLOPE DATA REGISTER
123  } __attribute__((packed));
124  typedef struct P33C_DAC_INSTANCE_s P33C_DAC_INSTANCE_t; // PDM DAC INSTANCE REGISTER SET
125 
126 
135  #define P33C_DAC_SFR_OFFSET ((volatile uint16_t)&DAC2CONL - (volatile uint16_t)&DAC1CONL)
136 
137 #endif
138 
139 
140 /* ********************************************************************************************* *
141  * API FUNCTION PROTOTYPES
142  * ********************************************************************************************* */
143 
144 extern volatile struct P33C_DAC_MODULE_s* p33c_DacModule_GetHandle(void);
145 
146 extern volatile uint16_t p33c_DacModule_Dispose(void);
147 
148 extern volatile struct P33C_DAC_MODULE_s p33c_DacModule_ConfigRead(void);
149 extern volatile uint16_t p33c_DacModule_ConfigWrite(
150  volatile struct P33C_DAC_MODULE_s dacConfig
151  );
152 
153 
154 extern volatile struct P33C_DAC_INSTANCE_s* p33c_DacInstance_GetHandle(
155  volatile uint16_t dacInstance
156  );
157 
158 extern volatile uint16_t p33c_DacInstance_Dispose(
159  volatile uint16_t dacInstance
160  );
161 
162 extern volatile struct P33C_DAC_INSTANCE_s p33c_DacInstance_ConfigRead(
163  volatile uint16_t dacInstance
164  );
165 
166 extern volatile uint16_t p33c_DacInstance_ConfigWrite(
167  volatile uint16_t dacInstance,
168  volatile struct P33C_DAC_INSTANCE_s dacConfig
169  );
170 
171 /* ********************************************************************************************* *
172  * DAC INSTANCE CONFIGURATION TEMPLATES
173  * ********************************************************************************************* */
174 extern volatile struct P33C_DAC_MODULE_s dacModuleConfigClear;
175 extern volatile struct P33C_DAC_INSTANCE_s dacConfigClear;
176 extern volatile struct P33C_DAC_MODULE_s dacModuleDefault;
177 
178 #endif /* P33C_DAC_SFR_ABSTRACTION_H */
179 // END OF FILE
p33c_DacInstance_GetHandle
volatile struct P33C_DAC_INSTANCE_s * p33c_DacInstance_GetHandle(volatile uint16_t dacInstance)
Gets pointer to DAC Instance SFR set.
Definition: p33c_dac.c:165
p33c_DacInstance_Dispose
volatile uint16_t p33c_DacInstance_Dispose(volatile uint16_t dacInstance)
Resets all DAC Instance registers to their RESET default values.
Definition: p33c_dac.c:197
P33C_DAC_INSTANCE_s::bits
volatile struct tagDAC1CONLBITS bits
Definition: p33c_dac.h:96
P33C_DAC_MODULE_s::DacModuleCtrl1L
union P33C_DAC_MODULE_s::@0 DacModuleCtrl1L
dacConfigClear
volatile struct P33C_DAC_INSTANCE_s dacConfigClear
Default RESET configuration of one DAC instance channel SFRs.
Definition: p33c_dac.c:335
p33c_DacModule_GetHandle
volatile struct P33C_DAC_MODULE_s * p33c_DacModule_GetHandle(void)
Gets pointer to DAC Module SFR set.
Definition: p33c_dac.c:44
P33C_DAC_INSTANCE_s::SLPxCONH
union P33C_DAC_INSTANCE_s::@11 SLPxCONH
p33c_DacInstance_ConfigWrite
volatile uint16_t p33c_DacInstance_ConfigWrite(volatile uint16_t dacInstance, volatile struct P33C_DAC_INSTANCE_s dacConfig)
Writes a user-defined configuration to the DAC instance registers.
Definition: p33c_dac.c:252
dacModuleDefault
volatile struct P33C_DAC_MODULE_s dacModuleDefault
Default configuration of DAC module running from 500 MHz input clock.
Definition: p33c_dac.c:314
P33C_DAC_INSTANCE_s::DACxDATL
union P33C_DAC_INSTANCE_s::@8 DACxDATL
P33C_DAC_MODULE_s::unsigned
volatile unsigned
Definition: p33c_dac.h:65
p33c_DacModule_ConfigWrite
volatile uint16_t p33c_DacModule_ConfigWrite(volatile struct P33C_DAC_MODULE_s dacConfig)
Writes a user-defined configuration to the DAC module base registers.
Definition: p33c_dac.c:129
P33C_DAC_INSTANCE_s::DACxCONH
union P33C_DAC_INSTANCE_s::@7 DACxCONH
p33c_DacModule_ConfigRead
volatile struct P33C_DAC_MODULE_s p33c_DacModule_ConfigRead(void)
Read the current configuration from the DAC module base registers.
Definition: p33c_dac.c:100
P33C_DAC_MODULE_s
Abstracted set of Special Function Registers of a Digital-to-Analog Converter peripheral.
Definition: p33c_dac.h:60
P33C_DAC_MODULE_s::bits
volatile struct tagDACCTRL1LBITS bits
Definition: p33c_dac.h:62
P33C_DAC_INSTANCE_s::SLPxDAT
union P33C_DAC_INSTANCE_s::@12 SLPxDAT
P33C_DAC_MODULE_s::DacModuleCtrl2L
union P33C_DAC_MODULE_s::@1 DacModuleCtrl2L
P33C_DAC_INSTANCE_s
Definition: p33c_dac.h:94
P33C_DAC_INSTANCE_s::DACxDATH
union P33C_DAC_INSTANCE_s::@9 DACxDATH
dacModuleConfigClear
volatile struct P33C_DAC_MODULE_s dacModuleConfigClear
Default RESET configuration of the DAC module base SFRs.
Definition: p33c_dac.c:287
p33c_DacModule_Dispose
volatile uint16_t p33c_DacModule_Dispose(void)
Resets all DAC Module registers to their RESET default values.
Definition: p33c_dac.c:75
P33C_DAC_INSTANCE_s::value
volatile uint16_t value
Definition: p33c_dac.h:97
P33C_DAC_MODULE_s::value
volatile uint16_t value
Definition: p33c_dac.h:63
P33C_DAC_INSTANCE_s::DACxCONL
union P33C_DAC_INSTANCE_s::@6 DACxCONL
P33C_DAC_MODULE_s::DacModuleCtrl2H
union P33C_DAC_MODULE_s::@2 DacModuleCtrl2H
P33C_DAC_INSTANCE_s::SLPxCONL
union P33C_DAC_INSTANCE_s::@10 SLPxCONL
p33c_DacInstance_ConfigRead
volatile struct P33C_DAC_INSTANCE_s p33c_DacInstance_ConfigRead(volatile uint16_t dacInstance)
Read the current configuration from the DAC instance registers.
Definition: p33c_dac.c:221