-
Notifications
You must be signed in to change notification settings - Fork 0
/
adc.h
123 lines (98 loc) · 3.2 KB
/
adc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* Microchip Technology Inc. and its subsidiaries. You may use this software
* and any derivatives exclusively with Microchip products.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
* PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
* WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
*
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
* BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS
* IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF
* ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*
* MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
* TERMS.
*/
/*
* File:
* Author:
* Comments:
* Revision history:
*/
// This is a guard condition so that contents of this file are not included
// more than once.
#ifndef ADC_H
#define ADC_H
#include <xc.h> // include processor files - each processor file is guarded.
// TODO Insert appropriate #include <>
// TODO Insert C++ class definitions if appropriate
// TODO Insert declarations
/* flag de interrupciones on/off */
#define INT_OFF 0x00
#define INT_ON 0x01
/* frequencia de oscillador */
#define FOSC_2 0x00
#define FOSC_4 0x04
#define FOSC_8 0x01
#define FOSC_16 0x05
#define FOSC_32 0x02
#define FOSC_64 0x06
#define FOSC_RC 0x07
/* configuracion de entradas y Vref(PCFG en ADCON1) */
#define A8_R0 0x00
#define A7_R1 0x01
#define A5_R0 0x02
#define A4_R1 0x03
#define A3_R0 0x04
#define A2_R1 0x05
#define A0_R0 0x06
#define A6_R2 0x08
#define A6_R0 0x09
#define A5_R1 0x0a
#define A4_R2 0x0b
#define A3_R2 0x0c
#define A2_R2 0x0d
#define A1_R0 0x0e
#define A1_R2 0x0f
/* canales */
#define CHAN0 0x00
#define CHAN1 0x01
#define CHAN2 0x02
#define CHAN3 0x03
#define CHAN4 0x04
#define CHAN5 0x05
#define CHAN6 0x06
#define CHAN7 0x07
void adc_init(unsigned char fosc, unsigned char pcfg, unsigned char config);
void adc_close(void);
unsigned int adc_read(unsigned char canal);
void adc_startread(unsigned char canal);
// Comment a function and leverage automatic documentation with slash star star
/**
<p><b>Function prototype:</b></p>
<p><b>Summary:</b></p>
<p><b>Description:</b></p>
<p><b>Precondition:</b></p>
<p><b>Parameters:</b></p>
<p><b>Returns:</b></p>
<p><b>Example:</b></p>
<code>
</code>
<p><b>Remarks:</b></p>
*/
// TODO Insert declarations or function prototypes (right here) to leverage
// live documentation
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
// TODO If C++ is being used, regular C code needs function names to have C
// linkage so the functions can be used by the c code.
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* XC_HEADER_TEMPLATE_H */