исправлены диапазоны адресов у коилов
сделано обращение по указателям в паре мест убрана громоздская конструкция из OneWire_Pin_Mode
This commit is contained in:
@@ -38,7 +38,7 @@ HAL_StatusTypeDef Dallas_ReplaceLostedSensor(DALLAS_SensorHandleTypeDef *sensor)
|
||||
|
||||
if(sensor->isLost)
|
||||
{
|
||||
if(DS18B20_Search(&DS, &OW) != HAL_OK)
|
||||
if(DS18B20_Search(sensor->hdallas->ds_devices, sensor->hdallas->onewire) != HAL_OK)
|
||||
return HAL_ERROR;
|
||||
|
||||
if(sensor->Init.init_func(sensor->hdallas, sensor) != HAL_OK)
|
||||
|
||||
@@ -16,30 +16,13 @@
|
||||
void OneWire_Pin_Mode(OneWire_t* OW, PinMode Mode)
|
||||
{
|
||||
#ifdef CMSIS_Driver
|
||||
static uint32_t pin_cr_numb = 0;
|
||||
static int get_pin_numb = 1;
|
||||
|
||||
if(get_pin_numb)
|
||||
{
|
||||
get_pin_numb = 0;
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
if((OW->DataPin >> i) == 0x1)
|
||||
pin_cr_numb = i*4;
|
||||
}
|
||||
for(int i = 8; i < 16; i++)
|
||||
{
|
||||
if((OW->DataPin >> i) == 0x1)
|
||||
pin_cr_numb = (i-8)*4;
|
||||
}
|
||||
}
|
||||
if(Mode == Input)
|
||||
{
|
||||
OW->DataPort->MODER &= ~((GPIO_MODER_MODE0_Msk) << pin_cr_numb);
|
||||
OW->DataPort->MODER |= (GPIO_MODE_INPUT << (pin_cr_numb+2));
|
||||
OW->DataPort->MODER &= ~((GPIO_MODER_MODE0_Msk) << 0);
|
||||
OW->DataPort->MODER |= (GPIO_MODE_INPUT << (0+2));
|
||||
}else{
|
||||
OW->DataPort->MODER &= ~((GPIO_MODER_MODE0_Msk) << pin_cr_numb);
|
||||
OW->DataPort->MODER |= (GPIO_MODE_OUTPUT_PP << pin_cr_numb);
|
||||
OW->DataPort->MODER &= ~((GPIO_MODER_MODE0_Msk) << 0);
|
||||
OW->DataPort->MODER |= (GPIO_MODE_OUTPUT_PP << 0);
|
||||
}
|
||||
#else
|
||||
#ifdef LL_Driver
|
||||
|
||||
Reference in New Issue
Block a user