Add arduino-esp32 3.x compatibility.
This commit is contained in:
@ -656,9 +656,6 @@ e: check-esp32-platform
|
||||
out: INPUT
|
||||
out: HIGH
|
||||
out: LOW
|
||||
out: tone
|
||||
out: freq
|
||||
out: duty
|
||||
out: adc
|
||||
out: pin
|
||||
out: default-key?
|
||||
|
||||
@ -99,7 +99,8 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
|
||||
REQUIRED_ARDUINO_GPIO_SUPPORT \
|
||||
REQUIRED_SYSTEM_SUPPORT \
|
||||
REQUIRED_FILES_SUPPORT \
|
||||
OPTIONAL_LEDC_SUPPORT \
|
||||
OPTIONAL_LEDC_V2_SUPPORT \
|
||||
OPTIONAL_LEDC_V3_SUPPORT \
|
||||
OPTIONAL_DAC_SUPPORT \
|
||||
OPTIONAL_SPIFFS_SUPPORT \
|
||||
OPTIONAL_WIFI_SUPPORT \
|
||||
@ -231,10 +232,10 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
|
||||
YV(internals, READDIR, \
|
||||
struct dirent *ent = readdir((DIR *) n0); SET (ent ? ent->d_name: 0))
|
||||
|
||||
#ifndef ENABLE_LEDC_SUPPORT
|
||||
# define OPTIONAL_LEDC_SUPPORT
|
||||
#ifndef ENABLE_LEDC_V2_SUPPORT
|
||||
# define OPTIONAL_LEDC_V2_SUPPORT
|
||||
#else
|
||||
# define OPTIONAL_LEDC_SUPPORT \
|
||||
# define OPTIONAL_LEDC_V2_SUPPORT \
|
||||
YV(ledc, ledcSetup, \
|
||||
n0 = (cell_t) (1000000 * ledcSetup(n2, n1 / 1000.0, n0)); NIPn(2)) \
|
||||
YV(ledc, ledcAttachPin, ledcAttachPin(n1, n0); DROPn(2)) \
|
||||
@ -248,6 +249,21 @@ static cell_t ResizeFile(cell_t fd, cell_t size);
|
||||
tos = (cell_t) (1000000 * ledcWriteNote(n2, (note_t) n1, n0)); NIPn(2))
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_LEDC_V3_SUPPORT
|
||||
# define OPTIONAL_LEDC_V3_SUPPORT
|
||||
#else
|
||||
# define OPTIONAL_LEDC_V3_SUPPORT \
|
||||
YV(ledc, ledcAttach, n0 = ledcAttach(n2, n1, n0); NIPn(2)) \
|
||||
YV(ledc, ledcAttachChannel, n0 = ledcAttachChannel(n3, n2, n1, n0); NIPn(3)) \
|
||||
YV(ledc, ledcDetach, n0 = ledcDetach(n0)) \
|
||||
YV(ledc, ledcRead, n0 = ledcRead(n0)) \
|
||||
YV(ledc, ledcReadFreq, n0 = ledcReadFreq(n0)) \
|
||||
YV(ledc, ledcWrite, ledcWrite(n1, n0); DROPn(2)) \
|
||||
YV(ledc, ledcWriteTone, n0 = ledcWriteTone(n1, n0); NIP) \
|
||||
YV(ledc, ledcWriteNote, n0 = ledcWriteNote(n2, (note_t) n1, n0); NIPn(2)) \
|
||||
YV(ledc, ledcChangeFrequency, n0 = ledcChangeFrequency(n2, n1, n0); NIPn(2))
|
||||
#endif
|
||||
|
||||
#ifndef ENABLE_DAC_SUPPORT
|
||||
# define OPTIONAL_DAC_SUPPORT
|
||||
# else
|
||||
|
||||
@ -22,10 +22,16 @@
|
||||
#define ENABLE_I2C_SUPPORT
|
||||
#define ENABLE_SOCKETS_SUPPORT
|
||||
#define ENABLE_FREERTOS_SUPPORT
|
||||
#define ENABLE_LEDC_SUPPORT
|
||||
#define ENABLE_SD_SUPPORT
|
||||
#define ENABLE_ESP32_FORTH_FAULT_HANDLING
|
||||
|
||||
// LEDC changed interface in v3.x+
|
||||
#if ESP_ARDUINO_VERSION_MAJOR >= 3
|
||||
# define ENABLE_LEDC_V3_SUPPORT
|
||||
#else
|
||||
# define ENABLE_LEDC_V2_SUPPORT
|
||||
#endif
|
||||
|
||||
// SD_MMC does not work on ESP32-S2 / ESP32-C3
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||
# define ENABLE_SD_MMC_SUPPORT
|
||||
|
||||
@ -40,9 +40,6 @@ also ledc also serial also SPIFFS
|
||||
( Map Arduino / ESP32 things to shorter names. )
|
||||
: pin ( n pin# -- ) swap digitalWrite ;
|
||||
: adc ( n -- n ) analogRead ;
|
||||
: duty ( n n -- ) 255 min 8191 255 */ ledcWrite ;
|
||||
: freq ( n n -- ) 1000 * 13 ledcSetup drop ;
|
||||
: tone ( n n -- ) 1000 * ledcWriteTone drop ;
|
||||
|
||||
( Basic Ardiuno Constants )
|
||||
0 constant LOW
|
||||
|
||||
@ -407,6 +407,20 @@ dacWrite ( pin 0-255 -- ) Write to DAC (pin 25, 26)
|
||||
<h5>ledc</h5>
|
||||
These words are inside the <code>ledc</code> vocabulary.
|
||||
<pre>
|
||||
<i>(arduino-esp32 3.x+)</i>
|
||||
ledcAttach ( pin freq resolution -- f )
|
||||
ledcAttachChannel ( pin freq resolution channel -- f )
|
||||
ledcDetach ( pin -- f )
|
||||
ledcRead ( channel -- n )
|
||||
ledcReadFreq ( channel -- freq )
|
||||
ledcWrite ( channel duty -- )
|
||||
ledcWriteTone ( channel freq -- freq )
|
||||
ledcWriteNote ( channel note octave -- freq )
|
||||
ledcChangeFrequency ( pin freq resolution -- freq )
|
||||
</pre>
|
||||
If built with arduino-esp32 2.x, this is the interface:
|
||||
<pre>
|
||||
<i>(arduino-esp32 2.x+)</i>
|
||||
ledcSetup ( channel freq resolution -- freq )
|
||||
ledcAttachPin ( pin channel -- )
|
||||
ledcDetachPin ( pin -- )
|
||||
|
||||
Reference in New Issue
Block a user