Skip to content

Commit e2ae84e

Browse files
authored
Merge pull request #8876 from donatieng/public_pr_cordio_nordic_ll
Add support for Cordio to NRF52 Devices
2 parents c0108b1 + c998248 commit e2ae84e

File tree

342 files changed

+20766
-15
lines changed

Some content is hidden

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

342 files changed

+20766
-15
lines changed

features/FEATURE_BLE/ble/pal/GapEvents.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ struct GapAdvertisingReportEvent : public GapEvent {
306306
struct advertising_t {
307307
received_advertising_type_t type;
308308
connection_peer_address_type_t address_type;
309-
const address_t& address;
309+
address_t address;
310310
ArrayView<const uint8_t> data;
311311
int8_t rssi;
312312
};

features/FEATURE_BLE/targets/TARGET_CORDIO/CordioBLE.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "ble/generic/GenericGap.h"
3232
#include "ble/generic/GenericSecurityManager.h"
3333
#include "SimpleEventQueue.h"
34+
#include "Timer.h"
3435

3536
namespace ble {
3637
namespace vendor {
@@ -153,6 +154,8 @@ class BLE : public ::BLEInstanceBase {
153154

154155
::BLE::InstanceID_t instanceID;
155156
mutable SimpleEventQueue _event_queue;
157+
mbed::Timer _timer;
158+
uint64_t _last_update_us;
156159

157160
class SigningEventMonitorProxy : public pal::SigningEventMonitor {
158161
public:

features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "mbed.h"
1818
#include "us_ticker_api.h"
1919
#include "BLE.h"
20+
#include "CriticalSectionLock.h"
2021
#include "wsf_types.h"
2122
#include "wsf_msg.h"
2223
#include "wsf_os.h"
@@ -95,10 +96,11 @@ namespace cordio {
9596
BLE::BLE(CordioHCIDriver& hci_driver) :
9697
initialization_status(NOT_INITIALIZED),
9798
instanceID(::BLE::DEFAULT_INSTANCE),
98-
_event_queue()
99+
_event_queue(),
100+
_last_update_us(0)
99101
{
100102
_hci_driver = &hci_driver;
101-
stack_setup();
103+
102104
}
103105

104106
BLE::~BLE() { }
@@ -120,6 +122,8 @@ ble_error_t BLE::init(
120122
{
121123
switch (initialization_status) {
122124
case NOT_INITIALIZED:
125+
_timer.reset();
126+
_timer.start();
123127
_event_queue.initialize(this, instanceID);
124128
_init_callback = initCallback;
125129
start_stack_reset();
@@ -389,6 +393,7 @@ void BLE::stack_setup()
389393
void BLE::start_stack_reset()
390394
{
391395
_hci_driver->initialize();
396+
stack_setup();
392397
DmDevReset();
393398
}
394399

@@ -397,20 +402,22 @@ void BLE::callDispatcher()
397402
// process the external event queue
398403
_event_queue.process();
399404

400-
// follow by stack events
401-
static uint32_t lastTimeUs = us_ticker_read();
402-
uint32_t currTimeUs, deltaTimeMs;
405+
_last_update_us += (uint64_t)_timer.read_high_resolution_us();
406+
_timer.reset();
403407

404-
// Update the current cordio time
405-
currTimeUs = us_ticker_read();
406-
deltaTimeMs = (currTimeUs - lastTimeUs) / 1000;
407-
if (deltaTimeMs > 0) {
408-
WsfTimerUpdate(deltaTimeMs / WSF_MS_PER_TICK);
409-
lastTimeUs += deltaTimeMs * 1000;
408+
uint64_t last_update_ms = (_last_update_us / 1000);
409+
wsfTimerTicks_t wsf_ticks = (last_update_ms / WSF_MS_PER_TICK);
410+
411+
if (wsf_ticks > 0) {
412+
WsfTimerUpdate(wsf_ticks);
413+
414+
_last_update_us -= (last_update_ms * 1000);
410415
}
411416

412417
wsfOsDispatcher();
413418

419+
CriticalSectionLock critical_section;
420+
414421
if (wsfOsReadyToSleep()) {
415422
static Timeout nextTimeout;
416423
// setup an mbed timer for the next Cordio timeout
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Permissive Binary License
2+
3+
Version 1.0, September 2015
4+
5+
Redistribution. Redistribution and use in binary form, without
6+
modification, are permitted provided that the following conditions are
7+
met:
8+
9+
1) Redistributions must reproduce the above copyright notice and the
10+
following disclaimer in the documentation and/or other materials
11+
provided with the distribution.
12+
13+
2) Unless to the extent explicitly permitted by law, no reverse
14+
engineering, decompilation, or disassembly of this software is
15+
permitted.
16+
17+
3) Redistribution as part of a software development kit must include the
18+
accompanying file named “DEPENDENCIES” and any dependencies listed in
19+
that file.
20+
21+
4) Neither the name of the copyright holder nor the names of its
22+
contributors may be used to endorse or promote products derived from
23+
this software without specific prior written permission.
24+
25+
Limited patent license. The copyright holders (and contributors) grant a
26+
worldwide, non-exclusive, no-charge, royalty-free patent license to
27+
make, have made, use, offer to sell, sell, import, and otherwise
28+
transfer this software, where such license applies only to those patent
29+
claims licensable by the copyright holders (and contributors) that are
30+
necessarily infringed by this software. This patent license shall not
31+
apply to any combinations that include this software. No hardware is
32+
licensed hereunder.
33+
34+
If you institute patent litigation against any entity (including a
35+
cross-claim or counterclaim in a lawsuit) alleging that the software
36+
itself infringes your patent(s), then your rights granted under this
37+
license shall terminate as of the date such litigation is filed.
38+
39+
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
40+
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
41+
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
42+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
43+
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
45+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
46+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
47+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
48+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
49+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# BLE API Cordio Link Layer Implementation
2+
3+
The BLE API Cordio link layer implementation allows Cordio licensee to easily
4+
deliver a complete and up to date implementation of mbed BLE to their customers
5+
using mbed OS.
6+
7+
The library a consists of the controller HCI, Bluetooth 5 compliant link layer
8+
protocol core, scheduler, baseband porting layer and a portable software
9+
foundation.
10+
11+
To deliver a BLE port, vendors simply have to provide an HCI driver tailored
12+
for the BLE module present on the board they want to support.
13+
14+
## Source Organization
15+
16+
The root contains the binary distribution `libcordio_stack.a` of the library and
17+
the folders contain the public headers to interface with it.
18+
19+
* `controller`: HCI Controller headers
20+
* `platform`: Platform headers
21+
22+
23+
## Library information
24+
25+
Compiled with: GNU Arm Embedded Toolchain 6-2017-q2-update

0 commit comments

Comments
 (0)