forked from espressif/arduino-esp32
Esp32 s3 support (#6341)
Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com> Co-authored-by: Tomáš Pilný <34927466+PilnyTomas@users.noreply.github.com> Co-authored-by: Pedro Minatel <pedro.minatel@espressif.com> Co-authored-by: Ivan Grokhotkov <ivan@espressif.com> Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net>
This commit is contained in:
@ -12,7 +12,10 @@ class MyProcessor {
|
||||
|
||||
public:
|
||||
MyProcessor(uint8_t pin, float nanoTicks) {
|
||||
assert((rmt_recv = rmtInit(21, RMT_RX_MODE, RMT_MEM_192)));
|
||||
if ((rmt_recv = rmtInit(pin, RMT_RX_MODE, RMT_MEM_192)) == NULL)
|
||||
{
|
||||
Serial.println("init receiver failed\n");
|
||||
}
|
||||
|
||||
realNanoTick = rmtSetTick(rmt_recv, nanoTicks);
|
||||
};
|
||||
@ -59,6 +62,6 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.printf("GPIO 4: %08x 5: %08x 6: %08x\n", mp1.val(), mp2.val(), mp3.val());
|
||||
Serial.printf("GPIO 4: %08x 5: %08x 10: %08x\n", mp1.val(), mp2.val(), mp3.val());
|
||||
delay(500);
|
||||
}
|
@ -5,6 +5,17 @@
|
||||
|
||||
#include "esp32-hal.h"
|
||||
|
||||
// The effect seen in ESP32C3, ESP32S2 and ESP32S3 is like a Blink of RGB LED
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#define BUILTIN_RGBLED_PIN 18
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#define BUILTIN_RGBLED_PIN 48
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define BUILTIN_RGBLED_PIN 8
|
||||
#else
|
||||
#define BUILTIN_RGBLED_PIN 21 // ESP32 has no builtin RGB LED
|
||||
#endif
|
||||
|
||||
#define NR_OF_LEDS 8*4
|
||||
#define NR_OF_ALL_BITS 24*NR_OF_LEDS
|
||||
|
||||
@ -41,7 +52,7 @@ void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
if ((rmt_send = rmtInit(18, RMT_TX_MODE, RMT_MEM_64)) == NULL)
|
||||
if ((rmt_send = rmtInit(BUILTIN_RGBLED_PIN, RMT_TX_MODE, RMT_MEM_64)) == NULL)
|
||||
{
|
||||
Serial.println("init sender failed\n");
|
||||
}
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "esp32s2/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#else
|
||||
#error Target CONFIG_IDF_TARGET is not supported
|
||||
#endif
|
||||
|
@ -245,6 +245,8 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
|
||||
#endif
|
||||
#if CONFIG_ETH_USE_ESP32_EMAC
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||
mac_config.clock_config.rmii.clock_mode = (eth_clock_mode) ? EMAC_CLK_OUT : EMAC_CLK_EXT_IN;
|
||||
mac_config.clock_config.rmii.clock_gpio = (1 == eth_clock_mode) ? EMAC_APPL_CLK_OUT_GPIO : (2 == eth_clock_mode) ? EMAC_CLK_OUT_GPIO : (3 == eth_clock_mode) ? EMAC_CLK_OUT_180_GPIO : EMAC_CLK_IN_GPIO;
|
||||
mac_config.smi_mdc_gpio_num = mdc;
|
||||
mac_config.smi_mdio_gpio_num = mdio;
|
||||
mac_config.sw_reset_timeout_ms = 1000;
|
||||
@ -305,7 +307,7 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
|
||||
|
||||
eth_handle = NULL;
|
||||
esp_eth_config_t eth_config = ETH_DEFAULT_CONFIG(eth_mac, eth_phy);
|
||||
eth_config.on_lowlevel_init_done = on_lowlevel_init_done;
|
||||
//eth_config.on_lowlevel_init_done = on_lowlevel_init_done;
|
||||
//eth_config.on_lowlevel_deinit_done = on_lowlevel_deinit_done;
|
||||
if(esp_eth_driver_install(ð_config, ð_handle) != ESP_OK || eth_handle == NULL){
|
||||
log_e("esp_eth_driver_install failed");
|
||||
@ -386,7 +388,7 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
tcpip_adapter_ip_info_t info;
|
||||
|
||||
|
||||
if(local_ip != (uint32_t)0x00000000 && local_ip != INADDR_NONE){
|
||||
info.ip.addr = static_cast<uint32_t>(local_ip);
|
||||
info.gw.addr = static_cast<uint32_t>(gateway);
|
||||
|
@ -260,7 +260,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
|
||||
|
||||
_protocol = url.substring(0, index);
|
||||
if (_protocol != expectedProtocol) {
|
||||
log_w("unexpected protocol: %s, expected %s", _protocol.c_str(), expectedProtocol);
|
||||
log_d("unexpected protocol: %s, expected %s", _protocol.c_str(), expectedProtocol);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
0
libraries/I2S/examples/ADCPlotter/.skip.esp32c3
Normal file
0
libraries/I2S/examples/ADCPlotter/.skip.esp32c3
Normal file
86
libraries/I2S/examples/ADCPlotter/ADCPlotter.ino
Normal file
86
libraries/I2S/examples/ADCPlotter/ADCPlotter.ino
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
This example is only for ESP devices.
|
||||
|
||||
This example demonstrates usage of integrated Digital to Analog Converter (DAC)
|
||||
You can display sound wave from audio device, or just measure voltage.
|
||||
|
||||
To display audio prepare circuit found in following link or drafted as ASCII art
|
||||
https://forum.arduino.cc/index.php?topic=567581.0
|
||||
(!) Note that unlike in the link we are connecting the supply line to 3.3V (not 5V)
|
||||
because ADC can measure only up to around 3V. Anything above 3V will be very inaccurate.
|
||||
|
||||
^ +3.3V
|
||||
|
|
||||
_
|
||||
| |10k
|
||||
|_|
|
||||
| | |10uF
|
||||
GPIO34-------------*------------| |----------- line in
|
||||
(Default ADC pin) | +| |
|
||||
|
|
||||
_
|
||||
| |10k
|
||||
|_|
|
||||
|
|
||||
|
|
||||
V GND
|
||||
|
||||
Connect hot wire of your audio to Line in and GNd wire of audio cable to common ground (GND)
|
||||
|
||||
Second option to measure voltage on trimmer / potentiometer has following connection
|
||||
^ +3.3V
|
||||
|
|
||||
_
|
||||
| |
|
||||
GPIO34----------->| |
|
||||
(Default ADC pin) |_|
|
||||
|
|
||||
|
|
||||
_
|
||||
| | optional resistor
|
||||
|_|
|
||||
|
|
||||
|
|
||||
V GND
|
||||
Optional resistor will decrease read value.
|
||||
|
||||
Steps to run:
|
||||
1. Select target board:
|
||||
Tools -> Board -> ESP32 Arduino -> your board
|
||||
2. Upload sketch
|
||||
Press upload button (arrow in top left corner)
|
||||
When you see in console line like this: "Connecting........_____.....__"
|
||||
On your board press and hold Boot button and press EN button shortly. Now you can release both buttons.
|
||||
You should see lines like this: "Writing at 0x00010000... (12 %)" with rising percentage on each line.
|
||||
If this fails, try the board buttons right after pressing upload button, or reconnect the USB cable.
|
||||
3. Open plotter
|
||||
Tools -> Serial Plotter
|
||||
Enjoy
|
||||
|
||||
Created by Tomas Pilny
|
||||
on 17th June 2021
|
||||
*/
|
||||
|
||||
#include <I2S.h>
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
// A baud rate of 115200 is used instead of 9600 for a faster data rate
|
||||
// on non-native USB ports
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
// start I2S at 8 kHz with 32-bits per sample
|
||||
if (!I2S.begin(ADC_DAC_MODE, 8000, 16)) {
|
||||
Serial.println("Failed to initialize I2S!");
|
||||
while (1); // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// read a sample
|
||||
int sample = I2S.read();
|
||||
Serial.println(sample);
|
||||
}
|
0
libraries/I2S/examples/FullDuplex/.skip.esp32c3
Normal file
0
libraries/I2S/examples/FullDuplex/.skip.esp32c3
Normal file
59
libraries/I2S/examples/FullDuplex/FullDuplex.ino
Normal file
59
libraries/I2S/examples/FullDuplex/FullDuplex.ino
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
This example is only for ESP
|
||||
This example demonstrates simultaneous usage of microphone and speaker using single I2S module.
|
||||
The application transfers data from input to output
|
||||
|
||||
Circuit:
|
||||
* ESP32
|
||||
* GND connected GND
|
||||
* VIN connected 5V
|
||||
* SCK 5
|
||||
* FS 25
|
||||
* DIN 35
|
||||
* DOUT 26
|
||||
* I2S microphone
|
||||
* I2S decoder + headphones / speaker
|
||||
|
||||
created 8 October 2021
|
||||
by Tomas Pilny
|
||||
*/
|
||||
|
||||
#include <I2S.h>
|
||||
const long sampleRate = 16000;
|
||||
const int bitsPerSample = 32;
|
||||
uint8_t *buffer;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
//I2S.setAllPins(5, 25, 35, 26); // you can change default pins; order of pins = (CLK, WS, IN, OUT)
|
||||
if(!I2S.setDuplex()){
|
||||
Serial.println("ERROR - could not set duplex");
|
||||
while(true){
|
||||
vTaskDelay(10); // Cannot continue
|
||||
}
|
||||
}
|
||||
if (!I2S.begin(I2S_PHILIPS_MODE, sampleRate, bitsPerSample)) {
|
||||
Serial.println("Failed to initialize I2S!");
|
||||
while(true){
|
||||
vTaskDelay(10); // Cannot continue
|
||||
}
|
||||
}
|
||||
buffer = (uint8_t*) malloc(I2S.getBufferSize() * (bitsPerSample / 8));
|
||||
if(buffer == NULL){
|
||||
Serial.println("Failed to allocate buffer!");
|
||||
while(true){
|
||||
vTaskDelay(10); // Cannot continue
|
||||
}
|
||||
}
|
||||
Serial.println("Setup done");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
//I2S.write(I2S.read()); // primitive implementation sample-by-sample
|
||||
|
||||
// Buffer based implementation
|
||||
I2S.read(buffer, I2S.getBufferSize() * (bitsPerSample / 8));
|
||||
I2S.write(buffer, I2S.getBufferSize() * (bitsPerSample / 8));
|
||||
|
||||
//optimistic_yield(1000); // yield if last yield occurred before <parameter> CPU clock cycles ago
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
This example reads audio data from an Invensense's ICS43432 I2S microphone
|
||||
breakout board, and prints out the samples to the Serial console. The
|
||||
Serial Plotter built into the Arduino IDE can be used to plot the audio
|
||||
data (Tools -> Serial Plotter)
|
||||
|
||||
Circuit:
|
||||
* Arduino/Genuino Zero, MKR family and Nano 33 IoT
|
||||
* ICS43432:
|
||||
* GND connected GND
|
||||
* 3.3V connected to 3.3V (Zero, Nano, ESP32), VCC (MKR)
|
||||
* WS connected to pin 0 (Zero) or 3 (MKR), A2 (Nano) or 25 (ESP32)
|
||||
* CLK connected to pin 1 (Zero) or 2 (MKR), A3 (Nano) or 5 (ESP32)
|
||||
* SD connected to pin 9 (Zero) or A6 (MKR), 4 (Nano) or 26 (ESP32)
|
||||
created 17 November 2016
|
||||
by Sandeep Mistry
|
||||
*/
|
||||
|
||||
#include <I2S.h>
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
// A baud rate of 115200 is used instead of 9600 for a faster data rate
|
||||
// on non-native USB ports
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB port only
|
||||
}
|
||||
|
||||
// start I2S at 8 kHz with 32-bits per sample
|
||||
if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 32)) {
|
||||
Serial.println("Failed to initialize I2S!");
|
||||
while (1); // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// read a sample
|
||||
int sample = I2S.read();
|
||||
|
||||
if (sample && sample != -1 && sample != 1) {
|
||||
Serial.println(sample);
|
||||
}
|
||||
}
|
0
libraries/I2S/examples/SimpleTone/.skip.esp32c3
Normal file
0
libraries/I2S/examples/SimpleTone/.skip.esp32c3
Normal file
79
libraries/I2S/examples/SimpleTone/SimpleTone.ino
Normal file
79
libraries/I2S/examples/SimpleTone/SimpleTone.ino
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
This example generates a square wave based tone at a specified frequency
|
||||
and sample rate. Then outputs the data using the I2S interface to a
|
||||
MAX08357 I2S Amp Breakout board.
|
||||
|
||||
I2S Circuit:
|
||||
* Arduino/Genuino Zero, MKR family and Nano 33 IoT
|
||||
* MAX08357:
|
||||
* GND connected GND
|
||||
* VIN connected 5V
|
||||
* LRC connected to pin 0 (Zero) or 3 (MKR), A2 (Nano) or 25 (ESP32)
|
||||
* BCLK connected to pin 1 (Zero) or 2 (MKR), A3 (Nano) or 5 (ESP32)
|
||||
* DIN connected to pin 9 (Zero) or A6 (MKR), 4 (Nano) or 26 (ESP32)
|
||||
|
||||
DAC Circuit:
|
||||
* ESP32 or ESP32-S2
|
||||
* Audio amplifier
|
||||
- Note:
|
||||
- ESP32 has DAC on GPIO pins 25 and 26.
|
||||
- ESP32-S2 has DAC on GPIO pins 17 and 18.
|
||||
- Connect speaker(s) or headphones.
|
||||
|
||||
created 17 November 2016
|
||||
by Sandeep Mistry
|
||||
For ESP extended
|
||||
Tomas Pilny
|
||||
2nd September 2021
|
||||
*/
|
||||
|
||||
#include <I2S.h>
|
||||
const int frequency = 440; // frequency of square wave in Hz
|
||||
const int amplitude = 500; // amplitude of square wave
|
||||
const int sampleRate = 8000; // sample rate in Hz
|
||||
const int bps = 16;
|
||||
|
||||
const int halfWavelength = (sampleRate / frequency); // half wavelength of square wave
|
||||
|
||||
short sample = amplitude; // current sample value
|
||||
int count = 0;
|
||||
|
||||
i2s_mode_t mode = I2S_PHILIPS_MODE; // I2S decoder is needed
|
||||
// i2s_mode_t mode = ADC_DAC_MODE; // Audio amplifier is needed
|
||||
|
||||
// Mono channel input
|
||||
// This is ESP specific implementation -
|
||||
// samples will be automatically copied to both channels inside I2S driver
|
||||
// If you want to have true mono output use I2S_PHILIPS_MODE and interlay
|
||||
// second channel with 0-value samples.
|
||||
// The order of channels is RIGH followed by LEFT
|
||||
//i2s_mode_t mode = I2S_RIGHT_JUSTIFIED_MODE; // I2S decoder is needed
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("I2S simple tone");
|
||||
|
||||
// start I2S at the sample rate with 16-bits per sample
|
||||
if (!I2S.begin(mode, sampleRate, bps)) {
|
||||
Serial.println("Failed to initialize I2S!");
|
||||
while (1); // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (count % halfWavelength == 0 ) {
|
||||
// invert the sample every half wavelength count multiple to generate square wave
|
||||
sample = -1 * sample;
|
||||
}
|
||||
|
||||
if(mode == I2S_PHILIPS_MODE || mode == ADC_DAC_MODE){ // write the same sample twice, once for Right and once for Left channel
|
||||
I2S.write(sample); // Right channel
|
||||
I2S.write(sample); // Left channel
|
||||
}else if(mode == I2S_RIGHT_JUSTIFIED_MODE || mode == I2S_LEFT_JUSTIFIED_MODE){
|
||||
// write the same only once - it will be automatically copied to the other channel
|
||||
I2S.write(sample);
|
||||
}
|
||||
|
||||
// increment the counter for the next sample
|
||||
count++;
|
||||
}
|
61
libraries/I2S/keywords.txt
Normal file
61
libraries/I2S/keywords.txt
Normal file
@ -0,0 +1,61 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map I2S
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
I2S KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
I2SClass KEYWORD2
|
||||
begin KEYWORD2
|
||||
end KEYWORD2
|
||||
|
||||
onReceive KEYWORD2
|
||||
onTransmit KEYWORD2
|
||||
|
||||
setSckPin KEYWORD2
|
||||
setFsPin KEYWORD2
|
||||
setDataInPin KEYWORD2
|
||||
setDataOutPin KEYWORD2
|
||||
setAllPins KEYWORD2
|
||||
|
||||
getSckPin KEYWORD2
|
||||
getFsPin KEYWORD2
|
||||
getDataPin KEYWORD2
|
||||
getDataInPin KEYWORD2
|
||||
getDataOutPin KEYWORD2
|
||||
|
||||
setDuplex KEYWORD2
|
||||
setSimplex KEYWORD2
|
||||
isDuplex KEYWORD2
|
||||
|
||||
setBufferSize KEYWORD2
|
||||
getBufferSize KEYWORD2
|
||||
|
||||
write KEYWORD2
|
||||
availableForWrite KEYWORD2
|
||||
|
||||
read KEYWORD2
|
||||
available KEYWORD2
|
||||
|
||||
gpioToAdcUnit KEYWORD2
|
||||
gpioToAdcChannel KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
I2S_PHILIPS_MODE LITERAL1
|
||||
I2S_RIGHT_JUSTIFIED_MODE LITERAL1
|
||||
I2S_LEFT_JUSTIFIED_MODE LITERAL1
|
||||
I2S_ADC_DAC LITERAL1
|
||||
I2S_PDM LITERAL1
|
||||
|
||||
PIN_I2S_SCK LITERAL1
|
||||
PIN_I2S_FS LITERAL1
|
||||
PIN_I2S_SD LITERAL1
|
||||
PIN_I2S_SD_OUT LITERAL1
|
9
libraries/I2S/library.properties
Normal file
9
libraries/I2S/library.properties
Normal file
@ -0,0 +1,9 @@
|
||||
name=I2S
|
||||
version=1.0
|
||||
author=Tomas Pilny
|
||||
maintainer=Tomas Pilny <tomas.pilny@espressif.com>
|
||||
sentence=Enables the communication with devices that use the Inter-IC Sound (I2S) Bus. Specific implementation for ESP.
|
||||
paragraph=
|
||||
category=Communication
|
||||
url=http://www.arduino.cc/en/Reference/I2S
|
||||
architectures=esp32
|
1209
libraries/I2S/src/I2S.cpp
Normal file
1209
libraries/I2S/src/I2S.cpp
Normal file
File diff suppressed because it is too large
Load Diff
195
libraries/I2S/src/I2S.h
Normal file
195
libraries/I2S/src/I2S.h
Normal file
@ -0,0 +1,195 @@
|
||||
/*
|
||||
Copyright (c) 2016 Arduino LLC. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _I2S_H_INCLUDED
|
||||
#define _I2S_H_INCLUDED
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "freertos/ringbuf.h"
|
||||
|
||||
namespace esp_i2s {
|
||||
#include "driver/i2s.h" // ESP specific i2s driver
|
||||
}
|
||||
|
||||
// Default pins
|
||||
#ifndef PIN_I2S_SCK
|
||||
#define PIN_I2S_SCK 14
|
||||
#endif
|
||||
|
||||
#ifndef PIN_I2S_FS
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#define PIN_I2S_FS 27
|
||||
#else
|
||||
#define PIN_I2S_FS 25
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef PIN_I2S_SD
|
||||
#define PIN_I2S_SD 26
|
||||
#endif
|
||||
|
||||
#ifndef PIN_I2S_SD_OUT
|
||||
#define PIN_I2S_SD_OUT 26
|
||||
#endif
|
||||
|
||||
#ifndef PIN_I2S_SD_IN
|
||||
#define PIN_I2S_SD_IN 35 // Pin 35 is only input!
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
I2S_PHILIPS_MODE,
|
||||
I2S_RIGHT_JUSTIFIED_MODE,
|
||||
I2S_LEFT_JUSTIFIED_MODE,
|
||||
ADC_DAC_MODE,
|
||||
PDM_STEREO_MODE,
|
||||
PDM_MONO_MODE
|
||||
} i2s_mode_t;
|
||||
|
||||
class I2SClass : public Stream
|
||||
{
|
||||
public:
|
||||
// The device index and pins must map to the "COM" pads in Table 6-1 of the datasheet
|
||||
I2SClass(uint8_t deviceIndex, uint8_t clockGenerator, uint8_t sdPin, uint8_t sckPin, uint8_t fsPin);
|
||||
|
||||
// Init in MASTER mode: the SCK and FS pins are driven as outputs using the sample rate
|
||||
int begin(int mode, int sampleRate, int bitsPerSample);
|
||||
|
||||
// Init in SLAVE mode: the SCK and FS pins are inputs, other side controls sample rate
|
||||
int begin(int mode, int bitsPerSample);
|
||||
|
||||
// change pin setup and mode (default is Half Duplex)
|
||||
// Can be called only on initialized object (after begin)
|
||||
int setSckPin(int sckPin);
|
||||
int setFsPin(int fsPin);
|
||||
int setDataPin(int sdPin); // shared data pin for simplex
|
||||
int setDataOutPin(int outSdPin);
|
||||
int setDataInPin(int inSdPin);
|
||||
|
||||
int setAllPins();
|
||||
int setAllPins(int sckPin, int fsPin, int sdPin, int outSdPin, int inSdPin);
|
||||
|
||||
int getSckPin();
|
||||
int getFsPin();
|
||||
int getDataPin();
|
||||
int getDataOutPin();
|
||||
int getDataInPin();
|
||||
|
||||
int setDuplex();
|
||||
int setSimplex();
|
||||
int isDuplex();
|
||||
|
||||
void end();
|
||||
|
||||
// from Stream
|
||||
virtual int available();
|
||||
virtual int read();
|
||||
virtual int peek();
|
||||
virtual void flush();
|
||||
|
||||
// from Print
|
||||
virtual size_t write(uint8_t);
|
||||
virtual size_t write(const uint8_t *buffer, size_t size);
|
||||
|
||||
virtual int availableForWrite();
|
||||
|
||||
int read(void* buffer, size_t size);
|
||||
|
||||
//size_t write(int);
|
||||
size_t write(int32_t);
|
||||
size_t write(const void *buffer, size_t size);
|
||||
size_t write_blocking(const void *buffer, size_t size);
|
||||
size_t write_nonblocking(const void *buffer, size_t size);
|
||||
|
||||
void onTransmit(void(*)(void));
|
||||
void onReceive(void(*)(void));
|
||||
|
||||
int setBufferSize(int bufferSize);
|
||||
int getBufferSize();
|
||||
private:
|
||||
#if (SOC_I2S_SUPPORTS_ADC && SOC_I2S_SUPPORTS_DAC)
|
||||
int _gpioToAdcUnit(gpio_num_t gpio_num, esp_i2s::adc_unit_t* adc_unit);
|
||||
int _gpioToAdcChannel(gpio_num_t gpio_num, esp_i2s::adc_channel_t* adc_channel);
|
||||
#endif
|
||||
int begin(int mode, int sampleRate, int bitsPerSample, bool driveClock);
|
||||
|
||||
int _enableTransmitter();
|
||||
int _enableReceiver();
|
||||
void _onTransferComplete();
|
||||
|
||||
int _createCallbackTask();
|
||||
|
||||
static void onDmaTransferComplete(void*);
|
||||
int _installDriver();
|
||||
void _uninstallDriver();
|
||||
void _setSckPin(int sckPin);
|
||||
void _setFsPin(int fsPin);
|
||||
void _setDataPin(int sdPin);
|
||||
void _setDataOutPin(int outSdPin);
|
||||
void _setDataInPin(int inSdPin);
|
||||
int _applyPinSetting();
|
||||
|
||||
private:
|
||||
typedef enum {
|
||||
I2S_STATE_IDLE,
|
||||
I2S_STATE_TRANSMITTER,
|
||||
I2S_STATE_RECEIVER,
|
||||
I2S_STATE_DUPLEX
|
||||
} i2s_state_t;
|
||||
|
||||
int _deviceIndex;
|
||||
int _sdPin;
|
||||
int _inSdPin;
|
||||
int _outSdPin;
|
||||
int _sckPin;
|
||||
int _fsPin;
|
||||
|
||||
i2s_state_t _state;
|
||||
int _bitsPerSample;
|
||||
uint32_t _sampleRate;
|
||||
int _mode;
|
||||
|
||||
uint16_t _buffer_byte_size;
|
||||
|
||||
bool _driverInstalled; // Is IDF I2S driver installed?
|
||||
bool _initialized; // Is everything initialized (callback task, I2S driver, ring buffers)?
|
||||
TaskHandle_t _callbackTaskHandle;
|
||||
QueueHandle_t _i2sEventQueue;
|
||||
SemaphoreHandle_t _i2s_general_mutex;
|
||||
RingbufHandle_t _input_ring_buffer;
|
||||
RingbufHandle_t _output_ring_buffer;
|
||||
int _i2s_dma_buffer_size;
|
||||
bool _driveClock;
|
||||
uint32_t _peek_buff;
|
||||
bool _peek_buff_valid;
|
||||
|
||||
void _tx_done_routine(uint8_t* prev_item);
|
||||
void _rx_done_routine();
|
||||
|
||||
uint16_t _nesting_counter;
|
||||
void _take_if_not_holding();
|
||||
void _give_if_top_call();
|
||||
void _post_read_data_fix(void *input, size_t *size);
|
||||
void _fix_and_write(void *output, size_t size, size_t *bytes_written = NULL, size_t *actual_bytes_written = NULL);
|
||||
|
||||
void (*_onTransmit)(void);
|
||||
void (*_onReceive)(void);
|
||||
};
|
||||
|
||||
extern I2SClass I2S;
|
||||
|
||||
#endif
|
@ -1,11 +1,12 @@
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "RMaker.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
#include <esp_rmaker_schedule.h>
|
||||
#include <esp_rmaker_utils.h>
|
||||
bool wifiLowLevelInit(bool persistent);
|
||||
static esp_err_t err;
|
||||
|
||||
static void event_handler(void *arg, esp_event_base_t event_base, int event_id, void *event_data)
|
||||
static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
||||
{
|
||||
if (event_base == RMAKER_EVENT) {
|
||||
switch (event_id) {
|
||||
|
@ -1,6 +1,20 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "esp_system.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "RMakerNode.h"
|
||||
#include "RMakerQR.h"
|
||||
@ -26,5 +40,4 @@ class RMakerClass
|
||||
};
|
||||
|
||||
extern RMakerClass RMaker;
|
||||
|
||||
#endif
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "RMakerDevice.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
static esp_err_t err;
|
||||
typedef void (*deviceWriteCb)(Device*, Param*, const param_val_t val, void *priv_data, write_ctx_t *ctx);
|
||||
@ -205,5 +206,4 @@ esp_err_t Device::updateAndReportParam(const char *param_name, const char *my_va
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,20 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "esp_system.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#include "RMakerParam.h"
|
||||
#include <esp_rmaker_standard_devices.h>
|
||||
#include <esp_rmaker_standard_params.h>
|
||||
@ -150,5 +164,4 @@ class TemperatureSensor : public Device
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "RMakerNode.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
static esp_err_t err;
|
||||
|
||||
esp_err_t Node::addDevice(Device device)
|
||||
@ -38,4 +39,4 @@ esp_err_t Node::addNodeAttr(const char *attr_name, const char *val)
|
||||
}
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,6 +1,20 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "esp_system.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#include "RMakerDevice.h"
|
||||
|
||||
class Node
|
||||
@ -29,5 +43,4 @@ class Node
|
||||
node_info_t *getNodeInfo();
|
||||
esp_err_t addNodeAttr(const char *attr_name, const char *val);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "RMakerParam.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
static esp_err_t err;
|
||||
|
||||
@ -29,5 +30,4 @@ esp_err_t Param::updateAndReport(param_val_t val)
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,6 +1,20 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "esp_system.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#include "RMakerType.h"
|
||||
|
||||
class Param
|
||||
@ -34,5 +48,4 @@ class Param
|
||||
esp_err_t addBounds(param_val_t min, param_val_t max, param_val_t step);
|
||||
esp_err_t updateAndReport(param_val_t val);
|
||||
};
|
||||
|
||||
#endif
|
@ -1,6 +1,20 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "esp_system.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#include <qrcode.h>
|
||||
|
||||
#define PROV_QR_VERSION "v1"
|
||||
@ -20,5 +34,4 @@ static void printQR(const char *name, const char *pop, const char *transport)
|
||||
qrcode_display(payload);
|
||||
Serial.printf("If QR code is not visible, copy paste the below URL in a browser.\n%s?data=%s\n", QRCODE_BASE_URL, payload);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
@ -1,5 +1,6 @@
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "RMakerType.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
param_val_t value(int ival)
|
||||
{
|
||||
@ -20,5 +21,4 @@ param_val_t value(float fval)
|
||||
{
|
||||
return esp_rmaker_float(fval);
|
||||
}
|
||||
|
||||
#endif
|
@ -1,6 +1,20 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "esp_system.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#include <esp_rmaker_core.h>
|
||||
#include <esp_rmaker_ota.h>
|
||||
#include <esp_err.h>
|
||||
@ -19,5 +33,4 @@ param_val_t value(int);
|
||||
param_val_t value(bool);
|
||||
param_val_t value(char *);
|
||||
param_val_t value(float);
|
||||
|
||||
#endif
|
@ -1,16 +1,29 @@
|
||||
// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#pragma once
|
||||
#include "sdkconfig.h"
|
||||
#ifdef CONFIG_ESP_RMAKER_WORK_QUEUE_TASK_STACK
|
||||
#include "esp_system.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && CONFIG_ESP_RMAKER_TASK_STACK && CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#include <esp_rmaker_utils.h>
|
||||
|
||||
static void RMakerFactoryReset(int seconds)
|
||||
{
|
||||
esp_rmaker_factory_reset(seconds);
|
||||
esp_rmaker_factory_reset(0, seconds);
|
||||
}
|
||||
|
||||
static void RMakerWiFiReset(int seconds)
|
||||
{
|
||||
esp_rmaker_wifi_reset(seconds);
|
||||
esp_rmaker_wifi_reset(0, seconds);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
@ -12,29 +12,77 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "pins_arduino.h"
|
||||
#include "SD_MMC.h"
|
||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) //SDMMC does not work on ESP32S2
|
||||
#ifdef SOC_SDMMC_HOST_SUPPORTED
|
||||
#include "vfs_api.h"
|
||||
|
||||
extern "C" {
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include "esp_vfs_fat.h"
|
||||
#include "driver/sdmmc_host.h"
|
||||
#include "driver/sdmmc_defs.h"
|
||||
#include "sdmmc_cmd.h"
|
||||
}
|
||||
#include "soc/sdmmc_pins.h"
|
||||
#include "ff.h"
|
||||
|
||||
using namespace fs;
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
SDMMCFS::SDMMCFS(FSImplPtr impl)
|
||||
: FS(impl), _card(NULL)
|
||||
{}
|
||||
: FS(impl), _card(nullptr)
|
||||
{
|
||||
#if defined(SOC_SDMMC_USE_GPIO_MATRIX) && defined(BOARD_HAS_SDMMC)
|
||||
_pin_clk = SDMMC_CLK;
|
||||
_pin_cmd = SDMMC_CMD;
|
||||
_pin_d0 = SDMMC_D0;
|
||||
#ifndef BOARD_HAS_1BIT_SDMMC
|
||||
_pin_d1 = SDMMC_D1;
|
||||
_pin_d2 = SDMMC_D2;
|
||||
_pin_d3 = SDMMC_D3;
|
||||
#endif // BOARD_HAS_1BIT_SDMMC
|
||||
#endif // defined(SOC_SDMMC_USE_GPIO_MATRIX) && defined(BOARD_HAS_SDMMC)
|
||||
}
|
||||
|
||||
bool SDMMCFS::setPins(int clk, int cmd, int d0)
|
||||
{
|
||||
return setPins(clk, cmd, d0, GPIO_NUM_NC, GPIO_NUM_NC, GPIO_NUM_NC);
|
||||
}
|
||||
|
||||
bool SDMMCFS::setPins(int clk, int cmd, int d0, int d1, int d2, int d3)
|
||||
{
|
||||
if (_card != nullptr) {
|
||||
log_e("SD_MMC.setPins must be called before SD_MMC.begin");
|
||||
return false;
|
||||
}
|
||||
#ifdef SOC_SDMMC_USE_GPIO_MATRIX
|
||||
// SoC supports SDMMC pin configuration via GPIO matrix. Save the pins for later use in SDMMCFS::begin.
|
||||
_pin_clk = (int8_t) clk;
|
||||
_pin_cmd = (int8_t) cmd;
|
||||
_pin_d0 = (int8_t) d0;
|
||||
_pin_d1 = (int8_t) d1;
|
||||
_pin_d2 = (int8_t) d2;
|
||||
_pin_d3 = (int8_t) d3;
|
||||
return true;
|
||||
#elif CONFIG_IDF_TARGET_ESP32
|
||||
// ESP32 doesn't support SDMMC pin configuration via GPIO matrix.
|
||||
// Since SDMMCFS::begin hardcodes the usage of slot 1, only check if
|
||||
// the pins match slot 1 pins.
|
||||
bool pins_ok = (clk == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_CLK) &&
|
||||
(cmd == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_CMD) &&
|
||||
(d0 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D0) &&
|
||||
(((d1 == -1) && (d2 == -1) && (d3 == -1)) ||
|
||||
((d1 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D1) &&
|
||||
(d1 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D2) &&
|
||||
(d1 == (int)SDMMC_SLOT1_IOMUX_PIN_NUM_D3)));
|
||||
if (!pins_ok) {
|
||||
log_e("SDMMCFS: specified pins are not supported by this chip.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
#error SoC not supported
|
||||
#endif
|
||||
}
|
||||
|
||||
bool SDMMCFS::begin(const char * mountpoint, bool mode1bit, bool format_if_mount_failed, int sdmmc_frequency)
|
||||
{
|
||||
@ -43,27 +91,33 @@ bool SDMMCFS::begin(const char * mountpoint, bool mode1bit, bool format_if_mount
|
||||
}
|
||||
//mount
|
||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
||||
sdmmc_host_t host;
|
||||
#ifdef SOC_SDMMC_USE_GPIO_MATRIX
|
||||
// SoC supports SDMMC pin configuration via GPIO matrix.
|
||||
// Chech that the pins have been set either in the constructor or setPins function.
|
||||
if (_pin_cmd == -1 || _pin_clk == -1 || _pin_d0 == -1
|
||||
|| (!mode1bit && (_pin_d1 == -1 || _pin_d2 == -1 || _pin_d3 == -1))) {
|
||||
log_e("SDMMCFS: some SD pins are not set");
|
||||
return false;
|
||||
}
|
||||
|
||||
slot_config.clk = (gpio_num_t) _pin_clk;
|
||||
slot_config.cmd = (gpio_num_t) _pin_cmd;
|
||||
slot_config.d0 = (gpio_num_t) _pin_d0;
|
||||
slot_config.d1 = (gpio_num_t) _pin_d1;
|
||||
slot_config.d2 = (gpio_num_t) _pin_d2;
|
||||
slot_config.d3 = (gpio_num_t) _pin_d3;
|
||||
slot_config.width = 4;
|
||||
#endif // SOC_SDMMC_USE_GPIO_MATRIX
|
||||
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
||||
host.flags = SDMMC_HOST_FLAG_4BIT;
|
||||
host.slot = SDMMC_HOST_SLOT_1;
|
||||
host.max_freq_khz = sdmmc_frequency;
|
||||
host.io_voltage = 3.3f;
|
||||
host.init = &sdmmc_host_init;
|
||||
host.set_bus_width = &sdmmc_host_set_bus_width;
|
||||
host.get_bus_width = &sdmmc_host_get_slot_width;
|
||||
host.set_bus_ddr_mode = &sdmmc_host_set_bus_ddr_mode;
|
||||
host.set_card_clk = &sdmmc_host_set_card_clk;
|
||||
host.do_transaction = &sdmmc_host_do_transaction;
|
||||
host.deinit = &sdmmc_host_deinit;
|
||||
host.io_int_enable = &sdmmc_host_io_int_enable;
|
||||
host.io_int_wait = &sdmmc_host_io_int_wait;
|
||||
host.command_timeout_ms = 0;
|
||||
#ifdef BOARD_HAS_1BIT_SDMMC
|
||||
mode1bit = true;
|
||||
#endif
|
||||
if(mode1bit) {
|
||||
host.flags = SDMMC_HOST_FLAG_1BIT; //use 1-line SD mode
|
||||
slot_config.width = 1;
|
||||
slot_config.width = 1;
|
||||
}
|
||||
|
||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||
@ -81,7 +135,7 @@ bool SDMMCFS::begin(const char * mountpoint, bool mode1bit, bool format_if_mount
|
||||
log_w("SD Already mounted");
|
||||
return true;
|
||||
} else {
|
||||
log_e("Failed to initialize the card (%d). Make sure SD card lines have pull-up resistors in place.", ret);
|
||||
log_e("Failed to initialize the card (0x%x). Make sure SD card lines have pull-up resistors in place.", ret);
|
||||
}
|
||||
_card = NULL;
|
||||
return false;
|
||||
@ -144,4 +198,4 @@ uint64_t SDMMCFS::usedBytes()
|
||||
}
|
||||
|
||||
SDMMCFS SD_MMC = SDMMCFS(FSImplPtr(new VFSImpl()));
|
||||
#endif /* CONFIG_IDF_TARGET_ESP32 */
|
||||
#endif /* SOC_SDMMC_HOST_SUPPORTED */
|
||||
|
@ -15,7 +15,8 @@
|
||||
#define _SDMMC_H_
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "soc/soc_caps.h"
|
||||
#ifdef SOC_SDMMC_HOST_SUPPORTED
|
||||
|
||||
#include "FS.h"
|
||||
#include "driver/sdmmc_types.h"
|
||||
@ -36,8 +37,19 @@ class SDMMCFS : public FS
|
||||
protected:
|
||||
sdmmc_card_t* _card;
|
||||
|
||||
#ifdef SOC_SDMMC_USE_GPIO_MATRIX
|
||||
int8_t _pin_clk = -1;
|
||||
int8_t _pin_cmd = -1;
|
||||
int8_t _pin_d0 = -1;
|
||||
int8_t _pin_d1 = -1;
|
||||
int8_t _pin_d2 = -1;
|
||||
int8_t _pin_d3 = -1;
|
||||
#endif
|
||||
|
||||
public:
|
||||
SDMMCFS(FSImplPtr impl);
|
||||
bool setPins(int clk, int cmd, int d0);
|
||||
bool setPins(int clk, int cmd, int d0, int d1, int d2, int d3);
|
||||
bool begin(const char * mountpoint="/sdcard", bool mode1bit=false, bool format_if_mount_failed=false, int sdmmc_frequency=BOARD_MAX_SDMMC_FREQ);
|
||||
void end();
|
||||
sdcard_type_t cardType();
|
||||
@ -50,5 +62,5 @@ public:
|
||||
|
||||
extern fs::SDMMCFS SD_MMC;
|
||||
|
||||
#endif /* CONFIG_IDF_TARGET_ESP32S2 */
|
||||
#endif /* SOC_SDMMC_HOST_SUPPORTED */
|
||||
#endif /* _SDMMC_H_ */
|
||||
|
@ -39,7 +39,7 @@
|
||||
#define HSPI_SS 15
|
||||
#endif
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
#define VSPI FSPI
|
||||
#endif
|
||||
|
||||
|
@ -50,7 +50,7 @@ void SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss)
|
||||
}
|
||||
|
||||
if(sck == -1 && miso == -1 && mosi == -1 && ss == -1) {
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
_sck = (_spi_num == FSPI) ? SCK : -1;
|
||||
_miso = (_spi_num == FSPI) ? MISO : -1;
|
||||
_mosi = (_spi_num == FSPI) ? MOSI : -1;
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "USBHIDMouse.h"
|
||||
#include "USBHIDKeyboard.h"
|
||||
@ -214,3 +219,4 @@ void loop() {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "USBHIDConsumerControl.h"
|
||||
USBHIDConsumerControl ConsumerControl;
|
||||
@ -19,3 +24,4 @@ void loop() {
|
||||
}
|
||||
previousButtonState = buttonState;
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "USBHID.h"
|
||||
USBHID HID;
|
||||
@ -50,6 +55,7 @@ public:
|
||||
};
|
||||
|
||||
CustomHIDDevice Device;
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
||||
const int buttonPin = 0;
|
||||
int previousButtonState = HIGH;
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "FirmwareMSC.h"
|
||||
|
||||
@ -72,3 +77,4 @@ void setup() {
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "USBHIDGamepad.h"
|
||||
USBHIDGamepad Gamepad;
|
||||
@ -19,3 +24,4 @@ void loop() {
|
||||
}
|
||||
previousButtonState = buttonState;
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "USBHIDVendor.h"
|
||||
USBHIDVendor Vendor;
|
||||
@ -50,3 +55,4 @@ void loop() {
|
||||
Serial.write(Vendor.read());
|
||||
}
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -24,6 +24,11 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardLogout
|
||||
*/
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
|
||||
#define OSX 0
|
||||
#define WINDOWS 1
|
||||
@ -90,3 +95,4 @@ void loop() {
|
||||
// do nothing:
|
||||
while (true) delay(1000);
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -19,6 +19,11 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardMessage
|
||||
*/
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
|
||||
#include "USB.h"
|
||||
#include "USBHIDKeyboard.h"
|
||||
@ -53,3 +58,4 @@ void loop() {
|
||||
// save the current button state for comparison next time:
|
||||
previousButtonState = buttonState;
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -24,6 +24,11 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardReprogram
|
||||
*/
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
|
||||
#include "USB.h"
|
||||
#include "USBHIDKeyboard.h"
|
||||
@ -104,3 +109,4 @@ void loop() {
|
||||
// wait for the sweet oblivion of reprogramming:
|
||||
while (true)delay(1000);
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -16,6 +16,11 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardSerial
|
||||
*/
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
|
||||
#include "USB.h"
|
||||
#include "USBHIDKeyboard.h"
|
||||
@ -38,3 +43,4 @@ void loop() {
|
||||
Keyboard.write(inChar + 1);
|
||||
}
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -18,6 +18,11 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/KeyboardAndMouseControl
|
||||
*/
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
|
||||
#include "USB.h"
|
||||
#include "USBHIDMouse.h"
|
||||
@ -93,3 +98,4 @@ void loop() {
|
||||
}
|
||||
delay(5);
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -20,6 +20,11 @@
|
||||
|
||||
http://www.arduino.cc/en/Tutorial/ButtonMouseControl
|
||||
*/
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
|
||||
#include "USB.h"
|
||||
#include "USBHIDMouse.h"
|
||||
@ -84,3 +89,4 @@ void loop() {
|
||||
// a delay so the mouse doesn't move too fast:
|
||||
delay(responseDelay);
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "USBHIDSystemControl.h"
|
||||
USBHIDSystemControl SystemControl;
|
||||
@ -19,3 +24,4 @@ void loop() {
|
||||
}
|
||||
previousButtonState = buttonState;
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "USBMSC.h"
|
||||
|
||||
@ -190,3 +195,4 @@ void setup() {
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
|
||||
#if ARDUINO_USB_CDC_ON_BOOT
|
||||
@ -81,3 +86,4 @@ void loop() {
|
||||
USBSerial.write(b, l);
|
||||
}
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -1,3 +1,8 @@
|
||||
#if ARDUINO_USB_MODE
|
||||
#warning This sketch should be used when USB is in OTG mode
|
||||
void setup(){}
|
||||
void loop(){}
|
||||
#else
|
||||
#include "USB.h"
|
||||
#include "USBVendor.h"
|
||||
|
||||
@ -189,3 +194,4 @@ void loop() {
|
||||
Vendor.write(b, l);
|
||||
}
|
||||
}
|
||||
#endif /* ARDUINO_USB_MODE */
|
||||
|
@ -171,7 +171,7 @@ int start_ssl_client(sslclient_context *ssl_client, const char *host, uint32_t p
|
||||
|
||||
if (insecure) {
|
||||
mbedtls_ssl_conf_authmode(&ssl_client->ssl_conf, MBEDTLS_SSL_VERIFY_NONE);
|
||||
log_i("WARNING: Skipping SSL Verification. INSECURE!");
|
||||
log_d("WARNING: Skipping SSL Verification. INSECURE!");
|
||||
} else if (rootCABuff != NULL) {
|
||||
log_v("Loading CA cert");
|
||||
mbedtls_x509_crt_init(&ssl_client->ca_cert);
|
||||
|
Reference in New Issue
Block a user