All information contained in these materials, including products and product specifications,
Electronics Corp. without notice. Please review the latest information published by
Renesas Electronics Corp. through various means, including the Renesas Electronics Corp.
®
Low Energy Protocol Stack
User’s
represents information on the product at the time of publication and is subject to change by
Renesas
website (http : //www.renesas.com).
Notice
on of
1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operati
semiconductor products and application examples. You are fully responsible for the incorporation or any other use of the circuits,
software, and i nformation i n the desi gn of your produc t or syste m. Renesa s Electr onics discla ims any and al l liabilit y for any loss es and
damages incurred by you or third parti es arising from the use of these circuits, software, or infor ma tion.
2. Renesas Elec tronics hereby expressly disclai ms any warranties against and liabi lity for infringeme nt or any other claims involving patents,
copyrights, or other intellectual prop erty rights of third part ies, by or arising from the use of Renesas Electronics pr oducts or technical
information described in this document, including but not limited to, the product data, drawings, charts, programs, algorithms, and
application examples.
3. No license, expr ess, impli ed or otherwi se, is gra nted hereb y under an y patents , copyright s or other intell ectual prop erty rights of Renesas
Electronics or others.
4. You shall not alter , modify, copy, or revers e engineer any Renes as Electr onics product , whether in whole or in part. Renesas Electronics
disclaims any and all liability for any losses or damages incurred by you or third parties arising from such alteration, modification,
copying or reverse engineering.
5. Renesas Electroni cs products are cla ssified accordi ng to the following two qua lity grades: “Sta ndard” and “High Quali ty”. The intended
applications for each Renesas Electronics product depends on the product’s quality grade, a s indicated below.
“Standard”: Computers; office equipment; communications equipment; test and measurement equi pment; audio and visual equipment;
home electronic appliances; machine tools; personal electronic eq uipment; industria l robots; etc.
“High Quality”: Transportation equipment (automobiles, trains, ships, etc.); traffic control (traffic lights); large-scale communication
equipment; key financial terminal systems; safety control equipment; etc.
Unless expressl y designated a s a high reli abilit y product or a product for ha rsh environ ments in a Renes as Elec tronics data sheet or ot her
Renesas Electr onic s docum ent, Ren esa s El ectr onic s pr oduc ts a re not i ntended or a uthor i z ed for us e in produc t s or systems tha t may pose a
direct threat to huma n life or bodily injury (ar tificial life supp ort devices or systems; s urgical implantations ; etc.), or may cause ser ious
property damage (s pace system; unders ea repeaters ; nuclear power cont rol systems; a ircraft control systems; key pla nt systems; milit ary
equipment; etc. ). Renesa s El ectroni cs dis claims a ny and al l liab ilit y for any damages or los ses i ncurred b y you or any thi rd parties arising
from the use of any Renes as Electronics product that is inconsistent with any Renesa s Electronics data sheet, us er’s manual or other
Renesas Electronics document.
6. When using Renesas Elect roni cs product s, r efer to t he lates t product informa tion ( data sheet s, user ’s manu als, applica tion not es, “Genera l
Notes for Handling a nd Using Semic onductor Devices ” in the relia bility handbook, etc.), and ens ure that usage c onditions are w ithin the
ranges specified by Renesas Electronics with respect to maximum ratings, operating power supply voltage range, heat dissipation
characterist ics, insta llation, etc. Renesa s Electr onics dis claims any and a ll liabi lity for any ma lfunct ions, fa ilure or acc ident aris ing out of
the use of Renesas Electronics products outside of such specified ranges.
7. Although Renesa s Electroni cs endeavors to imp rove the qual ity and relia bility of Renes as Electroni cs products, semiconductor products
have specific cha racteristics, such as the occurrenc e of failure at a certain rate and malf unctions under certain use conditi ons. Unless
designated as a high reliability product or a product for harsh environments in a Renesas Electronics data sheet or other Renesas
Electronics document, Renesa s Elect ronics produc ts are not s ubject t o radiation res istance des ign. You are r esponsib le for implement ing
safety measures to gua rd aga ins t the pos sibi lity of b odil y injur y, injur y or da mage c aus ed by fir e, a nd/or d anger t o the p ublic in the e vent
of a failure or malf unction of Renesas Elec tronics pr oducts, s uch as safety design for ha rdware a nd software, including b ut not limited t o
redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures.
Because the e valuat ion of mic roc omputer s oft ware a lone is very dif fi cult and imp ract ical, you are res pons ibl e for eval uat ing the s afet y of
the final products or systems manufactured by you.
8. Please contact a Renesas El ectronics sa les office f or details as to environmenta l matters such as the en vironmental compatibility of each
Renesas Elec tronic s produc t. Y ou are r esp onsibl e for c aref ully and s uff icient ly inves ti gati ng appl icab le laws and r egulat ions that regula te
the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive, and using Renesas Electronics
products in compl iance with all these applicab le laws and regul ations. Renesa s Electr onics disclai ms any and all liab ility for damages or
losses occurring as a result of your noncompliance wit h applicable laws and regulations.
9. Renesas Electr oni cs pr oduc ts and t echnol ogi es s ha ll not be us ed f or or incorp or ated i nt o any pr oduc ts or s ystems whos e manuf act ur e, us e,
or sale is pr ohibited under a ny applica ble domestic or foreign laws or regulati ons. You shall comply with an y applicabl e export contr ol
laws and regulations promulgated and administered by the governments of any countries asserting jurisdiction over the parties or
transactions.
10. It is the respons ibility of the buyer or distributor of Renesas Electronics products, or any other party who distr ibutes, disposes of, or
otherwise sell s or tr ansf er s the p r oduct to a thi rd pa r ty, t o noti f y such t hir d p ar ty in a dvanc e of the c ont ent s a nd condi t ions s et f orth i n t his
document.
11. This document sha ll not be repri nted, rep roduced or dup licated i n any form, in whole or in part, wit hout prior wr itten consent of Renesa s
Electronics.
12. Please contact a Renesas Electronics sales of fice if you have any q uestions regarding the information contained in t his document or
Renesas Electronics products.
(Note 1) “Renesas Elect ronics” as used in t his document m eans Renesas Electronics Corporation a nd also incl udes its direc tly or indirect ly
controlled subsidiaries.
(Note 2) “Renesas Electronics product(s)” means any product developed or manufactured by or for Renesas Electronics.
(Rev.4.0-1 November 2017)
General Preca ut ions in the Handl ing of Microprocessing Unit a nd Microcontrol l e r Unit Products
The following usage notes are applicab le to all Microprocessing unit and Microcontroller unit products from Renesas.
For detailed usage notes on the products covered by this document, refer to the relevant sections of the document as well
as any technical updates that have been issued for the products.
1. Handling of Unused Pins
Handle unused pins in accordance with the directions given under Handling of Unused Pins in the
manual.
The input pins of CMOS products are generally in the high-impedance state. In operation with an
unused pin in the open-circuit state, extra electromagnetic noise is induced in the vicinity of LSI, an
associated shoot-through current flows internally, and malfunctions occur due to the false
recognition of the pin state as an input signal become possible. Unused pins should be handled as
described under Handling of Unused Pins in the manual.
2. Processing at Power-on
The state of the produc t is undef in ed at the moment when power is supplied.
The states of internal circuits in the LSI are indeterminate and the states of register settings and
pins are undefined at the moment when power is supplied.
In a finished product where the reset signal is applied to the external reset pin, the states of pins
are not guaranteed from the moment when power is supplied until the reset process is completed.
In a similar way, the states of pins in a product that is reset by an on-chip power-on reset function
are not guaranteed from the moment when power is supplied until the power reaches the level at
which resetting has been specified.
3. Prohibition of Access to Reserved Addresses
Access to reserved addresses is prohibited.
The reserved addresses are provided for the possible future expansion of functions. Do not access
these addresses; the correct operation of LSI is not guaranteed if they are accessed.
4. Clock Signals
After applying a reset, only release the reset line after the operating clock signal has become stable.
When switching the clock signal during program execution, wait until the target clock signal has
stabilized.
When the clock signal is generated with an external resonator (or from an external oscillator)
during a reset, ensure that the reset line is only released after full stabilization of the clock signal.
Moreover, when switching to a clock signal produced with an external resonator (or by an external
oscillator) while program execution is in progress, wait until the target clock signal is stable.
5. Differences between Products
Before changing from one product to another, i.e. to a product with a different part number, confirm
that the change will not lead to problems.
The characteristics of Microprocessing unit or Microcontroller unit products in the same group but
having a different part number may differ in terms of the internal memory capacity, layout pattern,
and other factors, which can affect the ranges of electrical characteristics, such as characteristic
values, operating margins, immunity to noise, and amount of radiated noise. When changing to a
product with a different part number, implement a system-evaluation test for the given product.
How to Use This Manual
1. Purpose and Target Readers
This manual describes setup method, organization, and features of the Bluetooth Low Energy protocol stack (BLE
software), which is used to develop Bluetooth applications that incorporate the Renesas Bluetooth low energy
microcontroller RL78/G1D. It is intended for users designing application systems incorporating this software. A basic
knowledge of microcontrollers and Bluetooth low energy is necessary in order to use this manual.
Related documents
The related documents indicated in this publication may include preliminary versions. However, preliminary versions are
4. Installing BLE Software ................................................................................................................................. 4
4.1 Components Included ......................................................................................................................................... 4
4.2 BLE software build environment ........................................................................................................................ 4
5.2 rBLE API .......................................................................................................................................................... 18
5.3 RL78/G1D Hardware Resources used by the BLE Software ........................................................................... 20
5.4 Serial Communication in Modem Configuration .............................................................................................. 21
5.5 Customer-specific information ......................................................................................................................... 43
5.6 Selection of own Bluetooth Device address ..................................................................................................... 43
6.1 Changing the Configuration Parameters ........................................................................................................... 44
6.1.1 Maximum Number of Simultaneous Connections ................................................................................... 46
6.1.2 Allocating the Heap Area ........................................................................................................................ 47
6.1.3 Changing the Operating Frequency ......................................................................................................... 47
6.1.4 Setting MCU part initialization ................................................................................................................ 48
6.1.5 Setting RF part initialization .................................................................................................................... 49
Index-1
6.1.6 Selecting the serial communication method ............................................................................................ 51
6.1.7 Setting the UART baud rate ..................................................................................................................... 53
6.1.8 Setting the CSI baud rate ......................................................................................................................... 58
6.1.9 Setting the IIC transfer clock ................................................................................................................... 58
6.1.10 Wait for the time Sub Clock is stabled .................................................................................................... 58
6.1.11 Setting the Profile Service ....................................................................................................................... 58
6.2 Building a Project ............................................................................................................................................. 70
7. Description of Features ............................................................................................................................... 72
7.1.4 White List ................................................................................................................................................ 74
7.2.1 GAP roles ................................................................................................................................................ 76
7.2.2 GAP modes and procedures ..................................................................................................................... 76
7.3.3 Key distribution ....................................................................................................................................... 90
7.4.2 Creating a User Profile ............................................................................................................................ 98
7.4.3 GATT Service ........................................................................................................................................ 101
7.5 Find Me Profile ............................................................................................................................................... 102
7.5.1 Use case implemented by using the Immediate Alert service ................................................................ 102
7.11.1 Use case implemented by using the Heart Rate service and the Device Information service ................ 116
7.12 Cycling Speed and Cadence Profile ................................................................................................................ 117
7.12.1 Use case implemented by using the Cycling Speed and Cadence service and the Device Information
service .................................................................................................................................................... 117
7.12.2 Use case implemented by using the SC Control Point characteristic..................................................... 118
7.13 Cycling Power Profile ..................................................................................................................................... 119
7.13.1 Use case implemented by using the Cycling Power service, the Device Information service and the
Battery service ....................................................................................................................................... 119
7.13.2 Use case implemented by using the Cycling Power Control Point characteristic .................................. 121
7.13.3 Use case implemented by Broadcaster role and Observer role .............................................................. 122
7.14.1 Use case implemented by using the Glucose service and the Device Information service .................... 123
7.14.2 Use case implemented by using the Record Access Control Point characteristic .................................. 124
7.15 Time Profile .................................................................................................................................................... 125
7.15.1 Use case implemented by using the Current Time service .................................................................... 125
7.15.2 Use case implemented by using the Next DST Change service ............................................................ 125
7.15.3 Use case implemented by using the Reference Time Update service .................................................... 126
7.16 Running Speed and Cadence Profile ............................................................................................................... 127
7.16.1 Use case implemented by using the Running Speed and Cadence service and the Device Information
service .................................................................................................................................................... 127
7.16.2 Use case implemented by using the SC Control Point characteristic..................................................... 128
7.17.1 Use case implemented by using the Alert Notification service ............................................................. 129
7.17.2 Use case implemented by using the Alert Notification Control Point characteristic ............................. 130
7.18 Phone Alert Status Profile ............................................................................................................................... 131
7.18.1 Use case implemented by using the Phone Alert Status service ............................................................ 131
7.18.2 Use case implemented by using the Ringer Control Point characteristic ............................................... 131
7.19 Location and Navigation Profile ..................................................................................................................... 133
Index-3
7.19.1 Use case implemented by using the Location and Navigation service, the Device Information service and
the Battery service ................................................................................................................................. 133
7.19.2 Use case implemented by using the LN Control Point characteristic .................................................... 134
7.20 Vendor Specific .............................................................................................................................................. 136
7.20.1 Peak current consumption notification .................................................................................................. 136
9.1 About the Code Flash Library......................................................................................................................... 144
9.2 About setting for the Code Flash library ......................................................................................................... 144
9.3 Notes on using the Code Flash library ............................................................................................................ 144
10. Note on Writing User Application .............................................................................................................. 145
10.1 Note on RWKE Timer Management Function ............................................................................................... 145
10.2 Interrupt disabled time of the task and the interrupt handler .......................................................................... 145
10.3 Data transmission of large size data ................................................................................................................ 145
10.4 Performance of BLE MCU ............................................................................................................................. 145
11. Implementation of FW Update Feature ..................................................................................................... 147
11.1 The FW Update Feature .................................................................................................................................. 147
11.2 Function required for FW Update ................................................................................................................... 147
11.2.1 Writing function to the code flash ......................................................................................................... 147
11.2.2 Data transmission and reception profile ................................................................................................. 147
11.2.3 Application for update control (for Receiver device) ............................................................................ 149
11.2.4 Application for update control (for Sender device) ............................................................................... 150
11.3 Limitation and Special Processing .................................................................................................................. 151
11.3.1 Area switching control ........................................................................................................................... 151
11.3.2 Update the standard library (IAR Embedded Workbench only) ............................................................ 151
11.3.3 Limitation for FW Update feature implementation ............................................................................... 152
11.3.4 Update target area and User RAM area ................................................................................................. 153
12.3.2 How to Use ............................................................................................................................................ 157
Appendix A Referenced Documents ................................................................................................................ 159
Appendix B Terminology................................................................................................................................... 160
Index-5
Bluetooth Low Energy Protocol Stack
User
’s Manual
R01UW0095EJ0122
Rev.1.22
Mar. 30, 2018
1. Overview
This manual describes the API (Application Program Interface) of the basic features of the Bluetooth Low Energy
protocol stack (BLE software), which is used to develop Bluetooth applications that incorporate Renesas Bluetooth low
energy microcontroller RL78/G1D.
For details about the BLE software APIs, see Bluetooth Low Energy Protocol Stack API Reference Manual.
R01UW0095EJ0122 Rev.1.22 Page 1 of 162
Mar. 30, 2018
2. Applicability
2. Applicability
The descriptions in this manual apply to Bluetooth Low Energy protocol stack Version 1.21 or later.
R01UW0095EJ0122 Rev.1.22 Page 2 of 162
Mar. 30, 2018
3. Restrictions
3. Restrictions
This section describes the restrictions that apply to BLE software.
R01UW0095EJ0122 Rev.1.22 Page 3 of 162
Mar. 30, 2018
4. Installing BLE Software
4. Installing BLE Software
4.1 Components Included
The compressed package of the BLE software includes the followings:
•Documents
- Bluetooth Low Energy Protocol Stack User's Manual (this document)
- Bluetooth Low Energy Protocol Stack API Reference Manual
- Bluetooth Low Energy Protocol Stack Sample Program Application Note
- rBLE command specifications
•Project files used for creating the executable file
- Executable file
- BLE software library
- Sample source code
- Source code that configures parameters
2
studio project file
- e
- CS+ for CC project file
- CS+ for CA,CX project file
- IAR Embedded Workbench workspace file
•Sample applications for computer
- Executable file
- Source code
- Microsoft Visual Studio Express 2015 project file
•HCI packet monitor application for computer
- Executable file
- INI file
4.2 BLE software build environment
The environment in which BLE software was built is shown below.
•Hardware environment
- Host
• PC/AT™-compatible computer
• Processor : At least 1.6 GHz
• Main memory : At least 1 GB
• Display : 1024 x 768 or higher resolution and 65,536 colors
• Interface : USB 2.0 (E1 and USB-serial conversion cable)
• Tools used
• Renesas on-chip debugging emulator E1
• Software environment
• Windows 7 or later
• Microsoft Visual Studio Express 2015 for Desktop
R01UW0095EJ0122 Rev.1.22 Page 4 of 162
Mar. 30, 2018
4. Installing BLE Software
• Microsoft .NET Framework 4 + language pack
• Renesas CS+ for CC V4.00.00/ RL78 Compiler CC-RL V1.03.00
or e² studio 4.3.1.001/RL78 Family C Compiler Package V1 (without IDE) V1.03.00
or Renesas CS+ for CA, CX V3.02.00/Renesas CA78K0R V1.72
or IAR Embedded Workbench for Renesas RL78 V2.20.1
•Renesas Flash Programmer V3
(available from https://www.renesas.com/software-tool/renesas-flash-programmer-programming-gui)
For details about the environment in which to run the sample application for computers, see Bluetooth Low Energy
Protocol Stack Sample Program Application Note.
4.3 Installation Procedure
Copy the decompressed contents of the package to any folder in your computer.
2
Note: If using the e
To build the BLE software, the EEPROM Emulation Library and Code Flash Library are needed. Libraries for testing are
contained in the BLE software package in advance. But when you start to develop a product, it is necessary to download the
newest libraries corresponding to your development environment from Renesas website and copy to the following folder.
The EEPROM Emulation Library and Code Flash Library are provided by Renesas Electronics Corporation. Regarding
how to install the libraries, refer to 4.4.2 (7) and 4.4.2 (8).
EEPROM Emulation Library and Data Flash Access Library