日韩一区二区三区精品,欧美疯狂xxxxbbbb牲交,热99re久久免费视精品频,人妻互换 综合,欧美激情肉欲高潮视频

ESP32 開發(fā)環(huán)境和基本使用

發(fā)布者:breakthrough3最新更新時間:2025-06-09 來源: jianshu關鍵字:ESP32  開發(fā)環(huán)境  基本使用 手機看文章 掃描二維碼
隨時隨地手機看文章

Linux (Ubuntu)

默認軟件包安裝:



sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0

獲取 ESP-IDF



mkdir -p ~/esp

cd ~/esp

git clone --recursive https://github.com/espressif/esp-idf.git

獲取工具鏈



 cd ~/esp/esp-idf 

 ./install esp32

執(zhí)行 ./install.sh 時, 可以安裝指定芯片的工具, 比如 esp32s2 或 all.

下載默認位置為 $HOME/.espressif, 可在下載前設置 IDF_TOOLS_PATH 以更改位置


導出環(huán)境



source $HOME/esp/esp-idf/export.sh

執(zhí)行 esp-idf 目錄下的 export.sh 可使得開發(fā)環(huán)境在當前終端生效, 可以更改 ~/.bashrc 打開終端總是生效或者使用 alias 按需生效:



export IDF_PATH=/home/shino/esp/esp-idf

alias esp='source $IDF_PATH/export.sh'

這時只要在任意終端輸入 esp 即可進入編譯環(huán)境.


工程示例

創(chuàng)建工程



cp -r ~/esp/esp-idf/examples/get-started/hello_world .

cd hello_world

mkdir -p components/my_component 

cd components/my_component

touch my_component.c my_component.h CMakeLists.txt

上面操作復制了官方例程中的 hello_world 作為模板, 然后創(chuàng)建了一個組件 my_component.


編寫組件

my_component.c



#include 'my_component.h'int add(int a, int b){

    return a + b;}

my_component.h



#pragma onceint add(int a, int b);

my_component/CMakeLists.txt



idf_component_register(SRCS 'my_component.c'

                  INCLUDE_DIRS '.')

main/CMakeLists.txt



idf_component_register(SRCS 'hello_world_main.c'

                  INCLUDE_DIRS ''

                  PRIV_REQUIRES my_component)

組件之間的依賴關系可在組件注冊時使用 PRIV_REQUIRES 或 REQUIRES 來表示, 其中前者表示私有依賴, 后者則為共有依賴。例如上面因為在 main.c 中 include 了 my_component.h 說明 main 對my_component有依賴關系, 而 main 本身可看做是一個特殊的組件, 因為沒有組件依賴它且其對my_component組件的依賴沒有體現在頭文件上因此可使用 PRIV_REQUIRES 來申明。



關鍵字:ESP32  開發(fā)環(huán)境  基本使用 引用地址:ESP32 開發(fā)環(huán)境和基本使用

上一篇:【ESP32】HardwareSerial庫使用
下一篇:(3)ESP32 Python 制作一個辦公室溫度計

小廣播
設計資源 培訓 開發(fā)板 精華推薦

最新單片機文章

 
EEWorld訂閱號

 
EEWorld服務號

 
汽車開發(fā)圈

 
機器人開發(fā)圈

電子工程世界版權所有 京ICP證060456號 京ICP備10001474號-1 電信業(yè)務審批[2006]字第258號函 京公網安備 11010802033920號 Copyright ? 2005-2025 EEWORLD.com.cn, Inc. All rights reserved