Está en la página 1de 54

John So

Shenzen Aug 2013

Simple BLE sensor application using Nordic semi

Simple BLE Sensor Application

Nordic BLE Solutions

Simple BLE Sensor Application

Nordic semi Bluetooth low energy devices


External MCU
nRF8001

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.

nRF8002

nRF51822 nRF51922

nRF51822 and nRF51922 , Bluetooth low energy and multi protocol solution Single chip solution. ARM Cortex-M0

Simple BLE Sensor Application

nRF8001 Feature Highlight

Simple BLE Sensor Application

nRF8001
Operates in the peripheral role Integrated Host stack Integrated Link Layer Qualified radio

External MCU

ACI

GATT Server GATT Client

Simple BLE Sensor Application

nRF8001
Simple ACI command and Event interface
ACI Command External MCU
nRF8001

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)

ACI Event

Simple BLE Sensor Application

nRF8001
Optional ACTIVE line to show when the nRF8001 radio is in use and the duration of use
ACI Command External MCU
nRF8001

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

ACI Event

Simple BLE Sensor Application

nRF8001
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 ACI ACI ACI ACI ACI Commands and Event used in UART over BLE Setup Connect Pipe Status Event Send Data Data Received Event

GATT
Proprietary Service over Generic Attribute Profile

BLE Simple Sensor application

nRF2740 and nRF2741 modules can be used with the Arduino. The modules are included with the Nordic semi nRF8001 Development kit
Bluetooth low energy shield (nRF8001)

Connect Advertise

Use the ble_uart_project _template in Bluetooth low energy SDK for Arduino

Arduino

http://devzone.nordicsemi.com/arduino

nRF UART app for iOS nRF UART app for Samsung Galaxy S4 Send and Receive data

Simple BLE Sensor Application

10

nRF8002 features highlight

Simple BLE Sensor Application

11

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

Simple BLE Sensor Application

12

nRF8002 Development Kit

nRF8002

Fully functional Bluetooth low energy proximity tag Buzzer LEDs Buttons

Simple BLE Sensor Application

13

nRF51822 features highlight

nRF51822

nRF51822 IC
Multi-protocol Bluetooth low energy / 2.4GHz RF SoC
Memory
Timers / Counters Analog I/O 256kB/ 128kB Flash Digital I/O APB bus AHB Lite bus

256kB Flash, 16kB RAM 128kB Flash, 16kB RAM 2x SPI Master, 2x 2-wire Master, UART, 10-bit ADC, Quadrature Demodulator 16-channel PPI, 128-bit AES ECB/CCM/AAR coprocessor, RNG, Temp sensor, Watchdog 16/32 MHz XO, 32kHz XO 16 MHz RC, 32kHz 250ppm RC 2 16-bit Timers, 1 24-bit Timer , 2 24-bit RTC LDO (1.8 to 3.6V), LDO bypass (1.75 to 1.95V) Buck DC/DC (2.1 to 3.6V) S110 -Bluetooth low energy Softdevice Gazell 2.4GHz RF (SDK) 6x6mm 48-pin QFN (31) 3.5x3.8mm 62-ball WLCSP (32)

Analog and digital I/O System Peripherals Oscillators Timers / Counters

System Peripherals

16kB RAM

Processor
16 MHz 32-bit ARM Cortex-M0 CPU

Power Supply

Power Supply
(Supply range)

GPIO

Radio
Multi-protocol 2.4GHz

Software stacks
Oscillators

Package options
(GPIO count)

nRF51822

S110 Bluetooth low energy Software Stack


Complete Bluetooth low energy software stack
S110 Software Stack
Services and Profiles

Production-ready, qualified stack Controller, Host, Services and Profiles Peripheral and Broadcaster role

nRF518 SDK
SVC APIs

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

GATT ATT L2CAP Link Layer SMP

GAP

nRF51 SDK
Services, profiles and example code Source code

S110 Softdevice

Support for non-concurrent multi-protocol with 2.4GHz RF protocols

nRF518xx SoC

nRF51822

nRF518 SDK and Tool Chain


Common SDK for nRF518xx ICs Software stacks
S110 Bluetooth low energy Gazell 2 Proprietary 2.4GHz RF
S110 Software Stack

