Skip to content

Commit 993f653

Browse files
committed
fix: Blues Swan initVariant
1 parent d04df18 commit 993f653

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,21 @@ extern "C" {
120120

121121
WEAK void initVariant(void)
122122
{
123-
124-
GPIO_InitTypeDef GPIO_InitStruct;
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;
130-
GPIO_InitStruct.Pull = GPIO_NOPULL;
131-
GPIO_InitStruct.Pin = GPIO_PIN_6;
132-
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); /* PE6 DISCHRG */
133-
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); /* PC6 is USB_DETECT */
123+
/* All pins set to high-Z (floating) initially */
124+
/* DS12023 Rev 5, Section 3.10.5 - Reset mode: */
125+
/* In order to improve the consumption under reset, the I/Os state under and after reset is
126+
* “analog state” (the I/O schmitt trigger is disable). In addition, the internal reset pull-up is
127+
* deactivated when the reset source is internal.
128+
*/
134129

135130
/* Turn on the 3V3 regulator */
131+
__HAL_RCC_GPIOE_CLK_ENABLE();
132+
GPIO_InitTypeDef GPIO_InitStruct;
136133
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
137134
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
138-
GPIO_InitStruct.Pin = GPIO_PIN_4;
135+
GPIO_InitStruct.Pin = GPIO_PIN_4 | GPIO_PIN_6;
139136
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
140-
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
141-
137+
HAL_GPIO_WritePin(GPIOE, GPIO_InitStruct.Pin, GPIO_PIN_SET);
142138
}
143139

144140
/**

0 commit comments

Comments
 (0)