From 458d2d77c93af8f4282f55210929f0d56f4f44b5 Mon Sep 17 00:00:00 2001 From: Razvalyaev Date: Wed, 5 Mar 2025 12:22:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=B4=D0=B8=D0=B0=D0=BF=D0=B0=D0=B7=D0=BE?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B0=D0=B4=D1=80=D0=B5=D1=81=D0=BE=D0=B2=20?= =?UTF-8?q?=D1=83=20=D0=BA=D0=BE=D0=B8=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit сделано обращение по указателям в паре мест убрана громоздская конструкция из OneWire_Pin_Mode --- .gitignore | 1 + Core/Dallas/dallas_tools.c | 2 +- Core/Dallas/ow_port.c | 25 ++++--------------------- Core/Modbus/modbus_data.h | 2 +- Core/PY32Module/pch_sensors.c | 2 +- 5 files changed, 8 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 2413f4f..0ba4c12 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,4 @@ JLinkLog.txt /MDK-ARM/DebugConfig/ /MDK-ARM/Output/ +/~$ds18b20_locations.xlsx diff --git a/Core/Dallas/dallas_tools.c b/Core/Dallas/dallas_tools.c index a791dff..82f385d 100644 --- a/Core/Dallas/dallas_tools.c +++ b/Core/Dallas/dallas_tools.c @@ -38,7 +38,7 @@ HAL_StatusTypeDef Dallas_ReplaceLostedSensor(DALLAS_SensorHandleTypeDef *sensor) if(sensor->isLost) { - if(DS18B20_Search(&DS, &OW) != HAL_OK) + if(DS18B20_Search(sensor->hdallas->ds_devices, sensor->hdallas->onewire) != HAL_OK) return HAL_ERROR; if(sensor->Init.init_func(sensor->hdallas, sensor) != HAL_OK) diff --git a/Core/Dallas/ow_port.c b/Core/Dallas/ow_port.c index a40139b..89cfecc 100644 --- a/Core/Dallas/ow_port.c +++ b/Core/Dallas/ow_port.c @@ -16,30 +16,13 @@ void OneWire_Pin_Mode(OneWire_t* OW, PinMode Mode) { #ifdef CMSIS_Driver - static uint32_t pin_cr_numb = 0; - static int get_pin_numb = 1; - - if(get_pin_numb) - { - get_pin_numb = 0; - for(int i = 0; i < 8; i++) - { - if((OW->DataPin >> i) == 0x1) - pin_cr_numb = i*4; - } - for(int i = 8; i < 16; i++) - { - if((OW->DataPin >> i) == 0x1) - pin_cr_numb = (i-8)*4; - } - } if(Mode == Input) { - OW->DataPort->MODER &= ~((GPIO_MODER_MODE0_Msk) << pin_cr_numb); - OW->DataPort->MODER |= (GPIO_MODE_INPUT << (pin_cr_numb+2)); + OW->DataPort->MODER &= ~((GPIO_MODER_MODE0_Msk) << 0); + OW->DataPort->MODER |= (GPIO_MODE_INPUT << (0+2)); }else{ - OW->DataPort->MODER &= ~((GPIO_MODER_MODE0_Msk) << pin_cr_numb); - OW->DataPort->MODER |= (GPIO_MODE_OUTPUT_PP << pin_cr_numb); + OW->DataPort->MODER &= ~((GPIO_MODER_MODE0_Msk) << 0); + OW->DataPort->MODER |= (GPIO_MODE_OUTPUT_PP << 0); } #else #ifdef LL_Driver diff --git a/Core/Modbus/modbus_data.h b/Core/Modbus/modbus_data.h index 2168fbd..588cbab 100644 --- a/Core/Modbus/modbus_data.h +++ b/Core/Modbus/modbus_data.h @@ -123,7 +123,7 @@ typedef struct //MB_DataCoilsTypeDef // DEFINES FOR COIL ARRAYS #define C_CONTROL_ADDR 0 -#define C_CONTROL_QNT 3 +#define C_CONTROL_QNT 5 #define C_FLAGS_ADDR 16 #define C_FLAGS_QNT 2 diff --git a/Core/PY32Module/pch_sensors.c b/Core/PY32Module/pch_sensors.c index 5cdafe6..16fae4a 100644 --- a/Core/PY32Module/pch_sensors.c +++ b/Core/PY32Module/pch_sensors.c @@ -199,7 +199,7 @@ HAL_StatusTypeDef PCHSens_FindUnknownSensors(PCHSens_DallasBusHandle *hbus) for(int i = 0; i < hbus->hdallas->onewire->RomCnt; i++) { /* Проверка присутствует ли выбранный датчик на линии */ - result = DS18B20_ReadScratchpad(hbus->hdallas->onewire, (uint8_t *)&DS.DevAddr[i], (uint8_t *)&hbus->hdallas->scratchpad); + result = DS18B20_ReadScratchpad(hbus->hdallas->onewire, (uint8_t *)&hbus->hdallas->ds_devices->DevAddr[i], (uint8_t *)&hbus->hdallas->scratchpad); if(result != HAL_OK) __NOP();