Parcourir la source

Support Teensy-LC

main
Bill Greiman il y a 9 ans
Parent
révision
86ead52563
5 fichiers modifiés avec 85 ajouts et 9 suppressions
  1. +1
    -1
      SdFat/SdFatConfig.h
  2. +80
    -2
      SdFat/SdSpiTeensy3.cpp
  3. +3
    -3
      SdFat/examples/AnalogBinLogger/AnalogBinLogger.h
  4. +1
    -1
      SdFat/utility/FatFile.cpp
  5. +0
    -2
      SdFat/utility/StdioStream.cpp

+ 1
- 1
SdFat/SdFatConfig.h Voir le fichier

@@ -66,7 +66,7 @@
* is define and SdFat uses a fast custom SPI implementation.
*
* If SD_SPI_CONFIGURATION is define to be one, only the SdFat class is
* define and SdFat uses the standard Arduino SD.h library.
* define and SdFat uses the standard Arduino SPI.h library.
*
* If SD_SPI_CONFIGURATION is define to be two, only the SdFat class is
* define and SdFat uses software SPI on the pins defined below.

+ 80
- 2
SdFat/SdSpiTeensy3.cpp Voir le fichier

@@ -19,8 +19,9 @@
*/
#include "SdSpi.h"
#if defined(__arm__) && defined(CORE_TEENSY)
// Teensy 3.0 functions
#include "mk20dx128.h"
// SPI definitions
#include "kinetis.h"
#ifdef KINETISK
// use 16-bit frame if SPI_USE_8BIT_FRAME is zero
#define SPI_USE_8BIT_FRAME 0
// Limit initial fifo to three entries to avoid fifo overrun
@@ -220,4 +221,81 @@ void SdSpi::send(const uint8_t* buf , size_t n) {
}
#endif // SPI_USE_8BIT_FRAME
}
#else // KINETISK
//==============================================================================
// Use standard SPI library if not KINETISK
#include "SPI.h"
/**
* Initialize SPI pins.
*/
void SdSpi::begin() {
SPI.begin();
}
/** Set SPI options for access to SD/SDHC cards.
*
* \param[in] divisor SCK clock divider relative to the system clock.
*/
void SdSpi::init(uint8_t divisor) {
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE0);
#ifndef SPI_CLOCK_DIV128
SPI.setClockDivider(divisor);
#else // SPI_CLOCK_DIV128
int v;
if (divisor <= 2) {
v = SPI_CLOCK_DIV2;
} else if (divisor <= 4) {
v = SPI_CLOCK_DIV4;
} else if (divisor <= 8) {
v = SPI_CLOCK_DIV8;
} else if (divisor <= 16) {
v = SPI_CLOCK_DIV16;
} else if (divisor <= 32) {
v = SPI_CLOCK_DIV32;
} else if (divisor <= 64) {
v = SPI_CLOCK_DIV64;
} else {
v = SPI_CLOCK_DIV128;
}
SPI.setClockDivider(v);
#endif // SPI_CLOCK_DIV128
}
/** Receive a byte.
*
* \return The byte.
*/
uint8_t SdSpi::receive() {
return SPI.transfer(0XFF);
}
/** Receive multiple bytes.
*
* \param[out] buf Buffer to receive the data.
* \param[in] n Number of bytes to receive.
*
* \return Zero for no error or nonzero error code.
*/
uint8_t SdSpi::receive(uint8_t* buf, size_t n) {
for (size_t i = 0; i < n; i++) {
buf[i] = SPI.transfer(0XFF);
}
return 0;
}
/** Send a byte.
*
* \param[in] b Byte to send
*/
void SdSpi::send(uint8_t b) {
SPI.transfer(b);
}
/** Send multiple bytes.
*
* \param[in] buf Buffer for data to be sent.
* \param[in] n Number of bytes to send.
*/
void SdSpi::send(const uint8_t* buf , size_t n) {
for (size_t i = 0; i < n; i++) {
SPI.transfer(buf[i]);
}
}
#endif // KINETISK
#endif // defined(__arm__) && defined(CORE_TEENSY)

+ 3
- 3
SdFat/examples/AnalogBinLogger/AnalogBinLogger.h Voir le fichier

@@ -14,7 +14,7 @@ struct metadata_t {
// Data block for 8-bit ADC mode.
const size_t DATA_DIM8 = 508;
struct block8_t {
unsigned short count; // count of data bytes
unsigned short count; // count of data values
unsigned short overrun; // count of overruns since last block
unsigned char data[DATA_DIM8];
};
@@ -22,14 +22,14 @@ struct block8_t {
// Data block for 10-bit ADC mode.
const size_t DATA_DIM16 = 254;
struct block16_t {
unsigned short count; // count of data bytes
unsigned short count; // count of data values
unsigned short overrun; // count of overruns since last block
unsigned short data[DATA_DIM16];
};
//------------------------------------------------------------------------------
// Data block for PC use
struct adcdata_t {
unsigned short count; // count of data bytes
unsigned short count; // count of data values
unsigned short overrun; // count of overruns since last block
union {
unsigned char u8[DATA_DIM8];

+ 1
- 1
SdFat/utility/FatFile.cpp Voir le fichier

@@ -695,7 +695,7 @@ int FatFile::peek() {
//------------------------------------------------------------------------------
int FatFile::read(void* buf, size_t nbyte) {
int8_t fg;
uint8_t blockOfCluster;
uint8_t blockOfCluster = 0;
uint8_t* dst = reinterpret_cast<uint8_t*>(buf);
uint16_t offset;
size_t toRead;

+ 0
- 2
SdFat/utility/StdioStream.cpp Voir le fichier

@@ -376,13 +376,11 @@ int StdioStream::printDec(float value, uint8_t prec) {
}
//------------------------------------------------------------------------------
int StdioStream::printDec(signed char n) {
uint8_t s = 0;
if (n < 0) {
if (fputc('-') < 0) {
return -1;
}
n = -n;
s = 1;
}
return printDec((unsigned char)n);
}

Chargement…
Annuler
Enregistrer