Fix rp2040 build.
This commit is contained in:
parent
88cf3e3f4e
commit
ac72e272ee
@ -65,7 +65,7 @@ void LinBusListener::setup() {
|
||||
}
|
||||
|
||||
// Register interval to submit log messages
|
||||
this->set_interval("logmsg", 50, [this]() { this->process_log_queue_(QUEUE_WAIT_DONT_BLOCK); });
|
||||
this->set_interval("logmsg", 50, [this]() { this->process_log_queue(QUEUE_WAIT_DONT_BLOCK); });
|
||||
}
|
||||
|
||||
void LinBusListener::update() { this->check_for_lin_fault_(); }
|
||||
@ -323,14 +323,14 @@ void LinBusListener::clear_uart_buffer_() {
|
||||
}
|
||||
}
|
||||
|
||||
void LinBusListener::process_lin_msg_queue_(TickType_t xTicksToWait) {
|
||||
void LinBusListener::process_lin_msg_queue(TickType_t xTicksToWait) {
|
||||
QUEUE_LIN_MSG lin_msg;
|
||||
while (xQueueReceive(this->lin_msg_queue_, &lin_msg, xTicksToWait) == pdPASS) {
|
||||
this->lin_message_recieved_(lin_msg.current_PID, lin_msg.data, lin_msg.len);
|
||||
}
|
||||
}
|
||||
|
||||
void LinBusListener::process_log_queue_(TickType_t xTicksToWait) {
|
||||
void LinBusListener::process_log_queue(TickType_t xTicksToWait) {
|
||||
QUEUE_LOG_MSG log_msg;
|
||||
while (xQueueReceive(this->log_queue_, &log_msg, xTicksToWait) == pdPASS) {
|
||||
auto current_PID = log_msg.current_PID;
|
||||
|
||||
@ -7,12 +7,11 @@
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/semphr.h>
|
||||
#endif // USE_ESP32
|
||||
#ifdef USE_ESP32_FRAMEWORK_ESP_IDF
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#endif // USE_ESP32_FRAMEWORK_ESP_IDF
|
||||
#ifdef USE_RP2040
|
||||
#include <hardware/uart.h>
|
||||
#include <FreeRTOS.h>
|
||||
#include <semphr.h>
|
||||
#include <queue.h>
|
||||
#endif // USE_RP2040
|
||||
|
||||
namespace esphome {
|
||||
@ -78,6 +77,9 @@ class LinBusListener : public PollingComponent, public uart::UARTDevice {
|
||||
void set_observer_mode(bool val) { this->observer_mode_ = val; }
|
||||
bool get_lin_bus_fault() { return fault_on_lin_bus_reported_ > 3; }
|
||||
|
||||
void process_lin_msg_queue(TickType_t xTicksToWait);
|
||||
void process_log_queue(TickType_t xTicksToWait);
|
||||
|
||||
#ifdef USE_RP2040
|
||||
// Return is the expected wait time till next data check is recommended.
|
||||
u_int32_t onSerialEvent();
|
||||
@ -143,8 +145,6 @@ class LinBusListener : public PollingComponent, public uart::UARTDevice {
|
||||
void read_lin_frame_();
|
||||
void clear_uart_buffer_();
|
||||
void setup_framework();
|
||||
void process_lin_msg_queue_(TickType_t xTicksToWait);
|
||||
void process_log_queue_(TickType_t xTicksToWait);
|
||||
|
||||
uint8_t lin_msg_static_queue_storage[6 * sizeof(QUEUE_LIN_MSG)];
|
||||
StaticQueue_t lin_msg_static_queue_;
|
||||
|
||||
@ -12,6 +12,8 @@ namespace truma_inetbox {
|
||||
|
||||
static const char *const TAG = "truma_inetbox.LinBusListener";
|
||||
|
||||
#define QUEUE_WAIT_BLOCKING (portTickType) portMAX_DELAY
|
||||
|
||||
void LinBusListener::setup_framework() {
|
||||
auto uartComp = static_cast<esphome::uart::truma_ESP32ArduinoUARTComponent *>(this->parent_);
|
||||
|
||||
@ -66,11 +68,13 @@ void LinBusListener::setup_framework() {
|
||||
void LinBusListener::eventTask_(void *args) {
|
||||
LinBusListener *instance = (LinBusListener *) args;
|
||||
for (;;) {
|
||||
instance->process_lin_msg_queue_((portTickType) portMAX_DELAY);
|
||||
instance->process_lin_msg_queue(QUEUE_WAIT_BLOCKING);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace truma_inetbox
|
||||
} // namespace esphome
|
||||
|
||||
#undef QUEUE_WAIT_BLOCKING
|
||||
|
||||
#endif // USE_ESP32_FRAMEWORK_ARDUINO
|
||||
@ -10,6 +10,8 @@ namespace truma_inetbox {
|
||||
|
||||
static const char *const TAG = "truma_inetbox.LinBusListener";
|
||||
|
||||
#define QUEUE_WAIT_BLOCKING (portTickType) portMAX_DELAY
|
||||
|
||||
void LinBusListener::setup_framework() {
|
||||
// uartSetFastReading
|
||||
auto uartComp = static_cast<uart::truma_IDFUARTComponent *>(this->parent_);
|
||||
@ -64,7 +66,7 @@ void LinBusListener::uartEventTask_(void *args) {
|
||||
uart_event_t event;
|
||||
for (;;) {
|
||||
// Waiting for UART event.
|
||||
if (xQueueReceive(*uartEventQueue, (void *) &event, (portTickType) portMAX_DELAY)) {
|
||||
if (xQueueReceive(*uartEventQueue, (void *) &event, QUEUE_WAIT_BLOCKING)) {
|
||||
if (event.type == UART_DATA && instance->available() > 0) {
|
||||
instance->onReceive_();
|
||||
} else if (event.type == UART_BREAK) {
|
||||
@ -82,11 +84,13 @@ void LinBusListener::uartEventTask_(void *args) {
|
||||
void LinBusListener::eventTask_(void *args) {
|
||||
LinBusListener *instance = (LinBusListener *) args;
|
||||
for (;;) {
|
||||
instance->process_lin_msg_queue_((portTickType) portMAX_DELAY);
|
||||
instance->process_lin_msg_queue(QUEUE_WAIT_BLOCKING);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace truma_inetbox
|
||||
} // namespace esphome
|
||||
|
||||
#undef QUEUE_WAIT_BLOCKING
|
||||
|
||||
#endif // USE_ESP32_FRAMEWORK_ESP_IDF
|
||||
@ -15,6 +15,8 @@ namespace truma_inetbox {
|
||||
|
||||
static const char *const TAG = "truma_inetbox.LinBusListener";
|
||||
|
||||
#define QUEUE_WAIT_DONT_BLOCK (TickType_t) 0
|
||||
|
||||
void LinBusListener::setup_framework() {
|
||||
auto uartComp = static_cast<esphome::uart::truma_RP2040UartComponent *>(this->parent_);
|
||||
auto is_hw_serial = uartComp->is_hw_serial();
|
||||
@ -101,13 +103,15 @@ extern void loop1() {
|
||||
// TODO: Reconsider processing lin messages here.
|
||||
// They contain blocking log messages.
|
||||
if (LIN_BUS_LISTENER_INSTANCE_1 != nullptr) {
|
||||
LIN_BUS_LISTENER_INSTANCE_1->process_lin_msg_queue_((portTickType) 0 /* No blocking*/);
|
||||
LIN_BUS_LISTENER_INSTANCE_1->process_lin_msg_queue(QUEUE_WAIT_DONT_BLOCK);
|
||||
}
|
||||
if (LIN_BUS_LISTENER_INSTANCE_2 != nullptr) {
|
||||
LIN_BUS_LISTENER_INSTANCE_2->process_lin_msg_queue_((portTickType) 0 /* No blocking*/);
|
||||
LIN_BUS_LISTENER_INSTANCE_2->process_lin_msg_queue(QUEUE_WAIT_DONT_BLOCK);
|
||||
}
|
||||
delay(sleep1 > sleep2 ? sleep2 : sleep1);
|
||||
}
|
||||
}
|
||||
|
||||
#undef QUEUE_WAIT_DONT_BLOCK
|
||||
|
||||
#endif // USE_RP2040
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user