diff --git a/README.md b/README.md index 44f85f21c..f3d43a0e3 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Data|FLARM NMEA|

![](https://github.com/lyusupov/SoftRF/raw/mas Model(s)|Platform|First appearance|       Status       |Notes ---|:---:|:---:|:---:|--- 1 [Prime](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition)
2 [Standalone](https://github.com/lyusupov/SoftRF/wiki/Standalone-Edition)
3 [UAV](https://github.com/lyusupov/SoftRF/wiki/UAV-Edition)
4 [**WebTop Serial**](https://github.com/lyusupov/SoftRF/wiki/WebTop-Serial-adapter)|[Espressif
ESP8266](https://en.wikipedia.org/wiki/ESP8266)|Q4 2015|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|[Prime](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition) model is no longer supported - use [Prime MkII](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII) instead.
-1 [**Prime Mark II**](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII)
2 [**Standalone**](https://github.com/lyusupov/SoftRF/wiki/Standalone-Edition) + [adapter](https://github.com/lyusupov/ESP32-NODEMCU-ADAPTER)
3 [UAV](https://github.com/lyusupov/SoftRF/wiki/UAV-Edition)
4 [**SkyView EZ**](https://github.com/lyusupov/SoftRF/wiki/SkyView-EZ)
5 [Flight Recorder](https://github.com/lyusupov/SoftRF/wiki/Flight-Recorder)
6 [**WebTop USB**](https://github.com/lyusupov/SoftRF/wiki/WebTop-USB)![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)|[Espressif
ESP32](https://en.wikipedia.org/wiki/ESP32)
[ESP32-S2](https://en.wikipedia.org/wiki/ESP32#ESP32-S2)
[ESP32-S3](https://en.wikipedia.org/wiki/ESP32#ESP32-S3)|Q1 2018|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|1 today's best platform ;
2 holds [**FCC** mark](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII#certificates) ![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg) +1 [**Prime Mark II**](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII)
2 [**Standalone**](https://github.com/lyusupov/SoftRF/wiki/Standalone-Edition) + [adapter](https://github.com/lyusupov/ESP32-NODEMCU-ADAPTER)
3 [UAV](https://github.com/lyusupov/SoftRF/wiki/UAV-Edition)
4 [**SkyView EZ**](https://github.com/lyusupov/SoftRF/wiki/SkyView-EZ)
5 [Flight Recorder](https://github.com/lyusupov/SoftRF/wiki/Flight-Recorder)
6 [**WebTop USB**](https://github.com/lyusupov/SoftRF/wiki/WebTop-USB)![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)|[Espressif
ESP32](https://en.wikipedia.org/wiki/ESP32)
[ESP32-S2](https://en.wikipedia.org/wiki/ESP32#ESP32-S2)
[ESP32-S3](https://en.wikipedia.org/wiki/ESP32#ESP32-S3)
[ESP32-C3](https://en.wikipedia.org/wiki/ESP32#ESP32-C3)|Q1 2018|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|1 today's best platform ;
2 holds [**FCC** mark](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII#certificates) ![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg) 1 [**Raspberry Edition**](https://github.com/lyusupov/SoftRF/wiki/Raspberry-Edition)
2 [**SkyView Pi**](https://github.com/lyusupov/SoftRF/wiki/SkyView-Pi)|[Broadcom
BCM283X
(Raspberry Pi)](https://en.wikipedia.org/wiki/Raspberry_Pi)|Q4 2018|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|Good for use together with RTL-SDR dongles to achieve additional 1090ES (and 978UAT) ADS-B air traffic reception. 1 [UAT module](https://github.com/lyusupov/UAT-test-signal#variant-2-advanced)
2 [**Uni**](https://github.com/lyusupov/SoftRF/wiki/Uni-Edition)|[Texas Instruments
CC1310](http://www.ti.com/product/CC1310) and [CC13x2R](http://www.ti.com/product/CC1352R)|Q1 2019|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|1 Unique RF radio specs are useful for [UAT978 **ADS-B** reception](https://github.com/lyusupov/SoftRF/tree/master/software/firmware/source/UATbridge) [ [1](https://raw.githubusercontent.com/lyusupov/SoftRF/master/documents/images/uat-normal-7.jpg) , [2](https://raw.githubusercontent.com/lyusupov/SoftRF/master/documents/images/uat-normal-8.jpg) , [3](https://raw.githubusercontent.com/lyusupov/SoftRF/master/documents/images/uat-normal-6.jpg) ] ;
2 holds [**FCC/CE** mark](https://github.com/lyusupov/SoftRF/wiki/Uni-Edition#certificates) 1 [Retro](https://github.com/lyusupov/SoftRF/wiki/Retro-Edition)
2 [**Dongle**](https://github.com/lyusupov/SoftRF/wiki/Dongle-Edition)
3 [**Balkan**](https://github.com/lyusupov/SoftRF/wiki/Balkan-Edition) ![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)|[STMicroelectronics](https://en.wikipedia.org/wiki/STMicroelectronics)
[STM32**L073**](https://www.st.com/en/microcontrollers-microprocessors/stm32l073rz.html) and
[STM32**WLE5**](https://www.st.com/en/microcontrollers-microprocessors/stm32wle5cc.html)|Q3 2019|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)| diff --git a/software/firmware/binaries/README.md b/software/firmware/binaries/README.md index a8dc4dc8a..9fc55aedc 100644 --- a/software/firmware/binaries/README.md +++ b/software/firmware/binaries/README.md @@ -17,7 +17,7 @@ Model|Instructions|Firmware folder ---|:---:|:---: -[Standalone Edition](https://github.com/lyusupov/SoftRF/wiki/Standalone-Edition)|[NodeMCU](https://github.com/lyusupov/SoftRF/blob/master/software/firmware/binaries/README.md#nodemcu)|[NodeMCU](https://github.com/lyusupov/SoftRF/tree/master/software/firmware/binaries/NodeMCU/SoftRF) +[Standalone Edition](https://github.com/lyusupov/SoftRF/wiki/Standalone-Edition)|[NodeMCU](https://github.com/lyusupov/SoftRF/blob/master/software/firmware/binaries/README.md#nodemcu)
ESP32-C3|[NodeMCU](https://github.com/lyusupov/SoftRF/tree/master/software/firmware/binaries/NodeMCU/SoftRF)
ESP32C3 [Prime Edition Mk2](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII)|[ESP32](https://github.com/lyusupov/SoftRF/blob/master/software/firmware/binaries/README.md#esp32)|[ESP32](https://github.com/lyusupov/SoftRF/tree/master/software/firmware/binaries/ESP32/SoftRF) Prime Edition Mk3|[ESP32-S3](https://github.com/lyusupov/SoftRF/blob/master/software/firmware/binaries/README.md#esp32-s3)|[ESP32S3](https://github.com/lyusupov/SoftRF/tree/master/software/firmware/binaries/ESP32S3/SoftRF/MassStorage) [Badge Edition](https://github.com/lyusupov/SoftRF/wiki/Badge-Edition)|[nRF52840](https://github.com/lyusupov/SoftRF/blob/master/software/firmware/binaries/README.md#nrf52840)|[nRF52840](https://github.com/lyusupov/SoftRF/tree/master/software/firmware/binaries/nRF52840) diff --git a/software/firmware/source/SoftRF/src/platform/ESP32.cpp b/software/firmware/source/SoftRF/src/platform/ESP32.cpp index 78bdef9fd..2281556a5 100644 --- a/software/firmware/source/SoftRF/src/platform/ESP32.cpp +++ b/software/firmware/source/SoftRF/src/platform/ESP32.cpp @@ -2674,6 +2674,10 @@ static bool ESP32_Baro_setup() Wire.setPins(SOC_GPIO_PIN_S3_SDA, SOC_GPIO_PIN_S3_SCL); + } else if (esp32_board == ESP32_C3_DEVKIT) { + + Wire.setPins(SOC_GPIO_PIN_C3_SDA, SOC_GPIO_PIN_C3_SCL); + } else if (hw_info.model != SOFTRF_MODEL_PRIME_MK2) { if ((hw_info.rf != RF_IC_SX1276 && hw_info.rf != RF_IC_SX1262) || diff --git a/software/firmware/source/SoftRF/src/platform/ESP32.h b/software/firmware/source/SoftRF/src/platform/ESP32.h index fe1cc7464..6f72215bc 100644 --- a/software/firmware/source/SoftRF/src/platform/ESP32.h +++ b/software/firmware/source/SoftRF/src/platform/ESP32.h @@ -72,7 +72,7 @@ #define LED_STATE_ON HIGH // State when LED is litted -#if defined(CONFIG_IDF_TARGET_ESP32S3) +#if defined(CONFIG_IDF_TARGET_ESP32S3) || defined(CONFIG_IDF_TARGET_ESP32C3) /* Adafruit_NeoPixel still has "flickering" issue of ESP32 caused by 1 ms scheduler */ #define USE_ADAFRUIT_NEO_LIBRARY @@ -124,7 +124,7 @@ extern Adafruit_NeoPixel strip; #elif defined(CONFIG_IDF_TARGET_ESP32S3) #define SOC_GPIO_PIN_LED SOC_UNUSED_PIN /* TBD 14? */ #elif defined(CONFIG_IDF_TARGET_ESP32C3) -#define SOC_GPIO_PIN_LED SOC_UNUSED_PIN +#define SOC_GPIO_PIN_LED 19 /* D1 */ #else #error "This ESP32 family build variant is not supported!" #endif @@ -147,10 +147,11 @@ extern Adafruit_NeoPixel strip; SOC_UNUSED_PIN) : \ SOC_UNUSED_PIN)) -#define SOC_GPIO_PIN_BUZZER (hw_info.model == SOFTRF_MODEL_PRIME_MK2 ?\ - SOC_UNUSED_PIN : \ - (esp32_board == ESP32_DEVKIT ? \ - 13 : SOC_UNUSED_PIN)) +#define SOC_GPIO_PIN_BUZZER (hw_info.model == SOFTRF_MODEL_PRIME_MK2 ? \ + SOC_UNUSED_PIN : \ + (esp32_board == ESP32_DEVKIT ? 13 : \ + (esp32_board == ESP32_C3_DEVKIT ? \ + SOC_GPIO_PIN_C3_BUZZER : SOC_UNUSED_PIN))) /* SPI (does match Heltec & TTGO LoRa32 pins mapping) */ #define SOC_GPIO_PIN_MOSI 27 @@ -371,8 +372,8 @@ extern Adafruit_NeoPixel strip; // GNSS module #define SOC_GPIO_PIN_C3_GNSS_RX 9 /* D3 */ -#define SOC_GPIO_PIN_C3_GNSS_TX 19 /* D1 */ -#define SOC_GPIO_PIN_C3_GNSS_PPS SOC_UNUSED_PIN // 7 +#define SOC_GPIO_PIN_C3_GNSS_TX 7 +#define SOC_GPIO_PIN_C3_GNSS_PPS SOC_UNUSED_PIN // 0 // SPI #define SOC_GPIO_PIN_C3_MOSI 5 /* D7 */ @@ -387,7 +388,7 @@ extern Adafruit_NeoPixel strip; // SX1276 #define SOC_GPIO_PIN_C3_RST 18 /* D2 */ -#define SOC_GPIO_PIN_C3_DIO0 19 /* D0 */ +#define SOC_GPIO_PIN_C3_DIO0 2 /* D0 */ #define SOC_GPIO_PIN_C3_SDA 18 /* D2 */ #define SOC_GPIO_PIN_C3_SCL 10 /* D4 */ @@ -395,7 +396,6 @@ extern Adafruit_NeoPixel strip; #define SOC_GPIO_PIN_C3_BATTERY 1 /* A0 */ // auxillary -#define SOC_GPIO_PIN_C3_LED 19 /* D1 */ #define SOC_GPIO_PIN_C3_BUZZER 6 /* 10 */ #define SOC_GPIO_PIN_C3_STATUS SOC_UNUSED_PIN @@ -478,10 +478,10 @@ struct rst_info { //#define USE_GDL90_MSL #define USE_OGN_ENCRYPTION -//#define EXCLUDE_GNSS_UBLOX /* Neo-6/7/8 */ +//#define EXCLUDE_GNSS_UBLOX /* Neo-6/7/8, M10 */ #define ENABLE_UBLOX_RFS /* revert factory settings (when necessary) */ #define EXCLUDE_GNSS_GOKE /* 'Air530' GK9501 GPS/GLO/BDS (GAL inop.) */ -//#define EXCLUDE_GNSS_AT65 /* 'fake Neo-6/8' on some 2018 T-Beam boards */ +//#define EXCLUDE_GNSS_AT65 /* L76K, Air530Z */ #define EXCLUDE_GNSS_SONY #define EXCLUDE_GNSS_MTK @@ -493,9 +493,10 @@ struct rst_info { #if !defined(CONFIG_IDF_TARGET_ESP32) #define EXCLUDE_NRF905 #define EXCLUDE_UATM -#define EXCLUDE_LED_RING #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3) +#define EXCLUDE_LED_RING + /* Experimental */ //#define USE_ADAFRUIT_MSC //#define USE_USB_HOST diff --git a/software/firmware/source/libraries/Adafruit_NeoPixel/esp.c b/software/firmware/source/libraries/Adafruit_NeoPixel/esp.c new file mode 100644 index 000000000..c480a2050 --- /dev/null +++ b/software/firmware/source/libraries/Adafruit_NeoPixel/esp.c @@ -0,0 +1,178 @@ +// Implements the RMT peripheral on Espressif SoCs +// Copyright (c) 2020 Lucian Copeland for Adafruit Industries + +/* Uses code from Espressif RGB LED Strip demo and drivers + * 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. + */ + +#if defined(ESP32) + +#include +#include "driver/rmt.h" + +#if defined(ESP_IDF_VERSION) +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) +#define HAS_ESP_IDF_4 +#endif +#endif + +// This code is adapted from the ESP-IDF v3.4 RMT "led_strip" example, altered +// to work with the Arduino version of the ESP-IDF (3.2) + +#define WS2812_T0H_NS (400) +#define WS2812_T0L_NS (850) +#define WS2812_T1H_NS (800) +#define WS2812_T1L_NS (450) + +#define WS2811_T0H_NS (500) +#define WS2811_T0L_NS (2000) +#define WS2811_T1H_NS (1200) +#define WS2811_T1L_NS (1300) + +static uint32_t t0h_ticks = 0; +static uint32_t t1h_ticks = 0; +static uint32_t t0l_ticks = 0; +static uint32_t t1l_ticks = 0; + +// Limit the number of RMT channels available for the Neopixels. Defaults to all +// channels (8 on ESP32, 4 on ESP32-S2 and S3). Redefining this value will free +// any channels with a higher number for other uses, such as IR send-and-recieve +// libraries. Redefine as 1 to restrict Neopixels to only a single channel. +#define ADAFRUIT_RMT_CHANNEL_MAX RMT_CHANNEL_MAX + +#define RMT_LL_HW_BASE (&RMT) + +bool rmt_reserved_channels[ADAFRUIT_RMT_CHANNEL_MAX]; + +static void IRAM_ATTR ws2812_rmt_adapter(const void *src, rmt_item32_t *dest, size_t src_size, + size_t wanted_num, size_t *translated_size, size_t *item_num) +{ + if (src == NULL || dest == NULL) { + *translated_size = 0; + *item_num = 0; + return; + } + const rmt_item32_t bit0 = {{{ t0h_ticks, 1, t0l_ticks, 0 }}}; //Logical 0 + const rmt_item32_t bit1 = {{{ t1h_ticks, 1, t1l_ticks, 0 }}}; //Logical 1 + size_t size = 0; + size_t num = 0; + uint8_t *psrc = (uint8_t *)src; + rmt_item32_t *pdest = dest; + while (size < src_size && num < wanted_num) { + for (int i = 0; i < 8; i++) { + // MSB first + if (*psrc & (1 << (7 - i))) { + pdest->val = bit1.val; + } else { + pdest->val = bit0.val; + } + num++; + pdest++; + } + size++; + psrc++; + } + *translated_size = size; + *item_num = num; +} + +void espShow(uint8_t pin, uint8_t *pixels, uint32_t numBytes, boolean is800KHz) { + // Reserve channel + rmt_channel_t channel = ADAFRUIT_RMT_CHANNEL_MAX; + for (size_t i = 0; i < ADAFRUIT_RMT_CHANNEL_MAX; i++) { + if (!rmt_reserved_channels[i]) { + rmt_reserved_channels[i] = true; + channel = i; + break; + } + } + if (channel == ADAFRUIT_RMT_CHANNEL_MAX) { + // Ran out of channels! + return; + } + +#if defined(HAS_ESP_IDF_4) + rmt_config_t config = RMT_DEFAULT_CONFIG_TX(pin, channel); + config.clk_div = 2; +#else + // Match default TX config from ESP-IDF version 3.4 + rmt_config_t config = { + .rmt_mode = RMT_MODE_TX, + .channel = channel, + .gpio_num = pin, + .clk_div = 2, + .mem_block_num = 1, + .tx_config = { + .carrier_freq_hz = 38000, + .carrier_level = RMT_CARRIER_LEVEL_HIGH, + .idle_level = RMT_IDLE_LEVEL_LOW, + .carrier_duty_percent = 33, + .carrier_en = false, + .loop_en = false, + .idle_output_en = true, + } + }; +#endif + rmt_config(&config); + rmt_driver_install(config.channel, 0, 0); + + // Convert NS timings to ticks + uint32_t counter_clk_hz = 0; + +#if defined(HAS_ESP_IDF_4) + rmt_get_counter_clock(channel, &counter_clk_hz); +#else + // this emulates the rmt_get_counter_clock() function from ESP-IDF 3.4 + if (RMT_LL_HW_BASE->conf_ch[config.channel].conf1.ref_always_on == RMT_BASECLK_REF) { + uint32_t div_cnt = RMT_LL_HW_BASE->conf_ch[config.channel].conf0.div_cnt; + uint32_t div = div_cnt == 0 ? 256 : div_cnt; + counter_clk_hz = REF_CLK_FREQ / (div); + } else { + uint32_t div_cnt = RMT_LL_HW_BASE->conf_ch[config.channel].conf0.div_cnt; + uint32_t div = div_cnt == 0 ? 256 : div_cnt; + counter_clk_hz = APB_CLK_FREQ / (div); + } +#endif + + // NS to tick converter + float ratio = (float)counter_clk_hz / 1e9; + + if (is800KHz) { + t0h_ticks = (uint32_t)(ratio * WS2812_T0H_NS); + t0l_ticks = (uint32_t)(ratio * WS2812_T0L_NS); + t1h_ticks = (uint32_t)(ratio * WS2812_T1H_NS); + t1l_ticks = (uint32_t)(ratio * WS2812_T1L_NS); + } else { + t0h_ticks = (uint32_t)(ratio * WS2811_T0H_NS); + t0l_ticks = (uint32_t)(ratio * WS2811_T0L_NS); + t1h_ticks = (uint32_t)(ratio * WS2811_T1H_NS); + t1l_ticks = (uint32_t)(ratio * WS2811_T1L_NS); + } + + // Initialize automatic timing translator + rmt_translator_init(config.channel, ws2812_rmt_adapter); + + // Write and wait to finish + rmt_write_sample(config.channel, pixels, (size_t)numBytes, true); + rmt_wait_tx_done(config.channel, pdMS_TO_TICKS(100)); + + // Free channel again + rmt_driver_uninstall(config.channel); + rmt_reserved_channels[channel] = false; + + gpio_set_direction(pin, GPIO_MODE_OUTPUT); +} + +#endif diff --git a/software/firmware/source/libraries/Adafruit_NeoPixel/esp8266.c b/software/firmware/source/libraries/Adafruit_NeoPixel/esp8266.c index b4d0c8653..863cc4de7 100644 --- a/software/firmware/source/libraries/Adafruit_NeoPixel/esp8266.c +++ b/software/firmware/source/libraries/Adafruit_NeoPixel/esp8266.c @@ -2,7 +2,7 @@ // ESP8266 work for the NeoPixelBus library: github.com/Makuna/NeoPixelBus // Needs to be a separate .c file to enforce ICACHE_RAM_ATTR execution. -#if defined(ESP8266) || defined(ESP32) +#if defined(ESP8266) #include #ifdef ESP8266 @@ -55,14 +55,6 @@ void espShow( } #endif -#if defined(ESP32) - delay(1); // required - - portMUX_TYPE updateMux = portMUX_INITIALIZER_UNLOCKED; - - taskENTER_CRITICAL(&updateMux); -#endif - for(t = time0;; t = time0) { if(pix & mask) t = time1; // Bit high duration while(((c = _getCycleCount()) - startTime) < period); // Wait for bit start @@ -85,10 +77,6 @@ void espShow( } } -#if defined(ESP32) - taskEXIT_CRITICAL(&updateMux); -#endif - while((_getCycleCount() - startTime) < period); // Wait for last bit }