Skip to content
This repository was archived by the owner on Dec 20, 2018. It is now read-only.

Commit 557cf96

Browse files
committed
allow variable CS pin
1 parent d4a5a08 commit 557cf96

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

examples/ScanNetworks/ScanNetworks.ino

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@
1616

1717

1818
#include <SPI.h>
19-
#include <WiFi101.h>
19+
#include <Adafruit_WINC1500.h>
20+
21+
/************************* WiFI Setup *****************************/
22+
#define WINC_CS 8
23+
#define WINC_IRQ 7
24+
#define WINC_RST 4
25+
#define WINC_EN 2 // or, tie EN to VCC
26+
27+
Adafruit_WINC1500 WiFi(WINC_CS, WINC_IRQ, WINC_RST);
2028

2129
void setup() {
2230
//Initialize serial and wait for port to open:

src/bus_wrapper/source/nm_bus_wrapper_samd21.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
* Variants may define an alternative SPI instace to use for WiFi101.
5050
* If not defined the following defaults are used:
5151
* WINC1501_SPI - SPI
52+
* WINC1501_CS_PIN - pin 10
5253
*/
5354
#if !defined(WINC1501_SPI)
5455
#define WINC1501_SPI SPI
@@ -57,6 +58,10 @@
5758
// make CS pin configurable by 'extern'ing it
5859
extern uint8_t CONF_WINC_CS_PIN;
5960

61+
#if !defined(WINC1501_SPI_CS_PIN)
62+
#define WINC1501_SPI_CS_PIN CONF_WINC_CS_PIN
63+
#endif
64+
6065
extern "C" {
6166

6267
#include "bsp/include/nm_bsp.h"
@@ -96,7 +101,7 @@ static sint8 spi_rw(uint8* pu8Mosi, uint8* pu8Miso, uint16 u16Sz)
96101
}
97102

98103
WINC1501_SPI.beginTransaction(wifi_SPISettings);
99-
digitalWrite(CONF_WINC_CS_PIN, LOW);
104+
digitalWrite(WINC1501_SPI_CS_PIN, LOW);
100105

101106
while (u16Sz) {
102107
*pu8Miso = WINC1501_SPI.transfer(*pu8Mosi);
@@ -108,7 +113,7 @@ static sint8 spi_rw(uint8* pu8Mosi, uint8* pu8Miso, uint16 u16Sz)
108113
pu8Mosi++;
109114
}
110115

111-
digitalWrite(CONF_WINC_CS_PIN, HIGH);
116+
digitalWrite(WINC1501_SPI_CS_PIN, HIGH);
112117
WINC1501_SPI.endTransaction();
113118

114119
return M2M_SUCCESS;
@@ -132,8 +137,8 @@ sint8 nm_bus_init(void * /* pvInitValue */)
132137
WINC1501_SPI.begin();
133138

134139
/* Configure CS PIN. */
135-
pinMode(CONF_WINC_CS_PIN, OUTPUT);
136-
digitalWrite(CONF_WINC_CS_PIN, HIGH);
140+
pinMode(WINC1501_SPI_CS_PIN, OUTPUT);
141+
digitalWrite(WINC1501_SPI_CS_PIN, HIGH);
137142

138143
/* Reset WINC1500. */
139144
nm_bsp_reset();

0 commit comments

Comments
 (0)