Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nrf5x: Request HFXO via OS #1274

Merged
merged 1 commit into from
Jan 18, 2022
Merged
Changes from all commits
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
16 changes: 16 additions & 0 deletions src/portable/nordic/nrf5x/dcd_nrf5x.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
#include "device/usbd.h"
#include "device/usbd_pvt.h" // to use defer function helper

#if CFG_TUSB_OS == OPT_OS_MYNEWT
#include "mcu/mcu.h"
#endif

/*------------------------------------------------------------------*/
/* MACRO TYPEDEF CONSTANT ENUM
*------------------------------------------------------------------*/
Expand Down Expand Up @@ -891,6 +895,11 @@ static bool hfclk_running(void)

static void hfclk_enable(void)
{
#if CFG_TUSB_OS == OPT_OS_MYNEWT
usb_clock_request();
return;
#else

// already running, nothing to do
if ( hfclk_running() ) return;

Expand All @@ -904,10 +913,16 @@ static void hfclk_enable(void)

nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED);
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTART);
#endif
}

static void hfclk_disable(void)
{
#if CFG_TUSB_OS == OPT_OS_MYNEWT
usb_clock_release();
return;
#else

#ifdef SOFTDEVICE_PRESENT
if ( is_sd_enabled() )
{
Expand All @@ -917,6 +932,7 @@ static void hfclk_disable(void)
#endif

nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTOP);
#endif
}

// Power & Clock Peripheral on nRF5x to manage USB
Expand Down