22
22
#include < SPI.h>
23
23
#include " utility/spi_drv.h"
24
24
#include " pins_arduino.h"
25
+
26
+ #ifdef ARDUINO_SAMD_MKRVIDOR4000
27
+
28
+ // check if a bitstream is already included
29
+ #if __has_include(<VidorFPGA.h>)
30
+ // yes, so use the existing VidorFPGA include
31
+ #include < VidorFPGA.h>
32
+ #else
33
+ // otherwise, fallback to VidorPeripherals and it's bistream
34
+ #include < VidorPeripherals.h>
35
+ #endif
36
+
37
+ #define NINA_GPIO0 FPGA_NINA_GPIO0
38
+ #define SPIWIFI_SS FPGA_SPIWIFI_SS
39
+ #define SPIWIFI_ACK FPGA_SPIWIFI_ACK
40
+ #define SPIWIFI_RESET FPGA_SPIWIFI_RESET
41
+
42
+ #define pinMode (pin, mode ) FPGA.pinMode(pin, mode)
43
+ #define digitalRead (pin ) FPGA.digitalRead(pin)
44
+ #define digitalWrite (pin, value ) FPGA.digitalWrite(pin, value)
45
+ #endif
46
+
25
47
// #define _DEBUG_
26
48
extern " C" {
27
49
#include " utility/debug.h"
@@ -43,6 +65,9 @@ bool SpiDrv::initialized = false;
43
65
44
66
void SpiDrv::begin ()
45
67
{
68
+ #ifdef ARDUINO_SAMD_MKRVIDOR4000
69
+ FPGA.begin ();
70
+ #endif
46
71
47
72
#ifdef SPIWIFI_SS
48
73
SLAVESELECT = SPIWIFI_SS;
@@ -56,10 +81,14 @@ void SpiDrv::begin()
56
81
SLAVERESET = (uint8_t )SPIWIFI_RESET;
57
82
#endif
58
83
84
+ #ifdef ARDUINO_SAMD_MKRVIDOR4000
85
+ inverted_reset = false ;
86
+ #else
59
87
if (SLAVERESET > PINS_COUNT) {
60
88
inverted_reset = true ;
61
89
SLAVERESET = ~SLAVERESET;
62
- }
90
+ }
91
+ #endif
63
92
64
93
SPIWIFI.begin ();
65
94
pinMode (SLAVESELECT, OUTPUT);
0 commit comments