diff --git a/Core/Dallas/pch_sensors.c b/Core/Dallas/pch_sensors.c
index b3e3909..ac620ae 100644
--- a/Core/Dallas/pch_sensors.c
+++ b/Core/Dallas/pch_sensors.c
@@ -133,8 +133,6 @@ HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_ModuleTypeDef *module)
if(module == NULL)
return HAL_ERROR;
- result = Dallas_StartConvertTAll(module->hdallas, DALLAS_WAIT_BUS, 0);
-
result = PCHSens_SensorHandleActions(module->hdallas, &module->sens1);
result = PCHSens_SensorHandleActions(module->hdallas, &module->sens2);
result = PCHSens_SensorHandleActions(module->hdallas, &module->sens3);
@@ -143,7 +141,10 @@ HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_ModuleTypeDef *module)
return result;
}
-
+HAL_StatusTypeDef PCHSens_Covert(PCHSens_DallasBusHandle *hbus)
+{
+ return Dallas_StartConvertTAll(hbus->hdallas, DALLAS_WAIT_BUS, 0);
+}
HAL_StatusTypeDef PCHSens_CheckSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_SensorTypeDef* sensor)
{
HAL_StatusTypeDef result;
@@ -272,7 +273,8 @@ void PCHSens_FirstInit(void)
OneWire_Init(&OW);
DS18B20_Search(&DS, &OW);
- hdallas1.onewire = &OW;
+ DallasBus.hdallas = &hdallas1;
+ DallasBus.hdallas->onewire = &OW;
PCHSens_InitModule(&hdallas1, &module1, REG_PCH_NUMB_11|REG_PCH_DIODE_NUMB_1);
PCHSens_FindUnknownSensors(&DallasBus);
diff --git a/Core/Dallas/pch_sensors.h b/Core/Dallas/pch_sensors.h
index ab58707..e4e91af 100644
--- a/Core/Dallas/pch_sensors.h
+++ b/Core/Dallas/pch_sensors.h
@@ -164,6 +164,7 @@ HAL_StatusTypeDef PCHSens_InitNewSensor(DALLAS_HandleTypeDef *hdallas, PCHSens_S
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_ReadTemperature(PCHSens_ModuleTypeDef *module);
+HAL_StatusTypeDef PCHSens_Covert(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);
diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index f392556..79b3f49 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -31,7 +31,7 @@ extern "C" {
/* Includes ------------------------------------------------------------------*/
#include "py32f0xx_hal.h"
-
+#include "interface_config.h"
/* Private includes ----------------------------------------------------------*/
/* Private defines -----------------------------------------------------------*/
#define GPIO_LED_2 GPIO_PIN_1
diff --git a/Core/Modbus/interface_config.h b/Core/Modbus/interface_config.h
index 1e1c45a..456b4dd 100644
--- a/Core/Modbus/interface_config.h
+++ b/Core/Modbus/interface_config.h
@@ -21,23 +21,16 @@
#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/Andrey/Diod_Test"
-#define MODBUS_PRODUCT_NAME "Diode Tester"
-#define MODBUS_MODEL_NAME "STM32F103"
-#define MODBUS_USER_APPLICATION_NAME "diode_tester"
+#define MODBUS_VENDOR_URL "https://git.arktika.cyou/set506/DS18B20_Library/src/branch/py32f002b_dallas"
+#define MODBUS_PRODUCT_NAME "Dallas Driver"
+#define MODBUS_MODEL_NAME "PY32F002B"
+#define MODBUS_USER_APPLICATION_NAME "PY32Dallas"
-//#define MODBUS_UART_NUMB 1 ///< Номер используемого UART, по нему выставляется дефайн USED_MB_UART = USARTx
#define MODBUS_SPEED 115200 ///< Скорость UART для модбас
-//#define MODBUS_GPIOX GPIOA ///< Порт для UART RX/TX
-//#define MODBUS_GPIO_PIN_RX GPIO_PIN_9 ///< Пин для UART RX
-//#define MODBUS_GPIO_PIN_TX GPIO_PIN_10 ///< Пин для UART TX
-
-//#define MODBUS_TIM_NUMB 2 ///< number of used tim, accord to this define sets define USED_MB_TIM = TIMx
-//#define MODBUS_TIM_AHB_FREQ 72 ///< TIM AHB Bus Freq
-
// defines for modbus behaviour
#define MODBUS_DEVICE_ID 1 ///< девайс текущего устройства
-//#define MODBUS_MAX_TIMEOUT 500 ///< максимальнйы тайтаут MB is ms
+
+#define MODBUS_DATA_SIZE 27 ///< maximum number of data: DWORD (NOT MESSAGE SIZE)
#define RS_UART_Init MX_USART1_UART_Init
diff --git a/Core/Modbus/modbus.h b/Core/Modbus/modbus.h
index c0e0a93..ce2725d 100644
--- a/Core/Modbus/modbus.h
+++ b/Core/Modbus/modbus.h
@@ -37,7 +37,7 @@
#define Addr_SIZE 2 ///< size of (Addr)
#define Qnt_SIZE 2 ///< size of (Qnt)
#define ByteCnt_SIZE 1 ///< size of (ByteCnt)
-#define DATA_SIZE 27 ///< maximum number of data: DWORD (NOT MESSAGE SIZE)
+#define DATA_SIZE MODBUS_DATA_SIZE ///< maximum number of data: DWORD (NOT MESSAGE SIZE)
#define CRC_SIZE 2 ///< size of (MB_CRC) in bytes
/** @brief Size of whole message */
diff --git a/Core/Modbus/modbus_data.h b/Core/Modbus/modbus_data.h
index 9fcb038..22a07b2 100644
--- a/Core/Modbus/modbus_data.h
+++ b/Core/Modbus/modbus_data.h
@@ -13,8 +13,9 @@
#ifndef _MODBUS_DATA_H_
#define _MODBUS_DATA_H_
-
+
#include "stdint.h"
+#include "ds18b20_driver.h"
//--------------DEFINES FOR REGISTERS---------------
// DEFINES FOR ARRAYS
/**
@@ -37,8 +38,8 @@
*/
typedef struct //MB_DataInRegsTypeDef
{
- uint16_t ForwardVoltage;
- uint16_t ReversePeakVoltage;
+ uint16_t SensTemperature[DS18B20_DEVICE_AMOUNT];
+ uint16_t Resolution;
}MB_DataInRegsTypeDef;
diff --git a/Core/Src/main.c b/Core/Src/main.c
index ad5f059..d276089 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -58,17 +58,20 @@ int main(void)
RS_Receive_IT(&hmodbus1, &MODBUS_MSG);
-// PCHSens_FirstInit();
+ PCHSens_FirstInit();
/* infinite loop */
while (1)
{
GPIOA->ODR ^= GPIO_LED_2;
+
+ PCHSens_Covert(&DallasBus);
+
PCHSens_ReadTemperature(&module1);
- PCHSens_ReadTemperature(&module2);
- PCHSens_ReadTemperature(&module3);
- PCHSens_ReadTemperature(&module4);
- PCHSens_ReadTemperature(&module5);
- PCHSens_ReadTemperature(&module6);
+// PCHSens_ReadTemperature(&module2);
+// PCHSens_ReadTemperature(&module3);
+// PCHSens_ReadTemperature(&module4);
+// PCHSens_ReadTemperature(&module5);
+// PCHSens_ReadTemperature(&module6);
}
}
diff --git a/Core/Src/usart.c b/Core/Src/usart.c
index 66d3c09..d46ae86 100644
--- a/Core/Src/usart.c
+++ b/Core/Src/usart.c
@@ -19,7 +19,6 @@
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "usart.h"
-
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
@@ -39,7 +38,7 @@ void MX_USART1_UART_Init(void)
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
- huart1.Init.BaudRate = 115200;
+ huart1.Init.BaudRate = MODBUS_SPEED;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
diff --git a/MDK-ARM/PY32Dallas.uvoptx b/MDK-ARM/PY32Dallas.uvoptx
index b9837ff..78976fb 100644
--- a/MDK-ARM/PY32Dallas.uvoptx
+++ b/MDK-ARM/PY32Dallas.uvoptx
@@ -153,7 +153,40 @@
(105=-1,-1,-1,-1,0)
-
+
+
+ 0
+ 0
+ 67
+ 1
+ 134238266
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ ..\Core\Src\main.c
+
+ \\Project\../Core/Src/main.c\67
+
+
+ 1
+ 0
+ 66
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ ..\Core\Src\main.c
+
+
+
+
0
@@ -188,45 +221,40 @@
6
1
- \\Project\../Core/Dallas/pch_sensors.c\module1.sens1.action.connectROM
+ start,0x0A
7
1
- start,0x0A
+ end,0x0A
8
1
- end,0x0A
+ (uint16_t)htim1.Instance->CNT-start,0x0A
9
1
- (uint16_t)htim1.Instance->CNT-start,0x0A
+ end-start,0x0A
10
1
- end-start,0x0A
+ ((uint16_t)htim1.Instance->CNT-start <(end-start)),0x0A
11
1
- ((uint16_t)htim1.Instance->CNT-start <(end-start)),0x0A
+ ((uint16_t)htim1.Instance->CNT-start < us*tim_1us_period),0x0A
12
1
- ((uint16_t)htim1.Instance->CNT-start < us*tim_1us_period),0x0A
-
-
- 13
- 1
(uint16_t)htim1.Instance->CNT-start,0x0A
- 14
+ 13
1
hmodbus1
@@ -235,7 +263,7 @@
0
2
- UnknownSensors
+ DallasBus
1
@@ -296,6 +324,10 @@
+
+ System Viewer\TIM14
+ 35904
+
System Viewer\USART1
35905
@@ -348,6 +380,30 @@
0
0
0
+ ..\Core\Modbus\interface_config.h
+ interface_config.h
+ 0
+ 0
+
+
+ 1
+ 4
+ 5
+ 0
+ 0
+ 0
+ ..\Core\Modbus\modbus_data.h
+ modbus_data.h
+ 0
+ 0
+
+
+ 1
+ 5
+ 5
+ 0
+ 0
+ 0
..\Core\Inc\py32f002b_hal_conf.h
py32f002b_hal_conf.h
0
@@ -363,7 +419,7 @@
0
2
- 4
+ 6
1
0
0
@@ -375,7 +431,7 @@
2
- 5
+ 7
1
0
0
@@ -387,7 +443,7 @@
2
- 6
+ 8
1
0
0
@@ -399,7 +455,7 @@
2
- 7
+ 9
1
0
0
@@ -411,7 +467,7 @@
2
- 8
+ 10
1
0
0
@@ -423,7 +479,7 @@
2
- 9
+ 11
1
0
0
@@ -443,7 +499,7 @@
0
3
- 10
+ 12
1
0
0
@@ -455,7 +511,7 @@
3
- 11
+ 13
1
0
0
@@ -467,7 +523,7 @@
3
- 12
+ 14
1
0
0
@@ -479,7 +535,7 @@
3
- 13
+ 15
1
0
0
@@ -491,7 +547,7 @@
3
- 14
+ 16
1
0
0
@@ -503,7 +559,7 @@
3
- 15
+ 17
1
0
0
@@ -515,7 +571,7 @@
3
- 16
+ 18
1
0
0
@@ -527,7 +583,7 @@
3
- 17
+ 19
1
0
0
@@ -539,7 +595,7 @@
3
- 18
+ 20
1
0
0
@@ -551,7 +607,7 @@
3
- 19
+ 21
1
0
0
@@ -571,7 +627,7 @@
0
4
- 20
+ 22
1
0
0
@@ -583,7 +639,7 @@
4
- 21
+ 23
5
0
0
@@ -595,7 +651,7 @@
4
- 22
+ 24
1
0
0
@@ -607,7 +663,7 @@
4
- 23
+ 25
5
0
0
@@ -619,7 +675,7 @@
4
- 24
+ 26
1
0
0
@@ -631,7 +687,7 @@
4
- 25
+ 27
5
0
0
@@ -643,7 +699,7 @@
4
- 26
+ 28
1
0
0
@@ -655,7 +711,7 @@
4
- 27
+ 29
5
0
0
@@ -667,7 +723,7 @@
4
- 28
+ 30
1
0
0
@@ -679,7 +735,7 @@
4
- 29
+ 31
5
0
0
@@ -699,7 +755,7 @@
0
5
- 30
+ 32
1
0
0
@@ -711,7 +767,7 @@
5
- 31
+ 33
5
0
0
@@ -723,19 +779,7 @@
5
- 32
- 5
- 0
- 0
- 0
- ..\Core\Modbus\interface_config.h
- interface_config.h
- 0
- 0
-
-
- 5
- 33
+ 34
1
0
0
@@ -747,7 +791,7 @@
5
- 34
+ 35
5
0
0
@@ -757,18 +801,6 @@
0
0
-
- 5
- 35
- 5
- 0
- 0
- 0
- ..\Core\Modbus\modbus_data.h
- modbus_data.h
- 0
- 0
-
5
36
diff --git a/MDK-ARM/PY32Dallas.uvprojx b/MDK-ARM/PY32Dallas.uvprojx
index 8e69808..4444fad 100644
--- a/MDK-ARM/PY32Dallas.uvprojx
+++ b/MDK-ARM/PY32Dallas.uvprojx
@@ -395,6 +395,16 @@
1
..\Core\Src\system_py32f002b.c
+
+ interface_config.h
+ 5
+ ..\Core\Modbus\interface_config.h
+
+
+ modbus_data.h
+ 5
+ ..\Core\Modbus\modbus_data.h
+
py32f002b_hal_conf.h
5
@@ -560,11 +570,6 @@
5
..\Core\Modbus\crc_algs.h
-
- interface_config.h
- 5
- ..\Core\Modbus\interface_config.h
-
modbus.c
1
@@ -575,11 +580,6 @@
5
..\Core\Modbus\modbus.h
-
- modbus_data.h
- 5
- ..\Core\Modbus\modbus_data.h
-
rs_message.c
1