add basic signal led
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
j3d1 2021-07-19 22:31:30 +02:00
parent f4d1b53760
commit 006d281ad6
5 changed files with 42 additions and 10 deletions

View file

@ -25,4 +25,6 @@ void user_init(void)
xTaskCreate(wifi_task, "wifi_task", 512, NULL, 2, NULL); xTaskCreate(wifi_task, "wifi_task", 512, NULL, 2, NULL);
xTaskCreate(&httpd_task, "httpd_task", 512, NULL, 2, NULL); xTaskCreate(&httpd_task, "httpd_task", 512, NULL, 2, NULL);
xTaskCreate(&lux_task, "lux_task", 512, NULL, 1, NULL);
} }

View file

@ -1,3 +1,32 @@
// //
// Created by jedi on 25.06.21. // Created by jedi on 25.06.21.
// //
#include "lux.h"
#include <string.h>
#include <FreeRTOS.h>
#include <task.h>
#include <esp/spi.h>
const int signal_led_pin = 2;
const int cs0 = 15;
const int gpio4 = 4;
const int gpio5 = 5;
extern "C" void signal_led(bool state) {
gpio_write(signal_led_pin, state);
}
extern "C" void lux_task(void *pvParameters) {
gpio_enable(signal_led_pin, GPIO_OUTPUT);
gpio_enable(cs0, GPIO_OUTPUT);
gpio_enable(gpio4, GPIO_OUTPUT);
gpio_enable(gpio5, GPIO_OUTPUT);
spi_init(1, SPI_MODE0, SPI_FREQ_DIV_1M, 1, SPI_BIG_ENDIAN, 1);
vTaskDelete(nullptr);
}

View file

@ -9,6 +9,10 @@
extern "C" { extern "C" {
#endif #endif
void lux_task(void *pvParameters);
void signal_led(bool state);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -251,7 +251,7 @@ void websocket_open_cb(struct tcp_pcb *pcb, const char *uri) {
} }
} }
extern "C" [[noreturn]] void httpd_task(void *pvParameters) { extern "C" void httpd_task(void *pvParameters) {
while (!uxSemaphoreGetCount(wifi_available_semaphore)) while (!uxSemaphoreGetCount(wifi_available_semaphore))
vTaskDelay(500 / portTICK_PERIOD_MS); vTaskDelay(500 / portTICK_PERIOD_MS);
@ -259,6 +259,5 @@ extern "C" [[noreturn]] void httpd_task(void *pvParameters) {
websocket_register_callbacks((tWsOpenHandler) websocket_open_cb, (tWsHandler) websocket_cb); websocket_register_callbacks((tWsOpenHandler) websocket_open_cb, (tWsHandler) websocket_cb);
httpd_init(); httpd_init();
for (;;) vTaskDelete(nullptr);
vTaskDelay(500 / portTICK_PERIOD_MS);
} }

View file

@ -116,7 +116,7 @@ SemaphoreHandle_t wifi_available_semaphore = nullptr;
} }
} }
extern "C" [[noreturn]] void wifi_task(void *pvParameters) { extern "C" void wifi_task(void *pvParameters) {
(void) pvParameters; (void) pvParameters;
/* Default a hostname. */ /* Default a hostname. */
char *hostname = nullptr; char *hostname = nullptr;
@ -355,8 +355,6 @@ extern "C" [[noreturn]] void wifi_task(void *pvParameters) {
xSemaphoreGive(wifi_available_semaphore); xSemaphoreGive(wifi_available_semaphore);
while (1) { //monitor loop connection here
//monitor connection here vTaskDelete(nullptr);
vTaskDelay(5000);
}
} }