release espressif32 Arduino core 3.0.3 based on IDF 5.1.4
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
```shell
|
||||
# Change directory to example
|
||||
$ cd platform-espressif32/examples/arduino-ble5-advertising
|
||||
|
||||
# Build project
|
||||
$ pio run
|
||||
|
||||
# Upload firmware
|
||||
$ pio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
$ pio run -e esp32-c3-devkitm-1
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
$ pio run -e esp32-c3-devkitm-1 --target upload
|
||||
|
||||
# Clean build files
|
||||
$ pio run --target clean
|
||||
```
|
||||
@@ -1,14 +0,0 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp32-c3-devkitm-1]
|
||||
platform = espressif32
|
||||
board = esp32-c3-devkitm-1
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
Simple BLE5 multi advertising example on esp32 C3/S3
|
||||
only ESP_BLE_GAP_SET_EXT_ADV_PROP_NONCONN_NONSCANNABLE_UNDIRECTED can be used for periodic advertising
|
||||
|
||||
author: chegewara
|
||||
*/
|
||||
|
||||
#include <BLEDevice.h>
|
||||
#include <BLEAdvertising.h>
|
||||
|
||||
|
||||
esp_ble_gap_ext_adv_params_t ext_adv_params_2M = {
|
||||
.type = ESP_BLE_GAP_SET_EXT_ADV_PROP_NONCONN_NONSCANNABLE_UNDIRECTED,
|
||||
.interval_min = 0x40,
|
||||
.interval_max = 0x40,
|
||||
.channel_map = ADV_CHNL_ALL,
|
||||
.own_addr_type = BLE_ADDR_TYPE_RANDOM,
|
||||
.filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY,
|
||||
.primary_phy = ESP_BLE_GAP_PHY_1M,
|
||||
.max_skip = 0,
|
||||
.secondary_phy = ESP_BLE_GAP_PHY_2M,
|
||||
.sid = 1,
|
||||
.scan_req_notif = false,
|
||||
};
|
||||
|
||||
static uint8_t raw_scan_rsp_data_2m[] = {
|
||||
0x02, 0x01, 0x06,
|
||||
0x02, 0x0a, 0xeb,
|
||||
0x12, 0x09, 'E', 'S', 'P', '_', 'M', 'U', 'L', 'T', 'I', '_', 'A',
|
||||
'D', 'V', '_', '2', 'M', 0X0
|
||||
};
|
||||
|
||||
static esp_ble_gap_periodic_adv_params_t periodic_adv_params = {
|
||||
.interval_min = 0x320, // 1000 ms interval
|
||||
.interval_max = 0x640,
|
||||
.properties = 0, // Do not include TX power
|
||||
};
|
||||
|
||||
static uint8_t periodic_adv_raw_data[] = {
|
||||
0x02, 0x01, 0x06,
|
||||
0x02, 0x0a, 0xeb,
|
||||
0x03, 0x03, 0xab, 0xcd,
|
||||
0x11, 0x09, 'E', 'S', 'P', '_', 'P', 'E', 'R', 'I', 'O', 'D', 'I',
|
||||
'C', '_', 'A', 'D', 'V'
|
||||
};
|
||||
|
||||
|
||||
uint8_t addr_2m[6] = {0xc0, 0xde, 0x52, 0x00, 0x00, 0x02};
|
||||
|
||||
BLEMultiAdvertising advert(1); // max number of advertisement data
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Multi-Advertising...");
|
||||
|
||||
BLEDevice::init("");
|
||||
|
||||
advert.setAdvertisingParams(0, &ext_adv_params_2M);
|
||||
advert.setAdvertisingData(0, sizeof(raw_scan_rsp_data_2m), &raw_scan_rsp_data_2m[0]);
|
||||
advert.setInstanceAddress(0, addr_2m);
|
||||
advert.setDuration(0, 0, 0);
|
||||
|
||||
delay(100);
|
||||
advert.start();
|
||||
advert.setPeriodicAdvertisingParams(0, &periodic_adv_params);
|
||||
advert.setPeriodicAdvertisingData(0, sizeof(periodic_adv_raw_data), &periodic_adv_raw_data[0]);
|
||||
advert.startPeriodicAdvertising(0);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
delay(2000);
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -1,7 +1,7 @@
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
||||
1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html)
|
||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp-wrover-kit]
|
||||
platform = espressif32
|
||||
@@ -13,39 +13,16 @@ framework = arduino
|
||||
board = esp-wrover-kit
|
||||
monitor_speed = 115200
|
||||
build_flags =
|
||||
; https://docs.espressif.com/projects/esp-idf/en/latest/get-started/get-started-wrover-kit.html#rgb-led
|
||||
-D LED_BUILTIN=2
|
||||
|
||||
[env:esp32doit-devkit-v1]
|
||||
-DLED_BUILTIN=2
|
||||
|
||||
[env:esp32-c6-devkitc-1]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32doit-devkit-v1
|
||||
board = esp32-c6-devkitc-1
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:lolin32]
|
||||
[env:esp32-h2-devkitm-1]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = lolin32
|
||||
board = esp32-h2-devkitm-1
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:lolin_c3_mini]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = lolin_c3_mini
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:esp32-s3-devkitc-1]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32-s3-devkitc-1
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:arduino_nano_esp32]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = arduino_nano_esp32
|
||||
|
||||
[env:adafruit_qtpy_esp32s3_n4r2]
|
||||
platform = espressif32
|
||||
board = adafruit_qtpy_esp32s3_n4r2
|
||||
framework = arduino
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
// Set LED_BUILTIN if it is not defined by Arduino framework
|
||||
#ifndef LED_BUILTIN
|
||||
#define LED_BUILTIN 2
|
||||
#endif
|
||||
// #define LED_BUILTIN 2
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
[env:esp32-s2]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32-s2-saola-1
|
||||
build_flags = -DBUILTIN_RGBLED_PIN=18
|
||||
-DNR_OF_LEDS=1
|
||||
|
||||
[env:esp32-s3]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32-s3-devkitc-1
|
||||
build_flags = -DBUILTIN_RGBLED_PIN=48
|
||||
-DNR_OF_LEDS=1
|
||||
|
||||
[env:esp32-c3]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32-c3-devkitm-1
|
||||
build_flags = -DBUILTIN_RGBLED_PIN=8
|
||||
-DNR_OF_LEDS=1
|
||||
|
||||
[env:esp32-c6]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32-c6-devkitm-1
|
||||
build_flags = -DBUILTIN_RGBLED_PIN=8
|
||||
-DNR_OF_LEDS=1
|
||||
@@ -0,0 +1,103 @@
|
||||
// Copyright 2023 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.
|
||||
|
||||
/**
|
||||
* @brief This example demonstrates usage of RGB LED driven by RMT
|
||||
*
|
||||
* The output is a visual WS2812 RGB LED color moving in a 8 x 4 LED matrix
|
||||
* Parameters can be changed by the user. In a single LED circuit, it will just blink.
|
||||
*/
|
||||
|
||||
// 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 // 48 or 38
|
||||
//#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
|
||||
|
||||
//
|
||||
// Note: This example uses Neopixel LED board, 32 LEDs chained one
|
||||
// after another, each RGB LED has its 24 bit value
|
||||
// for color configuration (8b for each color)
|
||||
//
|
||||
// Bits encoded as pulses as follows:
|
||||
//
|
||||
// "0":
|
||||
// +-------+ +--
|
||||
// | | |
|
||||
// | | |
|
||||
// | | |
|
||||
// ---| |--------------|
|
||||
// + + +
|
||||
// | 0.4us | 0.85 0us |
|
||||
//
|
||||
// "1":
|
||||
// +-------------+ +--
|
||||
// | | |
|
||||
// | | |
|
||||
// | | |
|
||||
// | | |
|
||||
// ---+ +-------+
|
||||
// | 0.8us | 0.4us |
|
||||
|
||||
rmt_data_t led_data[NR_OF_ALL_BITS];
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
if (!rmtInit(BUILTIN_RGBLED_PIN, RMT_TX_MODE, RMT_MEM_NUM_BLOCKS_1, 10000000)) {
|
||||
Serial.println("init sender failed\n");
|
||||
}
|
||||
Serial.println("real tick set to: 100ns");
|
||||
}
|
||||
|
||||
int color[] = { 0x55, 0x11, 0x77 }; // Green Red Blue values
|
||||
int led_index = 0;
|
||||
|
||||
void loop() {
|
||||
// Init data with only one led ON
|
||||
int led, col, bit;
|
||||
int i=0;
|
||||
for (led=0; led<NR_OF_LEDS; led++) {
|
||||
for (col=0; col<3; col++ ) {
|
||||
for (bit=0; bit<8; bit++){
|
||||
if ( (color[col] & (1<<(7-bit))) && (led == led_index) ) {
|
||||
led_data[i].level0 = 1;
|
||||
led_data[i].duration0 = 8;
|
||||
led_data[i].level1 = 0;
|
||||
led_data[i].duration1 = 4;
|
||||
} else {
|
||||
led_data[i].level0 = 1;
|
||||
led_data[i].duration0 = 4;
|
||||
led_data[i].level1 = 0;
|
||||
led_data[i].duration1 = 8;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// make the led travel in the pannel
|
||||
if ((++led_index)>=NR_OF_LEDS) {
|
||||
led_index = 0;
|
||||
}
|
||||
// Send the data and wait until it is done
|
||||
rmtWrite(BUILTIN_RGBLED_PIN, led_data, NR_OF_ALL_BITS, RMT_WAIT_FOR_EVER);
|
||||
delay(100);
|
||||
}
|
||||
@@ -14,6 +14,3 @@ monitor_speed = 115200
|
||||
|
||||
[env:esp32-s2-saola-1]
|
||||
board = esp32-s2-saola-1
|
||||
|
||||
[env:esp32-s2-kaluga-1]
|
||||
board = esp32-s2-kaluga-1
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -1,7 +1,7 @@
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
||||
1. [Install PlatformIO Core](http://docs.platformio.org/page/core.html)
|
||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
@@ -5,28 +5,10 @@
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp-wrover-kit]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp-wrover-kit
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:espea32]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = espea32
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:esp320]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp320
|
||||
monitor_speed = 115200
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -1,3 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(espidf-arduino-wifiscan)
|
||||
project(espidf-arduino-blink)
|
||||
|
||||
@@ -11,14 +11,20 @@
|
||||
platform = espressif32
|
||||
framework = arduino, espidf
|
||||
build_flags =
|
||||
-D CONFIG_BLINK_GPIO=2
|
||||
-DCONFIG_BLINK_GPIO=2
|
||||
monitor_speed = 115200
|
||||
board_build.embed_txtfiles =
|
||||
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||
|
||||
[env:esp32dev]
|
||||
board = esp32dev
|
||||
; FixMe: Linker error only with S3 and arduino,espidf
|
||||
;[env:esp32-s3]
|
||||
;board = 4d_systems_esp32s3_gen4_r8n16
|
||||
;build_flags =
|
||||
; -DCONFIG_BLINK_GPIO=2
|
||||
; -DARDUINO_PARTITION_esp_sr_16
|
||||
|
||||
[env:espea32]
|
||||
board = espea32
|
||||
|
||||
[env:esp320]
|
||||
board = esp320
|
||||
[env:esp32-c6-devkitm-1]
|
||||
board = esp32-c6-devkitm-1
|
||||
|
||||
@@ -1,5 +1,157 @@
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
|
||||
|
||||
#
|
||||
# SPI RAM config
|
||||
#
|
||||
CONFIG_SPIRAM_MODE_OCT=y
|
||||
CONFIG_SPIRAM_TYPE_AUTO=y
|
||||
CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY=y
|
||||
CONFIG_SPIRAM_SPEED_80M=y
|
||||
CONFIG_SPIRAM_SPEED=80
|
||||
CONFIG_SPIRAM_USE_MALLOC=y
|
||||
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096
|
||||
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
|
||||
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=0
|
||||
|
||||
CONFIG_AUTOSTART_ARDUINO=y
|
||||
# CONFIG_WS2812_LED_ENABLE is not set
|
||||
CONFIG_ARDUHAL_ESP_LOG=y
|
||||
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
|
||||
CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y
|
||||
CONFIG_BT_BLE_BLUFI_ENABLE=y
|
||||
CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y
|
||||
CONFIG_BT_BTC_TASK_STACK_SIZE=8192
|
||||
CONFIG_BT_BTU_TASK_STACK_SIZE=8192
|
||||
CONFIG_BLE_MESH=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_COMPILER_CXX_EXCEPTIONS=y
|
||||
CONFIG_COMPILER_STACK_CHECK_MODE_NORM=y
|
||||
CONFIG_COMPILER_WARN_WRITE_STRINGS=y
|
||||
CONFIG_ESP_HTTPS_SERVER_ENABLE=y
|
||||
CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH=y
|
||||
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
|
||||
CONFIG_ESP_IPC_TASK_STACK_SIZE=1024
|
||||
CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096
|
||||
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2048
|
||||
CONFIG_ESP_TASK_WDT_PANIC=y
|
||||
CONFIG_ESP_TIMER_TASK_STACK_SIZE=4096
|
||||
CONFIG_ESP_WIFI_FTM_ENABLE=y
|
||||
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=8
|
||||
CONFIG_ESP_WIFI_STATIC_TX_BUFFER_NUM=8
|
||||
CONFIG_ESP_WIFI_CACHE_TX_BUFFER_NUM=16
|
||||
CONFIG_ESP_WIFI_CSI_ENABLED=y
|
||||
CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y
|
||||
# CONFIG_ESP_WIFI_IRAM_OPT is not set
|
||||
# CONFIG_ESP_WIFI_RX_IRAM_OPT is not set
|
||||
CONFIG_ETH_SPI_ETHERNET_DM9051=y
|
||||
CONFIG_ETH_SPI_ETHERNET_W5500=y
|
||||
CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y
|
||||
CONFIG_FATFS_CODEPAGE_850=y
|
||||
CONFIG_FATFS_LFN_STACK=y
|
||||
# CONFIG_FATFS_API_ENCODING_ANSI_OEM is not set
|
||||
CONFIG_FATFS_API_ENCODING_UTF_8=y
|
||||
CONFIG_FATFS_USE_LABEL=y
|
||||
# CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT is not set
|
||||
CONFIG_FMB_TIMER_PORT_ENABLED=y
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
|
||||
# CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION is not set
|
||||
CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1024
|
||||
CONFIG_HEAP_POISONING_LIGHT=y
|
||||
CONFIG_HTTPD_MAX_REQ_HDR_LEN=1024
|
||||
CONFIG_HTTPD_WS_SUPPORT=y
|
||||
# CONFIG_LOG_COLORS is not set
|
||||
CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y
|
||||
# CONFIG_LWIP_DHCP_DOES_ARP_CHECK is not set
|
||||
CONFIG_LWIP_TCP_SYNMAXRTX=6
|
||||
CONFIG_LWIP_TCP_MSS=1436
|
||||
CONFIG_LWIP_TCP_RTO_TIME=3000
|
||||
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=4096
|
||||
CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0=y
|
||||
CONFIG_LWIP_MAX_SOCKETS=16
|
||||
CONFIG_LWIP_IP_FORWARD=y
|
||||
CONFIG_LWIP_IPV4_NAPT=y
|
||||
CONFIG_LWIP_DHCP_RESTORE_LAST_IP=n
|
||||
CONFIG_LWIP_DHCP_OPTIONS_LEN=128
|
||||
CONFIG_LWIP_SNTP_MAX_SERVERS=3
|
||||
CONFIG_LWIP_SNTP_UPDATE_DELAY=10800000
|
||||
CONFIG_LWIP_DHCP_GET_NTP_SRV=y
|
||||
CONFIG_LWIP_IPV6_AUTOCONFIG=y
|
||||
CONFIG_LWIP_IPV6_DHCP6=y
|
||||
CONFIG_LWIP_IPV6_RDNSS_MAX_DNS_SERVERS=2
|
||||
CONFIG_LWIP_PPP_SUPPORT=y
|
||||
CONFIG_LWIP_PPP_NOTIFY_PHASE_SUPPORT=y
|
||||
CONFIG_LWIP_PPP_PAP_SUPPORT=y
|
||||
CONFIG_LWIP_PPP_ENABLE_IPV6=n
|
||||
CONFIG_MBEDTLS_PSK_MODES=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
||||
CONFIG_MBEDTLS_CAMELLIA_C=y
|
||||
# CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN is not set
|
||||
CONFIG_MBEDTLS_SSL_PROTO_DTLS=y
|
||||
CONFIG_OPENSSL_ASSERT_DO_NOTHING=y
|
||||
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048
|
||||
CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y
|
||||
CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=10
|
||||
CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=2
|
||||
CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096
|
||||
# CONFIG_SPI_MASTER_ISR_IN_IRAM is not set
|
||||
# CONFIG_SPI_SLAVE_ISR_IN_IRAM is not set
|
||||
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=4096
|
||||
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=0
|
||||
CONFIG_ESP_RMAKER_SKIP_VERSION_CHECK=y
|
||||
CONFIG_ESP_RMAKER_USER_ID_CHECK=y
|
||||
CONFIG_ESP_INSIGHTS_ENABLED=y
|
||||
CONFIG_ESP_INSIGHTS_COREDUMP_ENABLE=n
|
||||
CONFIG_ESP_INSIGHTS_TRANSPORT_HTTPS=y
|
||||
CONFIG_DIAG_LOG_DROP_WIFI_LOGS=y
|
||||
CONFIG_DIAG_ENABLE_METRICS=y
|
||||
CONFIG_DIAG_ENABLE_HEAP_METRICS=y
|
||||
CONFIG_DIAG_ENABLE_WIFI_METRICS=y
|
||||
CONFIG_DIAG_ENABLE_VARIABLES=y
|
||||
CONFIG_DIAG_ENABLE_NETWORK_VARIABLES=y
|
||||
CONFIG_ESP_COREDUMP_ENABLE=y
|
||||
CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=n
|
||||
CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF=y
|
||||
CONFIG_ESP_COREDUMP_CHECKSUM_CRC32=y
|
||||
CONFIG_ESP_COREDUMP_MAX_TASKS_NUM=64
|
||||
CONFIG_ESP_COREDUMP_STACK_SIZE=1024
|
||||
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
|
||||
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_SR_WN_WN9_HIESP=y
|
||||
CONFIG_SR_MN_CN_NONE=y
|
||||
CONFIG_SR_MN_EN_MULTINET5_SINGLE_RECOGNITION_QUANT8=y
|
||||
CONFIG_EN_SPEECH_COMMAND_ID0=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID1=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID2=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID3=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID4=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID5=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID6=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID7=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID8=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID9=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID10=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID11=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID12=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID13=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID14=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID15=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID16=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID17=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID18=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID19=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID20=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID21=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID22=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID23=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID24=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID25=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID26=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID27=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID28=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID29=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID30=""
|
||||
CONFIG_EN_SPEECH_COMMAND_ID31=""
|
||||
|
||||
@@ -29,7 +29,7 @@ void blink_task(void *pvParameter)
|
||||
Technical Reference for a list of pads and their default
|
||||
functions.)
|
||||
*/
|
||||
gpio_pad_select_gpio(BLINK_GPIO);
|
||||
esp_rom_gpio_pad_select_gpio(BLINK_GPIO);
|
||||
/* Set the GPIO as a push/pull output */
|
||||
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
||||
while(1) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.pio
|
||||
.vscode
|
||||
@@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(espidf-arduino-littlefs)
|
||||
@@ -0,0 +1 @@
|
||||
# Arduino_IDF_LittleFS
|
||||
@@ -0,0 +1 @@
|
||||
aaa
|
||||
@@ -0,0 +1 @@
|
||||
bbb
|
||||
@@ -0,0 +1,7 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
nvs, data, nvs, 0x9000, 0x5000,
|
||||
otadata, data, ota, 0xe000, 0x2000,
|
||||
app0, app, ota_0, 0x10000, 0x140000,
|
||||
app1, app, ota_1, 0x150000,0x140000,
|
||||
spiffs, data, spiffs, 0x290000,0x160000,
|
||||
coredump, data, coredump,0x3F0000,0x10000,
|
||||
|
@@ -0,0 +1,24 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env]
|
||||
platform = espressif32
|
||||
framework = arduino, espidf
|
||||
monitor_speed = 115200
|
||||
board_build.embed_txtfiles =
|
||||
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||
|
||||
[env:esp32dev]
|
||||
board = esp32dev
|
||||
board_build.filesystem = littlefs
|
||||
board_build.partitions = partitions_custom.csv
|
||||
@@ -0,0 +1,9 @@
|
||||
CONFIG_AUTOSTART_ARDUINO=y
|
||||
# CONFIG_WS2812_LED_ENABLE is not set
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_MBEDTLS_PSK_MODES=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
|
||||
@@ -0,0 +1,6 @@
|
||||
# This file was automatically generated for projects
|
||||
# without default 'CMakeLists.txt' file.
|
||||
|
||||
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
|
||||
|
||||
idf_component_register(SRCS ${app_sources})
|
||||
@@ -0,0 +1,282 @@
|
||||
#include <Arduino.h>
|
||||
#include "FS.h"
|
||||
#include <LittleFS.h>
|
||||
#include <time.h>
|
||||
|
||||
/* You only need to format LittleFS the first time you run a
|
||||
test or else use the LITTLEFS plugin to create a partition
|
||||
https://github.com/lorol/arduino-esp32littlefs-plugin */
|
||||
|
||||
#define FORMAT_LITTLEFS_IF_FAILED true
|
||||
|
||||
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
|
||||
Serial.printf("Listing directory: %s\r\n", dirname);
|
||||
|
||||
File root = fs.open(dirname);
|
||||
if(!root){
|
||||
Serial.println("- failed to open directory");
|
||||
return;
|
||||
}
|
||||
if(!root.isDirectory()){
|
||||
Serial.println(" - not a directory");
|
||||
return;
|
||||
}
|
||||
|
||||
File file = root.openNextFile();
|
||||
while(file){
|
||||
if(file.isDirectory()){
|
||||
Serial.print(" DIR : ");
|
||||
|
||||
Serial.print(file.name());
|
||||
time_t t= file.getLastWrite();
|
||||
struct tm * tmstruct = localtime(&t);
|
||||
Serial.printf(" LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n",(tmstruct->tm_year)+1900,( tmstruct->tm_mon)+1, tmstruct->tm_mday,tmstruct->tm_hour , tmstruct->tm_min, tmstruct->tm_sec);
|
||||
|
||||
if(levels){
|
||||
listDir(fs, file.name(), levels -1);
|
||||
}
|
||||
} else {
|
||||
Serial.print(" FILE: ");
|
||||
Serial.print(file.name());
|
||||
Serial.print(" SIZE: ");
|
||||
|
||||
Serial.print(file.size());
|
||||
time_t t= file.getLastWrite();
|
||||
struct tm * tmstruct = localtime(&t);
|
||||
Serial.printf(" LAST WRITE: %d-%02d-%02d %02d:%02d:%02d\n",(tmstruct->tm_year)+1900,( tmstruct->tm_mon)+1, tmstruct->tm_mday,tmstruct->tm_hour , tmstruct->tm_min, tmstruct->tm_sec);
|
||||
}
|
||||
file = root.openNextFile();
|
||||
}
|
||||
}
|
||||
|
||||
void createDir(fs::FS &fs, const char * path){
|
||||
Serial.printf("Creating Dir: %s\n", path);
|
||||
if(fs.mkdir(path)){
|
||||
Serial.println("Dir created");
|
||||
} else {
|
||||
Serial.println("mkdir failed");
|
||||
}
|
||||
}
|
||||
|
||||
void removeDir(fs::FS &fs, const char * path){
|
||||
Serial.printf("Removing Dir: %s\n", path);
|
||||
if(fs.rmdir(path)){
|
||||
Serial.println("Dir removed");
|
||||
} else {
|
||||
Serial.println("rmdir failed");
|
||||
}
|
||||
}
|
||||
|
||||
void readFile(fs::FS &fs, const char * path){
|
||||
Serial.printf("Reading file: %s\r\n", path);
|
||||
|
||||
File file = fs.open(path);
|
||||
if(!file || file.isDirectory()){
|
||||
Serial.println("- failed to open file for reading");
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.println("- read from file:");
|
||||
while(file.available()){
|
||||
Serial.write(file.read());
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
void writeFile(fs::FS &fs, const char * path, const char * message){
|
||||
Serial.printf("Writing file: %s\r\n", path);
|
||||
|
||||
File file = fs.open(path, FILE_WRITE);
|
||||
if(!file){
|
||||
Serial.println("- failed to open file for writing");
|
||||
return;
|
||||
}
|
||||
if(file.print(message)){
|
||||
Serial.println("- file written");
|
||||
} else {
|
||||
Serial.println("- write failed");
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
void appendFile(fs::FS &fs, const char * path, const char * message){
|
||||
Serial.printf("Appending to file: %s\r\n", path);
|
||||
|
||||
File file = fs.open(path, FILE_APPEND);
|
||||
if(!file){
|
||||
Serial.println("- failed to open file for appending");
|
||||
return;
|
||||
}
|
||||
if(file.print(message)){
|
||||
Serial.println("- message appended");
|
||||
} else {
|
||||
Serial.println("- append failed");
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
void renameFile(fs::FS &fs, const char * path1, const char * path2){
|
||||
Serial.printf("Renaming file %s to %s\r\n", path1, path2);
|
||||
if (fs.rename(path1, path2)) {
|
||||
Serial.println("- file renamed");
|
||||
} else {
|
||||
Serial.println("- rename failed");
|
||||
}
|
||||
}
|
||||
|
||||
void deleteFile(fs::FS &fs, const char * path){
|
||||
Serial.printf("Deleting file: %s\r\n", path);
|
||||
if(fs.remove(path)){
|
||||
Serial.println("- file deleted");
|
||||
} else {
|
||||
Serial.println("- delete failed");
|
||||
}
|
||||
}
|
||||
|
||||
// SPIFFS-like write and delete file
|
||||
|
||||
// See: https://github.com/esp8266/Arduino/blob/master/libraries/LittleFS/src/LittleFS.cpp#L60
|
||||
void writeFile2(fs::FS &fs, const char * path, const char * message){
|
||||
if(!fs.exists(path)){
|
||||
if (strchr(path, '/')) {
|
||||
Serial.printf("Create missing folders of: %s\r\n", path);
|
||||
char *pathStr = strdup(path);
|
||||
if (pathStr) {
|
||||
char *ptr = strchr(pathStr, '/');
|
||||
while (ptr) {
|
||||
*ptr = 0;
|
||||
fs.mkdir(pathStr);
|
||||
*ptr = '/';
|
||||
ptr = strchr(ptr+1, '/');
|
||||
}
|
||||
}
|
||||
free(pathStr);
|
||||
}
|
||||
}
|
||||
|
||||
Serial.printf("Writing file to: %s\r\n", path);
|
||||
File file = fs.open(path, FILE_WRITE);
|
||||
if(!file){
|
||||
Serial.println("- failed to open file for writing");
|
||||
return;
|
||||
}
|
||||
if(file.print(message)){
|
||||
Serial.println("- file written");
|
||||
} else {
|
||||
Serial.println("- write failed");
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
// See: https://github.com/esp8266/Arduino/blob/master/libraries/LittleFS/src/LittleFS.h#L149
|
||||
void deleteFile2(fs::FS &fs, const char * path){
|
||||
Serial.printf("Deleting file and empty folders on path: %s\r\n", path);
|
||||
|
||||
if(fs.remove(path)){
|
||||
Serial.println("- file deleted");
|
||||
} else {
|
||||
Serial.println("- delete failed");
|
||||
}
|
||||
|
||||
char *pathStr = strdup(path);
|
||||
if (pathStr) {
|
||||
char *ptr = strrchr(pathStr, '/');
|
||||
if (ptr) {
|
||||
Serial.printf("Removing all empty folders on path: %s\r\n", path);
|
||||
}
|
||||
while (ptr) {
|
||||
*ptr = 0;
|
||||
fs.rmdir(pathStr);
|
||||
ptr = strrchr(pathStr, '/');
|
||||
}
|
||||
free(pathStr);
|
||||
}
|
||||
}
|
||||
|
||||
void testFileIO(fs::FS &fs, const char * path){
|
||||
Serial.printf("Testing file I/O with %s\r\n", path);
|
||||
|
||||
static uint8_t buf[512];
|
||||
size_t len = 0;
|
||||
File file = fs.open(path, FILE_WRITE);
|
||||
if(!file){
|
||||
Serial.println("- failed to open file for writing");
|
||||
return;
|
||||
}
|
||||
|
||||
size_t i;
|
||||
Serial.print("- writing" );
|
||||
uint32_t start = millis();
|
||||
for(i=0; i<2048; i++){
|
||||
if ((i & 0x001F) == 0x001F){
|
||||
Serial.print(".");
|
||||
}
|
||||
file.write(buf, 512);
|
||||
}
|
||||
Serial.println("");
|
||||
uint32_t end = millis() - start;
|
||||
Serial.printf(" - %u bytes written in %u ms\r\n", 2048 * 512, (unsigned int)end);
|
||||
file.close();
|
||||
|
||||
file = fs.open(path);
|
||||
start = millis();
|
||||
end = start;
|
||||
i = 0;
|
||||
if(file && !file.isDirectory()){
|
||||
len = file.size();
|
||||
size_t flen = len;
|
||||
start = millis();
|
||||
Serial.print("- reading" );
|
||||
while(len){
|
||||
size_t toRead = len;
|
||||
if(toRead > 512){
|
||||
toRead = 512;
|
||||
}
|
||||
file.read(buf, toRead);
|
||||
if ((i++ & 0x001F) == 0x001F){
|
||||
Serial.print(".");
|
||||
}
|
||||
len -= toRead;
|
||||
}
|
||||
Serial.println("");
|
||||
end = millis() - start;
|
||||
Serial.printf("- %u bytes read in %u ms\r\n", flen, (unsigned int)end);
|
||||
file.close();
|
||||
} else {
|
||||
Serial.println("- failed to open file for reading");
|
||||
}
|
||||
}
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
|
||||
Serial.println("LittleFS Mount Failed");
|
||||
return;
|
||||
}
|
||||
|
||||
listDir(LittleFS, "/", 0);
|
||||
createDir(LittleFS, "/mydir");
|
||||
writeFile(LittleFS, "/mydir/hello2.txt", "Hello2");
|
||||
//writeFile(LittleFS, "/mydir/newdir2/newdir3/hello3.txt", "Hello3");
|
||||
writeFile2(LittleFS, "/mydir/newdir2/newdir3/hello3.txt", "Hello3");
|
||||
listDir(LittleFS, "/", 3);
|
||||
deleteFile(LittleFS, "/mydir/hello2.txt");
|
||||
//deleteFile(LittleFS, "/mydir/newdir2/newdir3/hello3.txt");
|
||||
deleteFile2(LittleFS, "/mydir/newdir2/newdir3/hello3.txt");
|
||||
removeDir(LittleFS, "/mydir");
|
||||
listDir(LittleFS, "/", 3);
|
||||
writeFile(LittleFS, "/hello.txt", "Hello ");
|
||||
appendFile(LittleFS, "/hello.txt", "World!\r\n");
|
||||
readFile(LittleFS, "/hello.txt");
|
||||
renameFile(LittleFS, "/hello.txt", "/foo.txt");
|
||||
readFile(LittleFS, "/foo.txt");
|
||||
deleteFile(LittleFS, "/foo.txt");
|
||||
testFileIO(LittleFS, "/test.txt");
|
||||
deleteFile(LittleFS, "/test.txt");
|
||||
|
||||
Serial.println( "Test complete" );
|
||||
}
|
||||
|
||||
void loop(){
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -11,9 +11,12 @@
|
||||
platform = espressif32
|
||||
framework = arduino, espidf
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:esp32dev]
|
||||
board = esp32dev
|
||||
board_build.esp-idf.preserve_source_file_extension = yes
|
||||
board_build.embed_txtfiles =
|
||||
managed_components/espressif__esp_insights/server_certs/https_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_mqtt_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_claim_service_server.crt
|
||||
managed_components/espressif__esp_rainmaker/server_certs/rmaker_ota_server.crt
|
||||
|
||||
[env:esp-wrover-kit]
|
||||
board = esp-wrover-kit
|
||||
|
||||
@@ -3,6 +3,10 @@ CONFIG_AUTOSTART_ARDUINO=y
|
||||
CONFIG_FREERTOS_HZ=1000
|
||||
CONFIG_MBEDTLS_PSK_MODES=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_PSK=y
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
|
||||
# Example config
|
||||
CONFIG_EXAMPLE_WIFI_SSID="MYSSID"
|
||||
CONFIG_EXAMPLE_WIFI_PASSWORD="MYPASS"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
.pio
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -1,6 +0,0 @@
|
||||
# The following lines of boilerplate have to be in your project's CMakeLists
|
||||
# in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(ble_eddystone_demo)
|
||||
@@ -1,27 +0,0 @@
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
```shell
|
||||
# Change directory to example
|
||||
$ cd platform-espressif32/examples/espidf-ble-eddystone
|
||||
|
||||
# Build project
|
||||
$ pio run
|
||||
|
||||
# Upload firmware
|
||||
$ pio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
$ pio run -e esp32dev
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
$ pio run -e esp32dev --target upload
|
||||
|
||||
# Clean build files
|
||||
$ pio run --target clean
|
||||
```
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -1,14 +0,0 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
@@ -1,6 +0,0 @@
|
||||
# Override some defaults so BT stack is enabled
|
||||
# and WiFi disabled by default in this example
|
||||
CONFIG_BT_ENABLED=y
|
||||
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
|
||||
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
|
||||
CONFIG_BTDM_CTRL_MODE_BTDM=n
|
||||
@@ -1,4 +0,0 @@
|
||||
idf_component_register(SRCS "esp_eddystone_api.c"
|
||||
"esp_eddystone_demo.c"
|
||||
INCLUDE_DIRS "")
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
@@ -1,251 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* This file is used to decode eddystone information.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
#include "esp_eddystone_protocol.h"
|
||||
#include "esp_eddystone_api.h"
|
||||
|
||||
|
||||
/* Declare static functions */
|
||||
static esp_err_t esp_eddystone_uid_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
||||
static esp_err_t esp_eddystone_url_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
||||
static char* esp_eddystone_resolve_url_scheme(const uint8_t* url_start, const uint8_t* url_end);
|
||||
static esp_err_t esp_eddystone_tlm_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
||||
static esp_err_t esp_eddystone_get_inform(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
||||
|
||||
/* Eddystone-URL scheme prefixes */
|
||||
static const char* eddystone_url_prefix[4] = {
|
||||
"http://www.",
|
||||
"https://www.",
|
||||
"http://",
|
||||
"https://"
|
||||
};
|
||||
|
||||
/* Eddystone-URL HTTP URL encoding */
|
||||
static const char* eddystone_url_encoding[14] = {
|
||||
".com/",
|
||||
".org/",
|
||||
".edu/",
|
||||
".net/",
|
||||
".info/",
|
||||
".biz/",
|
||||
".gov/",
|
||||
".com",
|
||||
".org",
|
||||
".edu",
|
||||
".net",
|
||||
".info",
|
||||
".biz",
|
||||
".gov"
|
||||
};
|
||||
|
||||
/****************** Eddystone-UID **************
|
||||
Byte offset Field Description
|
||||
0 Frame Type Value = 0x00
|
||||
1 Ranging Data Calibrated Tx power at 0 m
|
||||
2 NID[0] 10-byte Namespace
|
||||
3 NID[1]
|
||||
4 NID[2]
|
||||
5 NID[3]
|
||||
6 NID[4]
|
||||
7 NID[5]
|
||||
8 NID[6]
|
||||
9 NID[7]
|
||||
10 NID[8]
|
||||
11 NID[9]
|
||||
12 BID[0] 6-byte Instance
|
||||
13 BID[1]
|
||||
14 BID[2]
|
||||
15 BID[3]
|
||||
16 BID[4]
|
||||
17 BID[5]
|
||||
18 RFU Reserved for future use, must be0x00
|
||||
19 RFU Reserved for future use, must be0x00
|
||||
*********************************************/
|
||||
/* decode and store received UID */
|
||||
static esp_err_t esp_eddystone_uid_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
||||
{
|
||||
uint8_t pos = 0;
|
||||
//1-byte Ranging Data + 10-byte Namespace + 6-byte Instance
|
||||
if((len != EDDYSTONE_UID_DATA_LEN) && (len != (EDDYSTONE_UID_RFU_LEN+EDDYSTONE_UID_DATA_LEN))) {
|
||||
//ERROR:uid len wrong
|
||||
return -1;
|
||||
}
|
||||
res->inform.uid.ranging_data = buf[pos++];
|
||||
for(int i=0; i<EDDYSTONE_UID_NAMESPACE_LEN; i++) {
|
||||
res->inform.uid.namespace_id[i] = buf[pos++];
|
||||
}
|
||||
for(int i=0; i<EDDYSTONE_UID_INSTANCE_LEN; i++) {
|
||||
res->inform.uid.instance_id[i] = buf[pos++];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* resolve received URL to url_res pointer */
|
||||
static char* esp_eddystone_resolve_url_scheme(const uint8_t *url_start, const uint8_t *url_end)
|
||||
{
|
||||
int pos = 0;
|
||||
static char url_buf[100] = {0};
|
||||
const uint8_t *p = url_start;
|
||||
|
||||
pos += sprintf(&url_buf[pos], "%s", eddystone_url_prefix[*p++]);
|
||||
|
||||
for (; p <= url_end; p++) {
|
||||
if (esp_eddystone_is_char_invalid((*p))) {
|
||||
pos += sprintf(&url_buf[pos], "%s", eddystone_url_encoding[*p]);
|
||||
} else {
|
||||
pos += sprintf(&url_buf[pos], "%c", *p);
|
||||
}
|
||||
}
|
||||
return url_buf;
|
||||
}
|
||||
|
||||
/************************** Eddystone-URL *************
|
||||
Frame Specification
|
||||
Byte offset Field Description
|
||||
0 Frame Type Value = 0x10
|
||||
1 TX Power Calibrated Tx power at 0 m
|
||||
2 URL Scheme Encoded Scheme Prefix
|
||||
3+ Encoded URL Length 1-17
|
||||
*******************************************************/
|
||||
/* decode and store received URL, the pointer url_res points to the resolved url */
|
||||
static esp_err_t esp_eddystone_url_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
||||
{
|
||||
char *url_res = NULL;
|
||||
uint8_t pos = 0;
|
||||
if(len-EDDYSTONE_URL_TX_POWER_LEN > EDDYSTONE_URL_MAX_LEN) {
|
||||
//ERROR:too long url
|
||||
return -1;
|
||||
}
|
||||
res->inform.url.tx_power = buf[pos++];
|
||||
url_res = esp_eddystone_resolve_url_scheme(buf+pos, buf+len-1);
|
||||
memcpy(&res->inform.url.url, url_res, strlen(url_res));
|
||||
res->inform.url.url[strlen(url_res)] = '\0';
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************** eddystone-tlm ***************
|
||||
* Unencrypted TLM Frame Specification
|
||||
Byte offset Field Description
|
||||
0 Frame Type Value = 0x20
|
||||
1 Version TLM version, value = 0x00
|
||||
2 VBATT[0] Battery voltage, 1 mV/bit
|
||||
3 VBATT[1]
|
||||
4 TEMP[0] Beacon temperature
|
||||
5 TEMP[1]
|
||||
6 ADV_CNT[0] Advertising PDU count
|
||||
7 ADV_CNT[1]
|
||||
8 ADV_CNT[2]
|
||||
9 ADV_CNT[3]
|
||||
10 SEC_CNT[0] Time since power-on or reboot
|
||||
11 SEC_CNT[1]
|
||||
12 SEC_CNT[2]
|
||||
13 SEC_CNT[3]
|
||||
************************************************/
|
||||
/* decode and store received TLM */
|
||||
static esp_err_t esp_eddystone_tlm_received(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
||||
{
|
||||
uint8_t pos = 0;
|
||||
if(len > EDDYSTONE_TLM_DATA_LEN) {
|
||||
//ERROR:TLM too long
|
||||
return -1;
|
||||
}
|
||||
res->inform.tlm.version = buf[pos++];
|
||||
res->inform.tlm.battery_voltage = big_endian_read_16(buf, pos);
|
||||
pos += 2;
|
||||
uint16_t temp = big_endian_read_16(buf, pos);
|
||||
int8_t temp_integral = (int8_t)((temp >> 8) & 0xff);
|
||||
float temp_decimal = (temp & 0xff) / 256.0;
|
||||
res->inform.tlm.temperature = temp_integral + temp_decimal;
|
||||
pos += 2;
|
||||
res->inform.tlm.adv_count = big_endian_read_32(buf, pos);
|
||||
pos += 4;
|
||||
res->inform.tlm.time = big_endian_read_32(buf, pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static esp_err_t esp_eddystone_get_inform(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
||||
{
|
||||
static esp_err_t ret=-1;
|
||||
switch(res->common.frame_type)
|
||||
{
|
||||
case EDDYSTONE_FRAME_TYPE_UID: {
|
||||
ret = esp_eddystone_uid_received(buf, len, res);
|
||||
break;
|
||||
}
|
||||
case EDDYSTONE_FRAME_TYPE_URL: {
|
||||
ret = esp_eddystone_url_received(buf, len, res);
|
||||
break;
|
||||
}
|
||||
case EDDYSTONE_FRAME_TYPE_TLM: {
|
||||
ret = esp_eddystone_tlm_received(buf, len, res);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res)
|
||||
{
|
||||
if (len == 0 || buf == NULL || res == NULL) {
|
||||
return -1;
|
||||
}
|
||||
uint8_t pos=0;
|
||||
while(res->common.srv_data_type != EDDYSTONE_SERVICE_UUID)
|
||||
{
|
||||
pos++;
|
||||
if(pos >= len ) {
|
||||
return -1;
|
||||
}
|
||||
uint8_t ad_type = buf[pos++];
|
||||
switch(ad_type)
|
||||
{
|
||||
case ESP_BLE_AD_TYPE_FLAG: {
|
||||
res->common.flags = buf[pos++];
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_AD_TYPE_16SRV_CMPL: {
|
||||
uint16_t uuid = little_endian_read_16(buf, pos);
|
||||
if(uuid != EDDYSTONE_SERVICE_UUID) {
|
||||
return -1;
|
||||
}
|
||||
res->common.srv_uuid = uuid;
|
||||
pos += 2;
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_AD_TYPE_SERVICE_DATA: {
|
||||
uint16_t type = little_endian_read_16(buf, pos);
|
||||
pos += 2;
|
||||
uint8_t frame_type = buf[pos++];
|
||||
if(type != EDDYSTONE_SERVICE_UUID || !(frame_type == EDDYSTONE_FRAME_TYPE_UID || frame_type == EDDYSTONE_FRAME_TYPE_URL ||
|
||||
frame_type == EDDYSTONE_FRAME_TYPE_TLM)) {
|
||||
return -1;
|
||||
}
|
||||
res->common.srv_data_type = type;
|
||||
res->common.frame_type = frame_type;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return esp_eddystone_get_inform(buf+pos, len-pos, res);
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __ESP_EDDYSTONE_API_H__
|
||||
#define __ESP_EDDYSTONE_API_H__
|
||||
|
||||
typedef struct {
|
||||
struct {
|
||||
uint8_t flags; /*<! AD flags data */
|
||||
uint16_t srv_uuid; /*<! complete list of 16-bit service uuid*/
|
||||
uint16_t srv_data_type; /*<! service data type */
|
||||
uint8_t frame_type; /*<! Eddystone UID, URL or TLM */
|
||||
} common;
|
||||
union {
|
||||
struct {
|
||||
/*<! Eddystone-UID */
|
||||
int8_t ranging_data; /*<! calibrated Tx power at 0m */
|
||||
uint8_t namespace_id[10];
|
||||
uint8_t instance_id[6];
|
||||
} uid;
|
||||
struct {
|
||||
/*<! Eddystone-URL */
|
||||
int8_t tx_power; /*<! calibrated Tx power at 0m */
|
||||
char url[EDDYSTONE_URL_MAX_LEN]; /*<! the decoded URL */
|
||||
} url;
|
||||
struct {
|
||||
/*<! Eddystone-TLM */
|
||||
uint8_t version; /*<! TLM version,0x00 for now */
|
||||
uint16_t battery_voltage; /*<! battery voltage in mV */
|
||||
float temperature; /*<! beacon temperature in degrees Celsius */
|
||||
uint32_t adv_count; /*<! adv pdu count since power-up */
|
||||
uint32_t time; /*<! time since power-up, a 0.1 second resolution counter */
|
||||
} tlm;
|
||||
} inform;
|
||||
} esp_eddystone_result_t;
|
||||
|
||||
/* utils */
|
||||
static inline uint16_t little_endian_read_16(const uint8_t *buffer, uint8_t pos)
|
||||
{
|
||||
return ((uint16_t)buffer[pos]) | (((uint16_t)buffer[(pos)+1]) << 8);
|
||||
}
|
||||
|
||||
static inline uint16_t big_endian_read_16(const uint8_t *buffer, uint8_t pos)
|
||||
{
|
||||
return (((uint16_t)buffer[pos]) << 8) | ((uint16_t)buffer[(pos)+1]);
|
||||
}
|
||||
|
||||
static inline uint32_t big_endian_read_32(const uint8_t *buffer, uint8_t pos)
|
||||
{
|
||||
return (((uint32_t)buffer[pos]) << 24) | (((uint32_t)buffer[(pos)+1]) << 16) | (((uint32_t)buffer[(pos)+2]) << 8) | ((uint32_t)buffer[(pos)+3]);
|
||||
}
|
||||
|
||||
/*
|
||||
* The esp eddystone API.
|
||||
* This function is called to decode eddystone information from adv_data.
|
||||
* The res points to the result struct.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_eddystone_decode(const uint8_t* buf, uint8_t len, esp_eddystone_result_t* res);
|
||||
|
||||
//bool esp_eddystone_is_eddystone_packet(.....);
|
||||
|
||||
#endif /* __ESP_EDDYSTONE_API_H__ */
|
||||
@@ -1,173 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* This file is used for eddystone receiver.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_bt_defs.h"
|
||||
#include "esp_bt_main.h"
|
||||
#include "esp_gatt_defs.h"
|
||||
#include "esp_gattc_api.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
#include "esp_eddystone_protocol.h"
|
||||
#include "esp_eddystone_api.h"
|
||||
|
||||
static const char* DEMO_TAG = "EDDYSTONE_DEMO";
|
||||
|
||||
/* declare static functions */
|
||||
static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param);
|
||||
static void esp_eddystone_show_inform(const esp_eddystone_result_t* res);
|
||||
|
||||
static esp_ble_scan_params_t ble_scan_params = {
|
||||
.scan_type = BLE_SCAN_TYPE_ACTIVE,
|
||||
.own_addr_type = BLE_ADDR_TYPE_PUBLIC,
|
||||
.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL,
|
||||
.scan_interval = 0x50,
|
||||
.scan_window = 0x30,
|
||||
.scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE
|
||||
};
|
||||
|
||||
static void esp_eddystone_show_inform(const esp_eddystone_result_t* res)
|
||||
{
|
||||
switch(res->common.frame_type)
|
||||
{
|
||||
case EDDYSTONE_FRAME_TYPE_UID: {
|
||||
ESP_LOGI(DEMO_TAG, "Eddystone UID inform:");
|
||||
ESP_LOGI(DEMO_TAG, "Measured power(RSSI at 0m distance):%d dbm", res->inform.uid.ranging_data);
|
||||
ESP_LOGI(DEMO_TAG, "EDDYSTONE_DEMO: Namespace ID:0x");
|
||||
esp_log_buffer_hex(DEMO_TAG, res->inform.uid.namespace_id, 10);
|
||||
ESP_LOGI(DEMO_TAG, "EDDYSTONE_DEMO: Instance ID:0x");
|
||||
esp_log_buffer_hex(DEMO_TAG, res->inform.uid.instance_id, 6);
|
||||
break;
|
||||
}
|
||||
case EDDYSTONE_FRAME_TYPE_URL: {
|
||||
ESP_LOGI(DEMO_TAG, "Eddystone URL inform:");
|
||||
ESP_LOGI(DEMO_TAG, "Measured power(RSSI at 0m distance):%d dbm", res->inform.url.tx_power);
|
||||
ESP_LOGI(DEMO_TAG, "URL: %s", res->inform.url.url);
|
||||
break;
|
||||
}
|
||||
case EDDYSTONE_FRAME_TYPE_TLM: {
|
||||
ESP_LOGI(DEMO_TAG, "Eddystone TLM inform:");
|
||||
ESP_LOGI(DEMO_TAG, "version: %d", res->inform.tlm.version);
|
||||
ESP_LOGI(DEMO_TAG, "battery voltage: %d mV", res->inform.tlm.battery_voltage);
|
||||
ESP_LOGI(DEMO_TAG, "beacon temperature in degrees Celsius: %6.1f", res->inform.tlm.temperature);
|
||||
ESP_LOGI(DEMO_TAG, "adv pdu count since power-up: %d", res->inform.tlm.adv_count);
|
||||
ESP_LOGI(DEMO_TAG, "time since power-up: %d s", (res->inform.tlm.time)/10);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* param)
|
||||
{
|
||||
esp_err_t err;
|
||||
|
||||
switch(event)
|
||||
{
|
||||
case ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT: {
|
||||
uint32_t duration = 0;
|
||||
esp_ble_gap_start_scanning(duration);
|
||||
break;
|
||||
}
|
||||
case ESP_GAP_BLE_SCAN_START_COMPLETE_EVT: {
|
||||
if((err = param->scan_start_cmpl.status) != ESP_BT_STATUS_SUCCESS) {
|
||||
ESP_LOGE(DEMO_TAG,"Scan start failed: %s", esp_err_to_name(err));
|
||||
}
|
||||
else {
|
||||
ESP_LOGI(DEMO_TAG,"Start scanning...");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ESP_GAP_BLE_SCAN_RESULT_EVT: {
|
||||
esp_ble_gap_cb_param_t* scan_result = (esp_ble_gap_cb_param_t*)param;
|
||||
switch(scan_result->scan_rst.search_evt)
|
||||
{
|
||||
case ESP_GAP_SEARCH_INQ_RES_EVT: {
|
||||
esp_eddystone_result_t eddystone_res;
|
||||
memset(&eddystone_res, 0, sizeof(eddystone_res));
|
||||
esp_err_t ret = esp_eddystone_decode(scan_result->scan_rst.ble_adv, scan_result->scan_rst.adv_data_len, &eddystone_res);
|
||||
if (ret) {
|
||||
// error:The received data is not an eddystone frame packet or a correct eddystone frame packet.
|
||||
// just return
|
||||
return;
|
||||
} else {
|
||||
// The received adv data is a correct eddystone frame packet.
|
||||
// Here, we get the eddystone infomation in eddystone_res, we can use the data in res to do other things.
|
||||
// For example, just print them:
|
||||
ESP_LOGI(DEMO_TAG, "--------Eddystone Found----------");
|
||||
esp_log_buffer_hex("EDDYSTONE_DEMO: Device address:", scan_result->scan_rst.bda, ESP_BD_ADDR_LEN);
|
||||
ESP_LOGI(DEMO_TAG, "RSSI of packet:%d dbm", scan_result->scan_rst.rssi);
|
||||
esp_eddystone_show_inform(&eddystone_res);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT:{
|
||||
if((err = param->scan_stop_cmpl.status) != ESP_BT_STATUS_SUCCESS) {
|
||||
ESP_LOGE(DEMO_TAG,"Scan stop failed: %s", esp_err_to_name(err));
|
||||
}
|
||||
else {
|
||||
ESP_LOGI(DEMO_TAG,"Stop scan successfully");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void esp_eddystone_appRegister(void)
|
||||
{
|
||||
esp_err_t status;
|
||||
|
||||
ESP_LOGI(DEMO_TAG,"Register callback");
|
||||
|
||||
/*<! register the scan callback function to the gap module */
|
||||
if((status = esp_ble_gap_register_callback(esp_gap_cb)) != ESP_OK) {
|
||||
ESP_LOGE(DEMO_TAG,"gap register error: %s", esp_err_to_name(status));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void esp_eddystone_init(void)
|
||||
{
|
||||
esp_bluedroid_init();
|
||||
esp_bluedroid_enable();
|
||||
esp_eddystone_appRegister();
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
ESP_ERROR_CHECK(nvs_flash_init());
|
||||
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||
esp_bt_controller_init(&bt_cfg);
|
||||
esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||
|
||||
esp_eddystone_init();
|
||||
|
||||
/*<! set scan parameters */
|
||||
esp_ble_gap_set_scan_params(&ble_scan_params);
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
|
||||
#ifndef __ESP_EDDYSTONE_PROTOCOL_H__
|
||||
#define __ESP_EDDYSTONE_PROTOCOL_H__
|
||||
|
||||
#include "stdbool.h"
|
||||
#include "stdint.h"
|
||||
|
||||
/* Eddystone definitions */
|
||||
#define EDDYSTONE_SERVICE_UUID 0xFEAA
|
||||
|
||||
#define EDDYSTONE_FRAME_TYPE_UID 0x00
|
||||
#define EDDYSTONE_FRAME_TYPE_URL 0x10
|
||||
#define EDDYSTONE_FRAME_TYPE_TLM 0x20
|
||||
#define EDDYSTONE_FRAME_TYPE_EID 0x30
|
||||
//UID
|
||||
#define EDDYSTONE_UID_RANG_DATA_LEN 1
|
||||
#define EDDYSTONE_UID_NAMESPACE_LEN 10
|
||||
#define EDDYSTONE_UID_INSTANCE_LEN 6
|
||||
#define EDDYSTONE_UID_RFU_LEN 2
|
||||
#define EDDYSTONE_UID_DATA_LEN (EDDYSTONE_UID_RANG_DATA_LEN + EDDYSTONE_UID_NAMESPACE_LEN + EDDYSTONE_UID_INSTANCE_LEN)
|
||||
//TLM
|
||||
#define EDDYSTONE_TLM_VERSION_LEN 1
|
||||
#define EDDYSTONE_TLM_BATTERY_VOLTAGE_LEN 2
|
||||
#define EDDYSTONE_TLM_TEMPERATURE_LEN 2
|
||||
#define EDDYSTONE_TLM_ADV_COUNT_LEN 4
|
||||
#define EDDYSTONE_TLM_TIME_LEN 4
|
||||
#define EDDYSTONE_TLM_DATA_LEN (EDDYSTONE_TLM_VERSION_LEN + EDDYSTONE_TLM_BATTERY_VOLTAGE_LEN + \
|
||||
EDDYSTONE_TLM_TEMPERATURE_LEN + EDDYSTONE_TLM_ADV_COUNT_LEN + EDDYSTONE_TLM_TIME_LEN)
|
||||
//URL
|
||||
#define EDDYSTONE_URL_SCHEME_LEN 1
|
||||
#define EDDYSTONE_URL_ENCODED_MAX_LEN 17
|
||||
#define EDDYSTONE_URL_MAX_LEN (EDDYSTONE_URL_SCHEME_LEN + EDDYSTONE_URL_ENCODED_MAX_LEN)
|
||||
#define EDDYSTONE_URL_TX_POWER_LEN 1
|
||||
|
||||
|
||||
/* Eddystone UID frame */
|
||||
typedef struct {
|
||||
int8_t ranging_data; /*<! calibrated Tx power at 0m */
|
||||
uint8_t namespace_id[10];
|
||||
uint8_t instance_id[6];
|
||||
uint8_t reserved[2];
|
||||
} __attribute__((packed))esp_eddystone_uid_t;
|
||||
|
||||
/* Eddystone URL frame */
|
||||
typedef struct {
|
||||
int8_t tx_power; /*<! calibrated Tx power at 0m */
|
||||
uint8_t url_scheme; /*<! encoded scheme prefix */
|
||||
uint8_t encoded_url[0]; /*<! length 1-17 */
|
||||
} __attribute__((packed))esp_eddystone_url_t;
|
||||
|
||||
/* Eddystone TLM frame */
|
||||
typedef struct {
|
||||
uint8_t version; /*<! TLM version,0x00 for now */
|
||||
uint16_t batt; /*<! battery voltage, 1mV/bit */
|
||||
uint16_t temp; /*<! beacon temperature */
|
||||
uint32_t adv_count; /*<! adv pdu count since power-on or reboot */
|
||||
uint32_t time; /*<! time sence power-on or reboot, a 0.1 second resolution counter */
|
||||
} __attribute__((packed)) esp_eddystone_tlm_t;
|
||||
|
||||
/* AD Structure of flags */
|
||||
typedef struct {
|
||||
uint8_t len;
|
||||
uint8_t type;
|
||||
uint8_t flags;
|
||||
} __attribute__((packed)) esp_eddystone_flags_t;
|
||||
|
||||
/* AD Structure of complete 16-bit service uuid */
|
||||
typedef struct {
|
||||
uint8_t len;
|
||||
uint8_t type;
|
||||
uint16_t uuid; /*<! complete list of 16-bit service UUIDs data type value */
|
||||
} __attribute__((packed)) esp_eddystone_uuid_t;
|
||||
|
||||
/* AD Structure of eddystone frame*/
|
||||
typedef struct {
|
||||
uint8_t len; /*<! length of eddystone data */
|
||||
uint8_t type; /*<! service data type,must be 0x16 */
|
||||
uint16_t uuid; /*<! 16-bit eddystone uuid */
|
||||
uint8_t frame_type;
|
||||
union {
|
||||
esp_eddystone_uid_t uid;
|
||||
esp_eddystone_url_t url;
|
||||
esp_eddystone_tlm_t tlm;
|
||||
} u[0];
|
||||
} __attribute__((packed)) esp_eddystone_frame_t;
|
||||
|
||||
/* eddystone packet type */
|
||||
typedef struct {
|
||||
esp_eddystone_flags_t flags;
|
||||
esp_eddystone_uuid_t uuid;
|
||||
esp_eddystone_frame_t frame;
|
||||
} __attribute__((packed)) esp_eddystone_packet_t;
|
||||
|
||||
/*
|
||||
* URLs are written only with the graphic printable characters of the US-ASCII coded character set.
|
||||
* The octets 00-20 and 7F-FF hexadecimal are not used.
|
||||
* See “Excluded US-ASCII Characters” in RFC 2936.
|
||||
*
|
||||
*/
|
||||
static inline bool esp_eddystone_is_char_invalid(int ch)
|
||||
{
|
||||
return (ch >= 0x00 && ch <= 0x20) || (ch >= 0x7f && ch <= 0xff);
|
||||
}
|
||||
|
||||
#endif /* __ESP_EDDYSTONE_PROTOCOL_H__ */
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
This directory is intended for PIO Unit Testing and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
||||
@@ -1,3 +1,3 @@
|
||||
cmake_minimum_required(VERSION 3.16.0)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(espidf-ulp-pulse-new)
|
||||
project(espidf-blink)
|
||||
@@ -8,7 +8,7 @@ How to build PlatformIO based project
|
||||
|
||||
```shell
|
||||
# Change directory to example
|
||||
$ cd platform-espressif32/examples/espidf-ulp-adc
|
||||
$ cd platform-espressif32/examples/espidf-blink
|
||||
|
||||
# Build project
|
||||
$ pio run
|
||||
@@ -24,4 +24,4 @@ $ pio run -e esp32dev --target upload
|
||||
|
||||
# Clean build files
|
||||
$ pio run --target clean
|
||||
```
|
||||
```
|
||||
@@ -0,0 +1,77 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||
|
||||
# Blink Example
|
||||
|
||||
(See the README.md file in the upper level 'examples' directory for more information about examples.)
|
||||
|
||||
This example demonstrates how to blink a LED using GPIO or using the [led_strip](https://components.espressif.com/component/espressif/led_strip) component for the addressable LED, i.e. [WS2812](http://www.world-semi.com/Certifications/WS2812B.html).
|
||||
|
||||
The `led_strip` is installed via [component manager](main/idf_component.yml).
|
||||
|
||||
## How to Use Example
|
||||
|
||||
Before project configuration and build, be sure to set the correct chip target using `idf.py set-target <chip_name>`.
|
||||
|
||||
### Hardware Required
|
||||
|
||||
* A development board with Espressif SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
|
||||
* A USB cable for Power supply and programming
|
||||
|
||||
Some development boards use an addressable LED instead of a regular one. These development boards include:
|
||||
|
||||
| Board | LED type | Pin |
|
||||
| -------------------- | -------------------- | -------------------- |
|
||||
| ESP32-C3-DevKitC-1 | Addressable | GPIO8 |
|
||||
| ESP32-C3-DevKitM-1 | Addressable | GPIO8 |
|
||||
| ESP32-S2-DevKitM-1 | Addressable | GPIO18 |
|
||||
| ESP32-S2-Saola-1 | Addressable | GPIO18 |
|
||||
| ESP32-S3-DevKitC-1 | Addressable | GPIO48 |
|
||||
|
||||
See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it.
|
||||
|
||||
### Configure the Project
|
||||
|
||||
Open the project configuration menu (`idf.py menuconfig`).
|
||||
|
||||
In the `Example Configuration` menu:
|
||||
|
||||
* Select the LED type in the `Blink LED type` option.
|
||||
* Use `GPIO` for regular LED blink.
|
||||
* Set the GPIO number used for the signal in the `Blink GPIO number` option.
|
||||
* Set the blinking period in the `Blink period in ms` option.
|
||||
|
||||
### Build and Flash
|
||||
|
||||
Run `idf.py -p PORT flash monitor` to build, flash and monitor the project.
|
||||
|
||||
(To exit the serial monitor, type ``Ctrl-]``.)
|
||||
|
||||
See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.
|
||||
|
||||
## Example Output
|
||||
|
||||
As you run the example, you will see the LED blinking, according to the previously defined period. For the addressable LED, you can also change the LED color by setting the `led_strip_set_pixel(led_strip, 0, 16, 16, 16);` (LED Strip, Pixel Number, Red, Green, Blue) with values from 0 to 255 in the [source file](main/blink_example_main.c).
|
||||
|
||||
```text
|
||||
I (315) example: Example configured to blink addressable LED!
|
||||
I (325) example: Turning the LED OFF!
|
||||
I (1325) example: Turning the LED ON!
|
||||
I (2325) example: Turning the LED OFF!
|
||||
I (3325) example: Turning the LED ON!
|
||||
I (4325) example: Turning the LED OFF!
|
||||
I (5325) example: Turning the LED ON!
|
||||
I (6325) example: Turning the LED OFF!
|
||||
I (7325) example: Turning the LED ON!
|
||||
I (8325) example: Turning the LED OFF!
|
||||
```
|
||||
|
||||
Note: The color order could be different according to the LED model.
|
||||
|
||||
The pixel number indicates the pixel position in the LED strip. For a single LED, use 0.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
* If the LED isn't blinking, check the GPIO or the LED type selection in the `Example Configuration` menu.
|
||||
|
||||
For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon.
|
||||
@@ -0,0 +1,39 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
build_flags =
|
||||
; https://docs.espressif.com/projects/esp-idf/en/latest/get-started/get-started-wrover-kit.html#rgb-led
|
||||
-D CONFIG_BLINK_GPIO=2
|
||||
-D CONFIG_BLINK_LED_GPIO=2
|
||||
-D CONFIG_BLINK_PERIOD=1000
|
||||
|
||||
[env:esp32-c2-devkitm-1]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32-c2-devkitm-1
|
||||
monitor_speed = 115200
|
||||
build_flags =
|
||||
-D CONFIG_BLINK_GPIO=8
|
||||
-D CONFIG_BLINK_LED_GPIO=8
|
||||
-D CONFIG_BLINK_PERIOD=1000
|
||||
|
||||
[env:esp32-c6-devkitc-1]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32-c6-devkitc-1
|
||||
monitor_speed = 115200
|
||||
build_flags =
|
||||
-D CONFIG_BLINK_GPIO=2
|
||||
-D CONFIG_BLINK_LED_GPIO=2
|
||||
-D CONFIG_BLINK_PERIOD=1000
|
||||
@@ -0,0 +1,4 @@
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y
|
||||
@@ -0,0 +1,2 @@
|
||||
idf_component_register(SRCS "blink.c"
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,91 @@
|
||||
/* Blink Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_log.h"
|
||||
//#include "led_strip.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
static const char *TAG = "example";
|
||||
|
||||
/* Use project configuration menu (idf.py menuconfig) to choose the GPIO to blink,
|
||||
or you can edit the following line and set a number here.
|
||||
*/
|
||||
#define BLINK_GPIO CONFIG_BLINK_GPIO
|
||||
|
||||
static uint8_t s_led_state = 0;
|
||||
|
||||
#ifdef CONFIG_BLINK_LED_RMT
|
||||
|
||||
static led_strip_handle_t led_strip;
|
||||
|
||||
static void blink_led(void)
|
||||
{
|
||||
/* If the addressable LED is enabled */
|
||||
if (s_led_state) {
|
||||
/* Set the LED pixel using RGB from 0 (0%) to 255 (100%) for each color */
|
||||
led_strip_set_pixel(led_strip, 0, 16, 16, 16);
|
||||
/* Refresh the strip to send data */
|
||||
led_strip_refresh(led_strip);
|
||||
} else {
|
||||
/* Set all LED off to clear all pixels */
|
||||
led_strip_clear(led_strip);
|
||||
}
|
||||
}
|
||||
|
||||
static void configure_led(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Example configured to blink addressable LED!");
|
||||
/* LED strip initialization with the GPIO and pixels number*/
|
||||
led_strip_config_t strip_config = {
|
||||
.strip_gpio_num = BLINK_GPIO,
|
||||
.max_leds = 1, // at least one LED on board
|
||||
};
|
||||
led_strip_rmt_config_t rmt_config = {
|
||||
.resolution_hz = 10 * 1000 * 1000, // 10MHz
|
||||
};
|
||||
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
|
||||
/* Set all LED off to clear all pixels */
|
||||
led_strip_clear(led_strip);
|
||||
}
|
||||
|
||||
#elif CONFIG_BLINK_LED_GPIO
|
||||
|
||||
static void blink_led(void)
|
||||
{
|
||||
/* Set the GPIO level according to the state (LOW or HIGH)*/
|
||||
gpio_set_level(BLINK_GPIO, s_led_state);
|
||||
}
|
||||
|
||||
static void configure_led(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Example configured to blink GPIO LED!");
|
||||
gpio_reset_pin(BLINK_GPIO);
|
||||
/* Set the GPIO as a push/pull output */
|
||||
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
|
||||
/* Configure the peripheral according to the LED type */
|
||||
configure_led();
|
||||
|
||||
while (1) {
|
||||
ESP_LOGI(TAG, "Turning the LED %s!", s_led_state == true ? "ON" : "OFF");
|
||||
blink_led();
|
||||
/* Toggle the LED state */
|
||||
s_led_state = !s_led_state;
|
||||
vTaskDelay(CONFIG_BLINK_PERIOD / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -16,11 +16,5 @@ board_build.embed_txtfiles =
|
||||
src/certs/coap_server.crt
|
||||
src/certs/coap_server.key
|
||||
|
||||
[env:nano32]
|
||||
board = nano32
|
||||
|
||||
[env:esp-wrover-kit]
|
||||
board = esp-wrover-kit
|
||||
|
||||
[env:esp32dev]
|
||||
board = esp32dev
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -12,11 +12,5 @@ platform = espressif32
|
||||
framework = espidf
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:esp32dev]
|
||||
board = esp32dev
|
||||
|
||||
[env:esp-wrover-kit]
|
||||
board = esp-wrover-kit
|
||||
|
||||
[env:lolin32]
|
||||
board = lolin32
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -20,8 +20,3 @@ board = esp32-s2-kaluga-1
|
||||
|
||||
[env:esp32-c3-devkitm-1]
|
||||
board = esp32-c3-devkitm-1
|
||||
|
||||
[env:esp32-c6-devkitc-1]
|
||||
board = esp32-c6-devkitc-1
|
||||
board_build.cmake_extra_args =
|
||||
-DSDKCONFIG_DEFAULTS="sdkconfig.defaults.esp32c6"
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="8MB"
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -15,11 +15,5 @@ monitor_speed = 115200
|
||||
[env:esp32dev]
|
||||
board = esp32dev
|
||||
|
||||
[env:nano32]
|
||||
board = nano32
|
||||
|
||||
[env:espea32]
|
||||
board = espea32
|
||||
|
||||
[env:esp32-s2-saola-1]
|
||||
board = esp32-s2-saola-1
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -12,11 +12,5 @@ platform = espressif32
|
||||
framework = espidf
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:pocket_32]
|
||||
board = pocket_32
|
||||
|
||||
[env:odroid_esp32]
|
||||
board = odroid_esp32
|
||||
|
||||
[env:featheresp32]
|
||||
board = featheresp32
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -12,11 +12,5 @@ platform = espressif32
|
||||
framework = espidf
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:esp32thing]
|
||||
board = esp32thing
|
||||
|
||||
[env:esp32-gateway]
|
||||
board = esp32-gateway
|
||||
|
||||
[env:heltec_wifi_kit_32]
|
||||
board = heltec_wifi_kit_32
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
.pio
|
||||
@@ -1,24 +0,0 @@
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
```shell
|
||||
# Change directory to example
|
||||
$ cd platform-espressif32/examples/espidf-storage-spiffs
|
||||
|
||||
# Build project
|
||||
$ pio run
|
||||
|
||||
# Upload firmware
|
||||
$ pio run --target upload
|
||||
|
||||
# Upload SPIFFS image
|
||||
$ pio run --target uploadfs
|
||||
|
||||
# Clean build files
|
||||
$ pio run --target clean
|
||||
```
|
||||
@@ -1 +0,0 @@
|
||||
Hello World from SPIFFS.
|
||||
@@ -1,39 +0,0 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -1,6 +0,0 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, 0x9000, 0x6000,
|
||||
phy_init, data, phy, 0xf000, 0x1000,
|
||||
factory, app, factory, 0x10000, 1M,
|
||||
spiffs, data, spiffs, , 0xF0000,
|
||||
|
@@ -1,15 +0,0 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter, extra scripting
|
||||
; Upload options: custom port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
framework = espidf
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
board_build.partitions = partitions_example.csv
|
||||
@@ -1,3 +0,0 @@
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_example.csv"
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
|
||||
@@ -1,2 +0,0 @@
|
||||
idf_component_register(SRCS "spiffs_example_main.c"
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -1,9 +0,0 @@
|
||||
menu "SPIFFS Example menu"
|
||||
|
||||
config EXAMPLE_SPIFFS_CHECK_ON_START
|
||||
bool "Run SPIFFS_check on every start-up"
|
||||
default y
|
||||
help
|
||||
If this config item is set, esp_spiffs_check() will be run on every start-up.
|
||||
Slow on large flash sizes.
|
||||
endmenu
|
||||
@@ -1,127 +0,0 @@
|
||||
/* SPIFFS filesystem example.
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_spiffs.h"
|
||||
|
||||
static const char *TAG = "example";
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
ESP_LOGI(TAG, "Initializing SPIFFS");
|
||||
|
||||
esp_vfs_spiffs_conf_t conf = {
|
||||
.base_path = "/spiffs",
|
||||
.partition_label = NULL,
|
||||
.max_files = 5,
|
||||
.format_if_mount_failed = true
|
||||
};
|
||||
|
||||
// Use settings defined above to initialize and mount SPIFFS filesystem.
|
||||
// Note: esp_vfs_spiffs_register is an all-in-one convenience function.
|
||||
esp_err_t ret = esp_vfs_spiffs_register(&conf);
|
||||
|
||||
if (ret != ESP_OK) {
|
||||
if (ret == ESP_FAIL) {
|
||||
ESP_LOGE(TAG, "Failed to mount or format filesystem");
|
||||
} else if (ret == ESP_ERR_NOT_FOUND) {
|
||||
ESP_LOGE(TAG, "Failed to find SPIFFS partition");
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to initialize SPIFFS (%s)", esp_err_to_name(ret));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_EXAMPLE_SPIFFS_CHECK_ON_START
|
||||
ESP_LOGI(TAG, "Performing SPIFFS_check().");
|
||||
ret = esp_spiffs_check(conf.partition_label);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "SPIFFS_check() failed (%s)", esp_err_to_name(ret));
|
||||
return;
|
||||
} else {
|
||||
ESP_LOGI(TAG, "SPIFFS_check() successful");
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t total = 0, used = 0;
|
||||
ret = esp_spiffs_info(conf.partition_label, &total, &used);
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to get SPIFFS partition information (%s). Formatting...", esp_err_to_name(ret));
|
||||
esp_spiffs_format(conf.partition_label);
|
||||
return;
|
||||
} else {
|
||||
ESP_LOGI(TAG, "Partition size: total: %d, used: %d", total, used);
|
||||
}
|
||||
|
||||
#
|
||||
// Check consistency of reported partiton size info.
|
||||
if (used > total) {
|
||||
ESP_LOGW(TAG, "Number of used bytes cannot be larger than total. Performing SPIFFS_check().");
|
||||
ret = esp_spiffs_check(conf.partition_label);
|
||||
// Could be also used to mend broken files, to clean unreferenced pages, etc.
|
||||
// More info at https://github.com/pellepl/spiffs/wiki/FAQ#powerlosses-contd-when-should-i-run-spiffs_check
|
||||
if (ret != ESP_OK) {
|
||||
ESP_LOGE(TAG, "SPIFFS_check() failed (%s)", esp_err_to_name(ret));
|
||||
return;
|
||||
} else {
|
||||
ESP_LOGI(TAG, "SPIFFS_check() successful");
|
||||
}
|
||||
}
|
||||
|
||||
// Use POSIX and C standard library functions to work with files.
|
||||
// First create a file.
|
||||
ESP_LOGI(TAG, "Opening file");
|
||||
FILE* f = fopen("/spiffs/hello.txt", "w");
|
||||
if (f == NULL) {
|
||||
ESP_LOGE(TAG, "Failed to open file for writing");
|
||||
return;
|
||||
}
|
||||
fprintf(f, "Hello World!\n");
|
||||
fclose(f);
|
||||
ESP_LOGI(TAG, "File written");
|
||||
|
||||
// Check if destination file exists before renaming
|
||||
struct stat st;
|
||||
if (stat("/spiffs/foo.txt", &st) == 0) {
|
||||
// Delete it if it exists
|
||||
unlink("/spiffs/foo.txt");
|
||||
}
|
||||
|
||||
// Rename original file
|
||||
ESP_LOGI(TAG, "Renaming file");
|
||||
if (rename("/spiffs/hello.txt", "/spiffs/foo.txt") != 0) {
|
||||
ESP_LOGE(TAG, "Rename failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// Open renamed file for reading
|
||||
ESP_LOGI(TAG, "Reading file");
|
||||
f = fopen("/spiffs/foo.txt", "r");
|
||||
if (f == NULL) {
|
||||
ESP_LOGE(TAG, "Failed to open file for reading");
|
||||
return;
|
||||
}
|
||||
char line[64];
|
||||
fgets(line, sizeof(line), f);
|
||||
fclose(f);
|
||||
// strip newline
|
||||
char* pos = strchr(line, '\n');
|
||||
if (pos) {
|
||||
*pos = '\0';
|
||||
}
|
||||
ESP_LOGI(TAG, "Read from file: '%s'", line);
|
||||
|
||||
// All done, unmount partition and disable SPIFFS
|
||||
esp_vfs_spiffs_unregister(conf.partition_label);
|
||||
ESP_LOGI(TAG, "SPIFFS unmounted");
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
This directory is intended for PIO Unit Testing and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
||||
@@ -1 +0,0 @@
|
||||
.pio
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -1,39 +0,0 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -1,108 +0,0 @@
|
||||
/* ULP Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include "esp_sleep.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/sens_reg.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "ulp.h"
|
||||
#include "ulp_main.h"
|
||||
#include "esp_adc/adc_oneshot.h"
|
||||
#include "ulp/example_config.h"
|
||||
#include "ulp_adc.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
extern const uint8_t ulp_main_bin_start[] asm("_binary_ulp_main_bin_start");
|
||||
extern const uint8_t ulp_main_bin_end[] asm("_binary_ulp_main_bin_end");
|
||||
|
||||
/* This function is called once after power-on reset, to load ULP program into
|
||||
* RTC memory and configure the ADC.
|
||||
*/
|
||||
static void init_ulp_program(void);
|
||||
|
||||
/* This function is called every time before going into deep sleep.
|
||||
* It starts the ULP program and resets measurement counter.
|
||||
*/
|
||||
static void start_ulp_program(void);
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
|
||||
if (cause != ESP_SLEEP_WAKEUP_ULP) {
|
||||
printf("Not ULP wakeup\n");
|
||||
init_ulp_program();
|
||||
} else {
|
||||
printf("Deep sleep wakeup\n");
|
||||
printf("ULP did %"PRIu32" measurements since last reset\n", ulp_sample_counter & UINT16_MAX);
|
||||
printf("Thresholds: low=%"PRIu32" high=%"PRIu32"\n", ulp_low_thr, ulp_high_thr);
|
||||
ulp_last_result &= UINT16_MAX;
|
||||
printf("Value=%"PRIu32" was %s threshold\n", ulp_last_result,
|
||||
ulp_last_result < ulp_low_thr ? "below" : "above");
|
||||
}
|
||||
printf("Entering deep sleep\n\n");
|
||||
start_ulp_program();
|
||||
ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup() );
|
||||
|
||||
#if !CONFIG_IDF_TARGET_ESP32
|
||||
/* RTC peripheral power domain needs to be kept on to keep SAR ADC related configs during sleep */
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
#endif
|
||||
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
static void init_ulp_program(void)
|
||||
{
|
||||
esp_err_t err = ulp_load_binary(0, ulp_main_bin_start,
|
||||
(ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t));
|
||||
ESP_ERROR_CHECK(err);
|
||||
|
||||
ulp_adc_cfg_t cfg = {
|
||||
.adc_n = EXAMPLE_ADC_UNIT,
|
||||
.channel = EXAMPLE_ADC_CHANNEL,
|
||||
.width = EXAMPLE_ADC_WIDTH,
|
||||
.atten = EXAMPLE_ADC_ATTEN,
|
||||
.ulp_mode = ADC_ULP_MODE_FSM,
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK(ulp_adc_init(&cfg));
|
||||
|
||||
ulp_low_thr = EXAMPLE_ADC_LOW_TRESHOLD;
|
||||
ulp_high_thr = EXAMPLE_ADC_HIGH_TRESHOLD;
|
||||
|
||||
/* Set ULP wake up period to 20ms */
|
||||
ulp_set_wakeup_period(0, 20000);
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
/* Disconnect GPIO12 and GPIO15 to remove current drain through
|
||||
* pullup/pulldown resistors on modules which have these (e.g. ESP32-WROVER)
|
||||
* GPIO12 may be pulled high to select flash voltage.
|
||||
*/
|
||||
rtc_gpio_isolate(GPIO_NUM_12);
|
||||
rtc_gpio_isolate(GPIO_NUM_15);
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
esp_deep_sleep_disable_rom_logging(); // suppress boot messages
|
||||
}
|
||||
|
||||
static void start_ulp_program(void)
|
||||
{
|
||||
/* Reset sample counter */
|
||||
ulp_sample_counter = 0;
|
||||
|
||||
/* Start the program */
|
||||
esp_err_t err = ulp_run(&ulp_entry - RTC_SLOW_MEM);
|
||||
ESP_ERROR_CHECK(err);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
This directory is intended for PIO Unit Testing and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
/* ULP Example: using ADC in deep sleep
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
This file contains assembly code which runs on the ULP.
|
||||
|
||||
ULP wakes up to run this code at a certain period, determined by the values
|
||||
in SENS_ULP_CP_SLEEP_CYCx_REG registers. On each wake up, the program
|
||||
measures input voltage on the given ADC channel 'adc_oversampling_factor'
|
||||
times. Measurements are accumulated and average value is calculated.
|
||||
Average value is compared to the two thresholds: 'low_thr' and 'high_thr'.
|
||||
If the value is less than 'low_thr' or more than 'high_thr', ULP wakes up
|
||||
the chip from deep sleep.
|
||||
*/
|
||||
|
||||
/* ULP assembly files are passed through C preprocessor first, so include directives
|
||||
and C macros may be used in these files
|
||||
*/
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/soc_ulp.h"
|
||||
#include "example_config.h"
|
||||
|
||||
.set adc_channel, EXAMPLE_ADC_CHANNEL
|
||||
|
||||
/* Configure the number of ADC samples to average on each measurement.
|
||||
For convenience, make it a power of 2. */
|
||||
.set adc_oversampling_factor_log, 2
|
||||
.set adc_oversampling_factor, (1 << adc_oversampling_factor_log)
|
||||
|
||||
/* Define variables, which go into .bss section (zero-initialized data) */
|
||||
.bss
|
||||
|
||||
/* Low threshold of ADC reading.
|
||||
Set by the main program. */
|
||||
.global low_thr
|
||||
low_thr:
|
||||
.long 0
|
||||
|
||||
/* High threshold of ADC reading.
|
||||
Set by the main program. */
|
||||
.global high_thr
|
||||
high_thr:
|
||||
.long 0
|
||||
|
||||
/* Counter of measurements done */
|
||||
.global sample_counter
|
||||
sample_counter:
|
||||
.long 0
|
||||
|
||||
.global last_result
|
||||
last_result:
|
||||
.long 0
|
||||
|
||||
/* Code goes into .text section */
|
||||
.text
|
||||
.global entry
|
||||
entry:
|
||||
/* increment sample counter */
|
||||
move r3, sample_counter
|
||||
ld r2, r3, 0
|
||||
add r2, r2, 1
|
||||
st r2, r3, 0
|
||||
|
||||
/* do measurements using ADC */
|
||||
/* r0 will be used as accumulator */
|
||||
move r0, 0
|
||||
/* initialize the loop counter */
|
||||
stage_rst
|
||||
measure:
|
||||
/* measure and add value to accumulator */
|
||||
adc r1, 0, adc_channel + 1
|
||||
add r0, r0, r1
|
||||
/* increment loop counter and check exit condition */
|
||||
stage_inc 1
|
||||
jumps measure, adc_oversampling_factor, lt
|
||||
|
||||
/* divide accumulator by adc_oversampling_factor.
|
||||
Since it is chosen as a power of two, use right shift */
|
||||
rsh r0, r0, adc_oversampling_factor_log
|
||||
/* averaged value is now in r0; store it into last_result */
|
||||
move r3, last_result
|
||||
st r0, r3, 0
|
||||
|
||||
/* compare with low_thr; wake up if value < low_thr */
|
||||
move r3, low_thr
|
||||
ld r3, r3, 0
|
||||
sub r3, r0, r3
|
||||
jump wake_up, ov
|
||||
|
||||
/* compare with high_thr; wake up if value > high_thr */
|
||||
move r3, high_thr
|
||||
ld r3, r3, 0
|
||||
sub r3, r3, r0
|
||||
jump wake_up, ov
|
||||
|
||||
/* value within range, end the program */
|
||||
.global exit
|
||||
exit:
|
||||
halt
|
||||
|
||||
.global wake_up
|
||||
wake_up:
|
||||
/* Check if the system can be woken up */
|
||||
READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP)
|
||||
and r0, r0, 1
|
||||
jump exit, eq
|
||||
|
||||
/* Wake up the SoC, end program */
|
||||
wake
|
||||
WRITE_RTC_FIELD(RTC_CNTL_STATE0_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN, 0)
|
||||
halt
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/* Ints are used here to be able to include the file in assembly as well */
|
||||
#define EXAMPLE_ADC_CHANNEL 6 // ADC_CHANNEL_6, GPIO34 on ESP32, GPIO7 on ESP32-S3
|
||||
#define EXAMPLE_ADC_UNIT 0 // ADC_UNIT_1
|
||||
#define EXAMPLE_ADC_ATTEN 3 // ADC_ATTEN_DB_11
|
||||
#define EXAMPLE_ADC_WIDTH 0 // ADC_BITWIDTH_DEFAULT
|
||||
|
||||
/* Set low and high thresholds, approx. 1.35V - 1.75V*/
|
||||
#define EXAMPLE_ADC_LOW_TRESHOLD 1500
|
||||
#define EXAMPLE_ADC_HIGH_TRESHOLD 2000
|
||||
@@ -1 +0,0 @@
|
||||
.pio
|
||||
@@ -1,67 +0,0 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < https://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < https://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choose one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to be used as a library with examples.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -1,27 +0,0 @@
|
||||
How to build PlatformIO based project
|
||||
=====================================
|
||||
|
||||
1. [Install PlatformIO Core](https://docs.platformio.org/page/core.html)
|
||||
2. Download [development platform with examples](https://github.com/platformio/platform-espressif32/archive/develop.zip)
|
||||
3. Extract ZIP archive
|
||||
4. Run these commands:
|
||||
|
||||
```shell
|
||||
# Change directory to example
|
||||
$ cd platform-espressif32/examples/espidf-ulp-pulse
|
||||
|
||||
# Build project
|
||||
$ pio run
|
||||
|
||||
# Upload firmware
|
||||
$ pio run --target upload
|
||||
|
||||
# Build specific environment
|
||||
$ pio run -e esp32dev
|
||||
|
||||
# Upload firmware for the specific environment
|
||||
$ pio run -e esp32dev --target upload
|
||||
|
||||
# Clean build files
|
||||
$ pio run --target clean
|
||||
```
|
||||
@@ -1,39 +0,0 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
@@ -1,11 +0,0 @@
|
||||
|
||||
This directory is intended for PIO Unit Testing and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
||||
@@ -1,16 +0,0 @@
|
||||
/* ULP assembly files are passed through C preprocessor first, so include directives
|
||||
and C macros may be used in these files
|
||||
*/
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/soc_ulp.h"
|
||||
|
||||
.global wake_up
|
||||
wake_up:
|
||||
/* Check if the system can be woken up */
|
||||
READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP)
|
||||
and r0, r0, 1
|
||||
jump wake_up, eq
|
||||
|
||||
/* Wake up the SoC, end program */
|
||||
wake
|
||||
halt
|
||||
@@ -3,4 +3,4 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(ulp-adc-example)
|
||||
project(ulp_riscv_example)
|
||||
@@ -0,0 +1,31 @@
|
||||
| Supported Targets | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | -------- | -------- |
|
||||
|
||||
# ULP-RISC-V simple example with GPIO Polling:
|
||||
|
||||
This example demonstrates how to program the ULP-RISC-V coprocessor to poll a gpio and wakeup the main CPU when it changes its state;
|
||||
|
||||
ULP program written in C can be found across `ulp/main.c`. The build system compiles and links this program, converts it into binary format, and embeds it into the .rodata section of the ESP-IDF application.
|
||||
|
||||
At runtime, the application running inside the main CPU loads ULP program into the `RTC_SLOW_MEM` memory region using `ulp_riscv_load_binary` function. The main code then configures the ULP wakeup period and starts the coprocessor by using `ulp_riscv_run`. Once the ULP program is started, it runs periodically, with the period set by the main program. The main program enables ULP wakeup source and puts the chip into deep sleep mode.
|
||||
|
||||
When the ULP program finds an state changing in the pin, it saves the current state and sends a wakeup signal to the main CPU.
|
||||
|
||||
Upon wakeup, the main program prints the current level of the measured gpio and go back to the deep sleep.
|
||||
|
||||
In this example the input signal is connected to GPIO0. Note that this pin was chosen because most development boards have a button connected to it, so the pulses to be counted can be generated by pressing the button. For real world applications this is not a good choice of a pin, because GPIO0 also acts as a bootstrapping pin. To change the pin number, check the ESP32-S2 Chip Pin List document and adjust `gpio_num` and `ulp_io_number` variables in main.c.
|
||||
|
||||
|
||||
## Example output
|
||||
|
||||
```
|
||||
Not a ULP wakeup, initializing it!
|
||||
Entering in deep sleep
|
||||
|
||||
...
|
||||
|
||||
ULP-RISC-V woke up the main CPU!
|
||||
ULP-RISC-V read changes in GPIO_0 current is: High
|
||||
Entering in deep sleep
|
||||
|
||||
```
|
||||
@@ -0,0 +1,48 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import re
|
||||
import time
|
||||
|
||||
import tiny_test_fw
|
||||
import ttfw_idf
|
||||
from tiny_test_fw import DUT
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32s2', 'esp32s3'])
|
||||
def test_examples_ulp_riscv(env, extra_data): # type: (tiny_test_fw.Env.Env, None) -> None # pylint: disable=unused-argument
|
||||
dut = env.get_dut('ulp_riscv', 'examples/system/ulp_riscv/gpio')
|
||||
dut.start_app()
|
||||
|
||||
dut.expect_all('Not a ULP-RISC-V wakeup, initializing it!',
|
||||
'Entering in deep sleep',
|
||||
timeout=30)
|
||||
|
||||
# Give the chip time to enter deepsleep
|
||||
time.sleep(1)
|
||||
|
||||
# Run two times to make sure device sleep
|
||||
# and wake up properly
|
||||
for i in range(0, 2):
|
||||
# Set GPIO0 using DTR
|
||||
dut.port_inst.setDTR(i % 2 == 0)
|
||||
|
||||
dut.expect('ULP-RISC-V woke up the main CPU!', timeout=5)
|
||||
|
||||
# Check GPIO state
|
||||
state = 'Low' if i % 2 == 0 else 'High'
|
||||
dut.expect(re.compile(r'ULP-RISC-V read changes in GPIO_0 current is: %s' % state), timeout=5)
|
||||
|
||||
# Go back to sleep
|
||||
dut.expect('Entering in deep sleep', timeout=5)
|
||||
|
||||
try:
|
||||
# We expect a timeout here, otherwise it means that
|
||||
# the main CPU woke up unexpectedly!
|
||||
dut.expect('ULP-RISC-V woke up the main CPU!', timeout=20)
|
||||
raise Exception('Main CPU woke up unexpectedly!')
|
||||
except DUT.ExpectTimeout:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_ulp_riscv()
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user