Skip to content

Commit 2575c5f

Browse files
authored
Merge pull request #306 from ARMmbed/ble
Import (again) BLE branch into mainline
2 parents 2a0451e + f3c7597 commit 2575c5f

File tree

97 files changed

+33219
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+33219
-0
lines changed

bluetooth/ble/ble/services/EddystoneConfigService.h

Lines changed: 542 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright (c) Nordic Semiconductor ASA
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without modification,
6+
* are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* 2. Redistributions in binary form must reproduce the above copyright notice, this
12+
* list of conditions and the following disclaimer in the documentation and/or
13+
* other materials provided with the distribution.
14+
*
15+
* 3. Neither the name of Nordic Semiconductor ASA nor the names of other
16+
* contributors to this software may be used to endorse or promote products
17+
* derived from this software without specific prior written permission.
18+
*
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
24+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*
31+
*/
32+
33+
#include "ble_radio_notification.h"
34+
#include <stdlib.h>
35+
36+
37+
static bool m_radio_active = false; /**< Current radio state. */
38+
static ble_radio_notification_evt_handler_t m_evt_handler = NULL; /**< Application event handler for handling Radio Notification events. */
39+
40+
41+
void SWI1_IRQHandler(void)
42+
{
43+
m_radio_active = !m_radio_active;
44+
if (m_evt_handler != NULL)
45+
{
46+
m_evt_handler(m_radio_active);
47+
}
48+
}
49+
50+
51+
uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority,
52+
nrf_radio_notification_distance_t distance,
53+
ble_radio_notification_evt_handler_t evt_handler)
54+
{
55+
uint32_t err_code;
56+
57+
m_evt_handler = evt_handler;
58+
59+
// Initialize Radio Notification software interrupt
60+
err_code = sd_nvic_ClearPendingIRQ(SWI1_IRQn);
61+
if (err_code != NRF_SUCCESS)
62+
{
63+
return err_code;
64+
}
65+
66+
err_code = sd_nvic_SetPriority(SWI1_IRQn, irq_priority);
67+
if (err_code != NRF_SUCCESS)
68+
{
69+
return err_code;
70+
}
71+
72+
err_code = sd_nvic_EnableIRQ(SWI1_IRQn);
73+
if (err_code != NRF_SUCCESS)
74+
{
75+
return err_code;
76+
}
77+
78+
// Configure the event
79+
return sd_radio_notification_cfg_set(NRF_RADIO_NOTIFICATION_TYPE_INT_ON_BOTH, distance);
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) Nordic Semiconductor ASA
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without modification,
6+
* are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice, this
9+
* list of conditions and the following disclaimer.
10+
*
11+
* 2. Redistributions in binary form must reproduce the above copyright notice, this
12+
* list of conditions and the following disclaimer in the documentation and/or
13+
* other materials provided with the distribution.
14+
*
15+
* 3. Neither the name of Nordic Semiconductor ASA nor the names of other
16+
* contributors to this software may be used to endorse or promote products
17+
* derived from this software without specific prior written permission.
18+
*
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
24+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
*
31+
*/
32+
33+
/** @file
34+
*
35+
* @defgroup ble_radio_notification Radio Notification Event Handler
36+
* @{
37+
* @ingroup ble_sdk_lib
38+
* @brief Module for propagating Radio Notification events to the application.
39+
*/
40+
41+
#ifndef BLE_RADIO_NOTIFICATION_H__
42+
#define BLE_RADIO_NOTIFICATION_H__
43+
44+
#include <stdint.h>
45+
#include <stdbool.h>
46+
#include "nrf_soc.h"
47+
48+
/**@brief Application radio notification event handler type. */
49+
typedef void (*ble_radio_notification_evt_handler_t) (bool radio_active);
50+
51+
/**@brief Function for initializing the Radio Notification module.
52+
*
53+
* @param[in] irq_priority Interrupt priority for the Radio Notification interrupt handler.
54+
* @param[in] distance The time from an Active event until the radio is activated.
55+
* @param[in] evt_handler Handler to be executed when a radio notification event has been
56+
* received.
57+
*
58+
* @return NRF_SUCCESS on successful initialization, otherwise an error code.
59+
*/
60+
uint32_t ble_radio_notification_init(nrf_app_irq_priority_t irq_priority,
61+
nrf_radio_notification_distance_t distance,
62+
ble_radio_notification_evt_handler_t evt_handler);
63+
64+
#endif // BLE_RADIO_NOTIFICATION_H__
65+
66+
/** @} */

0 commit comments

Comments
 (0)