Убраны пока лишние пч, т.к. датчиков всего 4
Убрана функция скана Исправлен оформирование ром для инициализации датчика Переделан функция деинита структуры сенсора
This commit is contained in:
@@ -287,11 +287,12 @@ 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
* @}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,56 @@
|
||||
<Name>(105=-1,-1,-1,-1,0)</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>201</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134234866</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>..\Core\PY32Module\PY32module_main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\Project\../Core/PY32Module/PY32module_main.c\201</Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>1</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>197</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>..\Core\PY32Module\PY32module_main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
<Bp>
|
||||
<Number>2</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>198</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>0</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>0</BreakIfRCount>
|
||||
<Filename>..\Core\PY32Module\PY32module_main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression></Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
@@ -173,7 +222,7 @@
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>hmodbus1,0x0A</ItemText>
|
||||
<ItemText>hmodbus1,0x10</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
@@ -225,20 +274,10 @@
|
||||
<Ww>
|
||||
<count>1</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>DS,0x10</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>2</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>OW</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>3</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>MB_DATA,0x10</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>4</count>
|
||||
<count>2</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>hmodbus1</ItemText>
|
||||
</Ww>
|
||||
|
||||
Reference in New Issue
Block a user