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
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:
commit
5f5506c55c
592 files changed
+12559
No files matched your search
@@ -0,0 +1,50 @@
|
|||||||
|
name: Compilar exemplos
|
||||||
|
|
||||||
|
# Compila todos os projetos em todas as séries que cada um declara no
|
||||||
|
# platformio.ini. Um job por série; o cache guarda plataforma e toolchains.
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
paths-ignore: ['**.md', 'LICENSE']
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: compilar-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
compilar:
|
||||||
|
name: ${{ matrix.serie }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 300
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
serie: [esp32, esp32s2, esp32s3, esp32c2, esp32c3, esp32c5, esp32c6, esp32c61, esp32h2, esp32p4]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.platformio
|
||||||
|
key: pio-${{ runner.arch }}-${{ matrix.serie }}-${{ hashFiles('**/platformio.ini') }}
|
||||||
|
restore-keys: pio-${{ runner.arch }}-${{ matrix.serie }}-
|
||||||
|
- name: Instalar o PlatformIO
|
||||||
|
run: |
|
||||||
|
python3 -m venv ~/pio-venv
|
||||||
|
~/pio-venv/bin/pip install -q platformio
|
||||||
|
- name: Compilar
|
||||||
|
env:
|
||||||
|
SERIE: ${{ matrix.serie }}
|
||||||
|
run: |
|
||||||
|
falhas=0; total=0
|
||||||
|
for ini in $(grep -l "^\[env:${SERIE}\]" capitulo-*/*/platformio.ini | sort); do
|
||||||
|
d=$(dirname "$ini"); total=$((total+1))
|
||||||
|
if ~/pio-venv/bin/pio run -s -d "$d" -e "$SERIE" > log.txt 2>&1; then
|
||||||
|
echo "OK $d"
|
||||||
|
else
|
||||||
|
echo "FALHA $d"; tail -60 log.txt; falhas=$((falhas+1))
|
||||||
|
fi
|
||||||
|
rm -rf "$d/.pio"
|
||||||
|
done
|
||||||
|
echo "$((total-falhas))/$total compilações OK em $SERIE"
|
||||||
|
test "$falhas" -eq 0
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.pio/
|
||||||
|
.vscode/
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 Lucas Rayan Guerra
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,210 @@
|
|||||||
|
# Microcontroladores ESP32: códigos do livro
|
||||||
|
|
||||||
|
Códigos-fonte dos exemplos do livro **Microcontroladores ESP32: Conectividade,
|
||||||
|
Eficiência e Desempenho**, de Lucas Rayan Guerra (Ciência Embarcada).
|
||||||
|
|
||||||
|
Cada exemplo é um projeto [PlatformIO](https://platformio.org) completo, pronto
|
||||||
|
para compilar e gravar, em ESP-IDF ou em Arduino, com um ambiente para cada
|
||||||
|
série de ESP32 em que ele foi testado.
|
||||||
|
|
||||||
|
[](https://git.lucasrguerra.dev.br/lucasrguerra/microcontroladores-esp32-codigos/actions?workflow=compilar.yml)
|
||||||
|
|
||||||
|
## Como usar
|
||||||
|
|
||||||
|
1. Instale o [PlatformIO](https://platformio.org/install) (extensão do VS Code ou `pip install platformio`, versão 6.2 ou mais nova).
|
||||||
|
2. Abra a pasta do exemplo (não a raiz do repositório) no VS Code, ou entre nela pelo terminal.
|
||||||
|
3. Compile, grave e abra o monitor serial, escolhendo a série da sua placa:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd capitulo-01/pisca-esp-idf
|
||||||
|
pio run -e esp32c6 # só compila
|
||||||
|
pio run -e esp32c6 -t upload -t monitor # grava e abre o monitor (115200)
|
||||||
|
```
|
||||||
|
|
||||||
|
Os ambientes se chamam `esp32`, `esp32s2`, `esp32s3`, `esp32c2`, `esp32c3`,
|
||||||
|
`esp32c5`, `esp32c6`, `esp32c61`, `esp32h2` e `esp32p4`. Cada um usa a placa
|
||||||
|
de desenvolvimento oficial da Espressif para aquela série; se a sua for outra,
|
||||||
|
troque o `board` no `platformio.ini`.
|
||||||
|
|
||||||
|
Os projetos ESP-IDF mantêm a estrutura padrão (`CMakeLists.txt` + `main/`):
|
||||||
|
também compilam fora do PlatformIO, com `idf.py set-target esp32c6 build`.
|
||||||
|
|
||||||
|
## Versões
|
||||||
|
|
||||||
|
- Plataforma: [pioarduino](https://github.com/pioarduino/platform-espressif32) `55.03.312`
|
||||||
|
(Arduino Core 3.3 sobre ESP-IDF 5.5), fixada em todos os projetos.
|
||||||
|
- O livro usa o ESP-IDF 6.0 como referência. Os exemplos ESP-IDF também são
|
||||||
|
compilados no ESP-IDF 6.0 e 5.5 oficiais; o PlatformIO ainda não tem o 6.0
|
||||||
|
em versão estável, por isso aqui eles rodam sobre o 5.5.
|
||||||
|
- Todos os projetos são compilados em todas as séries listadas a cada
|
||||||
|
alteração (Gitea Actions).
|
||||||
|
|
||||||
|
## Exemplos
|
||||||
|
|
||||||
|
| Capítulo | Projeto | Framework | Séries |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 1 · O que é um Microcontrolador | [`pisca-arduino`](capitulo-01/pisca-arduino) | Arduino | todas |
|
||||||
|
| 1 · O que é um Microcontrolador | [`pisca-esp-idf`](capitulo-01/pisca-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 2 · Por Dentro de um Computador em um Chip | [`ciclos-arduino`](capitulo-02/ciclos-arduino) | Arduino | todas |
|
||||||
|
| 2 · Por Dentro de um Computador em um Chip | [`interrupcao-esp-idf`](capitulo-02/interrupcao-esp-idf) | ESP-IDF | ESP32, S2, S3, C3, C6, H2 |
|
||||||
|
| 2 · Por Dentro de um Computador em um Chip | [`registradores-esp-idf`](capitulo-02/registradores-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 3 · MCU, MPU, SoC e FPGA | [`jitter-esp-idf`](capitulo-03/jitter-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 4 · A História da Espressif | [`qual-chip-arduino`](capitulo-04/qual-chip-arduino) | Arduino | todas |
|
||||||
|
| 4 · A História da Espressif | [`qual-chip-esp-idf`](capitulo-04/qual-chip-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 6 · Os Núcleos: Xtensa e RISC-V | [`fpu-esp-idf`](capitulo-06/fpu-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 6 · Os Núcleos: Xtensa e RISC-V | [`nucleos-esp-idf`](capitulo-06/nucleos-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 7 · Memória: ROM, SRAM, Cache, Flash e PSRAM | [`memoria-esp-idf`](capitulo-07/memoria-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 7 · Memória: ROM, SRAM, Cache, Flash e PSRAM | [`psram-esp-idf`](capitulo-07/psram-esp-idf) | ESP-IDF | ESP32, S2, S3, C5, C61, P4 |
|
||||||
|
| 7 · Memória: ROM, SRAM, Cache, Flash e PSRAM | [`rtc-contador-esp-idf`](capitulo-07/rtc-contador-esp-idf) | ESP-IDF | ESP32, S2, S3, C3, C5, C6, H2, P4 |
|
||||||
|
| 8 · Clocks e Relógios | [`clocks-arduino`](capitulo-08/clocks-arduino) | Arduino | todas |
|
||||||
|
| 8 · Clocks e Relógios | [`clocks-esp-idf`](capitulo-08/clocks-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 9 · GPIO, IO MUX e Matriz de GPIO | [`gpio-modos-esp-idf`](capitulo-09/gpio-modos-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 9 · GPIO, IO MUX e Matriz de GPIO | [`modos-gpio-arduino`](capitulo-09/modos-gpio-arduino) | Arduino | todas |
|
||||||
|
| 10 · Alimentação, Reset e Domínios de Energia | [`motivo-reset-arduino`](capitulo-10/motivo-reset-arduino) | Arduino | todas |
|
||||||
|
| 10 · Alimentação, Reset e Domínios de Energia | [`motivo-reset-esp-idf`](capitulo-10/motivo-reset-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 11 · Do Reset ao app_main() | [`identidade-esp-idf`](capitulo-11/identidade-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 12 · ESP32: o Clássico | [`dac-rampa-esp-idf`](capitulo-12/dac-rampa-esp-idf) | ESP-IDF | ESP32, S2 |
|
||||||
|
| 12 · ESP32: o Clássico | [`rampa-arduino`](capitulo-12/rampa-arduino) | Arduino | ESP32 |
|
||||||
|
| 12 · ESP32: o Clássico | [`revisao-chip-arduino`](capitulo-12/revisao-chip-arduino) | Arduino | ESP32 |
|
||||||
|
| 12 · ESP32: o Clássico | [`revisao-chip-esp-idf`](capitulo-12/revisao-chip-esp-idf) | ESP-IDF | ESP32 |
|
||||||
|
| 13 · ESP32-S2 | [`teclado-usb-arduino`](capitulo-13/teclado-usb-arduino) | Arduino | S2, S3 |
|
||||||
|
| 13 · ESP32-S2 | [`usb-eco-esp-idf`](capitulo-13/usb-eco-esp-idf) | ESP-IDF | S2, S3 |
|
||||||
|
| 14 · ESP32-S3 e ESP32-S31 | [`dsp-vetor-esp-idf`](capitulo-14/dsp-vetor-esp-idf) | ESP-IDF | ESP32, S3, C3 |
|
||||||
|
| 14 · ESP32-S3 e ESP32-S31 | [`quadro-psram-arduino`](capitulo-14/quadro-psram-arduino) | Arduino | ESP32, S3 |
|
||||||
|
| 15 · ESP32-C2 e ESP32-C3 | [`despertares-arduino`](capitulo-15/despertares-arduino) | Arduino | C3 |
|
||||||
|
| 15 · ESP32-C2 e ESP32-C3 | [`despertares-esp-idf`](capitulo-15/despertares-esp-idf) | ESP-IDF | C2, C3 |
|
||||||
|
| 16 · ESP32-C5, ESP32-C6 e ESP32-C61 | [`varredura-arduino`](capitulo-16/varredura-arduino) | Arduino | C5, C6 |
|
||||||
|
| 16 · ESP32-C5, ESP32-C6 e ESP32-C61 | [`varredura-wifi6-esp-idf`](capitulo-16/varredura-wifi6-esp-idf) | ESP-IDF | C3, C5, C6, C61 |
|
||||||
|
| 17 · ESP32-H2 e ESP32-H4 | [`farol-termometro-arduino`](capitulo-17/farol-termometro-arduino) | Arduino | C6, H2 |
|
||||||
|
| 17 · ESP32-H2 e ESP32-H4 | [`ruido-802154-esp-idf`](capitulo-17/ruido-802154-esp-idf) | ESP-IDF | C5, C6, H2 |
|
||||||
|
| 18 · ESP32-P4 | [`ethernet-p4-arduino`](capitulo-18/ethernet-p4-arduino) | Arduino | P4 |
|
||||||
|
| 18 · ESP32-P4 | [`jpeg-p4-esp-idf`](capitulo-18/jpeg-p4-esp-idf) | ESP-IDF | P4 |
|
||||||
|
| 19 · Chips, Módulos e Placas | [`confere-modulo-arduino`](capitulo-19/confere-modulo-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 19 · Chips, Módulos e Placas | [`inspecao-esp-idf`](capitulo-19/inspecao-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 20 · Como Escolher o ESP32 Certo | [`capacidades-esp-idf`](capitulo-20/capacidades-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 21 · O Circuito Mínimo | [`bancada-esp-idf`](capitulo-21/bancada-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 22 · Alimentação: Reguladores, Baterias e Proteção | [`bateria-arduino`](capitulo-22/bateria-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 22 · Alimentação: Reguladores, Baterias e Proteção | [`bateria-esp-idf`](capitulo-22/bateria-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 23 · USB: Ponte Serial e USB Nativo | [`usj-eco-esp-idf`](capitulo-23/usj-eco-esp-idf) | ESP-IDF | S3, C3, C6 |
|
||||||
|
| 24 · RF e Antena | [`varre-rssi-arduino`](capitulo-24/varre-rssi-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 24 · RF e Antena | [`varre-rssi-esp-idf`](capitulo-24/varre-rssi-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 25 · Erros Clássicos de Projeto | [`auditoria-pinos-esp-idf`](capitulo-25/auditoria-pinos-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 26 · Primeiros Passos com Arduino | [`pisca-serial-arduino`](capitulo-26/pisca-serial-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 26 · Primeiros Passos com Arduino | [`por-tras-arduino`](capitulo-26/por-tras-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 27 · Instalando o ESP-IDF | [`ola-esp-idf`](capitulo-27/ola-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 28 · Anatomia de um Projeto ESP-IDF | [`anatomia-esp-idf`](capitulo-28/anatomia-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 29 · Flash, Partições e Ferramentas | [`particoes-esp-idf`](capitulo-29/particoes-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 30 · Depuração | [`pane-esp-idf`](capitulo-30/pane-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 31 · GPIO e Interrupções | [`botao-isr-esp-idf`](capitulo-31/botao-isr-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 31 · GPIO e Interrupções | [`gpio-dedicado-esp-idf`](capitulo-31/gpio-dedicado-esp-idf) | ESP-IDF | S3, C3, C6 |
|
||||||
|
| 31 · GPIO e Interrupções | [`hold-sono-esp-idf`](capitulo-31/hold-sono-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 31 · GPIO e Interrupções | [`repique-botao-arduino`](capitulo-31/repique-botao-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 32 · ADC, DAC e Sensores Internos | [`adc-dma-esp-idf`](capitulo-32/adc-dma-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 32 · ADC, DAC e Sensores Internos | [`dac-ondas-esp-idf`](capitulo-32/dac-ondas-esp-idf) | ESP-IDF | ESP32, S2 |
|
||||||
|
| 32 · ADC, DAC e Sensores Internos | [`leitura-continua-arduino`](capitulo-32/leitura-continua-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 32 · ADC, DAC e Sensores Internos | [`temperatura-esp-idf`](capitulo-32/temperatura-esp-idf) | ESP-IDF | S3, C3, C6 |
|
||||||
|
| 33 · PWM: LEDC e MCPWM | [`ledc-fade-esp-idf`](capitulo-33/ledc-fade-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 33 · PWM: LEDC e MCPWM | [`mede-pulso-esp-idf`](capitulo-33/mede-pulso-esp-idf) | ESP-IDF | ESP32, S3, C6 |
|
||||||
|
| 33 · PWM: LEDC e MCPWM | [`meia-ponte-esp-idf`](capitulo-33/meia-ponte-esp-idf) | ESP-IDF | ESP32, S3, C6 |
|
||||||
|
| 33 · PWM: LEDC e MCPWM | [`servo-led-arduino`](capitulo-33/servo-led-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 34 · Timers e Watchdogs | [`relogios-esp-idf`](capitulo-34/relogios-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 34 · Timers e Watchdogs | [`timer-hw-arduino`](capitulo-34/timer-hw-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 34 · Timers e Watchdogs | [`vigia-esp-idf`](capitulo-34/vigia-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 35 · RMT | [`fita-led-esp-idf`](capitulo-35/fita-led-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 35 · RMT | [`fita-rmt-arduino`](capitulo-35/fita-rmt-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 35 · RMT | [`rmt-eco-esp-idf`](capitulo-35/rmt-eco-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 36 · UART | [`ponte-serial-arduino`](capitulo-36/ponte-serial-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 36 · UART | [`rs485-esp-idf`](capitulo-36/rs485-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 36 · UART | [`uart-linhas-esp-idf`](capitulo-36/uart-linhas-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 37 · I²C | [`i2c-sensor-esp-idf`](capitulo-37/i2c-sensor-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 37 · I²C | [`varre-i2c-arduino`](capitulo-37/varre-i2c-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 38 · SPI | [`id-flash-arduino`](capitulo-38/id-flash-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 38 · SPI | [`spi-dma-eco-esp-idf`](capitulo-38/spi-dma-eco-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 38 · SPI | [`spi-flash-id-esp-idf`](capitulo-38/spi-flash-id-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 39 · I²S e PDM | [`mic-pdm-esp-idf`](capitulo-39/mic-pdm-esp-idf) | ESP-IDF | ESP32, S3 |
|
||||||
|
| 39 · I²S e PDM | [`nivel-microfone-arduino`](capitulo-39/nivel-microfone-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 39 · I²S e PDM | [`tom-i2s-esp-idf`](capitulo-39/tom-i2s-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 40 · TWAI: CAN | [`can-auto-teste-arduino`](capitulo-40/can-auto-teste-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 40 · TWAI: CAN | [`twai-no-esp-idf`](capitulo-40/twai-no-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 41 · Touch, PCNT, SDM e Outros | [`encoder-pcnt-esp-idf`](capitulo-41/encoder-pcnt-esp-idf) | ESP-IDF | ESP32, S3, C6 |
|
||||||
|
| 41 · Touch, PCNT, SDM e Outros | [`etm-onda-esp-idf`](capitulo-41/etm-onda-esp-idf) | ESP-IDF | C6 |
|
||||||
|
| 41 · Touch, PCNT, SDM e Outros | [`sdm-led-esp-idf`](capitulo-41/sdm-led-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 41 · Touch, PCNT, SDM e Outros | [`toque-led-arduino`](capitulo-41/toque-led-arduino) | Arduino | ESP32, S3 |
|
||||||
|
| 42 · Coprocessadores de Baixa Potência | [`lp-vigia-esp-idf`](capitulo-42/lp-vigia-esp-idf) | ESP-IDF | C5, C6, P4 |
|
||||||
|
| 42 · Coprocessadores de Baixa Potência | [`ulp-fsm-conta-esp-idf`](capitulo-42/ulp-fsm-conta-esp-idf) | ESP-IDF | ESP32 |
|
||||||
|
| 43 · FreeRTOS no ESP32 | [`pilha-esp-idf`](capitulo-43/pilha-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 43 · FreeRTOS no ESP32 | [`tarefas-esp-idf`](capitulo-43/tarefas-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 43 · FreeRTOS no ESP32 | [`tres-tarefas-arduino`](capitulo-43/tres-tarefas-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 44 · Comunicação entre Tarefas | [`coordena-esp-idf`](capitulo-44/coordena-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 44 · Comunicação entre Tarefas | [`corrida-esp-idf`](capitulo-44/corrida-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 44 · Comunicação entre Tarefas | [`fila-sensor-arduino`](capitulo-44/fila-sensor-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 45 · Memória Dinâmica | [`corrompe-esp-idf`](capitulo-45/corrompe-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 45 · Memória Dinâmica | [`fragmenta-esp-idf`](capitulo-45/fragmenta-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 45 · Memória Dinâmica | [`memoria-arduino-arduino`](capitulo-45/memoria-arduino-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 45 · Memória Dinâmica | [`vazamento-esp-idf`](capitulo-45/vazamento-esp-idf) | ESP-IDF | ESP32, S3 |
|
||||||
|
| 46 · Armazenamento | [`cartao-sd-esp-idf`](capitulo-46/cartao-sd-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 46 · Armazenamento | [`nvs-boot-esp-idf`](capitulo-46/nvs-boot-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 46 · Armazenamento | [`persistencia-arduino`](capitulo-46/persistencia-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 46 · Armazenamento | [`registro-fat-esp-idf`](capitulo-46/registro-fat-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 47 · Eventos, Logs e Tratamento de Erros | [`erros-esp-idf`](capitulo-47/erros-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 47 · Eventos, Logs e Tratamento de Erros | [`eventos-esp-idf`](capitulo-47/eventos-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 47 · Eventos, Logs e Tratamento de Erros | [`falhas-seguidas-arduino`](capitulo-47/falhas-seguidas-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 48 · Componentes e Component Manager | [`config-json-esp-idf`](capitulo-48/config-json-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 48 · Componentes e Component Manager | [`media-movel-esp-idf`](capitulo-48/media-movel-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 48 · Componentes e Component Manager | [`misto-esp-idf`](capitulo-48/misto-esp-idf) | ESP-IDF | ESP32, S3, C3 |
|
||||||
|
| 49 · Wi-Fi: Fundamentos e Modo Estação | [`estacao-esp-idf`](capitulo-49/estacao-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 49 · Wi-Fi: Fundamentos e Modo Estação | [`estacao-wi-fi-arduino`](capitulo-49/estacao-wi-fi-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 50 · Wi-Fi Avançado | [`ap-sta-esp-idf`](capitulo-50/ap-sta-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 50 · Wi-Fi Avançado | [`farejador-esp-idf`](capitulo-50/farejador-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 50 · Wi-Fi Avançado | [`ponto-acesso-arduino`](capitulo-50/ponto-acesso-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 50 · Wi-Fi Avançado | [`provisionamento-arduino`](capitulo-50/provisionamento-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 51 · Bluetooth: Classic e Low Energy | [`observador-esp-idf`](capitulo-51/observador-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 51 · Bluetooth: Classic e Low Energy | [`serial-bluetooth-arduino`](capitulo-51/serial-bluetooth-arduino) | Arduino | ESP32 |
|
||||||
|
| 51 · Bluetooth: Classic e Low Energy | [`servidor-ble-arduino`](capitulo-51/servidor-ble-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 52 · BLE na Prática | [`cliente-ble-arduino`](capitulo-52/cliente-ble-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 52 · BLE na Prática | [`gatt-nimble-esp-idf`](capitulo-52/gatt-nimble-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 53 · ESP-NOW | [`esp-now-difusao-arduino`](capitulo-53/esp-now-difusao-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 53 · ESP-NOW | [`espnow-par-esp-idf`](capitulo-53/espnow-par-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 54 · Thread, Zigbee e Matter | [`no-thread-esp-idf`](capitulo-54/no-thread-esp-idf) | ESP-IDF | C5, C6, H2 |
|
||||||
|
| 54 · Thread, Zigbee e Matter | [`sensor-zigbee-arduino`](capitulo-54/sensor-zigbee-arduino) | Arduino | C6, H2 |
|
||||||
|
| 55 · Ethernet | [`eth-dhcp-esp-idf`](capitulo-55/eth-dhcp-esp-idf) | ESP-IDF | ESP32, P4 |
|
||||||
|
| 55 · Ethernet | [`ethernet-w5500-arduino`](capitulo-55/ethernet-w5500-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 56 · Protocolos de Aplicação | [`cliente-https-esp-idf`](capitulo-56/cliente-https-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 56 · Protocolos de Aplicação | [`mqtt-eco-esp-idf`](capitulo-56/mqtt-eco-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 56 · Protocolos de Aplicação | [`servidor-hora-arduino`](capitulo-56/servidor-hora-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 57 · Modos de Energia | [`modos-sono-arduino`](capitulo-57/modos-sono-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 57 · Modos de Energia | [`modos-sono-esp-idf`](capitulo-57/modos-sono-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 58 · Fontes de Despertar e Retenção | [`botao-light-sleep-arduino`](capitulo-58/botao-light-sleep-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 58 · Fontes de Despertar e Retenção | [`desperta-pino-esp-idf`](capitulo-58/desperta-pino-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 59 · Gerenciamento Automático de Energia | [`economia-wi-fi-arduino`](capitulo-59/economia-wi-fi-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 59 · Gerenciamento Automático de Energia | [`wifi-economia-esp-idf`](capitulo-59/wifi-economia-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 60 · Medindo e Projetando para Bateria | [`autonomia-esp-idf`](capitulo-60/autonomia-esp-idf) | ESP-IDF | todas |
|
||||||
|
| 60 · Medindo e Projetando para Bateria | [`no-bateria-esp-idf`](capitulo-60/no-bateria-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 60 · Medindo e Projetando para Bateria | [`sensor-bateria-arduino`](capitulo-60/sensor-bateria-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 61 · Segurança no ESP32 | [`cripto-hw-esp-idf`](capitulo-61/cripto-hw-esp-idf) | ESP-IDF | ESP32, S3, C2, C3, C6, H2, P4 |
|
||||||
|
| 61 · Segurança no ESP32 | [`sorteio-seguro-arduino`](capitulo-61/sorteio-seguro-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 62 · eFuses | [`efuse-serie-esp-idf`](capitulo-62/efuse-serie-esp-idf) | ESP-IDF | S3, C3, C5, C6, H2, P4 |
|
||||||
|
| 62 · eFuses | [`identidade-efuse-arduino`](capitulo-62/identidade-efuse-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 63 · Secure Boot | [`boot-assinado-esp-idf`](capitulo-63/boot-assinado-esp-idf) | ESP-IDF | ESP32, S3, C2, C3, C5, C6, H2, P4 |
|
||||||
|
| 64 · Criptografia da Flash e da NVS | [`flash-cifrada-esp-idf`](capitulo-64/flash-cifrada-esp-idf) | ESP-IDF | ESP32, S3, C2, C3, C5, C6, H2, P4 |
|
||||||
|
| 66 · Atualização OTA | [`ota-eco-esp-idf`](capitulo-66/ota-eco-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 67 · Da Bancada à Fábrica | [`dados-fabrica-esp-idf`](capitulo-67/dados-fabrica-esp-idf) | ESP-IDF | ESP32, S3, C2, C3, C6, H2, P4 |
|
||||||
|
| 68 · Displays e Interfaces Gráficas | [`barras-lcd-arduino`](capitulo-68/barras-lcd-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 68 · Displays e Interfaces Gráficas | [`painel-lvgl-esp-idf`](capitulo-68/painel-lvgl-esp-idf) | ESP-IDF | ESP32, S3, C3 |
|
||||||
|
| 69 · Câmera e Vídeo | [`foto-web-arduino`](capitulo-69/foto-web-arduino) | Arduino | ESP32, S3 |
|
||||||
|
| 69 · Câmera e Vídeo | [`jpeg-quadro-esp-idf`](capitulo-69/jpeg-quadro-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 70 · Áudio | [`audio-codecs-esp-idf`](capitulo-70/audio-codecs-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 70 · Áudio | [`gravador-wav-arduino`](capitulo-70/gravador-wav-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 71 · IA na Borda | [`tflm-seno-esp-idf`](capitulo-71/tflm-seno-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 72 · DSP e Processamento de Sinais | [`espectro-mic-arduino`](capitulo-72/espectro-mic-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
| 72 · DSP e Processamento de Sinais | [`fft-filtro-esp-idf`](capitulo-72/fft-filtro-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 73 · USB Device e Host | [`leitor-barras-arduino`](capitulo-73/leitor-barras-arduino) | Arduino | S2, S3, P4 |
|
||||||
|
| 73 · USB Device e Host | [`usb-pendrive-esp-idf`](capitulo-73/usb-pendrive-esp-idf) | ESP-IDF | S2, S3, P4 |
|
||||||
|
| 78 · Comparativo Final de Frameworks | [`linha-base-esp-idf`](capitulo-78/linha-base-esp-idf) | ESP-IDF | ESP32, S3, C3, C6 |
|
||||||
|
| 78 · Comparativo Final de Frameworks | [`soma-base-arduino`](capitulo-78/soma-base-arduino) | Arduino | ESP32, S3, C3, C6 |
|
||||||
|
|
||||||
|
## Licença
|
||||||
|
|
||||||
|
Códigos sob a licença [MIT](LICENSE): use, modifique e distribua à vontade,
|
||||||
|
inclusive em projetos comerciais. O texto do livro não faz parte deste
|
||||||
|
repositório e não está sob esta licença.
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
board = esp32dev
|
||||||
|
|
||||||
|
[env:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
const int PINO_LED = 4; // GPIO onde o LED está ligado
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
pinMode(PINO_LED, OUTPUT); // configura o pino como saída
|
||||||
|
Serial.begin(115200);
|
||||||
|
Serial.println("Pisca iniciado");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
digitalWrite(PINO_LED, HIGH); // 3,3 V no pino: LED aceso
|
||||||
|
delay(500); // espera 500 ms
|
||||||
|
digitalWrite(PINO_LED, LOW); // 0 V no pino: LED apagado
|
||||||
|
delay(500);
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(pisca)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#define PINO_LED GPIO_NUM_4
|
||||||
|
static const char *TAG = "pisca";
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
gpio_reset_pin(PINO_LED); // estado padrão
|
||||||
|
gpio_set_direction(PINO_LED, GPIO_MODE_OUTPUT); // pino como saída
|
||||||
|
ESP_LOGI(TAG, "Pisca iniciado no GPIO %d", PINO_LED);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
gpio_set_level(PINO_LED, 1); // LED aceso
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(500)); // dorme 500 ms
|
||||||
|
gpio_set_level(PINO_LED, 0); // LED apagado
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(500));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
board = esp32dev
|
||||||
|
|
||||||
|
[env:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
volatile uint32_t soma = 0; // volatile: o compilador não pode eliminar o laço
|
||||||
|
uint32_t t0 = ESP.getCycleCount();
|
||||||
|
for (int i = 0; i < 1000; i++) {
|
||||||
|
soma += i;
|
||||||
|
}
|
||||||
|
uint32_t t1 = ESP.getCycleCount();
|
||||||
|
|
||||||
|
Serial.printf("CPU a %lu MHz\n", (unsigned long)getCpuFrequencyMhz());
|
||||||
|
Serial.printf("1000 somas: %lu ciclos (%.1f ciclos por volta)\n",
|
||||||
|
(unsigned long)(t1 - t0), (t1 - t0) / 1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(interrupcao)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/queue.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_timer.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
// O botão BOOT das placas oficiais fica no GPIO 0 nas séries Xtensa e no GPIO 9 em várias RISC-V.
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||||
|
#define PINO_BOTAO GPIO_NUM_0
|
||||||
|
#else
|
||||||
|
#define PINO_BOTAO GPIO_NUM_9
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char *TAG = "isr";
|
||||||
|
static QueueHandle_t fila;
|
||||||
|
|
||||||
|
static void IRAM_ATTR isr_botao(void *arg)
|
||||||
|
{
|
||||||
|
int64_t agora = esp_timer_get_time(); // microssegundos desde o boot
|
||||||
|
BaseType_t acordou_tarefa = pdFALSE;
|
||||||
|
xQueueSendFromISR(fila, &agora, &acordou_tarefa);
|
||||||
|
if (acordou_tarefa) {
|
||||||
|
portYIELD_FROM_ISR(); // troca já para a tarefa que espera
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
fila = xQueueCreate(10, sizeof(int64_t));
|
||||||
|
|
||||||
|
gpio_config_t cfg = {
|
||||||
|
.pin_bit_mask = 1ULL << PINO_BOTAO,
|
||||||
|
.mode = GPIO_MODE_INPUT,
|
||||||
|
.pull_up_en = GPIO_PULLUP_ENABLE, // botão liga o pino ao GND
|
||||||
|
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||||
|
.intr_type = GPIO_INTR_NEGEDGE, // interrompe na borda de descida
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(gpio_config(&cfg));
|
||||||
|
ESP_ERROR_CHECK(gpio_install_isr_service(0));
|
||||||
|
ESP_ERROR_CHECK(gpio_isr_handler_add(PINO_BOTAO, isr_botao, NULL));
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Pressione o botão no GPIO %d", PINO_BOTAO);
|
||||||
|
int64_t instante;
|
||||||
|
while (1) {
|
||||||
|
if (xQueueReceive(fila, &instante, portMAX_DELAY)) {
|
||||||
|
ESP_LOGI(TAG, "Interrupção em t = %lld us", instante);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(registradores)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "esp_cpu.h" // esp_cpu_get_cycle_count()
|
||||||
|
#include "soc/gpio_reg.h" // endereços dos registradores de GPIO
|
||||||
|
|
||||||
|
#define PINO GPIO_NUM_4
|
||||||
|
#define PULSOS 1000
|
||||||
|
static const char *TAG = "regs";
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
gpio_reset_pin(PINO);
|
||||||
|
gpio_set_direction(PINO, GPIO_MODE_OUTPUT);
|
||||||
|
|
||||||
|
// 1) Pela API do driver
|
||||||
|
uint32_t t0 = esp_cpu_get_cycle_count();
|
||||||
|
for (int i = 0; i < PULSOS; i++) {
|
||||||
|
gpio_set_level(PINO, 1);
|
||||||
|
gpio_set_level(PINO, 0);
|
||||||
|
}
|
||||||
|
// 2) Escrevendo direto nos registradores W1TS e W1TC
|
||||||
|
uint32_t t1 = esp_cpu_get_cycle_count();
|
||||||
|
for (int i = 0; i < PULSOS; i++) {
|
||||||
|
REG_WRITE(GPIO_OUT_W1TS_REG, BIT(PINO));
|
||||||
|
REG_WRITE(GPIO_OUT_W1TC_REG, BIT(PINO));
|
||||||
|
}
|
||||||
|
uint32_t t2 = esp_cpu_get_cycle_count();
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Driver: %lu ciclos por pulso", (unsigned long)((t1 - t0) / PULSOS));
|
||||||
|
ESP_LOGI(TAG, "Registrador: %lu ciclos por pulso", (unsigned long)((t2 - t1) / PULSOS));
|
||||||
|
ESP_LOGI(TAG, "GPIO_OUT_W1TS_REG fica no endereço 0x%08lx",
|
||||||
|
(unsigned long)GPIO_OUT_W1TS_REG);
|
||||||
|
}
|
||||||
@@ -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 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(jitter)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "esp_timer.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#define AMOSTRAS 1000
|
||||||
|
static const char *TAG = "jitter";
|
||||||
|
static int64_t instantes[AMOSTRAS];
|
||||||
|
static volatile int n = 0;
|
||||||
|
static TaskHandle_t tarefa_principal;
|
||||||
|
|
||||||
|
static void ao_disparar(void *arg)
|
||||||
|
{
|
||||||
|
if (n < AMOSTRAS) {
|
||||||
|
instantes[n++] = esp_timer_get_time();
|
||||||
|
if (n == AMOSTRAS) {
|
||||||
|
xTaskNotifyGive(tarefa_principal); // avisa que terminou
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
tarefa_principal = xTaskGetCurrentTaskHandle();
|
||||||
|
const esp_timer_create_args_t args = { .callback = ao_disparar, .name = "periodo_1ms" };
|
||||||
|
esp_timer_handle_t timer;
|
||||||
|
ESP_ERROR_CHECK(esp_timer_create(&args, &timer));
|
||||||
|
ESP_ERROR_CHECK(esp_timer_start_periodic(timer, 1000)); // 1000 µs
|
||||||
|
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
||||||
|
esp_timer_stop(timer);
|
||||||
|
|
||||||
|
int64_t menor = INT64_MAX, maior = 0, soma = 0;
|
||||||
|
for (int i = 1; i < AMOSTRAS; i++) {
|
||||||
|
int64_t d = instantes[i] - instantes[i - 1];
|
||||||
|
if (d < menor) menor = d;
|
||||||
|
if (d > maior) maior = d;
|
||||||
|
soma += d;
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG, "intervalo médio: %" PRId64 " us", soma / (AMOSTRAS - 1));
|
||||||
|
ESP_LOGI(TAG, "menor: %" PRId64 " us, maior: %" PRId64 " us, jitter: %" PRId64 " us",
|
||||||
|
menor, maior, maior - menor);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
board = esp32dev
|
||||||
|
|
||||||
|
[env:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
Serial.printf("Modelo: %s\n", ESP.getChipModel());
|
||||||
|
Serial.printf("Revisão de silício: %d\n", ESP.getChipRevision());
|
||||||
|
Serial.printf("Núcleos: %d\n", ESP.getChipCores());
|
||||||
|
Serial.printf("CPU: %lu MHz\n", (unsigned long)ESP.getCpuFreqMHz());
|
||||||
|
Serial.printf("Flash: %lu MB\n", (unsigned long)(ESP.getFlashChipSize() / (1024 * 1024)));
|
||||||
|
Serial.printf("PSRAM: %lu KB\n", (unsigned long)(ESP.getPsramSize() / 1024));
|
||||||
|
Serial.printf("Heap livre: %lu KB\n", (unsigned long)(ESP.getFreeHeap() / 1024));
|
||||||
|
Serial.printf("MAC (eFuse): %012llX\n", ESP.getEfuseMac());
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(qual_chip)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "esp_chip_info.h"
|
||||||
|
#include "esp_flash.h"
|
||||||
|
#include "esp_mac.h"
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
esp_chip_info_t chip;
|
||||||
|
esp_chip_info(&chip);
|
||||||
|
|
||||||
|
printf("Alvo da compilação: %s\n", CONFIG_IDF_TARGET);
|
||||||
|
printf("Revisão de silício: v%d.%d\n", chip.revision / 100, chip.revision % 100);
|
||||||
|
printf("Núcleos: %d\n", chip.cores);
|
||||||
|
printf("Rádios: %s%s%s%s\n",
|
||||||
|
(chip.features & CHIP_FEATURE_WIFI_BGN) ? " Wi-Fi" : "",
|
||||||
|
(chip.features & CHIP_FEATURE_BT) ? " BT-Clássico" : "",
|
||||||
|
(chip.features & CHIP_FEATURE_BLE) ? " BLE" : "",
|
||||||
|
(chip.features & CHIP_FEATURE_IEEE802154) ? " 802.15.4" : "");
|
||||||
|
|
||||||
|
uint32_t flash = 0;
|
||||||
|
esp_flash_get_physical_size(NULL, &flash);
|
||||||
|
printf("Flash: %" PRIu32 " MB (%s)\n", flash / (1024 * 1024),
|
||||||
|
(chip.features & CHIP_FEATURE_EMB_FLASH) ? "embutida" : "externa");
|
||||||
|
printf("PSRAM: %u KB\n",
|
||||||
|
(unsigned)(heap_caps_get_total_size(MALLOC_CAP_SPIRAM) / 1024));
|
||||||
|
|
||||||
|
uint8_t mac[6];
|
||||||
|
esp_read_mac(mac, ESP_MAC_BASE);
|
||||||
|
printf("MAC base: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||||
|
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(fpu)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "esp_cpu.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#define N 10000
|
||||||
|
static const char *TAG = "fpu";
|
||||||
|
static volatile uint32_t resultado_i; // volatile: os resultados precisam
|
||||||
|
static volatile float resultado_f; // "sair" do laço, senão o compilador
|
||||||
|
static volatile double resultado_d; // elimina as contas
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
uint32_t ai = 3;
|
||||||
|
float af = 1.0001f;
|
||||||
|
double ad = 1.0001;
|
||||||
|
|
||||||
|
uint32_t t0 = esp_cpu_get_cycle_count();
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
ai = ai * 3u + (uint32_t)i;
|
||||||
|
}
|
||||||
|
uint32_t t1 = esp_cpu_get_cycle_count();
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
af = af * 1.0001f + 0.5f;
|
||||||
|
}
|
||||||
|
uint32_t t2 = esp_cpu_get_cycle_count();
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
ad = ad * 1.0001 + 0.5;
|
||||||
|
}
|
||||||
|
uint32_t t3 = esp_cpu_get_cycle_count();
|
||||||
|
resultado_i = ai;
|
||||||
|
resultado_f = af;
|
||||||
|
resultado_d = ad;
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "%s a %d MHz", CONFIG_IDF_TARGET, CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ);
|
||||||
|
ESP_LOGI(TAG, "uint32: %6.1f ciclos por iteração", (t1 - t0) / (double)N);
|
||||||
|
ESP_LOGI(TAG, "float : %6.1f ciclos por iteração", (t2 - t1) / (double)N);
|
||||||
|
ESP_LOGI(TAG, "double: %6.1f ciclos por iteração", (t3 - t2) / (double)N);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(nucleos)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "esp_cpu.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
static const char *TAG = "nucleos";
|
||||||
|
|
||||||
|
static void tarefa(void *arg)
|
||||||
|
{
|
||||||
|
const char *nome = pcTaskGetName(NULL);
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
ESP_LOGI(TAG, "%-7s rodando no núcleo %d", nome, esp_cpu_get_core_id());
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(500));
|
||||||
|
}
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "FreeRTOS com %d núcleo(s)", CONFIG_FREERTOS_NUMBER_OF_CORES);
|
||||||
|
xTaskCreatePinnedToCore(tarefa, "fixa_0", 3072, NULL, 5, NULL, 0);
|
||||||
|
#if CONFIG_FREERTOS_NUMBER_OF_CORES > 1
|
||||||
|
xTaskCreatePinnedToCore(tarefa, "fixa_1", 3072, NULL, 5, NULL, 1);
|
||||||
|
#endif
|
||||||
|
xTaskCreatePinnedToCore(tarefa, "livre", 3072, NULL, 5, NULL, tskNO_AFFINITY);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(memoria)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char *TAG = "memoria";
|
||||||
|
|
||||||
|
static void mostrar(const char *nome, uint32_t caps)
|
||||||
|
{
|
||||||
|
size_t livre = heap_caps_get_free_size(caps);
|
||||||
|
size_t bloco = heap_caps_get_largest_free_block(caps);
|
||||||
|
size_t minimo = heap_caps_get_minimum_free_size(caps);
|
||||||
|
ESP_LOGI(TAG, "%-10s livre %7u B | maior bloco %7u B | mínimo histórico %7u B",
|
||||||
|
nome, (unsigned)livre, (unsigned)bloco, (unsigned)minimo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
mostrar("interna", MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
|
||||||
|
mostrar("DMA", MALLOC_CAP_DMA);
|
||||||
|
mostrar("PSRAM", MALLOC_CAP_SPIRAM);
|
||||||
|
mostrar("IRAM", MALLOC_CAP_EXEC);
|
||||||
|
heap_caps_print_heap_info(MALLOC_CAP_DEFAULT); // detalhe por região
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(psram)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "esp_heap_caps.h"
|
||||||
|
#include "esp_timer.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#define TAMANHO (256 * 1024)
|
||||||
|
static const char *TAG = "psram";
|
||||||
|
|
||||||
|
static int64_t preencher(uint32_t *buf, size_t palavras)
|
||||||
|
{
|
||||||
|
int64_t t0 = esp_timer_get_time();
|
||||||
|
for (size_t i = 0; i < palavras; i++) {
|
||||||
|
buf[i] = (uint32_t)i;
|
||||||
|
}
|
||||||
|
return esp_timer_get_time() - t0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
size_t n = TAMANHO / sizeof(uint32_t);
|
||||||
|
uint32_t *interno = heap_caps_malloc(TAMANHO, MALLOC_CAP_INTERNAL | MALLOC_CAP_32BIT);
|
||||||
|
uint32_t *externo = heap_caps_malloc(TAMANHO, MALLOC_CAP_SPIRAM);
|
||||||
|
if (!externo) {
|
||||||
|
ESP_LOGE(TAG, "Sem PSRAM: confira a placa e o CONFIG_SPIRAM");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (interno) {
|
||||||
|
ESP_LOGI(TAG, "SRAM interna: %lld us", preencher(interno, n));
|
||||||
|
heap_caps_free(interno);
|
||||||
|
} else {
|
||||||
|
ESP_LOGW(TAG, "Não há 256 KB contíguos na SRAM interna");
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG, "PSRAM: %lld us", preencher(externo, n));
|
||||||
|
heap_caps_free(externo);
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
CONFIG_SPIRAM=y
|
||||||
|
# Inclui a PSRAM no malloc() comum, para alocações acima de 16 KB
|
||||||
|
CONFIG_SPIRAM_USE_MALLOC=y
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(rtc_contador)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "esp_sleep.h"
|
||||||
|
#include "esp_attr.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static RTC_DATA_ATTR uint32_t acordadas = 0; // sobrevive ao deep sleep
|
||||||
|
static const char *TAG = "rtc";
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
acordadas++;
|
||||||
|
ESP_LOGI(TAG, "Acordei %lu vez(es). Motivo: %d",
|
||||||
|
(unsigned long)acordadas, (int)esp_sleep_get_wakeup_cause());
|
||||||
|
|
||||||
|
ESP_LOGI(TAG, "Dormindo por 5 segundos...");
|
||||||
|
esp_deep_sleep(5 * 1000000ULL); // em microssegundos
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
board = esp32dev
|
||||||
|
|
||||||
|
[env:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
void mostrar(const char *quando) {
|
||||||
|
Serial.printf("[%s] CPU %lu MHz | XTAL %lu MHz | APB %lu Hz\n", quando,
|
||||||
|
(unsigned long)getCpuFrequencyMhz(), (unsigned long)getXtalFrequencyMhz(),
|
||||||
|
(unsigned long)getApbFrequency());
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
delay(500);
|
||||||
|
mostrar("início");
|
||||||
|
if (setCpuFrequencyMhz(80)) { // só aceita frequências válidas da série
|
||||||
|
mostrar("depois");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(clocks)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "esp_clk_tree.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char *TAG = "clocks";
|
||||||
|
|
||||||
|
static void mostrar(const char *nome, soc_module_clk_t fonte)
|
||||||
|
{
|
||||||
|
uint32_t hz = 0;
|
||||||
|
esp_clk_tree_src_get_freq_hz(fonte, ESP_CLK_TREE_SRC_FREQ_PRECISION_APPROX, &hz);
|
||||||
|
ESP_LOGI(TAG, "%-9s %10" PRIu32 " Hz", nome, hz);
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
mostrar("CPU", SOC_MOD_CLK_CPU);
|
||||||
|
mostrar("XTAL", SOC_MOD_CLK_XTAL);
|
||||||
|
mostrar("RTC_SLOW", SOC_MOD_CLK_RTC_SLOW);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(gpio_modos)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
#define SAIDA GPIO_NUM_4
|
||||||
|
#define ENTRADA GPIO_NUM_5
|
||||||
|
static const char *TAG = "gpio";
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
gpio_config_t saida = {
|
||||||
|
.pin_bit_mask = 1ULL << SAIDA,
|
||||||
|
.mode = GPIO_MODE_INPUT_OUTPUT_OD, // open-drain, com leitura de volta
|
||||||
|
.pull_up_en = GPIO_PULLUP_ENABLE, // pull-up interno faz o nível alto
|
||||||
|
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||||
|
.intr_type = GPIO_INTR_DISABLE,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(gpio_config(&saida));
|
||||||
|
|
||||||
|
gpio_config_t entrada = {
|
||||||
|
.pin_bit_mask = 1ULL << ENTRADA,
|
||||||
|
.mode = GPIO_MODE_INPUT,
|
||||||
|
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||||
|
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||||
|
.intr_type = GPIO_INTR_DISABLE,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(gpio_config(&entrada));
|
||||||
|
ESP_ERROR_CHECK(gpio_set_drive_capability(SAIDA, GPIO_DRIVE_CAP_0)); // força mínima
|
||||||
|
|
||||||
|
for (int nivel = 0; nivel <= 1; nivel++) {
|
||||||
|
gpio_set_level(SAIDA, nivel);
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(1));
|
||||||
|
ESP_LOGI(TAG, "escrevi %d | saída lê %d | entrada lê %d",
|
||||||
|
nivel, gpio_get_level(SAIDA), gpio_get_level(ENTRADA));
|
||||||
|
}
|
||||||
|
gpio_dump_io_configuration(stdout, (1ULL << SAIDA) | (1ULL << ENTRADA));
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
board = esp32dev
|
||||||
|
|
||||||
|
[env:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
const int SAIDA = 4; // ligue um fio entre o GPIO 4...
|
||||||
|
const int ENTRADA = 5; // ...e o GPIO 5
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
pinMode(SAIDA, OUTPUT);
|
||||||
|
pinMode(ENTRADA, INPUT_PULLUP);
|
||||||
|
Serial.begin(115200);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
for (int nivel = 0; nivel <= 1; nivel++) {
|
||||||
|
digitalWrite(SAIDA, nivel);
|
||||||
|
delayMicroseconds(10);
|
||||||
|
Serial.printf("escrevi %d, li %d\n", nivel, digitalRead(ENTRADA));
|
||||||
|
}
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
board = esp32dev
|
||||||
|
|
||||||
|
[env:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#include "esp_system.h"
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
delay(500);
|
||||||
|
Serial.printf("Motivo do último reinício: %d\n", (int)esp_reset_reason());
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(motivo_reset)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "esp_system.h"
|
||||||
|
#include "esp_attr.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char *TAG = "reset";
|
||||||
|
static __NOINIT_ATTR uint32_t falhas; // sobrevive a reinícios, não à falta de energia
|
||||||
|
|
||||||
|
static const char *descricao(esp_reset_reason_t r)
|
||||||
|
{
|
||||||
|
switch (r) {
|
||||||
|
case ESP_RST_POWERON: return "energização";
|
||||||
|
case ESP_RST_EXT: return "pino de enable (reset externo)";
|
||||||
|
case ESP_RST_SW: return "esp_restart() chamado pelo software";
|
||||||
|
case ESP_RST_PANIC: return "exceção ou abort()";
|
||||||
|
case ESP_RST_INT_WDT: return "watchdog de interrupção";
|
||||||
|
case ESP_RST_TASK_WDT: return "watchdog de tarefas";
|
||||||
|
case ESP_RST_WDT: return "outro watchdog";
|
||||||
|
case ESP_RST_DEEPSLEEP: return "saída do deep sleep";
|
||||||
|
case ESP_RST_BROWNOUT: return "queda de tensão (brownout)";
|
||||||
|
case ESP_RST_SDIO: return "reset pelo SDIO";
|
||||||
|
default: return "outra causa";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
esp_reset_reason_t motivo = esp_reset_reason();
|
||||||
|
if (motivo == ESP_RST_POWERON || motivo == ESP_RST_BROWNOUT) {
|
||||||
|
falhas = 0; // conteúdo indefinido após falta de energia
|
||||||
|
} else if (motivo == ESP_RST_PANIC || motivo == ESP_RST_INT_WDT ||
|
||||||
|
motivo == ESP_RST_TASK_WDT || motivo == ESP_RST_WDT) {
|
||||||
|
falhas++;
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG, "Reiniciei por: %s (código %d)", descricao(motivo), motivo);
|
||||||
|
ESP_LOGI(TAG, "Falhas desde a última energização: %lu", (unsigned long)falhas);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(identidade)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "esp_app_desc.h"
|
||||||
|
#include "esp_ota_ops.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char *TAG = "identidade";
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
const esp_app_desc_t *app = esp_app_get_description();
|
||||||
|
ESP_LOGI(TAG, "Projeto: %s", app->project_name);
|
||||||
|
ESP_LOGI(TAG, "Versão: %s", app->version);
|
||||||
|
ESP_LOGI(TAG, "ESP-IDF: %s", app->idf_ver);
|
||||||
|
ESP_LOGI(TAG, "Compilado em %s às %s", app->date, app->time);
|
||||||
|
|
||||||
|
const esp_partition_t *rodando = esp_ota_get_running_partition();
|
||||||
|
ESP_LOGI(TAG, "Rodando da partição '%s' em 0x%08lx",
|
||||||
|
rodando->label, (unsigned long)rodando->address);
|
||||||
|
ESP_LOGI(TAG, "app_main na tarefa '%s', prioridade %u, núcleo %d",
|
||||||
|
pcTaskGetName(NULL), (unsigned)uxTaskPriorityGet(NULL), xPortGetCoreID());
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c2]
|
||||||
|
board = esp32-c2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c3]
|
||||||
|
board = esp32-c3-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32c5]
|
||||||
|
board = esp32-c5-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c6]
|
||||||
|
board = esp32-c6-devkitc-1
|
||||||
|
|
||||||
|
[env:esp32c61]
|
||||||
|
board = esp32-c61-devkitc1
|
||||||
|
|
||||||
|
[env:esp32h2]
|
||||||
|
board = esp32-h2-devkitm-1
|
||||||
|
|
||||||
|
[env:esp32p4]
|
||||||
|
board = esp32-p4-evboard
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(dac_rampa)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "driver/dac_oneshot.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
dac_oneshot_handle_t dac;
|
||||||
|
dac_oneshot_config_t cfg = {.chan_id = DAC_CHAN_0};
|
||||||
|
ESP_ERROR_CHECK(dac_oneshot_new_channel(&cfg, &dac));
|
||||||
|
ESP_LOGI("dac", "Rampa no canal 0 (GPIO 25 no ESP32, GPIO 17 no S2)");
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
for (int v = 0; v < 256; v++) {
|
||||||
|
ESP_ERROR_CHECK(dac_oneshot_output_voltage(dac, v));
|
||||||
|
vTaskDelay(pdMS_TO_TICKS(4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
; 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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
board = esp32dev
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
const int PINO_DAC = 25; // canal 1 do DAC no ESP32 clássico
|
||||||
|
|
||||||
|
void setup() {}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
for (int v = 0; v < 256; v++) {
|
||||||
|
dacWrite(PINO_DAC, v); // 0 = 0 V, 255 = cerca de 3,3 V
|
||||||
|
delay(4); // rampa completa em cerca de 1 s
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
board = esp32dev
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
uint16_t rev = ESP.getChipRevision(); // maior * 100 + menor: 301 = v3.1
|
||||||
|
Serial.printf("%s revisão v%u.%u, %u núcleo(s)\n", ESP.getChipModel(),
|
||||||
|
rev / 100, rev % 100, ESP.getChipCores());
|
||||||
|
Serial.printf("PSRAM: %u bytes\n", ESP.getPsramSize());
|
||||||
|
Serial.printf("Flash: %u bytes\n", ESP.getFlashChipSize());
|
||||||
|
|
||||||
|
if (rev < 300) {
|
||||||
|
Serial.println("Revisão anterior à v3.0: PSRAM com contorno e sem Secure Boot V2.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(revisao_chip)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include "esp_chip_info.h"
|
||||||
|
#include "esp_flash.h"
|
||||||
|
#include "esp_psram.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
esp_chip_info_t info;
|
||||||
|
esp_chip_info(&info);
|
||||||
|
|
||||||
|
printf("%s, revisão v%d.%d, %d núcleo(s)\n", CONFIG_IDF_TARGET,
|
||||||
|
info.revision / 100, info.revision % 100, info.cores);
|
||||||
|
printf("Wi-Fi: %s, Bluetooth Classic: %s, BLE: %s\n",
|
||||||
|
(info.features & CHIP_FEATURE_WIFI_BGN) ? "sim" : "não",
|
||||||
|
(info.features & CHIP_FEATURE_BT) ? "sim" : "não",
|
||||||
|
(info.features & CHIP_FEATURE_BLE) ? "sim" : "não");
|
||||||
|
|
||||||
|
if (info.revision < 300) {
|
||||||
|
printf("Revisão anterior à v3.0: veja a errata CPU-3.2 e o contorno de PSRAM.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t flash = 0;
|
||||||
|
esp_flash_get_size(NULL, &flash);
|
||||||
|
printf("Flash: %lu MB\n", (unsigned long)(flash / (1024 * 1024)));
|
||||||
|
#if CONFIG_SPIRAM
|
||||||
|
printf("PSRAM: %u bytes\n", (unsigned)esp_psram_get_size());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
; 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
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
; 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 = esp32s2
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
; A biblioteca USB inclui FS.h, mas o LDF do PlatformIO não propaga o caminho.
|
||||||
|
build_flags = -I${platformio.packages_dir}/framework-arduinoespressif32/libraries/FS/src
|
||||||
|
|
||||||
|
[env:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#include "USB.h"
|
||||||
|
#include "USBHIDKeyboard.h"
|
||||||
|
|
||||||
|
USBHIDKeyboard teclado;
|
||||||
|
const int BOTAO = 0; // botão BOOT das DevKits
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
pinMode(BOTAO, INPUT_PULLUP);
|
||||||
|
teclado.begin();
|
||||||
|
USB.begin(); // enumera no computador como teclado
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (digitalRead(BOTAO) == LOW) {
|
||||||
|
teclado.println("Olá do ESP32-S2!");
|
||||||
|
delay(500); // evita repetir enquanto o botão está apertado
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(usb_eco)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
espressif/esp_tinyusb: "^2.0.0"
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#include <ctype.h>
|
||||||
|
#include "esp_log.h"
|
||||||
|
#include "tinyusb.h"
|
||||||
|
#include "tinyusb_default_config.h"
|
||||||
|
#include "tinyusb_cdc_acm.h"
|
||||||
|
|
||||||
|
static const char *TAG = "usb_eco";
|
||||||
|
static uint8_t buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE];
|
||||||
|
|
||||||
|
static void ao_receber(int itf, cdcacm_event_t *evento)
|
||||||
|
{
|
||||||
|
size_t n = 0;
|
||||||
|
if (tinyusb_cdcacm_read(itf, buf, sizeof(buf), &n) != ESP_OK || n == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < n; i++) {
|
||||||
|
buf[i] = (uint8_t)toupper(buf[i]);
|
||||||
|
}
|
||||||
|
tinyusb_cdcacm_write_queue(itf, buf, n);
|
||||||
|
tinyusb_cdcacm_write_flush(itf, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "Iniciando a TinyUSB");
|
||||||
|
|
||||||
|
const tinyusb_config_t usb = TINYUSB_DEFAULT_CONFIG();
|
||||||
|
ESP_ERROR_CHECK(tinyusb_driver_install(&usb));
|
||||||
|
|
||||||
|
tinyusb_config_cdcacm_t acm = {
|
||||||
|
.cdc_port = TINYUSB_CDC_ACM_0,
|
||||||
|
.callback_rx = ao_receber,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(tinyusb_cdcacm_init(&acm));
|
||||||
|
ESP_LOGI(TAG, "Porta serial USB pronta; abra /dev/ttyACM0 no computador");
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
; 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 = esp32s2
|
||||||
|
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:esp32s2]
|
||||||
|
board = esp32-s2-saola-1
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
CONFIG_TINYUSB_CDC_ENABLED=y
|
||||||
|
CONFIG_TINYUSB_CDC_COUNT=1
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(dsp_vetor)
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
idf_component_register(SRCS "main.c"
|
||||||
|
INCLUDE_DIRS ".")
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
espressif/esp-dsp: "^1.5.0"
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "esp_cpu.h"
|
||||||
|
#include "esp_dsp.h"
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#define N 1024
|
||||||
|
|
||||||
|
static float a[N] __attribute__((aligned(16)));
|
||||||
|
static float b[N] __attribute__((aligned(16)));
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < N; i++) {
|
||||||
|
a[i] = (float)i / N;
|
||||||
|
b[i] = 1.0f - a[i];
|
||||||
|
}
|
||||||
|
float r_ansi = 0, r_otim = 0;
|
||||||
|
|
||||||
|
uint32_t t0 = esp_cpu_get_cycle_count();
|
||||||
|
dsps_dotprod_f32_ansi(a, b, &r_ansi, N);
|
||||||
|
uint32_t c_ansi = esp_cpu_get_cycle_count() - t0;
|
||||||
|
|
||||||
|
// dsps_dotprod_f32 aponta para a versão otimizada da série
|
||||||
|
// (com instruções vetoriais no S3)
|
||||||
|
t0 = esp_cpu_get_cycle_count();
|
||||||
|
dsps_dotprod_f32(a, b, &r_otim, N);
|
||||||
|
uint32_t c_otim = esp_cpu_get_cycle_count() - t0;
|
||||||
|
|
||||||
|
printf("%s: C puro %" PRIu32 " ciclos, otimizada %" PRIu32 " ciclos (%.1fx)\n",
|
||||||
|
CONFIG_IDF_TARGET, c_ansi, c_otim, (float)c_ansi / c_otim);
|
||||||
|
printf("Resultados: %.4f e %.4f\n", r_ansi, r_otim);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
; 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
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
[env]
|
||||||
|
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.312/platform-espressif32.zip
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
|
[env:esp32]
|
||||||
|
board = esp32dev
|
||||||
|
|
||||||
|
[env:esp32s3]
|
||||||
|
board = esp32-s3-devkitc-1
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
const int LARGURA = 480;
|
||||||
|
const int ALTURA = 320;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
delay(500);
|
||||||
|
|
||||||
|
Serial.printf("SRAM interna livre: %u bytes\n", ESP.getFreeHeap());
|
||||||
|
if (!psramFound()) {
|
||||||
|
Serial.println("PSRAM não encontrada: confira Tools > PSRAM no menu da placa.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Serial.printf("PSRAM: %u bytes, livre: %u\n", ESP.getPsramSize(), ESP.getFreePsram());
|
||||||
|
|
||||||
|
// Quadro de 480x320 em RGB565: 2 bytes por pixel, 307 200 bytes
|
||||||
|
size_t tamanho = LARGURA * ALTURA * sizeof(uint16_t);
|
||||||
|
uint16_t *quadro = (uint16_t *)ps_malloc(tamanho);
|
||||||
|
if (quadro == NULL) {
|
||||||
|
Serial.println("Sem memória para o quadro.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < LARGURA * ALTURA; i++) {
|
||||||
|
quadro[i] = 0xF800; // vermelho em RGB565
|
||||||
|
}
|
||||||
|
Serial.printf("Quadro de %u bytes pronto na PSRAM.\n", tamanho);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {}
|
||||||
Loaded 100 of 592 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user