Home

STM32 - nRF51822 Bluetooth Low Energy system solution

image

Contents

1. Cortex M Target Driver Setup 0 Cortex M Target Driver Setup ee li Options for Target nrf51822 xab_s110 128K Device Target Output Listing User C C Aam Linker Debug Utites C Use Simulator Setings Use GERT T Umi Speed to Real Time IV Load Application at Startup F Runto main FF Load Application at Startup F Runto main Initialization Fle Initialization Fle H amp l Restore Debug Session Settings Restore Debug Session Settings IV Breakpoints IV Toobox IV Breakpoints F Toolbox IV Watch Windows amp Performance Analyzer M Watch Windows IV Memory Display IV Memory Display CPU DLL Parameter Driver DLL Parameter ISARMCM3 DLL Dialog DLL Parameter TARMCM1 DLL fpcmo Debug Trace Rash Download Debug Trace Fash Download Download Function RAM for Algorithm IDCODE Device Name Lp Fax Erase Sectors Stat 020000000 Size 00800 SWDIO x0BB11477 ARM CoreSight SW DP C Do not Erase c La oue ui Description Address Range RFS box On chip Fash 00000000H DOIFFFFFH Cache Options Download Options gt Reset Atodetea F7 CacheCode I Very Code Download Stat 00000000 Size 00200000 IV Cache Memory Download to Bash ox ces ex dez dp eur DoclD026388 Rev 1 15 45 S
2. Frontline BLE air sniffer is used to capture in real time all data transmit over the air 2 DoclD026388 Rev 1 41 45 System limitations AN4499 8 System limitations e The STM32 shall not enter standby mode when BLE is enabled 2 42 45 DoclD026388 Rev 1 AN4499 Revision history 9 2 Revision history Table 7 Document revision history Date 25 June 2014 Revision 1 initial release Changes DoclD026388 Rev 1 43 45 AN4499 Please Read Carefully Information in this document is provided solely in connection with ST products STMicroelectronics NV and its subsidiaries ST reserve the right to make changes corrections modifications or improvements to this document and the products and services described herein at any time without notice All ST products are sold pursuant to ST s terms and conditions of sale Purchasers are solely responsible for the choice selection and use of the ST products and services described herein and ST assumes no liability whatsoever relating to the choice selection or use of the ST products and services described herein No license express or implied by estoppel or otherwise to any intellectual property rights is granted under this document If any part of this document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products or services
3. 33 45 2 DoclD026388 Rev 1 BLE application configuration AN4499 6 6 1 34 45 BLE application configuration The Nordic nRF51822 SDK provides examples how to manage the different profiles and Services To allow customers to verify BLE profiles and services two applications are available in the STM32 Project directory e Direct Test Mode application STM dtm app project e Heart Rate Monitoring Health Thermometer application STM ble app project Figure 17 Application overview Software Heart rate sensor Temperature simulator sensor Heart rate Temperature data value SD messages LEDs amp Buttons HRM HTS Server HRM HTS Client MS34133V1 Architecture The application part contains the code source to manage the different BLE services To use a BLE profile several services are initialized Next the service manages the values characteristics the notifications and BLE events by using the Soft Device functions and events The files ble services c are reused from the Nordic SDK 2 DoclD026388 Rev 1 AN4499 BLE application configuration 6 2 6 3 2 Direct test mode application The Direct Test Mode application is a firmware example that manages to initialize the nRF51822 to enter Direct Test Mode and redirect the nRF51822 UART to the tester e Project STM dtm app To initialize the DTM on nRF51822 side the following fu
4. Sleep Mode DMA HSI Clock HCI Cldkk Activation mm BOB MOM BOR HON OE BOR BOE EE HON MOM BOE EE EE EE EE LP STOP Time T Active As example Start Advertising Command with Tactive 458 us typ e RUN mode 48 typ Connection average power consumption To predict power consumption in dynamic approach typical profile scenarios are selected on which the device is connected to Mobile phone running Android or iOS BLE application as shown in Figure 12 The Heart Rate Monitoring Application is used to measure the system power consumption DoclD026388 Rev 1 39 45 Performances results AN4499 40 45 Figure 21 STM32 heart rate monitoring mobile notification vmm A9 1417 STM32_HRM DISCONNECT Peripheral STM32_HRM RSSI 64 db Address E2 CA F5 A2 B6 11 Status connected Heart Rate Measurement s details Peripheral STM32_HRM Address CA F5 A2 B6 11 Service Heart Rate UID 0000180d 0000 1000 8000 00805f9b34f Characteristic Heart Rate Measurement UUID 00002a37 0000 1000 8000 00805f9b34fb Data Type 32bit float Properties 0x0010 notify Notification ing 90 bpm Decimal 9 Jpdated 2014 03 05 14 17 46 174 The Table below indicate average power consumption for HRM HTS profile providing data to mobile phone at different connection interval System configuration is set as follow 1 x STM32Nucleo 64 board revC with STM32L152RE 1 x
5. lt T AN4499 Ts life augmented Application note STM32 nRF51822 Bluetooth Low Energy system solution Introduction The scope of this document is to describe the Bluetooth Low Energy BLE software STSW STM32149 implementation on the STM32L1 series and nRF51822 with the following features e Compatible with BLE profiles provided by Nordic e Application integration ready e Easy add on of low power BLE solution on STM32L 1 series e Extremely low STM32L1 CPU load HRS 1s update rate 0 065 e No latency requirements on STM32L1 series e Small STM32L1 memory footprint This document also describes how to interface to your own customer application and create your BLE services Customer application examples on STM32L 1 using the Nordic BLE services are provided The reference hardware platform is based on the STM32Nucleo 64 and the Wavetek Bluetooth LE shield with Nordic BLE module nRF51822 The software supports the following list of products Note It can be ported to other STM32 series Figure 1 STM32 Nordic nRF51822 BLE system solution June 2014 DoclD026388 Rev 1 1 45 www st com Contents AN4499 Contents 1 References EERDER RAS SEER REEDE ar ER ERES SS 6 2 Product definition sis ES ar 7 3 Getting started sc cris HERE ER eben 9 3 1 BLE system description ss EER E SEER RA RE Eh EE BREER REA ws 9 3 2 Features PPS 9 3 3 Hardware software quick setup 10
6. eHSclkMode pstorage init 0 Low Power LPM Mode Reguest Manager eld eMode Application MS34117V1 2 DoclD026388 Rev 1 25 45 Software description AN4499 Figure 12 NVM design overview Application HAL_NVM_Operation eOperation UserAddress NVMAddress Size HAL_NVM_Init HAL NVM Register NVMAdaressBlock BlockSize HAL NVM Read UserAddress NVMAddress Size HAL NVM HSclkReguest eHSclkMode Low Power Manager EEPROM MS34139V1 5 3 1 BLE SD FW module The following interfaces from the BLE SD FW module shall be mapped to the NVM driver e pstorage register e pstorage block identifier get e pstorage store e pstorage load e pstorage clear e pstorage init A default mapping to the timer server is done in the file ble nvm c There is no need for the application to make any modification 5 3 2 Initialization e HAL NVM Init This API shall be called before any request is done to the NVM driver 26 45 DoclD026388 Rev 1 2 AN4499 Software description 5 3 3 Operations e HAL NVM Register This API reserves a block of the required size in the NVM and returns the base address to the user e HAL NVM Operation This API is used to either write or erase data in the NVM When a write operation is requested the user shall provide the address of the da
7. 3 Operations sis Ge ed DR ea da REOR ce RC RU DIR Ron 27 5 3 4 Low power manager 27 5 3 5 Configuration 0 ar OE NE en 27 5 3 6 Integration 44244 bere Here dubbed 28 5 4 Low power manager interface 28 5 4 1 Dr TA rU 30 5 4 2 Configuration dazu ae Hera Bares ON 334 30 5 4 3 E Ae eee eee Seed doa a eae Ae ae eae a a 30 5 5 Exit from standby mode sis ss se DR ED ER EE oh dai 30 5 6 BLE SD FW module firmware integration in application 31 5 6 1 BLE StaFUP si 2544 rebns eher ar 31 5 6 2 Communication with the BLE SD FW module 31 5 7 Nordic delivery integration 32 6 BLE application configuration 34 6 1 Architecture cuidara dida 34 6 2 Direct test mode application 35 6 3 Heart rate monitoring Health thermometer application 35 6 3 1 Advertising application 36 6 3 2 Heart Rate application 36 6 3 3 Health thermomether application 37 7 Performances results corrio risa 38 7 1 Static power consumption 38 7 2 SD command exchange power consumption profile 38 7 3 Connection average power consumption 39 7 4 Data throughput
8. 4 Reference platform 5 2 2242 ka KERE DEERE Ra RR ER RE 12 4 1 Interface description 12 4 2 UART 4 wire interface 84 13 4 3 EE A N EE ER ON ON 13 4 3 1 Power on reset EE neuen en een nn 13 4 3 2 SE da ira ner 13 4 4 Device programming ss kase HERE PRES aan ERO en REX a ae ee 14 5 Software description 16 5 1 nidi T HER ESE DE GE SEGE A 16 5 1 1 BLE SD FW module si eh ie 5054 RV PERRA ay as ran 18 5 1 2 Low power manager 18 5 1 3 Interr pt IE RE N RE N OE AURI RO EORR d 18 5 1 4 Context manager 18 5 1 5 CONNQUFAUON RE EE ER aan at ee pu d Rod 19 5 1 6 STM32 resource requirements when BLE feature is used 19 5 1 7 Integration 2 tree ee en 20 5 2 Timer interface MET 20 5 2 1 BLE SD FW module 22 5 2 2 Initialization RR OE aa ea ae 22 5 2 3 User module ii ik RR EE RR lud Re ako yh ees 23 5 2 4 Context manager 41 4444444i44u hh nn 23 5 2 5 Configuration 23 5 2 6 Integration u iuo ees He are ara ara 24 5 3 NVM interface ea nen a a ME OE ea 24 2 45 DoclD026388 Rev 1 Ly AN4499 Contents 5 3 1 BLE SD FW module 26 5 3 2 Initialization oa eem RE ERU EA RR HR TRECE 26 5 3
9. Wavetek Arduino shield with BLE module nRF51822v1 0 Voltage 3 3V STM32 CPU HCLK Clock 8MHz UART 1MegaBaud Ambient Temperature 25 C Firmware STM ble app define APP HRS 2 DoclD026388 Rev 1 AN4499 Performances results Table 5 HRS profile average power consumption STM32L1524APP HRS Connection Interval amp Heart rate update 250ms 500ms 1s 2 5s 4s nRF51822 Power consumption uA 80 47 95 32 19 22 87 19 96 STM32 Power consumption uA 9 7 5 76 3 77 2 57 2 34 Total Power LE TOP Mode consumption 89 7 53 71 35 96 25 44 223 STM32 nRF51822 uA CPU load 0 250 0 125 0 062 0 025 0 015 NB Numbers are typical measured on a single STM32 nRF51822 solution for reference only 7 4 Data throughput The following data throughput is measured using the same system configuration as describe previously To reach maximum data throughput over the air between The STM32 nRF51822 BLE system and BLE remote device the connection interval is fixed to 7 5ms and data packet are sent via L2CAP Layer Table 6 Maximum data throughput L2CAP average power consumption STM32L152 ZAPP L2CAP TX TEST L2CAP throughput Test Connection Interval 7 5 ms Average Payload Throughput 89 kbit s nRF51822 Power consumption uA 6 596 mA STM32 Power Consumption uA 1 014mA LP STOP Mode Total power consumption STM32 nRF51822 uA 7 61mA CPU Load 22
10. is connected to the STM32 A system reset the STM32 which subsequently will generate a reset pulse on the GPIO to reset the nRF51822 This will guarantee that both the STM32 and the nRF51822 devices are reset on a system reset To allow STM32 to reset nRF51822 by GPIO Wavetek Bluetooth LE shield jumpers reset J5 amp J6 shall be OFF if D9 and nReset J6 1 are connected by a cable Another option is to reset the system by STM32Nucleo 64 system reset jumper J5 shall be OFF and jumper J6 shall be ON if the cable is not connected DoclD026388 Rev 1 13 45 Reference platform AN4499 4 4 Device programming The system solution provides FW download possibility through ST LINK for both the STM32 and the nRF51822 serialized application The nRF51822 Soft Device can t be loaded with the ST LINK See the STM32Nucleo 64 HW User Manual on how to program the software To program the STM32 solution with the ST LINK V2 the following procedure has to be respected e Remove SWD cable connection e STM32Nucleo 64 CN2 jumpers ON e Seethe example done with the STM32 ST LINK Utility to program the STM32 on STM32Nucleo 64 Board Connect ST LINK Utility Tool with option connect under reset Open STM ble app hex Program Figure 6 STM32 programming with ST LINK Utility File Edit View Target ST UNK xtemalloader Help Device Information Device STM32L bx high density 512K Device ID 0x437 Revision ID RevA Flash size
11. or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such third party products or services or any intellectual property contained therein UNLESS OTHERWISE SET FORTH IN ST S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE USE AND OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND THEIR EQUIVALENTS UNDER THE LAWS OF ANY JURISDICTION OR INFRINGEMENT OF ANY PATENT COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT ST PRODUCTS ARE NOT DESIGNED OR AUTHORIZED FOR USE IN A SAFETY CRITICAL APPLICATIONS SUCH AS LIFE SUPPORTING ACTIVE IMPLANTED DEVICES OR SYSTEMS WITH PRODUCT FUNCTIONAL SAFETY REQUIREMENTS B AERONAUTIC APPLICATIONS C AUTOMOTIVE APPLICATIONS OR ENVIRONMENTS AND OR D AEROSPACE APPLICATIONS OR ENVIRONMENTS WHERE ST PRODUCTS ARE NOT DESIGNED FOR SUCH USE THE PURCHASER SHALL USE PRODUCTS AT PURCHASER S SOLE RISK EVEN IF ST HAS BEEN INFORMED IN WRITING OF SUCH USAGE UNLESS A PRODUCT IS EXPRESSLY DESIGNATED BY ST AS BEING INTENDED FOR AUTOMOTIVE AUTOMOTIVE SAFETY OR MEDICAL INDUSTRY DOMAINS ACCORDING TO ST PRODUCT DESIGN SPECIFICATIONS PRODUCTS FORMALLY ESCC QML OR JAN QUALIFIED ARE DEEMED SUITABLE FOR USE IN AEROSPACE BY THE CORRESPONDING GOVERNMENTAL AGENCY Resale of ST products with provisions different from the statements and or technical fe
12. ss Re sata ER EX ERA 41 8 System limitations sis SE SERE EERS BERE SERE SEE EER RR RR RE 42 9 Revision history ss ded SESSE EERS RES RES RD REEL EE E E 43 Ky DocID026388 Rev 1 3 45 List of figures AN4499 List of figures Figure 1 Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 Figure 7 Figure 8 Figure 9 Figure 10 Figure 11 Figure 12 Figure 13 Figure 14 Figure 15 Figure 16 Figure 17 Figure 18 Figure 19 Figure 20 Figure 21 4 45 STM32 Nordic nRF51822 BLE system solution 1 STM32 nRF51822 system architecture 8 STM32 nRF51822 HRM on Android 11 HW platform stacking Arduino signals 12 nRF51822 STM32 communication interface UART 4 wire 13 STM32 programming with ST LINK Utility 14 nRF51822 device programming 15 UART interface overview o oocoooocooneo nennen 17 Timer interfaces overview 22 mann nenn eee hh 21 Timer design overview 22 NVM interfaces overview 25 NVM design overview 26 Low power manager interfaces overview 28 Low power ma
13. the availability of the HS clock The request comes asynchronously to the application In addition the application may have some requirements on the availability of the HS clock that would come as well asynchronously to both the UART and NVM driver requests There is a need for the application to implement a module that would take care of all these requirements and to compute the lowest power mode the system may enter at any time The low power manager provides a simple interface to receive the input of different users up to 32 and computes the lowest power mode the system may enter It provides as well hooks to the application before entering or on exit of low power mode Figure 13 Low power manager interfaces overview LPM Mode Request eld eMode HAL UART EnterStandByMode UART Driver Leave HAL_UART_ExitStandByMode LPM_Enter_Mode LPM_ExitStopMode HAL_UART_HSclkRequest eHSclkReguester eHSclkMode Wrapper Low Power Manager 0 o S t o 2 E z n E LPM EnterStandbyMode NVM Driver HAL NVM HSclkRequest eHSclkMode LPM ExitStandbyMode Application MS34140V1 2 DoclD026388 Rev 1 AN4499 Software description Figure 14 Low power manager design overview Application 4 LPM_Mode_Request eld eMode LPM_Enter_Mode 0 LPM_ExitStopMode 0 LPM_EnterStandbyMode 0 LPM_ExitStandbyMode 0 STM32 Deepsleep LPSDR PPDS DocID026
14. 388 Rev 1 MS34141V1 29 45 Software description AN4499 5 4 1 5 4 2 5 4 3 5 5 30 45 API e LPM Mode Request This API shall be used by all users to specify the lowest low power mode it supports e LPM Enter Model This API shall be used by the application when there is no more code to execute so that the system may enter low power mode e LPM ExitStopMode This API is called by the low power manager in a critical section PRIMASK bit set to allow the application to implement dedicated code before getting out from the critical section This is the location where the application should reconfigure the clock tree as the system gets out from Stop mode with the MSI clock selected as source clock e LPM EnterStandbyMode This API is called by the low power manager in a critical section PRIMASK bit set to allow the application to implement dedicated code before entering standby mode This is the location where the application could save data in the retention memory as the RAM memory content will be lost e LPM ExitStandbyMode This API is called by the low power manager in a critical section PRIMASK bit set to allow the application to implement dedicated code before getting out from Standby mode This can only happen when the Standby mode is finally not entered In that case the application may reverse some configurations done before entering Standby mode When Standby mode is successful the
15. 512KBvtes OxC344 Data width 32bts v Device Memory 0x08000000 File STM_ble_app hex STM le app hex Address range 0x08000000 Ox0800C 344 Address 0 Ja 20001470 08001081 osooso 0B0010BF 00000000 00000000 080010C5 00000000 Josoooce osooroce 08004025 Logootocs OOICB osomoce osooroce Dana Innen oammner losnatncr SET TIRONES STM32L box high density 512K TT DEVE TAST 14 57 11 Device family 22 Di from dev jonne vice 1D 0x437 14 57 26 Device flash Size 512KBytes 14 57 26 Device family STM32L box high density 512K 15 01 02 Flash memory programmed in 4s and 461ms fonnetion mode Connect Under Reset Device 1D 0x437 2 14 45 DoclD026388 Rev 1 AN4499 Reference platform 2 To program the nRF51822 solution with the ST LINK the following procedure has to be respected STM32Nucleo 64 CN2 jumpers OFF Wavetek Bluetooth LE shield RST J5 amp J6 Jumpers OFF nReset between STM32 amp nRF51822 not connected Connect JTCK STM32Nucleo 64 ST link SWD CNA pin2 to Wavetek Bluetooth LE shield JLINK SWDCLK pin4 Connect SWDIO STM32Nucleo 64 ST link SWD CN4 pin4 to Wavetek Bmuetooth LE shield J6 pin1 or JLINK SWDIO pin2 See the example done with Keil to program the nRF51822 on Wavetek Bluetooth LE shield Use ST Link Debugger Select Debug port SW Select Programming Algorithm nRF51xxx Figure 7 nRF51822 device programming
16. AHB clock in Sleep Mode DMA1LPEN bit in the RCC AHBLPENR register The SRAM AHB clock in Sleep Mode SRAMLPEN bit in the RCC AHBLPENR register The SYSCFG APB2 clock SYSCFGEN bit in the RCC_APB2ENR register The PWR APB1 clock PWREN bit in the RCC_APB1ENR register The APB clock of the USARTx selected in the file hal uart driver configuration h USARTXEN bit in the RCC_APBxENR register The APB clock in Sleep mode of the USARTx selected in the file hal uart driver configuration h USARTXLPEN bit in the RCC_APBxLPENR register DoclD026388 Rev 1 19 45 Software description AN4499 5 1 7 5 2 20 45 Integration To include the UART low power driver in an existing application using BLE SD FW the application shall 1 Setthe configuration required USART lOs baudrate wakeup pin and interrupt priority in the file hal uart driver configuration h 2 Include the file hal uart c in the project 3 Map the UART BLE interface on the HAL UART driver This step is already done in the wrapper implemented in the file ble uart c The application may just include that file in the project 4 Update the application low power manager to call the HAL UART EnterStandByModel before entering standby mode This step is done in the low power manager provided in the example If standby mode is not supported in the application there is nothing to do 5 Update the application low power manager to call the HAL UART ExitStandByMode whe
17. S PA1 O A1 UART STM32 RX Flow Control RTS O USART2 CTS PAO I AO UART nRF51822 RX Flow Control nRESET I PC7 GPIO O D9 BLE nReset nRF51822 device VCC 3V3 Power provided by STM32Nucleo 64 GND GND Ground The additional application interface between STM32 and Wavetek board consist of the following Arduino signals Table 3 Interface between the STM32 and Wavetek board Application Signal 10 Arduino Comment PA10 GPIO 10 D2 GPIO LED3 D3 PB3 GPIO 10 D3 GPIO LED2 D2 PB5 GPIO IO D4 GPIO LED1 D1 PB4 GPIO 10 D5 GPIO Button3 SW3 PA8 GPIO 10 D7 GPIO Button2 SW2 PA9 GPIO 10 D8 GPIO Button1 SW1 2 DoclD026388 Rev 1 AN4499 Reference platform 4 2 UART 4 wire interface The UART 4 wire interface is used to communicate between the 2 devices The HW CTS RTS flow control signals are also used for the low power control 4 3 Reset system The reset system can be divided into the following functions e Power on reset e System reset nRF51822 shield Wavetek jumper reset J1 shall be OFF Figure 5 nRF51822 STM32 communication interface UART 4 wire STM32Nucleo 64 MS34120V1 4 3 1 Power on reset Both the STM32 and the nRF51822 have their own integrated power on reset detector these will guarantee that both the STM32 and the nRF51822 devices are reset correctly on application power on 4 3 2 System reset 2 A system reset button
18. TimerMode pfTimerCallBack HAL TIMER Start ubTimerlD uh TimeoutTicks sisropitielviriualitiraenrt running Context e Move the virtual timer to List of virtual timers HAL TIMER Stop the pending state up to 255 Pu t s ubTimerlD e Keep the Id reserved Module e Status e Schedule a virtual timer Timeout Module2 e Callback Free HAL_TIMER_Create Free eTimerModulelD pTimerld Free eTimerMode pfTimerCallBack va ui z Fr o 2 o 5 2 va HAL_TIMER_Start e Move the virtual timer to the active state Doux ubTimerlD uhTimeoutTicks e Schedule a virtual timer e Stop the virtual timer if running e Remove the virtual timer from the list HAL TIMER Delete e Schedule a virtual timer ubTimerlD HAL_TIMER_Notification e Notify the virtual timer expires eTimerModulelD pFTimerCallBack e Move the timer to the pending state if single shot mode e Keep the virtual timer in the active state if repeated mode e Schedule a virtual timer MS34138V1 5 2 1 BLE SD FW module The following interfaces from the BLE SD FW module shall be mapped to the timer server e ble timer create e ble timer start e ble timer stop A default mapping to the timer server is done in the file ble timer c There is no need for the application to make any modification 5 2 2 Initialization HAL TIMER Init This API shall be called by the application before a
19. aged by the timer server It cannot be restarted again The user has to go with the creation of a new timer if required and may get a different timer id 5 2 4 Context manager e HAL TIMER Notification This API notifies the application that a timer expires This API is running in the RTC Wakeup interrupt context The application may implement an Operating System to change the context priority where the timer Callback may be handled This API provides the module ID to identify which module is concerned and to allow sending the information to the correct task 5 2 5 Configuration Some parameters of the Timer server may be configured in the file hal timer h e MAX NBR CONCURRENT TIMER The user may define the maximum number of virtual timer supported It shall not exceed 255 Default configuration is 8 e NVIC UART RTC WAKEUP IT PRIORITY The user may define the priority in the NVIC of the RTC WKUP interrupt handler that is used to manage the wakeup timer Default configuration is 3 e eHAL TIMER ModulelD t The user shall define the list of Module Id that the timer server shall support 2 DoclD026388 Rev 1 23 45 Software description AN4499 5 2 6 5 3 24145 Before running the Timer server the application shall e Configure the input clock of the RTC and the clock prescaler This is defining the timer tick In the current implementation the timer tick is equal to the LSI input clock divided by 16 432us It may provid
20. atures set forth in this document shall immediately void any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever any liability of ST ST and the ST logo are trademarks or registered trademarks of ST in various countries Information in this document supersedes and replaces all information previously supplied The ST logo is a registered trademark of STMicroelectronics All other names are the property of their respective owners 2014 STMicroelectronics All rights reserved STMicroelectronics group of companies Australia Belgium Brazil Canada China Czech Republic Finland France Germany Hong Kong India Israel Italy Japan Malaysia Malta Morocco Philippines Singapore Spain Sweden Switzerland United Kingdom United States of America www st com 44 45 DoclD026388 Rev 1 Ly
21. e a timeout value up to 28s e Keep the access always available in the RTC register while the Timer server is running e Keep disable the write protection in the RTC block while the Timer server is running Integration To include the TIMER server in an existing application the application shall 1 Include the file hal timer c in the project 2 Map the Timer BLE interface on the HAL Timer server This step is already done in the wrapper implemented in the file ble timer c The application may just include that file in the project 3 When an Operating System is used the HAL TIMER Notification may be used to send a signal with the associated parameter to handle the Callback in a different context than the RTC Wakeup interrupt This API is executed within the RTC Wakeup interrupt handler context This API shall be implemented by the application The timer created by the BLE SD FW module is deleted on a disconnect event The application shall first disconnect the link before switching OFF the nRF device to make sure the reserved timer for BLE is deleted NVM interface The BLE SD FW module requires storing some parameters in a non volatile memory While the firmware is running the BLE SD FW module keeps a copy in the RAM memory This copy in RAM is uploaded at BLE initialization with the data from the NVM When a parameter is updated a store to NVM is requested There is no read access to the NVM from the BLE SD FW module except at initiali
22. e in memory to be used for identity verification when they reconnect in the future After the startup of the application pushing the button B1 erases all the stored bonding information It is also recommended to delete the bonding information on the remote device Once a BLE connection is done the button B1 is used to update and provide the Heart value to the connectivity device Table 4 configuration of the BLE application ADV only HRS Only HTS only HRS amp HTS Device name STM32 ADV STM32 HRM STM32 HRS STM32 HRM HTS Manufacturer Name STM32 Advertising Interval 40ms Connection Interval NA 1s Conn Sup Timeout NA 4s Heart rate Heart Rate Battery Health Device Information BLE Services NA Battery device a Thermometer Health Information Thermometer 1 The connection Interval is proposed by the server once service notification is requested by the Client Advertising application In case both APP_HRS and APP_HTS are not defined the application manages the advertising interval the device name the GAP configuration and connection establishment according to the following parameters The application also manages the connection disconnection and timeout events Heart Rate application Once the APP HRS is defined the application includes e Heart Rate Service e Device Information Service e Battery Service The application reuses the Nordic Services code e
23. erence manual Nordic http www nordicsemi com 3 nRF51822 Product Specification Nordic http www nordicsemi com 4 Nordic Serializer project APIs http www nordicsemi com 5 STM32L151xx Reference Manual ST http www st com 6 STM32L15x Datasheet Production data ST http www st com 7 STM32 Nucleo HW User Manual ST http www st com 8 Wavetek Arduino Bluetooth LE shield UM Wavetek http www wavetek com hk 2 DoclD026388 Rev 1 AN4499 Product definition 2 2 Product definition The following firmware components are used e STM32 BLE application solution including the BLE SD FW Module e nRF51822 S110 SoftDevice binary see reference to Nordic documentation e nRF51822 connectivity serialized solution from Nordic see reference to Nordic documentation Table 1 STM32 memory footprint ROM Kbytes RAM Kbytes Full BLE SD FW Module 31 3 23 When HRS application only 22 8 f NVM driver Timer server UART driver low 3 3 0 7 power Manager The STM32 nRF51822 application provides a 2 chip BLE solution where the STM32 operates as a host device and nRF51822 is the connectivity part In the STM32 nRF51822 system the whole BLE stack is situated on the nRF51822 device which interfaces to the STM32 via a UART The BLE SD FW module UART timer NVM and the customer application are built on the STM32 platform The customer app
24. iguration is UART2 on PAO PA1 PA2 and PA3 The application may change the UART baudrate However it is recommended to keep the default setting 1Mbits for power consumption optimization The application may select which wakeup pin is used to get out of Standby mode on request from the nRF51822 connectivity device Default is WakeupPin1 The wakeup pin selected shall be connected to the STM32 CTS line The UART driver uses DMA UART and EXTI interrupts The priority set in the NVIC may be changed to allow the application to select the best priority with regard to already existing interrupts and timing requirement The UART driver is able to run fine whatever priority is set It is recommended to keep the same order as the default configuration which provides the best latency over UART Default order is DMA the highest UART and EXTI the lowest 5 1 6 STM32 resource requirements when BLE feature is used The UART driver requires some hardware resources that shall be made available before enabling the BLE feature These hardware resources shall be kept enable as long as the BLE feature is enabled The application should switch OFF all these hardware resources when BLE is disabled to save power The hardware resources concerned are 2 The GPIO AHB clock on which the UART is mapped from the file hal uart driver configuration h GPIOXEN bit in the RCC AHBENR register The DMA1 AHB clock DMA1EN bit in the RCC AHBENR register The DMA1
25. lication may be either a dedicated simple BLE application or a wider application on which BLE connectivity is added The following modules are required to add a BLE connectivity to the STM32 e Profile service management The BLE services are running on the nRF51822 system and this module is providing an implementation proposal on the STM32 side to manage each supported BLE services Although the implementation proposal is ready to be used the user may implement its own services management e BLE SD FW module This module is not expected to be modified by the user It provides an interface to the application to send and receive messages with the nRF51822 system It requires from the STM32 platform a timer a UART and a NVM Timer server The Timer Server is an implementation proposal of a module that can provide multiple virtual timers all sharing the RTC Wakeup The BLE Module gets a timer from that module to operate but the user may implement its own timer mechanism to be connected to the BLE Module e NVM driver The Non Volatile Memory driver is a very specific implementation proposal using the EEPROM suitable to be used by the BLE SD FW module It provides an efficient mechanism to minimize the performance impact of the high latency required to write in DoclDO26388 Rev 1 7145 Product definition AN4499 8 45 the EEPROM The user may implement its own NVM driver to be connected to the BLE SD FW Module UART dri
26. m 1 to 65535 ticks The timer server provides multiple virtual timers sharing the Wakeup TIMER Each virtual timer may be defined to be a single shot timer or a repeated timer When a repeated timer elapses the user is notified and the virtual timer is restarted automatically with the same timeout When a single shot timer elapses the user is notified and the virtual timer is set to the pending state The user may stop a virtual timer and restart it with a different timeout DoclD026388 Rev 1 Ly AN4499 Software description 2 value When a virtual timer is not needed anymore the user should delete it to free the slot in the timer server Figure 9 Timer interfaces overview Application ble_timer_create p timer id mode timeout handler ble timer start timer id timeout ms p context ble timer stop timer id 3 S t o 2 m W E HAL TIMER Create eTimerModulelD pTimerld eTimerMode pfTimerCallBack HAL TIMER Start ubTimerlD uh TimeoutTicks HAL TIMER Delete ubTimerlD HAL TIMER Init 0 HAL TIMER Stop ubTimerlD HAL_TIMER_Notification eTimerModulelD pfTimerCallBack MS34137V1 DoclD026388 Rev 1 21 45 Software description AN4499 Figure 10 Timer design overview TIMER Server Application HAL TIMER Init 0 Register a virtual timer with its context in the pending state HAL_TIMER_Create eTimerModulelD pTimerld e
27. n the CPU wakes up after failing entering standby mode This step is done in the low power manager provided in the example If standby mode is not supported in the application there is nothing to do 6 Implement the API HAL UART HSclkReduest to handle the HS clock requirement and AHB DMA1 clock according to the low power UART driver activity 7 When either USART1 or USART3 is selected update the EXTI15 10 IRQHandler to call the HAL UART wcts handler when the CTS line has triggered the interrupt The HAL UART wcts handler shall not be called if the CTS line is not the source that triggers the EXTI15 10 _IRQHandier When USART2 is selected there is nothing to do and the low power UART driver is taking care of it 8 When an Operating System is used the HAL UART Msg Handler may be used to send a signal with the associated parameter to handle the message in a different context than the UART interrupt This API is executed within the UART interrupt handler context Timer interface The BLE SD FW module uses a timer to timeout the connection parameters negotiations with the remote device In order to save power consumption this timer should be running on either the LSI or LSE LPO clock The timer server provides the following features e Upto 255 virtual timers or less due to RAM limitation e Single shot and Repeated mode e Stop a virtual timer and restart it with a different timeout value e Delete a timer e Timeout up fro
28. nager design overview 29 Scheduler implementation 32 Nordic delivery integration 33 Application overview 2 34 Application DTM access 35 RxSD command exchange power consumption 38 TxSD command exchange power consumption 39 STM32 heart rate monitoring mobile notification 40 2 DoclD026388 Rev 1 List of tables List of tables Table 1 STM32 memory footprint 7 Table 2 Interface between the STM32 and nRF51822 12 Table 3 Interface between the STM32 and Wavetek board 12 Table 4 configuration of the BLE application 36 Table 5 HRS profile average power consumption 41 Table 6 Maximum data throughput L2CAP average power consumption 41 Table 7 Document revision history 43 Ly DocID026388 Rev 1 5 45 References AN4499 6 45 References 1 nRF51822 Soft Device specification Nordic htto www nordicsemi com 2 nRF51822 Ref
29. nces results AN4499 7 7 1 7 2 38 45 Performances results This chapter relates system performance measured for power consumption amp data throughput It describes efficiency of the overall system in term of low power consumption along with maximum data throughput achievable Static power consumption The referenced STM32 Static power consumption numbers such as Standby mode Low Power Stop Mode are to be taken from the STM32 Datasheet reference 6 SD command exchange power consumption profile Next graph shows in detail power values diagram of Power Consumption on STM32 devices for UART message processing through the BLE SD FW MODULE while In UART Receiving Mode by Current vs Time using APP HRS only Figure 19 RxSD command exchange power consumption Current N ARM Activation Payload header detection ARM data processing Deactivation m m HON EE E N N EN ee N N E N EN E n n n aa 2 RUN Mode a EE meel n n n n nle n n n n MEI Sleep Mode 4 DMA UART Data byte reception using DMA oon AO n n mm EE HSI Clock HS1Clock Activation a n n EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE EE LP STOP Tine I T Active As example Start Advertising Command with Tactive 800 us typ e RUN mode 40 typ 2 DoclD026388 Rev 1 AN4499 Performances results 7 3 2 Figure 20 TxSD command exchange power consumption Current N Pun o RUN Mode hon
30. nction sends information to the nRF51822 e ble dtm init amp uart params The DTM uart parameters are configured by the following defines e defineDTM RX PIN NUMBER 10 e defineDTM TX PIN NUMBER 11 e 57600 is the default Uart Baud rate Next the STM32 after having sent the DTM command goes to Standby When in DTM test mode the UART between the STM32 and nRF51822 does no longer operate The nRF51822 communicates directly to the BLE tester via the UART on the configured set of IO s If needed the conversion from 3 3V to RS232 is done outside the Wavetek Bluetooth LE shield by a RS232 to 3 3V TTL Converter i e SerialComm TTL 232 33P Figure 18 Application DTM access Wavetek Bluetooth STM32Nucleo 64 LE Shield DTM test DTM mode RS232 select Access Application FW MS34142V1 Heart rate monitoring Health thermometer application The STM ble app project allows the customers to enable both the Heart Rate service or and the Health Thermometer service In case both compilation switches are not used the firmware just initializes and starts the advertiser parameters The configuration is done with stm3211xx conf h file e define APP HRS e define APP HTS DoclD026388 Rev 1 35 45 BLE application configuration AN4499 6 3 1 6 3 2 36 45 The application supports the bond manager The identification information exchanged between central device and peripheral device are stor
31. nd Wavetek Bluetooth LE shield ST LINK CN2 jumpers are On Load STM32L1 App ble binary on STM32 with Keil or other tool STM32 ST LINK Utility e Reset the System with Button Reset B2 on Nucleo Board e BLE State is advertising Use Android or iPhone application to verify the advertiser packets 2 10 45 DoclD026388 Rev 1 AN4499 Getting started 2 Figure 3 STM32 nRF51822 HRM on Android ST 14 16 BLE Scan OPTION a STM32_HRM E2 CA F5 A2 B6 11 DoclD026388 Rev 1 die Reference platform AN4499 4 4 1 12 45 Reference platform Interface description The STM32 nRF51822 system HW platform will consist of a STM32Nucleo 64 board from STMicroelectronics with a plugged nRF51822 Wavetek Arduino shield with BLE Module nRF51822 from Nordic In addition there is possibility to add an application module on top of the system via an extended Arduino shield Figure 4 HW platform stacking Arduino signals Optional Application BLE module nRF51822 Wavetek Bluetooth LE Shield Arduino connectors STM32Nucleo 64 The interface between the STM32 and nRF51822 consist of the following Arduino signals Table 2 Interface between the STM32 and nRF51822 nRF51822 Signal IO STM32 Signal IO Arduino Comment RXD I USART2 TX PA2 O D1 UART data STM32 to nRF51822 TXD O USART2 RX PA3 I DO UART data nRF51822 to STM32 CTS USART2_RT
32. ndler_reg HAL_UART_uart_open event_handler pf_PhyDriverEvent_Handler app_uart_stream_write HAL_UART_send_data p_buffer length pbuffer uhlength app_uart_stream_rx_buffer_set HAL_UART_receive_data p buffer num of bytes header pbuffer app uart stream close 0 app uart stream open p comm params Application side UART Driver LPM EnterStandbyMode HAL_UART_EnterStandByMode Low Power 0 0 Protocol Low Power LPM_ExitStandbyMode HAL_UART_ExitStandByMode Manager 0 LPM_Mode_Request HAL UART HSclkRequest eld eMode eHSclkRequester eHSclkMode HAL UART Msg Handler pf PhyDriverEvent Handler pPhyDriverEvent HAL UART wcts handler 0 MS34136V1 2 DoclD026388 Rev 1 17 45 Software description AN4499 5 1 1 5 1 2 18 45 BLE SD FW module The following interfaces shall be mapped to the BLE module They are not used by the application e HAL UART uart open e HAL UART send data e HAL UART receive data As the mapping is not depending on the application but only on the BLE SD FW module interface a default implementation is done in the file ble uart c There is no need for the application to make any modification Low power manager e HAL UART EnterStandByMode e This API shall be called by the application before entering Standby mode e HAL UART ExitStandByMode e This API shall be called by the application after the system did not succeed enteri
33. ng Standby mode This is recovering the configuration before the HAL UART EnterStandByMode has been called e HAL UART HSclkRequest e This API is notifying the application when the HS clock may be stopped and when it shall be kept enabled In addition the application may switch ON the AHB DMA clock when the HS clock is requested and switch OFF the AHB DMA1 clock when the HS clocked is not required This would save additional power when entering SLEEP mode Interrupt e HAL UART wcts handler This interrupt handler shall be called by the application in the EXTI15 10 IRQHandler interrupt handler only when either USART1 or USARTS is used as interface with the connectivity device When USART2 is selected the UART driver is implementing the EXTIO IROHandler Context manager e HAL UART Msg Handler This API is notifying the BLE SD FW module that an event occurred on the UART interface By default all messages are handled in the UART interrupt context The application may implement an Operating System to change the context priority where the BLE messages may be handled A signal to the BLE task may be sent from this API to notify a full message has been received over UART 2 DoclD026388 Rev 1 AN4499 Software description 5 1 5 Configuration The UART driver is fully configured in the file hal_uart_driver_configuration h The application may select to use USART1 USART2 or USART3 and chose the IO mapping Default conf
34. nvm h e NVM OPERATION QUEUE SIZE The user may define the maximum number of operations to be queued It shall not exceed 255 Default configuration is 30 e NVM BASE ADDRESS The user may define the base address in the NVM from where the NVM driver may allocate blocks to the user There is no block size limitation checking in the NVM driver Default configuration is 0x08082000 This is the start address of the EEPROM in bank2 as the code is by default running in bank1 This prevents latencies when the NVM is written while the code is running from FLASH e NVM IT PRIORITY The user may define the priority in the NVIC of the FLASH interrupt handler that is used to notify the NVM driver the end of programming Default configuration is 3 2 DoclD026388 Rev 1 27145 Software description AN4499 5 3 6 5 4 28 45 Integration To include the NVM driver the application shall 1 Setthe configuration required in the file hal timer h 2 Include the file hal nvm c in the project 3 Map the pstorage BLE interface on the HAL NVM driver This step is already done in the wrapper implemented in the file ble nvm c The application may just include that file in the project 4 Implement the API HAL NVM HSclkRequest to handle the HS clock requirement according to the NVM driver activity Low power manager interface When the BLE feature is used it requires the UART and NVM driver to be supported Both drivers have some requirements on
35. ny timer is requested to the timer server It configures the RTC module to be connected to the LSI input clock 22 45 DoclD026388 Rev 1 2 AN4499 Software description 5 2 3 User module e HAL TIMER Create The user shall call this API to create a timer Once created the timer is reserved to the module until it has been deleted When creating a timer the user shall specify the mode Single shot or Repeated the Callback to be notified when the timer expires and a Module ID to identify in the timer interrupt handler which module is concerned In return the User gets a timer ID to handle it e HAL TIMER Start This API shall be used to start a timer The timeout value is specified and may be different each time When the timer is in the Single shot mode it will move to the pending state when it expires The user may restart it at any time with a different timeout value When the timer is in the Repeated mode it always stay in the running state When the timer expires it will be restarted with the same timeout value This API shall not be called on a running timer e HAL TIMER Stop This API may be used to stop a running timer A timer which is stopped is move to the pending state A pending timer may be restarted at any time with a different timeout value but the mode cannot be changed e HAL TIMER Delete This API should be used when a timer is not needed anymore by the user A deleted timer is removed from the timer list man
36. oftware description AN4499 5 Note 5 1 16 45 Software description This section provides a description of the interfaces of the different blocks shown in figure2 STM32 nRF51822 system architecture e The interfaces between the BLE SD FW module and the STM32 peripherals UART Timer NVM Clocking e The interfaces between the BLE SD FW module and the application e The project structure folder It describes the split between the BLE SD FW module as such that does not require any modification by the application and the files that need to be adapted by the application In the current delivery the lowest low power mode supported when BLE is enabled is LP Stop The application may enter Standby mode when BLE is not enabled Although it is described below in that chapter there is no need for the application in the current delivery to e Connect the UART CTS on the Wakeup pin e Callthe API HAL UART EnterStandByMode when the device enters Standby mode e Call the API HAL UART ExitStandByMode when the device exits Standby mode UART Interface The BLE module sends and receives data over the UART interface The UART driver provides a simple interface to send and receive messages and implements a proprietary protocol to notify the application when the UART may be disabled to enter low power mode 2 DoclD026388 Rev 1 AN4499 Software description Figure 8 UART interface overview app_uart_stream_evt_ha
37. ometer service e Direct Test Mode entry e Advertiser Only DoclD026388 Rev 1 9 45 Getting started AN4499 3 3 Hardware software quick setup e Plug Wavetek Bluetooth LE shield on STM32Nucleo 64 board via the Arduino connectors See Figure at the front page 1 e Connect the STM32 Nucleo 64 board to the PC with an USB cable USB cable not provided e The PWD LED2 shall light up e As pre condition the nRF51822 S110 Soft Device binary must be programmed Refer to Nordic Quick Starter Guide documentation This part can t be programmed with the ST LINK e The nRF51822 needs to be programmed with the Connectivity serialized application e To program the Connectivity serialized via ST LINK ST LINK CN2 jumpers are OFF Wavetek Bluetooth LE shield RST J5 amp J6 Jumpers OFF Connect SWDCLK interface pin STM32Nucleo 64 ST LINK SWD CN4 pin 2 to Wavetek Bluetooth LE shield P1 JLINK SWDCLK pin4 Connect SWDIO interface pin STM32Nucleo 64 ST LINK SWD CN4 pin4 to Wavetek Bluetooth LE shield J6 1 Load Connectivity binary on nRF51822 with Keil or other tool e Select BLE feature for STM32 ble app application Open STM32 ble app project with MDK ARM Microcontroller Development Kit by Keil or other tool Open stm32l1xx conf h to configure your project and compile e Program the STM32 with STM32 ble app application Remove SWD interface connections between STM32Nucleo 64 ST LINK a
38. rt for mbed SB13 and SB14 ON SB62 and SB63 OFF As the communication between the target MCU and shield or extension board is required SB62 and SB63 should be ON SB13 and SB14 should be OFF The solution is composed of the following software items e STMicroelectronics BLE FW package three pre compiled applications stm dtm app hex stm hrs app hex Stm hts app hex e nRF51822 SoftDevice binary www nordicsemi com e S110 nrf51822 6 0 0 softdevice hex e nRF51822 serialized solution from Nordic www nordicsemi com ble app connectivity hex As the reference platform to run the previous software the following hardware items are used e 1x STM32Nucleo 64 board revC with STM32L152RE see Nucleo Rev C Hardware User manual 7 for more details By default the USART2 communication between the target MCU and ST LINK MCU is enabled in order to support Virtual Com Port for mbed SB13 and SB14 ON SB62 and SB63 OFF As the communication between the target MCU and shield or extension board is required SB62 and SB63 should be ON SB13 and SB14 should be OFF e 1 x Wavetek Arduino shield with Nordic BLE module nRF51822 see Wavetek shield User Manual 8 for more details Android Phone running STM32 BLE Toolbox can be used as demonstration tool e STM32 BLE Toolbox apk delivered with the solution Features The followings BLE services are supported with the system solution e Heart Rate service with Battery monitoring e Health Therm
39. ry in the STM32 project the steps are 1 Delete all folders from the Nordic delivery with a red cross in the figure below 2 Copy all files from the source delivery to the STM project as described below 2 DoclD026388 Rev 1 AN4499 Software description Figure 16 Nordic delivery integration Ji STM MX doc 4 STMa nRFSI Driver de Include 4 Interfaces All files i j Inc mm dx serialization 4 Ub ANS 4 bl e application y Inc 2X connectivity Bs gt lt connectivity mw Nu al codecs Lo Source inc Al files T d serialization u 4 Services application D inc y ds x connectivity 2X connectivity mw i stm X arm 2X ble app connectivity Al files TIRE All files gt lt nRF_hal inc XX NRF hal src The Interfaces folder contains the header interfaces between the BLE and the STM32 drivers in the inc folder and the implementation in the src folder As long as the interfaces in the inc did not change there is no reason to change the existing implementation in the src folder The Lib folder contains all internal BLE files that are not required to be changed by the application The user shall include the relevant headers in the project depending on which command and services are used in the application As long as the interfaces with the BLE SD FW module are not changed the integration of a new Nordic delivery has no impact on the application
40. sts or data to the BLE SD FW module with a SD command When a SD command is sent the application shall wait for the response before sending another SD command On each SD command the BLE SD FW module calls the API blocking_resp_wait to pause the BLE processing until the response is received The application may enter low power mode until the response is received In addition all events that do not require sending a SD command may be processed as well over that time As described below the current project provides a scheduler where the API blocking resp wait is implemented in the file blocking c to enter the background task when waiting for a response When the firmware enters the background task from the BLE SD FW module all events that do not require sending a SD command are processed DoclD026388 Rev 1 31 45 Software description AN4499 5 7 32 45 Figure 15 Scheduler implementation UART Driver Low Power Protocol Rx packet t Tx packet SD command Application BLE SD FW Module Event received Wait for event Waiting for Resp BLE Event to be processed Process Event Resp received When the Background is entered from the BLE Backg rou nd module only the events that do not require sending a SD command are processed t Enter low power mode Event to be processed Low Power Manager TIMER Server Nordic delivery integration To integrate the BLE Nordic delive
41. system is reset when getting out from this low power mode Configuration The application shall configure in the file stm3211xx_Ipm h the Id for each user supported and the list of low power mode supported The default lowest power mode supported for all users is Standby mode Integration To include the low power manager driver the application shall 1 Set the configuration required in the file stm3211xx Ipm h 2 Include the file stm3211xx_lpm c in the project Exit from standby mode The user may select in the UART configuration which Wakeup pin to use to exit standby mode on request of the nRF51822 system When several Wakeup pins are configured on the STM32 system the application shall manage the other wakeup pins The wakeup pin selected for the BLE feature is fully managed by the UART driver and the application does not need to implement dedicated code for this DoclD026388 Rev 1 Ly AN4499 Software description 5 6 BLE SD FW module firmware integration in application The STM32_ble_app project provides an application using the BLE SD FW module based on a scheduler It comes with a Timer server NVM driver and low power protocol UART driver to interface with the STM32 platform Whenever the BLE function is enabled the STM32 shall not enter standby mode the application shall take care that STOP mode is the lowest low power mode used The user may either implement its own services or integrate those which are provided in
42. ta to be copied the NVM destination address and the amount of data to be written The data shall be kept available at any time from the source address as the NVM driver does not make temporary copy When an erase operation is requested the user shall provide the base address in NVM of the data to be erased and the amount of data to erase The source address parameter when an erase operation is requested is not considered by the NVM driver and can be set to any value e HAL NVM Read This API is used to read an amount of data from the NVM The user shall provide the NVM start address the destination address where to copy the data and the amount of data to copy The NVM driver does not check whether the section to be read from the NVM may be in the operation queue to be written or not It is the responsibility of the application to not read a section if it may be on the way to be written 5 3 4 Low power manager e HAL NVM HSclkRequest This API notifies the application when the HS clock may be stopped and when it shall be kept enabled The NVM driver sends the notification when the operation queue gets a command and when the operation queue is empty There is no notification to the application for each command completed but this API may be used as well to make sure ALL commands Write Erase that have been sent to the NVM driver have been completed 5 3 5 Configuration Some parameters of the NVM driver may be configured in the file hal
43. the project 5 6 1 BLE startup When the nRF device is in OFF mode the application shall execute following steps to get BLE ready to be used 1 Enable the TIMER and NVM services The NVM driver is enabled at the same time the BLE SD FW module is initialized There is no additional implementation required in the application To enable the timer server the application shall called the API HAL TIMER 4Init 2 Enable hardware resources required for the BLE low power protocol UART driver All resources as described in 6 1 6 STM32 resource requirements when BLE feature is used are enabled in the API UART BLE Init The user may update the content of this API depending on its own implementation 3 Resetandinitialize the nRF device The nRF device shall be first reset before running any initialization The reset is applied when the API connectivity chip reset is called The firmware drives low the IO connected to the nRF nRESET pin for a minimum amount of time After that time the firmware configures the IO to analog mode to release the nRF nRESET pin The nRF nRESET pin should not be driven high to release the reset The reset timing requirement may be found on the Nordic website After the nRF device has been reset the firmware runs the nRF initialization with the API ble app main init Reset All details on the nRF initialization may be found on the Nordic website 5 6 2 Communication with the BLE SD FW module 2 The application sends reque
44. urity Level for battery report read attribute e Initialize Device information Service Manufacturer Name STM32 The application manages the GAP configuration and connection establishment according to the Bluetooth Specification Heart Rate Profile The Heart Rate values are provided by an application sensor module ble sensorsim c there is no external sensor Different timers are started to simulate e Battery measurement Heart Rate measurement e RR interval e Sensor contact detection At the first connection the parameters are provided by the client side The connection interval is requested by the application once the heart rate notification is enabled by the server ble_conn_param c Health thermomether application Once the APP HTS is defined the application includes e Health Thermomether Service The application reuses the Nordic Services code example e ble hts c The module ble hts c implements the Health Thermometer Service to provide to the Client the temperature in Degree Celsius the Temperature Type and the Time Stamp The temperature value is measured by the internal STM32 temperature sensor There is no external sensor At each indication enabled by the remote the temperature is measured provided to the nRF51822 and finally transferred to the remote The connection parameters are provided by the client side and may be changed by the application DoclD026388 Rev 1 37 45 Performa
45. ver The UART driver implements a proprietary low power protocol communication over UART between the STM32 and the nRF51822 system Although the user may implement its own driver it is strongly recommended to use the current implementation that has been pre integrated so that it is ready to be used Low power manager The UART and NVM drivers are making dynamically requests on the availability of the HS clock On top of this the application may have some modules that could require different low power mode over the time The low power manager provides an implementation proposal of an easy interface to receive all requests regarding power management and compute the lowest power mode the system may enter The user may implement its own low power manager A detailed description on the nRF51822 system is available on the Nordic s website The STM32 nRF51822 BLE system architecture is given in the figure below Figure 2 STM32 nRF51822 system architecture CUSTOMER APPLICATION Profile Service management BLE S140 i i SoftDevice BLE SD FW Module Connectivity Low Power TIMER ve UART Driver serialized NVM Dover Low Power Protocol CUSTOMER APPLICATION Drivers 2 DoclD026388 Rev 1 AN4499 Getting started 3 3 1 Note 3 2 2 Getting started BLE system description By default the UART communication between the target MCU and ST LINK MCU is enabled in order to support Virtual Com Po
46. xample e ble hrs c e ble dis c e ble bas c The module ble hrs c implements the Heart Rate Service with the Heart Rate Measurement Body Sensor Location and Heart Rate Control Point characteristics During initialization it adds the Heart Rate Service and Heart Rate Measurement characteristic to the BLE stack database It also adds the Body Sensor Location and Heart Rate Control Point characteristics DoclD026388 Rev 1 Ly AN4499 BLE application configuration 6 3 3 2 The module ble_dis c implements the Device Information Service During initialization it adds the Device Information Service to the BLE stack database It then encodes the supplied information and adds the corresponding characteristics The module ble bas c implements the Battery Service with the Battery Level characteristic During initialization it adds the Battery Service and Battery Level characteristic to the BLE stack database It also adds a Report Reference descriptor to the Battery Level characteristic used when including the Battery Service in the HID service By calling the previous modules the application initializes the services e Initialize Heart Rate Service Sensor Location Finger can be changed easily by a define Security Level for heart rate service measurement attribute Security Level for body sensor location attribute e Initialize Battery Service Security Level for battery characteristics attribute Sec
47. zation The BLE SD FW module always reads the parameters from the RAM copy The NVM driver has been designed to especially fit the BLE behavior Due to the high latency on writing data in the NVM the driver stores in a queue the operation write or erase requested and releases the CPU to keep on running code The NVM driver writes the data in the NVM and waits for the completion interrupt On each interrupt the NVM driver writes new data until there is no more data to be written As the NVM drivers stores only the operation to execute and the reference of the data these data shall be kept available in the RAM memory There is no feedback to the application of the completion of an operation During the programming of the NVM the HS clock shall be kept available The NVM driver notifies the application at the start end the end of the programming the lowest power mode supported 2 DoclD026388 Rev 1 AN4499 Software description Figure 11 NVM interfaces overview pstorage register o module param p block id HAL NVM Register NVMAddressBlock BlockSize HAL NVM Read UserAddress NVMAddress Size pstorage block identifier get p base id block num p block id HAL NVM Operation eOperation UserAddress NVMAddress Size pstorage store p dest p src size offset pstorage load p dest p src size offset HAL NVM Init 0 pstorage_clear p dest size HAL NVM HSclkRequest

Download Pdf Manuals

image

Related Search

Related Contents

- S&S Cycle  R3267 シリーズ OPT73 AMPS/JTACS/NTACS 解析 取扱説明書    White Rodgers 37-7237A Thermostat User Manual  山ノ手2号配水池解体工事(電気設備) 特記仕様書 四日市市上下水道局  Fiche Piratome (antidotes)  VACUSAFE Bedienungsanleitung  取 扱 説 明 書 - Acuvance  

Copyright © All rights reserved.
Failed to retrieve file