Skip to content

Commit 51925d2

Browse files
committed
making bluefruit multiprotocol friendly
1 parent 1046ce6 commit 51925d2

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ AdafruitBluefruit::AdafruitBluefruit(void)
162162

163163
_ble_event_sem = NULL;
164164
_soc_event_sem = NULL;
165+
_mprot_event_sem = NULL;
165166

166167
_led_blink_th = NULL;
167168
_led_conn = true;
@@ -310,7 +311,15 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
310311
#error Clock Source is not configured, define USE_LFXO or USE_LFRC according to your board in variant.h
311312
#endif
312313

314+
/*------------------------------------------------------------------*/
315+
/* BLE only Softdevices have 2-args sd_softdevice_enable()
316+
/* BLE & ANT+ Softdevices have 3-args sd_softdevice_enable()
317+
/*------------------------------------------------------------------*/
318+
#ifdef ANT_LICENSE_KEY
319+
VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, nrf_error_cb, ANT_LICENSE_KEY), false );
320+
#else //#ifdef ANT_LICENSE_KEY
313321
VERIFY_STATUS( sd_softdevice_enable(&clock_cfg, nrf_error_cb), false );
322+
#endif //#ifdef ANT_LICENSE_KEY
314323

315324
#ifdef USE_TINYUSB
316325
usb_softdevice_post_enable();
@@ -676,6 +685,8 @@ void SD_EVT_IRQHandler(void)
676685
// Notify both BLE & SOC Task
677686
xSemaphoreGiveFromISR(Bluefruit._soc_event_sem, NULL);
678687
xSemaphoreGiveFromISR(Bluefruit._ble_event_sem, NULL);
688+
// Notify parallel multiprotocol Task, if any
689+
if (Bluefruit._mprot_event_sem!=NULL) xSemaphoreGiveFromISR(*Bluefruit._mprot_event_sem, NULL);
679690
}
680691

681692
/**

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ class AdafruitBluefruit
178178

179179
BLEConnection* Connection(uint16_t conn_hdl);
180180

181+
/*------------------------------------------------------------------*
182+
* Optional semaphore for additional event handlers for SD event.
183+
* It can be used for handling non-BLE SD events
184+
*------------------------------------------------------------------*/
185+
void setMultiprotocolSemaphore(SemaphoreHandle_t* p_mprot_event_semaphore)
186+
{
187+
_mprot_event_sem= p_mprot_event_semaphore;
188+
}
189+
181190
/*------------------------------------------------------------------*/
182191
/* Callbacks
183192
*------------------------------------------------------------------*/
@@ -222,6 +231,8 @@ class AdafruitBluefruit
222231

223232
SemaphoreHandle_t _ble_event_sem;
224233
SemaphoreHandle_t _soc_event_sem;
234+
SemaphoreHandle_t* _mprot_event_sem;
235+
225236

226237
TimerHandle_t _led_blink_th;
227238
bool _led_conn;

0 commit comments

Comments
 (0)