инициализацию переключателя между А4 и А5 вынесла в желлезозависимые функции. У платы старт добавила заглушку

This commit is contained in:
klassents committed 2024-12-19 16:47:59 +07:00
1 parent 1ea864a947
commit 0d24c3f696
5 files changed
+24 -30

No files matched your search

+2 -12
View File
@@ -42,18 +42,8 @@ uint32_t analogRead(uint32_t PinNumber)
uint32_t adcChannel = analogInputToChannelNumber(PinNumber);
if (adcChannel != NC)
{
// if we use pin A5, we need to set SELA45 (1.15) to 1 to switch the output from A4 to A5
if (PinNumber == A5)
{
HAL_GPIO_PinConfig(GPIO_1, GPIO_PIN_15, HAL_GPIO_MODE_GPIO_OUTPUT, HAL_GPIO_PULL_NONE, HAL_GPIO_DS_2MA);
HAL_GPIO_WritePin(GPIO_1, GPIO_PIN_15, GPIO_PIN_HIGH);
}
else if(PinNumber == A4)
{
// return the switch to A4 in case A5 was previously read
HAL_GPIO_PinConfig(GPIO_1, GPIO_PIN_15, HAL_GPIO_MODE_GPIO_OUTPUT, HAL_GPIO_PULL_NONE, HAL_GPIO_DS_2MA);
HAL_GPIO_WritePin(GPIO_1, GPIO_PIN_15, GPIO_PIN_LOW);
}
additionalPinsInit(PinNumber);
// init channel
hadc.Init.Sel = adcChannel;
HAL_ADC_Init(&hadc);
+1 -18
View File
@@ -74,24 +74,7 @@ void pinMode(uint32_t PinNumber, uint32_t PinMode)
// init pin
HAL_GPIO_Init(GPIO_addr, &GPIO_InitStruct);
// if we use pin A5, we need to set SELA45 (1.15) to 1 to switch the output from A4 to A5
if (PinNumber == A5)
{
GPIO_InitStruct.Pin = GPIO_PIN_15;
GPIO_InitStruct.Mode = HAL_GPIO_MODE_GPIO_OUTPUT;
GPIO_InitStruct.Pull = HAL_GPIO_PULL_NONE;
HAL_GPIO_Init(GPIO_1, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIO_1, GPIO_PIN_15, GPIO_PIN_HIGH);
}
else if(PinNumber == A4)
{
GPIO_InitStruct.Pin = GPIO_PIN_15;
GPIO_InitStruct.Mode = HAL_GPIO_MODE_GPIO_OUTPUT;
GPIO_InitStruct.Pull = HAL_GPIO_PULL_NONE;
HAL_GPIO_Init(GPIO_1, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIO_1, GPIO_PIN_15, GPIO_PIN_LOW);
}
additionalPinsInit(PinNumber);
}
}