Skip to content

Commit

Permalink
C6 and C2 support (#363)
Browse files Browse the repository at this point in the history
* Initial C6 support

* add C6 in tasmota_globals.h

* fix copy&paste errors

* Use updated platform (build 1481)

* use common safeboot flags (arendst#19282) (#352)

Co-authored-by: Christian Baars <[email protected]>

* use env var lib_ignore

* safeboot lib_ignore env

* revert wrong change

* rm eink lib from standard used libs

* add c2-board 4M, maximum_size probably a bit off

* diffuse idea for 2MB with OTA and FS

* C2 and C6 additions

* C2 and C6 additions for commands.ino

* C2 and C6 additions for crash recorder

* C2 to support_esp

* some preps for C2

* add c2 to tasmota.h

* fix some typos and compile bugs

* fix 2 compiler warnings for Arduino 3.0

* fix another warning

* add correct pins to template

* pins for C2, maximum_size updated

* unclutter env:tasmota32c2-safeboot

* fix c6 env

* more pins for the C2, but not all

* pin 9 and 10 for c2/c6

* add ||

* prep pins for c6

* make c6 compile, needs testing

* fix copy-paste-error

* more correct pin support C6

* pin14 C6

* wrong warning for C6

* 10 and 11 are flash pins on the C6

* boolean voodoo

* fix EVERYTHING

* fix Onewire for Arduino 3.0

* enable OneWire

* finale fix for all platforms: OneWire.h

* better compatibility

* final fix onewire

* refactor Platformio Arduino 3.0 setup

* overlooked needed `;`

* refactor as requested

* fix NeoPixelBus compilation for C2 and C6

* fix Arduino30 for old working NeoPixel boards

* Try to switch of RMT LED when not SOC supported

* use latest IDF 5.1

* framework includes now "libsodium"

* prep NeoPixel RMT rewrite

* NeoPixel for C6

* fix Arduino 2.x

* really fix compile ??

* fix compiler warning TSL2591

* fix compiler warning TSL2591 _2

* fix compile warning TSL2561

* fix warning sensirion part 1

* fix ESP32 Arduino 3.0 compile (needs work check)

* Disable NeoPixel for C2 (no RMT support)

* forgotten to remove

* fix compiler warning

* prep 5.1, TasUpdater

* prep 5.1 SensirionRXFrame

* prep 5.1, SensiriomI2CCommunication.cpp

* prep5.1, last batch Sensirion

* prep5.1, silence compiler warning

* Silence C++ deprecated warning

* Align with branch C6-support (#359)

* prep5.1, fix berry_wire

* revert deprecated compiler flag

---------

Co-authored-by: Staars <[email protected]>
Co-authored-by: Christian Baars <[email protected]>

* add i2c #defines

* enable more libs for ESP32

* refactor for esp-nimble-cpp

* add esp-nimble-cpp, needed for C2,C6

* fix dual use of IRAM_ATTR for i2sDmaISR

* silence compiler warning with cast

* prep5.1, new DAC API in Berry

* more libs enabled

* NimBLE changes

* fix wrong build flag for MI

* add NimBLE ignores

* add MI to env

* use latest framework with changed NimBLE

* add libesp32_div to C2/C6

* fix env konfig for NimBLE

* new esp-cpp-nimble for all

---------

Co-authored-by: Christian Baars <[email protected]>
Co-authored-by: Christian Baars <[email protected]>
  • Loading branch information
3 people authored Aug 16, 2023
1 parent aa097e9 commit 95e77a8
Show file tree
Hide file tree
Showing 192 changed files with 23,400 additions and 214 deletions.
44 changes: 44 additions & 0 deletions boards/esp32c2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"build": {
"arduino":{
"ldscript": "esp32c2_out.ld"
},
"core": "esp32",
"extra_flags": "-DESP32_4M -DESP32C2",
"f_cpu": "120000000L",
"f_flash": "60000000L",
"flash_mode": "dio",
"mcu": "esp32c2",
"variant": "esp32c2",
"partitions": "partitions/esp32_partition_app2880k_fs320k.csv"
},
"connectivity": [
"wifi",
"bluetooth"
],
"debug": {
"openocd_target": "esp32c2.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif Generic ESP32-C2 = 4M Flash",
"upload": {
"arduino": {
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32c2-safeboot.bin"
]
]
},
"flash_size": "4MB",
"maximum_ram_size": 278528,
"maximum_size": 4194304,
"require_upload_port": true,
"speed": 460800
},
"url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html",
"vendor": "Espressif"
}
44 changes: 44 additions & 0 deletions boards/esp32c2_2M.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"build": {
"arduino":{
"ldscript": "esp32c2_out.ld"
},
"core": "esp32",
"extra_flags": "-DESP32_2M -DESP32C2",
"f_cpu": "120000000L",
"f_flash": "60000000L",
"flash_mode": "dio",
"mcu": "esp32c2",
"variant": "esp32c2",
"partitions": "partitions/esp32_partition_app1245k_fs64k.csv"
},
"connectivity": [
"wifi",
"bluetooth"
],
"debug": {
"openocd_target": "esp32c2.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif Generic ESP32-C2 = 2M Flash, Tasmota 1245kB Code/OTA, 64k FS",
"upload": {
"arduino": {
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32c2-safeboot.bin"
]
]
},
"flash_size": "2MB",
"maximum_ram_size": 278528,
"maximum_size": 2097152,
"require_upload_port": true,
"speed": 460800
},
"url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html",
"vendor": "Espressif"
}
2 changes: 1 addition & 1 deletion boards/esp32c6.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"extra_flags": "-DESP32_4M -DESP32C6",
"f_cpu": "160000000L",
"f_flash": "80000000L",
"flash_mode": "dio",
"flash_mode": "qio",
"mcu": "esp32c6",
"variant": "esp32c6",
"partitions": "partitions/esp32_partition_app2880k_fs320k.csv"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ License along with NeoPixel. If not, see

