working blink example
This commit is contained in:
14
.gitignore
vendored
14
.gitignore
vendored
@@ -1,5 +1,19 @@
|
|||||||
build/
|
build/
|
||||||
lib/idf-tools/*
|
lib/idf-tools/*
|
||||||
|
|
||||||
|
pcb/control/*
|
||||||
|
!pcb/control/README.md
|
||||||
|
!pcb/control/revisions.txt
|
||||||
|
!pcb/control/soburg2.kicad_pcb
|
||||||
|
!pcb/control/soburg2.kicad_pro
|
||||||
|
!pcb/control/soburg2.kicad_pch
|
||||||
|
|
||||||
|
pcb/panel/*
|
||||||
|
!pcb/panel/revisions.txt
|
||||||
|
!pcb/panel/wombus64_led.kicad_pcb
|
||||||
|
!pcb/panel/wombus64_led.kicad_pro
|
||||||
|
!pcb/panel/wombus64_led.kicad_pch
|
||||||
|
|
||||||
sdkconfig
|
sdkconfig
|
||||||
sdkconfig.old
|
sdkconfig.old
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(PROJECT_MAIN_COMPONENT ${CMAKE_CURRENT_LIST_DIR}/src)
|
set(PROJECT_MAIN_COMPONENT ${CMAKE_CURRENT_LIST_DIR}/src)
|
||||||
set(EXTRA_COMPONENT_DIRS ${CMAKE_CURRENT_LIST_DIR}/src)
|
|
||||||
|
set(EXTRA_COMPONENT_DIRS
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/config
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/src
|
||||||
|
)
|
||||||
|
|
||||||
# For the esp-idf configuration
|
# For the esp-idf configuration
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|||||||
@@ -393,23 +393,18 @@
|
|||||||
"rule_severities": {
|
"rule_severities": {
|
||||||
"bus_definition_conflict": "error",
|
"bus_definition_conflict": "error",
|
||||||
"bus_entry_needed": "error",
|
"bus_entry_needed": "error",
|
||||||
|
"bus_label_syntax": "error",
|
||||||
"bus_to_bus_conflict": "error",
|
"bus_to_bus_conflict": "error",
|
||||||
"bus_to_net_conflict": "error",
|
"bus_to_net_conflict": "error",
|
||||||
"conflicting_netclasses": "error",
|
|
||||||
"different_unit_footprint": "error",
|
"different_unit_footprint": "error",
|
||||||
"different_unit_net": "error",
|
"different_unit_net": "error",
|
||||||
"duplicate_reference": "error",
|
"duplicate_reference": "error",
|
||||||
"duplicate_sheet_names": "error",
|
"duplicate_sheet_names": "error",
|
||||||
"endpoint_off_grid": "warning",
|
|
||||||
"extra_units": "error",
|
"extra_units": "error",
|
||||||
"global_label_dangling": "warning",
|
"global_label_dangling": "warning",
|
||||||
"hier_label_mismatch": "error",
|
"hier_label_mismatch": "error",
|
||||||
"label_dangling": "error",
|
"label_dangling": "error",
|
||||||
"lib_symbol_issues": "warning",
|
"lib_symbol_issues": "warning",
|
||||||
"missing_bidi_pin": "warning",
|
|
||||||
"missing_input_pin": "warning",
|
|
||||||
"missing_power_pin": "error",
|
|
||||||
"missing_unit": "warning",
|
|
||||||
"multiple_net_names": "warning",
|
"multiple_net_names": "warning",
|
||||||
"net_not_bus_member": "warning",
|
"net_not_bus_member": "warning",
|
||||||
"no_connect_connected": "warning",
|
"no_connect_connected": "warning",
|
||||||
@@ -419,7 +414,6 @@
|
|||||||
"pin_to_pin": "warning",
|
"pin_to_pin": "warning",
|
||||||
"power_pin_not_driven": "error",
|
"power_pin_not_driven": "error",
|
||||||
"similar_labels": "warning",
|
"similar_labels": "warning",
|
||||||
"simulation_model_issue": "ignore",
|
|
||||||
"unannotated": "error",
|
"unannotated": "error",
|
||||||
"unit_value_mismatch": "error",
|
"unit_value_mismatch": "error",
|
||||||
"unresolved_variable": "error",
|
"unresolved_variable": "error",
|
||||||
@@ -437,7 +431,7 @@
|
|||||||
"net_settings": {
|
"net_settings": {
|
||||||
"classes": [
|
"classes": [
|
||||||
{
|
{
|
||||||
"bus_width": 12,
|
"bus_width": 12.0,
|
||||||
"clearance": 0.2,
|
"clearance": 0.2,
|
||||||
"diff_pair_gap": 0.25,
|
"diff_pair_gap": 0.25,
|
||||||
"diff_pair_via_gap": 0.25,
|
"diff_pair_via_gap": 0.25,
|
||||||
@@ -451,11 +445,11 @@
|
|||||||
"track_width": 0.2,
|
"track_width": 0.2,
|
||||||
"via_diameter": 0.6,
|
"via_diameter": 0.6,
|
||||||
"via_drill": 0.3,
|
"via_drill": 0.3,
|
||||||
"wire_width": 6
|
"wire_width": 6.0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"meta": {
|
"meta": {
|
||||||
"version": 3
|
"version": 2
|
||||||
},
|
},
|
||||||
"net_colors": null,
|
"net_colors": null,
|
||||||
"netclass_assignments": null,
|
"netclass_assignments": null,
|
||||||
@@ -587,8 +581,18 @@
|
|||||||
"version": 1
|
"version": 1
|
||||||
},
|
},
|
||||||
"net_format_name": "",
|
"net_format_name": "",
|
||||||
|
"ngspice": {
|
||||||
|
"fix_include_paths": true,
|
||||||
|
"fix_passive_vals": false,
|
||||||
|
"meta": {
|
||||||
|
"version": 0
|
||||||
|
},
|
||||||
|
"model_mode": 0,
|
||||||
|
"workbook_filename": ""
|
||||||
|
},
|
||||||
"page_layout_descr_file": "",
|
"page_layout_descr_file": "",
|
||||||
"plot_directory": "",
|
"plot_directory": "",
|
||||||
|
"spice_adjust_passive_values": false,
|
||||||
"spice_current_sheet_as_root": false,
|
"spice_current_sheet_as_root": false,
|
||||||
"spice_external_command": "spice \"%I\"",
|
"spice_external_command": "spice \"%I\"",
|
||||||
"spice_model_current_sheet_as_root": true,
|
"spice_model_current_sheet_as_root": true,
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ set -e
|
|||||||
export IDF_TOOLS_PATH=${PWD}/lib/idf-tools
|
export IDF_TOOLS_PATH=${PWD}/lib/idf-tools
|
||||||
export IDF_PATH=${PWD}/lib/esp-idf
|
export IDF_PATH=${PWD}/lib/esp-idf
|
||||||
|
|
||||||
|
export SDKCONFIG=${PWD}/config/sdkconfig
|
||||||
|
export SDKCONFIG_DEFAULTS=${PWD}/config/sdkconfig.defaults
|
||||||
|
|
||||||
. ${IDF_PATH}/export.sh
|
. ${IDF_PATH}/export.sh
|
||||||
|
|
||||||
idf.py build
|
idf.py build
|
||||||
|
|
||||||
|
# idk how to put it in the right place
|
||||||
|
mv ${PWD}/sdkconfig ${PWD}/config/sdkconfig
|
||||||
|
|||||||
@@ -12,3 +12,6 @@ idf.py set-target esp32s3
|
|||||||
idf.py -b 115200 flash
|
idf.py -b 115200 flash
|
||||||
|
|
||||||
# idf.py autodetects port but use -p <port> to specify
|
# idf.py autodetects port but use -p <port> to specify
|
||||||
|
|
||||||
|
# idk how to put it in the right place
|
||||||
|
mv ${PWD}/sdkconfig ${PWD}/config/sdkconfig
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
idf_component_register(SRCS "main.c"
|
idf_component_register(SRCS "main.c"
|
||||||
PRIV_REQUIRES spi_flash
|
PRIV_REQUIRES spi_flash
|
||||||
|
REQUIRES esp_driver_gpio
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
|
|||||||
133
src/main.c
133
src/main.c
@@ -1,50 +1,107 @@
|
|||||||
|
/* Blink Example
|
||||||
|
|
||||||
// Copied from official ESP-IDF repository
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||||
// https://github.com/espressif/esp-idf/blob/v5.5.1/examples/get-started/hello_world/main/hello_world_main.c
|
|
||||||
|
|
||||||
|
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 <stdio.h>
|
||||||
#include <inttypes.h>
|
|
||||||
#include "sdkconfig.h"
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/task.h"
|
#include "freertos/task.h"
|
||||||
#include "esp_chip_info.h"
|
#include "driver/gpio.h"
|
||||||
#include "esp_flash.h"
|
#include "esp_log.h"
|
||||||
#include "esp_system.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#ifdef CONFIG_BLINK_LED_STRIP
|
||||||
|
#include "led_strip.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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_STRIP
|
||||||
|
|
||||||
|
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
|
||||||
|
};
|
||||||
|
#if CONFIG_BLINK_LED_STRIP_BACKEND_RMT
|
||||||
|
led_strip_rmt_config_t rmt_config = {
|
||||||
|
.resolution_hz = 10 * 1000 * 1000, // 10MHz
|
||||||
|
.flags.with_dma = false,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
|
||||||
|
#elif CONFIG_BLINK_LED_STRIP_BACKEND_SPI
|
||||||
|
led_strip_spi_config_t spi_config = {
|
||||||
|
.spi_bus = SPI2_HOST,
|
||||||
|
.flags.with_dma = true,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(led_strip_new_spi_device(&strip_config, &spi_config, &led_strip));
|
||||||
|
#else
|
||||||
|
#error "unsupported LED strip backend"
|
||||||
|
#endif
|
||||||
|
/* 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "unsupported LED type"
|
||||||
|
#endif
|
||||||
|
|
||||||
void app_main(void)
|
void app_main(void)
|
||||||
{
|
{
|
||||||
printf("Hello world!\n");
|
|
||||||
|
|
||||||
/* Print chip information */
|
/* Configure the peripheral according to the LED type */
|
||||||
esp_chip_info_t chip_info;
|
configure_led();
|
||||||
uint32_t flash_size;
|
|
||||||
esp_chip_info(&chip_info);
|
|
||||||
printf("This is %s chip with %d CPU core(s), %s%s%s%s, ",
|
|
||||||
CONFIG_IDF_TARGET,
|
|
||||||
chip_info.cores,
|
|
||||||
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
|
|
||||||
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
|
|
||||||
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
|
|
||||||
(chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : "");
|
|
||||||
|
|
||||||
unsigned major_rev = chip_info.revision / 100;
|
while (1) {
|
||||||
unsigned minor_rev = chip_info.revision % 100;
|
ESP_LOGI(TAG, "Turning the LED %s!", s_led_state == true ? "ON" : "OFF");
|
||||||
printf("silicon revision v%d.%d, ", major_rev, minor_rev);
|
blink_led();
|
||||||
if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
|
/* Toggle the LED state */
|
||||||
printf("Get flash size failed");
|
s_led_state = !s_led_state;
|
||||||
return;
|
vTaskDelay(CONFIG_BLINK_PERIOD / portTICK_PERIOD_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
|
|
||||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
|
|
||||||
|
|
||||||
printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
|
|
||||||
|
|
||||||
for (int i = 10; i >= 0; i--) {
|
|
||||||
printf("Restarting in %d seconds...\n", i);
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
||||||
}
|
|
||||||
printf("Restarting now.\n");
|
|
||||||
fflush(stdout);
|
|
||||||
esp_restart();
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user