ble nano hid over gatt

Dependencies:   BLE_API mbed-dev nRF51822

Revision:
46:b8f4c050739a
Parent:
45:f4be69c936f6
Child:
47:5bf2ae8cc710
--- a/HIDController_BLE.cpp	Sun Aug 28 14:32:28 2016 +0000
+++ b/HIDController_BLE.cpp	Sun Aug 28 16:25:26 2016 +0000
@@ -236,7 +236,15 @@
 
 	BLE& ble = BLE::Instance(BLE::DEFAULT_INSTANCE);
 	ble.init(bleInitComplete);
-
+	
+	// copied from https://github.com/lancaster-university/microbit-dal/commit/3c314794f07e5ac91331c9e9849475375708ec89
+	// configure the stack to hold on to CPU during critical timing events.
+ 	// mbed-classic performs __disabe_irq calls in its timers, which can cause MIC failures 
+ 	// on secure BLE channels.
+    ble_common_opt_radio_cpu_mutex_t opt;
+    opt.enable = 1;
+    sd_ble_opt_set(BLE_COMMON_OPT_RADIO_CPU_MUTEX, (const ble_opt_t *)&opt);
+     
 	while (!ble.hasInitialized()) { }
 	DEBUG_PRINTF_BLE("ble.hasIntialized\r\n");
 }