Shenzen Aug 2013 John So Nordic BLE Solutions 2 Simple BLE Sensor Application Nordic semi Bluetooth low energy devices 3 Simple BLE Sensor Application External MCU nRF8001 , Bluetooth Connectivity solution. Uses an external MCU for user application. Visual editor for Bluetooth low energy configuration. Drivers available for multiple MCUs. nRF8002 , Bluetooth Proximity solution. Single chip solution. No software coding required. Visual editor to do configuration. nRF51822 and nRF51922 , Bluetooth low energy and multi protocol solution Single chip solution. ARM Cortex-M0 nRF51822 nRF51922 nRF8002 nRF8001 nRF8001 Feature Highlight 4 Simple BLE Sensor Application nRF8001 Operates in the peripheral role Integrated Host stack Integrated Link Layer Qualified radio Simple BLE Sensor Application GATT Server GATT Client ACI External MCU nRF8001 6 Simple BLE Sensor Application External MCU nRF8001 ACI Command ACI Event Simple ACI command and Event interface nRFgo Studio as the visual editor for creating Bluetooth Services and Characteristics ACI drivers available for multiple MCU platforms Requires 5 lines for connection ACI is an SPI slave with additional handshake lines Use the SPI master on your MCU or implement the SPI in software MISO, MOSI, SCK, REQN (similar to a Chip select), RDYN (nRF8001 is ready) nRF8001 7 Simple BLE Sensor Application External MCU nRF8001 ACI Command ACI Event Optional ACTIVE line to show when the nRF8001 radio is in use and the duration of use Optional DC-DC to reduce power consumption Optional 32 KHz Crystal (Can use the built-in 32 KHz internal oscillator) Option to supply 16MHz clock from external source and avoid using the 16MHz Crystal nRF8001 8 Simple BLE Sensor Application nRF8001 includes a GATT Server and GATT client ACI interfaces to the GATT Server and GATT Portable C Source code available for ACI library for porting to your MCU. Implementations available on multiple MCU platforms Demo to Send/Receive Data from an Arduino board to the iPhone using the Bluetooth low energy Shield for Arduino UART over BLE (proprietary Service) ACI Commands and Event used in UART over BLE ACI Setup ACI Connect ACI Pipe Status Event ACI Send Data ACI Data Received Event GATT Proprietary Service over Generic Attribute Profile Advertise 9 BLE Simple Sensor application Connect nRF UART app for iOS nRF UART app for Samsung Galaxy S4 Send and Receive data Arduino Bluetooth low energy shield (nRF8001) nRF2740 and nRF2741 modules can be used with the Arduino. The modules are included with the Nordic semi nRF8001 Development kit Use the ble_uart_project _template in Bluetooth low energy SDK for Arduino http://devzone.nordicsemi.com/arduino nRF8002 features highlight 10 Simple BLE Sensor Application nRF8002 11 Simple BLE Sensor Application nRF8002 Single chip solution for proximity solutions Link Loss, Immediate Alert, Battery, TX power Services Find Me and Alert Notification Profiles 3 Digital Outputs, 1 PWM output 2 Digital Inputs (Buttons, LEDs, Buzzers and Vibration) No software coding required Configure with a Visual Editor (nRFgo Studio) Production settings generated from nRFgo Studio iOS app sample code available (nRF Proximity) nRF8002 Development Kit 12 Simple BLE Sensor Application nRF8002 Fully functional Bluetooth low energy proximity tag Buzzer LEDs Buttons nRF51822 features highlight 13 Simple BLE Sensor Application n R F 5 1 8 2 2 Memory 256kB Flash, 16kB RAM 128kB Flash, 16kB RAM Analog and digital I/O 2x SPI Master, 2x 2-wire Master, UART, 10-bit ADC, Quadrature Demodulator System Peripherals 16-channel PPI, 128-bit AES ECB/CCM/AAR co- processor, RNG, Temp sensor, Watchdog Oscillators 16/32 MHz XO, 32kHz XO 16 MHz RC, 32kHz 250ppm RC Timers / Counters 2 16-bit Timers, 1 24-bit Timer , 2 24-bit RTC Power Supply (Supply range) LDO (1.8 to 3.6V), LDO bypass (1.75 to 1.95V) Buck DC/DC (2.1 to 3.6V) Software stacks S110 -Bluetooth low energy Softdevice Gazell 2.4GHz RF (SDK) Package options (GPIO count) 6x6mm 48-pin QFN (31) 3.5x3.8mm 62-ball WLCSP (32) nRF51822 IC Multi-protocol Bluetooth low energy / 2.4GHz RF SoC Processor 16 MHz 32-bit ARM Cortex-M0 CPU 256kB/ 128kB Flash A H B
L i t e
b u s 16kB RAM GPIO Radio Multi-protocol 2.4GHz A P B
b u s Oscillators Power Supply Timers / Counters Analog I/O Digital I/O System Peripherals S110 Softdevice S110 Bluetooth low energy Software Stack n R F 5 1 8 2 2 Complete Bluetooth low energy software stack Production-ready, qualified stack Controller, Host, Services and Profiles Peripheral and Broadcaster role S110 Softdevice Controller Host stack up to GATT and GAP L2CAP, GATT and GAP APIs Thread-safe, asynchronous and event driven API Memory isolation between application and protocol stack for robustness and security Pre-compiled hex nRF51 SDK Services, profiles and example code Source code Support for non-concurrent multi-protocol with 2.4GHz RF protocols nRF518xx SoC SVC APIs Link Layer L2CAP ATT GATT SMP GAP nRF518 SDK Services and Profiles S110 Software Stack nRF518 SDK and Tool Chain Common SDK for nRF518xx ICs Software stacks S110 Bluetooth low energy Gazell 2 Proprietary 2.4GHz RF Software Libraries Common for all nRF51 ICs ARM CMSIS (-CORE, -SVD, -DSP) Enhanced ShockBurst API Keil MDK-ARM tool chain IDE, Compiler, Programming, debug and simulation Free -Lite edition up to 32kB code n R F 5 1 8 2 2 nRF518 SDK Bluetooth low energy Services and Profiles nRF518xx SoC S110 Softdevice Gazell 2 Protocols Softdevice API S110 Software Stack Gazell 2 Software Stack D r i v e r s Software Libraries (Common nRF51 ICs) ARM CMSIS Example application code E S B
A P I 17 nRF51 Solution: IO signals can use any pin (Pin Crossbar) Low cost 2 layer PCBs are possible Simple layout of external components nRF51 Solution: SoftDevice power management API 1 API call will make your application low power nRF51 Solution: Programmable Peripheral Interconnect (PPI) True real-time system nRF51 Solution: Direct transfer between peripherals and RAM (EasyDMA) No CPU or code required to copy packet data 18 Problem: Application and stack code are dependent Re-linking the application changes the protocol stack Longer development time and more testing required Application Segment Stack Segment Memory Map Re-link Application Linkable Libraries 19 nRF51 Solution: SoftDevice Architecture Application program is isolated from the protocol stack Application developer does not need to re-link the protocol stack Application Segment Stack Segment Memory Map Re-link Application SoftDevice 20 nRF51 Solution: Automated power management 2 modes: ON and OFF Peripherals only use power when they need power OFF ON nRF51822 Development and Evaluation Kit 21 Simple BLE Sensor Application nRF51822 Development Kit n R F 5 1 8 2 2 Interfaces to existing nRFgo platform nRFgo available separately and required Fully featured for full system development Range of I/O options via nRFgo motherboard RF-stable development platform Enables detailed measurement & test Current measurements RF measurements using SMA connector USB dongle for easy PC interface and debug Module: PCB antenna Module: SMA connector USB dongle nRF51822 Evaluation Kit Flexible evaluation and development platform Stand-alone battery-powered system Portable system development Integrated debugger USB dongle for easy PC interface and debug n R F 5 1 8 2 2 Eval-board nRF51822 Application Example 24 Simple BLE Sensor Application nRF51822 Application Example 25 Simple BLE Sensor Application Application Example : Simple BLE sensor 26 Simple BLE Sensor Application GAP GATT ATT SMP L2CAP Link Layer (LL) Physical Layer (PHY) B a t t e r y H e a r t
R a t e Connect C o n t r o l l e r H o s t P r o f i l e s
+
A p p l i c a t i o n Application A p p l i c a t i o n
D r i v e r s Button Wakeup LED P r o f i l e s Battery Level Sample Advertise Inc. BPM Dec. BPM SoftDevice API S o f t D e v i c e m a n a g e r S o C l i b r a r y S 1 1 0
B L E
S o f t D e v i c e nRF51822 App Drivers 27 Simple BLE Sensor Application 28 Simple BLE Sensor Application GAP GATT ATT SMP L2CAP Link Layer (LL) Physical Layer (PHY) B a t t e r y H e a r t
R a t e Application A p p l i c a t i o n
D r i v e r s SoftDevice API S o f t D e v i c e m a n a g e r S o C l i b r a r y Application drivers Application drivers block diagram 29 Simple BLE Sensor Application GPIO PIN CPU PPI Controller Timer GPIOTE PIN Event Pin State Part 1: Output LED What do we want? Drive output without CPU (LED flash) Using a Timer, PPI and GPIOTE 30 Simple BLE Sensor Application CPU PPI Controller Timer GPIOTE PIN CLEAR COMPARE GPIO Part 1: Timer configuration 31 Simple BLE Sensor Application Timer [1] CLEAR COMPARE [0] Part 2: Input Button wakeup Button wakeup from System OFF Using GPIO sense / DETECT Configure the LED on wakeup 32 Simple BLE Sensor Application CPU GPIO PIN DETECT Part 2: GPIO configuration 33 Simple BLE Sensor Application PIN0 OUT.0 IN.0 PIN0 IN Sense OUT_OVERRIDE DIR_OVERRIDE DETECT OUT O I O: output buffer I: input buffer PIN_CNF[0].INPUT PIN_CNF[0].PULL PIN_CNF[0].DRIVE PIN0_CNF.SENSE PIN_CNF[0].DIR INPUT_OVERRIDE GPIO PIN ?? nRF51822 SoftDevice 34 Simple BLE Sensor Application nRF51 SoftDevice Architecture Application nRF51 Softdevice Pre-compiled binary implementing wireless protocols Service (system) Call (SVC) based APIs 100% event-driven No RTOS dependencies Run-time protection No link time dependencies w/ user application 35 Simple BLE Sensor Application GAP GATT ATT SMP L2CAP Link Layer (LL) Physical Layer (PHY) B a t t e r y H e a r t
R a t e Application A p p l i c a t i o n
D r i v e r s SoftDevice API S o f t D e v i c e m a n a g e r S o C l i b r a r y SoftDevice Architecture Benefits 36 Simple BLE Sensor Application Flexibility No proprietary application development model or RTOS The Application and Stack can be updated (programmed) separately Ease of Development Simple Application programmer model with no link time dependencies Stack is not re-linked constantly during application development Can use the free ARM MDK-Lite when application code is less than 32Kbytes Code safety QA and qualification on binary going into end-user product Thread-safe API Stack is run-time protected Reduced risk of Applications bugs affecting the Stack Application Programming Model 37 Simple BLE Sensor Application RAM Softdevice Region 0 Application Region 1 RAM_R1_BASE 0x2000 0000 0x2000 0000 + SizeOfRAM *MSP initial value - Call Stack Interrupt forwarding, SoftDevice to Application 38 Simple BLE Sensor Application Softdevice Application Application Vector Table System / Softdevice Vector Table &SVC_Handler CLENR0 CLENR0 + 0x0000 00C0 { #include softdevice.h ... int tmp = __SVC(X) ble_function_0(a,b,c,d) ... } SVC_Handler switch (SVC_number) case X: Ret = ble_function_0 (arg0, arg1, arg2, arg3) int ble_function (arg0, arg1, arg2, arg3) { return(ret0); } API call using SVC from Application to SoftDevice 39 Simple BLE Sensor Application CPU-generated interrupt to the SoftDevice SVC_Handler Softdevice@Run-time Cortex M0 has 4 interrupt priorities SoftDevice uses 2 priorities to implement its event-driven behavior Lower Stack (BLE Link Layer), Upper Stack (SVC API, BLE Host) Application have access to 2 priorities Application High for critical interrupts where low latency is required. Cannot call the SVC API. Application Low. Used for Host events. 40 Simple BLE Sensor Application 41 Simple BLE Sensor Application Softdevice@Run-time API Calls Made from MAIN & App(L) Protocol Event Signaling from LowerStack done with chained interrupts Softdevice HW block protection 42 Simple BLE Sensor Application ARM Cortex M0 Debugger GPIO WDT GPIOTE SPI NVMC A H B - L i t e Radio Timer [0] RTC ECB Radio RTC [1] ECB Timer [1] RTC [0] Timer [2] Timer [0] Application has Open access SoftDevice Restricts or Blocks access SoftDevice: DISABLED SoftDevice: ENABLED Working with the SoftDevice Applications running with the SoftDevice must be programmed into Region 1 flash The SoftDevice will reserve RAM and sandbox some peripheral interfaces All Restricted peripherals must now be accessed via the nrf_ SVC API A Hard Fault will occur if the application accesses the registers via CMSIS directly 43 Simple BLE Sensor Application 44 Simple BLE Sensor Application GAP GATT ATT SMP L2CAP Link Layer (LL) Physical Layer (PHY) B a t t e r y H e a r t
R a t e Application A p p l i c a t i o n
D r i v e r s SoftDevice API S o f t D e v i c e m a n a g e r S o C l i b r a r y Bluetooth low energy API Generic Access Profile (GAP) Generic Attribute Profile Server (GATTS) API calls as SuperVisor Calls Switches Core to SV priority Each SV Call numbered Events as SoftWare Interrupts Always through SWI2 Interrupt priority: Level 0 ble_evt_get() For all BLE events From ISR or main context 45 Simple BLE Sensor Application Application GAP API GATTS API SVC SVC SWI2 ble_evt_get() Bluetooth low energy API BLE API: GAP 46 Simple BLE Sensor Application GAP Connection SVC EVT GAP Service SVC Device Name Appearance PPCP Advertiser SVC EVT Adv Data Security SVC EVT Keys BLE API: Connection Sequence 47 Simple BLE Sensor Application App BLE Stack Central BLE_GAP_EVT_CONNECTED BLE_GAP_EVT_DISCONNECTED ble_gap_adv_start() Adv Data Adv Data scan() ble_gap_adv_data_set() Adv Data connect() disconnect() ble_gap_disconnect() BLE API: GATTS 48 Simple BLE Sensor Application GATTS ATT Table Population and Local Access SVC EVT GATT hierarchy enforcement SVC EVT ATT Protocol Server Initiated (HVx) ATT Table Access Control ATT Table Service Char. Char. Service Char. Char.
BLE API: Service population
49 Simple BLE Sensor Application App BLE Stack Handle UUID Value ble_gatts_characteristic_add(HSL, FINGER) 0x0004 CHAR HSL 0x0005 HSL FINGER ble_gatts_characteristic_add(HRM, 80bpm) 0x0002 CHAR HRM 0x0003 HRM 80bpm ble_gatts_service_add(HRS) 0x0001 SERVICE HRS BLE API: Service Discovery - Enabling Notifications 50 Simple BLE Sensor Application App BLE Stack Central ATT Table HVN ATT Packet 87 HRM Char. 80bpm 83bpm 87bpm ATT Write Request (enable Notifications) ATT Write Response ble_gatts_hvx(0x0003, 87bpm ) Notifications Service Discovery BLE_GATT_EVT_WRITE (WRITE_REQ, data=enable Notifications) Application block diagram 51 Simple BLE Sensor Application GPIO PIN CPU App Timer Event PIN READ ADC CPU operation SEND NOTIFICATION GAP GATT ATT SMP L2CAP Link Layer (LL) Physical Layer (PHY) SoftDevice API S o f t D e v i c e m a n a g e r S o C l i b r a r y Application block diagram 52 Simple BLE Sensor Application MAIN Program BLE Stack process BLE Event process Button Sample HRS Notify Battery Notify Application Interrupt BLE Stack Interrupt BLE Event Interrupt (SWI) DEMO Shenzen Aug 2013 John So Simple BLE sensor application using Nordic semi Shenzen Aug 2013 John So