diff --git a/Core/Dallas/dallas_tools.c b/Core/Dallas/dallas_tools.c index 82f385d..f820d8d 100644 --- a/Core/Dallas/dallas_tools.c +++ b/Core/Dallas/dallas_tools.c @@ -286,12 +286,13 @@ HAL_StatusTypeDef Dallas_SensorDeInit(DALLAS_SensorHandleTypeDef *sensor) { if(sensor == NULL) return HAL_ERROR; - - DALLAS_InitStructTypeDef initbuff = sensor->Init; - - memset(sensor, 0, sizeof(DALLAS_SensorHandleTypeDef)); - - sensor->Init = initbuff; + + memset(&sensor->f, 0, sizeof(sensor->f)); + sensor->isConnected = 0; + sensor->isInitialized = 0; + sensor->isLost = 0; + sensor->temperature = 0; + sensor->sensROM = 0; return HAL_OK; } diff --git a/Core/Dallas/ds18b20_driver.c b/Core/Dallas/ds18b20_driver.c index b553291..5e1f250 100644 --- a/Core/Dallas/ds18b20_driver.c +++ b/Core/Dallas/ds18b20_driver.c @@ -593,6 +593,12 @@ HAL_StatusTypeDef DS18B20_Search(DS18B20_Drv_t *DS, OneWire_t *OW) OW->RomCnt++; } + for(int i = OW->RomCnt; i < DS18B20_DEVICE_AMOUNT; i++) + { + for(int j = 0; j < 8; j++) + DS->DevAddr[i][j] = 0; + } + if(OW->RomCnt > 0) return HAL_OK; diff --git a/Core/Modbus/interface_config.h b/Core/Modbus/interface_config.h index 456b4dd..c877134 100644 --- a/Core/Modbus/interface_config.h +++ b/Core/Modbus/interface_config.h @@ -21,7 +21,7 @@ #define MODBUS_VENDOR_NAME "NIO-12" #define MODBUS_PRODUCT_CODE "12345" #define MODBUS_REVISION "Ver. 1.0" -#define MODBUS_VENDOR_URL "https://git.arktika.cyou/set506/DS18B20_Library/src/branch/py32f002b_dallas" +#define MODBUS_VENDOR_URL "https://git.arktika.cyou/set506/DS18B20_Library/" #define MODBUS_PRODUCT_NAME "Dallas Driver" #define MODBUS_MODEL_NAME "PY32F002B" #define MODBUS_USER_APPLICATION_NAME "PY32Dallas" diff --git a/Core/Modbus/modbus_data.h b/Core/Modbus/modbus_data.h index bdea18b..102cc51 100644 --- a/Core/Modbus/modbus_data.h +++ b/Core/Modbus/modbus_data.h @@ -123,6 +123,7 @@ typedef struct //MB_DataCoilsTypeDef /* reg 2 - settings */ unsigned ConvertionDone:1; unsigned LostedSensors:1; + unsigned reserved2:11; }MB_DataCoilsTypeDef; // DEFINES FOR COIL ARRAYS @@ -130,7 +131,7 @@ typedef struct //MB_DataCoilsTypeDef #define C_CONTROL_QNT 5 #define C_FLAGS_ADDR 16 -#define C_FLAGS_QNT 2 +#define C_FLAGS_QNT 10 /** MODBUS_DATA_COILS_DEFINES * @} diff --git a/Core/PY32Module/PY32module_main.c b/Core/PY32Module/PY32module_main.c index e2713ca..f1e7181 100644 --- a/Core/PY32Module/PY32module_main.c +++ b/Core/PY32Module/PY32module_main.c @@ -32,15 +32,21 @@ void PYModule_main(void) } } - if(MB_DATA.Coils.ScanSensors) + if(MB_DATA.Coils.ReadSensor) { - PYModule_ScanSensor(&DallasBus); - } - else - { - scan_cnt = 0; + PYModule_ReadSensor(&hdallas1, &pchsens); + MB_DATA.Coils.ReadSensor = 0; } +// if(MB_DATA.Coils.ScanSensors) +// { +// PYModule_ScanSensor(&DallasBus); +// } +// else +// { +// scan_cnt = 0; +// } + if(MB_DATA.Coils.InitSensor) { PYModule_InitSensor(&pchsens); @@ -93,11 +99,11 @@ void PYModule_FirstInit(void) DallasBus.hdallas->onewire = &OW; DallasBus.hdallas->ds_devices = DS; PCHSens_InitModule(&hdallas1, &pchsens.module1, REG_PCH_NUMB_11|REG_PCH_DIODE_NUMB_1); - PCHSens_InitModule(&hdallas1, &pchsens.module2, REG_PCH_NUMB_12|REG_PCH_DIODE_NUMB_1); - PCHSens_InitModule(&hdallas1, &pchsens.module3, REG_PCH_NUMB_21|REG_PCH_DIODE_NUMB_1); - PCHSens_InitModule(&hdallas1, &pchsens.module4, REG_PCH_NUMB_22|REG_PCH_DIODE_NUMB_1); - PCHSens_InitModule(&hdallas1, &pchsens.module5, REG_PCH_NUMB_31|REG_PCH_DIODE_NUMB_1); - PCHSens_InitModule(&hdallas1, &pchsens.module6, REG_PCH_NUMB_32|REG_PCH_DIODE_NUMB_1); +// PCHSens_InitModule(&hdallas1, &pchsens.module2, REG_PCH_NUMB_12|REG_PCH_DIODE_NUMB_1); +// PCHSens_InitModule(&hdallas1, &pchsens.module3, REG_PCH_NUMB_21|REG_PCH_DIODE_NUMB_1); +// PCHSens_InitModule(&hdallas1, &pchsens.module4, REG_PCH_NUMB_22|REG_PCH_DIODE_NUMB_1); +// PCHSens_InitModule(&hdallas1, &pchsens.module5, REG_PCH_NUMB_31|REG_PCH_DIODE_NUMB_1); +// PCHSens_InitModule(&hdallas1, &pchsens.module6, REG_PCH_NUMB_32|REG_PCH_DIODE_NUMB_1); /* Поиск неизвестных сенсоров */ PCHSens_FindUnknownSensors(&DallasBus); @@ -184,10 +190,11 @@ void PYModule_InitSensor(PCHSens_TypeDef *pchsens) if(PCHSens_GetSensorByLocation(pchsens, (PCHSens_LocationTypeDef)MB_DATA.HoldRegs.InitStruct.Location, &sensor) != HAL_OK) return; uint64_t connectROM = 0; - connectROM = ((uint64_t)(MB_DATA.HoldRegs.InitStruct.ROM[0]))<<48; - connectROM |= ((uint64_t)(MB_DATA.HoldRegs.InitStruct.ROM[1]))<<32; - connectROM |= ((uint64_t)(MB_DATA.HoldRegs.InitStruct.ROM[2]))<<16; - connectROM |= ((uint64_t)(MB_DATA.HoldRegs.InitStruct.ROM[3])); + connectROM = ((uint64_t)(__REV16(MB_DATA.HoldRegs.InitStruct.ROM[0])))<<48; + connectROM |= ((uint64_t)(__REV16(MB_DATA.HoldRegs.InitStruct.ROM[1])))<<32; + connectROM |= ((uint64_t)(__REV16(MB_DATA.HoldRegs.InitStruct.ROM[2])))<<16; + connectROM |= ((uint64_t)(__REV16(MB_DATA.HoldRegs.InitStruct.ROM[3]))); + if(PCHSens_InitNewSensor(&hdallas1, sensor, connectROM) == HAL_OK) { PYModule_FillResponse(sensor, STATUS_OK); @@ -208,7 +215,7 @@ void PYModule_DeInitSensor(PCHSens_TypeDef *pchsens) if(PCHSens_GetSensorByLocation(pchsens, (PCHSens_LocationTypeDef)MB_DATA.HoldRegs.InitStruct.Location, &sensor) != HAL_OK) return; - if(PCHSens_UndefineSensor(sensor) != HAL_OK) + if(PCHSens_UndefineSensor(sensor) == HAL_OK) { PYModule_FillResponse(sensor, STATUS_OK); } diff --git a/MDK-ARM/PY32Dallas.uvoptx b/MDK-ARM/PY32Dallas.uvoptx index 2c1d52a..d6db912 100644 --- a/MDK-ARM/PY32Dallas.uvoptx +++ b/MDK-ARM/PY32Dallas.uvoptx @@ -153,7 +153,56 @@ (105=-1,-1,-1,-1,0) - + + + 0 + 0 + 201 + 1 +
134234866
+ 0 + 0 + 0 + 0 + 0 + 1 + ..\Core\PY32Module\PY32module_main.c + + \\Project\../Core/PY32Module/PY32module_main.c\201 +
+ + 1 + 0 + 197 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + ..\Core\PY32Module\PY32module_main.c + + +
+ + 2 + 0 + 198 + 1 +
0
+ 0 + 0 + 0 + 0 + 0 + 0 + ..\Core\PY32Module\PY32module_main.c + + +
+
0 @@ -173,7 +222,7 @@ 3 1 - hmodbus1,0x0A + hmodbus1,0x10 4 @@ -225,20 +274,10 @@ 1 2 - DS,0x10 - - - 2 - 2 - OW - - - 3 - 2 MB_DATA,0x10 - 4 + 2 2 hmodbus1