Started with a blank main file

- Added GPIO handling
- Added a logger class with additional static debug log handling

Tested, functional
This commit is contained in:
Matthias Mitscherlich
2024-03-11 15:45:48 +01:00
parent 4b31b6c618
commit a0d13f08c1
10 changed files with 1067 additions and 4 deletions
+47 -2
View File
@@ -17,9 +17,22 @@
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
// ESP includes
#include "driver/uart.h"
#include "esp_log.h"
#include "nvs_flash.h"
// HAL includes
#include "gpio.h"
#include "uart.h"
// Platform includes
#include "logger.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
@@ -34,13 +47,14 @@
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
static uart_port_t uartPort = UART_NUM_0;
static TaskHandle_t loggerTaskHandle;
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
void loggerTask(void* parameters);
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
@@ -76,6 +90,26 @@ extern "C" void app_main(void)
ESP_ERROR_CHECK(uart_set_pin(uartPort, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
ESP_ERROR_CHECK(uart_driver_install(uartPort, 1024, 1024, 0, NULL, 0));
uart uartDebug = uart(&uartPort);
uartDebug.open();
// -----------------------------------------------------------------------------------------------------------------
// System-wide Debug Logger
logger debugLogger = logger(16, uartDebug);
// Call the logger executable within a dedicated task and forget about it afterwards
xTaskCreate(loggerTask, (const char*)"loggerTask", 3072, &debugLogger, 3, &loggerTaskHandle);
LOGGER_PRINT("\n\r-----------------------------------------------------------------------\n\r");
LOGGER_PRINT("System Start\n\r");
LOGGER_PRINT("\n\r");
LOGGER_PRINT("WordClock\n\r");
LOGGER_PRINT("Release: %d.%d \n\r", MAJORRELEASE, MINORRELEASE);
LOGGER_PRINT("Compiled on %s at %s\n\r\n\r\n\r", __DATE__, __TIME__);
gpio debugIO = gpio(2, gpio::Direction_t::GPIO_DIRECTION_OUTPUT, gpio::Value_t::GPIO_VALUE_LOW);
while(1)
@@ -84,3 +118,14 @@ extern "C" void app_main(void)
}
}
void loggerTask(void* parameters)
{
logger* debugLogger = (logger*) parameters;
while (1)
{
debugLogger->task();
vTaskDelay(10);
}
}