инициализацию переключателя между А4 и А5 вынесла в желлезозависимые функции. У платы старт добавила заглушку
This commit is contained in:
parent
1ea864a947
commit
0d24c3f696
@ -42,18 +42,8 @@ uint32_t analogRead(uint32_t PinNumber)
|
|||||||
uint32_t adcChannel = analogInputToChannelNumber(PinNumber);
|
uint32_t adcChannel = analogInputToChannelNumber(PinNumber);
|
||||||
if (adcChannel != NC)
|
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
|
additionalPinsInit(PinNumber);
|
||||||
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);
|
|
||||||
}
|
|
||||||
// init channel
|
// init channel
|
||||||
hadc.Init.Sel = adcChannel;
|
hadc.Init.Sel = adcChannel;
|
||||||
HAL_ADC_Init(&hadc);
|
HAL_ADC_Init(&hadc);
|
||||||
|
|||||||
@ -74,24 +74,7 @@ void pinMode(uint32_t PinNumber, uint32_t PinMode)
|
|||||||
|
|
||||||
// init pin
|
// init pin
|
||||||
HAL_GPIO_Init(GPIO_addr, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIO_addr, &GPIO_InitStruct);
|
||||||
|
additionalPinsInit(PinNumber);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -65,6 +65,8 @@ uint16_t pinCommonQty(void);
|
|||||||
volatile uint32_t* portOutputRegister(GPIO_TypeDef* GPIO_x);
|
volatile uint32_t* portOutputRegister(GPIO_TypeDef* GPIO_x);
|
||||||
// the function returns a reference to the STATE address of the GPIO register
|
// the function returns a reference to the STATE address of the GPIO register
|
||||||
volatile uint32_t* portInputRegister(GPIO_TypeDef* GPIO_x);
|
volatile uint32_t* portInputRegister(GPIO_TypeDef* GPIO_x);
|
||||||
|
// the function initializes additional MCU pins depending on the specified pin number
|
||||||
|
void additionalPinsInit(uint32_t PinNumber);
|
||||||
|
|
||||||
// UART
|
// UART
|
||||||
// available uarts quantity
|
// available uarts quantity
|
||||||
|
|||||||
@ -100,6 +100,23 @@ volatile uint32_t* portInputRegister(GPIO_TypeDef* GPIO_x)
|
|||||||
return &GPIO_x->STATE;
|
return &GPIO_x->STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the function initializes additional MCU pins depending on the specified pin number
|
||||||
|
void additionalPinsInit(uint32_t PinNumber)
|
||||||
|
{
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------- ADC ---------------------- //
|
// ---------------------- ADC ---------------------- //
|
||||||
// determines the ADC channel number by the board pin number
|
// determines the ADC channel number by the board pin number
|
||||||
uint32_t analogInputToChannelNumber(uint32_t PinNumber)
|
uint32_t analogInputToChannelNumber(uint32_t PinNumber)
|
||||||
|
|||||||
@ -112,6 +112,8 @@ uint16_t pinCommonQty(void);
|
|||||||
volatile uint32_t* portOutputRegister(GPIO_TypeDef* GPIO_x);
|
volatile uint32_t* portOutputRegister(GPIO_TypeDef* GPIO_x);
|
||||||
// the function returns a reference to the STATE address of the GPIO register
|
// the function returns a reference to the STATE address of the GPIO register
|
||||||
volatile uint32_t* portInputRegister(GPIO_TypeDef* GPIO_x);
|
volatile uint32_t* portInputRegister(GPIO_TypeDef* GPIO_x);
|
||||||
|
// the function is needed for compatibility with other boards
|
||||||
|
static inline void additionalPinsInit(uint32_t PinNumber) {}
|
||||||
|
|
||||||
// UART
|
// UART
|
||||||
// available uarts quantity
|
// available uarts quantity
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user