сделана инициализация всей периферии для OW в Dallas_BusFirstInit

можно выбрать дефолтную периферию, передав в фукнию NULL, а можно и свою кастомную, типа

  Dallas_BusFirstInit(&hdallas, GPIOA, GPIO_PIN_2);

надо теперь расписать все в ридми
This commit is contained in:
2025-06-30 19:00:42 +03:00
parent fad8b2551a
commit 5cc733f4d2
4 changed files with 43 additions and 23 deletions

View File

@@ -102,16 +102,30 @@ HAL_StatusTypeDef Dallas_BusFirstInit(DALLAS_HandleTypeDef *hdallas, UART_Handle
return HAL_ERROR;
#ifndef UART_Driver
if(GPIOx == NULL)
return HAL_ERROR;
OW_TIM->CR1 |= TIM_CR1_CEN;
hdallas->onewire.DataPin = GPIO_Pin;
hdallas->onewire.DataPort = GPIOx;
if(GPIOx == NULL)
{
hdallas->onewire.DataPin = OW_Pin;
hdallas->onewire.DataPort = OW_GPIO_Port;
}
else
{
hdallas->onewire.DataPin = GPIO_Pin;
hdallas->onewire.DataPort = GPIOx;
}
for (uint32_t i = 0; i < 16; i++)
{
if (hdallas->onewire.DataPin & (1 << i))
{
hdallas->onewire.DataPinNumb = i;
break;
}
}
#else
if(huart == NULL)
return HAL_ERROR;
hdallas->onewire.huart = huart;
hdallas->onewire.huart = &OW_UART_Handle;
else
hdallas->onewire.huart = huart;
#endif
/* Инициализация onewire и поиск датчиков*/
OneWire_Init(&hdallas->onewire);