SdFat: only try to use DMA if it is implemented
This commit is contained in:
parent
21a856702b
commit
7b13128353
|
@ -4,6 +4,10 @@
|
|||
#include <Arduino.h>
|
||||
#include "stm32_gpio_af.h"
|
||||
|
||||
#if defined(STM32F1) || defined(STM32F4)
|
||||
#define SPI_HAS_OLD_DMATRANSFER
|
||||
#endif
|
||||
|
||||
// SPI_HAS_TRANSACTION means SPI has
|
||||
// - beginTransaction()
|
||||
// - endTransaction()
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
*/
|
||||
#if defined(ARDUINO_ARCH_STM32)
|
||||
#include "SdSpiDriver.h"
|
||||
#define USE_STM32F1_DMAC 1
|
||||
//------------------------------------------------------------------------------
|
||||
static SPIClass& pSpi = SPI;
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -66,7 +65,7 @@ uint8_t SdSpiAltDriver::receive() {
|
|||
*/
|
||||
uint8_t SdSpiAltDriver::receive(uint8_t* buf, size_t n) {
|
||||
int rtn = 0;
|
||||
#if USE_STM32F1_DMAC
|
||||
#ifdef SPI_HAS_OLD_DMATRANSFER
|
||||
rtn = pSpi.dmaTransfer(0, buf, n);
|
||||
#else // USE_STM32F1_DMAC
|
||||
// pSpi.read(buf, n); fails ?? use byte transfer
|
||||
|
@ -91,7 +90,7 @@ void SdSpiAltDriver::send(uint8_t b) {
|
|||
* \param[in] n Number of bytes to send.
|
||||
*/
|
||||
void SdSpiAltDriver::send(const uint8_t* buf , size_t n) {
|
||||
#if USE_STM32F1_DMAC
|
||||
#ifdef SPI_HAS_OLD_DMATRANSFER
|
||||
pSpi.dmaSend(const_cast<uint8_t*>(buf), n);
|
||||
#else // #if USE_STM32F1_DMAC
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
|
|
Loading…
Reference in New Issue