Skip to content

Commit

Permalink
[stm32] Add PLL disable function
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durand committed Jan 16, 2023
1 parent 4f50d00 commit 0f0505f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/modm/platform/clock/stm32/rcc.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ Rcc::enablePll{{id}}(PllSource source, const PllFactors& pllFactors, uint32_t wa
%% endif
}

bool
Rcc::disablePll{{id}}(uint32_t waitCycles)
{
RCC->CR &= ~RCC_CR_PLL{{id}}ON;
while ((RCC->CR & RCC_CR_PLL{{id}}RDY) and --waitCycles)
;
return waitCycles > 0;
}

%% endfor

%% if pllsai_p_usb
Expand Down Expand Up @@ -349,6 +358,15 @@ Rcc::enablePllSai(const PllSaiFactors& pllFactors, uint32_t waitCycles)

return tmp;
}

bool
Rcc::disablePllSai(uint32_t waitCycles)
{
RCC->CR &= ~RCC_CR_PLLSAION;
while ((RCC->CR & RCC_CR_PLLSAIRDY) and --waitCycles)
;
return waitCycles > 0;
}
%% endif

%% if overdrive
Expand Down
17 changes: 17 additions & 0 deletions src/modm/platform/clock/stm32/rcc.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,14 @@ public:
static bool
enablePll{{id}}(PllSource source, const PllFactors& pllFactors, uint32_t waitCycles = 2048);

/**
* Disable PLL{{id}}.
*
* \param waitCycles
* Number of cycles to wait for the pll to stabilise. Default: 2048.
*/
static bool
disablePll{{id}}(uint32_t waitCycles = 2048);
%% endfor

%% if pllsai_p_usb
Expand All @@ -613,6 +621,15 @@ public:
*/
static bool
enablePllSai(const PllSaiFactors& pllFactors, uint32_t waitCycles = 2048);

/**
* Disable PLLSAI.
*
* \param waitCycles
* Number of cycles to wait for the pll to stabilise. Default: 2048.
*/
static bool
disablePllSai(uint32_t waitCycles = 2048);
%% endif

%% if target.family == "l0"
Expand Down

0 comments on commit 0f0505f

Please sign in to comment.