1 |
/** |
---|
2 |
PWM3 Generated Driver API Header File |
---|
3 |
|
---|
4 |
@Company |
---|
5 |
Microchip Technology Inc. |
---|
6 |
|
---|
7 |
@File Name |
---|
8 |
pwm3.h |
---|
9 |
|
---|
10 |
@Summary |
---|
11 |
This is the generated header file for the PWM3 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs |
---|
12 |
|
---|
13 |
@Description |
---|
14 |
This header file provides APIs for driver for PWM3. |
---|
15 |
Generation Information : |
---|
16 |
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2 |
---|
17 |
Device : PIC16F1579 |
---|
18 |
Driver Version : 2.01 |
---|
19 |
The generated drivers are tested against the following: |
---|
20 |
Compiler : XC8 1.45 or later |
---|
21 |
MPLAB : MPLAB X 4.15 |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
/* |
---|
25 |
(c) 2018 Microchip Technology Inc. and its subsidiaries. |
---|
26 |
|
---|
27 |
Subject to your compliance with these terms, you may use Microchip software and any |
---|
28 |
derivatives exclusively with Microchip products. It is your responsibility to comply with third party |
---|
29 |
license terms applicable to your use of third party software (including open source software) that |
---|
30 |
may accompany Microchip software. |
---|
31 |
|
---|
32 |
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER |
---|
33 |
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY |
---|
34 |
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS |
---|
35 |
FOR A PARTICULAR PURPOSE. |
---|
36 |
|
---|
37 |
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, |
---|
38 |
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND |
---|
39 |
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP |
---|
40 |
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO |
---|
41 |
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL |
---|
42 |
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT |
---|
43 |
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS |
---|
44 |
SOFTWARE. |
---|
45 |
*/ |
---|
46 |
|
---|
47 |
#ifndef PWM3_H |
---|
48 |
#define PWM3_H |
---|
49 |
|
---|
50 |
/** |
---|
51 |
Section: Included Files |
---|
52 |
*/ |
---|
53 |
|
---|
54 |
#include <xc.h> |
---|
55 |
#include <stdint.h> |
---|
56 |
#include <stdbool.h> |
---|
57 |
|
---|
58 |
#ifdef __cplusplus // Provide C++ Compatibility |
---|
59 |
|
---|
60 |
extern "C" { |
---|
61 |
|
---|
62 |
#endif |
---|
63 |
|
---|
64 |
//Added by GdS. Factor to get from a percentage to a duty cycle |
---|
65 |
const int16_t PWM3_MAX_PERIOD_COUNT=8000; //((PWM3PRH<<8)+PWR3PRL); |
---|
66 |
const int16_t PWM3_PERC_FACTOR=(PWM3_MAX_PERIOD_COUNT/100); |
---|
67 |
|
---|
68 |
|
---|
69 |
/** |
---|
70 |
Section: PWM Module APIs |
---|
71 |
*/ |
---|
72 |
|
---|
73 |
/** |
---|
74 |
@Summary |
---|
75 |
Initializes the PWM3 |
---|
76 |
|
---|
77 |
@Description |
---|
78 |
This routine initializes the Initializes the PWM3. |
---|
79 |
This routine must be called before any other PWM routine is called. |
---|
80 |
This routine should only be called once during system initialization. |
---|
81 |
|
---|
82 |
@Preconditions |
---|
83 |
None |
---|
84 |
|
---|
85 |
@Param |
---|
86 |
None |
---|
87 |
|
---|
88 |
@Returns |
---|
89 |
None |
---|
90 |
|
---|
91 |
@Comment |
---|
92 |
|
---|
93 |
|
---|
94 |
@Example |
---|
95 |
<code> |
---|
96 |
|
---|
97 |
</code> |
---|
98 |
*/ |
---|
99 |
void PWM3_Initialize(void); |
---|
100 |
|
---|
101 |
/** |
---|
102 |
@Summary |
---|
103 |
This function starts the PWM3. |
---|
104 |
|
---|
105 |
@Description |
---|
106 |
This function starts the PWM3 operation. |
---|
107 |
This function must be called after the initialization of PWM3. |
---|
108 |
|
---|
109 |
@Preconditions |
---|
110 |
Initialize the PWM3 before calling this function. |
---|
111 |
|
---|
112 |
@Param |
---|
113 |
None |
---|
114 |
|
---|
115 |
@Returns |
---|
116 |
None |
---|
117 |
|
---|
118 |
@Example |
---|
119 |
<code> |
---|
120 |
// Initialize PWM3 module |
---|
121 |
|
---|
122 |
// Start PWM3 |
---|
123 |
PWM3_Start(); |
---|
124 |
|
---|
125 |
// Do something else... |
---|
126 |
</code> |
---|
127 |
*/ |
---|
128 |
void PWM3_Start(void); |
---|
129 |
|
---|
130 |
/** |
---|
131 |
@Summary |
---|
132 |
This function stops the PWM3. |
---|
133 |
|
---|
134 |
@Description |
---|
135 |
This function stops the PWM3 operation. |
---|
136 |
This function must be called after the start of PWM3. |
---|
137 |
|
---|
138 |
@Preconditions |
---|
139 |
Initialize the PWM3 before calling this function. |
---|
140 |
|
---|
141 |
@Param |
---|
142 |
None |
---|
143 |
|
---|
144 |
@Returns |
---|
145 |
None |
---|
146 |
|
---|
147 |
@Example |
---|
148 |
<code> |
---|
149 |
// Initialize PWM3 module |
---|
150 |
|
---|
151 |
// Start PWM3 |
---|
152 |
PWM3_StartTimer(); |
---|
153 |
|
---|
154 |
// Do something else... |
---|
155 |
|
---|
156 |
// Stop PWM3; |
---|
157 |
PWM3_Stop(); |
---|
158 |
</code> |
---|
159 |
*/ |
---|
160 |
void PWM3_Stop(void); |
---|
161 |
|
---|
162 |
|
---|
163 |
/** |
---|
164 |
@Summary |
---|
165 |
This function used to check output status of PWM3. |
---|
166 |
|
---|
167 |
@Description |
---|
168 |
Check output status of PWM3 as High or Low. |
---|
169 |
|
---|
170 |
@Preconditions |
---|
171 |
Start the PWM3 before calling this function. |
---|
172 |
|
---|
173 |
@Param |
---|
174 |
None |
---|
175 |
|
---|
176 |
@Returns |
---|
177 |
true - Output High. |
---|
178 |
false - Output Low. |
---|
179 |
|
---|
180 |
@Example |
---|
181 |
<code> |
---|
182 |
|
---|
183 |
</code> |
---|
184 |
*/ |
---|
185 |
bool PWM3_CheckOutputStatus(void); |
---|
186 |
|
---|
187 |
/** |
---|
188 |
@Summary |
---|
189 |
This function is used to load buffer of PWM3 at the end of period. |
---|
190 |
|
---|
191 |
@Description |
---|
192 |
load buffer of PWM3 at the end of period. |
---|
193 |
|
---|
194 |
@Preconditions |
---|
195 |
Initialize the PWM3 before calling this function. |
---|
196 |
|
---|
197 |
@Param |
---|
198 |
None |
---|
199 |
|
---|
200 |
@Returns |
---|
201 |
None |
---|
202 |
|
---|
203 |
@Example |
---|
204 |
<code> |
---|
205 |
|
---|
206 |
</code> |
---|
207 |
*/ |
---|
208 |
void PWM3_LoadBufferSet(void); |
---|
209 |
|
---|
210 |
/** |
---|
211 |
@Summary |
---|
212 |
Load required 16 bit phase count |
---|
213 |
|
---|
214 |
@Description |
---|
215 |
Set the expected phase count |
---|
216 |
|
---|
217 |
@Preconditions |
---|
218 |
None |
---|
219 |
|
---|
220 |
@Param |
---|
221 |
Pass 16 bit phase count |
---|
222 |
|
---|
223 |
@Returns |
---|
224 |
None |
---|
225 |
|
---|
226 |
@Example |
---|
227 |
<code> |
---|
228 |
|
---|
229 |
</code> |
---|
230 |
*/ |
---|
231 |
void PWM3_PhaseSet(uint16_t phaseCount); |
---|
232 |
|
---|
233 |
/** |
---|
234 |
@Summary |
---|
235 |
Load required 16 bit Duty Cycle |
---|
236 |
|
---|
237 |
@Description |
---|
238 |
Set the expected Duty Cycle |
---|
239 |
|
---|
240 |
@Preconditions |
---|
241 |
None |
---|
242 |
|
---|
243 |
@Param |
---|
244 |
Pass 16 bit Duty Cycle |
---|
245 |
|
---|
246 |
@Returns |
---|
247 |
None |
---|
248 |
|
---|
249 |
@Example |
---|
250 |
<code> |
---|
251 |
|
---|
252 |
</code> |
---|
253 |
*/ |
---|
254 |
void PWM3_DutyCycleSet(uint16_t dutyCycleCount); |
---|
255 |
|
---|
256 |
/** |
---|
257 |
@Summary |
---|
258 |
Load required 16 bit Period |
---|
259 |
|
---|
260 |
@Description |
---|
261 |
Set the expected Period |
---|
262 |
|
---|
263 |
@Preconditions |
---|
264 |
None |
---|
265 |
|
---|
266 |
@Param |
---|
267 |
Pass 16 bit Period |
---|
268 |
|
---|
269 |
@Returns |
---|
270 |
None |
---|
271 |
|
---|
272 |
@Example |
---|
273 |
<code> |
---|
274 |
|
---|
275 |
</code> |
---|
276 |
*/ |
---|
277 |
void PWM3_PeriodSet(uint16_t periodCount); |
---|
278 |
|
---|
279 |
/** |
---|
280 |
@Summary |
---|
281 |
Load required 16 bit Offset |
---|
282 |
|
---|
283 |
@Description |
---|
284 |
Set the expected Offset |
---|
285 |
|
---|
286 |
@Preconditions |
---|
287 |
None |
---|
288 |
|
---|
289 |
@Param |
---|
290 |
Pass 16 bit Offset |
---|
291 |
|
---|
292 |
@Returns |
---|
293 |
None |
---|
294 |
|
---|
295 |
@Example |
---|
296 |
<code> |
---|
297 |
|
---|
298 |
</code> |
---|
299 |
*/ |
---|
300 |
|
---|
301 |
//Added by GdS |
---|
302 |
uint16_t PWM3_PeriodGet(); |
---|
303 |
|
---|
304 |
void PWM3_OffsetSet(uint16_t offsetCount); |
---|
305 |
|
---|
306 |
/** |
---|
307 |
@Summary |
---|
308 |
Read measured Timer count |
---|
309 |
|
---|
310 |
@Description |
---|
311 |
Read the measured Timer count |
---|
312 |
* |
---|
313 |
@Preconditions |
---|
314 |
None |
---|
315 |
|
---|
316 |
@Param |
---|
317 |
None |
---|
318 |
|
---|
319 |
@Returns |
---|
320 |
Return 16 bit Timer count |
---|
321 |
|
---|
322 |
@Example |
---|
323 |
<code> |
---|
324 |
|
---|
325 |
</code> |
---|
326 |
*/ |
---|
327 |
uint16_t PWM3_TimerCountGet(void); |
---|
328 |
|
---|
329 |
/** |
---|
330 |
@Summary |
---|
331 |
Returns status of Offset interrupt flag bit (OFIF ). |
---|
332 |
|
---|
333 |
@Description |
---|
334 |
When PWMTMR = PWMOF value offset flag sets. |
---|
335 |
|
---|
336 |
@Preconditions |
---|
337 |
None |
---|
338 |
|
---|
339 |
@Param |
---|
340 |
None |
---|
341 |
|
---|
342 |
@Returns |
---|
343 |
true - PWMTMR >= PWMOF value |
---|
344 |
false - PWMTMR < PWMOF value |
---|
345 |
|
---|
346 |
@Example |
---|
347 |
<code> |
---|
348 |
|
---|
349 |
</code> |
---|
350 |
*/ |
---|
351 |
bool PWM3_IsOffsetMatchOccured(void); |
---|
352 |
|
---|
353 |
/** |
---|
354 |
@Summary |
---|
355 |
Returns status of Phase interrupt flag bit (PHIF ). |
---|
356 |
|
---|
357 |
@Description |
---|
358 |
When PWMTMR = PWMPH value, Phase flag sets. |
---|
359 |
|
---|
360 |
@Preconditions |
---|
361 |
None |
---|
362 |
|
---|
363 |
@Param |
---|
364 |
None |
---|
365 |
|
---|
366 |
@Returns |
---|
367 |
true - PWMTMR count is >= PWMPH value |
---|
368 |
false - PWMTMR count is < PWMPH value |
---|
369 |
|
---|
370 |
@Example |
---|
371 |
<code> |
---|
372 |
|
---|
373 |
</code> |
---|
374 |
*/ |
---|
375 |
bool PWM3_IsPhaseMatchOccured(void); |
---|
376 |
|
---|
377 |
/** |
---|
378 |
@Summary |
---|
379 |
Returns status of DutyCycle interrupt flag bit (DCIF ). |
---|
380 |
|
---|
381 |
@Description |
---|
382 |
When PWMTMR = PWMDC value DutyCycle flag sets. |
---|
383 |
|
---|
384 |
@Preconditions |
---|
385 |
None |
---|
386 |
|
---|
387 |
@Param |
---|
388 |
None |
---|
389 |
|
---|
390 |
@Returns |
---|
391 |
true - PWMTMR count is >= PWMDC value |
---|
392 |
false - PWMTMR count is < PWMDC value |
---|
393 |
|
---|
394 |
@Example |
---|
395 |
<code> |
---|
396 |
|
---|
397 |
</code> |
---|
398 |
*/ |
---|
399 |
bool PWM3_IsDutyCycleMatchOccured(void); |
---|
400 |
|
---|
401 |
/** |
---|
402 |
@Summary |
---|
403 |
Returns status of Period interrupt flag bit (PRIF ). |
---|
404 |
|
---|
405 |
@Description |
---|
406 |
When PWMTMR = PWMPR value offset flag sets. |
---|
407 |
|
---|
408 |
@Preconditions |
---|
409 |
None |
---|
410 |
|
---|
411 |
@Param |
---|
412 |
None |
---|
413 |
|
---|
414 |
@Returns |
---|
415 |
true - PWMTMR count is >= PWMPR value |
---|
416 |
false - PWMTMR count is < PWMPR value |
---|
417 |
|
---|
418 |
@Example |
---|
419 |
<code> |
---|
420 |
|
---|
421 |
</code> |
---|
422 |
*/ |
---|
423 |
bool PWM3_IsPeriodMatchOccured(void); |
---|
424 |
|
---|
425 |
#endif /* PWM3_H */ |
---|
426 |
/** |
---|
427 |
End of File |
---|
428 |
*/ |
---|