/** ****************************************************************************** * @file onewire.h * @brief This file contains all the constants parameters for the OneWire ****************************************************************************** * @attention * Usage: * Uncomment LL Driver for HAL driver * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef ONEWIRE_IT_DRIVER_H #define ONEWIRE_IT_DRIVER_H /* Includes ------------------------------------------------------------------*/ #include "stm32f1xx.h" #include "onewire.h" #define ONE_WIRE_TIMER_PERIOD_US 1 // Период таймера в микросекундах (1 мкс) #define OP_QUEUE_SIZE 10 // Буфер операций OneWire typedef enum { OW_RESET, OW_READ_BIT, OW_SET_BIT, OW_RESET_BIT, OW_IDLE } OneWire_State; typedef struct { OneWire_t *onewire; uint8_t *data; // Буфер для данных (для записи и чтения) uint8_t data_len; // Длина данных uint8_t current_byte_idx; // Индекс текущего байта для записи/чтения uint8_t current_bit_idx; // Индекс текущего бита для записи/чтения uint8_t head; // Индекс первой операции в очереди uint8_t tail; // Индекс последней операции в очереди uint8_t op_done; // Индекс последней операции в очереди void (*operation_queue[OP_QUEUE_SIZE])(OneWire_t*); // Очередь операций }OneWire_ITHandleTypeDef; extern OneWire_ITHandleTypeDef honewire; void OneWireTIMHandler(TIM_HandleTypeDef *htim, OneWire_ITHandleTypeDef *OW); void OneWireIT_Init(OneWire_ITHandleTypeDef *OW_IT); HAL_StatusTypeDef OneWire_ReadBit_ITHandle(OneWire_t *OW, uint8_t *bit); HAL_StatusTypeDef OneWire_WriteBit_ITHandle(OneWire_t *OW, uint8_t bit); HAL_StatusTypeDef OneWire_Reset_ITHandle(OneWire_t *OW); #endif /* ONEWIRE_IT_DRIVER_H */