LTlib LaurTec Library
4.0.3
Open Source C Library for Microchip Microcontrollers based on XC8 Compiler
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
module_ADC.h
Go to the documentation of this file.
1
/*******************************************************************************
2
3
Autore : Mauro Laurenti
4
Versione : 1.0
5
6
Created on Date : 16/03/2016
7
Last update : 31/07/2016
8
9
CopyRight 2006-2016 all rights are reserved
10
11
********************************************************
12
SOFTWARE LICENSE AGREEMENT
13
********************************************************
14
15
The usage of the supplied software imply the acceptance of the following license.
16
17
The software supplied herewith by Mauro Laurenti (the Author) is intended for
18
use solely and exclusively on Microchip PIC Microcontroller (registered mark).
19
The software is owned by the Author, and is protected under applicable
20
copyright laws. All rights are reserved.
21
Any use in violation of the foregoing restrictions may subject the
22
user to criminal sanctions under applicable laws, as well as to civil liability
23
for the breach of the terms and conditions of this license.
24
Commercial use is forbidden without a written acknowledgement with the Author.
25
Personal or educational use is allowed if the application containing the
26
following software doesn't aim to commercial use or monetary earning of any kind.
27
28
THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES,
29
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
30
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE AUTHOR SHALL NOT,
32
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
33
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
34
35
*******************************************************************************/
36
37
#ifndef LTLIB_ADC_MODULE_H
38
#define LTLIB_ADC_MODULE_H
39
40
#ifdef __XC8
41
#include <xc.h>
42
#endif
43
44
//*****************************************
45
// Library Test
46
//*****************************************
47
#include "
LTlib.h
"
48
49
#ifndef ADC_LIBRARY_SUPPORTED
50
#error (LTlib) The MCU you have selected is not supported by module_ADC library.
51
#endif
52
53
54
//****************************************************
55
56
#define ADC_JUSTIFICATION_LEFT 0
57
#define ADC_JUSTIFICATION_RIGHT 1
58
59
//**************************************************
60
61
#if defined (ADC_MODULE_TYPE_1) || defined (ADC_MODULE_TYPE_2)|| defined (ADC_MODULE_TYPE_3)
62
#define ADC_ACQUISITION_TIME_0_TAD 0b00000000
63
#define ADC_ACQUISITION_TIME_2_TAD 0b00001000
64
#define ADC_ACQUISITION_TIME_4_TAD 0b00010000
65
#define ADC_ACQUISITION_TIME_6_TAD 0b00011000
66
#define ADC_ACQUISITION_TIME_8_TAD 0b00100000
67
#define ADC_ACQUISITION_TIME_12_TAD 0b00101000
68
#define ADC_ACQUISITION_TIME_16_TAD 0b00110000
69
#define ADC_ACQUISITION_TIME_20_TAD 0b00111000
70
71
#define ADC_CLOCK_FOSC_2 0b00000000
72
#define ADC_CLOCK_FOSC_8 0b00000001
73
#define ADC_CLOCK_FOSC_32 0b00000010
74
#define ADC_CLOCK_FOSC_RC 0b00000011
75
#define ADC_CLOCK_FOSC_4 0b00000100
76
#define ADC_CLOCK_FOSC_16 0b00000101
77
#define ADC_CLOCK_FOSC_64 0b00000110
78
#endif
79
80
#ifdef ADC_MODULE_TYPE_4
81
#define ADC_CLOCK_FOSC_RC 0b11000000
82
#define ADC_CLOCK_FOSC_4 0b00000000
83
#define ADC_CLOCK_FOSC_16 0b01000000
84
#define ADC_CLOCK_FOSC_64 0b10000000
85
#endif
86
87
//**************************************************
88
#ifdef ADC_MODULE_TYPE_1
89
#define ADC_VREF_P_AVDD 0b00000000
90
#define ADC_VREF_P_EXT 0b00010000
91
92
#define ADC_VREF_N_AVSS 0b00000000
93
#define ADC_VREF_N_EXT 0b00100000
94
#endif
95
96
//**************************************************
97
#if defined (ADC_MODULE_TYPE_2)|| defined (ADC_MODULE_TYPE_3)
98
#define ADC_VREF_P_AVDD 0b00000000
99
#define ADC_VREF_P_EXT 0b00000100
100
#define ADC_VREF_P_BUF 0b00001000
101
102
#define ADC_VREF_N_AVSS 0b00000000
103
#define ADC_VREF_N_EXT 0b00000001
104
#endif
105
106
//****************************************************
107
120
void
ADC_open
(
unsigned
long
int
ADC_enable_channel);
121
122
131
void
ADC_close
();
132
133
143
void
ADC_select_channel
(
unsigned
long
int
ADC_channel);
144
145
154
void
ADC_start_conversion
(
void
);
155
156
165
void
ADC_abort_conversion
(
void
);
166
167
178
unsigned
int
ADC_read_value
(
void
);
179
180
193
unsigned
int
ADC_read_channel
(
unsigned
long
int
ADC_channel);
194
195
205
unsigned
char
ADC_is_converting
();
206
207
218
void
ADC_set_acquisition_time
(
register_size
acq_time);
219
220
230
void
ADC_set_clock
(
register_size
ADC_clock);
231
242
void
ADC_set_justification
(
unsigned
char
ADC_justification);
243
244
256
void
ADC_set_reference
(
register_size
ADC_reference_V_P,
register_size
ADC_reference_V_N);
257
267
unsigned
char
ADC_channel_converter
(
unsigned
long
int
channel_mask);
268
269
270
#endif
LTlib_v_4.0.3
inc
module_ADC.h
Generated on Wed Aug 3 2016 19:57:31 for LTlib LaurTec Library by
1.8.3.1