-
Notifications
You must be signed in to change notification settings - Fork 13
lib: add ble_radio_notification and sample #351
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
base: main
Are you sure you want to change the base?
Conversation
74df57c
to
2f5eb93
Compare
You can find the documentation preview for this PR here. |
2f5eb93
to
e110194
Compare
e110194
to
afdbe0a
Compare
CODEOWNERS
Outdated
@@ -89,6 +90,7 @@ | |||
/tests/lib/bm_zms/ @nrfconnect/ncs-bm @rghaddab | |||
/tests/lib/ble_qwr/ @nrfconnect/ncs-bm | |||
/tests/lib/ble_racp/ @nrfconnect/ncs-bm | |||
tests/lib/ble_radio_notif/ @nrfconnect/ncs-bm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/lib/ble_radio_notif/ @nrfconnect/ncs-bm | |
/tests/lib/ble_radio_notif/ @nrfconnect/ncs-bm |
Seems like the other ones start with /
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thanks
Overview | ||
******** | ||
|
||
The library allows the user to register a handler to receive the radio notifications and configure the distance in microseconds between the Radio Notification signal and the radio event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The library allows the user to register a handler to receive the radio notifications and configure the distance in microseconds between the Radio Notification signal and the radio event. | |
The library allows the user to register a handler to receive the radio notifications and configure the distance in microseconds between the active Radio Notification signal and the radio event. |
The library is enabled and configured entirely using the Kconfig system. | ||
Set the :kconfig:option:`CONFIG_BLE_RADIO_NOTIFICATION` Kconfig option to enable the library. | ||
|
||
The library uses the ``SWI02`` IRQ. Use the :kconfig:option:`CONFIG_BLE_RADIO_NOTIFICATION_IRQ_PRIO` Kconfig option to set the IRQ priority. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the correct place to mention it, but some priority levels shall not be used.
This used to be documented in the SDS: https://docs.nordicsemi.com/bundle/sds_s140/page/SDS/s1xx/processor_avail_interrupt_latency/exception_mgmt_sd.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think it can be documented in the Kconfig option at least.
|
||
if BLE_RADIO_NOTIFICATION | ||
|
||
config BLE_RADIO_NOTIFICATION_IRQ_PRIO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add a range that disallows 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a help text that level 0 and 4 is reserved by the SoftDevice.
NVIC_ClearPendingIRQ(RADIO_NOTIFICATION_IRQn); | ||
NVIC_EnableIRQ(RADIO_NOTIFICATION_IRQn); | ||
|
||
return sd_radio_notification_cfg_set(NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, distance); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit limiting. The library will only support generating both active and inactive notifications.
There are several use cases that would only need only active or inactive notification.
I think it would be better to allow the user to configure this with a config, that can select the different options for softdevice:
sdk-nrf-bm/components/softdevice/s115/s115_API/include/nrf_soc.h
Lines 187 to 189 in 97734f1
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE, /**< Using interrupt for notification when the radio will be enabled. */ | |
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE, /**< Using interrupt for notification when the radio has been disabled. */ | |
NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, /**< Using interrupt for notification both when the radio will be enabled and disabled. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a bit limiting indeed. This module mimics the behavior from nRF5 SDK. I can look into adding a Kconfig option for this, keeping the current behavior as the default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is the same behavior as nRF5 SDK, it may be good as is. There is always the opportunity to use the SD interface directly if someone wants only active or inactive notifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added Kconfig choice.
Building and running | ||
******************** | ||
|
||
This sample can be found under :file:`samples/bluetooth/ble_hrs/` in the |BMshort| folder structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sample can be found under :file:`samples/bluetooth/ble_hrs/` in the |BMshort| folder structure. | |
This sample can be found under :file:`samples/bluetooth/ble_radio_notification/` in the |BMshort| folder structure. |
|
||
.. include:: /includes/softdevice_flash.txt | ||
|
||
.. _ble_hrs_sample_testing: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. _ble_hrs_sample_testing: | |
.. _ble_radio_notification_sample_testing: |
CONFIG_NRF_SDH=y | ||
|
||
CONFIG_BLE_ADV=y | ||
CONFIG_BLE_ADV_NAME="nRF_BM_HRS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONFIG_BLE_ADV_NAME="nRF_BM_HRS" | |
CONFIG_BLE_ADV_NAME="nRF_BM_RADIO_NOTIFICATION" |
Or an abbreviation
CONFIG_BLE_ADV_NAME="nRF_BM_HRS" | ||
CONFIG_BLE_ADV_EXTENDED_ADVERTISING=n | ||
CONFIG_BLE_ADV_DIRECTED_ADVERTISING=n | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps:
CONFIG_BLE_ADV_FAST_ADVERTISING_INTERVAL=400 | |
CONFIG_BLE_ADV_SLOW_ADVERTISING_INTERVAL=1600 |
So it blinks at 4Hz, then 1 Hz. The default blinks a bit fast.
include/ble_radio_notification.h
Outdated
/** | ||
* @brief Function for initializing the Radio Notification module. | ||
* | ||
* @param[in] distance The time from an Active event until the radio is activated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The distance is from the active event until the SoftDevice does the preparation for the radio event.
The time between the preparation and the actual radio activity will vary depending on the role that is scheduled.
It is documented like this in the softdevice
sdk-nrf-bm/components/softdevice/s115/s115_API/include/nrf_soc.h
Lines 607 to 608 in 97734f1
* @param[in] distance_us Distance between the ACTIVE notification signal and start of radio event | |
* preparation by SoftDevice in microseconds. |
e5a75ba
to
8c2a381
Compare
Add ble_radio_notification library and sample. Signed-off-by: Eivind Jølsgard <[email protected]>
8c2a381
to
974e8c4
Compare
Add ble_radio_notification library and sample.