Skip to content

Add support for Cordio to NRF52 Devices #8876

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

Merged
merged 27 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
065bad6
fix(pan-cordio): Move stack BLE stack setup to later in initialisation
Nov 21, 2018
f60c2c9
fix(pan-cordio): Increase the maximum number of supported WSF handlers
Nov 21, 2018
5782e93
fix(pan-cordio): Wrap call to wsfOsReadyToSleep in a critical section
Nov 21, 2018
299ae1d
fix(pan-cordio): Override WSF handler size in a platform specific manner
Nov 22, 2018
e5aa843
refactor(pan-cordio): Use Timer class instead of raw ticker for timing
Nov 22, 2018
ca2efcd
fix(pan-cordio): Reset timer after updating to reduce chance of overflow
Nov 26, 2018
815d0d5
feat(pan-cordio): Add cordio-ll libraries and NORDIC implementation
Nov 22, 2018
9326769
fix(pan-nordic): Fix memory allocation sizes to resolve NRF52832 issues
Nov 23, 2018
f583596
refactor(pan-cordio): Replace the uECC source with a precompiled library
Nov 23, 2018
c3e6113
fix(pan-cordio): Fix incorrectly adding macros to NRF52_DK target
Nov 23, 2018
0f4ded1
feat(pan-cordio): Replace NRF51 softdevice BLE stack with cordio
Nov 23, 2018
01620b9
Use uECC C99 implementation
Nov 23, 2018
1e1486e
fix(pan-cordio): Replace the compiled uECC library with the sources
Nov 26, 2018
93bf68d
fix(pan-cordio): Remove erroneous files added after rebasing
Nov 26, 2018
c68c150
Fix buffer size for NRF Cordio HCI driver
Nov 26, 2018
12fdab3
feat(pan-cordio): Add nordic softdevice sources back into repository
Nov 26, 2018
4f7dcf4
refactor(pan-cordio): Make nordic softdevice the default link layer
Nov 26, 2018
1b3efa4
doc(pan-cordio): Add documentation to README on how to enable Cordio LL
Nov 26, 2018
3ce1d91
Amend Nordic HCI driver to support BLE5 features
Nov 26, 2018
f980814
Add number of advertising sets
Nov 26, 2018
89aabae
Fix some rebasing quirks
Nov 27, 2018
5a87cfa
Fix a few more rebasing issues
Nov 27, 2018
a3bae1c
doc(pan-cordio): Add readme and license documents for cordio link layer
Nov 27, 2018
353e991
doc(pan-cordio): Add toolchain version used to compile cordio-ll readme
Nov 27, 2018
837ba72
NRF51: Add label to compile BLE softdevice implementation.
pan- Nov 28, 2018
93d8c71
NORDIC: Fix labels in target.
pan- Nov 28, 2018
c998248
BLE: Reintroduce changes to address types lost.
pan- Nov 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion features/FEATURE_BLE/ble/pal/GapEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ struct GapAdvertisingReportEvent : public GapEvent {
struct advertising_t {
received_advertising_type_t type;
connection_peer_address_type_t address_type;
const address_t& address;
address_t address;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for that change ?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit adding the initial change says "Fix advertising_t in GapEvents.h having a reference to an inexisting address_t instance". I'm not sure which usage of it caused the issue though.

ArrayView<const uint8_t> data;
int8_t rssi;
};
Expand Down
3 changes: 3 additions & 0 deletions features/FEATURE_BLE/targets/TARGET_CORDIO/CordioBLE.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "ble/generic/GenericGap.h"
#include "ble/generic/GenericSecurityManager.h"
#include "SimpleEventQueue.h"
#include "Timer.h"

namespace ble {
namespace vendor {
Expand Down Expand Up @@ -153,6 +154,8 @@ class BLE : public ::BLEInstanceBase {

::BLE::InstanceID_t instanceID;
mutable SimpleEventQueue _event_queue;
mbed::Timer _timer;
uint64_t _last_update_us;

class SigningEventMonitorProxy : public pal::SigningEventMonitor {
public:
Expand Down
29 changes: 18 additions & 11 deletions features/FEATURE_BLE/targets/TARGET_CORDIO/source/CordioBLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "mbed.h"
#include "us_ticker_api.h"
#include "BLE.h"
#include "CriticalSectionLock.h"
#include "wsf_types.h"
#include "wsf_msg.h"
#include "wsf_os.h"
Expand Down Expand Up @@ -95,10 +96,11 @@ namespace cordio {
BLE::BLE(CordioHCIDriver& hci_driver) :
initialization_status(NOT_INITIALIZED),
instanceID(::BLE::DEFAULT_INSTANCE),
_event_queue()
_event_queue(),
_last_update_us(0)
{
_hci_driver = &hci_driver;
stack_setup();

}

BLE::~BLE() { }
Expand All @@ -120,6 +122,8 @@ ble_error_t BLE::init(
{
switch (initialization_status) {
case NOT_INITIALIZED:
_timer.reset();
_timer.start();
_event_queue.initialize(this, instanceID);
_init_callback = initCallback;
start_stack_reset();
Expand Down Expand Up @@ -389,6 +393,7 @@ void BLE::stack_setup()
void BLE::start_stack_reset()
{
_hci_driver->initialize();
stack_setup();
DmDevReset();
}

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

// follow by stack events
static uint32_t lastTimeUs = us_ticker_read();
uint32_t currTimeUs, deltaTimeMs;
_last_update_us += (uint64_t)_timer.read_high_resolution_us();
_timer.reset();

// Update the current cordio time
currTimeUs = us_ticker_read();
deltaTimeMs = (currTimeUs - lastTimeUs) / 1000;
if (deltaTimeMs > 0) {
WsfTimerUpdate(deltaTimeMs / WSF_MS_PER_TICK);
lastTimeUs += deltaTimeMs * 1000;
uint64_t last_update_ms = (_last_update_us / 1000);
wsfTimerTicks_t wsf_ticks = (last_update_ms / WSF_MS_PER_TICK);

if (wsf_ticks > 0) {
WsfTimerUpdate(wsf_ticks);

_last_update_us -= (last_update_ms * 1000);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_last_update_us -= (last_update_ms * 1000);
_last_update_us -= (wsf_ticks * WSF_MS_PER_TICK * 1000);

otherwise you're losing milliseconds that aren't passed in as ticks

}

wsfOsDispatcher();

CriticalSectionLock critical_section;

if (wsfOsReadyToSleep()) {
static Timeout nextTimeout;
// setup an mbed timer for the next Cordio timeout
Expand Down
49 changes: 49 additions & 0 deletions features/FEATURE_BLE/targets/TARGET_CORDIO_LL/cordio_stack/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Permissive Binary License

Version 1.0, September 2015

Redistribution. Redistribution and use in binary form, without
modification, are permitted provided that the following conditions are
met:

1) Redistributions must reproduce the above copyright notice and the
following disclaimer in the documentation and/or other materials
provided with the distribution.

2) Unless to the extent explicitly permitted by law, no reverse
engineering, decompilation, or disassembly of this software is
permitted.

3) Redistribution as part of a software development kit must include the
accompanying file named “DEPENDENCIES” and any dependencies listed in
that file.

4) Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

Limited patent license. The copyright holders (and contributors) grant a
worldwide, non-exclusive, no-charge, royalty-free patent license to
make, have made, use, offer to sell, sell, import, and otherwise
transfer this software, where such license applies only to those patent
claims licensable by the copyright holders (and contributors) that are
necessarily infringed by this software. This patent license shall not
apply to any combinations that include this software. No hardware is
licensed hereunder.

If you institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the software
itself infringes your patent(s), then your rights granted under this
license shall terminate as of the date such litigation is filed.

DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# BLE API Cordio Link Layer Implementation

The BLE API Cordio link layer implementation allows Cordio licensee to easily
deliver a complete and up to date implementation of mbed BLE to their customers
using mbed OS.

The library a consists of the controller HCI, Bluetooth 5 compliant link layer
protocol core, scheduler, baseband porting layer and a portable software
foundation.

To deliver a BLE port, vendors simply have to provide an HCI driver tailored
for the BLE module present on the board they want to support.

## Source Organization

The root contains the binary distribution `libcordio_stack.a` of the library and
the folders contain the public headers to interface with it.

* `controller`: HCI Controller headers
* `platform`: Platform headers


## Library information

Compiled with: GNU Arm Embedded Toolchain 6-2017-q2-update
Loading