본문 바로가기

카테고리 없음

[ESP32-C6 SSM] Arduino 개발환경 설정

ESP32C6 개발환경을 설정하기 위해 가장 간단한 방법은 Arduino IDE를 이용하는 것이다.

최신 ESP32 Board 설정파일로 업데이트 하면 ESP32C6 Dev Module 가 포함되어 있다.

 

 

ESP32C6의 Arduino variant 파일 설정은 아래와 같다.

#include <stdint.h>
#include "soc/soc_caps.h"

#define PIN_RGB_LED 8
// BUILTIN_LED can be used in new Arduino API digitalWrite() like in Blink.ino
static const uint8_t LED_BUILTIN = SOC_GPIO_PIN_COUNT + PIN_RGB_LED;
#define BUILTIN_LED LED_BUILTIN  // backward compatibility
#define LED_BUILTIN LED_BUILTIN  // allow testing #ifdef LED_BUILTIN
// RGB_BUILTIN and RGB_BRIGHTNESS can be used in new Arduino API rgbLedWrite()
#define RGB_BUILTIN    LED_BUILTIN
#define RGB_BRIGHTNESS 64

static const uint8_t TX = 16;
static const uint8_t RX = 17;

static const uint8_t SDA = 23;
static const uint8_t SCL = 22;

static const uint8_t SS = 18;
static const uint8_t MOSI = 19;
static const uint8_t MISO = 20;
static const uint8_t SCK = 21;

static const uint8_t A0 = 0;
static const uint8_t A1 = 1;
static const uint8_t A2 = 2;
static const uint8_t A3 = 3;
static const uint8_t A4 = 4;
static const uint8_t A5 = 5;
static const uint8_t A6 = 6;

 

 

ESP32 기존 코드 컴파일 하면 에러가 발생한다.

 

D:\WORK\arduino\ESP32C6\DhryAndWhetstone\DhryAndWhetstone.ino:10:23: error: invalid conversion from 'int' to 'const esp_task_wdt_config_t*' [-fpermissive]

   10 |   #define WDT_TIMEOUT 9

      |                       ^

      |                       |

      |                       int

D:\WORK\arduino\ESP32C6\DhryAndWhetstone\DhryAndWhetstone.ino:106:23: note: in expansion of macro 'WDT_TIMEOUT'

  106 |     esp_task_wdt_init(WDT_TIMEOUT, 0);

      |                       ^~~~~~~~~~~

D:\WORK\arduino\ESP32C6\DhryAndWhetstone\DhryAndWhetstone.ino:106:22: error: too many arguments to function 'esp_err_t esp_task_wdt_init(const esp_task_wdt_config_t*)'

  106 |     esp_task_wdt_init(WDT_TIMEOUT, 0);

      |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~

In file included from D:\WORK\arduino\ESP32C6\DhryAndWhetstone\DhryAndWhetstone.ino:9:

C:\Users\jhpark\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.3-466a392a\esp32c6/include/esp_system/include/esp_task_wdt.h:47:11: note: declared here

   47 | esp_err_t esp_task_wdt_init(const esp_task_wdt_config_t *config);

      |           ^~~~~~~~~~~~~~~~~

 

exit status 1

 

 

뭐가 또 바꼈구나…

WATCH DOC관련 함수 구조가 변경된것 같다.

#ifdef ESP32
  #include "esp_task_wdt.h"
#define TWDT_TIMEOUT_MS         3000
#define TASK_RESET_PERIOD_MS    2000
#define MAIN_DELAY_MS           10000


    esp_task_wdt_config_t twdt_config = {
        .timeout_ms = TWDT_TIMEOUT_MS,
        .idle_core_mask = (1 << CONFIG_FREERTOS_NUMBER_OF_CORES) - 1,    // Bitmask of all cores
        .trigger_panic = false,
    };  
#endif

 

 

WatchDog 수정하니 정상 컴파일되도 ESP32-C6 SSM에 실장된 LED 구동이 정상적으로 되는것을 확인 할 수 있다.

#include <Arduino.h>

#define LED1_PIN       14 
#define LED2_PIN       15 

#define Led1On()       digitalWrite(LED1_PIN, 0) 
#define Led1Off()      digitalWrite(LED1_PIN, 1) 

#define Led2On()       digitalWrite(LED2_PIN, 0) 
#define Led2Off()      digitalWrite(LED2_PIN, 1) 

void setup() {
  pinMode(LED1_PIN, OUTPUT);
  pinMode(LED2_PIN, OUTPUT);

  Led1On();
  Led2Off();
}

void loop() {
    Led1On();
    Led2Off();
    delay(500);

    Led1Off();
    Led2On();
    delay(500);
}
반응형