|
1 | | -/* |
2 | | - SerialNINAPassthrough - Use esptool to flash the ESP32 module |
3 | | - For use with PyPortal, Metro M4 WiFi... |
4 | | -
|
5 | | - Copyright (c) 2018 Arduino SA. All rights reserved. |
6 | | -
|
7 | | - This library is free software; you can redistribute it and/or |
8 | | - modify it under the terms of the GNU Lesser General Public |
9 | | - License as published by the Free Software Foundation; either |
10 | | - version 2.1 of the License, or (at your option) any later version. |
11 | | -
|
12 | | - This library is distributed in the hope that it will be useful, |
13 | | - but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | - Lesser General Public License for more details. |
16 | | -
|
17 | | - You should have received a copy of the GNU Lesser General Public |
18 | | - License along with this library; if not, write to the Free Software |
19 | | - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
20 | | -*/ |
21 | | - |
22 | | -#include <Adafruit_NeoPixel.h> |
23 | | - |
24 | | -unsigned long baud = 115200; |
25 | | - |
26 | | -#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) |
27 | | - // Configure the pins used for the ESP32 connection |
28 | | - #define SerialESP32 Serial1 |
29 | | - #define SPIWIFI SPI // The SPI port |
30 | | - #define SPIWIFI_SS 13 // Chip select pin |
31 | | - #define ESP32_RESETN 12 // Reset pin |
32 | | - #define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin |
33 | | - #define ESP32_GPIO0 10 |
34 | | - #define NEOPIXEL_PIN 8 |
35 | | -#endif |
36 | | - |
37 | | -Adafruit_NeoPixel pixel = Adafruit_NeoPixel(1, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800); |
38 | | - |
39 | | - |
40 | | -void setup() { |
41 | | - Serial.begin(baud); |
42 | | - pixel.begin(); |
43 | | - pixel.setPixelColor(0, 10, 10, 10); pixel.show(); |
44 | | - |
45 | | - while (!Serial); |
46 | | - pixel.setPixelColor(0, 50, 50, 50); pixel.show(); |
47 | | - |
48 | | - delay(100); |
49 | | - SerialESP32.begin(baud); |
50 | | - |
51 | | - pinMode(SPIWIFI_SS, OUTPUT); |
52 | | - pinMode(ESP32_GPIO0, OUTPUT); |
53 | | - pinMode(ESP32_RESETN, OUTPUT); |
54 | | - |
55 | | - // manually put the ESP32 in upload mode |
56 | | - digitalWrite(ESP32_GPIO0, LOW); |
57 | | - |
58 | | - digitalWrite(ESP32_RESETN, LOW); |
59 | | - delay(100); |
60 | | - digitalWrite(ESP32_RESETN, HIGH); |
61 | | - pixel.setPixelColor(0, 20, 20, 0); pixel.show(); |
62 | | - delay(100); |
63 | | -} |
64 | | - |
65 | | -void loop() { |
66 | | - while (Serial.available()) { |
67 | | - pixel.setPixelColor(0, 10, 0, 0); pixel.show(); |
68 | | - SerialESP32.write(Serial.read()); |
69 | | - } |
70 | | - |
71 | | - while (SerialESP32.available()) { |
72 | | - pixel.setPixelColor(0, 0, 0, 10); pixel.show(); |
73 | | - Serial.write(SerialESP32.read()); |
74 | | - } |
75 | | -} |
| 1 | +/* |
| 2 | + SerialNINAPassthrough - Use esptool to flash the ESP32 module |
| 3 | + For use with PyPortal, Metro M4 WiFi... |
| 4 | +
|
| 5 | + Copyright (c) 2018 Arduino SA. All rights reserved. |
| 6 | +
|
| 7 | + This library is free software; you can redistribute it and/or |
| 8 | + modify it under the terms of the GNU Lesser General Public |
| 9 | + License as published by the Free Software Foundation; either |
| 10 | + version 2.1 of the License, or (at your option) any later version. |
| 11 | +
|
| 12 | + This library is distributed in the hope that it will be useful, |
| 13 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | + Lesser General Public License for more details. |
| 16 | +
|
| 17 | + You should have received a copy of the GNU Lesser General Public |
| 18 | + License along with this library; if not, write to the Free Software |
| 19 | + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | +*/ |
| 21 | + |
| 22 | +#include <Adafruit_NeoPixel.h> |
| 23 | + |
| 24 | +unsigned long baud = 115200; |
| 25 | + |
| 26 | +#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || defined(ADAFRUIT_PYBADGE_M4_EXPRESS) || defined(ADAFRUIT_PYGAMER_M4_EXPRESS) |
| 27 | + // Configure the pins used for the ESP32 connection via |
| 28 | + #define SerialESP32 Serial1 |
| 29 | + #define SPIWIFI SPI // The SPI port |
| 30 | + #define SPIWIFI_SS 13 // Chip select pin |
| 31 | + #define ESP32_RESETN 12 // Reset pin |
| 32 | + #define SPIWIFI_ACK 11 // a.k.a BUSY or READY pin |
| 33 | + #define ESP32_GPIO0 10 |
| 34 | + #define NEOPIXEL_PIN 8 |
| 35 | +#endif |
| 36 | + |
| 37 | +Adafruit_NeoPixel pixel = Adafruit_NeoPixel(1, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800); |
| 38 | + |
| 39 | + |
| 40 | +void setup() { |
| 41 | + Serial.begin(baud); |
| 42 | + pixel.begin(); |
| 43 | + pixel.setPixelColor(0, 10, 10, 10); pixel.show(); |
| 44 | + |
| 45 | + while (!Serial); |
| 46 | + pixel.setPixelColor(0, 50, 50, 50); pixel.show(); |
| 47 | + |
| 48 | + delay(100); |
| 49 | + SerialESP32.begin(baud); |
| 50 | + |
| 51 | + pinMode(SPIWIFI_SS, OUTPUT); |
| 52 | + pinMode(ESP32_GPIO0, OUTPUT); |
| 53 | + pinMode(ESP32_RESETN, OUTPUT); |
| 54 | + |
| 55 | + // manually put the ESP32 in upload mode |
| 56 | + digitalWrite(ESP32_GPIO0, LOW); |
| 57 | + |
| 58 | + digitalWrite(ESP32_RESETN, LOW); |
| 59 | + delay(100); |
| 60 | + digitalWrite(ESP32_RESETN, HIGH); |
| 61 | + pixel.setPixelColor(0, 20, 20, 0); pixel.show(); |
| 62 | + delay(100); |
| 63 | +} |
| 64 | + |
| 65 | +void loop() { |
| 66 | + while (Serial.available()) { |
| 67 | + pixel.setPixelColor(0, 10, 0, 0); pixel.show(); |
| 68 | + SerialESP32.write(Serial.read()); |
| 69 | + } |
| 70 | + |
| 71 | + while (SerialESP32.available()) { |
| 72 | + pixel.setPixelColor(0, 0, 0, 10); pixel.show(); |
| 73 | + Serial.write(SerialESP32.read()); |
| 74 | + } |
| 75 | +} |
0 commit comments