diff --git a/components/heartbeat/heartbeat.c b/components/heartbeat/heartbeat.c new file mode 100644 index 0000000..606af42 --- /dev/null +++ b/components/heartbeat/heartbeat.c @@ -0,0 +1,29 @@ +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "driver/gpio.h" + +#define HEARTBEAT_GPIO GPIO_NUM_5 +#define HEARTBEAT_PERIOD_MS 250 + +void heartbeat_task(void *pvParameter) +{ + /* Configure the IOMUX register for pad HEARTBEAT_GPIO (some pads are + muxed to GPIO on reset already, but some default to other + functions and need to be switched to GPIO. Consult the + Technical Reference for a list of pads and their default + functions.) + */ + gpio_pad_select_gpio(HEARTBEAT_GPIO); + /* Set the GPIO as a push/pull output */ + gpio_set_direction(HEARTBEAT_GPIO, GPIO_MODE_OUTPUT); + + while(1) { + /* Heartbeat off (output low) */ + gpio_set_level(HEARTBEAT_GPIO, 0); + vTaskDelay(HEARTBEAT_PERIOD_MS / portTICK_PERIOD_MS); + /* Heartbeat on (output high) */ + gpio_set_level(HEARTBEAT_GPIO, 1); + vTaskDelay(HEARTBEAT_PERIOD_MS / portTICK_PERIOD_MS); + } +} + diff --git a/components/heartbeat/heartbeat.h b/components/heartbeat/heartbeat.h new file mode 100644 index 0000000..02f97d7 --- /dev/null +++ b/components/heartbeat/heartbeat.h @@ -0,0 +1,5 @@ + + +// Task which blinks the LED to make sure the device +// is still running. +void heartbeat_task(void *pvParameter);