Skip to content

Commit 057b9a1

Browse files
facchinmeriknyquist
authored andcommitted
Make onboard flash port and cs pin explicit
1 parent 1c643fb commit 057b9a1

File tree

6 files changed

+11
-15
lines changed

6 files changed

+11
-15
lines changed

libraries/CurieSerialFlash/examples/CopyFromSerial/CopyFromSerial.ino

+1-3
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,12 @@
8181
#define BYTE_ESCAPE 0x7d
8282
#define BYTE_SEPARATOR 0x7c
8383

84-
#define CSPIN 21
85-
8684
void setup(){
8785
Serial.begin(9600); //Teensy serial is always at full USB speed and buffered... the baud rate here is required but ignored
8886

8987
pinMode(13, OUTPUT);
9088

91-
SerialFlash.begin(SPI1, CSPIN);
89+
SerialFlash.begin(ONBOARD_FLASH_SPI_PORT, ONBOARD_FLASH_CS_PIN);
9290

9391
//We start by formatting the flash...
9492
uint8_t id[5];

libraries/CurieSerialFlash/examples/EraseEverything/EraseEverything.ino

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include <CurieSerialFlash.h>
44
#include <SPI.h>
55

6-
const int FlashChipSelect = 21; // digital pin for flash chip CS pin
7-
86
SerialFlashFile file;
97

108
const unsigned long testIncrement = 4096;
@@ -26,7 +24,7 @@ void setup() {
2624
while (!Serial && (millis() - startMillis < 10000)) ;
2725
delay(100);
2826

29-
SerialFlash.begin(SPI1, FlashChipSelect);
27+
SerialFlash.begin(ONBOARD_FLASH_SPI_PORT, ONBOARD_FLASH_CS_PIN);
3028
unsigned char id[5];
3129
SerialFlash.readID(id);
3230
unsigned long size = SerialFlash.capacity(id);

libraries/CurieSerialFlash/examples/FileWrite/FileWrite.ino

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
const char *filename = "myfile.txt";
99
const char *contents = "0123456789ABCDEF";
1010

11-
const int FlashChipSelect = 21; // digital pin for flash chip CS pin
12-
1311
void setup() {
1412
Serial.begin(9600);
1513

@@ -18,7 +16,7 @@ void setup() {
1816
delay(100);
1917

2018
// Init. SPI Flash chip
21-
if (!SerialFlash.begin(SPI1, FlashChipSelect)) {
19+
if (!SerialFlash.begin(ONBOARD_FLASH_SPI_PORT, ONBOARD_FLASH_CS_PIN)) {
2220
Serial.println("Unable to access SPI Flash chip");
2321
}
2422

libraries/CurieSerialFlash/examples/ListFiles/ListFiles.ino

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include <CurieSerialFlash.h>
44
#include <SPI.h>
55

6-
const int FlashChipSelect = 21; // digital pin for flash chip CS pin
7-
86
void setup() {
97
//uncomment these if using Teensy audio shield
108
//SPI.setSCK(14); // Audio shield has SCK on pin 14
@@ -22,7 +20,7 @@ void setup() {
2220
delay(100);
2321
Serial.println("All Files on SPI Flash chip:");
2422

25-
if (!SerialFlash.begin(SPI1, FlashChipSelect)) {
23+
if (!SerialFlash.begin(ONBOARD_FLASH_SPI_PORT, ONBOARD_FLASH_CS_PIN)) {
2624
error("Unable to access SPI Flash chip");
2725
}
2826

libraries/CurieSerialFlash/examples/RawHardwareTest/RawHardwareTest.ino

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include <CurieSerialFlash.h>
2626
#include <SPI.h>
2727

28-
const int FlashChipSelect = 21; // digital pin for flash chip CS pin
29-
3028
SerialFlashFile file;
3129

3230
const unsigned long testIncrement = 4096;
@@ -48,7 +46,7 @@ void setup() {
4846
delay(100);
4947

5048
Serial.println("Raw SerialFlash Hardware Test");
51-
SerialFlash.begin(SPI1, FlashChipSelect);
49+
SerialFlash.begin(ONBOARD_FLASH_SPI_PORT, ONBOARD_FLASH_CS_PIN);
5250

5351
if (test()) {
5452
Serial.println();

variants/arduino_101/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ extern "C"{
113113
* ADC
114114
*/
115115

116+
/*
117+
* ONBOARD SPI FLASH
118+
*/
119+
#define ONBOARD_FLASH_SPI_PORT SPI1
120+
#define ONBOARD_FLASH_CS_PIN 21
121+
116122
/* EAI ADC device registers */
117123
#define ADC_SET (0x80015000)
118124
#define ADC_DIVSEQSTAT (0x80015001)

0 commit comments

Comments
 (0)