Skip to content

Commit 48c0c57

Browse files
committed
SD: fix SD library for ZPUino
1 parent 7ba153f commit 48c0c57

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

hardware/zpuino/zpu/libraries/SD/utility/Sd2Card.cpp

+5-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* along with the Arduino Sd2Card Library. If not, see
1818
* <http://www.gnu.org/licenses/>.
1919
*/
20-
#define USE_SPI_LIB
20+
2121
#include <Arduino.h>
2222
#include "Sd2Card.h"
2323
//------------------------------------------------------------------------------
@@ -267,26 +267,23 @@ int Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
267267
// set pin modes
268268
pinMode(chipSelectPin_, OUTPUT);
269269
chipSelectHigh();
270-
<<<<<<< HEAD
271-
272-
#ifdef AVR
273-
=======
274270
#ifndef USE_SPI_LIB
275-
>>>>>>> 1.5.1
276271
pinMode(SPI_MISO_PIN, INPUT);
277272
pinMode(SPI_MOSI_PIN, OUTPUT);
278273
pinMode(SPI_SCK_PIN, OUTPUT);
279274
#endif
280275

281276
#ifndef SOFTWARE_SPI
282277
#ifndef USE_SPI_LIB
278+
#ifndef ZPU
283279
// SS must be in output mode even it is not chip select
284280
pinMode(SS_PIN, OUTPUT);
285281
digitalWrite(SS_PIN, HIGH); // disable any SPI device using hardware SS pin
286282
// Enable SPI, Master, clock rate f_osc/128
287283
SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR1) | (1 << SPR0);
288284
// clear double speed
289285
SPSR &= ~(1 << SPI2X);
286+
#endif // defined ZPU
290287
#else // USE_SPI_LIB
291288
SPI.begin();
292289
#ifdef SPI_CLOCK_DIV128
@@ -553,7 +550,7 @@ int Sd2Card::readRegister(unsigned cmd, void* buf) {
553550
* false, is returned for an invalid value of \a sckRateID.
554551
*/
555552
uint8_t Sd2Card::setSckRate(uint8_t sckRateID) {
556-
#ifdef AVR
553+
#ifndef ZPU
557554
if (sckRateID > 6) {
558555
error(SD_CARD_ERROR_SCK_RATE);
559556
return false;
@@ -585,6 +582,7 @@ uint8_t Sd2Card::setSckRate(uint8_t sckRateID) {
585582
#endif // SPI_CLOCK_DIV128
586583
SPI.setClockDivider(v);
587584
#endif // USE_SPI_LIB
585+
#endif // defined ZPU
588586
return true;
589587
}
590588
//------------------------------------------------------------------------------

hardware/zpuino/zpu/libraries/SD/utility/Sd2Card.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ uint8_t const SPI_QUARTER_SPEED = 2;
3535
* USE_SPI_LIB: if set, use the SPI library bundled with Arduino IDE, otherwise
3636
* run with a standalone driver for AVR.
3737
*/
38+
#ifndef ZPU
3839
#define USE_SPI_LIB
40+
#endif // ZPU
3941
/**
4042
* Define MEGA_SOFT_SPI non-zero to use software SPI on Mega Arduinos.
4143
* Pins used are SS 10, MOSI 11, MISO 12, and SCK 13.
@@ -52,7 +54,7 @@ uint8_t const SPI_QUARTER_SPEED = 2;
5254

5355
#if defined(ZPU)
5456
#undef SOFTWARE_SPI
55-
#endif
57+
#endif // ZPU
5658

5759
//------------------------------------------------------------------------------
5860
// SPI pin definitions
@@ -93,6 +95,7 @@ uint8_t const SPI_MISO_PIN = 12;
9395
/** SPI Clock pin */
9496
uint8_t const SPI_SCK_PIN = 13;
9597
#endif // SOFTWARE_SPI
98+
#endif // AVR
9699
//------------------------------------------------------------------------------
97100
/** Protect block zero from write if nonzero */
98101
#define SD_PROTECT_BLOCK_ZERO 1

hardware/zpuino/zpu/libraries/SD/utility/Sd2PinMap.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,6 @@ static inline __attribute__((always_inline))
371371

372372
#endif // Sd2PinMap_h
373373

374-
#else
375-
#error Architecture or board not supported.
374+
//#else
375+
//#error Architecture or board not supported.
376376
#endif

0 commit comments

Comments
 (0)