diff --git a/Core/Dallas/dallas_tools.c b/Core/Dallas/dallas_tools.c
index 4d36623..0ed6a6f 100644
--- a/Core/Dallas/dallas_tools.c
+++ b/Core/Dallas/dallas_tools.c
@@ -55,7 +55,7 @@ HAL_StatusTypeDef Dallas_ReplaceLostedSensor(DALLAS_SensorHandleTypeDef *sensor)
/**
* @brief Функция для иниицализации нового датчика в структуре
- * @param onewire Указатель на структуру OneWire
+ * @param hdallas Указатель на хендл для общения с датчиками
* @param sensor Указатель на структуру датчика
* @retval HAL Status
*/
@@ -79,7 +79,7 @@ HAL_StatusTypeDef Dallas_AddNewSensors(DALLAS_HandleTypeDef *hdallas, DALLAS_Sen
/**
* @brief Инициализирует структуру датчика по ROM
- * @param onewire Указатель на структуру OneWire
+ * @param hdallas Указатель на хендл для общения с датчиками
* @param sensor Указатель на структуру датчика
* @retval HAL Status
*/
@@ -141,7 +141,7 @@ HAL_StatusTypeDef Dallas_SensorInitByROM(DALLAS_HandleTypeDef *hdallas, DALLAS_S
/**
* @brief Инициализирует структуру датчика по пользовательским байтам
- * @param onewire Указатель на структуру OneWire
+ * @param hdallas Указатель на хендл для общения с датчиками
* @param sensor Указатель на структуру датчика
* @retval HAL Status
*/
@@ -211,7 +211,7 @@ HAL_StatusTypeDef Dallas_SensorInitByUserBytes(DALLAS_HandleTypeDef *hdallas, DA
/**
* @brief Инициализирует структуру датчика по порядковому номеру
- * @param onewire Указатель на структуру OneWire
+ * @param hdallas Указатель на хендл для общения с датчиками
* @param sensor Указатель на структуру датчика
* @retval HAL Status
* @details Порядковый номер датчика в списке найденных.
@@ -233,7 +233,7 @@ HAL_StatusTypeDef Dallas_SensorInitByInd(DALLAS_HandleTypeDef *hdallas, DALLAS_S
/**
* @brief Инициализирует датчик для работы
- * @param onewire Указатель на структуру OneWire
+ * @param hdallas Указатель на хендл для общения с датчиками
* @param sensor Указатель на структуру датчика
* @param ROM ROM датчика, который надо инициализировать
* @retval HAL Status
@@ -254,7 +254,7 @@ HAL_StatusTypeDef Dallas_SensorInit(DALLAS_HandleTypeDef *hdallas, DALLAS_Sensor
// sensor->sensROM |= ((uint64_t)(*ROM)[i] << (56 - 8*i));
/* Проверка присутствует ли выбранный датчик на линии */
- result = DS18B20_ReadScratchpad(hdallas->onewire, (uint8_t *)&sensor->sensROM, (uint8_t *)&hdallas->scratchpad);
+ result = Dallas_ReadScratchpad(sensor);
if (result == HAL_OK)
{
/* Установка разрешения */
@@ -279,9 +279,7 @@ HAL_StatusTypeDef Dallas_SensorInit(DALLAS_HandleTypeDef *hdallas, DALLAS_Sensor
/**
* @brief Деинициализирует структуру датчика
- * @param onewire Указатель на структуру OneWire
* @param sensor Указатель на структуру датчика
- * @param sens_ind Порядковый номер датчика в структуре
* @retval HAL Status
*/
HAL_StatusTypeDef Dallas_SensorDeInit(DALLAS_SensorHandleTypeDef *sensor)
@@ -300,7 +298,7 @@ HAL_StatusTypeDef Dallas_SensorDeInit(DALLAS_SensorHandleTypeDef *sensor)
/**
* @brief Запускает измерение температуры на всех датчиках
- * @param onewire Указатель на структуру OneWire
+ * @param hdallas Указатель на хендл для общения с датчиками
* @param waitCondition Условие ожидания завершения преобразования
* @param dallas_delay_ms Время ожидания окончания конверсии
* @retval HAL Status
@@ -483,11 +481,10 @@ HAL_StatusTypeDef Dallas_ReadTemperature(DALLAS_SensorHandleTypeDef *sensor)
HAL_StatusTypeDef Dallas_IsConnected(DALLAS_SensorHandleTypeDef *sensor)
{
HAL_StatusTypeDef result;
-
- if(sensor->isInitialized == 0)
+ if(sensor == NULL)
return HAL_ERROR;
-
- result = DS18B20_ReadScratchpad(sensor->hdallas->onewire, (uint8_t *)&sensor->sensROM, (uint8_t *)&sensor->hdallas->scratchpad);
+
+ result = Dallas_ReadScratchpad(sensor);
if (result == HAL_OK)
{
@@ -501,8 +498,8 @@ HAL_StatusTypeDef Dallas_IsConnected(DALLAS_SensorHandleTypeDef *sensor)
if(sensor->isConnected == 1)
{
sensor->f.disconnect_cnt++;
- sensor->isLost = 1;
}
+ sensor->isLost = 1;
sensor->isConnected = 0;
// Dallas_ReplaceLostedSensor(sensor);
@@ -522,6 +519,8 @@ HAL_StatusTypeDef Dallas_IsConnected(DALLAS_SensorHandleTypeDef *sensor)
HAL_StatusTypeDef Dallas_WriteUserBytes(DALLAS_SensorHandleTypeDef *sensor, uint16_t UserBytes12, uint16_t UserBytes34, uint8_t UserBytesMask)
{
HAL_StatusTypeDef result;
+ if(sensor == NULL)
+ return HAL_ERROR;
if(sensor->isInitialized == 0)
return HAL_ERROR;
@@ -537,7 +536,7 @@ HAL_StatusTypeDef Dallas_WriteUserBytes(DALLAS_SensorHandleTypeDef *sensor, uint
sensor->f.write_err_cnt++;
return result;
}
- result = DS18B20_ReadScratchpad(sensor->hdallas->onewire, (uint8_t *)&sensor->sensROM, (uint8_t *)&sensor->hdallas->scratchpad);
+ result = Dallas_ReadScratchpad(sensor);
if (result != HAL_OK)
{
return result;
@@ -547,3 +546,9 @@ HAL_StatusTypeDef Dallas_WriteUserBytes(DALLAS_SensorHandleTypeDef *sensor, uint
}
+HAL_StatusTypeDef Dallas_ReadScratchpad(DALLAS_SensorHandleTypeDef *sensor)
+{
+ if(sensor == NULL)
+ return HAL_ERROR;
+ return DS18B20_ReadScratchpad(sensor->hdallas->onewire, (uint8_t *)&sensor->sensROM, (uint8_t *)&sensor->hdallas->scratchpad);
+}
diff --git a/Core/Dallas/dallas_tools.h b/Core/Dallas/dallas_tools.h
index aa4808d..345c8ff 100644
--- a/Core/Dallas/dallas_tools.h
+++ b/Core/Dallas/dallas_tools.h
@@ -140,6 +140,8 @@ HAL_StatusTypeDef Dallas_ReadTemperature(DALLAS_SensorHandleTypeDef *sensor);
HAL_StatusTypeDef Dallas_IsConnected(DALLAS_SensorHandleTypeDef *sensor);
/* Записывает пользовательские байты */
HAL_StatusTypeDef Dallas_WriteUserBytes(DALLAS_SensorHandleTypeDef *sensor, uint16_t UserBytes12, uint16_t UserBytes34, uint8_t UserBytesMask);
+/* Записывает пользовательские байты */
+HAL_StatusTypeDef Dallas_ReadScratchpad(DALLAS_SensorHandleTypeDef *sensor);
#endif // #ifndef DALLAS_TOOLS_H
\ No newline at end of file
diff --git a/Core/Dallas/ds18b20_driver.c b/Core/Dallas/ds18b20_driver.c
index a87b63d..d72ee1a 100644
--- a/Core/Dallas/ds18b20_driver.c
+++ b/Core/Dallas/ds18b20_driver.c
@@ -352,6 +352,22 @@ HAL_StatusTypeDef DS18B20_WaitForEndConvertion(OneWire_t* OW)
}
+/**
+ * @brief The function is used to wait for end of convertion without blocking
+ * @param OW OneWire HandleTypedef
+ */
+HAL_StatusTypeDef DS18B20_WaitForEndConvertion_NonBlocking(OneWire_t* OW)
+{
+ if(OW == NULL)
+ return HAL_ERROR;
+
+ /* If line is pull down - conversion is ongoing */
+ if(OneWire_ReadBit(OW) == 0)
+ return HAL_BUSY;
+ else
+ return HAL_OK; // convertion done
+}
+
/**
* @brief The function is used as set temperature alarm range on
diff --git a/Core/Dallas/ds18b20_driver.h b/Core/Dallas/ds18b20_driver.h
index 42d42db..4751312 100644
--- a/Core/Dallas/ds18b20_driver.h
+++ b/Core/Dallas/ds18b20_driver.h
@@ -89,6 +89,7 @@ HAL_StatusTypeDef DS18B20_StartConvTAll(OneWire_t* OW);
HAL_StatusTypeDef DS18B20_CalcTemperature(OneWire_t* OW, uint8_t *ROM, uint8_t *Scratchpad, float *destination);
HAL_StatusTypeDef DS18B20_ReadScratchpad(OneWire_t* OW, uint8_t *ROM, uint8_t *Scratchpad);
HAL_StatusTypeDef DS18B20_WaitForEndConvertion(OneWire_t* OW);
+HAL_StatusTypeDef DS18B20_WaitForEndConvertion_NonBlocking(OneWire_t* OW);
HAL_StatusTypeDef DS18B20_SetTempAlarm(OneWire_t* OW, uint8_t *ROM, int8_t Low,
int8_t High);
HAL_StatusTypeDef DS18B20_WriteUserBytes(OneWire_t* OW, uint8_t *ROM, int16_t UserBytes12,
diff --git a/Core/Modbus/modbus.c b/Core/Modbus/modbus.c
index 6ba7edb..e5e0626 100644
--- a/Core/Modbus/modbus.c
+++ b/Core/Modbus/modbus.c
@@ -281,6 +281,7 @@ MB_ExceptionTypeDef MB_DefineRegistersAddress(uint16_t **pRegs, uint16_t Addr, u
if(MB_Check_Address_For_Arr(Addr, Qnt, R_TEMPERATURE_ADDR, R_TEMPERATURE_QNT) == NO_ERRORS)
{
*pRegs = MB_Set_Register_Ptr(&MB_DATA.InRegs, Addr); // начало регистров хранения/входных
+ MB_DATA.Coils.ConvertionDone = 0; // сброс флага
}
// Параметры датчика
else if(MB_Check_Address_For_Arr(Addr, Qnt, R_SENS_PARAMS_ADDR, R_SENS_PARAMS_QNT) == NO_ERRORS)
diff --git a/Core/Modbus/modbus_data.h b/Core/Modbus/modbus_data.h
index adf9a0d..3414778 100644
--- a/Core/Modbus/modbus_data.h
+++ b/Core/Modbus/modbus_data.h
@@ -109,8 +109,9 @@ typedef struct //MB_DataCoilsTypeDef
{
/* reg 1 - control */
unsigned RunConvertions:1;
+ unsigned ReadSensor:1;
unsigned InitSensor:1;
- unsigned DenitSensor:1;
+ unsigned DeInitSensor:1;
unsigned reserved:13;
diff --git a/Core/PY32Module/PY32module_main.c b/Core/PY32Module/PY32module_main.c
new file mode 100644
index 0000000..398d3c8
--- /dev/null
+++ b/Core/PY32Module/PY32module_main.c
@@ -0,0 +1,297 @@
+/**
+******************************************************************************
+* @file pch_sensors.c
+* @brief Работа с датчиками температуры DS18B20 в ПЧ
+*****************************************************************************/
+
+
+/* Includes ----------------------------------------------------------------*/
+
+#include "PY32module_main.h"
+#include "rs_message.h"
+
+/* Declarations and definitions --------------------------------------------*/
+PCHSens_TypeDef pchsens;
+
+/* Functions ---------------------------------------------------------------*/
+
+void PYModule_main(void)
+{
+
+ if(MB_DATA.Coils.RunConvertions)
+ {
+ if(DS18B20_WaitForEndConvertion_NonBlocking(hdallas1.onewire) == HAL_OK)
+ {
+ PCHSens_StartCovert(&DallasBus);
+ GPIOA->ODR ^= GPIO_LED_2;
+ }
+ }
+
+ if(MB_DATA.Coils.ReadSensor)
+ {
+ PYModule_ReadSensor(&hdallas1, &pchsens);
+ MB_DATA.Coils.ReadSensor = 0;
+ }
+
+ if(MB_DATA.Coils.InitSensor)
+ {
+ PYModule_InitSensor(&pchsens);
+ MB_DATA.Coils.InitSensor = 0;
+ }
+
+ if(MB_DATA.Coils.DeInitSensor != NULL)
+ {
+ PYModule_DeInitSensor(&pchsens);
+ MB_DATA.Coils.DeInitSensor = 0;
+ }
+
+ PYModule_CheckLosted(&pchsens);
+
+
+ if(MB_DATA.Coils.RunConvertions)
+ {
+ if(DS18B20_WaitForEndConvertion_NonBlocking(hdallas1.onewire) == HAL_OK)
+ {
+ PCHSens_ModuleReadTemperature(&pchsens.module1);
+// PCHSens_ModuleReadTemperature(&pchsens.module2);
+// PCHSens_ModuleReadTemperature(&pchsens.module3);
+// PCHSens_ModuleReadTemperature(&pchsens.module4);
+// PCHSens_ModuleReadTemperature(&pchsens.module5);
+// PCHSens_ModuleReadTemperature(&pchsens.module6);
+
+ PYModule_StoreModbus(&pchsens);
+ }
+ }
+
+}
+
+
+void PYModule_FirstInit(void)
+{
+ OW.DataPin = DS_Pin;
+ OW.DataPort = DS_GPIO_Port;
+ DS.Resolution = DS18B20_RESOLUTION_9BITS;
+
+ /* Инициализация onewire и поиск датчиков*/
+ OneWire_Init(&OW);
+ DS18B20_Search(&DS, &OW);
+
+
+ /* Инициализация modbus */
+ MODBUS_FirstInit();
+ RS_Receive_IT(&hmodbus1, &MODBUS_MSG);
+
+ /* Инициализация структур датчиков ПЧ */
+ DallasBus.hdallas = &hdallas1;
+ DallasBus.hdallas->onewire = &OW;
+ 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_13|REG_PCH_DIODE_NUMB_1);
+ PCHSens_InitModule(&hdallas1, &pchsens.module4, REG_PCH_NUMB_21|REG_PCH_DIODE_NUMB_1);
+ PCHSens_InitModule(&hdallas1, &pchsens.module5, REG_PCH_NUMB_22|REG_PCH_DIODE_NUMB_1);
+ PCHSens_InitModule(&hdallas1, &pchsens.module6, REG_PCH_NUMB_23|REG_PCH_DIODE_NUMB_1);
+
+ /* Поиск неизвестных сенсоров */
+ PCHSens_FindUnknownSensors(&DallasBus);
+
+ MB_DATA.Coils.RunConvertions = 1;
+}
+
+
+
+void PYModule_ReadSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_TypeDef *pchsens)
+{
+ // чтение по локации
+ if(MB_DATA.HoldRegs.InitStruct.Location != 0) // если локация не равна нулю
+ {
+ PCHSens_SensorTypeDef *sensor;
+
+ if(PCHSens_GetSensorByLocation(pchsens, (PCHSens_LocationTypeDef)MB_DATA.HoldRegs.InitStruct.Location, &sensor) != HAL_OK)
+ return;
+
+ if(Dallas_ReadScratchpad(&sensor->sens) == HAL_OK)
+ {
+ MB_DATA.InRegs.Response.Location = *(uint16_t *)&sensor->sens.hdallas->scratchpad.tHighRegister;
+ MB_DATA.InRegs.Response.Resolution = sensor->sens.hdallas->scratchpad.ConfigRegister;
+ MB_DATA.InRegs.Response.ROM[0] = __REV16((sensor->sens.sensROM) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[1] = __REV16((sensor->sens.sensROM >> 16) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[2] = __REV16((sensor->sens.sensROM >> 32) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[3] = __REV16((sensor->sens.sensROM >> 48) & 0xFFFF);
+ MB_DATA.InRegs.Response.Status = 0x1;
+ }
+ else
+ {
+ MB_DATA.InRegs.Response.Location = MB_DATA.HoldRegs.InitStruct.Location;
+ MB_DATA.InRegs.Response.Resolution = 0;
+ MB_DATA.InRegs.Response.ROM[0] = 0;
+ MB_DATA.InRegs.Response.ROM[1] = 0;
+ MB_DATA.InRegs.Response.ROM[2] = 0;
+ MB_DATA.InRegs.Response.ROM[3] = 0;
+ MB_DATA.InRegs.Response.Status = 0xFF;
+ }
+ }
+ // чтение по ROM
+ else if(MB_DATA.HoldRegs.InitStruct.ROM[0] | MB_DATA.HoldRegs.InitStruct.ROM[1] | // если РОМ не равен нулю
+ MB_DATA.HoldRegs.InitStruct.ROM[2] | MB_DATA.HoldRegs.InitStruct.ROM[3] != 0)
+ {
+ if(DS18B20_ReadScratchpad(hdallas->onewire, (uint8_t *)MB_DATA.HoldRegs.InitStruct.ROM, (uint8_t *)&hdallas->scratchpad) == HAL_OK)
+ {
+ MB_DATA.InRegs.Response.Location = *(uint16_t *)&hdallas->scratchpad.tHighRegister;
+ MB_DATA.InRegs.Response.Resolution = hdallas->scratchpad.ConfigRegister;
+ MB_DATA.InRegs.Response.ROM[0] = MB_DATA.HoldRegs.InitStruct.ROM[0];
+ MB_DATA.InRegs.Response.ROM[1] = MB_DATA.HoldRegs.InitStruct.ROM[1];
+ MB_DATA.InRegs.Response.ROM[2] = MB_DATA.HoldRegs.InitStruct.ROM[2];
+ MB_DATA.InRegs.Response.ROM[3] = MB_DATA.HoldRegs.InitStruct.ROM[3];
+ MB_DATA.InRegs.Response.Status = 0x1;
+ }
+ else
+ {
+ MB_DATA.InRegs.Response.Location = 0;
+ MB_DATA.InRegs.Response.Resolution = 0;
+ MB_DATA.InRegs.Response.ROM[0] = MB_DATA.HoldRegs.InitStruct.ROM[0];
+ MB_DATA.InRegs.Response.ROM[1] = MB_DATA.HoldRegs.InitStruct.ROM[1];
+ MB_DATA.InRegs.Response.ROM[2] = MB_DATA.HoldRegs.InitStruct.ROM[2];
+ MB_DATA.InRegs.Response.ROM[3] = MB_DATA.HoldRegs.InitStruct.ROM[3];
+ MB_DATA.InRegs.Response.Status = 0xFF;
+ }
+ }
+
+
+}
+
+void PYModule_InitSensor(PCHSens_TypeDef *pchsens)
+{
+ if( (MB_DATA.HoldRegs.InitStruct.Location != 0) && // если локация не равна нулю
+ (MB_DATA.HoldRegs.InitStruct.ROM[0] | MB_DATA.HoldRegs.InitStruct.ROM[1] | // И если РОМ не равен нулю
+ MB_DATA.HoldRegs.InitStruct.ROM[2] | MB_DATA.HoldRegs.InitStruct.ROM[3] != 0) )
+ {
+ PCHSens_SensorTypeDef *sensor;
+
+ 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]));
+ if(PCHSens_InitNewSensor(&hdallas1, sensor, connectROM) == HAL_OK)
+ {
+ MB_DATA.InRegs.Response.Location = *(uint16_t *)&sensor->sens.hdallas->scratchpad.tHighRegister;
+ MB_DATA.InRegs.Response.Resolution = sensor->sens.hdallas->scratchpad.ConfigRegister;
+ MB_DATA.InRegs.Response.ROM[0] = __REV16((sensor->sens.sensROM) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[1] = __REV16((sensor->sens.sensROM >> 16) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[2] = __REV16((sensor->sens.sensROM >> 32) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[3] = __REV16((sensor->sens.sensROM >> 48) & 0xFFFF);
+ MB_DATA.InRegs.Response.Status = 0x1;
+ }
+ else
+ {
+ MB_DATA.InRegs.Response.Location = MB_DATA.HoldRegs.InitStruct.Location;
+ MB_DATA.InRegs.Response.Resolution = 0;
+ MB_DATA.InRegs.Response.ROM[0] = MB_DATA.HoldRegs.InitStruct.ROM[0];
+ MB_DATA.InRegs.Response.ROM[1] = MB_DATA.HoldRegs.InitStruct.ROM[1];
+ MB_DATA.InRegs.Response.ROM[2] = MB_DATA.HoldRegs.InitStruct.ROM[2];
+ MB_DATA.InRegs.Response.ROM[3] = MB_DATA.HoldRegs.InitStruct.ROM[3];
+ MB_DATA.InRegs.Response.Status = 0xFF;
+ }
+ }
+}
+
+void PYModule_DeInitSensor(PCHSens_TypeDef *pchsens)
+{
+ if(MB_DATA.HoldRegs.InitStruct.Location != 0) // если локация не равна нулю
+ {
+ PCHSens_SensorTypeDef *sensor;
+
+ if(PCHSens_GetSensorByLocation(pchsens, (PCHSens_LocationTypeDef)MB_DATA.HoldRegs.InitStruct.Location, &sensor) != HAL_OK)
+ return;
+
+ if(PCHSens_UndefineSensor(sensor) != HAL_OK)
+ {
+ MB_DATA.InRegs.Response.Location = *(uint16_t *)&sensor->sens.hdallas->scratchpad.tHighRegister;
+ MB_DATA.InRegs.Response.Resolution = sensor->sens.hdallas->scratchpad.ConfigRegister;
+ MB_DATA.InRegs.Response.ROM[0] = __REV16((sensor->sens.sensROM) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[1] = __REV16((sensor->sens.sensROM >> 16) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[2] = __REV16((sensor->sens.sensROM >> 32) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[3] = __REV16((sensor->sens.sensROM >> 48) & 0xFFFF);
+ MB_DATA.InRegs.Response.Status = 0xFF;
+ }
+ else
+ {
+ MB_DATA.InRegs.Response.Location = *(uint16_t *)&sensor->sens.hdallas->scratchpad.tHighRegister;
+ MB_DATA.InRegs.Response.Resolution = sensor->sens.hdallas->scratchpad.ConfigRegister;
+ MB_DATA.InRegs.Response.ROM[0] = __REV16((sensor->sens.sensROM) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[1] = __REV16((sensor->sens.sensROM >> 16) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[2] = __REV16((sensor->sens.sensROM >> 32) & 0xFFFF);
+ MB_DATA.InRegs.Response.ROM[3] = __REV16((sensor->sens.sensROM >> 48) & 0xFFFF);
+ MB_DATA.InRegs.Response.Status = 1;
+ }
+ }
+}
+
+void PYModule_CheckModuleLosted(PCHSens_ModuleTypeDef *module, uint8_t *losted_flag)
+{
+ if(module->sens1.not_found)
+ *losted_flag |= 1;
+ if(module->sens2.not_found)
+ *losted_flag |= 1;
+ if(module->sens3.not_found)
+ *losted_flag |= 1;
+ if(module->sens4.not_found)
+ *losted_flag |= 1;
+}
+void PYModule_CheckLosted(PCHSens_TypeDef *pchsens)
+{
+ uint8_t losted = 0;
+
+ // module1
+ PYModule_CheckModuleLosted(&pchsens->module1, &losted);
+ PYModule_CheckModuleLosted(&pchsens->module2, &losted);
+ PYModule_CheckModuleLosted(&pchsens->module3, &losted);
+ PYModule_CheckModuleLosted(&pchsens->module4, &losted);
+ PYModule_CheckModuleLosted(&pchsens->module5, &losted);
+ PYModule_CheckModuleLosted(&pchsens->module6, &losted);
+
+ if(losted)
+ MB_DATA.Coils.LostedSensors = 1;
+ else
+ MB_DATA.Coils.LostedSensors = 0;
+}
+
+void PYModule_StoreModuleToModbus(PCHSens_ModuleTypeDef *module)
+{
+ uint8_t mb_location;
+ uint8_t pch_numb = (module->refLocation.param.PCHdig1 - 1)*3 + (module->refLocation.param.PCHdig2 - 1);
+ pch_numb *= 4;
+
+ mb_location = pch_numb + module->sens1.Location.param.Location;
+ if (mb_location < DS18B20_DEVICE_AMOUNT)
+ MB_DATA.InRegs.SensTemperature[mb_location] = module->sens1.sens.temperature*100;
+
+ mb_location = pch_numb + module->sens2.Location.param.Location;
+ if (mb_location < DS18B20_DEVICE_AMOUNT)
+ MB_DATA.InRegs.SensTemperature[mb_location] = module->sens2.sens.temperature*100;
+
+ mb_location = pch_numb + module->sens3.Location.param.Location;
+ if (mb_location < DS18B20_DEVICE_AMOUNT)
+ MB_DATA.InRegs.SensTemperature[mb_location] = module->sens3.sens.temperature*100;
+
+ mb_location = pch_numb + module->sens4.Location.param.Location;
+ if (mb_location < DS18B20_DEVICE_AMOUNT)
+ MB_DATA.InRegs.SensTemperature[mb_location] = module->sens4.sens.temperature*100;
+}
+
+void PYModule_StoreModbus(PCHSens_TypeDef *pchsens)
+{
+ uint8_t losted = 0;
+
+ // module1
+ PYModule_StoreModuleToModbus(&pchsens->module1);
+ PYModule_StoreModuleToModbus(&pchsens->module2);
+ PYModule_StoreModuleToModbus(&pchsens->module3);
+ PYModule_StoreModuleToModbus(&pchsens->module4);
+ PYModule_StoreModuleToModbus(&pchsens->module5);
+ PYModule_StoreModuleToModbus(&pchsens->module6);
+
+ MB_DATA.Coils.ConvertionDone |= 1;
+}
\ No newline at end of file
diff --git a/Core/PY32Module/PY32module_main.h b/Core/PY32Module/PY32module_main.h
new file mode 100644
index 0000000..00e9259
--- /dev/null
+++ b/Core/PY32Module/PY32module_main.h
@@ -0,0 +1,26 @@
+/**
+******************************************************************************
+* @file pch_sensors.h
+* @brief Работа с датчиками температуры DS18B20 в ПЧ
+******************************************************************************
+*****************************************************************************/
+
+#ifndef MODULE_MAIN_H
+#define MODULE_MAIN_H
+
+/* Includes -----------------------------------------------------------------*/
+#include "main.h"
+#include "pch_sensors.h"
+#include "modbus_data.h"
+
+/* Declarations and definitions ---------------------------------------------*/
+
+/* Functions ---------------------------------------------------------------*/
+void PYModule_main(void);
+void PYModule_FirstInit(void);
+void PYModule_ReadSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_TypeDef *pchsens);
+void PYModule_InitSensor(PCHSens_TypeDef *pchsens);
+void PYModule_DeInitSensor(PCHSens_TypeDef *pchsens);
+void PYModule_CheckLosted(PCHSens_TypeDef *pchsens);
+void PYModule_StoreModbus(PCHSens_TypeDef *pchsens);
+#endif // #ifndef MODULE_MAIN_H
\ No newline at end of file
diff --git a/Core/Dallas/pch_sensors.c b/Core/PY32Module/pch_sensors.c
similarity index 62%
rename from Core/Dallas/pch_sensors.c
rename to Core/PY32Module/pch_sensors.c
index f47d36e..2300ef6 100644
--- a/Core/Dallas/pch_sensors.c
+++ b/Core/PY32Module/pch_sensors.c
@@ -10,16 +10,9 @@
#include "pch_sensors.h"
#include "modbus_data.h"
PCHSens_DallasBusHandle DallasBus;
-PCHSens_SensorActionsTypeDef action;
/* Declarations and definitions --------------------------------------------*/
-
-PCHSens_ModuleTypeDef module1;
-PCHSens_ModuleTypeDef module2;
-PCHSens_ModuleTypeDef module3;
-PCHSens_ModuleTypeDef module4;
-PCHSens_ModuleTypeDef module5;
-PCHSens_ModuleTypeDef module6;
+
/* Functions ---------------------------------------------------------------*/
HAL_StatusTypeDef PCHSens_InitNewSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef* sensor, uint64_t ROM)
{
@@ -73,8 +66,6 @@ HAL_StatusTypeDef PCHSens_AddSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_Senso
if(sensor == NULL)
return HAL_ERROR;
-// sensor->UserBytes = (PCHSens_LocationTypeDef *)&sensor->sens.scratchpad.tHighRegister;
-
sensor->sens.Init.InitParam = sensor->Location.all;
sensor->sens.Init.init_func = &Dallas_SensorInitByUserBytes;
@@ -102,7 +93,6 @@ HAL_StatusTypeDef PCHSens_InitModule(DALLAS_HandleTypeDef *hdallas, PCHSens_Modu
PCHSens_LocationTypeDef initlocation;
initlocation.all = param;
- action.read = 1;
module->hdallas = hdallas;
module->refLocation = initlocation;
@@ -126,23 +116,37 @@ HAL_StatusTypeDef PCHSens_InitModule(DALLAS_HandleTypeDef *hdallas, PCHSens_Modu
}
-HAL_StatusTypeDef PCHSens_ModuleHandleAction(PCHSens_ModuleTypeDef* module)
+HAL_StatusTypeDef PCHSens_ModuleReadTemperature(PCHSens_ModuleTypeDef* module)
{
HAL_StatusTypeDef result;
if(module == NULL)
return HAL_ERROR;
- result = PCHSens_SensorHandleActions(module->hdallas, &module->sens1);
- result = PCHSens_SensorHandleActions(module->hdallas, &module->sens2);
- result = PCHSens_SensorHandleActions(module->hdallas, &module->sens3);
- result = PCHSens_SensorHandleActions(module->hdallas, &module->sens4);
-
+ result = PCHSens_SensorReadTemperature(module->hdallas, &module->sens1);
+ result = PCHSens_SensorReadTemperature(module->hdallas, &module->sens2);
+ result = PCHSens_SensorReadTemperature(module->hdallas, &module->sens3);
+ result = PCHSens_SensorReadTemperature(module->hdallas, &module->sens4);
+
return result;
}
-HAL_StatusTypeDef PCHSens_Covert(PCHSens_DallasBusHandle *hbus)
+HAL_StatusTypeDef PCHSens_SensorReadTemperature(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef *sensor)
{
- return Dallas_StartConvertTAll(hbus->hdallas, DALLAS_WAIT_BUS, 0);
+ HAL_StatusTypeDef result;
+ if(hdallas == NULL)
+ return HAL_ERROR;
+ if(sensor == NULL)
+ return HAL_ERROR;
+
+ result = PCHSens_ReadTemperature(sensor);
+ if(result != HAL_OK)
+ PCHSens_CheckSensor(hdallas, sensor);
+
+ return result;
+}
+HAL_StatusTypeDef PCHSens_StartCovert(PCHSens_DallasBusHandle *hbus)
+{
+ return Dallas_StartConvertTAll(hbus->hdallas, DALLAS_WAIT_NONE, 0);
}
HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_SensorTypeDef* sensor)
{
@@ -150,9 +154,10 @@ HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_SensorTypeDef* sensor)
if(sensor == NULL)
return HAL_ERROR;
+ if(sensor->sens.isInitialized == 0)
+ return HAL_ERROR;
- result = Dallas_ReadTemperature(&sensor->sens);
- PCHSens_StoreToModbus(sensor);
+ result = Dallas_ReadTemperature(&sensor->sens);
return result;
}
@@ -163,12 +168,10 @@ HAL_StatusTypeDef PCHSens_CheckSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_Sen
if(sensor == NULL)
return HAL_ERROR;
- if(sensor->sens.isInitialized == 0)
- return HAL_ERROR;
- if((sensor->sens.isLost == 1))
+ if((sensor->sens.isLost == 1) || (sensor->sens.isInitialized == 0))
{
- if(Dallas_ReplaceLostedSensor(&sensor->sens) != HAL_OK)
+ if(Dallas_ReplaceLostedSensor(&sensor->sens) == HAL_ERROR)
{
sensor->not_found = 1;
}
@@ -177,6 +180,10 @@ HAL_StatusTypeDef PCHSens_CheckSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_Sen
sensor->not_found = 0;
}
}
+ else
+ {
+ sensor->not_found = 0;
+ }
return HAL_OK;
}
@@ -211,23 +218,6 @@ HAL_StatusTypeDef PCHSens_FindUnknownSensors(PCHSens_DallasBusHandle *hbus)
}
return HAL_OK;
}
-//HAL_StatusTypeDef PCHSens_DefineUnknownSensor(PCHSens_UnknownSensorsTypeDef *unknowns, PCHSens_SensorTypeDef *sensor)
-//{
-// HAL_StatusTypeDef result;
-// if(sensor == NULL)
-// return HAL_ERROR;
-//
-// if((unknowns->ROMtoDefine != NULL) && (unknowns->LocationtoDefine.all != NULL) && (unknowns->senstoDefine != NULL))
-// {
-// result = PCHSens_InitNewSensor(unknowns->onewire, unknowns->senstoDefine, unknowns->ROMtoDefine);
-// unknowns->ROMtoDefine = 0;
-// unknowns->LocationtoDefine.all = 0;
-// unknowns->senstoDefine = 0;
-// return result;
-// }
-// return HAL_OK;
-//}
-
HAL_StatusTypeDef PCHSens_UndefineSensor(PCHSens_SensorTypeDef *sensor)
{
HAL_StatusTypeDef result;
@@ -244,70 +234,40 @@ HAL_StatusTypeDef PCHSens_UndefineSensor(PCHSens_SensorTypeDef *sensor)
return result;
}
-HAL_StatusTypeDef PCHSens_SensorHandleActions(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef *sensor)
+HAL_StatusTypeDef PCHSens_GetSensorByLocation(PCHSens_TypeDef *pchsens, PCHSens_LocationTypeDef Location, PCHSens_SensorTypeDef **sensor)
{
- HAL_StatusTypeDef result;
- if(sensor == NULL)
- return HAL_ERROR;
+ PCHSens_ModuleTypeDef *module;
+ uint8_t pch_numb = (Location.param.PCHdig1 - 1)*3 + (Location.param.PCHdig2 - 1);
- if(action.connectROM != NULL)
+ switch(pch_numb)
{
- result = PCHSens_InitNewSensor(hdallas, sensor, action.connectROM);
- action.connectROM = 0;
+ case 0:
+ module = &pchsens->module1; break;
+ case 1:
+ module = &pchsens->module2; break;
+ case 2:
+ module = &pchsens->module3; break;
+ case 3:
+ module = &pchsens->module4; break;
+ case 4:
+ module = &pchsens->module5; break;
+ case 5:
+ module = &pchsens->module6; break;
+ default:
+ return HAL_ERROR;
}
- if(action.read != NULL)
+ switch(Location.param.Location)
{
- result = PCHSens_ReadTemperature(sensor);
- if(result != HAL_OK)
- PCHSens_CheckSensor(hdallas, sensor);
+ case 0:
+ *sensor = &module->sens1; break;
+ case 1:
+ *sensor = &module->sens2; break;
+ case 2:
+ *sensor = &module->sens3; break;
+ case 3:
+ *sensor = &module->sens4; break;
}
- if(action.deinit != NULL)
- {
- action.deinit = 0;
- result = PCHSens_UndefineSensor(sensor);
- }
-
- return result;
+ return HAL_OK;
}
-
-void PCHSens_FirstInit(void)
-{
- int init_find = 0;
- OW.DataPin = DS_Pin;
- OW.DataPort = DS_GPIO_Port;
- DS.Resolution = DS18B20_RESOLUTION_9BITS;
-
- OneWire_Init(&OW);
- DS18B20_Search(&DS, &OW);
-
- DallasBus.hdallas = &hdallas1;
- DallasBus.hdallas->onewire = &OW;
-
-
-
- PCHSens_InitModule(&hdallas1, &module1, REG_PCH_NUMB_11|REG_PCH_DIODE_NUMB_1);
- PCHSens_InitModule(&hdallas1, &module2, REG_PCH_NUMB_12|REG_PCH_DIODE_NUMB_1);
- PCHSens_InitModule(&hdallas1, &module3, REG_PCH_NUMB_13|REG_PCH_DIODE_NUMB_1);
- PCHSens_InitModule(&hdallas1, &module4, REG_PCH_NUMB_21|REG_PCH_DIODE_NUMB_1);
- PCHSens_InitModule(&hdallas1, &module5, REG_PCH_NUMB_22|REG_PCH_DIODE_NUMB_1);
- PCHSens_InitModule(&hdallas1, &module6, REG_PCH_NUMB_23|REG_PCH_DIODE_NUMB_1);
-
- PCHSens_FindUnknownSensors(&DallasBus);
-}
-
-
-void PCHSens_StoreToModbus(PCHSens_SensorTypeDef *sensor)
-{
- uint8_t pch_numb = (sensor->Location.param.PCHdig1 - 1)*3 + (sensor->Location.param.PCHdig2 - 1);
- uint8_t location = (sensor->Location.param.Location);
-
- uint8_t mb_location = pch_numb*4 + location;
-
- if (mb_location < DS18B20_DEVICE_AMOUNT)
- MB_DATA.InRegs.SensTemperature[mb_location] = sensor->sens.temperature*100;
-}
-
-
-
diff --git a/Core/Dallas/pch_sensors.h b/Core/PY32Module/pch_sensors.h
similarity index 92%
rename from Core/Dallas/pch_sensors.h
rename to Core/PY32Module/pch_sensors.h
index 419c9d5..c9bc7d2 100644
--- a/Core/Dallas/pch_sensors.h
+++ b/Core/PY32Module/pch_sensors.h
@@ -120,10 +120,12 @@ typedef union
typedef struct
{
+ unsigned convertion;
uint64_t connectROM;
unsigned read;
unsigned deinit;
}PCHSens_SensorActionsTypeDef;
+extern PCHSens_SensorActionsTypeDef action;
typedef struct
{
@@ -144,12 +146,6 @@ typedef struct
PCHSens_LocationTypeDef refLocation;
}PCHSens_ModuleTypeDef;
-extern PCHSens_ModuleTypeDef module1;
-extern PCHSens_ModuleTypeDef module2;
-extern PCHSens_ModuleTypeDef module3;
-extern PCHSens_ModuleTypeDef module4;
-extern PCHSens_ModuleTypeDef module5;
-extern PCHSens_ModuleTypeDef module6;
typedef struct
{
@@ -159,17 +155,26 @@ typedef struct
extern PCHSens_DallasBusHandle DallasBus;
+typedef struct
+{
+ PCHSens_ModuleTypeDef module1;
+ PCHSens_ModuleTypeDef module2;
+ PCHSens_ModuleTypeDef module3;
+ PCHSens_ModuleTypeDef module4;
+ PCHSens_ModuleTypeDef module5;
+ PCHSens_ModuleTypeDef module6;
+}PCHSens_TypeDef;
+
/* Functions ---------------------------------------------------------------*/
HAL_StatusTypeDef PCHSens_InitNewSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef* sensor, uint64_t ROM);
HAL_StatusTypeDef PCHSens_AddSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef* sensor);
HAL_StatusTypeDef PCHSens_InitModule(DALLAS_HandleTypeDef *hdallas, PCHSens_ModuleTypeDef* module, uint16_t param);
-HAL_StatusTypeDef PCHSens_ModuleHandleAction(PCHSens_ModuleTypeDef* module);
+HAL_StatusTypeDef PCHSens_ModuleReadTemperature(PCHSens_ModuleTypeDef* module);
+HAL_StatusTypeDef PCHSens_SensorReadTemperature(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef *sensor);
HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_SensorTypeDef* sensor);
-HAL_StatusTypeDef PCHSens_Covert(PCHSens_DallasBusHandle *hbus);
+HAL_StatusTypeDef PCHSens_StartCovert(PCHSens_DallasBusHandle *hbus);
HAL_StatusTypeDef PCHSens_CheckSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef* sensor);
HAL_StatusTypeDef PCHSens_FindUnknownSensors(PCHSens_DallasBusHandle *hbus);
-HAL_StatusTypeDef PCHSens_DefineUnknownSensor(PCHSens_DallasBusHandle *hbus, PCHSens_SensorTypeDef *sensor);
-HAL_StatusTypeDef PCHSens_SensorHandleActions(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef *sensor);
-void PCHSens_FirstInit(void);
-void PCHSens_StoreToModbus(PCHSens_SensorTypeDef *sensor);
+HAL_StatusTypeDef PCHSens_UndefineSensor(PCHSens_SensorTypeDef *sensor);
+HAL_StatusTypeDef PCHSens_GetSensorByLocation(PCHSens_TypeDef *pchsens, PCHSens_LocationTypeDef Location, PCHSens_SensorTypeDef **sensor);
#endif // #ifndef PCH_SENSORS_H
\ No newline at end of file
diff --git a/Core/Src/iwdg.c b/Core/Src/iwdg.c
index d0ed87f..a25b988 100644
--- a/Core/Src/iwdg.c
+++ b/Core/Src/iwdg.c
@@ -39,7 +39,7 @@ void MX_IWDG_Init(void)
/* USER CODE END IWDG_Init 1 */
hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_32;
- hiwdg.Init.Reload = 100;
+ hiwdg.Init.Reload = 1000;
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
{
Error_Handler();
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 6608625..10edc9e 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -26,8 +26,7 @@
#include "tim.h"
#include "usart.h"
#include "iwdg.h"
-#include "pch_sensors.h"
-#include "rs_message.h"
+#include "PY32module_main.h"
/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
@@ -42,6 +41,7 @@ static void APP_SystemClockConfig(void);
*/
int main(void)
{
+ __HAL_DBGMCU_FREEZE_IWDG();
__HAL_DBGMCU_FREEZE_TIM1();
__HAL_DBGMCU_FREEZE_TIM14();
/* Reset of all peripherals, Initializes the Systick. */
@@ -50,32 +50,19 @@ int main(void)
/* System clock configuration */
APP_SystemClockConfig();
- MX_IWDG_Init();
+// MX_IWDG_Init();
MX_GPIO_Init();
MX_TIM1_Init();
MX_TIM14_Init();
MX_USART1_UART_Init();
- MODBUS_FirstInit();
- RS_Receive_IT(&hmodbus1, &MODBUS_MSG);
- PCHSens_FirstInit();
+ PYModule_FirstInit();
/* infinite loop */
while (1)
{
- GPIOA->ODR ^= GPIO_LED_2;
-
-
- PCHSens_Covert(&DallasBus);
-
- PCHSens_ModuleHandleAction(&module1);
- PCHSens_ModuleHandleAction(&module2);
- PCHSens_ModuleHandleAction(&module3);
- PCHSens_ModuleHandleAction(&module4);
- PCHSens_ModuleHandleAction(&module5);
- PCHSens_ModuleHandleAction(&module6);
-
+ PYModule_main();
}
}
diff --git a/MDK-ARM/PY32Dallas.uvoptx b/MDK-ARM/PY32Dallas.uvoptx
index b5806ef..40c61dc 100644
--- a/MDK-ARM/PY32Dallas.uvoptx
+++ b/MDK-ARM/PY32Dallas.uvoptx
@@ -163,7 +163,7 @@
1
1
- module1,0x10
+ pchsens,0x10
2
@@ -230,6 +230,16 @@
1
RS_Buffer,0x10
+
+ 15
+ 1
+ mb_location
+
+
+ 16
+ 1
+ DS
+
@@ -250,7 +260,7 @@
3
2
- MB_DATA,0x0A
+ MB_DATA,0x10
4
@@ -389,7 +399,7 @@
- Application/User
+ PY32Module
1
0
0
@@ -401,20 +411,20 @@
0
0
0
- ..\Core\Src\main.c
- main.c
+ ..\Core\PY32Module\PY32module_main.c
+ PY32module_main.c
0
0
2
7
- 1
+ 5
0
0
0
- ..\Core\Src\gpio.c
- gpio.c
+ ..\Core\PY32Module\PY32module_main.h
+ PY32module_main.h
0
0
@@ -425,196 +435,20 @@
0
0
0
- ..\Core\Src\tim.c
- tim.c
+ ..\Core\PY32Module\pch_sensors.c
+ pch_sensors.c
0
0
2
9
- 1
+ 5
0
0
0
- ..\Core\Src\usart.c
- usart.c
- 0
- 0
-
-
- 2
- 10
- 1
- 0
- 0
- 0
- ..\Core\Src\iwdg.c
- iwdg.c
- 0
- 0
-
-
- 2
- 11
- 1
- 0
- 0
- 0
- ..\Core\Src\py32f002b_it.c
- py32f002b_it.c
- 0
- 0
-
-
- 2
- 12
- 1
- 0
- 0
- 0
- ..\Core\Src\py32f002b_hal_msp.c
- py32f002b_hal_msp.c
- 0
- 0
-
-
-
-
- Drivers/PY32F002B_HAL_Driver
- 1
- 0
- 0
- 0
-
- 3
- 13
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal.c
- py32f002b_hal.c
- 0
- 0
-
-
- 3
- 14
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_rcc.c
- py32f002b_hal_rcc.c
- 0
- 0
-
-
- 3
- 15
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_rcc_ex.c
- py32f002b_hal_rcc_ex.c
- 0
- 0
-
-
- 3
- 16
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_cortex.c
- py32f002b_hal_cortex.c
- 0
- 0
-
-
- 3
- 17
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_gpio.c
- py32f002b_hal_gpio.c
- 0
- 0
-
-
- 3
- 18
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_pwr.c
- py32f002b_hal_pwr.c
- 0
- 0
-
-
- 3
- 19
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_usart.c
- py32f002b_hal_usart.c
- 0
- 0
-
-
- 3
- 20
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_tim.c
- py32f002b_hal_tim.c
- 0
- 0
-
-
- 3
- 21
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_tim_ex.c
- py32f002b_hal_tim_ex.c
- 0
- 0
-
-
- 3
- 22
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_uart.c
- py32f002b_hal_uart.c
- 0
- 0
-
-
- 3
- 23
- 1
- 0
- 0
- 0
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_iwdg.c
- py32f002b_hal_iwdg.c
+ ..\Core\PY32Module\pch_sensors.h
+ pch_sensors.h
0
0
@@ -627,32 +461,8 @@
0
0
- 4
- 24
- 1
- 0
- 0
- 0
- ..\Core\Dallas\pch_sensors.c
- pch_sensors.c
- 0
- 0
-
-
- 4
- 25
- 5
- 0
- 0
- 0
- ..\Core\Dallas\pch_sensors.h
- pch_sensors.h
- 0
- 0
-
-
- 4
- 26
+ 3
+ 10
1
0
0
@@ -663,8 +473,8 @@
0
- 4
- 27
+ 3
+ 11
5
0
0
@@ -675,8 +485,8 @@
0
- 4
- 28
+ 3
+ 12
1
0
0
@@ -687,8 +497,8 @@
0
- 4
- 29
+ 3
+ 13
5
0
0
@@ -699,8 +509,8 @@
0
- 4
- 30
+ 3
+ 14
1
0
0
@@ -711,8 +521,8 @@
0
- 4
- 31
+ 3
+ 15
5
0
0
@@ -723,8 +533,8 @@
0
- 4
- 32
+ 3
+ 16
1
0
0
@@ -735,8 +545,8 @@
0
- 4
- 33
+ 3
+ 17
5
0
0
@@ -755,8 +565,8 @@
0
0
- 5
- 34
+ 4
+ 18
1
0
0
@@ -767,8 +577,8 @@
0
- 5
- 35
+ 4
+ 19
5
0
0
@@ -779,8 +589,8 @@
0
- 5
- 36
+ 4
+ 20
1
0
0
@@ -791,8 +601,8 @@
0
- 5
- 37
+ 4
+ 21
5
0
0
@@ -803,8 +613,8 @@
0
- 5
- 38
+ 4
+ 22
1
0
0
@@ -815,8 +625,8 @@
0
- 5
- 39
+ 4
+ 23
5
0
0
@@ -828,6 +638,98 @@
+
+ Application/User
+ 1
+ 0
+ 0
+ 0
+
+ 5
+ 24
+ 1
+ 0
+ 0
+ 0
+ ..\Core\Src\main.c
+ main.c
+ 0
+ 0
+
+
+ 5
+ 25
+ 1
+ 0
+ 0
+ 0
+ ..\Core\Src\gpio.c
+ gpio.c
+ 0
+ 0
+
+
+ 5
+ 26
+ 1
+ 0
+ 0
+ 0
+ ..\Core\Src\tim.c
+ tim.c
+ 0
+ 0
+
+
+ 5
+ 27
+ 1
+ 0
+ 0
+ 0
+ ..\Core\Src\usart.c
+ usart.c
+ 0
+ 0
+
+
+ 5
+ 28
+ 1
+ 0
+ 0
+ 0
+ ..\Core\Src\iwdg.c
+ iwdg.c
+ 0
+ 0
+
+
+ 5
+ 29
+ 1
+ 0
+ 0
+ 0
+ ..\Core\Src\py32f002b_it.c
+ py32f002b_it.c
+ 0
+ 0
+
+
+ 5
+ 30
+ 1
+ 0
+ 0
+ 0
+ ..\Core\Src\py32f002b_hal_msp.c
+ py32f002b_hal_msp.c
+ 0
+ 0
+
+
+
MyLibs
1
@@ -836,7 +738,7 @@
0
6
- 40
+ 31
5
0
0
@@ -848,7 +750,7 @@
6
- 41
+ 32
1
0
0
@@ -860,7 +762,7 @@
6
- 42
+ 33
5
0
0
@@ -872,7 +774,7 @@
6
- 43
+ 34
5
0
0
@@ -884,7 +786,7 @@
6
- 44
+ 35
5
0
0
@@ -896,7 +798,7 @@
6
- 45
+ 36
5
0
0
@@ -908,7 +810,7 @@
6
- 46
+ 37
5
0
0
@@ -920,7 +822,7 @@
6
- 47
+ 38
5
0
0
@@ -932,6 +834,146 @@
+
+ Drivers/PY32F002B_HAL_Driver
+ 0
+ 0
+ 0
+ 0
+
+ 7
+ 39
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal.c
+ py32f002b_hal.c
+ 0
+ 0
+
+
+ 7
+ 40
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_rcc.c
+ py32f002b_hal_rcc.c
+ 0
+ 0
+
+
+ 7
+ 41
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_rcc_ex.c
+ py32f002b_hal_rcc_ex.c
+ 0
+ 0
+
+
+ 7
+ 42
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_cortex.c
+ py32f002b_hal_cortex.c
+ 0
+ 0
+
+
+ 7
+ 43
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_gpio.c
+ py32f002b_hal_gpio.c
+ 0
+ 0
+
+
+ 7
+ 44
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_pwr.c
+ py32f002b_hal_pwr.c
+ 0
+ 0
+
+
+ 7
+ 45
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_usart.c
+ py32f002b_hal_usart.c
+ 0
+ 0
+
+
+ 7
+ 46
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_tim.c
+ py32f002b_hal_tim.c
+ 0
+ 0
+
+
+ 7
+ 47
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_tim_ex.c
+ py32f002b_hal_tim_ex.c
+ 0
+ 0
+
+
+ 7
+ 48
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_uart.c
+ py32f002b_hal_uart.c
+ 0
+ 0
+
+
+ 7
+ 49
+ 1
+ 0
+ 0
+ 0
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_iwdg.c
+ py32f002b_hal_iwdg.c
+ 0
+ 0
+
+
+
::CMSIS
0
diff --git a/MDK-ARM/PY32Dallas.uvprojx b/MDK-ARM/PY32Dallas.uvprojx
index 2e4fa08..a1cf606 100644
--- a/MDK-ARM/PY32Dallas.uvprojx
+++ b/MDK-ARM/PY32Dallas.uvprojx
@@ -341,7 +341,7 @@
USE_HAL_DRIVER,PY32F002Bx5
- ..\Core\Inc;..\Drivers\CMSIS\Include;..\Drivers\CMSIS\Device\PY32F0xx\Include;..\Drivers\PY32F002B_HAL_Driver\Inc;..\Core\Dallas;..\Core\Modbus;..\Core\MyLibs
+ ..\Core\Inc;..\Drivers\CMSIS\Include;..\Drivers\CMSIS\Device\PY32F0xx\Include;..\Drivers\PY32F002B_HAL_Driver\Inc;..\Core\Dallas;..\Core\Modbus;..\Core\MyLibs;..\Core\PY32Module
@@ -413,118 +413,33 @@
- Application/User
+ PY32Module
- main.c
+ PY32module_main.c
1
- ..\Core\Src\main.c
+ ..\Core\PY32Module\PY32module_main.c
- gpio.c
- 1
- ..\Core\Src\gpio.c
+ PY32module_main.h
+ 5
+ ..\Core\PY32Module\PY32module_main.h
- tim.c
+ pch_sensors.c
1
- ..\Core\Src\tim.c
+ ..\Core\PY32Module\pch_sensors.c
- usart.c
- 1
- ..\Core\Src\usart.c
-
-
- iwdg.c
- 1
- ..\Core\Src\iwdg.c
-
-
- py32f002b_it.c
- 1
- ..\Core\Src\py32f002b_it.c
-
-
- py32f002b_hal_msp.c
- 1
- ..\Core\Src\py32f002b_hal_msp.c
-
-
-
-
- Drivers/PY32F002B_HAL_Driver
-
-
- py32f002b_hal.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal.c
-
-
- py32f002b_hal_rcc.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_rcc.c
-
-
- py32f002b_hal_rcc_ex.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_rcc_ex.c
-
-
- py32f002b_hal_cortex.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_cortex.c
-
-
- py32f002b_hal_gpio.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_gpio.c
-
-
- py32f002b_hal_pwr.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_pwr.c
-
-
- py32f002b_hal_usart.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_usart.c
-
-
- py32f002b_hal_tim.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_tim.c
-
-
- py32f002b_hal_tim_ex.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_tim_ex.c
-
-
- py32f002b_hal_uart.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_uart.c
-
-
- py32f002b_hal_iwdg.c
- 1
- ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_iwdg.c
+ pch_sensors.h
+ 5
+ ..\Core\PY32Module\pch_sensors.h
Dallas
-
- pch_sensors.c
- 1
- ..\Core\Dallas\pch_sensors.c
-
-
- pch_sensors.h
- 5
- ..\Core\Dallas\pch_sensors.h
-
dallas_tools.c
1
@@ -602,6 +517,46 @@
+
+ Application/User
+
+
+ main.c
+ 1
+ ..\Core\Src\main.c
+
+
+ gpio.c
+ 1
+ ..\Core\Src\gpio.c
+
+
+ tim.c
+ 1
+ ..\Core\Src\tim.c
+
+
+ usart.c
+ 1
+ ..\Core\Src\usart.c
+
+
+ iwdg.c
+ 1
+ ..\Core\Src\iwdg.c
+
+
+ py32f002b_it.c
+ 1
+ ..\Core\Src\py32f002b_it.c
+
+
+ py32f002b_hal_msp.c
+ 1
+ ..\Core\Src\py32f002b_hal_msp.c
+
+
+
MyLibs
@@ -647,6 +602,66 @@
+
+ Drivers/PY32F002B_HAL_Driver
+
+
+ py32f002b_hal.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal.c
+
+
+ py32f002b_hal_rcc.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_rcc.c
+
+
+ py32f002b_hal_rcc_ex.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_rcc_ex.c
+
+
+ py32f002b_hal_cortex.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_cortex.c
+
+
+ py32f002b_hal_gpio.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_gpio.c
+
+
+ py32f002b_hal_pwr.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_pwr.c
+
+
+ py32f002b_hal_usart.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_usart.c
+
+
+ py32f002b_hal_tim.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_tim.c
+
+
+ py32f002b_hal_tim_ex.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_tim_ex.c
+
+
+ py32f002b_hal_uart.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_uart.c
+
+
+ py32f002b_hal_iwdg.c
+ 1
+ ..\Drivers\PY32F002B_HAL_Driver\Src\py32f002b_hal_iwdg.c
+
+
+
::CMSIS
@@ -667,4 +682,13 @@
+
+
+
+ PY32Dallas
+ 1
+
+
+
+