diff --git a/platformio_tasmota_env.ini b/platformio_tasmota_env.ini index 4fcae1887..fd479cf4c 100644 --- a/platformio_tasmota_env.ini +++ b/platformio_tasmota_env.ini @@ -68,7 +68,7 @@ board_build.f_cpu = 160000000L lib_extra_dirs = lib/lib_ssl [env:tasmota-zigbee] -build_flags = ${common.build_flags} -DUSE_ZIGBEE -DUSE_UFILESYS +build_flags = ${common.build_flags} -DUSE_ZIGBEE -DUSE_CCLOADER -DUSE_UFILESYS board = esp8266_4M2M board_build.f_cpu = 160000000L diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index b3cc2d0fc..fcd53cd2b 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -176,7 +176,7 @@ enum ProgramSelectablePins { GPIO_USER, // User configurable needs to be 2047 GPIO_MAX }; -#define MAX_OPTIONS_A 3 // Increase if more bits are used from GpioOptionABits +#define MAX_OPTIONS_A 4 // Increase if more bits are used from GpioOptionABits typedef union { // Restricted by MISRA-C Rule 18.4 but so useful... uint32_t data; // Allow bit manipulation using SetOption @@ -184,7 +184,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu uint32_t pwm1_input : 1; // bit 0 (v9.2.0.1) - Option_A1 - (Light) Change PWM1 to input on power off and no fade running (1) uint32_t dummy_energy : 1; // bit 1 (v9.3.1.2) - Option_A2 - (Energy) Enable dummy values uint32_t udisplay_driver : 1; // bit 2 (v9.3.1.2) - Option_A3 - (Display) Universal display driver - uint32_t spare03 : 1; // bit 3 + uint32_t enable_ccloader : 1; // bit 3 (v9.4.0.5) - Option_A4 - (Zigbee) Enable CCLoader using Zigbee Rx/Tx/Rst Gpios uint32_t spare04 : 1; // bit 4 uint32_t spare05 : 1; // bit 5 uint32_t spare06 : 1; // bit 6 diff --git a/tasmota/xdrv_23_zigbee_A_impl.ino b/tasmota/xdrv_23_zigbee_A_impl.ino index da49c057b..ebc71e9cc 100644 --- a/tasmota/xdrv_23_zigbee_A_impl.ino +++ b/tasmota/xdrv_23_zigbee_A_impl.ino @@ -2128,8 +2128,9 @@ void ZigbeeShowMap(void) { * Interface \*********************************************************************************************/ -bool Xdrv23(uint8_t function) -{ +bool Xdrv23(uint8_t function) { + if (TasmotaGlobal.gpio_optiona.enable_ccloader) { return false; } + bool result = false; if (zigbee.active) { @@ -2177,7 +2178,7 @@ bool Xdrv23(uint8_t function) result = DecodeCommand(kZbCommands, ZigbeeCommand, kZbSynonyms); break; case FUNC_SAVE_BEFORE_RESTART: - if (!zigbee.init_phase) { + if (!zigbee.init_phase) { hibernateAllData(); restoreDumpAllDevices(); } diff --git a/tasmota/xdrv_46_ccloader.ino b/tasmota/xdrv_46_ccloader.ino index 3b2afc84b..8e258b91d 100644 --- a/tasmota/xdrv_46_ccloader.ino +++ b/tasmota/xdrv_46_ccloader.ino @@ -30,9 +30,14 @@ #ifdef USE_CCLOADER /*********************************************************************************************\ -* CCLOader +* CCLoader * * Usage: +* - Configure GPIOs like: +* - DEBUG_DATA on CC25xx device to GPIO Zigbee Rx +* - DEBUG_CLOCK on CC25xx device to GPIO Zigbee Tx +* - RESET_N on CC25xx device to GPIO Zigbee Rst +* - Any GPIO as Option_A4 \*********************************************************************************************/ #define XDRV_46 46 @@ -125,10 +130,10 @@ struct { const char CCLtype[] PROGMEM = "CCL"; -// Debug control pins & the indicate LED -int CCL_RESET = 14; //GPIO14=D5 on NodeMCU/WeMos D1 Mini -int CCL_DD = 4; //GPIO4=D2 on NodeMCU/WeMos D1 Mini -int CCL_DC = 5; //GPIO5=D1 on NodeMCU/WeMos D1 Mini +// Debug control pins +int CCL_RESET; // RESET_N on CC25xx device +int CCL_DD; // DEBUG_DATA on CC25xx device +int CCL_DC; // DEBUG_CLOCK on CC25xx device /********************************************************************************************/ /**************************************************************************//** @@ -520,22 +525,22 @@ void CCLRunDUP(void) delay(10); // Wait } -void CCLProgrammerInit(void) -{ - pinMode(CCL_DD, OUTPUT); - pinMode(CCL_DC, OUTPUT); - pinMode(CCL_RESET, OUTPUT); - digitalWrite(CCL_DD, LOW); - digitalWrite(CCL_DC, LOW); - digitalWrite(CCL_RESET, HIGH); -} +void CCLoaderinit(void) { + if (PinUsed(GPIO_ZIGBEE_RX) && PinUsed(GPIO_ZIGBEE_TX) && PinUsed(GPIO_ZIGBEE_RST)) { + CCL_RESET = Pin(GPIO_ZIGBEE_RST); + CCL_DD = Pin(GPIO_ZIGBEE_RX); + CCL_DC = Pin(GPIO_ZIGBEE_TX); -bool CCLoaderinit() -{ - CCLProgrammerInit(); - AddLog(LOG_LEVEL_INFO,PSTR("CCL: programmer init")); - CCL.init = true; - return true; + pinMode(CCL_DD, OUTPUT); + pinMode(CCL_DC, OUTPUT); + pinMode(CCL_RESET, OUTPUT); + digitalWrite(CCL_DD, LOW); + digitalWrite(CCL_DC, LOW); + digitalWrite(CCL_RESET, HIGH); + + AddLog(LOG_LEVEL_INFO, PSTR("CCL: programmer init")); + CCL.init = true; + } } String CCLChipName(uint8_t chipID) { @@ -664,22 +669,23 @@ void CCLoadershow(bool json) { * Interface \*********************************************************************************************/ -bool Xdrv46(uint8_t function) -{ +bool Xdrv46(uint8_t function) { + if (!TasmotaGlobal.gpio_optiona.enable_ccloader) { return false; } + bool result = false; if (FUNC_INIT == function) { - result = CCLoaderinit(); + CCLoaderinit(); } - if(CCL.init){ - switch(function){ - case FUNC_EVERY_100_MSECOND: - CCLoaderLoop(); - break; - case FUNC_WEB_SENSOR: - CCLoadershow(0); - break; - } + if (CCL.init) { + switch(function){ + case FUNC_EVERY_100_MSECOND: + CCLoaderLoop(); + break; + case FUNC_WEB_SENSOR: + CCLoadershow(0); + break; + } } return result; }