aboutsummaryrefslogtreecommitdiff
path: root/src/core/gpio.h
blob: 5b7c05c39b4e7a33c3cb67ca1889baa37e01bf9a (plain)
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
 * gpio.h
 *
 *  Created on: 2011/07/27
 *      Author: lynxeyed
 */
#ifndef GPIO_H_
#define GPIO_H_

//#if defined (__USE_CMSIS)
#include "LPC11xx.h"
//#endif
//=======================================
// Define LPC_GPIO[4] (each top address)
//=======================================
static LPC_GPIO_TypeDef (* const LPC_GPIO[4]) = { LPC_GPIO0, LPC_GPIO1, LPC_GPIO2, LPC_GPIO3 };

/*	=======================================
*	Macros and functions for Defining MARY's GPIO Assign
*
*	CN1_7,8		:	(PIO1_2,PIO1_1)
*					should be C17,C18
*
*	CN2_1...8	:	(PIO1_4,PIO1_11,PIO1_7,PIO1_5,PIO3_2,PIO2_0,PIO1_6,PIO0_1)
*					should be C21,C22,C23,C24,C25,C26,C27,C28
*
*	CN3_1...8	:	(PIO1_8,PIO0_3,PIO0_2,PIO3_4,PIO0_4,PIO3_5,PIO0_5,PIO1_7)
*					should be C31,C32,C33,C34,C35,C36,C37,C38
*
*	CN4_1...7	:	(PIO1_9,PIO1_10,PIO0_6,PIO0_11,PIO0_8,PIO1_0,PIO0_9)
*					should be C41,C42,C43,C44,C45,C46,C47
*	=======================================
*/
#define C17	(100)
#define C18	(101)

#define C21 (102)
#define C22 (103)
#define C23 (104)
#define C24 (105)
#define C25 (106)
#define C26 (107)
#define C27 (108)
#define C28 (109)

#define C31 (110)
#define C32 (111)
#define C33 (112)
#define C34 (113)
#define C35 (114)
#define C36 (115)
#define C37 (116)
#define C38 (117)

#define C41 (118)
#define C42 (119)
#define C43 (120)
#define C44 (121)
#define C45 (122)
#define C46 (123)
#define C47 (124)
#define GLED (125)
#define BLED (126)
#define RLED (127)

// For LPCXpresso LPC1114
#define P1_2	(100)
#define P1_1	(101)
#define P1_4	(102)
#define P1_11	(103)
#define P1_7	(104)
#define P1_5	(105)
#define P3_2	(106)
#define P2_0	(107)
#define P1_6	(108)
#define P0_1	(109)
#define P1_8	(110)
#define P0_3	(111)
#define P0_2	(112)
#define P3_4	(113)
#define P0_4	(114)
#define P3_5	(115)
#define P0_5	(116)
//#define P1_7	(117)
#define P1_9	(118)
#define P1_10	(119)
#define P0_6	(120)
#define P0_11	(121)
#define P0_8	(122)
#define P1_0	(123)
#define P0_9	(124)
#define P0_7	(125)
//#define P1_5	(126)
//#define P2_0	(127)

#define _BIT0 (1U << 0)
#define _BIT1 (1U << 1)
#define _BIT2 (1U << 2)
#define _BIT3 (1U << 3)
#define _BIT4 (1U << 4)
#define _BIT5 (1U << 5)
#define _BIT6 (1U << 6)
#define _BIT7 (1U << 7)
#define _BIT8 (1U << 8)
#define _BIT9 (1U << 9)
#define _BIT10 (1U << 10)
#define _BIT11 (1U << 11)

const unsigned int mary_pinAssign[] =
{
	1, _BIT2,	//CN1_7
	1, _BIT1,	//CN1_8

	1, _BIT4,	//CN2_1
	1, _BIT11,	//CN2_2
	1, _BIT7,	//CN2_3
	1, _BIT5,	//CN2_4
	3, _BIT2,	//CN2_5
	2, _BIT0,	//CN2_6
	1, _BIT6,	//CN2_7
	0, _BIT1,	//CN2_8

	1, _BIT8,	//CN3_1
	0, _BIT3,	//CN3_2
	0, _BIT2,	//CN3_3
	3, _BIT4,	//CN3_4
	0, _BIT4,	//CN3_5
	3, _BIT5,	//CN3_6
	0, _BIT5,	//CN3_7
	1, _BIT7,	//CN3_8

	1, _BIT9,	//CN4_1
	1, _BIT10,	//CN4_2
	0, _BIT6,	//CN4_3
	0, _BIT11,	//CN4_4
	0, _BIT8,	//CN4_5
	1, _BIT0,	//CN4_6
	0, _BIT9,	//CN4_7
	0, _BIT7,	//GLED
	1, _BIT5,	//BLED
	2, _BIT0	//RLED
};


// Arduino's pins assign
const unsigned int arduino_pinAssign[] =
{
	1, _BIT6,	//P1_6:D0/RX
	1, _BIT7,	//P1_7:D1/TX
	0, _BIT3,	//P0_3:D2
	1, _BIT9,	//P1_9:D3
	3, _BIT4,	//P3_4:D4
	2, _BIT4,	//P2_4:D5
	2, _BIT0,	//P2_0:D6
	2, _BIT3,	//P2_3:D7
	2, _BIT2,	//P2_2:D8
	2, _BIT1,	//P2_1:D9
	0, _BIT2,	//P0_2:D10

	0, _BIT9,	//P0_9:D11
	0, _BIT8,	//P0_8:D12
	0, _BIT6,	//P0_6:D13


/*	0, _BIT4,	//P
	3, _BIT5,	//CN3_6
	0, _BIT5,	//CN3_7
	1, _BIT7,	//CN3_8

	1, _BIT9,	//CN4_1
	1, _BIT10,	//CN4_2
	0, _BIT6,	//CN4_3
	0, _BIT11,	//CN4_4
	0, _BIT8,	//CN4_5
	1, _BIT0,	//CN4_6
	0, _BIT9,	//CN4_7
	0, _BIT7,	//GLED
	1, _BIT5,	//BLED
	2, _BIT0	//RLED
*/
};


typedef enum {INPUT, OUTPUT}pinModeState;
typedef enum {LOW, HIGH}digitalWriteState;

void pinMode(int pin,pinModeState state);
void digitalWrite(int pin,digitalWriteState state);
int digitalRead(int pin);




#endif /* GPIO_H_ */