Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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.
  • Loading branch information
zfields committed Sep 15, 2021
commit e506d85e30af2cb801f91bc1720b51924c553e11
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