test
Fork of nRF51822 by
Revision 431:95158d6d493f, committed 2015-09-25
- Comitter:
- rgrover1
- Date:
- Fri Sep 25 15:26:40 2015 +0100
- Parent:
- 430:db7edc9ad0bc
- Child:
- 432:4b768f4abc74
- Commit message:
- Synchronized with git rev 21e8e22d
Author: Rohit Grover
Release 0.4.7
=============
* There's now a compile time switch to for handling for BLE stack events. For
mbed OS, we now post callbacks to Minar, else stack events are executed
right-away in interrupt context. In either case, the logic of event
processing is identical--this means that the Nordic port of BLE_API will
have the same code for mbed-classic and mbed OS. :)
As a fallout of the above, all mbed-OS BLE event handling now happens in
thread mode.
Changed in this revision
--- a/module.json Fri Sep 25 15:26:40 2015 +0100 +++ b/module.json Fri Sep 25 15:26:40 2015 +0100 @@ -1,6 +1,6 @@ { "name": "ble-nrf51822", - "version": "0.4.6", + "version": "0.4.7", "description": "Nordic stack and drivers for the mbed BLE API.", "keywords": [ "Bluetooth", @@ -19,7 +19,7 @@ } ], "dependencies": { - "ble": "~0.4.6" + "ble": "~0.4.7" }, "extraIncludes": [ "source/btle",
--- a/source/btle/btle.cpp Fri Sep 25 15:26:40 2015 +0100 +++ b/source/btle/btle.cpp Fri Sep 25 15:26:40 2015 +0100 @@ -50,6 +50,30 @@ pstorage_sys_event_handler(sys_evt); } +/** + * This function is called in interrupt context to handle BLE events; i.e. pull + * system and user events out of the pending events-queue of the BLE stack. The + * BLE stack signals the availability of events by the triggering the SWI2 + * interrupt, which forwards the handling to this function. + * + * The event processing loop is implemented in intern_softdevice_events_execute(). + * + * In mbed OS, a callback for intern_softdevice_events_execute() is posted + * to the scheduler, which then executes in thread mode. In mbed-classic, + * event processing happens right-away in interrupt context (which is more + * risk-prone). In either case, the logic of event processing is identical. + */ +static uint32_t eventHandler() +{ +#ifdef YOTTA_CFG_MBED_OS + minar::Scheduler::postCallback(intern_softdevice_events_execute); +#else + intern_softdevice_events_execute(); +#endif + + return NRF_SUCCESS; +} + error_t btle_init(void) { nrf_clock_lfclksrc_t clockSource; @@ -58,7 +82,7 @@ } else { clockSource = NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION; } - SOFTDEVICE_HANDLER_INIT(clockSource, NULL); + SOFTDEVICE_HANDLER_INIT(clockSource, eventHandler); // Enable BLE stack /**
--- a/source/nordic-sdk/components/softdevice/common/softdevice_handler/softdevice_handler.h Fri Sep 25 15:26:40 2015 +0100 +++ b/source/nordic-sdk/components/softdevice/common/softdevice_handler/softdevice_handler.h Fri Sep 25 15:26:40 2015 +0100 @@ -89,8 +89,7 @@ * reinitialization). */ /*lint -emacro(506, SOFTDEVICE_HANDLER_INIT) */ /* Suppress "Constant value Boolean */ -#define SOFTDEVICE_HANDLER_INIT(CLOCK_SOURCE, \ - EVT_HANDLER) \ +#define SOFTDEVICE_HANDLER_INIT(CLOCK_SOURCE, EVT_HANDLER) \ do \ { \ static uint32_t BLE_EVT_BUFFER[CEIL_DIV(BLE_STACK_EVT_MSG_BUF_SIZE, sizeof(uint32_t))]; \ @@ -98,7 +97,7 @@ ERR_CODE = softdevice_handler_init((CLOCK_SOURCE), \ BLE_EVT_BUFFER, \ sizeof(BLE_EVT_BUFFER), \ - EVT_HANDLER); \ + EVT_HANDLER); \ APP_ERROR_CHECK(ERR_CODE); \ } while (0) @@ -117,7 +116,7 @@ * used, this buffer must be provided by the application. The * buffer must be large enough to hold the biggest stack event the * application is supposed to handle. The buffer must be aligned to - * a 4 byte boundary. This parameter is unused if BLE stack support + * a 4 byte boundary. This parameter is unused if BLE stack support * is not required. * @param[in] ble_evt_buffer_size Size of SoftDevice BLE event buffer. This parameter is unused if * BLE stack support is not required.