CC2640R2 Launchpad
project 0

Congratulations on choosing the CC2640R2 microcontroller and LaunchPad ecosystem! This example is an easy starting point for developing your own Bluetooth® Smart application. The functionality and architecture of the example is presented on this page. It also explains how to flash and test the example on your LaunchPad. The next step is to load the project into CCS Cloud or download it to your computer for further development.

The CC2640R2 LaunchPad development kit includes everything you need to run and develop with this example.

  • (1) CC2640R2 LaunchPad
  • (1) Micro USB Cable

We will use a tailored project based on the TI Bluetooth Smart Software Developers Kit's SimpleBLEPeripheral project to demonstrate operation of your LaunchPad.

This example will allow you to control the LEDs from a mobile phone or other Bluetooth Smart capable device and subscribe to button press notifications from the LaunchPad. A log of the actions taken along with the code-line executed is output on the Application/User Serial port on your LaunchPad.

To get started follow these steps:
1
Plug your LaunchPad into the computer with the included USB cable
2
Program your LaunchPad by pressing on the button in the Sources section. The device should enter advertising state and be connectable from a Bluetooth Smart device.
3
[Optional]: To see the log messages during execution, open for example Putty and select the XDS110 Class Application/User UART at 115200 baud.
You can find the COM port number in Windows Device Manager (Start→Run→mmc devmgmt.msc and expand Ports)
4
Connect to the CC2640R2 Launchpad, write to change the LED state or subscribe to button status. Instructions for doing this with the iOS apps SensorTag and LightBlue and the Android app BLE Scanner can be found below.
SensorTag for iOS LightBlue for iOS BLE Scanner for Android
1
Download and install SensorTag by Texas Instrumens via the App Store
2
Scan for nearby devices, find ProjectZero and click on it, then select Service Explorer. The closest devices have the highest RSSI value (most bars).
3

Review the three custom BLE Services exposed by Project Zero. Find these at the bottom of the list.

All the custom service identifiers (UUIDs) are on the form F000XXXX-0451-4000-B000-000000000000 where each service has a different 16-bit XXXX-part identifier, and the rest of the UUID is the Texas Instruments 128-bit UUID namespace used for demo purposes.

The services can be identified from the 16-bit part of the UUID as follows:

    0x1110 – LED Service
    Service declaration
    0x1111 – LED0 State (marked with red box)
    Read state or write 01 or 00.
    0x1112 – LED1 State
    Read state or write 01 or 00.
    0x1120 – Button Service
    Service declaration
    0x1121 – BUTTON0 State
    Read state or subscribe to notifications
    0x1122 – BUTTON1 State
    Read state or subscribe to notifications
    0x1130 – Data Service
    Service declaration
    0x1131 – String char
    Read/Write a long string
    0x1132 – Stream char
    Send or receive WriteNoRsp/Notification


4

Turn on the LEDs.

Find the topmost custom service, which can be identified from the list above as the LED service

Tap the first characteristic entry to enter the Read/Write menu for the LED0 characteristic.

Tap on Write with response, write the numbers 01 and tap Write to change the LED0 state to ON.


5
Notice that the LED turns on when you write 01 and turns off if you write 00. You will also see the following log output:

6
Bonus: Subscribe to notifications on button presses and receive these in the application.
1
Download and install LightBlue by Punch Through Design LLC via the App Store
2
Scan for nearby devices, find ProjectZero and click on it. The closest devices have the highest RSSI value (least negative).
3

Review the three custom BLE Services exposed by Project Zero. Find these at the bottom of the list.

All the custom service identifiers (UUIDs) are on the form F000XXXX-0451-4000-B000-000000000000 where each service has a different 16-bit XXXX-part identifier, and the rest of the UUID is the Texas Instruments 128-bit UUID namespace used for demo purposes.

The services can be identified from the 16-bit part of the UUID as follows:

    0x1110 – LED Service
    Service declaration
    0x1111 – LED0 State (marked with red box)
    Read state or write 01 or 00.
    0x1112 – LED1 State
    Read state or write 01 or 00.
    0x1120 – Button Service
    Service declaration
    0x1121 – BUTTON0 State
    Read state or subscribe to notifications
    0x1122 – BUTTON1 State
    Read state or subscribe to notifications
    0x1130 – Data Service
    Service declaration
    0x1131 – String char
    Read/Write a long string
    0x1132 – Stream char
    Send or receive WriteNoRsp/Notification


