Last active
March 22, 2024 05:46
-
-
Save GOROman/19907c2ef1c2cd45d35a91e9cfb24c62 to your computer and use it in GitHub Desktop.
M5NanoC6 + PlatformIO + ESP-IDF で Lチカ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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
gpio_set_direction()
https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/peripherals/gpio.html#_CPPv418gpio_set_direction10gpio_num_t11gpio_mode_t