Exemplos do livro Microcontroladores ESP32 como projetos PlatformIO
Compilar exemplos / esp32 (push) Canceled after 21m59s
Compilar exemplos / esp32c2 (push) Canceled after 0s
Compilar exemplos / esp32c3 (push) Canceled after 0s
Compilar exemplos / esp32c5 (push) Canceled after 0s
Compilar exemplos / esp32c6 (push) Canceled after 0s
Compilar exemplos / esp32c61 (push) Canceled after 0s
Compilar exemplos / esp32h2 (push) Canceled after 0s
Compilar exemplos / esp32p4 (push) Canceled after 0s
Compilar exemplos / esp32s2 (push) Canceled after 0s
Compilar exemplos / esp32s3 (push) Canceled after 0s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-10 12:10:42 -03:00
commit 5f5506c55c
592 files changed
+12559

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(pane)
@@ -0,0 +1,3 @@
idf_component_register(SRCS "main.c"
INCLUDE_DIRS "."
PRIV_REQUIRES esp_system esp_event)
@@ -0,0 +1,17 @@
menu "Pane (exemplo do livro)"
choice PANE_TIPO
prompt "Falha a provocar"
default PANE_PONTEIRO_NULO
config PANE_PONTEIRO_NULO
bool "Escrita por ponteiro nulo"
config PANE_ESTOURO_PILHA
bool "Estouro de pilha de uma tarefa"
config PANE_WATCHDOG
bool "Tarefa presa sem ceder a CPU"
config PANE_ERROR_CHECK
bool "ESP_ERROR_CHECK com erro"
endchoice
endmenu
+67
View File
@@ -0,0 +1,67 @@
#include <stdint.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_task_wdt.h"
#include "sdkconfig.h"
static const char *TAG = "pane";
#if CONFIG_PANE_PONTEIRO_NULO
static void gravar_leitura(uint32_t *destino, uint32_t valor)
{
*destino = valor; /* destino NULL: a falha é aqui */
}
static void provocar(void)
{
uint32_t *sensor = NULL; /* deveria apontar para um buffer */
gravar_leitura(sensor, 42);
}
#elif CONFIG_PANE_ESTOURO_PILHA
static int consumir(int n)
{
volatile char local[256]; /* cada nível ocupa mais 256 bytes */
memset((char *)local, n, sizeof(local));
return n > 0 ? consumir(n - 1) + local[0] : local[0];
}
static void tarefa_pequena(void *arg)
{
int r = consumir(12); /* ~3 KB numa pilha de 2 KB */
vTaskDelay(1); /* a troca de contexto confere a pilha */
ESP_LOGI(TAG, "não deveria chegar aqui (%d)", r);
vTaskDelete(NULL);
}
static void provocar(void)
{
xTaskCreate(tarefa_pequena, "pequena", 2048, NULL, 5, NULL);
}
#elif CONFIG_PANE_WATCHDOG
static void provocar(void)
{
ESP_ERROR_CHECK(esp_task_wdt_add(NULL));
while (1) {
/* laço sem vTaskDelay: a tarefa ociosa nunca roda */
}
}
#elif CONFIG_PANE_ERROR_CHECK
static void provocar(void)
{
/* apaga o laço de eventos padrão sem tê-lo criado */
ESP_ERROR_CHECK(esp_event_loop_delete_default());
}
#endif
void app_main(void)
{
ESP_LOGI(TAG, "A falha vem em 3 s");
vTaskDelay(pdMS_TO_TICKS(3000));
provocar();
}
+5
View File
@@ -0,0 +1,5 @@
# Nome, Tipo, Subtipo, Offset, Tamanho
nvs, data, nvs, 0x9000, 0x6000
phy_init, data, phy, 0xf000, 0x1000
factory, app, factory, 0x10000, 0x100000
coredump, data, coredump, , 64K
1 # Nome Tipo Subtipo Offset Tamanho
2 nvs data nvs 0x9000 0x6000
3 phy_init data phy 0xf000 0x1000
4 factory app factory 0x10000 0x100000
5 coredump data coredump 64K
+22
View File
@@ -0,0 +1,22 @@
; Projeto PlatformIO. Compile com: pio run -e <série>
; Grave e abra o monitor: pio run -e <série> -t upload -t monitor
[platformio]
default_envs = esp32
src_dir = main
[env]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
framework = espidf
monitor_speed = 115200
[env:esp32]
board = esp32dev
[env:esp32s3]
board = esp32-s3-devkitc-1
[env:esp32c3]
board = esp32-c3-devkitm-1
[env:esp32c6]
board = esp32-c6-devkitc-1
@@ -0,0 +1,3 @@
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=y