1
1
/*
2
- ESP32BootROM - part of the Firmware Updater for the
2
+ ESP32BootROM - part of the Firmware Updater for the
3
3
Arduino MKR WiFi 1010, Arduino MKR Vidor 4000, and Arduino UNO WiFi Rev.2.
4
-
4
+
5
5
Copyright (c) 2018 Arduino SA. All rights reserved.
6
-
6
+
7
7
This library is free software; you can redistribute it and/or
8
8
modify it under the terms of the GNU Lesser General Public
9
9
License as published by the Free Software Foundation; either
10
10
version 2.1 of the License, or (at your option) any later version.
11
-
11
+
12
12
This library is distributed in the hope that it will be useful,
13
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
15
Lesser General Public License for more details.
16
-
16
+
17
17
You should have received a copy of the GNU Lesser General Public
18
18
License along with this library; if not, write to the Free Software
19
19
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
20
*/
21
21
22
+ #ifdef ARDUINO_SAMD_MKRVIDOR4000
23
+ #include < VidorPeripherals.h>
24
+
25
+ #define NINA_GPIO0 FPGA_NINA_GPIO0
26
+ #define NINA_RESETN FPGA_SPIWIFI_RESET
27
+ #endif
28
+
29
+
22
30
#include " ESP32BootROM.h"
23
31
24
32
ESP32BootROMClass::ESP32BootROMClass (HardwareSerial& serial, int gpio0Pin, int resetnPin) :
@@ -30,7 +38,25 @@ ESP32BootROMClass::ESP32BootROMClass(HardwareSerial& serial, int gpio0Pin, int r
30
38
}
31
39
32
40
int ESP32BootROMClass::begin (unsigned long baudrate)
33
- { pinMode (_gpio0Pin, OUTPUT);
41
+ {
42
+ #ifdef ARDUINO_SAMD_MKRVIDOR4000
43
+ FPGA.begin ();
44
+
45
+ _serial->begin (119400 );
46
+
47
+ FPGA.pinMode (_gpio0Pin, OUTPUT);
48
+ FPGA.pinMode (_resetnPin, OUTPUT);
49
+
50
+ FPGA.digitalWrite (_gpio0Pin, LOW);
51
+
52
+ FPGA.digitalWrite (_resetnPin, LOW);
53
+ delay (10 );
54
+ FPGA.digitalWrite (_resetnPin, HIGH);
55
+ delay (100 );
56
+ #else
57
+ _serial->begin (115200 );
58
+
59
+ pinMode (_gpio0Pin, OUTPUT);
34
60
pinMode (_resetnPin, OUTPUT);
35
61
36
62
digitalWrite (_gpio0Pin, LOW);
@@ -39,8 +65,7 @@ int ESP32BootROMClass::begin(unsigned long baudrate)
39
65
delay (10 );
40
66
digitalWrite (_resetnPin, LOW);
41
67
delay (100 );
42
-
43
- _serial->begin (115200 );
68
+ #endif
44
69
45
70
int synced = 0 ;
46
71
@@ -52,6 +77,9 @@ int ESP32BootROMClass::begin(unsigned long baudrate)
52
77
return 0 ;
53
78
}
54
79
80
+ #ifdef ARDUINO_SAMD_MKRVIDOR4000
81
+ (void )baudrate;
82
+ #else
55
83
if (baudrate != 115200 ) {
56
84
if (!changeBaudrate (baudrate)) {
57
85
return 0 ;
@@ -62,6 +90,7 @@ int ESP32BootROMClass::begin(unsigned long baudrate)
62
90
_serial->end ();
63
91
_serial->begin (baudrate);
64
92
}
93
+ #endif
65
94
66
95
if (!spiAttach ()) {
67
96
return 0 ;
@@ -209,7 +238,11 @@ void ESP32BootROMClass::command(int opcode, const void* data, uint16_t length)
209
238
writeEscapedBytes ((uint8_t *)&checksum, sizeof (checksum));
210
239
writeEscapedBytes ((uint8_t *)data, length);
211
240
_serial->write (0xc0 );
241
+ #ifdef ARDUINO_SAMD_MKRVIDOR4000
242
+ // _serial->flush(); // doesn't work!
243
+ #else
212
244
_serial->flush ();
245
+ #endif
213
246
}
214
247
215
248
int ESP32BootROMClass::response (int opcode, unsigned int timeout, void * body)
0 commit comments