Blink
This commit is contained in:
parent
959d67428b
commit
53540d9fb4
4 changed files with 40 additions and 4 deletions
|
@ -1,2 +1,2 @@
|
||||||
idf_component_register(SRCS "main.c"
|
idf_component_register(SRCS "main.c" "task_blink.c"
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
#include "freertos/idf_additions.h"
|
||||||
|
#include "tasks.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void app_main(void)
|
void app_main(void) {
|
||||||
{
|
TaskHandle_t task_handle_blink;
|
||||||
|
xTaskCreate(task_blink, "task_blink", 1024, NULL, 0, &task_handle_blink);
|
||||||
}
|
}
|
||||||
|
|
20
main/task_blink.c
Normal file
20
main/task_blink.c
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include "freertos/idf_additions.h"
|
||||||
|
#include "portmacro.h"
|
||||||
|
#include <driver/gpio.h>
|
||||||
|
#include <esp_rom_gpio.h>
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
|
||||||
|
#include "tasks.h"
|
||||||
|
|
||||||
|
void task_blink(void *pvParams) {
|
||||||
|
esp_rom_gpio_pad_select_gpio(LED_PIN);
|
||||||
|
gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
gpio_set_level(LED_PIN, 0);
|
||||||
|
vTaskDelay(BLINK_DELAY / portTICK_PERIOD_MS);
|
||||||
|
gpio_set_level(LED_PIN, 1);
|
||||||
|
vTaskDelay(BLINK_DELAY / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
}
|
14
main/tasks.h
Normal file
14
main/tasks.h
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef TASKS_H
|
||||||
|
#define TASKS_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file exports all the individual tasks, avoiding tons of semi-empty headers.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LED_PIN 2
|
||||||
|
#define RATE_PER_S 10
|
||||||
|
#define BLINK_DELAY (1000 / 2 / RATE_PER_S)
|
||||||
|
|
||||||
|
void task_blink(void *pvParams);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue