Fraise
2.1
FRAmework for Interfacing Software and Electronics
Main Page
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Typedefs
Groups
analog.h
1
/*********************************************************************
2
*
3
* Analog library for Fraise pic18f device
4
*
5
*
6
*********************************************************************
7
* Author Date Comment
8
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9
* Antoine Rousseau march 2013 Original.
10
********************************************************************/
11
/*
12
# This program is free software; you can redistribute it and/or
13
# modify it under the terms of the GNU General Public License
14
# as published by the Free Software Foundation; either version 2
15
# of the License, or (at your option) any later version.
16
#
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU General Public License for more details.
21
22
# You should have received a copy of the GNU General Public License
23
# along with this program; if not, write to the Free Software
24
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25
# MA 02110-1301, USA.
26
*/
27
#ifndef _ANALOG__H_
28
#define _ANALOG__H_
29
30
#include <
fruit.h
>
31
32
#ifndef ANALOG_MAX_CHANNELS
33
#define ANALOG_MAX_CHANNELS 16
34
#endif
35
36
#ifndef ANALOG_FILTER
37
#define ANALOG_FILTER 3
38
#endif
39
40
#ifndef ANALOG_THRESHOLD
41
#define ANALOG_THRESHOLD 7
42
#endif
43
44
#ifndef ANALOG_MINMAX_MARGIN
45
#define ANALOG_MINMAX_MARGIN 100
46
#endif
47
48
#ifndef ANALOG_SCALED_MAX
49
#define ANALOG_SCALED_MAX 16383
50
#endif
51
52
#define AMODE_SCALE 1
53
#define AMODE_NOSCALE 0
54
#define AMODE_NUM 2
55
#define AMODE_CHAR 0
56
#define AMODE_CROSS 4
57
#define AMODE_NOCROSS 0
58
59
void
analogInit();
60
61
void
analogSelectAdc(
unsigned
char
chan,
unsigned
char
hwchan);
// attach a hardware channel to an analog channel
62
#define analogSelect(num,conn) do { pinModeAnalogIn(conn); CALL_FUN2(analogSelectAdc,num,KAN(conn)); } while(0)
63
64
void
analogDeselect(
unsigned
char
chan);
// deselect a channel
65
66
void
analogService(
void
);
// call often
67
68
char
analogSend(
void
);
// call at the maximum rate you want to report analog ;
69
// return number of channels sent (max 4)
70
71
void
analogSetMode(
unsigned
char
mode);
// configure the way analog values are sent;
72
73
void
analogSet(
unsigned
char
chan,
int
val);
74
int
analogGet(
unsigned
char
chan);
75
76
int
analogGetDistance(
unsigned
char
chan);
77
78
void
analogScaling(
unsigned
char
scaling);
// when scaling, min and max are updated each sample
79
80
void
analogDeclareEE();
81
82
83
#endif //
fruit.h
analog
analog.h
Generated on Mon Jan 18 2016 00:28:53 for Fraise by
1.8.6