Kernel Configuration

In the SimpleLink CC13xx/CC26xx SDK, all FreeRTOS application routines are abstracted using the following:

You can find example FreeRTOS projects that use the SimpleLink CC13xx/CC26xx SDK in the examples/rtos/ folder for all supported IDEs.

No native FreeRTOS examples are provided in this SimpleLink CC13xx/CC26xx SDK. If you want to use the native FreeRTOS routines without the abstractions provided by the SimpleLink CC13xx/CC26xx SDK, documentation is provided on the FreeRTOS website.

Note

At this moment, the only example with FreeRTOS support is multi_role.

POSIX Support

Portable Operating System Interface (POSIX) is an IEEE industry API standard for OS compatibility. The SimpleLink CC13xx/CC26xx SDK provides support for POSIX APIs on top of FreeRTOS (as it does for TI-RTOS). For a more detailed description of the POSIX support in the SimpleLink CC13xx/CC26xx SDK, please refer to the POSIX Overview Workshop

Driver Porting Layer (DPL)

The TI Drivers (e.g. UART, I2C, Power Management, etc.) are written to be used with the Driver Porting Layer (DPL). The SimpleLink CC13xx/CC26xx SDK includes a DPL implementation for both FreeRTOS, TI-RTOS and no RTOS.

../_images/driver_levels_dpl.png

Using FreeRTOS with CCS

Warning

This feature is a preview and still under development.

In order to use FreeRTOS within CCS, you must specify the location of the FreeRTOS installation. To do this, follow these steps:

Note

GCC is only supported at this time, therfore no support for IAR and CCS.

  1. In CCS, choose Window → Preferences from the menus.

  2. Select the General → Workspace → Linked Resource category.

  3. Click New and add a link with the following settings.

    • Name: FREERTOS_INSTALL_DIR

    • Value: The location of you FreeRTOS installation

      ../_images/freertos_install_dir.png

These steps only need to be performed once per CCS workspace that you create.

FreeRTOS examples

As mentioned before, only the multi_role example supports FreeRTOS and it needs to be used with the gcc compiler, therefore please import the project located in multi_role/freertos/gcc.

../_images/freertos_project_import.png

Two projects will get imported:

../_images/multi_role_freertos_import.png

FreeRTOS vs. TI-RTOS modules

The application and the ICall layer communicate using events to call the OS and made context switch. The table below shows the modules that are used by TI-RTOS in a typical example flow, at the same time explains which modules are used by FreeRTOS.

Table 5. Replacing modules that supports FreeRTOS in place of TI-RTOS modules
Example flow TI-RTOS modules FreeRTOS modules
1. Application Thread Listen (pend) on event number TI-RTOS Semaphore/Event SemaphoreP (used through DPL layer) and mq_send / mq_receive Blocking Mqueue (POSIX queues)
2. Stack Thread Doing whatever he asked to do by the app called TI-RTOS Timers TimersP (used through DPL layer)
3. Stack Thread Push a message (or number of messages) into the queue and post an event Queue TI-RTOS utility Queue mq_send / mq_receive NON-Blocking Mqueue (POSIX queues)
4. Application Thread OS wakes the application thread and the application pulls the message from the Non-OS queue TI-RTOS utility Queue mq_send / mq_receive NON-Blocking Mqueue (POSIX queues)
5. Application Thread Listen (pend) on event number - cycle has completed TI-RTOS event mq_send / mq_receive Blocking Mqueue (POSIX queues)

icall_POSIX

The file ICall_POSIX is based on POSIX, DPL and FreeRTOS bare APIs calls. This implementation should allow us to support different Operating Systems if required. In order to do this, all the #ifdef FreeRTOS on the current ICall_POSIX could be changed to support a different OS.

Here are the places where these defines are used (icall_POSIX.c):

Listing 19. ical_POSIX.c - Includes
#ifdef FREERTOS
#include <FreeRTOS.h>
#include <task.h>
#include "bget.h"
#endif
Listing 20. ical_POSIX.c - ICall_taskSelf()
Task_Handle ICall_taskSelf(void)
{
  Task_Handle task = NULL;
#ifdef FREERTOS
  task = (Task_Handle) xTaskGetCurrentTaskHandle();
#else
  task = <handler need to be returned according to the chosen OS>;
#endif // FREERTOS
  return (task);
}
Listing 21. ical_POSIX.c - TI_heap_wrapper.h
#if defined(HEAPMGR_CONFIG) && ((HEAPMGR_CONFIG == 0) || (HEAPMGR_CONFIG == 0x80))
#include <rtos_heaposal.h>
#elif defined(HEAPMGR_CONFIG) && ( (HEAPMGR_CONFIG == 1) || (HEAPMGR_CONFIG == 0x81))
#include <rtos_heapmem.h>
#elif defined(HEAPMGR_CONFIG) && ( (HEAPMGR_CONFIG == 2) || (HEAPMGR_CONFIG == 0x82))
#include <rtos_heaptrack.h>
#elif defined(FREERTOS)
#include "TI_heap_wrapper.h"
#else
static ICall_CSState ICall_heapCSState;
#include <rtos_heaposal.h>
#endif
Listing 22. ical_POSIX.c - ICALL_Task_disable()
void ICALL_Task_disable(struct sched_param *OriginalParam)
{
    int justForFunc=0;
    pthread_t pthreadID = pthread_self();

    pthread_getschedparam(pthreadID, &justForFunc, OriginalParam);

    struct sched_param NewParam;
#ifdef FREERTOS
    NewParam.sched_priority = configMAX_PRIORITIES;
#else
    NewParam.sched_priority = <Please define Max Priority>;
#warning "Please define Max OS Priority"
#endif
    pthread_setschedparam(pthreadID, 0, &NewParam);
}
Listing 23. ical_POSIX.c - ICall_heapMalloc()
#ifdef FREERTOS
/**
 * Allocates a memory block.
 * @param size   size of the block in bytes.
 * @return address of the allocated memory block or NULL
 *         if allocation fails.
 */

void *ICall_heapMalloc(uint32_t size)
{
    void* ret = NULL;
    ret = pvPortMalloc(size);
    return ret;
}

Note

pvPortMalloc is an internal malloc call of the FreeRTOS