diff --git a/.gitignore b/.gitignore index 83a5535..30d13b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ -.devcontainer -.vscode -.cache -build -sdkconfig.old \ No newline at end of file +.devcontainer/ +.cache/ +build/ +CMakeFiles/ + +CMakeCache.txt +sdkconfig.old diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..98f2d1e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "sonarlint.pathToCompileCommands": "${workspaceFolder}/build/compile_commands.json" +} \ No newline at end of file diff --git a/components/opentherm/opentherm.c b/components/opentherm/opentherm.c index 8fea658..d770eab 100644 --- a/components/opentherm/opentherm.c +++ b/components/opentherm/opentherm.c @@ -7,6 +7,7 @@ #include "opentherm.h" #include "esp_log.h" +#include "hal/gpio_types.h" #include "rom/ets_sys.h" #include @@ -58,7 +59,7 @@ esp_err_t esp_ot_init( io_conf.pin_bit_mask = (1ULL << pin_in); io_conf.intr_type = GPIO_INTR_ANYEDGE; 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); io_conf.mode = GPIO_MODE_OUTPUT; @@ -385,11 +386,15 @@ float esp_ot_get_slave_ot_version() * * @return void */ + +#define OT_INPUT_ACTIVE 0 +#define OT_INPUT_INACTIVE 1 + void IRAM_ATTR esp_ot_handle_interrupt() { // ESP_DRAM_LOGI("esp_ot_handle_interrupt", "%ld", status); 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; } else { return; @@ -398,7 +403,7 @@ void IRAM_ATTR esp_ot_handle_interrupt() unsigned long newTs = esp_timer_get_time(); 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_ot_status = OT_RESPONSE_START_BIT; esp_ot_response_timestamp = newTs; @@ -408,7 +413,7 @@ void IRAM_ATTR esp_ot_handle_interrupt() esp_ot_response_timestamp = newTs; } } 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_response_timestamp = newTs; 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) { if ((newTs - esp_ot_response_timestamp) > 750) { 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_bit_index++; } else { // stop bit diff --git a/main/ot_example.c b/main/ot_example.c index 8cf61c0..98331aa 100644 --- a/main/ot_example.c +++ b/main/ot_example.c @@ -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) { 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, "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); 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(); ESP_LOGI(T, "Slave Version: %08lX", slaveProductVersion); diff --git a/sdkconfig b/sdkconfig index 9e42f57..795998c 100644 --- a/sdkconfig +++ b/sdkconfig @@ -561,8 +561,8 @@ CONFIG_PARTITION_TABLE_MD5=y # # OpenTherm Configuration # -CONFIG_OT_IN_PIN=21 -CONFIG_OT_OUT_PIN=22 +CONFIG_OT_IN_PIN=17 +CONFIG_OT_OUT_PIN=16 # end of OpenTherm Configuration #