nRF518 SDK
Gazell 2 Software Stack Software Libraries (Common nRF51 ICs)

Example application code Bluetooth low energy Services and Profiles Softdevice API ESB API Drivers

Software Libraries
Common for all nRF51 ICs ARM CMSIS (-CORE, -SVD, -DSP) Enhanced ShockBurst API

Gazell 2 Protocols

ARM CMSIS

Keil MDK-ARM tool chain


IDE, Compiler, Programming, debug and simulation Free -Lite edition up to 32kB code
S110 Softdevice

nRF518xx SoC

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

Linkable Libraries Re-link Application

Memory Map

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

SoftDevice Re-link Application

Memory Map

20

nRF51 Solution: Automated power management


2 modes: ON and OFF Peripherals only use power when they need power

ON

OFF

Simple BLE Sensor Application

21

nRF51822
Development and Evaluation Kit

nRF51822

nRF51822 Development Kit


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

Module: PCB antenna

Module: SMA connector

USB dongle for easy PC interface and debug

USB dongle

nRF51822

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

Eval-board

Simple BLE Sensor Application

24

nRF51822 Application Example

Simple BLE Sensor Application

25

nRF51822 Application Example

Simple BLE Sensor Application

26

Application Example : Simple BLE sensor


Profiles + Profiles Application

Battery Level Sample

Heart Rate

Battery

Application

Connect Advertise SoftDevice API Controller S110Host BLE SoftDevice

Application Drivers

GATT ATT L2CAP

GAP
SMP

SoftDevice manager SoC library

LED Inc. BPM Button Wakeup Dec. BPM

Link Layer (LL) Physical Layer (PHY)

Simple BLE Sensor Application

27

nRF51822 App Drivers

Simple BLE Sensor Application

28

Application drivers
Heart Rate Battery Application

SoftDevice API

Application Drivers

GATT ATT L2CAP

GAP
SMP

SoftDevice manager SoC library

Link Layer (LL) Physical Layer (PHY)

Simple BLE Sensor Application

29

Application drivers block diagram


Event Pin State

Timer

CPU

GPIO

PIN

PPI Controller

GPIOTE

PIN

Simple BLE Sensor Application

30

Part 1: Output LED


What do we want? Drive output without CPU (LED flash)
Using a Timer, PPI and GPIOTE

CLEAR

Timer
COMPARE

CPU

GPIO

PPI Controller

GPIOTE

PIN

Simple BLE Sensor Application

31

Part 1: Timer configuration

CLEAR

Timer [1]
COMPARE [0]

Simple BLE Sensor Application

32

Part 2: Input Button wakeup


Button wakeup from System OFF
Using GPIO sense / DETECT

Configure the LED on wakeup

DETECT

CPU

GPIO

PIN

Simple BLE Sensor Application

33

Part 2: GPIO configuration


PIN0 DIR_OVERRIDE OUT_OVERRIDE OUT
O PIN_CNF[0].DRIVE

OUT.0
PIN_CNF[0].DIR

PIN0

DETECT

Sense
PIN0_CNF.SENSE PIN_CNF[0].PULL PIN_CNF[0].INPUT

GPIO

PIN ??

IN.0 IN INPUT_OVERRIDE O: output buffer

I: input buffer

Simple BLE Sensor Application

34

nRF51822 SoftDevice

Simple BLE Sensor Application

35

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
Heart Rate Battery Application

SoftDevice API

Application Drivers

GATT ATT L2CAP

GAP
SMP

SoftDevice manager SoC library

Link Layer (LL) Physical Layer (PHY)

Simple BLE Sensor Application

36

SoftDevice Architecture Benefits


Flexibility
No proprietary application development model or RTOS The Application and Stack can be updated (programmed) separately 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 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

Ease of Development

Code safety

Simple BLE Sensor Application

37

Application Programming Model


RAM 0x2000 0000 + SizeOfRAM
*MSP initial value -

Call Stack

Application Region 1 RAM_R1_BASE Softdevice Region 0 0x2000 0000

Simple BLE Sensor Application

38

Interrupt forwarding, SoftDevice to Application

Simple BLE Sensor Application

39

API call using SVC from Application to SoftDevice


