Skip to content

Commit e241352

Browse files
authored
Improve Swan initialization (#1722)
1 parent f8bf924 commit e241352

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

variants/STM32L4xx/L4R5Z(G-I)Y_L4R9Z(G-I)Y_L4S5ZIY_L4S9ZIY/variant_SWAN_R5.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,25 @@ extern "C" {
120120

121121
WEAK void initVariant(void)
122122
{
123-
/* Initialize the 3V3 discharge to be OFF and the output power to be ON */
124-
__HAL_RCC_GPIOE_CLK_ENABLE();
123+
125124
GPIO_InitTypeDef GPIO_InitStruct;
126-
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
125+
__HAL_RCC_GPIOE_CLK_ENABLE();
126+
__HAL_RCC_GPIOC_CLK_ENABLE();
127+
128+
/* Set the DISCHARGE pin and the USB_DETECT pin to FLOAT */
129+
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
127130
GPIO_InitStruct.Pull = GPIO_NOPULL;
128-
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
129131
GPIO_InitStruct.Pin = GPIO_PIN_6;
130-
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
131-
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, GPIO_PIN_SET);
132+
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /* PE6 DISCHRG */
133+
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* PC6 is USB_DETECT */
134+
135+
/* Turn on the 3V3 regulator */
132136
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
137+
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
133138
GPIO_InitStruct.Pin = GPIO_PIN_4;
134139
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
135140
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
141+
136142
}
137143

138144
/**

0 commit comments

Comments
 (0)