From 971817fa2d29078723fbb1ecdcb9a96bb3a501a2 Mon Sep 17 00:00:00 2001 From: Razvalyaev Date: Thu, 13 Feb 2025 13:40:33 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D1=83=D1=87=D0=B0=20=D0=B2=D1=81=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D1=8B=20=D1=81=20=D0=B4=D0=B0=D1=82=D1=87=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=D0=BC=D0=B8=20=D1=82=D0=B5=D0=BC=D0=BF=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=D1=82=D1=83=D1=80=D1=8B=20=D0=B2=20=D0=9F=D0=A7=20(=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BA=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Планируется сделать: - инициализацию (запись локации в ROM) найденных неизвестных датчиков - переинициализацию уже найденных датчиков --- DS18B20/dallas_tools.c | 7 +- DS18B20/pch_sensors.c | 169 ++++++++++++++++++++++------ DS18B20/pch_sensors.h | 99 +++++++++++----- test_project/Core/Src/main.c | 4 +- test_project/MDK-ARM/ds18b20.uvoptx | 37 +----- 5 files changed, 216 insertions(+), 100 deletions(-) diff --git a/DS18B20/dallas_tools.c b/DS18B20/dallas_tools.c index 86ef68a..8bd859d 100644 --- a/DS18B20/dallas_tools.c +++ b/DS18B20/dallas_tools.c @@ -45,7 +45,7 @@ HAL_StatusTypeDef Dallas_ReplaceLostedSensor(DALLAS_HandleTypeDef *sensor) } else { - return HAL_OK; + return HAL_BUSY; // } } @@ -201,6 +201,9 @@ HAL_StatusTypeDef Dallas_SensorInitByUserBytes(OneWire_t *onewire, DALLAS_Handle return result; } } + + memset(&sensor->sensROM, 0, DALLAS_ROM_SIZE); + memset(&sensor->scratchpad, 0, sizeof(DALLAS_ScratchpadTypeDef)); /* */ return HAL_ERROR; } @@ -499,7 +502,7 @@ HAL_StatusTypeDef Dallas_IsConnected(DALLAS_HandleTypeDef *sensor) } sensor->isConnected = 0; - Dallas_ReplaceLostedSensor(sensor); +// Dallas_ReplaceLostedSensor(sensor); return HAL_BUSY; // busy, HAL_ERROR } } diff --git a/DS18B20/pch_sensors.c b/DS18B20/pch_sensors.c index 6656c9e..7f80098 100644 --- a/DS18B20/pch_sensors.c +++ b/DS18B20/pch_sensors.c @@ -8,14 +8,47 @@ /* Includes ----------------------------------------------------------------*/ #include "pch_sensors.h" - +PCHSens_UnknownSensorsTypeDef UnknownSensors; /* Declarations and definitions --------------------------------------------*/ PCHSens_ModuleTypeDef module1; /* Functions ---------------------------------------------------------------*/ +HAL_StatusTypeDef PCHSens_FindUnknownSensors(OneWire_t *onewire, PCHSens_UnknownSensorsTypeDef *unknowns) +{ + HAL_StatusTypeDef result; + if(onewire == NULL) + return HAL_ERROR; + if(unknowns == NULL) + return HAL_ERROR; + + unknowns->onewire = onewire; + unknowns->UnknownCnt = 0; + DALLAS_ScratchpadTypeDef scratchpad; + + PCHSens_LocationTypeDef *location = (PCHSens_LocationTypeDef *)&scratchpad.tHighRegister; + for(int i = 0; i < onewire->RomCnt; i++) + { + /* */ + result = DS18B20_ReadScratchpad(onewire, (uint8_t *)&DS.DevAddr[i], (uint8_t *)&scratchpad); + if(result != HAL_OK) + __NOP(); + + if((IS_REG_PCH_LOCATION(location) == 0) || + (IS_REG_PCH_LOCATION(location) == 0) || + (IS_REG_PCH_NUMB(location) == 0) ) + { + unknowns->unknown_sensors[unknowns->UnknownCnt].Init.SensInd = i; + unknowns->unknown_sensors[unknowns->UnknownCnt].Init.init_func = &Dallas_SensorInitByInd; + result = Dallas_AddNewSensors(onewire, &unknowns->unknown_sensors[unknowns->UnknownCnt++]); + if(result != HAL_OK) + __NOP(); + } + } + return HAL_OK; +} -HAL_StatusTypeDef PCHSens_InitNewSensor(OneWire_t *onewire, PCH_SensorTypeDef* sensor, uint64_t ROM, PCHSens_LocationTypeDef *location) +HAL_StatusTypeDef PCHSens_InitNewSensor(OneWire_t *onewire, PCHSens_SensorTypeDef* sensor, uint64_t ROM, uint16_t location) { DALLAS_HandleTypeDef tempsens; HAL_StatusTypeDef result; @@ -25,59 +58,75 @@ HAL_StatusTypeDef PCHSens_InitNewSensor(OneWire_t *onewire, PCH_SensorTypeDef* s return HAL_ERROR; if(location == NULL) return HAL_ERROR; - - PCHSens_LocationTypeDef initlocation = *location; - + sensor->Location = (PCHSens_LocationTypeDef *)&sensor->sens.scratchpad.tHighRegister; sensor->sens.Init.ROM = ROM; - sensor->sens.Init.UserBytes12 = initlocation.all; + sensor->sens.Init.UserBytes12 = location; sensor->sens.Init.init_func = &Dallas_SensorInitByROM; result = Dallas_AddNewSensors(onewire, &sensor->sens); if(result != HAL_OK) + { + sensor->not_found = 1; return result; + } - result = Dallas_WriteUserBytes(&sensor->sens, initlocation.all, 0, DALLAS_USER_BYTE_12); + result = Dallas_WriteUserBytes(&sensor->sens, location, 0, DALLAS_USER_BYTE_12); if(result != HAL_OK) return result; - + sensor->sens.Init.init_func = &Dallas_SensorInitByUserBytes; - return Dallas_AddNewSensors(onewire, &sensor->sens); + result = Dallas_AddNewSensors(onewire, &sensor->sens); + if(result == HAL_OK) + sensor->not_found = 0; + else + sensor->not_found = 1; + + return result; } -HAL_StatusTypeDef PCHSens_FindSensor(OneWire_t *onewire, PCH_SensorTypeDef* sensor, PCHSens_LocationTypeDef *location) -{ + + +HAL_StatusTypeDef PCHSens_AddSensor(OneWire_t *onewire, PCHSens_SensorTypeDef* sensor, uint16_t location) +{ + HAL_StatusTypeDef result; if(onewire == NULL) return HAL_ERROR; if(sensor == NULL) return HAL_ERROR; if(location == NULL) return HAL_ERROR; - - PCHSens_LocationTypeDef initlocation = *location; - + sensor->Location = (PCHSens_LocationTypeDef *)&sensor->sens.scratchpad.tHighRegister; - sensor->sens.Init.UserBytes12 = initlocation.all; + sensor->sens.Init.UserBytes12 = location; sensor->sens.Init.init_func = &Dallas_SensorInitByUserBytes; - - return Dallas_AddNewSensors(onewire, &sensor->sens); + + result = Dallas_AddNewSensors(onewire, &sensor->sens); + + if(result == HAL_OK) + sensor->not_found = 0; + else + sensor->not_found = 1; + + return result; } -HAL_StatusTypeDef PCHSens_FindModule(OneWire_t *onewire, PCHSens_ModuleTypeDef* module, PCHSens_LocationTypeDef *location, uint8_t init) +HAL_StatusTypeDef PCHSens_InitModule(OneWire_t *onewire, PCHSens_ModuleTypeDef* module, uint16_t location, uint8_t init) { if(onewire == NULL) return HAL_ERROR; if(module == NULL) return HAL_ERROR; - PCHSens_LocationTypeDef initlocation = *location; + PCHSens_LocationTypeDef initlocation; + initlocation.all = location; module->onewire = onewire; module->refLocation = initlocation; @@ -85,54 +134,109 @@ HAL_StatusTypeDef PCHSens_FindModule(OneWire_t *onewire, PCHSens_ModuleTypeDef* if(init == 0) { initlocation.location.Location = 0; - PCHSens_FindSensor(onewire, &module->sens1, &initlocation); + PCHSens_AddSensor(onewire, &module->sens1, initlocation.all); initlocation.location.Location = 1; - PCHSens_FindSensor(onewire, &module->sens2, &initlocation); + PCHSens_AddSensor(onewire, &module->sens2, initlocation.all); initlocation.location.Location = 2; - PCHSens_FindSensor(onewire, &module->sens3, &initlocation); + PCHSens_AddSensor(onewire, &module->sens3, initlocation.all); initlocation.location.Location = 3; - PCHSens_FindSensor(onewire, &module->sens4, &initlocation); + PCHSens_AddSensor(onewire, &module->sens4, initlocation.all); } else { uint64_t ROM = 0x28366a48f6563c8d; initlocation.location.Location = 0; - PCHSens_InitNewSensor(onewire, &module->sens1, ROM, &initlocation); + PCHSens_InitNewSensor(onewire, &module->sens1, ROM, initlocation.all); ROM = 0x28CF5248F6BB3C2F; initlocation.location.Location = 1; - PCHSens_InitNewSensor(onewire, &module->sens2, ROM, &initlocation); + PCHSens_InitNewSensor(onewire, &module->sens2, ROM, initlocation.all); ROM = 0x28876D60060000CD; initlocation.location.Location = 2; - PCHSens_InitNewSensor(onewire, &module->sens3, ROM, &initlocation); + PCHSens_InitNewSensor(onewire, &module->sens3, ROM, initlocation.all); ROM = 0; initlocation.location.Location = 3; - PCHSens_InitNewSensor(onewire, &module->sens4, ROM, &initlocation); + PCHSens_InitNewSensor(onewire, &module->sens4, ROM, initlocation.all); } return HAL_OK; } -HAL_StatusTypeDef PCHSens_ReadModuleTemperature(PCHSens_ModuleTypeDef *module) +HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_ModuleTypeDef *module) { HAL_StatusTypeDef result; + if(module == NULL) + return HAL_ERROR; + result = Dallas_StartConvertTAll(module->onewire, DALLAS_WAIT_BUS, 0); result = Dallas_ReadTemperature(&module->sens1.sens); + if(result != HAL_OK) + PCHSens_CheckSensor(module->onewire, &module->sens1); + result = Dallas_ReadTemperature(&module->sens2.sens); + if(result != HAL_OK) + PCHSens_CheckSensor(module->onewire, &module->sens1); + result = Dallas_ReadTemperature(&module->sens3.sens); + if(result != HAL_OK) + PCHSens_CheckSensor(module->onewire, &module->sens1); + result = Dallas_ReadTemperature(&module->sens4.sens); + if(result != HAL_OK) + PCHSens_CheckSensor(module->onewire, &module->sens1); return result; } -void Dallas_FirstInit(void) + +HAL_StatusTypeDef PCHSens_CheckSensor(OneWire_t *onewire, PCHSens_SensorTypeDef* sensor) +{ + HAL_StatusTypeDef result; + PCHSens_LocationTypeDef initlocation; + unsigned unknow_sensors_flag = 0; + + if(sensor == NULL) + return HAL_ERROR; + if(sensor->sens.isInitialized == 0) + return HAL_ERROR; + + if((sensor->sens.isLost == 1)) + { + initlocation.location.Location = 0; + if(Dallas_ReplaceLostedSensor(&sensor->sens) != HAL_OK) + { + sensor->not_found = 1; + } + else + { + sensor->not_found = 0; + } + } + return HAL_OK; +} + + +HAL_StatusTypeDef PCHSens_DefineUnknownSensor(PCHSens_UnknownSensorsTypeDef *unknowns, PCHSens_SensorTypeDef *sensor) +{ + HAL_StatusTypeDef result; + if(unknowns->UnknownCnt == 0) + return HAL_OK; + + if((unknowns->ROMtoDefine != NULL) && (unknowns->LocationtoDefine.all != NULL)) + { + result = PCHSens_InitNewSensor(unknowns->onewire, sensor, unknowns->ROMtoDefine, unknowns->LocationtoDefine.all); + } + return HAL_OK; +} + +void PCHSens_FirstInit(void) { int init_find = 0; OW.DataPin = DS_Pin; @@ -142,12 +246,9 @@ void Dallas_FirstInit(void) OneWire_Init(&OW); DS18B20_Search(&DS, &OW); + PCHSens_InitModule(&OW, &module1, REG_PCH_NUMB_11|REG_PCH_DIODE_NUMB_1, init_find); - PCHSens_LocationTypeDef location; - location.all = REG_PCH_NUMB_11|REG_PCH_DIODE_NUMB_1; - PCHSens_FindModule(&OW, &module1, &location, init_find); - - + PCHSens_FindUnknownSensors(&OW, &UnknownSensors); // Dallas_SensorInitByInd(&OW, &AllSens.outdoor, 0); // Dallas_SensorInitByInd(&OW, &AllSens.indoor, 2); // Dallas_SensorInitByInd(&OW, &AllSens.bathroom, 1); diff --git a/DS18B20/pch_sensors.h b/DS18B20/pch_sensors.h index 55eda97..eb8ad8c 100644 --- a/DS18B20/pch_sensors.h +++ b/DS18B20/pch_sensors.h @@ -16,20 +16,20 @@ /* Declarations and definitions ---------------------------------------------*/ -/* ROM */ +/* UserBytes */ #define REG_SENS_LOCATION_Pos (0) /*!< @brief " " */ #define REG_PCH_LOCATION_Pos (8) /*!< @brief " " */ -#define REG_PCH_DIOD_PHASE_Pos (10) /*!< @brief " " */ -#define REG_PCH_MODULE_NUMB_Pos (8) /*!< @brief " / " */ +#define REG_PCH_DIOD_PHASE_Pos (10) /*!< @brief " " @ref REG_PCH_LOCATION_Pos */ +#define REG_PCH_MODULE_NUMB_Pos (8) /*!< @brief " / " @ref REG_PCH_LOCATION_Pos */ #define REG_PCH_NUMB_Pos (11) /*!< @brief " " */ -#define REG_PCH_NUMB_DIGIT_1_Pos (13) /*!< @brief " " */ -#define REG_PCH_NUMB_DIGIT_2_Pos (11) /*!< @brief " " */ +#define REG_PCH_NUMB_DIGIT_1_Pos (13) /*!< @brief " " @ref REG_PCH_NUMB_Pos */ +#define REG_PCH_NUMB_DIGIT_2_Pos (11) /*!< @brief " " @ref REG_PCH_NUMB_Pos */ #define REG_ZIP_Pos (15) /*!< @brief "/ " */ -/* ROM */ +/* UserBytes */ #define REG_SENS_LOCATION_Mask ((uint16_t)0x3 << REG_SENS_LOCATION_Pos) /*!< @brief " " */ #define REG_PCH_LOCATION_Mask ((uint16_t)0x7 << REG_PCH_LOCATION_Pos) /*!< @brief " " */ @@ -42,7 +42,7 @@ #define REG_ZIP_Mask ((uint16_t)0x1 << REG_ZIP_Pos) /*!< @brief "/ " */ -/* ROM */ +/* UserBytes */ #define REG_PCH_NUMB_11 ((1 << REG_PCH_NUMB_DIGIT_1_Pos) | (1 << REG_PCH_NUMB_DIGIT_2_Pos)) #define REG_PCH_NUMB_12 ((1 << REG_PCH_NUMB_DIGIT_1_Pos) | (2 << REG_PCH_NUMB_DIGIT_2_Pos)) #define REG_PCH_NUMB_13 ((1 << REG_PCH_NUMB_DIGIT_1_Pos) | (3 << REG_PCH_NUMB_DIGIT_2_Pos)) @@ -57,19 +57,50 @@ #define REG_PCH_PHASE_NUMB_2 ((1 << REG_PCH_DIOD_PHASE_Pos) | (2 << REG_PCH_MODULE_NUMB_Pos)) #define REG_PCH_PHASE_NUMB_3 ((1 << REG_PCH_DIOD_PHASE_Pos) | (3 << REG_PCH_MODULE_NUMB_Pos)) -/* ROM */ -#define GET_REG_SENS_LOCATION(_REG_) ((_REG_) & REG_SENS_LOCATION_Mask) /*!< @brief " " */ +/* UserBytes */ +#define GET_REG_SENS_LOCATION(_REG_) ((_REG_) & REG_SENS_LOCATION_Mask) /*!< @brief " " */ -#define GET_REG_PCH_LOCATION(_REG_) ((_REG_) & REG_PCH_LOCATION_Mask) /*!< @brief " " */ -#define GET_REG_PCH_DIOD_PHASE(_REG_) ((_REG_) & REG_PCH_DIOD_PHASE_Mask) /*!< @brief " " */ -#define GET_REG_PCH_MODULE_NUMB(_REG_) ((_REG_) & REG_PCH_MODULE_NUMB_Mask) /*!< @brief " / " */ +#define GET_REG_PCH_LOCATION(_REG_) ((_REG_) & REG_PCH_LOCATION_Mask) /*!< @brief " " */ +#define GET_REG_PCH_DIOD_PHASE(_REG_) ((_REG_) & REG_PCH_DIOD_PHASE_Mask) /*!< @brief " " */ +#define GET_REG_PCH_MODULE_NUMB(_REG_) ((_REG_) & REG_PCH_MODULE_NUMB_Mask) /*!< @brief " / " */ -#define GET_REG_PCH_NUMB(_REG_) ((_REG_) & REG_PCH_NUMB_Mask) /*!< @brief " " */ -#define GET_REG_PCH_NUMB_DIGIT_1(_REG_) ((_REG_) & REG_PCH_NUMB_DIGIT_1_Mask) /*!< @brief " " */ -#define GET_REG_PCH_NUMB_DIGIT_2(_REG_) ((_REG_) & REG_PCH_NUMB_DIGIT_2_Mask) /*!< @brief " " */ +#define GET_REG_PCH_NUMB(_REG_) ((_REG_) & REG_PCH_NUMB_Mask) /*!< @brief " " */ +#define GET_REG_PCH_NUMB_DIGIT_1(_REG_) ((_REG_) & REG_PCH_NUMB_DIGIT_1_Mask) /*!< @brief " " */ +#define GET_REG_PCH_NUMB_DIGIT_2(_REG_) ((_REG_) & REG_PCH_NUMB_DIGIT_2_Mask) /*!< @brief " " */ -#define GET_REG_ZIP(_REG_) ((_REG_) & REG_ZIP_Mask) /*!< @brief "/ " */ +#define GET_REG_ZIP(_REG_) ((_REG_) & REG_ZIP_Mask) /*!< @brief "/ " */ +/* UserBytes */ +#define REG_SENS_LOCATION_MAX 4 +#define REG_SENS_LOCATION_MIN 1 +#define REG_PCH_DIOD_PHASE_MAX 1 +#define REG_PCH_DIOD_PHASE_MIN 0 +#define REG_PCH_MODULE_NUMB_MAX 3 +#define REG_PCH_MODULE_NUMB_MIN 0 +#define REG_PCH_NUMB_DIGIT_1_MAX 3 +#define REG_PCH_NUMB_DIGIT_1_MIN 1 +#define REG_PCH_NUMB_DIGIT_2_MAX 2 +#define REG_PCH_NUMB_DIGIT_2_MIN 1 + + +/** @brief " " */ +#define IS_REG_SENS_LOCATION(_REG_) (((_REG_)->location.Location <= REG_SENS_LOCATION_MAX) && ((_REG_)->location.Location >= REG_SENS_LOCATION_MIN)) + +/*!< @brief " " */ +#define IS_REG_PCH_LOCATION(_REG_) (IS_REG_PCH_DIOD_PHASE(_REG_) && IS_REG_PCH_MODULE_NUMB(_REG_)) +/*!< @brief " " */ +#define IS_REG_PCH_DIOD_PHASE(_REG_) (((_REG_)->location.DiodeOrPhase <= REG_PCH_DIOD_PHASE_MAX) && ((_REG_)->location.DiodeOrPhase >= REG_PCH_DIOD_PHASE_MIN)) +/*!< @brief " / " */ +#define IS_REG_PCH_MODULE_NUMB(_REG_) (((_REG_)->location.ModuleNumb <= REG_PCH_MODULE_NUMB_MAX) && ((_REG_)->location.ModuleNumb >= REG_PCH_MODULE_NUMB_MIN)) + +/*!< @brief " " */ +#define IS_REG_PCH_NUMB(_REG_) (IS_REG_PCH_NUMB_DIGIT_1(_REG_) && IS_REG_PCH_NUMB_DIGIT_2(_REG_)) +/*!< @brief " " */ +#define IS_REG_PCH_NUMB_DIGIT_1(_REG_) (((_REG_)->location.PCHdig1 <= REG_PCH_NUMB_DIGIT_1_MAX) && ((_REG_)->location.PCHdig1 >= REG_PCH_NUMB_DIGIT_1_MIN)) +/*!< @brief " " s*/ +#define IS_REG_PCH_NUMB_DIGIT_2(_REG_) (((_REG_)->location.PCHdig2 <= REG_PCH_NUMB_DIGIT_2_MAX) && ((_REG_)->location.PCHdig2 >= REG_PCH_NUMB_DIGIT_2_MIN)) +/*!< @brief "/ " */ +#define IS_REG_ZIP(_REG_) (GET_REG_ZIP(_REG_)) typedef union { @@ -91,27 +122,41 @@ typedef struct { DALLAS_HandleTypeDef sens; PCHSens_LocationTypeDef *Location; -}PCH_SensorTypeDef; + unsigned not_found:1; +}PCHSens_SensorTypeDef; typedef struct { OneWire_t *onewire; - PCH_SensorTypeDef sens1; - PCH_SensorTypeDef sens2; - PCH_SensorTypeDef sens3; - PCH_SensorTypeDef sens4; + PCHSens_SensorTypeDef sens1; + PCHSens_SensorTypeDef sens2; + PCHSens_SensorTypeDef sens3; + PCHSens_SensorTypeDef sens4; + + PCHSens_LocationTypeDef refLocation; - PCHSens_LocationTypeDef refLocation; }PCHSens_ModuleTypeDef; extern PCHSens_ModuleTypeDef module1; +typedef struct +{ + OneWire_t *onewire; + + DALLAS_HandleTypeDef unknown_sensors[DS18B20_DEVICE_AMOUNT]; + uint8_t UnknownCnt; + uint64_t ROMtoDefine; + PCHSens_LocationTypeDef LocationtoDefine; +}PCHSens_UnknownSensorsTypeDef; + /* Functions ---------------------------------------------------------------*/ -HAL_StatusTypeDef PCHSens_InitNewSensor(OneWire_t *onewire, PCH_SensorTypeDef* sensor, uint64_t ROM, PCHSens_LocationTypeDef *location); -HAL_StatusTypeDef PCHSens_FindSensor(OneWire_t *onewire, PCH_SensorTypeDef* sensor, PCHSens_LocationTypeDef *location); -HAL_StatusTypeDef PCHSens_FindModule(OneWire_t *onewire, PCHSens_ModuleTypeDef* module, PCHSens_LocationTypeDef *location, uint8_t init); -HAL_StatusTypeDef PCHSens_ReadModuleTemperature(PCHSens_ModuleTypeDef *module); +HAL_StatusTypeDef PCHSens_FindUnknownSensors(OneWire_t *onewire, PCHSens_UnknownSensorsTypeDef *unknowns); +HAL_StatusTypeDef PCHSens_InitNewSensor(OneWire_t *onewire, PCHSens_SensorTypeDef* sensor, uint64_t ROM, uint16_t location); +HAL_StatusTypeDef PCHSens_AddSensor(OneWire_t *onewire, PCHSens_SensorTypeDef* sensor, uint16_t location); +HAL_StatusTypeDef PCHSens_InitModule(OneWire_t *onewire, PCHSens_ModuleTypeDef* module, uint16_t location, uint8_t init); +HAL_StatusTypeDef PCHSens_ReadTemperature(PCHSens_ModuleTypeDef *module); +HAL_StatusTypeDef PCHSens_CheckSensor(OneWire_t *onewire, PCHSens_SensorTypeDef* sensor); -void Dallas_FirstInit(void); +void PCHSens_FirstInit(void); #endif // #ifndef PCH_SENSORS_H \ No newline at end of file diff --git a/test_project/Core/Src/main.c b/test_project/Core/Src/main.c index 694b797..913b6ec 100644 --- a/test_project/Core/Src/main.c +++ b/test_project/Core/Src/main.c @@ -96,14 +96,14 @@ int main(void) DwtInit(); /* Set parameter and initialize DS18B20 */ /* Initialize OneWire and reset all data */ - Dallas_FirstInit(); + PCHSens_FirstInit(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { - PCHSens_ReadModuleTemperature(&module1); + PCHSens_ReadTemperature(&module1); // Dallas_ReadAll(); /* Start temperature conversion on all devices on one bus */ // DS18B20_StartConvTAll(&OW); diff --git a/test_project/MDK-ARM/ds18b20.uvoptx b/test_project/MDK-ARM/ds18b20.uvoptx index 66bd40e..a5bf29f 100644 --- a/test_project/MDK-ARM/ds18b20.uvoptx +++ b/test_project/MDK-ARM/ds18b20.uvoptx @@ -145,43 +145,10 @@ 0 ST-LINKIII-KEIL_SWO - -U53FF72064980555724221187 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL08000 -FP0($$Device:STM32F103C6$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 + -U53FF72064980555724221187 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL08000 -FP0($$Device:STM32F103C6$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 - - - 0 - 0 - 294 - 1 -
134220332
- 0 - 0 - 0 - 0 - 0 - 1 - ..\..\DS18B20\dallas_tools.c - - \\ds18b20\../../DS18B20/dallas_tools.c\294 -
- - 1 - 0 - 291 - 1 -
0
- 0 - 0 - 0 - 0 - 0 - 0 - ..\..\DS18B20\dallas_tools.c - - -
-
+ 0