CC2640 to CC2640R2F

Introduction

This section describes main differences an Application Developer must be aware of between the CC2640 and the CC2640R2F along with a example porting guide to demonstrate the migration effort.

The CC2640R2F was designed to increase flash availability for the application, without changing underlying proven hardware of the CC2640.

Due to the underlaying hardware and platform based on the CC2640, the migration effort from a CC2640 to CC2640R2F is very minor. For more information on specific steps, see Porting Guide from CC2640 to CC2640R2F.

Features and Benefits

To enable maximum possible flash availability, the CC2640R2F features:
Additional benefits of the CC2640R2F:

These features and benefits enable rapid development, future-ready, and innovative robust products.

Additional ROM Support on CC2640R2F

A majority of the increase in application flash availability on the CC2640R2F is due to portions of the BLE-Stack being placed into ROM. When enabled, the stack flash usage dramatically decreases. Up to an ~50% decrease of the BLE-Stack flash usage can be realized with this feature alone; this results in up to an additional 30 kB for the application when migrating from an existing CC2640 project.

In addition, the BLE-Stack has the following Bluetooth 4.2 features always enabled:

  • Ping

  • Slave feature exchange

  • Connection Parameter Update Request

  • Multirole Connections

  • Privacy

  • LE Data Length Extension

See Stack Configurations for more information on selecting features.

See Porting Guide from CC2640 to CC2640R2F for specific instructions.

Warning

Flashing a CC2640 with binaries made for CC2640R2F will result in a spin-lock prior to main.

../../_images/running-r2-on-r1-trap.png

Figure 151. A screen shot highlighting the spin-lock in IAR when running CC2640R2F code on a CC2640.

../../_images/running-r2-on-r1-trap-ccs.png

Figure 152. A screen shot highlighting the spin-lock in CCS when running CC2640R2F code on a CC2640.

Improved ICall and App/Stack Library Builds

ICall has been optimized for reduced flash usage and increased stack operational efficiency. Given these improvements to ICall, stack library builds are possible.

Library builds will not have an application/stack boundary. Instead, global linking is enabled. This allows the linker to only link the stack components that are utilized. Global linking also allows objects used by both the application and stack to be shared.

No ICall/Stack API changes are required to realize these benefits.

For details regarding improved ICall and it’s benefits, see ICall Translation and Include.

For additional information on ICall see ICall.

CC2640R2F LaunchPad Support

All example applications of the SimpleLink CC2640R2 SDK are compatible with the CC2640R2F LaunchPad development kit. These features allow for a unified development experience and empowers developers to rapidly release to market.

CC2640R2 LaunchPad Development Kit Product Page

Improved OAD Support

OAD Support on the CC2640R2F has been improved with new features to boost flash availability to both the application and the stack and reduce costs to future proof.

The CC2640R2F has been improved to allow linking to TI-RTOS ROM functions for OAD application images. The nature of OAD and BIM on CC2640 forced TI-RTOS to be linked into flash for OAD application images.

In addition, BIM for CC2640R2F is redesigned to reside in Page 31 of flash. CC2640’s BIM resided in both Page 0 and Page 31, limiting Application and Stack flash. This feature allows for an additional Page for the developer to use.

BTool now supports the OAD profile, replacing BLE Device Monitor. This change gives a consistent OAD Downloader experience across all devices supporting the TI BLE-Stack.

For more information regarding OAD, see Introduction

Note

On-Chip OAD was supported by IAR Embedded Workbench for Arm for CC2640.

Micro BLE Stack for Broadcaster Applications

The Micro BLE Stack is included with the SimpleLink CC2640R2 SDK. It features the ability to send non-connectable advertisements.

For more information on the Micro BLE Stack see Micro BLE Stack.

Additional Vendor Specific HCI Functionality

Two additional vendor specific commands were created in BLE-Stack 3.00.00:

  • HCI_EXT_ScanEventNoticeCmd()

    Scan Request Detection allows for a BLE Application operating as a Peripheral or Broadcaster GAPRole to receive a notification when a Scan Request is received from a peer device.

  • HCI_EXT_ScanReqRptCmd()

    Scan Event Notifications allows for a BLE Application operating as a Central or Observer GAPRole to receive a notification when a Scan Event is completed.

