Merge pull request #15806 from haukepetersen/opt_nrf5x_nrfblehfxo

cpu/nrf/radio/nrfble: request HFXO only on demand
This commit is contained in:
Hauke Petersen 2021-04-12 11:04:12 +02:00 committed by GitHub
commit e28ec7907b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,6 +120,16 @@ static const uint8_t _ble_chan_map[40] = {
[39] = 80,
};
/**
* @brief Enable the radio
*/
static void _enable(void)
{
clock_hfxo_request();
NRF_RADIO->EVENTS_DISABLED = 0;
NRF_RADIO->INTENSET = INT_EN;
}
/**
* @brief Set radio into idle (DISABLED) state
*/
@ -131,6 +141,7 @@ static void _go_idle(void)
NRF_RADIO->EVENTS_DISABLED = 0;
NRF_RADIO->TASKS_DISABLE = 1;
while (NRF_RADIO->EVENTS_DISABLED == 0) {}
clock_hfxo_release();
_state = STATE_IDLE;
}
}
@ -239,12 +250,8 @@ static int _nrfble_init(netdev_t *dev)
(void)dev;
assert(_nrfble_dev.driver && _nrfble_dev.event_callback);
/* 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 the NRFs radio */
/* power cycle the radio to reset it */
NRF_RADIO->POWER = 0;
NRF_RADIO->POWER = 1;
/* configure variable parameters to default values */
NRF_RADIO->TXPOWER = NRFBLE_TXPOWER_DEFAULT;
@ -286,8 +293,7 @@ static int _nrfble_send(netdev_t *dev, const iolist_t *data)
/* in case no trx sequence is active, we start a new one now */
if (_state == STATE_IDLE) {
_state = STATE_TX;
NRF_RADIO->EVENTS_DISABLED = 0;
NRF_RADIO->INTENSET = INT_EN;
_enable();
NRF_RADIO->TASKS_TXEN = 1;
}
@ -307,8 +313,7 @@ static int _nrfble_recv(netdev_t *dev, void *buf, size_t len, void *info)
/* in case no trx sequence is active, we start a new one now */
if (_state == STATE_IDLE) {
_state = STATE_RX;
NRF_RADIO->EVENTS_DISABLED = 0;
NRF_RADIO->INTENSET = INT_EN;
_enable();
NRF_RADIO->TASKS_RXEN = 1;
}