Инициализация датчиков сделана по функции в структуре. По какому алгоритму надо найти датчик (ROM, UserBytes, порядковый номер) та функцию и пихается в структуру

Сделан поиск потерянных датчиков по функции в структуре (по тому же алгоритму, которому они были найдены)
This commit is contained in:
2025-02-06 18:47:20 +03:00
parent 9296faa0fb
commit 1de01f5665
4 changed files with 303 additions and 84 deletions

View File

@@ -85,21 +85,34 @@ typedef struct
}DALLAS_FlagsTypeDef;
typedef struct
{
uint64_t ROM;
uint16_t UserBytes12;
uint16_t UserBytes34;
uint8_t SensInd;
uint8_t Resolution;
HAL_StatusTypeDef (*init_func)();
}DALLAS_InitStructTypeDef;
typedef struct
{
uint8_t isConnected;
uint8_t isInitialized;
uint8_t isLost;
#ifdef ONEWIRE_UART_H
UART_HandleTypeDef *uart;
#else
OneWire_t *onewire;
#endif
uint8_t (*sensROM)[DALLAS_ROM_SIZE];
uint8_t sensROM[DALLAS_ROM_SIZE];
DALLAS_ScratchpadTypeDef scratchpad;
float temperature;
DALLAS_InitStructTypeDef Init;
DALLAS_FlagsTypeDef f;
}DALLAS_HandleTypeDef;
@@ -128,9 +141,13 @@ typedef enum
void Dallas_Init(DALLAS_HandleTypeDef *sensor, UART_HandleTypeDef *huart);
void Dallas_ReadAll(void);
void Dallas_FirstInit(void);
HAL_StatusTypeDef Dallas_SensorInitByROM(OneWire_t *onewire, DALLAS_HandleTypeDef *sensor, uint64_t intROM);
HAL_StatusTypeDef Dallas_SensorInitByUserBytes(OneWire_t *onewire, DALLAS_HandleTypeDef *sensor, uint16_t UserBytes12, uint16_t UserBytes34);
HAL_StatusTypeDef Dallas_SensorInitByInd(OneWire_t *onewire, DALLAS_HandleTypeDef *sensor, uint8_t sens_ind);
HAL_StatusTypeDef Dallas_ReplaceLostedSensor(DALLAS_HandleTypeDef *sensor);
HAL_StatusTypeDef Dallas_AddNewSensors(OneWire_t *onewire, DALLAS_HandleTypeDef *sensor);
HAL_StatusTypeDef Dallas_SensorInitByROM(OneWire_t *onewire, DALLAS_HandleTypeDef *sensor);
HAL_StatusTypeDef Dallas_SensorInitByUserBytes(OneWire_t *onewire, DALLAS_HandleTypeDef *sensor);
HAL_StatusTypeDef Dallas_SensorInitByInd(OneWire_t *onewire, DALLAS_HandleTypeDef *sensor);
HAL_StatusTypeDef Dallas_SensorInit(OneWire_t *onewire, DALLAS_HandleTypeDef *sensor, uint8_t (*ROM)[DALLAS_ROM_SIZE]);
HAL_StatusTypeDef Dallas_SensorDeInit(DALLAS_HandleTypeDef *sensor);
HAL_StatusTypeDef Dallas_StartConvertTAll(OneWire_t *onewire, DALLAS_WaitCondition waitCondition, uint8_t dallas_delay_ms);
HAL_StatusTypeDef Dallas_ConvertT(DALLAS_HandleTypeDef *sensor, DALLAS_WaitCondition waitCondition);
HAL_StatusTypeDef Dallas_ReadTemperature(DALLAS_HandleTypeDef *sensor);