Added support for SD, tweaked SD_MMC.

This commit is contained in:
Brad Nelson
2021-12-27 00:19:13 -08:00
parent 67765788c1
commit 3d026f4f31
4 changed files with 62 additions and 9 deletions

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
VERSION=7.0.6.7
VERSION=7.0.6.8
STABLE_VERSION=7.0.5.4
REVISION=$(shell git rev-parse HEAD)
REVSHORT=$(shell echo $(REVISION) | head -c 7)

View File

@ -56,10 +56,22 @@ transfer{
forth definitions
DEFINED? SD.begin [IF]
vocabulary SD SD definitions
transfer{
SD.begin SD.end
SD.beginFull SD.beginDefaults
SD.totalBytes SD.usedBytes
SD.cardType
}transfer
forth definitions
[THEN]
DEFINED? SD_MMC.begin [IF]
vocabulary SD_MMC SD_MMC definitions
transfer{
SD_MMC.begin SD_MMC.end
SD_MMC.beginFull SD_MMC.beginDefaults
SD_MMC.totalBytes SD_MMC.usedBytes
SD_MMC.cardType
}transfer

View File

@ -32,10 +32,11 @@
#define ENABLE_SOCKETS_SUPPORT
#define ENABLE_FREERTOS_SUPPORT
#define ENABLE_INTERRUPTS_SUPPORT
#define ENABLE_SD_SUPPORT
// SD_MMC does not work on ESP32-S2 / ESP32-C3
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
# define ENABLE_SDCARD_SUPPORT
# define ENABLE_SD_MMC_SUPPORT
#endif
// ESP32-C3 has no DACs.
@ -170,7 +171,8 @@
OPTIONAL_WIFI_SUPPORT \
OPTIONAL_MDNS_SUPPORT \
OPTIONAL_WEBSERVER_SUPPORT \
OPTIONAL_SDCARD_SUPPORT \
OPTIONAL_SD_SUPPORT \
OPTIONAL_SD_MMC_SUPPORT \
OPTIONAL_I2C_SUPPORT \
OPTIONAL_SERIAL_BLUETOOTH_SUPPORT \
OPTIONAL_CAMERA_SUPPORT \
@ -344,12 +346,31 @@
Y(errno, PUSH errno)
#endif
#ifndef ENABLE_SDCARD_SUPPORT
# define OPTIONAL_SDCARD_SUPPORT
#ifndef ENABLE_SD_SUPPORT
# define OPTIONAL_SD_SUPPORT
#else
# include "SD.h"
# define OPTIONAL_SD_SUPPORT \
X("SD.begin", SD_BEGIN, PUSH SD.begin()) \
X("SD.beginFull", SD_BEGIN_FULL, \
tos = SD.begin(n5, *(SPIClass*)a4, n3, c2, n1, n0); NIPn(5)) \
X("SD.beginDefaults", SD_BEGIN_DEFAULTS, \
PUSH SS; PUSH &SPI; PUSH 4000000; PUSH "/sd"; PUSH 5; PUSH false) \
X("SD.end", SD_END, SD.end()) \
X("SD.cardType", SD_CARD_TYPE, PUSH SD.cardType()) \
X("SD.totalBytes", SD_TOTAL_BYTES, PUSH SD.totalBytes()) \
X("SD.usedBytes", SD_USED_BYTES, PUSH SD.usedBytes())
#endif
#ifndef ENABLE_SD_MMC_SUPPORT
# define OPTIONAL_SD_MMC_SUPPORT
#else
# include "SD_MMC.h"
# define OPTIONAL_SDCARD_SUPPORT \
X("SD_MMC.begin", SD_MMC_BEGIN, tos = SD_MMC.begin(c1, n0); NIP) \
# define OPTIONAL_SD_MMC_SUPPORT \
X("SD_MMC.begin", SD_MMC_BEGIN, PUSH SD_MMC.begin()) \
X("SD_MMC.beginFull", SD_MMC_BEGIN_FULL, tos = SD_MMC.begin(c2, n1, n0); NIPn(2)) \
X("SD_MMC.beginDefaults", SD_MMC_BEGIN_DEFAULTS, \
PUSH "/sdcard"; PUSH false; PUSH false) \
X("SD_MMC.end", SD_MMC_END, SD_MMC.end()) \
X("SD_MMC.cardType", SD_MMC_CARD_TYPE, PUSH SD_MMC.cardType()) \
X("SD_MMC.totalBytes", SD_MMC_TOTAL_BYTES, PUSH SD_MMC.totalBytes()) \

View File

@ -535,11 +535,31 @@ server ( port -- ) Start an image server at port,
e.g. http://IP/image will produce an image
</pre>
<h5>SD</h5>
These words are inside the <code>SD</code> vocabulary.
They allow use of an SDcard over SPI.
<pre>
SD.begin ( -- ok ) uses all the defaults "/sd" etc.
SD.beginDefaults ( -- sspin SPIClass frequency mountpointsz maxfiles format_if_empty )
( SS SPI 4000000 "/sd" 5 false )
SD.beginFull ( sspin SPIClass frequency mountpoint maxfiles format_if_empty -- ok )
SD.end ( -- )
SD.cardType ( -- n )
SD.totalBytes ( -- n )
SD.usedBytes ( -- n )
</pre>
<h5>SD_MMC</h5>
These words are inside the <code>SD_MMC</code> vocabulary.<br/>
These words are inside the <code>SD_MMC</code> vocabulary.
They allow use of an SDcard over MMC internal interface.
<br/>
Note, SD_MMC is unavailable on ESP32-S2 and ESP32-C3.
<pre>
SD_MMC.begin ( mount mode1bit ) default mode1bit=false
SD_MMC.begin ( -- ok ) uses all the defaults "/sdcard" etc.
SD_MMC.beginDefaults ( -- mountsz mode1bit format_if_fail )
( "/sdcard" false false )
( sdmmc_freq not supported for generality )
SD_MMC.beginFull ( mountsz mode1bit format_if_fail -- ok )
SD_MMC.end ( -- )
SD_MMC.cardType ( -- n )
SD_MMC.totalBytes ( -- n )