#include "driver/spi_master.h"

#if defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(HSPI_HOST)
#if (defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C6)) && !defined(HSPI_HOST)
// HSPI_HOST depreciated in C3
#define HSPI_HOST SPI2_HOST
#endif

#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
class Esp32VspiBus
{
public:
Expand All @@ -52,7 +52,7 @@ class Esp32HspiBus
const static int ParallelBits = 1;
};

#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
class Esp32Vspi2BitBus
{
public:
Expand All @@ -70,7 +70,7 @@ class Esp32Hspi2BitBus
const static int ParallelBits = 2;
};

#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
class Esp32Vspi4BitBus
{
public:
Expand Down Expand Up @@ -174,7 +174,7 @@ template<typename T_SPISPEED, typename T_SPIBUS> class DotStarEsp32DmaSpiMethod
// If pins aren't specified, initialize bus with just the default SCK and MOSI pins for the SPI peripheral (no SS, no >1-bit pins)
void Initialize()
{
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
if (T_SPIBUS::SpiHostDevice == VSPI_HOST)
{
Initialize(SCK, -1, MOSI, -1, -1, -1);
Expand Down Expand Up @@ -277,7 +277,7 @@ template<typename T_SPISPEED, typename T_SPIBUS> class DotStarEsp32DmaSpiMethod
int8_t _ssPin;
};

#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
// Clock Speed and Default Definitions for DotStarEsp32DmaVspi
typedef DotStarEsp32DmaSpiMethod<SpiSpeed40Mhz, Esp32VspiBus> DotStarEsp32DmaVspi40MhzMethod;
typedef DotStarEsp32DmaSpiMethod<SpiSpeed20Mhz, Esp32VspiBus> DotStarEsp32DmaVspi20MhzMethod;
Expand All @@ -303,7 +303,7 @@ typedef DotStarEsp32DmaSpiMethod<SpiSpeedHz, Esp32HspiBus> DotStarEsp32DmaHspiHz

typedef DotStarEsp32DmaHspi10MhzMethod DotStarEsp32DmaHspiMethod;

#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
// Clock Speed and Default Definitions for DotStarEsp32DmaVspi2Bit
typedef DotStarEsp32DmaSpiMethod<SpiSpeed40Mhz,Esp32Vspi2BitBus> DotStarEsp32DmaVspi2Bit40MhzMethod;
typedef DotStarEsp32DmaSpiMethod<SpiSpeed20Mhz,Esp32Vspi2BitBus> DotStarEsp32DmaVspi2Bit20MhzMethod;
Expand All @@ -329,7 +329,7 @@ typedef DotStarEsp32DmaSpiMethod<SpiSpeedHz,Esp32Hspi2BitBus> DotStarEsp32DmaHsp

typedef DotStarEsp32DmaHspi2Bit10MhzMethod DotStarEsp32DmaHspi2BitMethod;

#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
// Clock Speed and Default Definitions for DotStarEsp32DmaVspi4Bit
typedef DotStarEsp32DmaSpiMethod<SpiSpeed40Mhz,Esp32Vspi4BitBus> DotStarEsp32DmaVspi4Bit40MhzMethod;
typedef DotStarEsp32DmaSpiMethod<SpiSpeed20Mhz,Esp32Vspi4BitBus> DotStarEsp32DmaVspi4Bit20MhzMethod;
Expand Down
23 changes: 19 additions & 4 deletions lib/lib_basic/NeoPixelBus/src/internal/Esp32_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "sdkconfig.h" // this sets useful config symbols, like CONFIG_IDF_TARGET_ESP32C3

// ESP32C3/S3 I2S is not supported yet due to significant changes to interface
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)

#include <string.h>
#include <stdio.h>
Expand All @@ -41,20 +41,27 @@
#include "soc/gpio_reg.h"
#include "soc/gpio_sig_map.h"
#include "soc/io_mux_reg.h"
#if ESP_IDF_VERSION_MAJOR>=5
#include "soc/rtc_cntl_periph.h"
#include "soc/periph_defs.h"
#else
#include "soc/rtc_cntl_reg.h"
#include "soc/sens_reg.h"
#endif

#include "soc/i2s_struct.h"
#if defined(CONFIG_IDF_TARGET_ESP32)
/* included here for ESP-IDF v4.x compatibility */
#include "soc/dport_reg.h"
#endif
#include "soc/sens_reg.h"

#include "driver/gpio.h"
#include "driver/i2s.h"
#include "driver/dac.h"
#include "Esp32_i2s.h"
#include "esp32-hal.h"

#if ESP_IDF_VERSION_MAJOR<=4
#if ESP_IDF_VERSION_MAJOR<=4 || ESP_IDF_VERSION_MAJOR>=5
#define I2S_BASE_CLK (160000000L)
#endif

Expand Down Expand Up @@ -93,7 +100,11 @@ typedef struct {
int8_t in;
uint32_t rate;
intr_handle_t isr_handle;
#if ESP_IDF_VERSION_MAJOR >= 5
QueueHandle_t tx_queue;
#else
xQueueHandle tx_queue;
#endif

uint8_t* silence_buf;
size_t silence_len;
Expand All @@ -110,6 +121,10 @@ typedef struct {
#define I2s_Is_Pending 1
#define I2s_Is_Sending 2

#if ESP_IDF_VERSION_MAJOR >= 5
#define I2S_NUM_MAX I2S_NUM_AUTO // not 100% correct
#endif

static uint8_t i2s_silence_buf[I2S_DMA_SILENCE_SIZE] = { 0 };

#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
Expand All @@ -124,7 +139,7 @@ static i2s_bus_t I2S[I2S_NUM_MAX] = {
};
#endif

void IRAM_ATTR i2sDmaISR(void* arg);
void i2sDmaISR(void* arg);

bool i2sInitDmaItems(uint8_t bus_num) {
if (bus_num >= I2S_NUM_MAX) {
Expand Down
2 changes: 1 addition & 1 deletion lib/lib_basic/NeoPixelBus/src/internal/Esp32_i2s.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

// ESP32C3 I2S is not supported yet due to significant changes to interface
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)

#ifdef __cplusplus
extern "C" {
Expand Down
4 changes: 2 additions & 2 deletions lib/lib_basic/NeoPixelBus/src/internal/NeoBusChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum NeoBusChannel
NeoBusChannel_0,
NeoBusChannel_1,

#if !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)

NeoBusChannel_2,

Expand All @@ -35,7 +35,7 @@ enum NeoBusChannel
NeoBusChannel_7,
#endif // !defined(CONFIG_IDF_TARGET_ESP32S2)

#endif // !defined(CONFIG_IDF_TARGET_ESP32C3)
#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)

#endif // ARDUINO_ARCH_ESP32

Expand Down
9 changes: 5 additions & 4 deletions lib/lib_basic/NeoPixelBus/src/internal/NeoEsp32I2sMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ License along with NeoPixel. If not, see
#pragma once

// ESP32C3 I2S is not supported yet due to significant changes to interface
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)

extern "C"
{
#include <Arduino.h>
#include "Esp32_i2s.h"
#include "rom/gpio.h"
}

const uint16_t c_dmaBytesPerPixelBytes = 4;
Expand Down Expand Up @@ -301,7 +302,7 @@ typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed800Kbps, NeoEsp32I2sBusZero, NeoEs
typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeed400Kbps, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0400KbpsInvertedMethod;
typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedApa106, NeoEsp32I2sBusZero, NeoEsp32I2sInverted> NeoEsp32I2s0Apa106InvertedMethod;

#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
// (I2S_NUM_MAX == 2)

typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedWs2812x, NeoEsp32I2sBusOne, NeoEsp32I2sNotInverted> NeoEsp32I2s1Ws2812xMethod;
Expand Down Expand Up @@ -343,7 +344,7 @@ typedef NeoEsp32I2sMethodBase<NeoEsp32I2sSpeedApa106, NeoEsp32I2sBusN, NeoEsp32I

#endif

#if !defined(NEOPIXEL_ESP32_RMT_DEFAULT) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#if !defined(NEOPIXEL_ESP32_RMT_DEFAULT) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)

// I2s Bus 1 method is the default method for Esp32
// Esp32S2 & Esp32C3 will use RMT as the default allways
Expand Down Expand Up @@ -375,6 +376,6 @@ typedef NeoEsp32I2s1Apa106InvertedMethod NeoApa106InvertedMethod;
typedef NeoEsp32I2s1Ws2812xInvertedMethod Neo800KbpsInvertedMethod;
typedef NeoEsp32I2s1400KbpsInvertedMethod Neo400KbpsInvertedMethod;

#endif // !defined(NEOPIXEL_ESP32_RMT_DEFAULT) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3)
#endif // !defined(NEOPIXEL_ESP32_RMT_DEFAULT) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)

#endif
Loading

0 comments on commit 95e77a8

Please sign in to comment.