# Option 1: Using the CMSIS-Pack Features to Build Your Own Application

The easiest way to build your first RSL15 application is to modify one of the existing sample applications that are part of the RSL15 CMSIS-Pack.

While this method has many steps, each step is simple and makes use of the CMSIS-Pack features to allow for ease development and ease of updating when new CMSIS-Packs are released by onsemi. This is the applicable method for most users. Advanced users can consider using an alternate option, described in Option 1: Using the CMSIS-Pack Features to Build Your Own Application.

## Copying Application Code Files

In the onsemi IDE, use the CMSIS-Pack Manager to copy an example that closely resembles your end application. The example used in this topic is the ble_peripheral_server_sleep application, as shown in the "Copying the Sample Application" figure, but you can use the sample application that suits your purposes best. This process copies the application code to your workspace. (For more information about using the IDE and its Pack Manager, see the RSL15 Getting Started Guide.)

Figure: Copying the Sample Application

Once you have copied the application code files to your workspace, they can be seen in the project root directory, and the code, include, and RTE folders in the project explorer, as shown in the "Application Code Files" figure (using the ble_peripheral_server_sleep sample project as the example). These are the applications files; you can edit them, and/or add new files, to build your own RSL15 application.

IMPORTANT: When you start building your own application, give it a new unique name, so that you can later copy updated sample projects from future CMSIS-Packs into the same workspace for comparison. It is not recommended that you keep the same name as the sample project your application is based on. For this example, ble_peripheral_server_sleep is renamed ble_peripheral_server_sleep_my_app.

NOTE: When adding custom defines to the CMSIS-based project, the preprocessor defines must be added before the _RTE_ entry.

Figure: Application Code Files

## Library and System Files

The other software components remain in the CMSIS-Pack at the installed location (C:\users\<user_name>\ON_Semiconductor\PACK\ONSemiconductor\RSL15\<version_number>\firmware\) and are linked by your project. These links are visible in the "Library and System Files Linked by the Project" figure.

Figure: Library and System Files Linked by the Project

In most cases, these software components do not need to be modified by the user, so linking to the CMSIS-Pack is more efficient than copying these software component files to your workspace.

If you really do need to modify any of these software component files, you can go into the CMSIS-Pack and modify them directly, but be aware that his changes the files for all the sample code that links to those files.

The rteconfig file can be used to add software components to your project. The components can then be configured in the RTE_device.h file, using the CMSIS Configuration Wizard.

To add the software components, perform the following steps:

1. Double click <project_name>.rteconfig, as shown in the "Selecting the Project’s .rteconfig File" figure.

Figure: Selecting the Project’s .rteconfig File

2. Select the desired components (for example, SPI), as shown in the "Selecting the Components" figure. Save the changes.

NOTE: Only software components whose Vendor is listed as ONSemiconductor are developed and provided by onsemi.

Figure: Selecting the Components

This adds the linked driver source and header files, as shown in the "Driver Source and Header Files" figure.

NOTE: You might need to manually refresh the project view. To do this, right-click the project name and click Refresh to see the changes.

Figure: Driver Source and Header Files

Now the project includes your selected components — in the example seen in the "Initialization Code to Copy Manually" figure, this is the SPI driver. The initialization code must be manually copied from each component’s sample code into your project. Some header includes might need to be added to your application as well; for instance, #include <spi_driver>.h for the SPI driver. You can also copy the implementation from the component’s code sample, or develop your own.

Figure: Initialization Code to Copy Manually

The components can be configured in the RTE_device.h file. In RTE > Device > RSL15, right click RTE_device.h and choose Open With > CMSIS Configuration Wizard, as shown in the "Opening the CMSIS Configuration Wizard" figure.

Figure: Opening the CMSIS Configuration Wizard

This opens the CMSIS Configuration Wizard, which looks like the "CMSIS Configuration Wizard Window" figure:

Figure: CMSIS Configuration Wizard Window

This Wizard can configure some software components via a graphical interface, as shown in the "Applying Configuration with the CMSIS Configuration Wizard" figure.

NOTE: Selecting the component check box enables the configuration to be applied to the RTE_device.h file; however, it does not add the software component itself. Software components must be added using the .rteconfig.

Figure: Applying Configuration with the CMSIS Configuration Wizard

From the CMSIS Configuration Wizard, your desired components (the SPI driver in the "Linked Files Update Automatically" figure’s example) can be configured to your requirements.

## NCV-RSL15 Automotive Product Selection

When using the NCV-RSL15 automotive product, select the automotive_rsl15 variant for the HAL component in the RTEConfig file. This variant defines the AUTOMOTIVE definition, which selects the correct settings for the NCV-RSL15 automotive product. This is shown in the "NCV-RL15 Automotive Product HAL Variant" figure.

Figure: NCV-RL15 Automotive Product HAL Variant

## Updating to a New CMSIS-Pack

From time to time, onsemi releases an updated CMSIS-Pack. You might wish to update your project to the latest CMSIS-Pack version. This process is made more convenient by the CMSIS-Pack linking feature. To update the CMSIS-Pack, use the general procedure guideline that follows, modified for your specific situation if necessary:

NOTE: Review the release notes from the CMSIS-Pack before you begin, as some additional steps might be required for a specific release.

1. Download and install the latest CMSIS-Pack, as instructed in the RSL15 Getting Started Guide.
2. Open your project. The CMSIS-Pack linked library and system files in your project are automatically updated to point to the latest installed CMSIS-Pack, as seen in the "Automatically Updating to the Latest Installed CMSIS-Pack" figure.

Figure: Linked Files Update Automatically

Figure: Automatically Updating to the Latest Installed CMSIS-Pack

5. If you want to update the application code from the latest CMSIS-Pack samples, use the CMSIS-Pack Manager to copy the examples from the latest CMSIS-Pack. Before coping the new project, rename the old project by appending the SDK version (such as ble_peripheral_server_sleep_3_5) to help keep track of the different sample versions.
6. Compare your application to the latest sample from the CMSIS-Pack using the Eclipse Compare With feature, as shown in the "Comparing Your Sample Application to the Latest Version" figure, or with your preferred comparison tool.

Figure: Comparing Your Sample Application to the Latest Version

7. The output shows all the files and the changes within the files, as seen in the "Changes Shown Between Application Versions" figure.

Figure: Changes Shown Between Application Versions

8. Copy the changes from the latest CMSIS-Pack to your application as you see fit.

The linked library and system files in your project are automatically updated to point to the latest installed CMSIS-Pack, as seen in the "Linked Files Update Automatically" figure.