Added ESP console logger as serial interface
This commit is contained in:
@@ -5,6 +5,7 @@ idf_component_register(
|
||||
SRCS # list the source files of this component
|
||||
"main.cpp"
|
||||
# "old/src/bmp280.cpp"
|
||||
"hal/src/esplog.cpp"
|
||||
"hal/src/i2c.cpp"
|
||||
"hal/src/gpio.cpp"
|
||||
"hal/src/uart.cpp"
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file esplog.h
|
||||
/// \brief File description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef MAIN_HAL_INC_UART_H_
|
||||
#define MAIN_HAL_INC_UART_H_
|
||||
|
||||
/**
|
||||
* esplog implementation
|
||||
* \defgroup esplog
|
||||
* \brief {group_description}
|
||||
* \addtogroup {Layer}
|
||||
*
|
||||
* Detailed description
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Include files
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// CompilerIncludes
|
||||
// All include files that are provided by the compiler directly
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
// ProjectIncludes
|
||||
// All include files that are provided by the project
|
||||
#include "ISerialBus.h"
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class esplog : public ISerialBus<uint8_t>
|
||||
{
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public Section
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
public:
|
||||
// Class Constructor
|
||||
esplog();
|
||||
~esplog();
|
||||
|
||||
FunctionStatus read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length, uint32_t* actualLength);
|
||||
|
||||
FunctionStatus write(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length);
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Protected Section
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
protected:
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Private Section
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
#endif /* MAIN_HAL_INC_UART_H_ */
|
||||
@@ -0,0 +1,90 @@
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// \file esplog.cpp
|
||||
/// \brief Description
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
// vbchaos software design
|
||||
//
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
/// $Revision: $
|
||||
/// $Author: $
|
||||
/// $Date: $
|
||||
// (c) 2023 vbchaos
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Include files
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#include "esplog.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
esplog::esplog()
|
||||
{
|
||||
this->status = CLOSED;
|
||||
}
|
||||
|
||||
esplog::~esplog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FunctionStatus esplog::write(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length)
|
||||
{
|
||||
FunctionStatus returnValue = FUNCTION_STATUS_OK;
|
||||
|
||||
if (status == OPEN)
|
||||
{
|
||||
ESP_LOGI("", "%s", buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = FUNCTION_STATUS_NOT_OPEN;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
FunctionStatus esplog::read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length, uint32_t* actualLength)
|
||||
{
|
||||
FunctionStatus returnValue = FUNCTION_STATUS_OK;
|
||||
|
||||
if (status == OPEN)
|
||||
{
|
||||
// Do Stuff
|
||||
}
|
||||
else
|
||||
{
|
||||
returnValue = FUNCTION_STATUS_NOT_OPEN;
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
+34
-8
@@ -28,6 +28,7 @@
|
||||
#include "nvs_flash.h"
|
||||
|
||||
// HAL includes
|
||||
#include "esplog.h"
|
||||
#include "gpio.h"
|
||||
#include "i2c.h"
|
||||
#include "uart.h"
|
||||
@@ -36,7 +37,7 @@
|
||||
#include "isl29125.h"
|
||||
#include "logger.h"
|
||||
#include "ledmatrix.h"
|
||||
#include "Wifi.h"
|
||||
#include "wifi.h"
|
||||
|
||||
// Application includes
|
||||
#include "clock.h"
|
||||
@@ -92,7 +93,7 @@ void otaTask(void* parameters);
|
||||
|
||||
extern "C" void app_main(void)
|
||||
{
|
||||
esp_log_level_set("*", ESP_LOG_WARN);
|
||||
esp_log_level_set("*", ESP_LOG_INFO);
|
||||
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
|
||||
@@ -102,6 +103,9 @@ extern "C" void app_main(void)
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
|
||||
ESP_LOGE("Test", "System start");
|
||||
vTaskDelay(100);
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// UART
|
||||
//
|
||||
@@ -120,17 +124,30 @@ extern "C" void app_main(void)
|
||||
ESP_ERROR_CHECK(uart_set_pin(debugUart, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
|
||||
ESP_ERROR_CHECK(uart_driver_install(debugUart, 1024, 1024, 0, NULL, 0));
|
||||
|
||||
uart uartDebug = uart(&debugUart);
|
||||
uartDebug.open();
|
||||
uartDebug.write(255, 255, (uint8_t*)"START", 5);
|
||||
ESP_LOGE("Test", "Uart installed");
|
||||
vTaskDelay(100);
|
||||
|
||||
// uart uartDebug = uart(&debugUart);
|
||||
// uartDebug.open();
|
||||
// uartDebug.write(255, 255, (uint8_t*)"START", 5);
|
||||
|
||||
ESP_LOGE("Test", "Uart interface open");
|
||||
vTaskDelay(100);
|
||||
|
||||
esplog esplogger = esplog();
|
||||
esplogger.open();
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// System-wide Debug Logger
|
||||
//
|
||||
|
||||
logger debugLogger = logger(16, uartDebug);
|
||||
// logger debugLogger = logger(16, uartDebug);
|
||||
logger debugLogger = logger(16, esplogger);
|
||||
// Call the logger executable within a dedicated task and forget about it afterwards
|
||||
xTaskCreate(loggerTask, (const char*)"loggerTask", 4000, &debugLogger, 3, &loggerTaskHandle);
|
||||
xTaskCreate(loggerTask, (const char*)"loggerTask", 3000, &debugLogger, 3, &loggerTaskHandle);
|
||||
|
||||
ESP_LOGE("Test", "Logger Task started");
|
||||
vTaskDelay(100);
|
||||
|
||||
LOGGER_PRINT("\n\r-----------------------------------------------------------------------\n\r");
|
||||
LOGGER_PRINT("System Start\n\r");
|
||||
@@ -139,6 +156,9 @@ extern "C" void app_main(void)
|
||||
LOGGER_PRINT("Release: %d.%d \n\r", MAJORRELEASE, MINORRELEASE);
|
||||
LOGGER_PRINT("Compiled on %s at %s\n\r\n\r\n\r", __DATE__, __TIME__);
|
||||
|
||||
|
||||
ESP_LOGE("Test", "Logger System Rpintout");
|
||||
vTaskDelay(100);
|
||||
// // -----------------------------------------------------------------------------------------------------------------
|
||||
// // I2C Masterbus for sensoring peripherals
|
||||
// //
|
||||
@@ -176,9 +196,15 @@ extern "C" void app_main(void)
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Wifi create and connect
|
||||
//
|
||||
Wifi wifi;
|
||||
Wifi wifi = Wifi();
|
||||
ESP_LOGE("Test", "Wifi object created");
|
||||
vTaskDelay(100);
|
||||
|
||||
wifi.start_client();
|
||||
|
||||
ESP_LOGE("Test", "Wifi started");
|
||||
vTaskDelay(100);
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Programmable LEDs in a strip
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user