Customize it to fit the hardware.

This commit is contained in:
Attila Body 2025-06-05 12:57:11 +02:00
parent 381c994449
commit afd998adb6
Signed by: abody
GPG key ID: BD0C6214E68FB5CF
5 changed files with 24 additions and 14 deletions

10
.gitignore vendored
View file

@ -1,5 +1,7 @@
.devcontainer .devcontainer/
.vscode .cache/
.cache build/
build CMakeFiles/
CMakeCache.txt
sdkconfig.old sdkconfig.old

3
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"sonarlint.pathToCompileCommands": "${workspaceFolder}/build/compile_commands.json"
}

View file

@ -7,6 +7,7 @@
#include "opentherm.h" #include "opentherm.h"
#include "esp_log.h" #include "esp_log.h"
#include "hal/gpio_types.h"
#include "rom/ets_sys.h" #include "rom/ets_sys.h"
#include <stdio.h> #include <stdio.h>
@ -58,7 +59,7 @@ esp_err_t esp_ot_init(
io_conf.pin_bit_mask = (1ULL << pin_in); io_conf.pin_bit_mask = (1ULL << pin_in);
io_conf.intr_type = GPIO_INTR_ANYEDGE; io_conf.intr_type = GPIO_INTR_ANYEDGE;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE; io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_DISABLE; io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config(&io_conf); gpio_config(&io_conf);
io_conf.mode = GPIO_MODE_OUTPUT; io_conf.mode = GPIO_MODE_OUTPUT;
@ -385,11 +386,15 @@ float esp_ot_get_slave_ot_version()
* *
* @return void * @return void
*/ */
#define OT_INPUT_ACTIVE 0
#define OT_INPUT_INACTIVE 1
void IRAM_ATTR esp_ot_handle_interrupt() void IRAM_ATTR esp_ot_handle_interrupt()
{ {
// ESP_DRAM_LOGI("esp_ot_handle_interrupt", "%ld", status); // ESP_DRAM_LOGI("esp_ot_handle_interrupt", "%ld", status);
if (esp_ot_is_ready()) { if (esp_ot_is_ready()) {
if (esp_ot_is_slave && esp_ot_read_state() == 1) { if (esp_ot_is_slave && esp_ot_read_state() == OT_INPUT_ACTIVE) {
esp_ot_status = OT_RESPONSE_WAITING; esp_ot_status = OT_RESPONSE_WAITING;
} else { } else {
return; return;
@ -398,7 +403,7 @@ void IRAM_ATTR esp_ot_handle_interrupt()
unsigned long newTs = esp_timer_get_time(); unsigned long newTs = esp_timer_get_time();
if (esp_ot_status == OT_RESPONSE_WAITING) { if (esp_ot_status == OT_RESPONSE_WAITING) {
if (esp_ot_read_state() == 1) { if (esp_ot_read_state() == OT_INPUT_ACTIVE) {
// ESP_DRAM_LOGI("BIT", "Set start bit"); // ESP_DRAM_LOGI("BIT", "Set start bit");
esp_ot_status = OT_RESPONSE_START_BIT; esp_ot_status = OT_RESPONSE_START_BIT;
esp_ot_response_timestamp = newTs; esp_ot_response_timestamp = newTs;
@ -408,7 +413,7 @@ void IRAM_ATTR esp_ot_handle_interrupt()
esp_ot_response_timestamp = newTs; esp_ot_response_timestamp = newTs;
} }
} else if (esp_ot_status == OT_RESPONSE_START_BIT) { } else if (esp_ot_status == OT_RESPONSE_START_BIT) {
if ((newTs - esp_ot_response_timestamp < 750) && esp_ot_read_state() == 0) { if ((newTs - esp_ot_response_timestamp < 750) && esp_ot_read_state() == OT_INPUT_INACTIVE) {
esp_ot_status = OT_RESPONSE_RECEIVING; esp_ot_status = OT_RESPONSE_RECEIVING;
esp_ot_response_timestamp = newTs; esp_ot_response_timestamp = newTs;
esp_ot_response_bit_index = 0; esp_ot_response_bit_index = 0;
@ -419,7 +424,7 @@ void IRAM_ATTR esp_ot_handle_interrupt()
} else if (esp_ot_status == OT_RESPONSE_RECEIVING) { } else if (esp_ot_status == OT_RESPONSE_RECEIVING) {
if ((newTs - esp_ot_response_timestamp) > 750) { if ((newTs - esp_ot_response_timestamp) > 750) {
if (esp_ot_response_bit_index < 32) { if (esp_ot_response_bit_index < 32) {
response = (response << 1) | !esp_ot_read_state(); response = (response << 1) | (esp_ot_read_state() == OT_INPUT_INACTIVE);
esp_ot_response_timestamp = newTs; esp_ot_response_timestamp = newTs;
esp_ot_response_bit_index++; esp_ot_response_bit_index++;
} else { // stop bit } else { // stop bit

View file

@ -34,7 +34,7 @@ static void IRAM_ATTR esp_ot_process_response_callback(unsigned long response, o
void esp_ot_control_task_handler(void *pvParameter) void esp_ot_control_task_handler(void *pvParameter)
{ {
while (1) { while (1) {
unsigned long status = esp_ot_set_boiler_status(false, true, false, false, false); unsigned long status = esp_ot_set_boiler_status(false, false, false, false, false);
ESP_LOGI(T, "====== OPENTHERM ====="); ESP_LOGI(T, "====== OPENTHERM =====");
ESP_LOGI(T, "Free heap size before: %ld", esp_get_free_heap_size()); ESP_LOGI(T, "Free heap size before: %ld", esp_get_free_heap_size());
@ -61,7 +61,7 @@ void esp_ot_control_task_handler(void *pvParameter)
ESP_LOGI(T, "CH Temp: %.1f", chTemp); ESP_LOGI(T, "CH Temp: %.1f", chTemp);
float pressure = esp_ot_get_pressure(); float pressure = esp_ot_get_pressure();
ESP_LOGI(T, "Slave OT Version: %.1f", pressure); ESP_LOGI(T, "Pressure: %.1f", pressure);
unsigned long slaveProductVersion = esp_ot_get_slave_product_version(); unsigned long slaveProductVersion = esp_ot_get_slave_product_version();
ESP_LOGI(T, "Slave Version: %08lX", slaveProductVersion); ESP_LOGI(T, "Slave Version: %08lX", slaveProductVersion);

View file

@ -561,8 +561,8 @@ CONFIG_PARTITION_TABLE_MD5=y
# #
# OpenTherm Configuration # OpenTherm Configuration
# #
CONFIG_OT_IN_PIN=21 CONFIG_OT_IN_PIN=17
CONFIG_OT_OUT_PIN=22 CONFIG_OT_OUT_PIN=16
# end of OpenTherm Configuration # end of OpenTherm Configuration
# #