Digital Power Starter Kit 3 Firmware
dsPIC33C Boost 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 /**************************************************************************************************
23  * @file p33c_dac.h
24  * @see p33c_dac.c
25  * @brief Generic Digital-To-Analog Converter Driver Module (header file)
26  * @details
27  * This additional header file contains defines for all required bit-settings of all related
28  * special function registers of a peripheral module and/or instance.
29  * This file is an additional header file on top of the generic device header file.
30  *
31  *************************************************************************************************/
32 
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 /***********************************************************************************
49  * @ingroup lib-layer-pral-properties-public-dac
50  * @struct P33C_DAC_MODULE_s
51  * @brief Abstracted set of Special Function Registers of a Digital-to-Analog Converter peripheral
52  * @details
53  * This structure defines an abstracted set of Special Function Registers of
54  * Digital-to-Analog Converter peripheral module base registers. Users can use this
55  * abstracted set of registers to capture register settings from or write generic
56  * register settings to these peripheral base registers.
57  *
58  **********************************************************************************/
59 
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  /*********************************************************************************
78  * @def p33c_DacModule_GetHandle()
79  * @ingroup lib-layer-pral-functions-public-dac
80  * @brief Gets pointer to DAC Module SFR set
81  * @param void
82  * @return struct P33C_DAC_MODULE_s Pointer to DAC module special function register set object
83  *
84  * @details
85  * This function returns the pointer to a DAC module register set
86  * Special Function Register memory space. This pointer can be used to
87  * directly write to/read from the Special Function Registers of the
88  * DAC peripheral module configuration.
89  *********************************************************************************/
90  #define p33c_DacModule_GetHandle(x) (struct P33C_DAC_MODULE_s*)&DACCTRL1L
91 
92 #endif
93 
94 // GENERIC PDM DAC INSTANCE SPECIAL FUNCTION REGISTER SET
95 #ifndef P33C_DAC_INSTANCE_s
96 
97 /***********************************************************************************
98  * @ingroup lib-layer-pral-properties-public-dac
99  * @struct P33C_DAC_MODULE_s
100  * @brief Abstracted set of Special Function Registers of a Digital-to-Analog Converter peripheral instance
101  * @details
102  * This structure defines an abstracted set of Special Function Registers of
103  * Digital-to-Analog Converter peripheral instance registers. It provides an
104  * abstracted set of registers to capture register settings from or write generic
105  * register settings to this peripheral instance.
106  *
107  **********************************************************************************/
108 
110  union {
111  volatile struct tagDAC1CONLBITS bits; // Register bit-field
112  volatile uint16_t value; // 16-bit wide register value
113  } DACxCONL; // DACxCONL: DACx CONTROL LOW REGISTER
114  union {
115  volatile struct tagDAC1CONHBITS bits; // Register bit-field
116  volatile uint16_t value; // 16-bit wide register value
117  } DACxCONH; // DACxCONH: DACx CONTROL HIGH REGISTER
118  union {
119  volatile struct tagDAC1DATLBITS bits; // Register bit-field
120  volatile uint16_t value; // 16-bit wide register value
121  } DACxDATL; // DACxDATL: DACx DATA LOW REGISTER
122  union {
123  volatile struct tagDAC1DATHBITS bits; // Register bit-field
124  volatile uint16_t value; // 16-bit wide register value
125  } DACxDATH; // DACxDATH: DACx DATA HIGH REGISTER
126  union {
127  volatile struct tagSLP1CONLBITS bits; // Register bit-field
128  volatile uint16_t value; // 16-bit wide register value
129  } SLPxCONL; // SLPxCONL: DACx SLOPE CONTROL LOW REGISTER
130  union {
131  volatile struct tagSLP1CONHBITS bits; // Register bit-field
132  volatile uint16_t value; // 16-bit wide register value
133  } SLPxCONH; // SLPxCONH: DACx SLOPE CONTROL HIGH REGISTER
134  union {
135  volatile struct tagSLP1DATBITS bits; // Register bit-field
136  volatile uint16_t value; // 16-bit wide register value
137  } SLPxDAT; // SLPxDAT: DACx SLOPE DATA REGISTER
138  } __attribute__((packed));
139  typedef struct P33C_DAC_INSTANCE_s P33C_DAC_INSTANCE_t; // PDM DAC INSTANCE REGISTER SET
140 
141  /*********************************************************************************
142  * @ingroup lib-layer-pral-properties-public-dac
143  * @def P33C_CCPGEN_SFR_OFFSET
144  * @brief Derives the address offset between two peripheral instances
145  * @details
146  * This macro derives the address offset between two peripheral instances.
147  * Users can use this address offset to derive the start address to/from which
148  * the register set should be written or read.
149  **********************************************************************************/
150  #define P33C_DAC_SFR_OFFSET ((volatile uint16_t)&DAC2CONL - (volatile uint16_t)&DAC1CONL)
151 
152 
153  /*********************************************************************************
154  * @def p33c_DacInstance_GetHandle(x)
155  * @ingroup lib-layer-pral-functions-public-dac
156  * @brief Gets pointer to DAC Instance 'x' SFR set
157  * @param x Index of the selected DAC Instance of type unsinged integer (1=DAC1, 2=DAC2, etc.)
158  * @return DAC instance object of type struct P33C_DAC_INSTANCE_s of the selected DAC instance
159  *
160  * @details
161  * This function returns the pointer to a DAC instance register set in
162  * Special Function Register memory space. This pointer can be used to directly
163  * write to/read from the Special Function Registers of a given peripheral
164  * instance.
165  *
166  *********************************************************************************/
167  extern volatile uint16_t* p33cDacInstanceHandles[];
168  #define p33c_DacInstance_GetHandle(x) (struct P33C_DAC_INSTANCE_s*)p33cDacInstanceHandles[(x-1)]
169 
170 
171 #endif
172 
173 
174 /* ********************************************************************************************* *
175  * API FUNCTION PROTOTYPES
176  * ********************************************************************************************* */
177 
178 extern volatile uint16_t p33c_DacModule_Dispose(void);
179 extern volatile struct P33C_DAC_MODULE_s p33c_DacModule_ConfigRead(void);
180 extern volatile uint16_t p33c_DacModule_ConfigWrite(
181  volatile struct P33C_DAC_MODULE_s dacConfig
182  );
183 
184 
185 extern volatile uint16_t p33c_DacInstance_Dispose(
186  volatile uint16_t dacInstance
187  );
188 
189 extern volatile struct P33C_DAC_INSTANCE_s p33c_DacInstance_ConfigRead(
190  volatile uint16_t dacInstance
191  );
192 
193 extern volatile uint16_t p33c_DacInstance_ConfigWrite(
194  volatile uint16_t dacInstance,
195  volatile struct P33C_DAC_INSTANCE_s dacConfig
196  );
197 
198 /* ********************************************************************************************* *
199  * DAC INSTANCE CONFIGURATION TEMPLATES
200  * ********************************************************************************************* */
201 extern volatile struct P33C_DAC_MODULE_s dacModuleConfigClear;
202 extern volatile struct P33C_DAC_INSTANCE_s dacConfigClear;
203 extern volatile struct P33C_DAC_MODULE_s dacModuleDefault;
204 
205 #endif /* P33C_DAC_SFR_ABSTRACTION_H */
206 // END OF FILE
union P33C_DAC_INSTANCE_s::@83 SLPxCONH
union P33C_DAC_INSTANCE_s::@81 DACxDATH
union P33C_DAC_INSTANCE_s::@80 DACxDATL
volatile struct tagDAC1CONLBITS bits
Definition: p33c_dac.h:111
union P33C_DAC_INSTANCE_s::@78 DACxCONL
union P33C_DAC_INSTANCE_s::@79 DACxCONH
union P33C_DAC_MODULE_s::@73 DacModuleCtrl2L
volatile uint16_t value
Definition: p33c_dac.h:63
union P33C_DAC_INSTANCE_s::@82 SLPxCONL
volatile struct tagDACCTRL1LBITS bits
Definition: p33c_dac.h:62
volatile unsigned
Definition: p33c_dac.h:65
volatile uint16_t value
Definition: p33c_dac.h:112
union P33C_DAC_INSTANCE_s::@84 SLPxDAT
union P33C_DAC_MODULE_s::@72 DacModuleCtrl1L
union P33C_DAC_MODULE_s::@74 DacModuleCtrl2H