Skip to content

Commit 92c36f1

Browse files
authored
Merge pull request hathach#1274 from kasjer/kasjer/nrf5x-request-clock-in-mynewt
nrf5x: Request HFXO via OS
2 parents 6972a4f + f472512 commit 92c36f1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/portable/nordic/nrf5x/dcd_nrf5x.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
#include "device/usbd.h"
3939
#include "device/usbd_pvt.h" // to use defer function helper
4040

41+
#if CFG_TUSB_OS == OPT_OS_MYNEWT
42+
#include "mcu/mcu.h"
43+
#endif
44+
4145
/*------------------------------------------------------------------*/
4246
/* MACRO TYPEDEF CONSTANT ENUM
4347
*------------------------------------------------------------------*/
@@ -891,6 +895,11 @@ static bool hfclk_running(void)
891895

892896
static void hfclk_enable(void)
893897
{
898+
#if CFG_TUSB_OS == OPT_OS_MYNEWT
899+
usb_clock_request();
900+
return;
901+
#else
902+
894903
// already running, nothing to do
895904
if ( hfclk_running() ) return;
896905

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

905914
nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED);
906915
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTART);
916+
#endif
907917
}
908918

909919
static void hfclk_disable(void)
910920
{
921+
#if CFG_TUSB_OS == OPT_OS_MYNEWT
922+
usb_clock_release();
923+
return;
924+
#else
925+
911926
#ifdef SOFTDEVICE_PRESENT
912927
if ( is_sd_enabled() )
913928
{
@@ -917,6 +932,7 @@ static void hfclk_disable(void)
917932
#endif
918933

919934
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTOP);
935+
#endif
920936
}
921937

922938
// Power & Clock Peripheral on nRF5x to manage USB

0 commit comments

Comments
 (0)