1 | /*
|
---|
2 | Copyright (c) 2011 Arduino. All right reserved.
|
---|
3 |
|
---|
4 | This library is free software; you can redistribute it and/or
|
---|
5 | modify it under the terms of the GNU Lesser General Public
|
---|
6 | License as published by the Free Software Foundation; either
|
---|
7 | version 2.1 of the License, or (at your option) any later version.
|
---|
8 |
|
---|
9 | This library is distributed in the hope that it will be useful,
|
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
12 | See the GNU Lesser General Public License for more details.
|
---|
13 |
|
---|
14 | You should have received a copy of the GNU Lesser General Public
|
---|
15 | License along with this library; if not, write to the Free Software
|
---|
16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef _WIRING_ANALOG_
|
---|
20 | #define _WIRING_ANALOG_
|
---|
21 |
|
---|
22 | #include <stdint.h>
|
---|
23 |
|
---|
24 | #ifdef __cplusplus
|
---|
25 | extern "C" {
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | /*
|
---|
29 | * \brief SAM3 products have only one reference for ADC
|
---|
30 | */
|
---|
31 | typedef enum _eAnalogReference
|
---|
32 | {
|
---|
33 | AR_DEFAULT,
|
---|
34 | AR_INTERNAL,
|
---|
35 | AR_EXTERNAL
|
---|
36 | } eAnalogReference ;
|
---|
37 |
|
---|
38 |
|
---|
39 | /*
|
---|
40 | * \brief Configures the reference voltage used for analog input (i.e. the value used as the top of the input range).
|
---|
41 | * This function is kept only for compatibility with existing AVR based API.
|
---|
42 | *
|
---|
43 | * \param ulMmode Should be set to AR_DEFAULT.
|
---|
44 | */
|
---|
45 | extern void analogReference( eAnalogReference ulMode ) ;
|
---|
46 |
|
---|
47 | /*
|
---|
48 | * \brief Writes an analog value (PWM wave) to a pin.
|
---|
49 | *
|
---|
50 | * \param ulPin
|
---|
51 | * \param ulValue
|
---|
52 | */
|
---|
53 | extern void analogWrite( uint32_t ulPin, uint32_t ulValue ) ;
|
---|
54 |
|
---|
55 | /*
|
---|
56 | * \brief Reads the value from the specified analog pin.
|
---|
57 | *
|
---|
58 | * \param ulPin
|
---|
59 | *
|
---|
60 | * \return Read value from selected pin, if no error.
|
---|
61 | */
|
---|
62 | extern uint32_t analogRead( uint32_t ulPin ) ;
|
---|
63 |
|
---|
64 | /*
|
---|
65 | * \brief Set the resolution of analogRead return values. Default is 10 bits (range from 0 to 1023).
|
---|
66 | *
|
---|
67 | * \param res
|
---|
68 | */
|
---|
69 | extern void analogReadResolution(int res);
|
---|
70 |
|
---|
71 | /*
|
---|
72 | * \brief Set the resolution of analogWrite parameters. Default is 8 bits (range from 0 to 255).
|
---|
73 | *
|
---|
74 | * \param res
|
---|
75 | */
|
---|
76 | extern void analogWriteResolution(int res);
|
---|
77 |
|
---|
78 | extern void analogOutputInit( void ) ;
|
---|
79 |
|
---|
80 | #ifdef __cplusplus
|
---|
81 | }
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | #endif /* _WIRING_ANALOG_ */
|
---|