исправлены диапазоны адресов у коилов
сделано обращение по указателям в паре мест убрана громоздская конструкция из OneWire_Pin_Mode
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -47,3 +47,4 @@ JLinkLog.txt
|
||||
|
||||
/MDK-ARM/DebugConfig/
|
||||
/MDK-ARM/Output/
|
||||
/~$ds18b20_locations.xlsx
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -123,7 +123,7 @@ typedef struct //MB_DataCoilsTypeDef
|
||||
|
||||
// DEFINES FOR COIL ARRAYS
|
||||
#define C_CONTROL_ADDR 0
|
||||
#define C_CONTROL_QNT 3
|
||||
#define C_CONTROL_QNT 5
|
||||
|
||||
#define C_FLAGS_ADDR 16
|
||||
#define C_FLAGS_QNT 2
|
||||
|
||||
@@ -199,7 +199,7 @@ HAL_StatusTypeDef PCHSens_FindUnknownSensors(PCHSens_DallasBusHandle *hbus)
|
||||
for(int i = 0; i < hbus->hdallas->onewire->RomCnt; i++)
|
||||
{
|
||||
/* Проверка присутствует ли выбранный датчик на линии */
|
||||
result = DS18B20_ReadScratchpad(hbus->hdallas->onewire, (uint8_t *)&DS.DevAddr[i], (uint8_t *)&hbus->hdallas->scratchpad);
|
||||
result = DS18B20_ReadScratchpad(hbus->hdallas->onewire, (uint8_t *)&hbus->hdallas->ds_devices->DevAddr[i], (uint8_t *)&hbus->hdallas->scratchpad);
|
||||
if(result != HAL_OK)
|
||||
__NOP();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user