Skip to content

Commit

Permalink
feat: Improve Swan 3V3 pin control/behavior
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
zfields committed Sep 15, 2021
1 parent 03d223f commit e506d85
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ const uint32_t analogInputPin[] = {
extern "C" {
#endif

WEAK void initVariant(void)
{
/* Initialize the 3V3 discharge to be OFF and the output power to be ON */
__HAL_RCC_GPIOE_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Pin = GPIO_PIN_6;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6, GPIO_PIN_SET);
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pin = GPIO_PIN_4;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_4, GPIO_PIN_SET);
}

/**
* @brief System Clock Configuration
* @param None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,15 @@
#define USER_BTN PC13
#endif

// Power switch EN pin
// Power switch ENABLE and DISCHARGE pins
#ifndef ENABLE_3V3
#define ENABLE_3V3 PE4
#endif
#ifndef DISCHARGE_3V3
#define DISCHARGE_3V3 PE6
#define DISABLE_DISCHARGING HIGH
#define ENABLE_DISCHARGING LOW
#endif

// SPI definitions
#ifndef PIN_SPI_SS
Expand Down

0 comments on commit e506d85

Please sign in to comment.