logo资料库

DA14580软件开发快速入门.pdf

第1页 / 共24页
第2页 / 共24页
第3页 / 共24页
第4页 / 共24页
第5页 / 共24页
第6页 / 共24页
第7页 / 共24页
第8页 / 共24页
资料共24页,剩余部分请下载后查看
Contents
Figures
Tables
1 Terms and definitions
2 References
3 Introduction
4 Creating a new project
4.1 Create an application project folder from template
4.2 Create a Keil project file folder from template
4.3 Editing your new project
4.3.1 Edit project directory tree
4.3.2 Edit project include path
4.4 Edit configuration of the project
5 Project Oriented Functionality – User Defined
6 Addition of existing application code for profiles
6.1 Enable the profile
6.2 Add application profile source files to the project
6.3 Add the newly referenced header files path to the project include paths:
6.4 Add the profile header files to the project
6.5 Create the profile database and enable profile
6.6 Application verification
7 Peripheral drivers utilization
7.1 Configure peripherals
7.2 Add peripheral drivers in project.
7.3 Initialize peripherals
7.4 Further reading
8 Project configuration
8.1 Configuration directives
8.2 Further reading
9 Using sleep API
9.1 Sleep mode API functions
9.2 App sleep hooks
9.3 Further reading
10 Create a new profile
10.1 Project and source files
10.2 API Messages and handlers
10.3 Creation of profile task
10.4 Add services and attributes in database
10.5 Send Notification for second characteristic
10.6 Further reading
11 Developing application layer profile code
11.1 Create folder and files
11.2 Sending messages to profile
11.3 Message handlers
11.4 Adding code in project
12 Application initialization
12.1 Application and stack initialization
12.2 Further reading
13 Console print using the UART
Appendix A Opening your project for the first time with Keil
Issue description
Possible causes
Versions of Keil uVision found to be affected
Under which circumstances user will encounter this error
A proposed solution
14 Revision history
Company confidential User manual DA14580 Software development guide UM-B-003 Abstract This document provides basic guidelines for developers, in order to get familiar with DA14580 Software Development Kit and create the first BLE application based on it.
UM-B-003 DA14580 Software development guide Company confidential Contents Contents ............................................................................................................................................... 2 Figures .................................................................................................................................................. 3 Tables ................................................................................................................................................... 3 1 Terms and definitions ................................................................................................................... 4 2 References ..................................................................................................................................... 4 3 Introduction .................................................................................................................................... 5 4.2 4.1 4 Creating a new project .................................................................................................................. 5 Create an application project folder from template ............................................................... 5 Create a Keil project file folder from template ....................................................................... 5 Editing your new project ........................................................................................................ 5 Edit project directory tree ........................................................................................ 5 Edit project include path ......................................................................................... 6 Edit configuration of the project ............................................................................................ 7 4.3.1 4.3.2 4.3 4.4 5 Project Oriented Functionality – User Defined ........................................................................... 7 6.2 6.1 6 Addition of existing application code for profiles ..................................................................... 8 Enable the profile .................................................................................................................. 8 Add application profile source files to the project ................................................................. 8 Add the newly referenced header files path to the project include paths: ............................ 9 Add the profile header files to the project ............................................................................. 9 Create the profile database and enable profile ..................................................................... 9 Application verification .......................................................................................................... 9 6.3 6.4 6.5 6.6 7.1 7 Peripheral drivers utilization ........................................................................................................ 9 Configure peripherals .......................................................................................................... 10 Add peripheral drivers in project. ........................................................................................ 10 Initialize peripherals ............................................................................................................ 10 7.3 Further reading .................................................................................................................... 11 7.2 7.4 8 Project configuration .................................................................................................................. 11 Configuration directives ....................................................................................................... 11 Further reading .................................................................................................................... 12 8.1 8.2 9.1 9 Using sleep API ........................................................................................................................... 12 Sleep mode API functions ................................................................................................... 12 App sleep hooks .................................................................................................................. 13 Further reading .................................................................................................................... 13 9.2 9.3 10.2 10.1 10 Create a new profile .................................................................................................................... 13 Project and source files ....................................................................................................... 13 API Messages and handlers ............................................................................................... 14 Creation of profile task ........................................................................................................ 14 Add services and attributes in database ............................................................................. 15 Send Notification for second characteristic ......................................................................... 16 Further reading .................................................................................................................... 16 10.6 10.5 10.3 10.4 11 Developing application layer profile code ................................................................................ 17 Create folder and files ......................................................................................................... 17 Sending messages to profile ............................................................................................... 17 11.1 11.2 User manual Revision 1.4 16-Jul-2014 CFR0012-00 Rev 1 2 of 24 © 2014 Dialog Semiconductor GmbH
UM-B-003 DA14580 Software development guide Company confidential 11.3 11.4 Message handlers ............................................................................................................... 17 Adding code in project ......................................................................................................... 17 12 Application initialization ............................................................................................................. 18 Application and stack initialization ...................................................................................... 18 Further reading .................................................................................................................... 19 12.1 12.2 13 Console print using the UART ................................................................................................... 20 Appendix A Opening your project for the first time with Keil ....................................................... 22 Issue description ........................................................................................................................... 22 Possible causes ............................................................................................................................ 22 Versions of Keil uVision found to be affected ................................................................................ 22 Under which circumstances user will encounter this error .................................................. 22 14 Revision history .......................................................................................................................... 23 Figures Figure 1: Edit project directory tree ....................................................................................................... 6 Figure 2: Edit include paths ................................................................................................................... 6 Figure 3: Database initialization sequence .......................................................................................... 18 Figure 4: Peripheral device initialization sequence ............................................................................. 19 Figure 5: Central device initialization sequence .................................................................................. 19 Tables Table 1: Common app api functions ...................................................................................................... 7 Table 2: Project configuration .............................................................................................................. 11 Table 3: UART PC console settings .................................................................................................... 21 Table 4: Template project UART2 GPIO configuration ....................................................................... 21 User manual Revision 1.4 16-Jul-2014 CFR0012-00 Rev 1 3 of 24 © 2014 Dialog Semiconductor GmbH
UM-B-003 DA14580 Software development guide Company confidential 1 Terms and definitions BLE GAPM ISR SDK Bluetooth Low Energy Generic Access Profile Manager Interrupt Service Routine Software Development Kit 2 References 1. UM-B-015, DA14580 Software Architecture, Dialog Semiconductor 2. UM-B-006, DA14580 Sleep mode configuration, Dialog Semiconductor 3. UM-B-004, DA14580 Peripheral Drivers, Dialog Semiconductor 4. UM-B-011, DA14580 Memory Map-Scatter File, Dialog Semiconductor 5. Riviera Waves Kernel (RW-BT-KERNEL-SW-FS) 6. GAP Interface Specification (RW-BLE-GAP-IS) 7. ATTDB Interface Specification (RW-BLE-ATTDB-IS) User manual Revision 1.4 16-Jul-2014 CFR0012-00 Rev 1 4 of 24 © 2014 Dialog Semiconductor GmbH
UM-B-003 DA14580 Software development guide Company confidential 3 Introduction Basic instructions and guidelines on how a developer can use the DA14580 Software Development Kit (SDK) to create an application based on it and add application specific functionality. Document reader must have already read in UM-B-015 Software Architecture [1] where the DA14580 SDK organization and architecture are described in details. 4 Creating a new project This section describes the steps needed for creating a new application project starting from the application template provided in DA14580 SDK. 4.1 Create an application project folder from template 1. In windows explorer, locate your DA14580 SDK distribution and open the folder: dk_apps\src\modules\app\src\app_project 2. Make a clone of template_fh. 3. Rename the newly created folder to e.g. my_application. 4. Open folder my_application. IMPORTANT NOTE: Do not alter the contents of “system “ folder. 5. Rename the file app_template_proj.c to e.g. app_myproject_proj.c 6. Rename the file app_template_proj.h to e.g. app_myproject_proj.h 4.2 Create a Keil project file folder from template 1. Open the folder: dk_apps\keil_projects 2. Make a clone of template folder. Rename the newly created folder to e.g. myproject. 3. Open folder myproject. 4. Rename folder template_fh to e.g. myproject 5. Open folder myproject. 6. Rename fh_project_template.uvproj (there will be only one of these files in the folder) to e.g. my_project.uvproj. 4.3 Editing your new project Double-click on my_project.uvproj to open the Keil project. 4.3.1 Edit project directory tree 1. In Project Explorer, expand group app and right-click on the file app_template_proj.c. On the pop-up menu, click on Options for File ‘app_template_proj.c’. In tab Properties, edit the Path from ..\..\..\src\modules\app\src\app_project\template_fh\app_template_proj.c to ..\..\..\src\modules\app\src\app_project\my_application\app_myproject_proj.c. 2. Expand group arch and right-click on the file periph_setup.c. On the pop-up menu, click on Options for File ‘periph_setup.c’. In tab Properties, edit the Path from ..\..\..\src\modules\app\src\app_project\template_fh\common\periph_setup.c to ..\..\..\src\modules\app\src\app_project\my_application\system\periph_setup.c. User manual Revision 1.4 16-Jul-2014 CFR0012-00 Rev 1 5 of 24 © 2014 Dialog Semiconductor GmbH
UM-B-003 DA14580 Software development guide Company confidential Figure 1: Edit project directory tree 4.3.2 Edit project include path In Project Explorer, select the root group “Full_emb_cortex_M0”. 1. 2. On the main menu, click Project  Options for Target ‘Full_emb_cortex_M0’ and select the tab “C/C++”. 3. Double-click on the line: .\..\..\..\src\modules\app\src\app_project\template_fh and edit it to reflect the path of your application folder, e.g. : .\..\..\..\src\modules\app\src\app_project\my_application 4. Double-click on the line: .\..\..\..\src\modules\app\src\app_project\template_fh\system and edit it to reflect the path of the common folder in your application folder, e.g.: .\..\..\..\src\modules\app\src\app_project\ my_application\system Figure 2: Edit include paths User manual Revision 1.4 16-Jul-2014 CFR0012-00 Rev 1 6 of 24 © 2014 Dialog Semiconductor GmbH
UM-B-003 DA14580 Software development guide Company confidential 4.4 Edit configuration of the project 1. Open da14580_config.h file and replace the following line to declare the specific application: #define CFG_APP_TEMPLATE with e.g. #define CFG_APP_MYPROJECT. 2. Open rwip_conifg.h file and add the following lines to convert the configuration directive into a zero/one switch: #if defined(CFG_APP_MYPROJECT) #define BLE_APP_MYPROJECT 1 #else // defined(CFG_APP_MYPROJECT) #define BLE_APP_MYPROJECT 0 #endif // defined(CFG_APP_MYPROJECT) 3. Open app_api.h file and add the following lines to export types and declaration of the specific project to the BLE common application code: #if (BLE_APP_ MYPROJECT) #include "app_myproject_proj.h" #endif 4. Open app_myproject_proj.c file and replace line to replace old header file with the new one: #include "app_template_proj.h" with #include "app_myproject_proj.h". 5 Project Oriented Functionality – User Defined A list of “callback” functions is defined in file app_myproject_proj.c. These “callback” functions are referenced by BLE application common code (files app.c, app_task.c, app_sec.c, app_sec_task.c) and they cannot be removed. User/developer must enter application specific code in the following “callback” functions defined in file app_myproject_proj.c. Table 1: Common app api functions APP CallBack Functions Initialization app_init_func app_sec_init_func app_db_init_func Project actions in app_init Project actions in app_sec_init during system initialization Project actions for profiles database initialization app_db_init_complete_func Handles completion of databases creation. i.e. Device configuration app_set_dev_config_complete_func Called upon device configuration completion app_param_update_func Sends request to update connection parameters. app_configuration_func Project configures GAPM. Called upon reset completion app_update_params_complete_func Called upon connection parameters update completion app_update_params_rejected_func Called upon connection parameters update rejection Advertise app_adv_func Setup advertise string app_adv_direct_complete Handles direct advertising completion app_adv_undirect_complete Handles undirect advertising completion Connection app_connection_func app_disconnect_func Actions in app_connect (device connection) Actions in app_disconnect User manual Revision 1.4 16-Jul-2014 CFR0012-00 Rev 1 7 of 24 © 2014 Dialog Semiconductor GmbH
UM-B-003 DA14580 Software development guide Company confidential APP CallBack Functions Central role app_scanning_completed_func Handles the completion of scanning procedure app_adv_report_ind_func Handles reception of advertise report indication app_connect_func Sends a connection request message app_connect_failed_func Handles connection request failure Security app_sec_encrypt_ind_func Handles encryption indication app_paired_func Project action when device is paired app_send_pairing_rsp_func App_sec_encrypt_complete_func Sends pairing response message Called upon pairing request message reception. Project actions when encryption request is completed successfully app_sec_encrypt_ind_func Handles encryption indication app_validate_encrypt_req_func Validates encryption request message app_sec_encrypt_complete_func Project actions when encryption request is completed successfully app_mitm_passcode_entry_func app_send_tk_exch_func app_send_irk_exch_func app_send_csrk_exch_func app_send_ltk_exch_func Start passcode entry process. Called in gapc_bond_req_ind_handler(tk_type == GAP_TK_KEY_ENTRY) Send GAPC_TK_EXCH. Called in gapc_bond_req_ind_handler(tk_type == GAP_TK_KEY_DISPLAY) Send GAPC_IRK_EXCH. Called in gapc_bond_req_ind_handler/GAPC_IRK_EXCH Send GAPC_CSRK_EXCH. Called in gapc_bond_req_ind_handler/GAPC_CSRK_EXCH Send GAPC_LTK_EXCH. Called in gapc_bond_req_ind_handler/GAPC_LTK_EXCH 6 Addition of existing application code for profiles In this section, application code initializing and controlling Device Information Service Server Role (DISS) profile will be added to the application. 6.1 Enable the profile Open file da14580_config.h and add: #define CFG_PRF_DISS 1 This will define BLE_DIS_SERVER identifier as 1 and includes DISS profile source code files in project. 6.2 Add application profile source files to the project In Project Explorer, right click on group app and select Add Existing Files to Group ‘app’. Navigate to the path: dk_apps\src\modules\app\src\app_profiles\diss, and add the files: app_diss.c and app_diss_task.c. User manual Revision 1.4 16-Jul-2014 CFR0012-00 Rev 1 8 of 24 © 2014 Dialog Semiconductor GmbH
分享到:
收藏