こちらでは、サンプルのプロジェクトをコピーしましたが、新規のプロジェクトを作成する方法です。
esp-idf の使い方
プロジェクトの作成
idf.py create-project hello01
作成されたフォルダー構造
$ tree hello01
hello01
├── CMakeLists.txt
└── main
├── CMakeLists.txt
└── hello01.c
プログラムの修正
main/hello01.c
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
void app_main(void)
{
int count = 0;
printf("Hello world!\n");
printf("Good Morning!\n");
printf("Good Afternoon!\n");
printf("こんにちは\n");
while (1) {
printf("Hello world! %d\n" , count);
vTaskDelay(2000 / portTICK_PERIOD_MS);
count ++;
}
}
Build
idf.py set-target esp32
idf.py build
idf.py -p /dev/ttyUSB0 flash
実行結果
$ cu -l /dev/ttyUSB0 -s 115200
Connected.
Hello world! 190
Hello world! 191
Hello world! 192
Hello world! 193