Application
{ #include softdevice.h

... int tmp = __SVC(X) ble_function_0(a,b,c,d) ...

CPU-generated interrupt to the SoftDevice SVC_Handler


CLENR0 + 0x0000 00C0

Application Vector Table


CLENR0

Softdevice
int ble_function (arg0, arg1, arg2, arg3) { return(ret0); } SVC_Handler switch (SVC_number) case X: Ret = ble_function_0 (arg0, arg1, arg2, arg3)

System / Softdevice Vector Table


&SVC_Handler

Simple BLE Sensor Application

40

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.

Simple BLE Sensor Application

41

Softdevice@Run-time
API Calls
Made from MAIN & App(L)

Protocol Event
Signaling from LowerStack done with chained interrupts

Simple BLE Sensor Application

42

Softdevice HW block protection


ENABLED SoftDevice: DISABLED
AHB-Lite ARM Cortex M0 Debugger WDT GPIO GPIOTE SPI NVMC Radio Timer [2] Timer [1] Timer [0] RTC [0] RTC [1] RTC ECB Application has Open access SoftDevice Restricts or Blocks access

Simple BLE Sensor Application

43

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

Simple BLE Sensor Application

44

Bluetooth low energy API


Heart Rate Battery Application

SoftDevice API

Application Drivers

GATT ATT L2CAP

GAP
SMP

SoftDevice manager SoC library

Link Layer (LL) Physical Layer (PHY)

Simple BLE Sensor Application

45

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

Application

Events as SoftWare Interrupts


Always through SWI2 Interrupt priority: Level 0 ble_evt_get() For all BLE events From ISR or main context

SVC

SWI2 ble_evt_get()

SVC

GAP API

GATTS API

Simple BLE Sensor Application

46

BLE API: GAP


GAP SVC EVT Advertiser
Adv Data

Connection

SVC EVT

GAP Service SVC


Device Name Appearance PPCP Keys

Security

SVC EVT

Simple BLE Sensor Application

47

BLE API: Connection Sequence


App
BLE Stack Central

scan() ble_gap_adv_data_set() ble_gap_adv_start()


Adv Data Adv Data Adv Data

connect() BLE_GAP_EVT_CONNECTED

ble_gap_disconnect() disconnect() BLE_GAP_EVT_DISCONNECTED

Simple BLE Sensor Application

48

BLE API: GATTS


GATTS
ATT Table Population and Local Access

ATT Table
Service
Char. Char.

SVC EVT
GATT hierarchy enforcement

Service

SVC EVT

ATT Protocol
Server Initiated (HVx) ATT Table Access Control

Char. Char.

Simple BLE Sensor Application

49

BLE API: Service population


App
BLE Stack

ble_gatts_service_add(HRS)

Handle 0x0001 0x0002

UUID SERVICE CHAR HRM CHAR HSL

Value HRS HRM 80bpm HSL FINGER

ble_gatts_characteristic_add(HRM, 80bpm)

0x0003 0x0004
ble_gatts_characteristic_add(HSL, FINGER)

0x0005

Simple BLE Sensor Application

50

BLE API: Service Discovery - Enabling Notifications


App
BLE Stack ATT Table
HRM Char.

Central

87bpm 83bpm 80bpm Notifications

Service Discovery

BLE_GATT_EVT_WRITE (WRITE_REQ, data=enable Notifications)

ATT Write Request (enable Notifications) ATT Write Response

ble_gatts_hvx(0x0003,

87bpm

) HVN ATT Packet

87

Simple BLE Sensor Application

51

Application block diagram


Event

ADC

CPU operation

PIN App Timer CPU GPIO PIN


SEND NOTIFICATION
SoftDevice API
GATT ATT L2CAP Link Layer (LL) Physical Layer (PHY) GAP
SMP

READ

SoftDevice manager SoC library

Simple BLE Sensor Application

52

Application block diagram


MAIN Program BLE Stack process
BLE Event Interrupt (SWI) Application Interrupt

BLE Stack Interrupt

BLE Event process

Battery Notify

HRS Notify

Button Sample

John So

Shenzen Aug 2013

DEMO

John So

Shenzen Aug 2013

Simple BLE sensor application using Nordic semi

También podría gustarte