Skip to content

Commit 474011d

Browse files
authored
Merge pull request #2876 from zfields/blues-init
fix: `initVariant` on Blues boards
2 parents 68b80b3 + 044a72f commit 474011d

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

variants/STM32L4xx/L433C(B-C)(T-U)_L443CC(T-U)/variant_CYGNET.cpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,31 +73,21 @@ extern "C" {
7373

7474
WEAK void initVariant(void)
7575
{
76-
GPIO_InitTypeDef GPIO_InitStruct;
77-
78-
// Init lines that we'll be using below
79-
__HAL_RCC_GPIOA_CLK_ENABLE();
80-
__HAL_RCC_GPIOC_CLK_ENABLE();
81-
__HAL_RCC_GPIOH_CLK_ENABLE();
82-
83-
/* Set DISCHARGE_3V3 as well as the pins we're not initially using to FLOAT */
84-
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
85-
GPIO_InitStruct.Pull = GPIO_NOPULL;
86-
GPIO_InitStruct.Pin = GPIO_PIN_1;
87-
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /* PH1 DISCHARGE_3V3 */
88-
GPIO_InitStruct.Pin = GPIO_PIN_3;
89-
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* PB3 is USB_DETECT */
90-
GPIO_InitStruct.Pin = GPIO_PIN_15;
91-
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* PA15 is CHARGE_DETECT */
92-
GPIO_InitStruct.Pin = GPIO_PIN_4;
93-
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* PA4 is BAT_VOLTAGE */
76+
/* All pins set to high-Z (floating) initially */
77+
/* DS11449 Rev 8, Section 3.9.5 - Reset Mode: */
78+
/* In order to improve the consumption under reset, the I/Os state under and after reset is
79+
* “analog state” (the I/O schmitt trigger is disable). In addition, the internal reset pull-up is
80+
* deactivated when the reset source is internal.
81+
*/
9482

9583
/* Turn on the 3V3 regulator */
84+
__HAL_RCC_GPIOH_CLK_ENABLE();
85+
GPIO_InitTypeDef GPIO_InitStruct;
9686
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
9787
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
98-
GPIO_InitStruct.Pin = GPIO_PIN_0;
99-
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
100-
HAL_GPIO_WritePin(GPIOH, GPIO_InitStruct.Pin, GPIO_PIN_SET);
88+
GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1;
89+
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); /* PH0 is ENABLE_3V3, PH1 is DISCHARGE_3V3 */
90+
HAL_GPIO_WritePin(GPIOH, GPIO_InitStruct.Pin, GPIO_PIN_SET); /* Enable 3V3 regulator and disable discharging */
10191
}
10292

10393
/**

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)