Skip to content

NRFCordioHCIDriver: remove idle_hook (and RTOS dependency) #12956

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

Merged
merged 1 commit into from
May 13, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

// mbed Includes
#include "mbed_assert.h"
#include "rtos/source/rtos_idle.h"
#include "platform/mbed_power_mgmt.h"
#include "mbed_critical.h"

Expand Down Expand Up @@ -183,30 +182,6 @@ const LlRtCfg_t NRFCordioHCIDriver::_ll_cfg = {

extern "C" void TIMER0_IRQHandler(void);

static void idle_hook(void)
{
wsfTimerTicks_t nextExpiration;
bool_t timerRunning;

nextExpiration = WsfTimerNextExpiration(&timerRunning);
if(timerRunning && nextExpiration > 0)
{
// Make sure we hae enough time to go to sleep
if( nextExpiration < 1 /* 10 ms per tick which is long enough to got to sleep */ )
{
// Bail
return;
}
}

// critical section to complete sleep with locked deepsleep
core_util_critical_section_enter();
sleep_manager_lock_deep_sleep();
sleep();
sleep_manager_unlock_deep_sleep();
core_util_critical_section_exit();
}

NRFCordioHCIDriver::NRFCordioHCIDriver(CordioHCITransportDriver& transport_driver) : cordio::CordioHCIDriver(transport_driver), _is_init(false), _stack_buffer(NULL)
{
_stack_buffer = (uint8_t*)malloc(CORDIO_LL_MEMORY_FOOTPRINT);
Expand Down Expand Up @@ -234,9 +209,6 @@ NRFCordioHCIDriver::~NRFCordioHCIDriver()
free(_stack_buffer);
_stack_buffer = NULL;

// Restore RTOS idle thread
rtos_attach_idle_hook(NULL);

MBED_ASSERT(_stack_buffer == NULL);
}

Expand Down Expand Up @@ -281,9 +253,6 @@ void NRFCordioHCIDriver::do_initialize()
.freeMemAvail = CORDIO_LL_MEMORY_FOOTPRINT
};

// Override RTOS idle thread
rtos_attach_idle_hook(idle_hook);

/* switch to more accurate 16 MHz crystal oscillator (system starts up using 16MHz RC oscillator) */
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
Expand Down