cpu/nrf/radio/nrf802154: request HFXO clock source
This commit is contained in:
parent
9d1692c45a
commit
cea6d8dd2d
@ -27,6 +27,7 @@
|
||||
|
||||
#include "cpu.h"
|
||||
#include "mutex.h"
|
||||
#include "nrf_clock.h"
|
||||
|
||||
#include "net/ieee802154.h"
|
||||
#include "periph/timer.h"
|
||||
@ -247,6 +248,11 @@ static int _init(netdev_t *dev)
|
||||
txbuf[0] = 0;
|
||||
_state = 0;
|
||||
|
||||
/* the radio need the external HF clock source to be enabled */
|
||||
/* @todo add proper handling to release the clock whenever the radio is
|
||||
* idle */
|
||||
clock_hfxo_request();
|
||||
|
||||
/* power on peripheral */
|
||||
NRF_RADIO->POWER = 1;
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
#include "cpu.h"
|
||||
#include "luid.h"
|
||||
#include "nrf_clock.h"
|
||||
|
||||
#include "net/ieee802154.h"
|
||||
#include "periph/timer.h"
|
||||
@ -101,6 +102,22 @@ ieee802154_dev_t nrf802154_hal_dev = {
|
||||
.driver = &nrf802154_ops,
|
||||
};
|
||||
|
||||
static void _power_on(void)
|
||||
{
|
||||
if (NRF_RADIO->POWER == 0) {
|
||||
clock_hfxo_request();
|
||||
NRF_RADIO->POWER = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void _power_off(void)
|
||||
{
|
||||
if (NRF_RADIO->POWER == 1) {
|
||||
NRF_RADIO->POWER = 0;
|
||||
clock_hfxo_release();
|
||||
}
|
||||
}
|
||||
|
||||
static bool _l2filter(uint8_t *mhr)
|
||||
{
|
||||
uint8_t dst_addr[IEEE802154_LONG_ADDRESS_LEN];
|
||||
@ -445,7 +462,8 @@ int nrf802154_init(void)
|
||||
(void)result;
|
||||
timer_stop(NRF802154_TIMER);
|
||||
|
||||
/* power off peripheral */
|
||||
/* power off peripheral (but do not release the HFXO as we never requested
|
||||
* it so far) */
|
||||
NRF_RADIO->POWER = 0;
|
||||
|
||||
return 0;
|
||||
@ -574,7 +592,7 @@ static int _request_on(ieee802154_dev_t *dev)
|
||||
(void) dev;
|
||||
_state = STATE_IDLE;
|
||||
DEBUG("[nrf802154]: Request to turn on\n");
|
||||
NRF_RADIO->POWER = 1;
|
||||
_power_on();
|
||||
/* make sure the radio is disabled/stopped */
|
||||
_disable();
|
||||
/* we configure it to run in IEEE802.15.4 mode */
|
||||
@ -639,7 +657,7 @@ static int _off(ieee802154_dev_t *dev)
|
||||
{
|
||||
(void) dev;
|
||||
DEBUG("[nrf802154] Turning off the radio\n");
|
||||
NRF_RADIO->POWER = 0;
|
||||
_power_off();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user