Skip to content

Instantly share code, notes, and snippets.

@GOROman
Last active March 22, 2024 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GOROman/19907c2ef1c2cd45d35a91e9cfb24c62 to your computer and use it in GitHub Desktop.
Save GOROman/19907c2ef1c2cd45d35a91e9cfb24c62 to your computer and use it in GitHub Desktop.
M5NanoC6 + PlatformIO + ESP-IDF で Lチカ
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_task_wdt.h"
#include "driver/gpio.h"
TaskHandle_t loopTaskHandle = NULL;
void setup()
{
#if 1
gpio_config_t io_conf = {
1ULL << GPIO_NUM_7,
GPIO_MODE_OUTPUT,
GPIO_PULLUP_DISABLE,
GPIO_PULLDOWN_DISABLE,
GPIO_INTR_DISABLE
};
gpio_config(&io_conf);
#else
gpio_set_direction(GPIO_NUM_7, GPIO_MODE_OUTPUT); // うまくいかん
#endif
}
void loop()
{
gpio_set_level(GPIO_NUM_7, 1);
vTaskDelay(10/portTICK_PERIOD_MS);
gpio_set_level(GPIO_NUM_7, 0);
vTaskDelay(990/portTICK_PERIOD_MS);
}
void loopTask(void *pvParameters)
{
setup();
while(1) {
esp_task_wdt_reset();
loop();
}
}
void app_main() {
xTaskCreate( loopTask, "NAME", 8192, NULL, tskIDLE_PRIORITY, &loopTaskHandle );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment