Skip to content

Commit 423515e

Browse files
Add support for MKR Vidor 4000 (#2)
* Add support for MKR Vidor 4000 * Force inverted reset on MKR Vidor 4000, and bypass pin number inverting * Dynamic include for Vidor bitstream
1 parent 6228d82 commit 423515e

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/utility/spi_drv.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@
2222
#include <SPI.h>
2323
#include "utility/spi_drv.h"
2424
#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+
2547
//#define _DEBUG_
2648
extern "C" {
2749
#include "utility/debug.h"
@@ -43,6 +65,9 @@ bool SpiDrv::initialized = false;
4365

4466
void SpiDrv::begin()
4567
{
68+
#ifdef ARDUINO_SAMD_MKRVIDOR4000
69+
FPGA.begin();
70+
#endif
4671

4772
#ifdef SPIWIFI_SS
4873
SLAVESELECT = SPIWIFI_SS;
@@ -56,10 +81,14 @@ void SpiDrv::begin()
5681
SLAVERESET = (uint8_t)SPIWIFI_RESET;
5782
#endif
5883

84+
#ifdef ARDUINO_SAMD_MKRVIDOR4000
85+
inverted_reset = false;
86+
#else
5987
if (SLAVERESET > PINS_COUNT) {
6088
inverted_reset = true;
6189
SLAVERESET = ~SLAVERESET;
62-
}
90+
}
91+
#endif
6392

6493
SPIWIFI.begin();
6594
pinMode(SLAVESELECT, OUTPUT);

0 commit comments

Comments
 (0)