Skip to content

Commit 3e11772

Browse files
committed
added a method to switch the USB to the main pll with a divider
1 parent 39c83b1 commit 3e11772

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

targets/core/nxp/lpc175x/system.hpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ namespace klib::core::lpc175x::io::system {
4343
rtc = 2,
4444
};
4545

46+
/**
47+
* @brief USB PLL clock divider if the USB pll is not used for USB
48+
*
49+
*/
50+
enum class usb_pll_divider {
51+
mhz_288 = 5,
52+
mhz_384 = 7,
53+
mhz_480 = 9,
54+
};
55+
4656
/**
4757
* @brief Check if a pll is connected
4858
*
@@ -268,6 +278,22 @@ namespace klib::core::lpc175x::io::system {
268278
// connect the usb pll
269279
clock::connect<clock::pll::usb, true>();
270280
}
281+
282+
/**
283+
* @brief Set the USB clock input to the main pll with
284+
* a divider
285+
*
286+
* @tparam Freq
287+
*/
288+
template <usb_pll_divider Freq>
289+
static void set_usb() {
290+
// disable the USB pll to switch to main pll
291+
// with a divider
292+
clock::enable<clock::pll::usb, false>();
293+
294+
// set the clock divider to the one provided
295+
SYSCON->USBCLKCFG = static_cast<uint32_t>(Freq);
296+
}
271297
};
272298

273299
class trace {

0 commit comments

Comments
 (0)