API documentation
Multiprotocol Service Layer interface
- group mpsl
The main APIs needed to configure, enable, and use the MPSL.
Defines
-
MPSL_HIGH_IRQ_PRIORITY
High IRQ priority.
High IRQ priority is used for realtime scheduling. It should not be used except when inside radio timeslot by the owner of the timeslot
-
MPSL_BUILD_REVISION_SIZE
Size of build revision array in bytes.
Typedefs
-
typedef void (*mpsl_assert_handler_t)(const char *const file, const uint32_t line)
Bitmask of (D)PPI channels reserved for MPSL.
Function prototype for the assert handler.
Note
If an internal assert occurs this function is called. It is supposed to log the assert and stop execution.
- Param file
[in] The filename where the assertion occurred.
- Param line
[in] The line number where the assertion occurred.
Functions
-
int32_t mpsl_init(mpsl_clock_lfclk_cfg_t const *p_clock_config, IRQn_Type low_prio_irq, mpsl_assert_handler_t p_assert_handler)
MPSL initialization.
Note
If
CONFIG_SYSTEM_CLOCK_NO_WAIT
is set to 0, never modify the SEVONPEND flag in the SCR register, while this function is executing. Doing so might lead to a deadlock.- Parameters
p_clock_config – [in] Clock configuration. If NULL the LF clock will be configured as an RC source with rc_ctiv = MPSL_RECOMMENDED_RC_CTIV, .rc_temp_ctiv = MPSL_RECOMMENDED_RC_TEMP_CTIV, and .accuracy_ppm = MPSL_DEFAULT_CLOCK_ACCURACY_PPM.
low_prio_irq – [in] IRQ to pend when low priority processing should be executed. The application shall call mpsl_low_priority_process after this IRQ has occurred.
p_assert_handler – [in] Pointer to MPSL assert handler.
- Return values
0 – MPSL is successfully initialized.
-NRF_EPERM – MPSL is already initialized.
-NRF_EINVAL – Invalid parameters supplied.
-
void mpsl_uninit(void)
Uninitialize MPSL. Stops clocks and scheduler. This will release all peripherals and reduce power usage.
Note
This function assumes no protocol stacks are running, and no timeslots are requested. All initialized protocol stacks need to be stopped before calling this function. Failing to do so will lead to undefined behavior.
-
bool mpsl_is_initialized(void)
Returns true if MPSL is already initialized, false otherwise.
- Returns
True if initialized, false if not.
-
int32_t mpsl_build_revision_get(uint8_t *p_build_revision)
Obtain build revision.
The application must provide a buffer that is at least MPSL_BUILD_REVISION_SIZE bytes long. MPSL will copy the build revision to the provided buffer.
- Parameters
p_build_revision – [inout] Build revision.
- Return values
0 – Success
-NRF_EINVAL – Invalid argument provided
-
void MPSL_IRQ_RADIO_Handler(void)
RADIO interrupt handler.
Note
This handler should be placed in the interrupt vector table. The interrupt priority level should be priority 0.
-
void MPSL_IRQ_RTC0_Handler(void)
RTC0 interrupt handler.
Note
This handler should be placed in the interrupt vector table. The interrupt priority level should be priority 0
-
void MPSL_IRQ_TIMER0_Handler(void)
TIMER0 interrupt handler.
Note
This handler should be placed in the interrupt vector table. The interrupt priority level should be priority 0
-
void MPSL_IRQ_CLOCK_Handler(void)
POWER_CLOCK interrupt handler.
Note
This handler should be placed in the interrupt vector table. The interrupt priority level should be lower than priority 0.
-
void mpsl_low_priority_process(void)
MPSL low priority processing handler.
Note
This handler should be called when MPSL signals low priority processing should be executed (via low_prio_irq provided to mpsl_init) within reasonable time (a at least a few 100 ms). The caller is responsible to ensure this function is not called concurrently with any other low priority MPSL API functions, for more information see thread safety in the MPSL documentation.
-
MPSL_HIGH_IRQ_PRIORITY
MPSL Clock
- group mpsl_clock
The MPSL clock interface provides APIs for controlling the clocks.
Defines
-
MPSL_RECOMMENDED_RC_CTIV
Recommended RC clock calibration timer interval.
-
MPSL_RECOMMENDED_RC_TEMP_CTIV
Recommended RC clock calibration timer interval for temperature changes.
-
MPSL_DEFAULT_CLOCK_ACCURACY_PPM
Default LF clock accuracy in parts per million (ppm).
-
MPSL_DEFAULT_SKIP_WAIT_LFCLK_STARTED
MPSL waits for low frequency clock to start by default.
Typedefs
-
typedef void (*mpsl_clock_hfclk_callback_t)(void)
High frequency clock callback.
This callback will be called when the high frequency clock is started. It will be executed in the same execution priority as mpsl_low_priority_process.
Enums
Functions
-
int32_t mpsl_clock_hfclk_request(mpsl_clock_hfclk_callback_t hfclk_started_callback)
Request the high frequency crystal oscillator.
Will start the high frequency crystal oscillator, the startup time of the crystal varies and the mpsl_clock_hfclk_is_running function can be polled to check if it has started.
See also
See also
- Parameters
hfclk_started_callback – [in] Function to be called when the high frequency clock is started. The callback will be executed in the context as mpsl_low_priority_process.
- Return values
0 – Success
-
int32_t mpsl_clock_hfclk_release(void)
Releases the high frequency crystal oscillator.
Indicates that the high frequency crystal oscillator is not needed by the application. MPSL may continue to use the high frequency clock if it is requested by protocol stacks. MPSL will automatically turn it off when it is no longer needed.
See also
See also
- Return values
0 – Success
-
int32_t mpsl_clock_hfclk_is_running(uint32_t *p_is_running)
Checks if the high frequency crystal oscillator is running.
See also
See also
- Parameters
p_is_running – [out] 1 if the external crystal oscillator is running, 0 if not.
- Return values
0 – Success
-
int32_t mpsl_clock_hfclk_latency_set(mpsl_clock_hfclk_latency_config_t mpsl_clock_hfclk_latency_config)
Informs MPSL about the actual ramp-up time of the high-frequency crystal oscillator.
- Parameters
mpsl_clock_hfclk_latency_config – [in] Setting for the time it takes for the HFCLK to ramp up.
- Return values
0 – Success
-
struct mpsl_clock_lfclk_cfg_t
- #include <mpsl_clock.h>
Type representing LFCLK oscillator source.
Public Members
-
uint8_t source
LF oscillator clock source, see MPSL_CLOCK_LF_SRC.
-
uint8_t rc_ctiv
Only for MPSL_CLOCK_LF_SRC_RC. Calibration timer interval in 1/4 second units.
Note
To avoid excessive clock drift, 0.5 degrees Celsius is the maximum temperature change allowed in one calibration timer interval. The interval should be selected to ensure this.
Note
Must be 0 if source is not MPSL_CLOCK_LF_SRC_RC.
-
uint8_t rc_temp_ctiv
Only for MPSL_CLOCK_LF_SRC_RC. How often (in number of calibration intervals) the RC oscillator shall be calibrated if the temperature hasn’t changed.
0: Always calibrate even if the temperature hasn’t changed.
1-33: Check the temperature and only calibrate if it has changed, however calibration will take place every rc_temp_ctiv intervals in any case.
Note
Must be 0 if source is not MPSL_CLOCK_LF_SRC_RC.
Note
The application must ensure calibration at least once every 8 seconds to ensure +/-500 ppm clock stability. The recommended configuration for MPSL_CLOCK_LF_SRC_RC is given by MPSL_RECOMMENDED_RC_CTIV and MPSL_RECOMMENDED_RC_TEMP_CTIV. This sets the calibration interval to 4 seconds and guarantees clock calibration every second calibration interval. That is, the clock will be calibrated every 8 seconds. If the temperature changes more that 0.5 every 4 seconds, the clock will be calibrated every 4 seconds. See the Product Specification for more information.
-
uint16_t accuracy_ppm
Accuracy of the low frequency clock in parts per million (ppm). Default value is MPSL_DEFAULT_CLOCK_ACCURACY_PPM.
-
bool skip_wait_lfclk_started
Determines whether MPSL waits for the low frequency clock to start during initialization or not. If it is set to true, MPSL will wait for the low frequency clock later, before the low frequency clock is used for the first time. Default value is MPSL_DEFAULT_SKIP_WAIT_LFCLK_STARTED.
Note
If this option is set to true and the application writes to NRF_CLOCK->TASKS_LFCLKSTART before mpsl_init() is called, the application shall either:
Write to NRF_CLOCK->TASKS_LFCLKSTOP.
Keep NRF_CLOCK->EVENTS_LFCLKSTARTED untouched.
-
uint8_t source
-
MPSL_RECOMMENDED_RC_CTIV
MPSL Timeslot
- group mpsl_timeslot
The Timeslot interface allows the application to run another radio protocol concurrently with Bluetooth LE activity. When a timeslot is granted, the application has exclusive access to the normally blocked RADIO, TIMER0, CCM, and AAR peripherals. The application can use the peripherals freely for the duration of the timeslot.
Defines
-
MPSL_TIMESLOT_LENGTH_MIN_US
The shortest allowed timeslot event in microseconds.
-
MPSL_TIMESLOT_LENGTH_MAX_US
The longest allowed timeslot event in microseconds.
-
MPSL_TIMESLOT_DISTANCE_MAX_US
The longest timeslot distance in microseconds allowed for the distance parameter see mpsl_timeslot_request_normal_t.
-
MPSL_TIMESLOT_EARLIEST_TIMEOUT_MAX_US
The longest timeout in microseconds allowed when requesting the earliest possible timeslot.
-
MPSL_TIMESLOT_START_JITTER_US
The maximum jitter in MPSL_TIMESLOT_SIGNAL_START relative to the requested start time.
-
MPSL_TIMESLOT_EXTENSION_TIME_MIN_US
The minimum allowed timeslot extension time.
-
MPSL_TIMESLOT_EXTENSION_PROCESSING_TIME_MAX_US
The maximum processing time to handle a timeslot extension.
-
MPSL_TIMESLOT_EXTENSION_MARGIN_MIN_US
The latest time before the end of a timeslot when timeslot can be extended.
-
MPSL_TIMESLOT_CONTEXT_SIZE
Size of a single timeslot context.
-
MPSL_TIMESLOT_CONTEXT_COUNT_MAX
Maximum number of timeslot sessions.
Typedefs
-
typedef uint8_t mpsl_timeslot_session_id_t
The timeslot session id type.
-
typedef mpsl_timeslot_signal_return_param_t *(*mpsl_timeslot_callback_t)(mpsl_timeslot_session_id_t session_id, uint32_t signal)
The timeslot signal callback type.
Note
In case of invalid return parameters, the timeslot will automatically end immediately after returning from the signal callback and the MPSL_TIMESLOT_SIGNAL_INVALID_RETURN event will be sent.
Note
The returned struct pointer must remain valid after the signal callback function returns. For instance, this means that it must not point to a stack variable.
- Param session_id
[in] Session id as returned by mpsl_timeslot_session_open.
- Param signal
[in] Type of signal, see MPSL_TIMESLOT_SIGNAL.
- Return
Pointer to structure containing action requested by the application.
Enums
-
enum MPSL_TIMESLOT_SIGNAL
The timeslot signal types.
Values:
-
enumerator MPSL_TIMESLOT_SIGNAL_START
This signal indicates the start of the timeslot. The signal will be executed in the same context as MPSL_IRQ_TIMER0_Handler.
-
enumerator MPSL_TIMESLOT_SIGNAL_TIMER0
This signal indicates the TIMER0 interrupt. The signal will be executed in the same context as MPSL_IRQ_TIMER0_Handler.
-
enumerator MPSL_TIMESLOT_SIGNAL_RADIO
This signal indicates the RADIO interrupt. The signal will be executed in the same context as MPSL_IRQ_RADIO_Handler.
-
enumerator MPSL_TIMESLOT_SIGNAL_EXTEND_FAILED
This signal indicates extend action failed. The signal will be executed in the same context as the previous signal.
-
enumerator MPSL_TIMESLOT_SIGNAL_EXTEND_SUCCEEDED
This signal indicates extend action succeeded. The signal will be executed in the same context as the previous signal.
-
enumerator MPSL_TIMESLOT_SIGNAL_BLOCKED
The previous request was blocked. The signal will be executed in the same context as mpsl_low_priority_process.
-
enumerator MPSL_TIMESLOT_SIGNAL_CANCELLED
The previous request was cancelled. The signal will be executed in the same context as mpsl_low_priority_process.
-
enumerator MPSL_TIMESLOT_SIGNAL_SESSION_IDLE
The timeslot session has no more pending requests. The signal will be executed in the same context as mpsl_low_priority_process.
-
enumerator MPSL_TIMESLOT_SIGNAL_INVALID_RETURN
The previous timeslot callback return value was invalid. The signal will be executed in the same context as the previous signal which had an invalid return value. The application should avoid to continuously provide invalid return values. Doing so, will lead to an infinite loop.
-
enumerator MPSL_TIMESLOT_SIGNAL_SESSION_CLOSED
The session has been closed.
-
enumerator MPSL_TIMESLOT_SIGNAL_OVERSTAYED
The timeslot event was closed too late. An assert will be triggered after the processing of this signal completes.
-
enumerator MPSL_TIMESLOT_SIGNAL_START
-
enum MPSL_TIMESLOT_SIGNAL_ACTION
The actions requested by the signal callback.
This code gives instructions about what action to take when the signal callback has returned.
Note
For signals executed in low priority returning any action other than MPSL_TIMESLOT_SIGNAL_ACTION_NONE will result in an assert.
Values:
-
enumerator MPSL_TIMESLOT_SIGNAL_ACTION_NONE
Return without action.
-
enumerator MPSL_TIMESLOT_SIGNAL_ACTION_EXTEND
Request an extension of the current timeslot event. Maximum execution time for this action: MPSL_TIMESLOT_EXTENSION_PROCESSING_TIME_MAX_US. This action must be started at least MPSL_TIMESLOT_EXTENSION_MARGIN_MIN_US before the end of a timeslot event.
Note
This signal action may only be used from within a timeslot event.
-
enumerator MPSL_TIMESLOT_SIGNAL_ACTION_END
End the current timeslot event.
Note
This signal action may only be called from within a timeslot event.
-
enumerator MPSL_TIMESLOT_SIGNAL_ACTION_REQUEST
Request a new timeslot event.
Note
If this signal action is used from within a timeslot, the current timeslot event is closed.
-
enumerator MPSL_TIMESLOT_SIGNAL_ACTION_NONE
-
enum MPSL_TIMESLOT_HFCLK_CFG
Timeslot high frequency clock source configuration.
Values:
-
enumerator MPSL_TIMESLOT_HFCLK_CFG_XTAL_GUARANTEED
The high frequency clock source is the external crystal for the whole duration of the timeslot. This should be the preferred option for events that use the radio or require high timing accuracy.
Note
The external crystal will automatically be turned on and off at the beginning and end of the timeslot.
-
enumerator MPSL_TIMESLOT_HFCLK_CFG_NO_GUARANTEE
This configuration allows for earlier and tighter scheduling of timeslots. The RC oscillator may be the clock source in part or for the whole duration of the timeslot. The RC oscillator’s accuracy must therefore be taken into consideration.
Note
If the application will use the radio peripheral in timeslots with this configuration, it must ensure that the crystal is running and stable before starting the radio.
-
enumerator MPSL_TIMESLOT_HFCLK_CFG_XTAL_GUARANTEED
-
enum MPSL_TIMESLOT_PRIORITY
Timeslot event priorities.
Values:
-
enumerator MPSL_TIMESLOT_PRIORITY_HIGH
High priority.
-
enumerator MPSL_TIMESLOT_PRIORITY_NORMAL
Low priority.
-
enumerator MPSL_TIMESLOT_PRIORITY_HIGH
-
enum MPSL_TIMESLOT_REQUEST_TYPE
Timeslot request type.
Values:
-
enumerator MPSL_TIMESLOT_REQ_TYPE_EARLIEST
Request timeslot as early as possible. This should always be used for the first request in a session.
Note
It is not permitted to request an earliest timeslot from within a timeslot.
-
enumerator MPSL_TIMESLOT_REQ_TYPE_NORMAL
Normal timeslot request.
-
enumerator MPSL_TIMESLOT_REQ_TYPE_EARLIEST
Functions
-
int32_t mpsl_timeslot_session_count_set(void *p_mem, uint8_t n_sessions)
Set or update the MPSL timeslot configuration.
Note
Resource configuration can only be performed when all timeslots are closed.
- Parameters
p_mem – [in] Pointer to a memory location for timeslot sessions. The size of the memory block needs to be at least n_sessions * MPSL_TIMESLOT_CONTEXT_SIZE bytes. The memory needs to reside in RAM. The pointer needs to be aligned to a 4-byte boundary.
n_sessions – [in] Number of timeslot sessions. Maximum number of supported timeslot sessions is MPSL_TIMESLOT_CONTEXT_COUNT_MAX.
- Return values
0 – The configuration was applied successfully.
-NRF_EPERM – Timeslots need to be configured when no timeslots are open.
-NRF_EINVAL – Invalid argument provided.
-NRF_EFAULT – The memory is not aligned to a 4-byte boundary.
-
int32_t mpsl_timeslot_session_open(mpsl_timeslot_callback_t mpsl_timeslot_signal_callback, mpsl_timeslot_session_id_t *p_session_id)
Opens a session for timeslot requests.
Note
Only one session can be open at a time.
Note
mpsl_timeslot_signal_callback(MPSL_TIMESLOT_SIGNAL_START) will be called when the timeslot starts. From this point the RADIO, TIMER0, AAR, and CCM peripherals can be freely accessed by the application.
Note
mpsl_timeslot_signal_callback(MPSL_TIMESLOT_SIGNAL_TIMER0) is called whenever the TIMER0 interrupt occurs.
Note
mpsl_timeslot_signal_callback(MPSL_TIMESLOT_SIGNAL_RADIO) is called whenever the RADIO interrupt occurs.
Note
If the low frequency clock is not running when this function is called, the function will wait until the low frequency clock has started. See mpsl_clock_lfclk_cfg_t::skip_wait_lfclk_started.
- Parameters
mpsl_timeslot_signal_callback – [in] The signal callback.
p_session_id – [out] Pointer to the id of the session that was opened.
- Return values
0 – Request was successful.
-NRF_ENOMEM – All sessions are already open.
-
int32_t mpsl_timeslot_session_close(mpsl_timeslot_session_id_t session_id)
Closes a session for timeslot requests.
Note
Any current timeslot will be finished before the session is closed.
Note
If a timeslot is scheduled when the session is closed, it will be canceled.
- Parameters
session_id – [in] The session identifier as returned by mpsl_timeslot_session_open.
- Return values
0 – Success
-NRF_EAGAIN – Session already closed
-
int32_t mpsl_timeslot_request(mpsl_timeslot_session_id_t session_id, mpsl_timeslot_request_t const *p_request)
Requests a timeslot.
Note
The first request in a session must always be of type MPSL_TIMESLOT_REQ_TYPE_EARLIEST.
Note
Successful requests will result in mpsl_timeslot_signal_callback_t(MPSL_TIMESLOT_SIGNAL_START). Unsuccessful requests will result in a MPSL_TIMESLOT_SIGNAL_BLOCKED event.
Note
The jitter in the start time of the timeslots is +/- MPSL_TIMESLOT_START_JITTER_US us.
Note
The mpsl_timeslot_signal_callback_t(MPSL_TIMESLOT_SIGNAL_START) call has a latency relative to the specified timeslot start, but this does not affect the actual start time of the timeslot.
Note
TIMER0 is reset at the start of the timeslot, and is clocked at 1MHz from the high frequency (16 MHz) clock source
Note
No stack will neither access the RADIO peripheral nor the TIMER0 peripheral during the timeslot.
- Parameters
session_id – [in] The session identifier as returned by mpsl_timeslot_session_open.
p_request – [in] Pointer to the request parameters.
- Return values
0 – Success
-NRF_EINVAL – The parameters of p_request are not valid
-NRF_ENOENT – The session is not open.
-NRF_EAGAIN – The session is not IDLE.
-
struct mpsl_timeslot_request_earliest_t
- #include <mpsl_timeslot.h>
Parameters for a request for a timeslot as early as possible.
Public Members
-
uint8_t hfclk
High frequency clock source, see MPSL_TIMESLOT_HFCLK_CFG.
-
uint8_t priority
The timeslot priority, see MPSL_TIMESLOT_PRIORITY.
-
uint32_t length_us
The timeslot length,
See also
See also
-
uint32_t timeout_us
Longest acceptable delay until the start of the requested timeslot, up to MPSL_TIMESLOT_EARLIEST_TIMEOUT_MAX_US microseconds.
-
uint8_t hfclk
-
struct mpsl_timeslot_request_normal_t
- #include <mpsl_timeslot.h>
Parameters for a normal timeslot request.
Public Members
-
uint8_t hfclk
High frequency clock source, see MPSL_TIMESLOT_HFCLK_CFG.
-
uint8_t priority
The timeslot priority, see MPSL_TIMESLOT_PRIORITY.
-
uint32_t distance_us
Distance from the start of the previous timeslot up to MPSL_TIMESLOT_DISTANCE_MAX_US microseconds.
-
uint32_t length_us
The timeslot length,
See also
See also
-
uint8_t hfclk
-
struct mpsl_timeslot_request_t
- #include <mpsl_timeslot.h>
Timeslot request parameters.
Public Members
-
uint8_t request_type
Type of request, see MPSL_TIMESLOT_REQUEST_TYPE.
-
mpsl_timeslot_request_earliest_t earliest
Parameters for requesting a timeslot as early as possible.
-
mpsl_timeslot_request_normal_t normal
Parameters for requesting a normal timeslot.
-
union mpsl_timeslot_request_t.[anonymous] params
Union containing parameters for the request specified.
-
uint8_t request_type
-
struct mpsl_timeslot_signal_return_param_t
- #include <mpsl_timeslot.h>
Return parameters of the timeslot signal callback.
Public Members
-
uint8_t callback_action
The action requested by the application when returning from the signal callback, see MPSL_TIMESLOT_SIGNAL_ACTION.
-
mpsl_timeslot_request_t *p_next
The request parameters for the next timeslot.
-
struct mpsl_timeslot_signal_return_param_t.[anonymous].[anonymous] request
Additional parameters for return_code MPSL_TIMESLOT_SIGNAL_ACTION_REQUEST.
-
uint32_t length_us
Requested extension of the timeslot duration. The minimum time is MPSL_TIMESLOT_EXTENSION_TIME_MIN_US).
-
struct mpsl_timeslot_signal_return_param_t.[anonymous].[anonymous] extend
Additional parameters for return_code MPSL_TIMESLOT_SIGNAL_ACTION_EXTEND.
-
union mpsl_timeslot_signal_return_param_t.[anonymous] params
Parameter union.
-
uint8_t callback_action
-
MPSL_TIMESLOT_LENGTH_MIN_US
MPSL Radio Notification
- group mpsl_radio_notification
The MPSL radio interface provides APIs for configuring radio notifications. When radio notifications are enabled, the application is notified when an MPSL timeslot starts or ends. By using radio notifications, the application is informed when a protocol uses the radio.
Defines
-
MPSL_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US
Guaranteed time for application to process radio inactive notification.
Enums
-
enum MPSL_RADIO_NOTIFICATION_DISTANCES
Radio notification distances.
Values:
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_NONE
The event does not have a notification.
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_200US
The distance from the active notification to start of radio activity.
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_420US
The distance from the active notification to start of radio activity.
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_800US
The distance from the active notification to start of radio activity.
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_1740US
The distance from the active notification to start of radio activity.
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_2680US
The distance from the active notification to start of radio activity.
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_3620US
The distance from the active notification to start of radio activity.
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_4560US
The distance from the active notification to start of radio activity.
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_5500US
The distance from the active notification to start of radio activity.
-
enumerator MPSL_RADIO_NOTIFICATION_DISTANCE_NONE
-
enum MPSL_RADIO_NOTIFICATION_TYPES
Radio notification types.
Values:
-
enumerator MPSL_RADIO_NOTIFICATION_TYPE_NONE
The event does not have a radio notification signal.
-
enumerator MPSL_RADIO_NOTIFICATION_TYPE_INT_ON_ACTIVE
Using interrupt for notification when the radio will be enabled.
-
enumerator MPSL_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE
Using interrupt for notification when the radio has been disabled.
-
enumerator MPSL_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH
Using interrupt for notification both when the radio will be enabled and disabled.
-
enumerator MPSL_RADIO_NOTIFICATION_TYPE_NONE
Functions
-
int32_t mpsl_radio_notification_cfg_set(uint8_t type, uint8_t distance, IRQn_Type irq)
Configures the Radio Notification signal.
Note
The notification signal latency depends on the interrupt priority settings of IRQ used for notification signal.
To ensure that the radio notification signal behaves in a consistent way, the radio notifications must be configured when there is no protocol stack enabled. It is recommended that the radio notification signal is configured directly after the MPSL is enabled.
- Parameters
type – [in] Type of notification signal, see MPSL_RADIO_NOTIFICATION_TYPES. MPSL_RADIO_NOTIFICATION_TYPE_NONE shall be used to turn off radio notification. Using MPSL_RADIO_NOTIFICATION_DISTANCE_NONE is recommended (but not required) to be used with MPSL_RADIO_NOTIFICATION_TYPE_NONE.
distance – [in] Distance between the notification signal and start of radio activity, see MPSL_RADIO_NOTIFICATION_DISTANCES. This parameter is ignored when MPSL_RADIO_NOTIFICATION_TYPE_NONE or MPSL_RADIO_NOTIFICATION_TYPE_INT_ON_INACTIVE is used.
irq – [in] IRQ to pend as the radio notification signal, e.g SWI1_IRQn. If the application uses IRQs that are already in use, e.g, RADIO_IRQn, TIMER0_IQRn or similar, the behavior is undefined. The interrupt priority level should be lower than priority level 0, that is, a higher numerical priority value. The application is responsible for setting the interrupt priority.
- Return values
-NRF_EINVAL – Invalid parameters supplied.
-NRF_EINPROGRESS – A protocol stack or other SoftDevice is running. Stop all running activities and retry.
0 – Success
-
MPSL_RADIO_NOTIFICATION_INACTIVE_GUARANTEED_TIME_US
MPSL TX Power
- group mpsl_tx_power
The MPSL TX Power interface provides APIs to set the maximum TX power per channel.
Defines
-
MPSL_TOTAL_NUM_OF_BLE_CHANNELS
The number of channels for Bluetooth LE protocol.
-
MPSL_TOTAL_NUM_OF_802154_CHANNELS
The number of channels for 802.15.4 protocol.
Typedefs
-
typedef int8_t mpsl_tx_power_t
TX power, dBm.
Enums
Functions
-
int32_t mpsl_tx_power_channel_map_set(const mpsl_tx_power_envelope_t *const p_envelope)
Sets maximum TX power envelope. If the PHY already has an envelope configured, it will be over-written.
Note
Calling this function while an envelope is being used to limit current TX Power may lead to undefined behavior.
Note
The memory for the provided envelope is not copied and must be valid until it is replaced with another envelope for the same PHY.
- Parameters
p_envelope – [in] The pointer to an envelope, if NULL the envelopes for all PHYs are reset to maximum power possible.
- Return values
0 – TX power channel successfully set.
-NRF_EINVAL – Invalid parameter provided.
-
mpsl_tx_power_t mpsl_tx_power_radio_supported_power_adjust(mpsl_tx_power_t req_radio_power)
Adjusts TX power to a value supported by the RADIO peripheral.
- Parameters
req_radio_power – [in] Requested TX power desired for RADIO peripheral.
- Returns
RADIO TX power that is supported by the RADIO peripheral. If
req_radio_power
is less than the minimum TX power supported, the minimum supported TX power is returned. Otherwise, closest supported value that is less or equal toreq_radio_power
returned.
-
struct mpsl_tx_power_envelope_t
- #include <mpsl_tx_power.h>
Max TX power envelope. It is up to the application to allocate memory for an envelope.
Public Members
-
mpsl_phy_t phy
The PHY that this envelope applies to.
-
mpsl_tx_power_t tx_power_ble[40]
Tx power per channel when mpsl_tx_power_envelope_t::phy is a Bluetooth LE PHY.
-
mpsl_tx_power_t tx_power_802154[16]
Tx power per channel when mpsl_tx_power_envelope_t::phy is a 802.15.4 PHY.
-
union mpsl_tx_power_envelope_t.[anonymous] envelope
Array of maximum TX power value per channel. From 11 to 26 for 802.15.4 protocol. From 0 to 40 for Bluetooth LE protocol.
-
mpsl_phy_t phy
-
MPSL_TOTAL_NUM_OF_BLE_CHANNELS
MPSL FEM
- group mpsl_fem
This module provides the interface for the protocols to use PA, LNA, or both in the radio transmission and the radio reception. Refer to the README.rst for the details.
Typedefs
-
typedef uint8_t mpsl_subscribable_hw_event_t
Type representing a multiple-subscribable hardware event.
For nRF52 series this is an address of an event within a peripheral. This event can be written to
EEP
register of a PPI channel, to make the PPI channel be driven by the event. For nRF52 series an event can be published to multiple PPI channels by hardware design, which makes it possible for multiple tasks to subscribe to it.For nRF53 series this is a number of a DPPI channel which is configured in such a way that certain event publishes to the DPPI channel and the DPPI channel is enabled. Ensuring above is responsibility of an user of the provided API. Multiple tasks can then subscribe to the DPPI channel (by hardware design) thus indirectly to the event.
Enums
Functions
-
int32_t mpsl_fem_disable(void)
Disable Front End Module.
Some Front End Module devices can be explicitly disabled after PA and LNA activities are finished to preserve power.
This function is intended to disable Front End Module shortly after radio operations are finished and the protocol does not expect more radio activities in short future, or passes radio control to other protocols in the system.
Front End Module disabling process is synchronous and immediate.
- Return values
0 –
-NRF_EPERM – FEM is configured to enable PA or LNA.
-
int32_t mpsl_fem_pa_configuration_set(const mpsl_fem_event_t *const p_activate_event, const mpsl_fem_event_t *const p_deactivate_event)
Sets up PA using the provided events for the upcoming radio transmission.
Multiple configurations can be provided by repeating calls to this function (that is, you can set the activate and the deactivate events in multiple calls, and the configuration is preserved between calls).
The order of calls of this function and its
lna
counterpart must match the order of radio operations. I.e. if you want to listen first and then send the frame, you need first to issue mpsl_fem_lna_configuration_set and only after mpsl_fem_pa_configuration_set.If a mpsl_fem_event_type_t::MPSL_FEM_EVENT_TYPE_TIMER timer event is provided, the PA will be configured to activate or deactivate at the application-configured time gap before the timer instance reaches the given register_value. The time gap is set via the corresponding configuration setter of the selected Front End Module.
If a mpsl_fem_event_type_t::MPSL_FEM_EVENT_TYPE_GENERIC event is provided, the PA will be configured to activate or deactivate when an event occurs.
The function sets up the PPIs and the GPIOTE channel to activate PA for the upcoming radio transmission. The PA pin will be active until deactivated, which can happen either by encountering a configured deactivation event or by using mpsl_fem_deactivate_now.
Note
If a timer event is provided, the caller of this function is responsible for starting the timer and configuring its shorts. Moreover, the caller is responsible for stopping the timer no earlier than the compare channel of the lowest ID among the provided ones does expire.
Note
The activation event can be only of type mpsl_fem_event_type_t::MPSL_FEM_EVENT_TYPE_TIMER. Using other activation event type leads to undefined module behavior.
- Parameters
p_activate_event – [in] Pointer to the activation event structure.
p_deactivate_event – [in] Pointer to the deactivation event structure.
- Return values
0 – PA activation setup is successful.
-NRF_EPERM – PA is currently disabled.
-NRF_EINVAL – PA activation setup could not be performed due to invalid or missing configuration parameters in p_activate_event or p_deactivate_event, or both.
- Pre
To activate PA, the corresponding configuration setter of the selected Front End Module must have been called first.
-
int32_t mpsl_fem_pa_configuration_clear(void)
Clears up the configuration provided by the mpsl_fem_pa_configuration_set function.
- Return values
0 – PA activation setup purge is successful.
-NRF_EPERM – PA is currently disabled.
-
int32_t mpsl_fem_lna_configuration_set(const mpsl_fem_event_t *const p_activate_event, const mpsl_fem_event_t *const p_deactivate_event)
Sets up LNA using the provided event for the upcoming radio reception.
Multiple configurations can be provided by repeating calls to this function (that is, you can set the activate and the deactivate event in multiple calls, and the configuration is preserved between calls).
The order of calls of this function and its
pa
counterpart must match the order of radio operations. I.e. if you want to listen first and then send the frame, you need first to issue mpsl_fem_lna_configuration_set and only after mpsl_fem_pa_configuration_set.If a mpsl_fem_event_type_t::MPSL_FEM_EVENT_TYPE_TIMER timer event is provided, the LNA will be configured to activate or deactivate at the application-configured time gap before the timer instance reaches the given register_value. The time gap is set via the corresponding configuration setter of the selected Front End Module.
If a mpsl_fem_event_type_t::MPSL_FEM_EVENT_TYPE_GENERIC event is provided, the LNA will be configured to activate or deactivate when an event occurs.
The function sets up the PPIs and the GPIOTE channel to activate LNA for the upcoming radio transmission. The LNA pin will be active until deactivated, which can happen either by encountering a configured deactivation event or by using mpsl_fem_deactivate_now.
Note
If a timer event is provided, the caller of this function is responsible for starting the timer and configuring its shorts. Moreover, the caller is responsible for stopping the timer no earlier than the compare channel of the lowest ID among the provided ones does expire.
Note
The activation event can be only of type mpsl_fem_event_type_t::MPSL_FEM_EVENT_TYPE_TIMER. Using other activation event type leads to undefined module behavior.
- Parameters
p_activate_event – [in] Pointer to the activation event structure.
p_deactivate_event – [in] Pointer to the deactivation event structure.
- Return values
0 – LNA activation setup is successful.
-NRF_EPERM – LNA is currently disabled.
-NRF_EINVAL – LNA activation setup could not be performed due to invalid or missing configuration parameters in p_activate_event or p_deactivate_event, or both.
- Pre
To activate LNA, the corresponding configuration setter of the selected Front End Module must have been called first.
-
int32_t mpsl_fem_lna_configuration_clear(void)
Clears up the configuration provided by the mpsl_fem_lna_configuration_set function.
- Return values
0 – LNA activate setup purge is successful.
-NRF_EPERM – LNA is currently disabled.
-
void mpsl_fem_deactivate_now(mpsl_fem_functionality_t type)
Deactivates PA/LNA with immediate effect.
Deactivates PA/LNA with immediate effect - contrary to mpsl_fem_lna_configuration_clear or mpsl_fem_pa_configuration_clear, which both just set up the infrastructure for events which shall disable the PA/LNA.
- Parameters
type – [in] Whether to deactivate imeediately PA, LNA, or both (see mpsl_fem_functionality_t).
-
int32_t mpsl_fem_abort_set(mpsl_subscribable_hw_event_t event, uint32_t group)
Instruct Front End Module to disable PA and LNA as soon as possible using the group following the event.
- Parameters
event – [in] An event which is triggered when the abort condition occurs. (See doc for mpsl_subscribable_hw_event_t type.)
group – [in] (D)PPI Group which shall be disabled when the abort event is triggered.
- Return values
0 – Setting of the abort sequence path is successful.
-NRF_EPERM – Setting of the abort sequence path could not be performed.
-
int32_t mpsl_fem_abort_extend(uint32_t channel_to_add, uint32_t group)
Adds one more PPI channel to the PPI Group prepared by the mpsl_fem_abort_set function.
- Parameters
channel_to_add – [in] (D)PPI channel to add to the (D)PPI group.
group – [in] The said PPI group.
- Return values
0 – Setting of the abort sequence path is successful.
-NRF_EPERM – Setting of the abort sequence path could not be performed.
-
int32_t mpsl_fem_abort_reduce(uint32_t channel_to_remove, uint32_t group)
Removes one PPI channel from the PPI Group prepared by the mpsl_fem_abort_set function.
- Parameters
channel_to_remove – [in] (D)PPI channel to remove from the (D)PPI group.
group – [in] The said PPI group.
- Return values
0 – Setting of the abort sequence path is successful.
-NRF_EPERM – Setting of the abort sequence path could not be performed.
-
int32_t mpsl_fem_abort_clear(void)
Clears up the configuration provided by the mpsl_fem_abort_set function.
- Return values
0 – Clearing of the abort sequence path is successful.
-NRF_EPERM – Clearing was not done - the possible reason is that there was nothing to clear.
-
void mpsl_fem_cleanup(void)
Cleans up the configured PA/LNA hardware resources.
The function resets the hardware that has been set up for the PA/LNA activation. The PA and LNA module control configuration parameters are not deleted. The function is intended to be called after the radio DISABLED signal.
-
int8_t mpsl_fem_tx_power_split(const mpsl_tx_power_t power, mpsl_tx_power_split_t *const p_tx_power_split, uint16_t freq_mhz)
Splits transmit power value into components to be applied on each stage on transmit path.
Note
If the exact value of
power
cannot be achieved, this function attempts to use less power to not exceed constraint.- Parameters
power – [in] TX power requested for transmission on air.
p_tx_power_split – [out] Components of tx_power to be applied for stages on transmit path. If requested
power
is too high, the split will be set to a value representing maximum achievable power. If the requestedpower
is too low, the split will be set to a value representing minimum achievable power.freq_mhz – [in] Frequency in MHz to calculate the split for.
- Returns
The power in dBm that will be achieved if values returned through
p_tx_power_split
are applied.
-
int32_t mpsl_fem_pa_gain_set(const mpsl_fem_gain_t *p_gain)
Sets PA gain.
Note
The gain set by this function will be applied to radio transmissions following the call. If the function is called during radio transmission or during ramp-up for transmission it is unspecified if the gain is applied.
- Parameters
p_gain – [in] Pointer to structure with data needed to apply the gain.
- Return values
0 – Gain setting has been applied successfully.
-NRF_EINVAL – Gain setting could not be applied. Provided
gain_setting
is invalid.
-
void mpsl_fem_pa_is_configured(int8_t *const p_gain)
Checks if the PA signaling is configured and enabled, and gets the configured gain in dB.
- Parameters
p_gain – [out] The configured gain in dB if PA is configured and enabled. If there is no PA present or the PA does not affect the signal gain, returns 0 dB.
-
void mpsl_fem_lna_is_configured(int8_t *const p_gain)
Returns LNA gain if the LNA signal is configured and enabled, 0 otherwise.
- Parameters
p_gain – [out] The configured gain in dB if LNA is configured and enabled. If there is no LNA present or the LNA does not affect the signal gain, returns 0 dB.
-
bool mpsl_fem_prepare_powerdown(NRF_TIMER_Type *p_instance, uint32_t compare_channel, uint32_t ppi_id, uint32_t event_addr)
Prepares the Front End Module to switch to the Power Down state.
- Deprecated:
This function is deprecated. Use mpsl_fem_disable instead.
This function makes sure the Front End Module shall be switched off in the appropriate time, using the hardware timer and its compare channel. The timer is owned by the protocol and must be started by the protocol. The timer stops after matching the provided compare channel (the call sets the short).
- Parameters
p_instance – [in] Timer instance that is used to schedule the transition to the Power Down state.
compare_channel – [in] Compare channel to hold a value for the timer.
ppi_id – [in] ID of the PPI channel used to switch to the Power Down state.
event_addr – [in] Address of the event which shall trigger the Timer start.
- Return values
true – Whether the scheduling of the transition was successful.
false – Whether the scheduling of the transition was not successful.
-
struct mpsl_fem_event_t
- #include <mpsl_fem_protocol_api.h>
MPSL Front End Module event.
Public Members
-
mpsl_fem_event_type_t type
Type of event source.
-
NRF_TIMER_Type *p_timer_instance
Pointer to a 1-us resolution timer instance.
-
uint32_t start
Timer value when the Front End Module can start preparing PA/LNA.
-
uint32_t end
Timer value at which the PA/LNA have to be prepared. Radio operation shall start at this point.
-
struct mpsl_fem_event_t.[anonymous].[anonymous].[anonymous] counter_period
Counter period parameters
-
uint8_t compare_channel_mask
Mask of the compare channels that can be used by the Front End Module to schedule its own tasks.
-
struct mpsl_fem_event_t.[anonymous].[anonymous] timer
Parameters when type is MPSL_FEM_EVENT_TYPE_TIMER.
-
mpsl_subscribable_hw_event_t event
Event triggerring required FEM operation.
-
struct mpsl_fem_event_t.[anonymous].[anonymous] generic
Parameters when type is MPSL_FEM_EVENT_TYPE_GENERIC.
-
union mpsl_fem_event_t.[anonymous] event
Implementation of the event.
-
mpsl_fem_event_type_t type
-
struct mpsl_tx_power_split_t
- #include <mpsl_fem_protocol_api.h>
Represents components of tx_power to be applied for stages on transmit path.
Public Members
-
mpsl_tx_power_t radio_tx_power
TX power to be applied to the RADIO peripheral.
-
mpsl_fem_gain_t fem
FEM gain.
-
mpsl_tx_power_t radio_tx_power
-
typedef uint8_t mpsl_subscribable_hw_event_t
MPSL FEM common configuration
- group mpsl_fem_config_common
The MPSL Front End Module Common Configuration defines structures common for every supported Front End Module.
Enums
-
enum mpsl_fem_pin_config_type_t
Values:
-
enumerator MPSL_FEM_PIN_CFG_TYPE_MPSL_FEM_PIN
New style configuration, specify mpsl_fem_pin_t.
-
enumerator MPSL_FEM_PIN_CFG_TYPE_PIN_PORT
Old style configuration, specify pin and port. Deprecated.
-
enumerator MPSL_FEM_PIN_CFG_TYPE_MPSL_FEM_PIN
Functions
-
void mpsl_fem_device_config_254_apply_set(bool apply)
Sets flag which determines whether DEVICE-CONFIG-254 shall be applied.
Note
This function shall be called before initialization of any protocol stack.
- Parameters
apply – [in] Whether the DEVICE-CONFIG-254 option shall be applied.
-
bool mpsl_fem_device_config_254_apply_get(void)
Gets flag which determines whether DEVICE-CONFIG-254 shall be applied.
- Return values
true – DEVICE-CONFIG-254 shall be applied.
false – DEVICE-CONFIG-254 shall not be applied.
-
struct mpsl_fem_pin_t
- #include <mpsl_fem_config_common.h>
GPIO pin and port to be used by Front End Module.
-
struct mpsl_fem_gpiote_pin_config_t
- #include <mpsl_fem_config_common.h>
Configuration parameters for pins that enable or disable (or both) either Power Amplifier (PA) or Low Noise Amplifier (LNA).
Public Members
-
mpsl_fem_pin_config_type_t cfg_type
Pin configuration type. This field is deprecated and will be removed.
-
NRF_GPIO_Type *p_port
GPIO port register address.
-
uint8_t gpio_port_no
GPIO port number.
-
uint8_t gpio_port_pin
GPIO pin number relative to the port.
-
mpsl_fem_pin_t gpio_pin
GPIO port number, register address and pin number relative to the port.
-
bool enable
Enable toggling for this pin.
-
bool active_high
If true, the pin will be active high. Otherwise, the pin will be active low.
-
uint8_t gpiote_ch_id
The GPIOTE channel used for toggling this pin.
-
mpsl_fem_pin_config_type_t cfg_type
-
struct mpsl_fem_gpio_pin_config_t
- #include <mpsl_fem_config_common.h>
Configuration parameters for pins that enable or disable (or both) either Power Amplifier (PA) or Low Noise Amplifier (LNA).
Public Members
-
mpsl_fem_pin_config_type_t cfg_type
Pin configuration type. This field is deprecated and will be removed.
-
NRF_GPIO_Type *p_port
GPIO port register address.
-
uint8_t gpio_port_no
GPIO port number.
-
uint8_t gpio_port_pin
GPIO pin number relative to the port.
-
mpsl_fem_pin_t gpio_pin
GPIO port number, register address and pin number relative to the port.
-
bool enable
Enable toggling for this pin.
-
bool active_high
If true, the pin will be active high. Otherwise, the pin will be active low.
-
mpsl_fem_pin_config_type_t cfg_type
-
enum mpsl_fem_pin_config_type_t
MPSL FEM common nRF21540 configuration
- group mpsl_fem_nrf21540_common
Defines
-
MPSL_FEM_NRF21540_DEFAULT_PA_TIME_IN_ADVANCE_US
Time in microseconds when PA GPIO is activated before the radio is ready for transmission.
-
MPSL_FEM_NRF21540_DEFAULT_LNA_TIME_IN_ADVANCE_US
Time in microseconds when LNA GPIO is activated before the radio is ready for reception.
-
MPSL_FEM_NRF21540_DEFAULT_PDN_SETTLE_US
Time in microseconds between activating the PDN and asserting the RX_EN/TX_EN.
-
MPSL_FEM_NRF21540_DEFAULT_TRX_HOLD_US
Time in microseconds between deasserting the RX_EN/TX_EN and deactivating PDN.
-
MPSL_FEM_NRF21540_PA_POUTA_DEFAULT_GAIN_DB
Gain of the PA in dB when using POUTA.
-
MPSL_FEM_NRF21540_PA_POUTB_DEFAULT_GAIN_DB
Gain of the PA in dB when using POUTB.
-
MPSL_FEM_NRF21540_PA_DEFAULT_GAIN_DB
Default gain of the PA in dB.
-
MPSL_FEM_NRF21540_LNA_DEFAULT_GAIN_DB
Gain of the LNA in dB.
-
struct mpsl_fem_nrf21540_config_t
- #include <mpsl_fem_config_nrf21540_common.h>
Configuration structure of the nRF21540 Front End Module.
Public Members
-
uint32_t pa_time_gap_us
Time in microseconds between the activation of the PA pin and the start of the radio transmission. Should be no bigger than Radio Ramp-Up time.
-
uint32_t lna_time_gap_us
Time in microseconds between the activation of the LNA pin and the start of the radio reception. Should be no bigger than Radio Ramp-Up time.
-
uint32_t pdn_settle_us
Time in microseconds between activating the PDN pin and activating the PA/LNA pin.
-
uint32_t trx_hold_us
Time in microseconds between deactivating the PA/LNA pin and deactivating the PDN pin.
-
int8_t pa_gain_db
Default PA gain in dB. Ignored if the amplifier is not supporting this feature.
-
int8_t pa_gains_db[2]
Available PA gains in dB.
pa_gains_db
[0] corresponds to POUTA andpa_gains_db
[1] to POUTB.
-
int8_t lna_gain_db
Configurable LNA gain in dB. Ignored if the amplifier is not supporting this feature.
-
uint32_t pa_time_gap_us
-
MPSL_FEM_NRF21540_DEFAULT_PA_TIME_IN_ADVANCE_US
MPSL FEM nRF21540 GPIO
- group mpsl_fem_nrf21540_gpio
Functions
-
int32_t mpsl_fem_nrf21540_gpio_interface_config_set(mpsl_fem_nrf21540_gpio_interface_config_t const *const p_config)
Configures the PA and LNA device interface.
This function sets device interface parameters for the PA/LNA module. The module can then be used to control PA or LNA (or both) through the given interface and resources.
The function also sets the PPI and GPIOTE channels to be configured for the PA/LNA interface.
- Parameters
p_config – [in] Pointer to the interface parameters for the PA/LNA device.
- Return values
0 – PA/LNA control successfully configured.
-NRF_EPERM – PA/LNA control configuration error.
-
struct mpsl_fem_nrf21540_gpio_interface_config_t
- #include <mpsl_fem_config_nrf21540_gpio.h>
Configuration parameters for the Power Amplifier (PA) and Low Noise Amplifier (LNA) interface in the nRF21540 GPIO variant.
Public Members
-
mpsl_fem_nrf21540_config_t fem_config
nRF21540 parameters configuration.
-
mpsl_fem_gpiote_pin_config_t pa_pin_config
PA pin configuration.
-
mpsl_fem_gpiote_pin_config_t lna_pin_config
LNA pin configuration.
-
mpsl_fem_gpiote_pin_config_t pdn_pin_config
PDN pin configuration.
-
mpsl_fem_gpio_pin_config_t mode_pin_config
MODE pin configuration. To enable runtime MODE pin switching
mode_pin_config.enable
must be set to true. Thefem_config.pa_gains_db
must contain correct values corresponding to POUTA and POUTB gains then.
-
uint8_t dppi_channels[4]
Array of DPPI channels which need to be provided to Front End Module to operate.
-
uint8_t egu_instance_no
Number of EGU instance for which
egu_channels
apply.
-
uint8_t egu_channels[3]
Array of EGU channels (belonging to EGU instance number
egu_instance_no
) which need to be provided to Front End Module to operate.
-
mpsl_fem_nrf21540_config_t fem_config
-
int32_t mpsl_fem_nrf21540_gpio_interface_config_set(mpsl_fem_nrf21540_gpio_interface_config_t const *const p_config)
MPSL FEM nRF21540 GPIO/SPI
- group mpsl_fem_nrf21540_gpio_spi
Functions
-
int32_t mpsl_fem_nrf21540_gpio_spi_interface_config_set(mpsl_fem_nrf21540_gpio_spi_interface_config_t const *const p_config)
Configures the PA and LNA device interface.
This function sets device interface parameters for the PA/LNA module. The module can then be used to control PA or LNA (or both) through the given interface and resources.
The function also sets the PPI and GPIOTE channels to be configured for the PA/LNA interface as well as SPI interface to be used.
- Parameters
p_config – [in] Pointer to the interface parameters for the PA/LNA device.
- Return values
0 – PA/LNA control successfully configured.
-NRF_EPERM – PA/LNA control configuration error.
-
struct mpsl_fem_spi_config_t
- #include <mpsl_fem_config_nrf21540_gpio_spi.h>
SPI interface.
Public Members
-
NRF_SPIM_Type *p_spim
Pointer to the SPI peripheral instance to be used.
-
mpsl_fem_pin_t mosi_pin
MOSI pin.
-
mpsl_fem_pin_t miso_pin
MISO pin.
-
mpsl_fem_pin_t sck_pin
SCK pin.
-
mpsl_fem_gpiote_pin_config_t cs_pin_config
CS pin.
-
NRF_SPIM_Type *p_spim
-
struct mpsl_fem_nrf21540_gpio_spi_interface_config_t
- #include <mpsl_fem_config_nrf21540_gpio_spi.h>
Configuration parameters for the Power Amplifier (PA), the Low Noise Amplifier (LNA) and the SPI interface in the nRF21540 GPIO/SPI variant.
Public Members
-
mpsl_fem_nrf21540_config_t fem_config
nRF21540 parameters configuration.
-
mpsl_fem_gpiote_pin_config_t pa_pin_config
PA pin configuration.
-
mpsl_fem_gpiote_pin_config_t lna_pin_config
LNA pin configuration.
-
mpsl_fem_gpiote_pin_config_t pdn_pin_config
PDN pin configuration.
-
mpsl_fem_gpio_pin_config_t mode_pin_config
MODE pin configuration.
-
mpsl_fem_spi_config_t spi_config
SPI interface configuration.
-
uint8_t dppi_channels[6]
Array of DPPI channels which need to be provided to Front End Module to operate.
-
uint8_t egu_instance_no
Number of EGU instance for which
egu_channels
apply.
-
uint8_t egu_channels[5]
Array of EGU channels (belonging to EGU instance number
egu_instance_no
) which need to be provided to Front End Module to operate.
-
bool pa_gain_runtime_control
Flag that indicates if PA gain should be changeable in runtime. If this flag is set,
fem_config.pa_gains_db
must contain correct values corresponding to POUTA and POUTB gains. Otherwise, PA gain is considered constant. In both cases there are SPI transfers performed to the nRF21540, so the SPI interface must be configured and operable.
-
mpsl_fem_nrf21540_config_t fem_config
-
int32_t mpsl_fem_nrf21540_gpio_spi_interface_config_set(mpsl_fem_nrf21540_gpio_spi_interface_config_t const *const p_config)
MPSL FEM Simple GPIO
- group mpsl_fem_simple_gpio
Defines
-
MPSL_FEM_SIMPLE_GPIO_DEFAULT_PA_TIME_IN_ADVANCE_US
Simple GPIO Front End Module Timings.
A Simple GPIO Front End Module may be used with all Front End Modules which use one wire for PA and one wire for LNA. The timing restrictions should be obtained from its corresponding datasheet. Time in microseconds when PA GPIO is activated before the radio is ready for transmission.
-
MPSL_FEM_SIMPLE_GPIO_DEFAULT_LNA_TIME_IN_ADVANCE_US
Time in microseconds when LNA GPIO is activated before the radio is ready for reception.
-
MPSL_FEM_SIMPLE_GPIO_PA_DEFAULT_GAIN_DB
Simple GPIO Front End Module Gains.
A Simple GPIO Front End Module may be used with all Front End Modules which use one wire for PA and one wire for LNA. The gains should be obtained from its corresponding datasheet. Gain of the PA in dB.
-
MPSL_FEM_SIMPLE_GPIO_LNA_DEFAULT_GAIN_DB
Gain of the LNA in dB.
Functions
-
int32_t mpsl_fem_simple_gpio_interface_config_set(mpsl_fem_simple_gpio_interface_config_t const *const p_config)
Configures the PA and LNA device interface.
This function sets device interface parameters for the PA/LNA module. The module can then be used to control PA or LNA (or both) through the given interface and resources.
The function also sets the PPI and GPIOTE channels to be configured for the PA/LNA interface.
- Parameters
p_config – [in] Pointer to the interface parameters for the PA/LNA device.
- Return values
0 – PA/LNA control successfully configured.
-NRF_EPERM – PA/LNA is not available.
-
struct mpsl_fem_simple_gpio_interface_config_t
- #include <mpsl_fem_config_simple_gpio.h>
Configuration parameters for the Front End Module Simple GPIO variant.
A Simple GPIO Front End Module may be used with all Front End Modules which use one wire for a Power Amplifier (PA) and one wire for a Linear Noise Amplifier (LNA).
Public Members
-
uint32_t pa_time_gap_us
Time between the activation of the PA pin and the start of the radio transmission. Should be no bigger than Radio Ramp-Up time.
-
uint32_t lna_time_gap_us
Time between the activation of the LNA pin and the start of the radio reception. Should be no bigger than Radio Ramp-Up time.
-
int8_t pa_gain_db
Configurable PA gain. Ignored if the amplifier is not supporting this feature.
-
int8_t lna_gain_db
Configurable LNA gain. Ignored if the amplifier is not supporting this feature.
-
struct mpsl_fem_simple_gpio_interface_config_t.[anonymous] fem_config
Configration structure of the Simple GPIO Front End Module.
-
mpsl_fem_gpiote_pin_config_t pa_pin_config
Power Amplifier pin configuration.
-
mpsl_fem_gpiote_pin_config_t lna_pin_config
Low Noise Amplifier pin configuration.
-
uint8_t dppi_channels[3]
Array of DPPI channels which need to be provided to Front End Module to operate.
-
uint8_t egu_instance_no
Number of EGU instance for which
egu_channels
apply.
-
uint8_t egu_channels[3]
Array of EGU channels (belonging to EGU instance number
egu_instance_no
) which need to be provided to Front End Module to operate.
-
uint32_t pa_time_gap_us
-
MPSL_FEM_SIMPLE_GPIO_DEFAULT_PA_TIME_IN_ADVANCE_US
IEEE 802.15.4 External Radio Coexistence
- group mpsl_cx
This module provides the interface for the protocols to communicate with a coexistence arbitrator, Packet Traffic Arbitrator, PTA.
Concurrency model of this module: Each function defined in this interface may be called from any execution context (thread, including preemptive thread in operating system, or handler). However, none of the functions is re-entrant. It is responsibility of API user to ensure that even if one function is preempted by other execution context, the other execution context does not call preempted function.
It is not allowed to call a function defined in this module while the same function is called from another preempted context. It is allowed to call any function defined in this module while any other is preempted. It is allowed to call any function defined in this module from mpsl_cx_cb_t implementation. Callback function mpsl_cx_cb_t called from this module may be called from thread or handler context. But it never preempts itself.
Typedefs
-
typedef uint8_t mpsl_cx_op_map_t
Bitmap representing a list of radio operations.
Logical OR of radio operations defined in mpsl_cx_op_t.
-
typedef uint8_t mpsl_cx_prio_t
Priority of given radio operation.
This numerical value is translated by given PTA interface driver to appropriate signal. The straightforward translation would be <= UINT8_MAX/2 is low priority, while > UINT8_MAX/2 is high priority. More complicated PTAs support more than 2 priority levels and valid matching must be implemented for such devices.
Priority values must be aligned between all users of this API in given system. When multiple radio protocols are enabled (like Bluetooth LE and IEEE 802.15.4), all protocols must use aligned values (Bluetooth low priority operations must use numerically lower value than IEEE 802.15.4 high priority operations).
-
typedef void (*mpsl_cx_cb_t)(mpsl_cx_op_map_t granted_ops)
Callback used to notify radio protocol about changes of granted radio operations.
- Param granted_ops
[in] List of all operations currently allowed by PTA.
Enums
-
enum mpsl_cx_op_t
Radio operations which may be requested from or granted by PTA.
Values:
-
enumerator MPSL_CX_OP_IDLE_LISTEN
Listening for asynchronous transmissions
-
enumerator MPSL_CX_OP_RX
Active reception
This value may be used to indicate:
RX window:
in BLE connection event
802.15.4 CSL
…
Detected a frame transmitted asynchronously:
during BLE scanning
during 802.15.4 idle listening
…
-
enumerator MPSL_CX_OP_TX
Active transmission
-
enumerator MPSL_CX_OP_IDLE_LISTEN
-
enum mpsl_cx_req_trig_t
Coexistence request signal triggers.
Values:
-
enumerator MPSL_CX_REQ_TRIG_INSTANT
Request is triggered instantly, during mpsl_cx_request call.
-
enumerator MPSL_CX_REQ_TRIG_INSTANT
Functions
-
int32_t mpsl_cx_request(const mpsl_cx_request_t *p_req_params)
Request radio operation from PTA.
This function is to be called before transceiver is enabled to inform PTA about planned radio operation which is about to start and about the priority of this operation.
Each call of this function overrides the last request.
This function is usually called shortly before scheduled radio operations, or just after detection of asynchronous events indicating radio operations.
Call to this function cannot preempt a call to mpsl_cx_release. It is responsibility of user of this interface to prevent such preemption.
- Parameters
p_req_params – [in] Pointer to a structure containing parameters of given request.
- Return values
0 – Requested radio operation from PTA
-EINVAL – Incorrect value of any field in
p_req_params
orp_req_params
is NULL.
-
int32_t mpsl_cx_release(void)
Release last radio operation requested from PTA.
This function is to be called after transceiver is disabled to inform PTA that any previously requested operations by mpsl_cx_request are not requested anymore.
This function releases requested radio operations immediately.
Call to this function cannot preempt a call to mpsl_cx_request. It is responsibility of user of this interface to prevent such preemption.
- Return values
0 – Last request is released.
-EALREADY – There was no request to release.
-
int32_t mpsl_cx_granted_ops_get(mpsl_cx_op_map_t *p_granted_ops)
Get list of radio operations currently granted by PTA.
Note
PTA may change granted radio operations list at any time. It is possible that value returned by this function is outdated before the function ends its execution.
- Parameters
p_granted_ops – [out] Map of granted radio operations.
- Return values
0 – List of granted radio operations is stored in the passed memory address.
-EINVAL –
granted_ops
is NULL pointer.
-
uint32_t mpsl_cx_req_grant_delay_get(void)
Get time PTA needs to respond with grant signal to request signal.
There are three ways to manage the grant signal by PTA:
Keep grant signal in denied state by default and provide grant only after request. The maximum delay between request and grant signal is known.
Keep grant signal in approved state by default and deny only if given request cannot be accepted. Radio is not allowed to start any operation for known time after the request signal is set. After this delay the grant signal can indicate denial anytime to prevent or to abort radio operation.
Manage the granted signal constantly, even if there is no request from given radio.
This function is to be used to verify how long the user of this interface should wait from calling mpsl_cx_request (return from function) to mpsl_cx_granted_ops_get (call to function) to prevent getting false results while PTA is responding to the last request.
- Return values
>0 – Minimal delay from setting the request signal to the time grant signal gets meaningful value. In microseconds, rounded up
0 – Grant signal has always meaningful value. Can be checked before, during, or after setting the request signal.
-
int32_t mpsl_cx_register_callback(mpsl_cx_cb_t cb)
Register callback function called when radio operations granted by PTA change.
This function is used by radio protocols that require CPU processing when list of granted operations changes. One example is a protocol waiting with asynchronous transmission until TX operation is granted.
When radio protocol stops using Coexistence interface to hand it over to another protocol, it shall reset callback by calling this function with NULL value passed in
cb
.- Parameters
cb – [in] Pointer to a callback function called when radio operations granted by PTA change. If NULL, callback function is reset and nothing is called when granted radio operations change.
- Return values
0 – Successfully set or reset callback function.
-
struct mpsl_cx_request_t
- #include <mpsl_cx_protocol_api.h>
Structure with parameters describing next coexistence request.
Public Members
-
mpsl_cx_op_map_t ops
List of requested radio operations.
-
mpsl_cx_prio_t prio
Priority of requested radio operation.
-
mpsl_cx_req_trig_t trigger
When request is to be triggered.
-
mpsl_cx_op_map_t ops
-
typedef uint8_t mpsl_cx_op_map_t
Bluetooth External Radio Coexistence
- group mpsl_coex
This module provides the necessary interface for communication between the Bluetooth stack and a Packet Traffic Arbitrator.
Defines
-
MPSL_COEX_ESCALATION_THRESHOLD_OFF
Setting for coexistence interface API to switch off escalation.
Typedefs
-
typedef void mpsl_coex_on_complete_callback_t(void)
Type of callback invoked from coexistence interface upon completion of enable or disable procedure. The callback must accept calls in both high- and low-priority threads.
Enums
-
enum MPSL_COEX_PRIORITY
Possible priorities to handle related BLE event.
Values:
-
enumerator MPSL_COEX_PRIORITY_LOW
Low priority for the related coexistence interface event.
-
enumerator MPSL_COEX_PRIORITY_HIGH
High priority for the related coexistence interface event.
-
enumerator MPSL_COEX_PRIORITY_NUMBER
Number of priorities in the coexistence interface.
-
enumerator MPSL_COEX_PRIORITY_LOW
-
enum mpsl_coex_if_id_t
Ids of the supported coexistence interfaces.
Values:
-
enumerator MPSL_COEX_802152_3WIRE_GPIOTE_ID
3-wire GPIO coexistence interface based on IEEE 802.15.2-2003, subclause 6. To support this interface, mpsl_coex_support_802152_3wire_gpiote_if() must be called.
-
enumerator MPSL_COEX_1WIRE_GPIOTE_ID
1-wire GPIO coexistence interface. To support this interface, mpsl_coex_support_1wire_gpiote_if() must be called.
-
enumerator MPSL_COEX_802152_3WIRE_GPIOTE_ID
-
enum mpsl_coex_1wire_concurrency_mode_t
Concurrency mode with the external modem supported by 1-wire coexistence.
Values:
-
enumerator MPSL_COEX_1WIRE_CONCURRENCY_NONE
1-wire configuration to allow no concurrency with the external modem.
-
enumerator MPSL_COEX_1WIRE_CONCURRENCY_RX_ONLY
1-wire configuration to allow RX only concurrency with the external modem.
-
enumerator MPSL_COEX_1WIRE_CONCURRENCY_NONE
Functions
-
void mpsl_coex_support_802152_3wire_gpiote_if(void)
Enable support for the 802.15.2 3-Wire coexistence interface.
After this API is called, it is possible to configure MPSL with the coexistence interface MPSL_COEX_802152_3WIRE_GPIOTE_ID.
-
void mpsl_coex_support_1wire_gpiote_if(void)
Enable support for the 1-Wire coexistence interface.
After this API is called, it is possible to configure MPSL with the coexistence interface MPSL_COEX_1WIRE_GPIOTE_ID.
-
int32_t mpsl_coex_enable(const mpsl_coex_if_t *p_cfg, mpsl_coex_on_complete_callback_t enable_complete_callback)
Configures and enables the coexistence interface.
Note
The function configures the interface and maps the other interface functions on exact coexistence implementation
- Parameters
p_cfg – [in] Pointer to coexistence interface configuration structure. Any configuration with if_id set to MPSL_COEX_IDS_NUMBER is invalid.
enable_complete_callback – [in] Callback to be invoked when the coexistence interface completes the enabling procedure. The callback must accept calls in both high- and low-priority threads.
- Return values
0 – The configuration for the coexistence interface was successfully set and the enabling procedure operation was initiated. The supplied callback will be called when the enabling procedure is completed.
-NRF_EINVAL – Invalid configuration or NULL callback provided.
-NRF_EAGAIN – Enabling was not allowed at the time because the coexistence interface was already enabled or in an ongoing enable or disable procedure. The call aborted without any effect.
-NRF_EOPNOTSUPP – The provided interface is not supported. All interfaces must be explicitly enabled. See mpsl_coex_if_id_t.
-
int32_t mpsl_coex_disable(mpsl_coex_on_complete_callback_t disable_complete_callback)
Disables the coexistence interface.
This releases all peripherals supplied to mpsl_coex_enable for application use. The released GPIOs will be reset to high-impedance mode with no pull.
- Parameters
disable_complete_callback – [in] Callback to be invoked when coexistence interface completes the disabling procedure. The callback must accept calls in both high- and low-priority threads.
- Return values
0 – The disabling procedure for the coexistence interface was initiated. The supplied callback will be called when the disable procedure is completed.
-NRF_EAGAIN – Disabling was not allowed at the time because the coexistence interface was already disabled or in an ongoing enable or disable procedure. The call aborted without any effect.
-NRF_EINVAL – Invalid NULL callback provided.
-
struct mpsl_coex_gpiote_cfg_t
- #include <mpsl_coex.h>
Configuration parameters for one wire of the 3-wire coexistence interface GPIOTE based interface.
-
struct mpsl_coex_802152_3wire_gpiote_if_t
- #include <mpsl_coex.h>
GPIOs configuration for 3-wire coexistence arbitrator.
3-wire coexistence protocol applies the packet traffic arbitration recommendation based on IEEE Std 802.15.2-2003, subclause 6. 3-wire interface is exposed by following signals: REQUEST - Asserted whenever the user of MPSL wants to transmit or receive. The signal must remain asserted till the end of TX/RX or the request is rejected by PTA controller. PRI_STATUS - Asserted to indicate the priority (high or low) of the intended traffic immediately following REQUEST. After that, it is changed to indicate TX or RX. GRANT - Asserted to indicate whether the request is granted or rejected.
The request is made at
type_delay_us
+radio_delay_us
before the radio activity starts. The Priority and Status line will first indicate the priority of the request, then aftertype_delay_us
, it’ll switch to showing the type of transaction (RX/TX). The radio will start transmitting or receivingradio_delay_us
after this. Sum oftype_delay_us
+radio_delay_us
cannot be more than 40us due to radio ramp-up time.Public Members
-
mpsl_coex_gpiote_cfg_t request_cfg
Request line configuration.
-
mpsl_coex_gpiote_cfg_t priority_cfg
Priority and Status line configuration.
-
mpsl_coex_gpiote_cfg_t grant_cfg
Grant line configuration.
-
uint8_t additional_ppi_ch_id
PPI channel used to set the priority level at the correct time. Since Priority and Status are combined functional, it requires separate PPI channel to handle both.
-
uint8_t is_rx_active_level
Since Priority and Status are combined functional, the signal of the high priority is active level on the pin. Which active level to use for the RX/TX signal is set by this variable.
-
uint32_t type_delay_us
Delay in us from the request pin is raised until the Priority and Status line shows the type of transaction (RX/TX).
-
uint32_t radio_delay_us
Delay in us from the Priority and Status line shows the type of transaction, to the radio starts its on-air activity.
-
NRF_TIMER_Type *p_timer_instance
Pointer to a timer instance. Timer should not be shared with any other functionality.
-
mpsl_coex_gpiote_cfg_t request_cfg
-
struct mpsl_coex_1wire_gpiote_if_t
- #include <mpsl_coex.h>
GPIOs configuration for 1-wire coexistence arbitrator.
1-wire interface is exposed by following signals: GRANT - Asserted to indicate whether the external modem is active.
Public Members
-
mpsl_coex_gpiote_cfg_t grant_cfg
Grant line configuration.
-
mpsl_coex_1wire_concurrency_mode_t concurrency_mode
Concurrency mode configuration.
-
mpsl_coex_gpiote_cfg_t grant_cfg
-
struct mpsl_coex_if_t
- #include <mpsl_coex.h>
Configuration of the coexistence interface.
This option configures MPSL to support interface for requesting and granting access to the media and status notification in case of coexistence with another wireless standard.
Public Members
-
mpsl_coex_if_id_t if_id
Identification number of configured interface.
-
mpsl_coex_802152_3wire_gpiote_if_t coex_3wire_gpiote
Configuration parameters of 3-wire GPIO based coexistence.
-
mpsl_coex_1wire_gpiote_if_t coex_1wire_gpiote
Configuration parameters of 1-wire GPIO based coexistence.
-
union mpsl_coex_if_t.[anonymous] interfaces
Union with supported coexistence interfaces.
-
mpsl_coex_if_id_t if_id
-
MPSL_COEX_ESCALATION_THRESHOLD_OFF
MPSL Temp
- group mpsl_temp
The MPSL temperature sensor interface provides APIs for measuring the chip temperature.
Functions
-
int32_t mpsl_temperature_get(void)
Get the temperature measured on the chip.
This function will block until the temperature measurement is done. It takes around 50 us from call to return.
- Returns
Result of temperature measurement. Die temperature in 0.25 degrees Celsius.
-
int32_t mpsl_temperature_get(void)
MPSL DPPI Protocol
- group mpsl_dppi_protocol_api
API for fixed DPPI channel.
Fixed DPPI channels are DPPI channels where a publisher or subscriber remain attached to the channel for the entire duration of a radio event. This allows the application to add additional subscribers to channels that have a fixed publisher. For example, the application can configure a pin to toggle on every transaction by connecting NRF_GPIOTE->SUBSCRIBE_OUT[i] to MPSL_DPPI_RADIO_PUBLISH_READY_CHANNEL_IDX or NRF_GPIOTE->SUBSCRIBE_OUT[i] to MPSL_DPPI_RADIO_PUBLISH_DISABLED_CH_IDX.
Defines
-
MPSL_DPPI_RADIO_PUBLISH_READY_CHANNEL_IDX
Fixed channel for NRF_RADIO->PUBLISH_READY.
-
MPSL_DPPI_RADIO_PUBLISH_ADDRESS_CHANNEL_IDX
Fixed channel for NRF_RADIO->PUBLISH_ADDRESS.
-
MPSL_DPPI_RADIO_PUBLISH_END_CHANNEL_IDX
Fixed channel for NRF_RADIO->PUBLISH_END.
-
MPSL_DPPI_RADIO_PUBLISH_DISABLED_CH_IDX
Fixed channel for NRF_RADIO->PUBLISH_DISABLED.
-
MPSL_DPPI_RADIO_PUBLISH_PHYEND_CHANNEL_IDX
Fixed channel for NRF_RADIO->PUBLISH_PHYEND.
-
MPSL_DPPI_RADIO_SUBSCRIBE_DISABLED_CHANNEL_IDX
Fixed channel for NRF_RADIO->SUBSCRIBE_DISABLE. Publishing to this channel will result in undefined behavior.
-
MPSL_DPPI_RADIO_PUBLISH_READY_CHANNEL_IDX