Switch SD2cadrLib to fastio

Replace all fastDigitalRead/Write() with READ/WRITE()

Define SCK_PIN, MISO_PIN, MOSI_PIN in pins.h if not already defined in the pins_*.h files.

Remove these conditional pin definitions from the pin-files. They are now always defined.

Define separate sets of SPI-pins for AT90USB with and without Teensy support in fastio.h.
Likely this was the main reason for all that confusion about the AT90USB-SPI pins.
This commit is contained in:
AnHardt
2016-07-27 12:40:44 +02:00
parent 9f1dd6d431
commit e4942d2163
18 changed files with 42 additions and 544 deletions

View File

@ -30,6 +30,7 @@
#if ENABLED(SDSUPPORT)
#include "Sd2Card.h"
//------------------------------------------------------------------------------
#if DISABLED(SOFTWARE_SPI)
// functions for hardware SPI
@ -99,10 +100,10 @@
// no interrupts during byte receive - about 8 us
cli();
// output pin high - like sending 0XFF
fastDigitalWrite(SPI_MOSI_PIN, HIGH);
WRITE(SPI_MOSI_PIN, HIGH);
for (uint8_t i = 0; i < 8; i++) {
fastDigitalWrite(SPI_SCK_PIN, HIGH);
WRITE(SPI_SCK_PIN, HIGH);
// adjust so SCK is nice
nop;
@ -110,9 +111,9 @@
data <<= 1;
if (fastDigitalRead(SPI_MISO_PIN)) data |= 1;
if (READ(SPI_MISO_PIN)) data |= 1;
fastDigitalWrite(SPI_SCK_PIN, LOW);
WRITE(SPI_SCK_PIN, LOW);
}
// enable interrupts
sei();
@ -130,13 +131,13 @@
// no interrupts during byte send - about 8 us
cli();
for (uint8_t i = 0; i < 8; i++) {
fastDigitalWrite(SPI_SCK_PIN, LOW);
WRITE(SPI_SCK_PIN, LOW);
fastDigitalWrite(SPI_MOSI_PIN, data & 0X80);
WRITE(SPI_MOSI_PIN, data & 0X80);
data <<= 1;
fastDigitalWrite(SPI_SCK_PIN, HIGH);
WRITE(SPI_SCK_PIN, HIGH);
}
// hold SCK high for a few ns
nop;
@ -144,7 +145,7 @@
nop;
nop;
fastDigitalWrite(SPI_SCK_PIN, LOW);
WRITE(SPI_SCK_PIN, LOW);
// enable interrupts
sei();
}