4

Turn on the LEDs.

Find the topmost custom service, which can be identified from the list above as the LED service

Tap the first characteristic entry (red box above) to enter the Read/Write menu for the LED0 characteristic.

Tap on Write new value, write the numbers 01 and tap Done to change the LED0 state to ON.


5
Notice that the LED turns on when you write 01 and turns off if you write 00. You will also see the following log output:

6
Bonus: Subscribe to notifications on button presses and receive these in the application.
1
Download and install BLE Scanner by Bluepixel Technologies LLP via the Play Store
2
Scan for nearby devices, find ProjectZero and click Connect. The closest devices have the highest RSSI value (least negative).

3

Review the three custom BLE Services exposed by Project Zero.

All the custom service identifiers (UUIDs) are on the form F000XXXX-0451-4000-B000-000000000000 where each service has a different 16-bit XXXX-part identifier, and the rest of the UUID is the Texas Instruments 128-bit UUID namespace used for demo purposes.

The services can be identified from the 16-bit part of the UUID as follows:

    0x1110 – LED Service
    Service declaration
    0x1111 – LED0 State
    Read state or write 01 or 00.
    0x1112 – LED1 State
    Read state or write 01 or 00.
    0x1120 – Button Service
    Service declaration
    0x1121 – BUTTON0 State
    Read state or subscribe to notifications
    0x1122 – BUTTON1 State
    Read state or subscribe to notifications
    0x1130 – Data Service
    Service declaration
    0x1131 – String char
    Read/Write a long string
    0x1132 – Stream char
    Send or receive WriteNoRsp/Notification


4

Turn on the LEDs

Expand the topmost CUSTOM SERVICE which can be identified from the list above as the LED service

Click on the W next to the first Characteristic to write to it, and select Byte Array

Write the numbers 01 and click OK to change the LED0 state to ON.


5
Notice that the LED turns on when you write 01 and turns off if you write 00. You will also see the following log output:

6
Bonus: Subscribe to notifications on button presses and receive these in the application.

To see all available resources associated with the CC2640R2, click on this link to filter out all the incompatible projects and collateral.

Available in resource explorer are code examples using SimpleLink CC2640R2 SDK, documentation, Software Developers Guide and links to wiki articles and more. Feel free to navigate the available resources to jump-start your development.

Find the ProjectZeroApp project in Resource Explorer and import to CCS Cloud to review the files in the project and to debug.

Below is a short description and a quick-link to flash your CC2640R2 Launchpad with a pre-built version of the example.

Note: In CCS Cloud, the Stack project must be downloaded to the device once, before downloading or debugging the App project. This is only needed the first time, or after a mass-erase of the device.

10.000 feet overview of how the application is structured

1
The first thing that happens is that main.c initializes the supporting tasks for the Stack and GAP role, calls the user application's ProjectZero_createTask() and starts the TI-RTOS scheduler.
2
From there, ProjectZero_createTask() sets up the user Task with TI-RTOS and tells the system that the task thread is the function called ProjectZero_taskFxn(). When BIOS_start() is called from main(), this function will be executed.
3
The first thing our task function does is to call ProjectZero_init() which configures the BLE Stack, the services and the hardware peripherals used by the application. It also registers a whole slew of callbacks for system events, and from here everything is event based. The taskFxn then enters an infinite loop, waiting for messages to process.
4
During the lifetime of the application, callbacks (found in a section towards the bottom of the file) will be invoked and will send messages to the Task thread for handling in the infinite loop found in ProjectZero_taskFxn().

This includes things such as button presses, connection state changes and data received from a peer device. You can follow the code flow by looking at the UART log output.


Download prebuilt Project Zero App+Stack combined image to the CC2640R2 Launchpad
Note: You may have to re-insert the USB cable to the Launchpad after downloading for the virtual COM port to work correctly in Windows
  • CCS Cloud IDE: Develop your code right in the cloud. Use this tool to import, modify and program code examples for your LaunchPad. Click CCS Project Import Icon anywhere in TI Resource Explorer to import that project into Cloud IDE. Cloud IDE will be automatically started with that project to get your started with development. my.ti.com login is required for use of Cloud IDE.
  • Booster Pack checker: Verify whether Booster Packs What's This are compatible with your LaunchPad.