diff --git a/RemoteIDModule/RemoteIDModule.ino b/RemoteIDModule/RemoteIDModule.ino index fd3bcd7..71af201 100644 --- a/RemoteIDModule/RemoteIDModule.ino +++ b/RemoteIDModule/RemoteIDModule.ino @@ -104,9 +104,18 @@ void setup() #endif #if defined(PIN_CAN_TERM) +#if !defined(CAN_TERM_EN) +#define CAN_TERM_EN HIGH +#endif + // optional CAN termination control pinMode(PIN_CAN_TERM, OUTPUT); - digitalWrite(PIN_CAN_TERM, HIGH); + + if (g.can_term == 1) { + digitalWrite(PIN_CAN_TERM, CAN_TERM_EN); + } else { + digitalWrite(PIN_CAN_TERM, !CAN_TERM_EN); + } #endif #if defined(BUZZER_PIN) diff --git a/RemoteIDModule/board_config.h b/RemoteIDModule/board_config.h index fa1b613..8107b5a 100644 --- a/RemoteIDModule/board_config.h +++ b/RemoteIDModule/board_config.h @@ -160,6 +160,9 @@ #define WS2812_LED_PIN GPIO_NUM_48 +#define PIN_CAN_TERM GPIO_NUM_37 +#define CAN_TERM_EN LOW + #else #error "unsupported board" #endif diff --git a/RemoteIDModule/parameters.cpp b/RemoteIDModule/parameters.cpp index fbeb3a0..b28a986 100644 --- a/RemoteIDModule/parameters.cpp +++ b/RemoteIDModule/parameters.cpp @@ -12,6 +12,9 @@ static nvs_handle handle; const Parameters::Param Parameters::params[] = { { "LOCK_LEVEL", Parameters::ParamType::INT8, (const void*)&g.lock_level, 0, -1, 2 }, { "CAN_NODE", Parameters::ParamType::UINT8, (const void*)&g.can_node, 0, 0, 127 }, +#if defined(PIN_CAN_TERM) + { "CAN_TERMINATE", Parameters::ParamType::UINT8, (const void*)&g.can_term, 0, 0, 1 }, +#endif { "UAS_TYPE", Parameters::ParamType::UINT8, (const void*)&g.ua_type, 0, 0, 15 }, { "UAS_ID_TYPE", Parameters::ParamType::UINT8, (const void*)&g.id_type, 0, 0, 4 }, { "UAS_ID", Parameters::ParamType::CHAR20, (const void*)&g.uas_id[0], 0, 0, 0 }, diff --git a/RemoteIDModule/parameters.h b/RemoteIDModule/parameters.h index b537c97..38c05d8 100644 --- a/RemoteIDModule/parameters.h +++ b/RemoteIDModule/parameters.h @@ -1,6 +1,7 @@ #pragma once #include +#include "board_config.h" #define MAX_PUBLIC_KEYS 5 #define PUBLIC_KEY_LEN 32 @@ -12,6 +13,9 @@ class Parameters { public: +#if defined(PIN_CAN_TERM) + uint8_t can_term = !CAN_TERM_EN; +#endif int8_t lock_level; uint8_t can_node; uint8_t bcast_powerup;