Files
DS18B20_Library/DS18B20/onewire_uart.h
Razvalyaev fa32d653e8 добавлена реализация onewire через uart и переделана структуруа шины OneWire и инциализация
Теперь при выборе UART, в функцию Dallas_BusFirstInit передается hdallas, huart, ow, ds

А при выборе GPIO ножки: hdallas, gpiox, gpio_pin, ow, ds

но надо как-то структуруизировать дальше
2025-06-30 18:34:17 +03:00

57 lines
2.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
******************************************************************************
* @file : onewire_uart.h
* @brief : 1-Wire driver
* @author : MicroTechnics (microtechnics.ru)
*****************************************************************************/
#ifndef ONEWIRE_UART_H
#define ONEWIRE_UART_H
/* Includes ----------------------------------------------------------------*/
#include "stm32f1xx_hal.h"
/* Declarations and definitions --------------------------------------------*/
#define ONEWIRE_BAUDRATE 115200
#define ONEWIRE_RESET_BAUDRATE 9600
#define ONEWIRE_UART_TIMEOUT 10
/**
* @brief Комманды OneWire
* @details Определяет байты для uart, которые будут
* формировать необходимую длину импульса для разных комманд
*/
typedef enum
{
ONEWIRE_RESET = 0xF0, /*!< @brief Импульс длиной 520мкс для команды Reset (9600bod)
@details 1-Wire требует импульс длительностью >480мкс */
ONEWIRE_PULSE_SHORT = 0xFF, /*!< @brief Импульс длиной 8.7 мкс для записи "1"/чтения бита (115200bod)
@details 1-Wire требует импульс длительностью 1-15мкс */
ONEWIRE_PULSE_LONG = 0x00, /*!< @brief импульс длиной 78.3 мкс для записи "0" (115200bod)
@details 1-Wire требует импульс длительностью 60-120мкс */
// ONEWIRE_PULSE_1_15US = 0xFF,
// ONEWIRE_PULSE_60_120US = 0x00,
}ONEWIRE_Commands;
/* Functions ---------------------------------------------------------------*/
/* Выполняет 1-Wire Reset и проверяет наличие устройств на шине */
HAL_StatusTypeDef OneWireUART_Reset(UART_HandleTypeDef *huart);
/* Передает и принимает байт через 1-Wire */
uint8_t OneWireUART_ProcessByte(UART_HandleTypeDef *huart, uint8_t byte);
/* Передает и принимает один бит через 1-Wire */
uint8_t OneWireUART_ProcessBit(UART_HandleTypeDef *huart, uint8_t bit);
#endif // #ifndef ONEWIRE_UART_H