Skip to content

Commit e506d85

Browse files
committed
feat: Improve Swan 3V3 pin control/behavior
- Define constant to reference `DISCHARGE_3V3` pin. - Define constants `ENABLE_DISCHARGING` and `DISABLE_DISCHARGING` to manipulate `DISCHARGE_3V3` pin. - Initialize `ENABLE_3V3` pin to be on, and `DISCHARGE_3V3` to be disabled.
1 parent 03d223f commit e506d85

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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

+17
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ const uint32_t analogInputPin[] = {
118118
extern "C" {
119119
#endif
120120

121+
WEAK void initVariant(void)
122+
{
123+
/* Initialize the 3V3 discharge to be OFF and the output power to be ON */
124+
__HAL_RCC_GPIOE_CLK_ENABLE();
125+
GPIO_InitTypeDef GPIO_InitStruct;
126+
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
127+
GPIO_InitStruct.Pull = GPIO_NOPULL;
128+
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
129+
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+
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
133+
GPIO_InitStruct.Pin = GPIO_PIN_4;
134+
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
135+
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
136+
}
137+
121138
/**
122139
* @brief System Clock Configuration
123140
* @param None

Diff for: variants/STM32L4xx/L4R5Z(G-I)Y_L4R9Z(G-I)Y_L4S5ZIY_L4S9ZIY/variant_SWAN_R5.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,15 @@
181181
#define USER_BTN PC13
182182
#endif
183183

184-
// Power switch EN pin
184+
// Power switch ENABLE and DISCHARGE pins
185185
#ifndef ENABLE_3V3
186186
#define ENABLE_3V3 PE4
187187
#endif
188+
#ifndef DISCHARGE_3V3
189+
#define DISCHARGE_3V3 PE6
190+
#define DISABLE_DISCHARGING HIGH
191+
#define ENABLE_DISCHARGING LOW
192+
#endif
188193

189194
// SPI definitions
190195
#ifndef PIN_SPI_SS

0 commit comments

Comments
 (0)