forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmachine_pin.h
More file actions
297 lines (276 loc) · 9.96 KB
/
machine_pin.h
File metadata and controls
297 lines (276 loc) · 9.96 KB
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2023 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_ESP32_MACHINE_PIN_H
#define MICROPY_INCLUDED_ESP32_MACHINE_PIN_H
#include "py/obj.h"
#include "hal/gpio_types.h"
// Define which pins are enabled for a given SoC and configuration.
#if CONFIG_IDF_TARGET_ESP32
#define MICROPY_HW_ENABLE_GPIO0 (1)
#define MICROPY_HW_ENABLE_GPIO1 (1)
#define MICROPY_HW_ENABLE_GPIO2 (1)
#define MICROPY_HW_ENABLE_GPIO3 (1)
#define MICROPY_HW_ENABLE_GPIO4 (1)
#define MICROPY_HW_ENABLE_GPIO5 (1)
#define MICROPY_HW_ENABLE_GPIO6 (1)
#define MICROPY_HW_ENABLE_GPIO7 (1)
#define MICROPY_HW_ENABLE_GPIO8 (1)
#define MICROPY_HW_ENABLE_GPIO9 (1)
#define MICROPY_HW_ENABLE_GPIO10 (1)
#define MICROPY_HW_ENABLE_GPIO11 (1)
#define MICROPY_HW_ENABLE_GPIO12 (1)
#define MICROPY_HW_ENABLE_GPIO13 (1)
#define MICROPY_HW_ENABLE_GPIO14 (1)
#define MICROPY_HW_ENABLE_GPIO15 (1)
#if !CONFIG_SPIRAM
#define MICROPY_HW_ENABLE_GPIO16 (1)
#define MICROPY_HW_ENABLE_GPIO17 (1)
#endif
#define MICROPY_HW_ENABLE_GPIO18 (1)
#define MICROPY_HW_ENABLE_GPIO19 (1)
#define MICROPY_HW_ENABLE_GPIO20 (1)
#define MICROPY_HW_ENABLE_GPIO21 (1)
#define MICROPY_HW_ENABLE_GPIO22 (1)
#define MICROPY_HW_ENABLE_GPIO23 (1)
#define MICROPY_HW_ENABLE_GPIO25 (1)
#define MICROPY_HW_ENABLE_GPIO26 (1)
#define MICROPY_HW_ENABLE_GPIO27 (1)
#define MICROPY_HW_ENABLE_GPIO32 (1)
#define MICROPY_HW_ENABLE_GPIO33 (1)
#define MICROPY_HW_ENABLE_GPIO34 (1)
#define MICROPY_HW_ENABLE_GPIO35 (1)
#define MICROPY_HW_ENABLE_GPIO36 (1)
#define MICROPY_HW_ENABLE_GPIO37 (1)
#define MICROPY_HW_ENABLE_GPIO38 (1)
#define MICROPY_HW_ENABLE_GPIO39 (1)
#elif CONFIG_IDF_TARGET_ESP32C2
#define MICROPY_HW_ENABLE_GPIO0 (1)
#define MICROPY_HW_ENABLE_GPIO1 (1)
#define MICROPY_HW_ENABLE_GPIO2 (1)
#define MICROPY_HW_ENABLE_GPIO3 (1)
#define MICROPY_HW_ENABLE_GPIO4 (1)
#define MICROPY_HW_ENABLE_GPIO5 (1)
#define MICROPY_HW_ENABLE_GPIO6 (1)
#define MICROPY_HW_ENABLE_GPIO7 (1)
#define MICROPY_HW_ENABLE_GPIO8 (1)
#define MICROPY_HW_ENABLE_GPIO9 (1)
#define MICROPY_HW_ENABLE_GPIO10 (1)
#define MICROPY_HW_ENABLE_GPIO18 (1)
#define MICROPY_HW_ENABLE_GPIO19 (1) // UART0_RXD
#define MICROPY_HW_ENABLE_GPIO20 (1) // UART0_TXD
#elif CONFIG_IDF_TARGET_ESP32C3
#define MICROPY_HW_ENABLE_GPIO0 (1)
#define MICROPY_HW_ENABLE_GPIO1 (1)
#define MICROPY_HW_ENABLE_GPIO2 (1)
#define MICROPY_HW_ENABLE_GPIO3 (1)
#define MICROPY_HW_ENABLE_GPIO4 (1)
#define MICROPY_HW_ENABLE_GPIO5 (1)
#define MICROPY_HW_ENABLE_GPIO6 (1)
#define MICROPY_HW_ENABLE_GPIO7 (1)
#define MICROPY_HW_ENABLE_GPIO8 (1)
#define MICROPY_HW_ENABLE_GPIO9 (1)
#define MICROPY_HW_ENABLE_GPIO10 (1)
#define MICROPY_HW_ENABLE_GPIO11 (1)
#define MICROPY_HW_ENABLE_GPIO12 (1)
#define MICROPY_HW_ENABLE_GPIO13 (1)
#if !MICROPY_HW_ESP_USB_SERIAL_JTAG
#define MICROPY_HW_ENABLE_GPIO18 (1)
#define MICROPY_HW_ENABLE_GPIO19 (1)
#endif
#define MICROPY_HW_ENABLE_GPIO20 (1)
#define MICROPY_HW_ENABLE_GPIO21 (1)
#elif CONFIG_IDF_TARGET_ESP32C5
#define MICROPY_HW_ENABLE_GPIO0 (1)
#define MICROPY_HW_ENABLE_GPIO1 (1)
#define MICROPY_HW_ENABLE_GPIO2 (1)
#define MICROPY_HW_ENABLE_GPIO3 (1)
#define MICROPY_HW_ENABLE_GPIO4 (1)
#define MICROPY_HW_ENABLE_GPIO5 (1)
#define MICROPY_HW_ENABLE_GPIO6 (1)
#define MICROPY_HW_ENABLE_GPIO7 (1)
#define MICROPY_HW_ENABLE_GPIO8 (1)
#define MICROPY_HW_ENABLE_GPIO9 (1)
#define MICROPY_HW_ENABLE_GPIO10 (1)
#define MICROPY_HW_ENABLE_GPIO11 (1)
#define MICROPY_HW_ENABLE_GPIO12 (1)
#if !MICROPY_HW_ESP_USB_SERIAL_JTAG
#define MICROPY_HW_ENABLE_GPIO13 (1)
#define MICROPY_HW_ENABLE_GPIO14 (1)
#endif
#define MICROPY_HW_ENABLE_GPIO23 (1)
#define MICROPY_HW_ENABLE_GPIO24 (1)
#define MICROPY_HW_ENABLE_GPIO25 (1)
#define MICROPY_HW_ENABLE_GPIO26 (1)
#define MICROPY_HW_ENABLE_GPIO27 (1)
#define MICROPY_HW_ENABLE_GPIO28 (1)
#elif CONFIG_IDF_TARGET_ESP32C6
#define MICROPY_HW_ENABLE_GPIO0 (1)
#define MICROPY_HW_ENABLE_GPIO1 (1)
#define MICROPY_HW_ENABLE_GPIO2 (1)
#define MICROPY_HW_ENABLE_GPIO3 (1)
#define MICROPY_HW_ENABLE_GPIO4 (1)
#define MICROPY_HW_ENABLE_GPIO5 (1)
#define MICROPY_HW_ENABLE_GPIO6 (1)
#define MICROPY_HW_ENABLE_GPIO7 (1)
#define MICROPY_HW_ENABLE_GPIO8 (1)
#define MICROPY_HW_ENABLE_GPIO9 (1)
#define MICROPY_HW_ENABLE_GPIO10 (1)
#define MICROPY_HW_ENABLE_GPIO11 (1)
#if !MICROPY_HW_ESP_USB_SERIAL_JTAG
#define MICROPY_HW_ENABLE_GPIO12 (1)
#define MICROPY_HW_ENABLE_GPIO13 (1)
#endif
#define MICROPY_HW_ENABLE_GPIO14 (1)
#define MICROPY_HW_ENABLE_GPIO15 (1)
#define MICROPY_HW_ENABLE_GPIO16 (1)
#define MICROPY_HW_ENABLE_GPIO17 (1)
#define MICROPY_HW_ENABLE_GPIO18 (1)
#define MICROPY_HW_ENABLE_GPIO19 (1)
#define MICROPY_HW_ENABLE_GPIO20 (1)
#define MICROPY_HW_ENABLE_GPIO21 (1)
#define MICROPY_HW_ENABLE_GPIO22 (1)
#define MICROPY_HW_ENABLE_GPIO23 (1)
// GPIO 24-30 are used for spi/sip flash.
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
#define MICROPY_HW_ENABLE_GPIO0 (1)
#define MICROPY_HW_ENABLE_GPIO1 (1)
#define MICROPY_HW_ENABLE_GPIO2 (1)
#define MICROPY_HW_ENABLE_GPIO3 (1)
#define MICROPY_HW_ENABLE_GPIO4 (1)
#define MICROPY_HW_ENABLE_GPIO5 (1)
#define MICROPY_HW_ENABLE_GPIO6 (1)
#define MICROPY_HW_ENABLE_GPIO7 (1)
#define MICROPY_HW_ENABLE_GPIO8 (1)
#define MICROPY_HW_ENABLE_GPIO9 (1)
#define MICROPY_HW_ENABLE_GPIO10 (1)
#define MICROPY_HW_ENABLE_GPIO11 (1)
#define MICROPY_HW_ENABLE_GPIO12 (1)
#define MICROPY_HW_ENABLE_GPIO13 (1)
#define MICROPY_HW_ENABLE_GPIO14 (1)
#define MICROPY_HW_ENABLE_GPIO15 (1)
#define MICROPY_HW_ENABLE_GPIO16 (1)
#define MICROPY_HW_ENABLE_GPIO17 (1)
#define MICROPY_HW_ENABLE_GPIO18 (1)
#if !CONFIG_USB_CDC_ENABLED
#define MICROPY_HW_ENABLE_GPIO19 (1)
#define MICROPY_HW_ENABLE_GPIO20 (1)
#endif
#define MICROPY_HW_ENABLE_GPIO21 (1)
#if !CONFIG_SPIRAM
#define MICROPY_HW_ENABLE_GPIO26 (1)
#endif
#if !CONFIG_SPIRAM_MODE_OCT
#define MICROPY_HW_ENABLE_GPIO33 (1)
#define MICROPY_HW_ENABLE_GPIO34 (1)
#define MICROPY_HW_ENABLE_GPIO35 (1)
#define MICROPY_HW_ENABLE_GPIO36 (1)
#define MICROPY_HW_ENABLE_GPIO37 (1)
#endif
#define MICROPY_HW_ENABLE_GPIO38 (1)
#define MICROPY_HW_ENABLE_GPIO39 (1)
#define MICROPY_HW_ENABLE_GPIO40 (1)
#define MICROPY_HW_ENABLE_GPIO41 (1)
#define MICROPY_HW_ENABLE_GPIO42 (1)
#define MICROPY_HW_ENABLE_GPIO43 (1)
#define MICROPY_HW_ENABLE_GPIO44 (1)
#define MICROPY_HW_ENABLE_GPIO45 (1)
#define MICROPY_HW_ENABLE_GPIO46 (1)
#if CONFIG_IDF_TARGET_ESP32S3 && MICROPY_HW_ESP32S3_EXTENDED_IO
#define MICROPY_HW_ENABLE_GPIO47 (1)
#define MICROPY_HW_ENABLE_GPIO48 (1)
#endif
#elif CONFIG_IDF_TARGET_ESP32P4
#define MICROPY_HW_ENABLE_GPIO0 (1)
#define MICROPY_HW_ENABLE_GPIO1 (1)
#define MICROPY_HW_ENABLE_GPIO2 (1)
#define MICROPY_HW_ENABLE_GPIO3 (1)
#define MICROPY_HW_ENABLE_GPIO4 (1)
#define MICROPY_HW_ENABLE_GPIO5 (1)
#define MICROPY_HW_ENABLE_GPIO6 (1)
#define MICROPY_HW_ENABLE_GPIO7 (1)
#define MICROPY_HW_ENABLE_GPIO8 (1)
#define MICROPY_HW_ENABLE_GPIO9 (1)
#define MICROPY_HW_ENABLE_GPIO10 (1)
#define MICROPY_HW_ENABLE_GPIO11 (1)
#define MICROPY_HW_ENABLE_GPIO12 (1)
#define MICROPY_HW_ENABLE_GPIO13 (1)
#define MICROPY_HW_ENABLE_GPIO14 (1)
#define MICROPY_HW_ENABLE_GPIO15 (1)
#define MICROPY_HW_ENABLE_GPIO16 (1)
#define MICROPY_HW_ENABLE_GPIO17 (1)
#define MICROPY_HW_ENABLE_GPIO18 (1)
#define MICROPY_HW_ENABLE_GPIO19 (1)
#define MICROPY_HW_ENABLE_GPIO20 (1)
#define MICROPY_HW_ENABLE_GPIO21 (1)
#define MICROPY_HW_ENABLE_GPIO22 (1)
#define MICROPY_HW_ENABLE_GPIO23 (1)
#if !MICROPY_HW_ESP_USB_SERIAL_JTAG
// Note: ESP32-P4 can switch USJ to 26/27 instead, but
// this isn't supported
#define MICROPY_HW_ENABLE_GPIO24 (1)
#define MICROPY_HW_ENABLE_GPIO25 (1)
#endif
#define MICROPY_HW_ENABLE_GPIO26 (1)
#define MICROPY_HW_ENABLE_GPIO27 (1)
#define MICROPY_HW_ENABLE_GPIO28 (1)
#define MICROPY_HW_ENABLE_GPIO29 (1)
#define MICROPY_HW_ENABLE_GPIO30 (1)
#define MICROPY_HW_ENABLE_GPIO31 (1)
#define MICROPY_HW_ENABLE_GPIO32 (1)
#define MICROPY_HW_ENABLE_GPIO33 (1)
#define MICROPY_HW_ENABLE_GPIO34 (1)
#define MICROPY_HW_ENABLE_GPIO35 (1)
#define MICROPY_HW_ENABLE_GPIO36 (1)
#define MICROPY_HW_ENABLE_GPIO37 (1)
#define MICROPY_HW_ENABLE_GPIO38 (1)
#define MICROPY_HW_ENABLE_GPIO39 (1)
#define MICROPY_HW_ENABLE_GPIO40 (1)
#define MICROPY_HW_ENABLE_GPIO41 (1)
#define MICROPY_HW_ENABLE_GPIO42 (1)
#define MICROPY_HW_ENABLE_GPIO43 (1)
#define MICROPY_HW_ENABLE_GPIO44 (1)
#define MICROPY_HW_ENABLE_GPIO45 (1)
#define MICROPY_HW_ENABLE_GPIO46 (1)
#define MICROPY_HW_ENABLE_GPIO47 (1)
#define MICROPY_HW_ENABLE_GPIO48 (1)
#define MICROPY_HW_ENABLE_GPIO49 (1)
#define MICROPY_HW_ENABLE_GPIO50 (1)
#define MICROPY_HW_ENABLE_GPIO51 (1)
#define MICROPY_HW_ENABLE_GPIO52 (1)
#define MICROPY_HW_ENABLE_GPIO53 (1)
#define MICROPY_HW_ENABLE_GPIO54 (1)
#endif
typedef struct _machine_pin_irq_obj_t {
mp_obj_base_t base;
} machine_pin_irq_obj_t;
typedef struct _machine_pin_obj_t {
mp_obj_base_t base;
machine_pin_irq_obj_t irq;
} machine_pin_obj_t;
extern const mp_obj_type_t machine_pin_irq_type;
extern const machine_pin_obj_t machine_pin_obj_table[GPIO_NUM_MAX];
extern const mp_obj_dict_t machine_pin_board_pins_locals_dict;
#endif // MICROPY_INCLUDED_ESP32_MACHINE_PIN_H