For more information on how to use these commands, please see the TI Vendor Specific HCI Guide.

Porting Guide from CC2640 to CC2640R2F

These sections describe porting between different versions of the BLE-Stack. To port from versions of the BLE-Stack prior to BLE-Stack 2.2.1, see the Porting Guide Legacy.

To port to newer versions of the BLE-Stack, see guides on the Migration Guides page.

Porting Instructions from BLE-Stack 2.2.3 to BLE-Stack 3.3.2

This section will describe a way to port a project from BLE-Stack 2.2.3 to a BLE-Stack 3.3.2 project. BLE-Stack 2.2.3 can be downloaded from ti.com (TI Bluetooth LE Software Stack) and BLE-Stack 3.3.2 is bundled in the SimpleLink CC2640R2 SDK 3.40.

For this porting guide, simple_peripheral from BLE-Stack 2.2.3 will be ported over to BLE-Stack 3.3.2. Due to the a number of changes in the directory structure and drivers, we will utilize the simple_peripheral project in BLE-Stack 3.3.2 as the project base. In other words, no modifications will be made to the BLE-Stack 2.2.3 project. All application specific code will be inserted into the BLE-Stack 3.3.2 project.

  1. Choose a BLE-Stack 3.3.2 example project

    For reference, see available sample projects that start with “simple_”. A full overview of example projects is given in the Develop section of the Quick Start Guide.

    In this example, we’re going to use simple_peripheral as the starting BLE-Stack 3.3.2 sample project.

    Tip

    All BLE-Stack 3.3.2 sample projects by default contain all the necessary includes and preprocessor defines to utilize the improved ICall in FlashROM_Library configurations.

  2. Transfer all modified application files into the example project

    Place modified profile and application files the existing files in the SimpleLink CC2640R2 SDK to match those in BLE-Stack 2.2.3 project.

    Modify main.c in the BLE-Stack 3.3.2 example if additional tasks were added in the BLE-Stack 2.2.3 project.

    In this example, the following files from BLE-Stack 2.2.3 were moved into simple_peripheral BLE-Stack 3.3.2 example:

    • simple_peripheral.c

    • simple_peripheral.h

    • simple_gatt_profile.c

    • simple_gatt_profile.h

    Note

    The folder structure has changed, see SDK root folders.

    Attention

    For applications using Directed Advertisements comment out #define GBM_GATT_NO_CLIENT in gapbondmgr.c of BLE v3.3.2 project to remain compliant with the Bluetooth Core Specification Version 5.1.

    1#ifdef GATT_NO_CLIENT
    2#ifndef GBM_GATT_NO_CLIENT
    3//#define GBM_GATT_NO_CLIENT // <-- Comment this out
    4#endif // !GBM_GATT_NO_CLIENT
    5#endif // GATT_NO_CLIENT
    

    See Directed Advertisements as GATT Server for more information.

  3. Include icall.h and icall_ble_api.h if Stack/ICall APIs are used.

    1#include "icall_apimsg.h"            // Remove
    2#include <icall.h>                   // Add
    3#include "icall_ble_api.h"           // Add
    

    For more information regarding icall_ble_api.h see ICall Translation and Include.

    Attention

    All Stack/ICall APIs are listed in icall_ble_api.h. If any APIs are used without icall_ble_api.h, build and or link errors may occur with erratic runtime behaviors!

    Remove the icall_apimsg.h include. In addition, remove any include statements for BLE-Stack header files such as gatt.h, gapbondmgr.h etc.

    1#include "hci_tl.h"         // Remove
    2#include "gatt.h"           // Remove
    3#include "gapgattserver.h"  // Remove
    4#include "gattservapp.h"    // Remove
    5#include "gapbondmgr.h"     // Remove
    6#include "osal_snv.h"       // Remove
    7#include "linkdb.h"         // Remove
    8#include "bcomdef.h"        // Remove
    
  4. Convert the application to use the TI-RTOS Event module.

    ICall/the BLE-Stack now synchronize threads with the TI-RTOS Event Module instead of the TI-RTOS Semaphore module.

    In this example, simple_peripheral needs to modified as shown in ICall Utilizes the TI-RTOS Event Module Instead of Semaphores.

  5. Apply changes from TI-RTOS drivers used in BLE-Stack 2.2.3 to the TI-RTOS drivers included with the SimpleLink CC2640R2 SDK.

    TI-RTOS Kernel is now packaged with the SimpleLink CC2640R2 SDK. When migrating from the BLE-Stack 2.2.3, the following drivers have changed. Please see the changes to these files between TI-RTOS for SimpleLink CC13xx/CC26xx 2.21.01.08 with the supplied headers in the SimpleLink CC2640R2 SDK.

    • PDMCC26XX.h

    • PDMCC26XX_util.h

    • PINCC26XX.h

    • PWMTimerCC26XX.h

    • UARTCC26XX.h

    • WatchdogCC26XX.h

    Also, refer to the Core SDK release notes for additional information and the TI-RTOS examples included with SimpleLink CC2640R2 SDK.

    For additional information on how BLE-Stack 3.3.2 uses TI-RTOS see TI-RTOS (RTOS Kernel) Overview

    For any utilized TI Drivers, review TI-RTOS Kernel (SYS/BIOS) User’s Guide and TI Drivers API Reference.

    In this example, the simple_peripheral includes paths need to modified. The TI-RTOS Display Driver driver has been relocated to the following location:

    1#include <ti/mw/display/Display.h> // NOT CORRECT
    2#include <ti/display/Display.h>    // CORRECT
    
  6. Build the stack library project

    In the Output Folder of the IDE, a library file will be generated.

  7. Build application project Build and flash the project onto the CC2640R2F. At this point, you should have a functional BLE-Stack 3.3.2 project running on the CC2640R2F.

