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_DIGITAL_
|
---|
20 | #define _WIRING_DIGITAL_
|
---|
21 |
|
---|
22 | #ifdef __cplusplus
|
---|
23 | extern "C" {
|
---|
24 | #endif
|
---|
25 |
|
---|
26 | #define INPUT (0x0ul)
|
---|
27 | #define OUTPUT (0x1ul)
|
---|
28 | #define INPUT_PULLUP (0x2ul)
|
---|
29 |
|
---|
30 | #define LOW (0x0ul)
|
---|
31 | #define HIGH (0x1ul)
|
---|
32 |
|
---|
33 | #include "WVariant.h"
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * \brief Configures the specified pin to belong to a device peripheral or to behave either as a an input or an output. See the description of board for details.
|
---|
37 | *
|
---|
38 | * \param ulPin The number of the pin whose mode you wish to set
|
---|
39 | * \param ulPeripheral See WVariant.h for type decription
|
---|
40 | */
|
---|
41 | extern int pinPeripheral( uint32_t ulPin, EPioType ulPeripheral ) ;
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * \brief Configures the specified pin to behave either as an input or an output. See the description of digital pins for details.
|
---|
45 | *
|
---|
46 | * \param ulPin The number of the pin whose mode you wish to set
|
---|
47 | * \param ulMode Either INPUT or OUTPUT
|
---|
48 | */
|
---|
49 | extern void pinMode( uint32_t dwPin, uint32_t dwMode ) ;
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * \brief Write a HIGH or a LOW value to a digital pin.
|
---|
53 | *
|
---|
54 | * If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the
|
---|
55 | * corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.
|
---|
56 | *
|
---|
57 | * If the pin is configured as an INPUT, writing a HIGH value with digitalWrite() will enable an internal
|
---|
58 | * 20K pullup resistor (see the tutorial on digital pins). Writing LOW will disable the pullup. The pullup
|
---|
59 | * resistor is enough to light an LED dimly, so if LEDs appear to work, but very dimly, this is a likely
|
---|
60 | * cause. The remedy is to set the pin to an output with the pinMode() function.
|
---|
61 | *
|
---|
62 | * \note Digital pin PIN_LED is harder to use as a digital input than the other digital pins because it has an LED
|
---|
63 | * and resistor attached to it that's soldered to the board on most boards. If you enable its internal 20k pull-up
|
---|
64 | * resistor, it will hang at around 1.7 V instead of the expected 5V because the onboard LED and series resistor
|
---|
65 | * pull the voltage level down, meaning it always returns LOW. If you must use pin PIN_LED as a digital input, use an
|
---|
66 | * external pull down resistor.
|
---|
67 | *
|
---|
68 | * \param dwPin the pin number
|
---|
69 | * \param dwVal HIGH or LOW
|
---|
70 | */
|
---|
71 | extern void digitalWrite( uint32_t dwPin, uint32_t dwVal ) ;
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * \brief Reads the value from a specified digital pin, either HIGH or LOW.
|
---|
75 | *
|
---|
76 | * \param ulPin The number of the digital pin you want to read (int)
|
---|
77 | *
|
---|
78 | * \return HIGH or LOW
|
---|
79 | */
|
---|
80 | extern int digitalRead( uint32_t ulPin ) ;
|
---|
81 |
|
---|
82 | #ifdef __cplusplus
|
---|
83 | }
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | #endif /* _WIRING_DIGITAL_ */
|
---|