Skip to content

Commit

Permalink
fix(fw): compilation without power switch (#5021)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelcoeffic authored May 18, 2024
1 parent 6a59c58 commit dbe4050
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions radio/src/targets/common/arm/stm32/pwr_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,19 @@ void pwrInit()
#endif

// External module power
#if defined(HARDWARE_EXTERNAL_MODULE)
EXTERNAL_MODULE_PWR_OFF();
GPIO_InitStructure.GPIO_Pin = EXTMODULE_PWR_GPIO_PIN;
GPIO_Init(EXTMODULE_PWR_GPIO, &GPIO_InitStructure);
#endif

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;

// PWR switch
#if defined(PWR_SWITCH_GPIO)
GPIO_InitStructure.GPIO_Pin = PWR_SWITCH_GPIO_PIN;
GPIO_Init(PWR_SWITCH_GPIO, &GPIO_InitStructure);
#endif

#if defined(PWR_EXTRA_SWITCH_GPIO)
// PWR Extra switch
Expand Down Expand Up @@ -86,7 +90,7 @@ void pwrInit()
void pwrOn()
{
// we keep the init of the PIN to have pwrOn as quick as possible

#if defined(PWR_ON_GPIO)
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = PWR_ON_GPIO_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
Expand All @@ -96,11 +100,14 @@ void pwrOn()
GPIO_Init(PWR_ON_GPIO, &GPIO_InitStructure);

GPIO_SetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
#endif
}

void pwrOff()
{
#if defined(PWR_ON_GPIO)
GPIO_ResetBits(PWR_ON_GPIO, PWR_ON_GPIO_PIN);
#endif
}

#if defined(PWR_EXTRA_SWITCH_GPIO)
Expand All @@ -117,18 +124,22 @@ bool pwrPressed()
Bit_RESET ||
GPIO_ReadInputDataBit(PWR_EXTRA_SWITCH_GPIO,
PWR_EXTRA_SWITCH_GPIO_PIN) == Bit_RESET);
#else
#elif defined(PWR_SWITCH_GPIO)
return GPIO_ReadInputDataBit(PWR_SWITCH_GPIO, PWR_SWITCH_GPIO_PIN) ==
Bit_RESET;
#else
return true;
#endif
}

bool pwrOffPressed()
{
#if defined(PWR_BUTTON_PRESS)
return pwrPressed();
#else
#elif defined(PWR_SWITCH_GPIO)
return !pwrPressed();
#else
return false;
#endif
}

Expand Down

0 comments on commit dbe4050

Please sign in to comment.