diff --git a/README.md b/README.md index 655d040..cd41b81 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,21 @@ 1.去掉压力传感器传感器信息自动上报 V5: 添加看门狗 +``` + +```c +BoardTypeId: + 0x080E0000: + kLargeSpaceDMLiquidCtrlBoard = 0x1, // 大空间消毒机液路板 + kLargeSpaceDMPowerCtrlBoard = 0x2, // 大空间消毒机电源板 + kSmallSpaceDMLiquidCtrlBoard = 0x3, // 小空间消毒机液路板 + kSmallSpaceDMPowerCtrlBoard = 0x4, // 小空间消毒机电源板 + kPipeDMLiquidCtrlBoard = 0x5, // 管道式消毒机液路板 + kPipeDMPowerCtrlBoard = 0x6, // 管道式消毒机电源板 + kDrawBarDMLiquidCtrlBoard = 0x7, // 手持拉杆箱消毒机液路板 + kDrawBarDMPowerCtrlBoard = 0x8, // 手持拉杆箱消毒机电源板 + kDrawBarDMExtBallValveCtrl = 0x9, // 手持拉杆箱消毒机外部球阀控制板 + kH2O2SensorBoard = 0xA, // H2O2传感器板 + + ``` \ No newline at end of file diff --git a/app_protocols/transmit_disfection_protocol b/app_protocols/transmit_disfection_protocol index 20cd700..57b758e 160000 --- a/app_protocols/transmit_disfection_protocol +++ b/app_protocols/transmit_disfection_protocol @@ -1 +1 @@ -Subproject commit 20cd7005a568952e4e8a440a3dc318ca7258311b +Subproject commit 57b758e6dd94aaedd42606bd27da98437090d6dc diff --git a/usrc/app_main.cpp b/usrc/app_main.cpp index 78c85b4..4959e99 100644 --- a/usrc/app_main.cpp +++ b/usrc/app_main.cpp @@ -80,11 +80,12 @@ void umain() { PublicBoard::ins()->initialize(); ZLOGI(TAG, "======================= boardinfo ==================== "); - ZLOGI(TAG, "project : %s ", PROJECT); - ZLOGI(TAG, "version : %d ", SOFTWARE_VERSION); - ZLOGI(TAG, "pversion: %d", deviceInfo_getProtocolVersion()); - ZLOGI(TAG, "sn : %s", sn_get_str()); - ZLOGI(TAG, "boardId : %d", PublicBoard::ins()->getBoardId()); + ZLOGI(TAG, "project : %s ", PROJECT); + ZLOGI(TAG, "version : %d ", SOFTWARE_VERSION); + ZLOGI(TAG, "pversion : %d", deviceInfo_getProtocolVersion()); + ZLOGI(TAG, "sn : %s", sn_get_str()); + ZLOGI(TAG, "boardTypeId : %s(%d)", BoardTypeId2Str(PublicBoard::ins()->getBoardTypeId()), PublicBoard::ins()->getBoardTypeId()); + ZLOGI(TAG, "boardId : %d", PublicBoard::ins()->getBoardId()); ZLOGI(TAG, "="); ProtocolProcesserMgr::ins()->initialize(); @@ -118,7 +119,6 @@ void umain() { ZLOGI(TAG, "======================= init processer ================ "); - ProtocolProcesserMgr::ins()->startSchedule(); ZLOGI(TAG, "="); diff --git a/usrc/board/public_board.cpp b/usrc/board/public_board.cpp index f4f9408..9c35c39 100644 --- a/usrc/board/public_board.cpp +++ b/usrc/board/public_board.cpp @@ -1,9 +1,27 @@ #include "public_board.hpp" #include "idtable/IdMgr.hpp" +#include "project_configs.h" using namespace iflytop; using namespace transmit_disfection_protocol; +static ZGPIO BID0; +static ZGPIO BID1; +static ZGPIO BID2; +static ZGPIO BID3; +static ZGPIO BID4; +static ZGPIO BID5; +static ZGPIO BID6; +static ZGPIO BID7; + +int32_t getDeviceIdFromFlash() { + int32_t *deviceId = (int32_t *)BOARD_TYPE_ID_FLASH_ADD; + if (*deviceId <= 0) { + return 0; + } + return *deviceId; +} + void PublicBoard::debugUartInit(void) { GPIO_InitTypeDef GPIO_InitStruct = {0}; @@ -74,12 +92,38 @@ void PublicBoard::initialize() { debugUartInit(); canInit(); + if (getDeviceIdFromFlash() <= 0) { + BID0.initAsInput(PE1, kxs_gpio_pullup, kxs_gpio_no_irq, false); + BID1.initAsInput(PE2, kxs_gpio_pullup, kxs_gpio_no_irq, false); + BID2.initAsInput(PE3, kxs_gpio_pullup, kxs_gpio_no_irq, false); + BID3.initAsInput(PE4, kxs_gpio_pullup, kxs_gpio_no_irq, false); + BID4.initAsInput(PE5, kxs_gpio_pullup, kxs_gpio_no_irq, false); + BID5.initAsInput(PE6, kxs_gpio_pullup, kxs_gpio_no_irq, false); + BID6.initAsInput(PE7, kxs_gpio_pullup, kxs_gpio_no_irq, false); + BID7.initAsInput(PE8, kxs_gpio_pullup, kxs_gpio_no_irq, false); + } + m_debugled.initAsOutput(DEBUG_LIGHT_GPIO, kxs_gpio_nopull, false, false); } void PublicBoard::setDebugLightState(bool state) { m_debugled.write(state); } void PublicBoard::toggleDebugLight() { m_debugled.toggle(); } -int PublicBoard::getProjId() { return klarge_space_disinfection_machine; } -int PublicBoard::getBoardTypeId() { return kLargeSpaceDMLiquidCtrlBoard; } +int PublicBoard::getProjId() { return IdMgr::ins().getProjId(getBoardTypeId()); } +int PublicBoard::getBoardTypeId() { + if (getDeviceIdFromFlash() > 0) { + return getDeviceIdFromFlash(); + } else { + int32_t id = 0; + id += BID0.read() ? 1 : 0; + id += BID1.read() ? 2 : 0; + id += BID2.read() ? 4 : 0; + id += BID3.read() ? 8 : 0; + id += BID4.read() ? 16 : 0; + id += BID5.read() ? 32 : 0; + id += BID6.read() ? 64 : 0; + id += BID7.read() ? 128 : 0; + return id; + } +} int PublicBoard::getBoardId() { return IdMgr::ins().getBoardId(getBoardTypeId()); } diff --git a/usrc/project_configs.h b/usrc/project_configs.h index 2393b16..b165578 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -6,7 +6,6 @@ #define SDK_DELAY_US_TIMER htim6 // 微秒延迟定时器,注意该延时定时器需要按照以下文档进行配置 http://192.168.1.3:3000/zwikipedia/iflytop_wikipedia/src/branch/master/doc/stm32cubemx_us_timer.md #define SDK_IRQ_PREEMPTPRIORITY_DEFAULT 5 // IO中断默认中断等级 #define SDK_CFG__CFG_FLASH_ADDR 0x080C0000 // -#define SDK_CFG__SN_FLASH_ADDR 0x080E0000 // #define SDK_MAX_TASK 10 /*********************************************************************************************************************** @@ -21,4 +20,7 @@ #define PROJECT "transmit_disinfection_micro" // 工程名称 #define SN_HEADER "SN" // SN号前缀 #define DEBUG_UART huart1 // 调试串口 -#define DEBUG_LIGHT_GPIO PE0 // 调试指示灯 \ No newline at end of file +#define DEBUG_LIGHT_GPIO PE0 // 调试指示灯 + +#define BOARD_TYPE_ID_FLASH_ADD 0x080E0000 +#define SDK_CFG__SN_FLASH_ADDR 0x080E0004 //