Replace external SPIRAM lib w/internal optimized (#250)

* Replace external SPIRAM lib w/internal optimized

Instead of requiring everyone to download and install another Arduino
library to use this lib, include an optimized, self-contained one from
the 8266 VM PR: https://github.com/esp8266/Arduino/pull/6994

Does change the API as it now requires a HW chip select, so that
parameter is removed from the SpiRAM buffer object.

* Redo the FIFO to try and be faster

* Fix the SPI interface, buffering.

SPI FIFO needs special care so do all work in a RAM copy and the copy it
over manually w/32b writes.

Ensure the SPI command is done before touching the FIFO.

Fix buffering organization.

Make the buffer report status as a #### bar.

* Fix infinite wait on EOF

* Add SW chip select support

* Update URL to one that's live today

* Clean up metadata printout

* Clean up readme refs to obsolete lib

* Slow down the DIO->SIO reset sequence

* Update readme to remove old SPIRam library ref

Also add the resistor to the 1T circuit to avoid transistor overheating.
This commit is contained in:
Earle F. Philhower, III authored and GitHub committed 2020-04-14 15:41:47 -07:00
1 parent be0ee8283f
commit 0fd2d0413b
5 files changed
+372 -132

No files matched your search

+16 -10
View File
@@ -24,14 +24,18 @@
#include "AudioFileSource.h"
#include <SPI.h>
#include <ESP8266Spiram.h> // https://github.com/Gianbacchio/ESP8266_Spiram
#include "spiram-fast.h"
//#define FAKERAM
// #define SPIBUF_DEBUG
class AudioFileSourceSPIRAMBuffer : public AudioFileSource
{
public:
AudioFileSourceSPIRAMBuffer(AudioFileSource *in, uint8_t csPin, uint32_t bufferBytes);
#ifdef FAKERAM
AudioFileSourceSPIRAMBuffer(AudioFileSource *in, uint8_t csPin = 15, uint32_t bufferBytes = 2048);
#else
AudioFileSourceSPIRAMBuffer(AudioFileSource *in, uint8_t csPin = 15, uint32_t bufferBytes = 128*1024);
#endif
virtual ~AudioFileSourceSPIRAMBuffer() override;
virtual uint32_t read(void *data, uint32_t len) override;
@@ -47,13 +51,15 @@ class AudioFileSourceSPIRAMBuffer : public AudioFileSource
private:
AudioFileSource *src;
ESP8266Spiram *Spiram;
uint32_t ramSize;
uint32_t writePtr;
uint32_t readPtr;
uint16_t length;
uint32_t bytesAvailable;
bool filled;
ESP8266SPIRAM ram;
size_t ramSize;
size_t writePtr;
size_t readPtr;
bool filled;
#ifdef FAKERAM
char fakeRAM[2048];
#endif
};