forked from Seeed-Studio/Lua_for_LinkIt_One
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwiring_digital.h
133 lines (126 loc) · 3.77 KB
/
wiring_digital.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
123
124
125
126
127
128
129
130
131
132
133
/*
* digital I/O for Arduino Due
* Copyright (c) 2011 Cristian Maglie <[email protected]>.
* All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Modified 20 Aug 2014 by MediaTek Inc.
*/
#ifndef _WIRING_DIGITAL_
#define _WIRING_DIGITAL_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
//DESCRIPTION
// Sets up modes for assigned pins.
//
// There are 16 pins on LinkIt ONE used as digital I/O, they are D0 ~ D13
// and D18/D19, particularly D18/D19 are shared with Wire/I2C.
//
//
//
// LinkIt One supports 3 pin modes:
//
// * INPUT mode is used for reading voltage (HIGH or LOW) or sensor. In INPUT mode when
// the circuit is at high impedance, similar to serially connecting a big resistance in
// the circuit, the pin can read accurate voltage value. However, this pin may not have
// enough voltage to activate peripheral devices, e.g. LED.
// * INPUT_PULLUP mode is similar to INPUT mode, used for reading voltage of sensor. However
// in this mode, the pin is often at high voltage when the sensor is disabled and turns to
// low voltage when the sensor is enabled, which is opposite to its behavior in INPUT mode.
// * OUTPUT mode is used for controlling peripheral devices. In OUTPUT mode when the circuit
// is at low impedance, the pin has enough voltage to activate or control other devices but
// cannot read the voltage of sensor.
//
//EXAMPLE
// <code>
// #define LED 13
// void setup()
// {
// pinMode(LED, OUTPUT);
// }
// void loop()
// {
// digitalWrite(LED, HIGH);
// delay(3000);
// digitalWrite(LED, LOW);
// delay(3000);
// }
// </code>
extern void pinMode(
uint32_t dwPin, // [IN] Pin number that needs to be set with a mode
uint32_t dwMode // [IN] Mode of pin (INPUT, INPUT_PULLUP or OUTPUT)
) ;
//DESCRIPTION
// Sets assigned pins to high voltage (3.3V) or low voltage (0V).
//
// There are 16 pins on LinkIt ONE used as digital I/O, they are D0 ~ D13 and D18/D19, particularly D18/D19 are shared with Wire/I2C.
//EXAMPLE
// <code>
// #define LED 13
// void setup()
// {
// pinMode(LED, OUTPUT);
// }
// void loop()
// {
// digitalWrite(LED, HIGH);
// delay(3000);
// digitalWrite(LED, LOW);
// delay(3000);
// }
// </code>
extern void digitalWrite(
uint32_t dwPin, // [IN] Pin number that needs to be set with a value
uint32_t dwVal // [IN] HIGH or LOW
) ;
//DESCRIPTION
// Reads voltage of assigned pin, HIGH or LOW.
//
// There are 16 pins on LinkIt ONE used as digital I/O, they are D0 ~ D13 and D18/D19, particularly D18/D19 are shared with Wire/I2C.
//RETURNS
// HIGH or LOW
//EXAMPLE
// <code>
// #define LED 13
// #define BUTTON 8
// void setup()
// {
// pinMode(LED, OUTPUT);
// pinMode(BUTTON, INPUT);
// }
// void loop()
// {
// int n= digitalRead(BUTTON);
// if (n == HIGH)
// {
// digitalWrite(LED, LOW);
// }
// else
// {
// digitalWrite(LED, HIGH);
// }
// delay(2000);
// }
// </code>
extern int digitalRead(
uint32_t ulPin // [IN] Pin number that needs to read voltage
) ;
#ifdef __cplusplus
}
#endif
#endif /* _WIRING_DIGITAL_ */