diff --git a/CLC-qthing/SiliconTorch/CyanBus.cpp b/CLC-qthing/SiliconTorch/CyanBus.cpp index 24c4d71753a625b54a357e91bc96b932bccdfc0f..5dfe382b15f499e3f7c85b001afa3b046b09a9aa 100644 --- a/CLC-qthing/SiliconTorch/CyanBus.cpp +++ b/CLC-qthing/SiliconTorch/CyanBus.cpp @@ -9,6 +9,7 @@ #include "esp_log.h" #include "driver/gpio.h" #include "driver/uart.h" +#include "freertos/FreeRTOS.h" #include "freertos/queue.h" // project specific @@ -22,15 +23,15 @@ static const char* TAG = "CyanBus"; -// This leads to ~54 P/s @ 2 MBaud at 100% load -// TODO: Make configurable?! -const uint32_t CyanBusMTU = 4096; - - namespace SiliconTorch { namespace CyanBus { + // This leads to ~54 P/s @ 2 MBaud at 100% load + const uint32_t MTU = 4096; + + const uint8_t* const HEADER = (const uint8_t*)"fxCyan"; + CyanBus::CyanBus(uint8_t tx, uint8_t rx, uint8_t de, uint8_t re, uint32_t baudRate, uint8_t uartChannel) : tx(tx), rx(rx), de(de), re(re), uartChannel(uartChannel) { @@ -74,7 +75,7 @@ namespace SiliconTorch { uart_port_t _ch = (uart_port_t)uartChannel; - uart_driver_install(_ch, CyanBusMTU, 0, 0, &uartEvQ, 0); + uart_driver_install(_ch, MTU * 2, 0, 32, &uartEvQ, 0); // txBuf = 0; queue size = 32; TODO: evaluate!!! uart_param_config(_ch, &uartConfig); uart_set_pin(_ch, tx, rx, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); uart_set_mode(_ch, UART_MODE_UART); @@ -85,12 +86,21 @@ namespace SiliconTorch { rxEN(true); - // readerTaskHandle = new SiliconTorch::Util::LambdaTask([&](){ readerTask(); }); - + readerTaskHandle = new SiliconTorch::Util::LambdaTask([&](){ readerTask(); }); } void CyanBus::readerTask() { - // const uint8_t* header = (const uint8_t*)"fxCyan"; + + uart_event_t event; + + uint32_t bufLEN = MTU * 1.2; + uint8_t* buffer = new uint8_t[bufLEN]; + uint8_t* bufPTR = buffer; + + ESP_LOGW(TAG, "bufLEN = %d BufferSize[MTU * 1.2] = %d", bufLEN, (int)sizeof(buffer)); + + + } diff --git a/CLC-qthing/SiliconTorch/CyanBus.hpp b/CLC-qthing/SiliconTorch/CyanBus.hpp index e3f0a7e0c77f0eeccece23d28fe15ad0d6253c43..ee561e7ab4b4431f36edf8cfe5d08f7ca65eb5b0 100644 --- a/CLC-qthing/SiliconTorch/CyanBus.hpp +++ b/CLC-qthing/SiliconTorch/CyanBus.hpp @@ -6,6 +6,7 @@ #include <functional> // ESP32 specific +#include "freertos/FreeRTOS.h" #include "freertos/queue.h" // project specific @@ -16,6 +17,12 @@ namespace SiliconTorch { namespace CyanBus { + // CyanBus payload MTU + extern const uint32_t MTU; + + // CyanBus envelope header + extern const uint8_t* const HEADER; + class CyanBus { public: CyanBus(uint8_t tx, uint8_t rx, uint8_t de, uint8_t re, uint32_t baudRate = 115200, uint8_t uartChannel = 1); diff --git a/CLC-qthing/device_main.cpp b/CLC-qthing/device_main.cpp index f8a0a690d23ac98720f11db3bc63aeffb30764a8..c15857689b648fbffe8c7b072471c96433cad4e4 100644 --- a/CLC-qthing/device_main.cpp +++ b/CLC-qthing/device_main.cpp @@ -9,7 +9,6 @@ #include "CyanLight.hpp" -#include "SiliconTorch/RS485.hpp" #include "SiliconTorch/CyanBus.hpp" @@ -20,10 +19,15 @@ CyanLight::CyanLightControl* ctrl; void device_main() { - SiliconTorch::Impl::RS485 rs485(25, 21, 22, 23); - SiliconTorch::CyanBus::CyanBus cyanBus(rs485); + uint8_t tx = 0; + uint8_t rx = 0; + uint8_t de = 0; + uint8_t re = 0; + SiliconTorch::CyanBus::CyanBus cyanBus(tx, rx, de, re); + + // TODO: ???