This section describes the software changes that are required when migrating a BLE application from the nRF51 Series to the nRF52 Series. The document assumes that you already have a BLE application running on the nRF51 Series. If you are starting a new development based on the nRF52 Series, please have a look at the nRF52 Series documentation and start with the development kits, SoftDevice and SDK based on the nRF52 Series directly.
Upgrade every component of the toolchain to the latest version in order to make the toolchain compatible with the nRF52 Series. The latest versions are also backward compatible with the nRF51 Series. This way you can develop an application in parallel for the nRF51 Series and the nRF52 Series with the latest components in the toolchain. The following toolchain components are required for the nRF52 Series:
The new S132 SoftDevice developed for the nRF52 Series is based on the S130 SoftDevice for the nRF51 Series. It supports both peripheral and central role concurrently. The API for S132 v1.0.0-3.alpha is aligned with the APIs for S110 v8.x.x, S120 v2.x.x and S130 v1.0.0. If you have an application running on S110 v8.x.x, S120 v2.x.x or S130 v1.x.x, the application should work with the S132 v1.0.0-3.alpha by adjusting the different memory settings as shown in ROM and RAM settings for the S132 v1.0.0-3.alpha SoftDevice. Newer S132 SoftDevices may have different memory settings and/or unaligned API compared with S132 v1.0.0-3.alpha. Refer to the release notes, migration document and SoftDevice Specification for details on any newer version of the S132 SoftDevice version. It is important that you recompile your application with the header files released with the S132 SoftDevice you are using.
This section describes the steps needed to port the ble_app_hrs example application in nRF51 SDK 8.1.0 to run on nRF52. A customer with a custom application that currently compiles and runs with nRF51 SDK 8.1.0 may find the steps helpful in porting their application to the nRF52 Series. A custom application may, however, need to follow only some of the steps mentioned in this example, or require additional steps, depending on what libraries and drivers are used. The following steps are tailored for Keil IDE but may also apply for developers using other toolchains for nRF5x development.
The following steps describe the changes needed to port the ble_app_hrs example from nRF51 SDK 8.1.0 to nRF52 SDK 0.9.0. If you are starting a new development based on the nRF52 Series, use the template examples provided by the nRF52 SDK, for example ble_app_hrs. This port is chosen here because the nRF52 SDK 0.9.0 is a close successor to the nRF51 SDK 8.1.0, so only minimal changes are required. If you have a more recent version of the nRF52 SDK, you may want to become familiar with the release notes for that specific nRF52 SDK version and add any potential steps to accommodate for changes made from nRF52 SDK 0.9.0. Similarly, if you have an nRF51 SDK version older than 8.1.0, see the nRF51 SDK release notes that represent the changes going from that nRF51 SDK version to nRF51 SDK 8.1.0.
The porting method chosen here is to let the ble_app_hrs example reside inside nRF51 SDK 8.1.0 and make changes to it there in order to port it to the nRF52 Series. You should create a separate copy of nRF51 SDK 8.1.0 to use with the nRF52 Series:
#if defined(S110) || defined(S130) || defined(S132)
// Enable BLE stack.
ble_enable_params_t ble_enable_params;
memset(&ble_enable_params, 0, sizeof(ble_enable_params));
#if defined(S130) || defined(S132)
ble_enable_params.gatts_enable_params.attr_tab_size = BLE_GATTS_ATTR_TAB_SIZE_DEFAULT;
#endif
ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT;
err_code = sd_ble_enable(&ble_enable_params);
APP_ERROR_CHECK(err_code);
#endif