ICall Utilizes the TI-RTOS Event Module Instead of Semaphores

Applications for the BLE-Stack projects now use the TI-RTOS Event module instead of the TI-RTOS Semaphore module to implement stack-application ICall messaging and synchronization. The following items need to be changed when porting applications from BLE-Stack 2.2.3 to BLE-Stack 3.3.2. Existing applications that utilize Semaphores for non-ICall aware tasks do not need to adapt to the Event module.

For more information on how to use the Event module, see the Event and the Event Synchronization Module section the TI-RTOS Kernel (SYS/BIOS) User’s Guide.

Tip

To compare the changes required to use the TI-RTOS Event module instead of the Semaphore module in your application, see changes between simple_peripheral.c in BLE-Stack 2.2.3 and BLE-Stack 3.3.2. Use a text comparison program to look at the difference between the two simple_peripheral.c files.

  1. Change include paths from Semaphore to Event module:

    1#include <ti/sysbios/knl/Semaphore.h> //Remove
    2#include <ti/sysbios/knl/Event.h>     //Add
    
  2. Change the type ICall_Semaphore to ICall_SyncHandle:

    1static ICall_Semaphore sem;           //Remove
    2static ICall_SyncHandle syncEvent;    //Add
    

    Replace any references to sem with syncEvent.

  3. Add the syncEvent in ICall_registerApp

    1// ******************************************************************
    2// N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp
    3// ******************************************************************
    4// Register the current thread as an ICall dispatcher application
    5// so that the application can send and receive messages.
    6ICall_registerApp(&selfEntity, &syncEvent);
    
  4. If you are using Util_enqueueMsg to enqueue messages in the application queue, it also takes the syncEvent argument:

     1/*********************************************************************
     2 *
     3 * @brief   Creates a message and puts the message in RTOS queue.
     4 *
     5 * @param   event - message event.
     6 * @param   state - message state.
     7 * @param   pData - message data pointer.
     8 *
     9 * @return  TRUE or FALSE
    10 */
    11static uint8_t SimplePeripheral_enqueueMsg(uint8_t event, uint8_t state,
    12                                           uint8_t *pData)
    13{
    14  sbpEvt_t *pMsg = ICall_malloc(sizeof(sbpEvt_t));
    15
    16  // Create dynamic pointer to message.
    17  if (pMsg)
    18  {
    19    pMsg->hdr.event = event;
    20    pMsg->hdr.state = state;
    21    pMsg->pData = pData;
    22
    23    // Enqueue the message.
    24    return Util_enqueueMsg(appMsgQueue, syncEvent, (uint8_t *)pMsg);
    25  }
    26
    27  return FALSE;
    28}
    
  5. Add internal events for TI-RTOS. Add a bit mask to contain all the RTOS events (SBP_ALL_EVENTS). Any events to be processed in the task function (SimplePeripheral_taskFxn) must also be added here (in this case, we want to process the SBP_PERIODIC_EVT in the task function).

     1// Application events
     2#define SBP_STATE_CHANGE_EVT                  0x0001
     3#define SBP_CHAR_CHANGE_EVT                   0x0002
     4#define SBP_PAIRING_STATE_EVT                 0x0004
     5#define SBP_PASSCODE_NEEDED_EVT               0x0008
     6#define SBP_CONN_EVT                          0x0010
     7
     8// Internal Events for RTOS application
     9#define SBP_ICALL_EVT                         ICALL_MSG_EVENT_ID // Event_Id_31
    10#define SBP_QUEUE_EVT                         UTIL_QUEUE_EVENT_ID // Event_Id_30
    11#define SBP_PERIODIC_EVT                      Event_Id_00
    12
    13// Bitwise OR of all events to pend on
    14#define SBP_ALL_EVENTS                        (SBP_ICALL_EVT        | \
    15                                               SBP_QUEUE_EVT        | \
    16                                               SBP_PERIODIC_EVT)
    
  6. Replace Semaphore_post() with Event_post() and remove any references to the previously used events flag.

     1static void SimpleBLEPeripheral_clockHandler(UArg arg)
     2{
     3    // Store the event.
     4    events |= arg; // Remove
     5
     6    // Wake up the application.
     7    Semaphore_post(sem); // Remove
     8
     9    // Wake up the application.
    10    Event_post(syncEvent, arg); // Add
    11}
    
    1if (events & SBP_PERIODIC_EVT)
    2{
    3    events &= ~SBP_PERIODIC_EVT; // Remove
    4
    5    Util_startClock(&periodicClock);
    6
    7    // Perform periodic application task
    8    SimplePeripheral_performPeriodicTask();
    9}
    
  7. Relocate the global events flag. Remove the global uint16_t events variable and place uint32_t events into SimpleBLEPeripheral_taskFxn() as a local variable.

     1#if defined(FEATURE_OAD)
     2// Event data from OAD profile.
     3static Queue_Struct oadQ;
     4static Queue_Handle hOadQ;
     5#endif //FEATURE_OAD
     6
     7// events flag for internal application events.
     8static uint16_t events; // Remove
     9
    10// Task configuration
    11Task_Struct sbpTask;
    12Char sbpTaskStack[SBP_TASK_STACK_SIZE];
    
    1static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
    2{
    3    uint32_t events; // Add
    4
    5    // Initialize application
    6    SimpleBLEPeripheral_init();
    
  8. Replace ICall_wait() in Application Task with Event_pend()

     1static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
     2{
     3   // Initialize application
     4   SimpleBLEPeripheral_init();
     5
     6   // Application main loop
     7   for (;;)
     8   {
     9       // Waits for a signal to the semaphore associated with the calling thread.
    10       // Note that the semaphore associated with a thread is signaled when a
    11       // message is queued to the message receive queue of the thread or when
    12       // ICall_signal() function is called onto the semaphore.
    13       ICall_Errno errno = ICall_wait(ICALL_TIMEOUT_FOREVER);  // Remove
    14
    15       if (errno == ICALL_ERRNO_SUCCESS) // Remove
    16       {
    17            ICall_EntityID dest;
    18            ICall_ServiceEnum src;
    
     1static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1)
     2{
     3    uint32_t events;
     4
     5    // Initialize application
     6    SimpleBLEPeripheral_init();
     7
     8    // Application main loop
     9    for (;;)
    10    {
    11        // Waits for an event to be posted associated with the calling thread.
    12        // Note that an event associated with a thread is posted when a
    13        // message is queued to the message receive queue of the thread
    14        events = Event_pend(syncEvent, Event_Id_NONE, SBP_ALL_EVENTS,
    15                            ICALL_TIMEOUT_FOREVER); // Add
    16
    17    if (events) // Add
    18    {
    19        ICall_EntityID dest;
    20        ICall_ServiceEnum src;