Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Migrating a TI-RTOS project to a custom development board

From Texas Instruments Wiki
Jump to: navigation, search

This migration guides describes the steps involved to port an existing TI-RTOS project (such as an example project) to custom development/production board.

TI-RTOS projects are easily modified to accommodate custom development/production boards. Each TI-RTOS project has a set of board files that configure and initialize TI-RTOS drivers which are named (by convention) after the development board. By simply configuring a few specific files, the porting process from one development board to another is straight forward. Before continuing, it's recommended to create a copy of the CCS project as a backup.

Backup the original CCS project

  • Clean the TI-RTOS project. Right-click on the project and select Clean Project.
  • Create copy of original. Right-click on the project select Copy.
  • Right-click in the Project Explorer window and select Paste.
  • Give you project a new name of your choosing. For the remaining portion of the documentation references to this new name is referred as Project.

Modify the board files

Within Project you will find a set of files that need to be modified for your port.

  • Board.h
  • <dev board name>.h
  • <dev board name>.c
  • <dev board name>.cmd

It's recommended to rename the files with the <dev board name> file names with the name chosen for Project. For example EK_TM4C123GXL.h, EK_TM4C123GXL.c, and EK_TM4C123GXL.cmd would be renamed to Project.h, Project.c, and Project.cmd. During the process of renaming the board files you will also have to update the #include and other #define directives and function names as necessary. Board.h also contains definitions that need to be updated.

For full details on what these files are for, see the TI-RTOS User's guide. From a high-level perspective these files serve the following functions:

File Purpose
Board.h This file used by TI-RTOS examples to abstract Board_ definitions. Depending on your setup, you may not need this file.
Project.h Development board's .h file. This file contains the enum statements that dictate on how many peripheral instances are to be statically allocated in the application.
Project.c Development board's .c file. This file contains the initialization code that is specific to the peripherals used by Project.
Project.cmd Development board's linker command file.

The following steps guide you through the migration:

Update Project.h

Open Project.h and update the enum definitions to allocate the desired number of peripheral instances needed for your application. This applies for each TI-RTOS driver in Project.h.

/*
 *  @def    Project_I2CName
 *  @brief  Enum of I2C names on the Project dev board
 */
typedef enum Project_I2CName {
    Project_I2C1 = 0,
    Project_I2C3,
 
    Project_I2CCOUNT
} Project_I2CName;

Update Project.c

Open Project.c and make the necessary updates that reflect your custom development board. The following code block shows a board configuration for a TI-RTOS I2C driver for Tiva devices.

#if TI_DRIVERS_I2C_INCLUDED
#include <ti/drivers/I2C.h>
#include <ti/drivers/i2c/I2CTiva.h>
 
/* I2C objects */
I2CTiva_Object i2cTivaObjects[Project_I2CCOUNT];
 
/* I2C configuration structure, describing which pins are to be used */
const I2CTiva_HWAttrs i2cTivaHWAttrs[Project_I2CCOUNT] = {
    {I2C1_BASE, INT_I2C1},
    {I2C3_BASE, INT_I2C3},
};
 
const I2C_Config I2C_config[] = {
    {&I2CTiva_fxnTable, &i2cTivaObjects[0], &i2cTivaHWAttrs[0]},
    {&I2CTiva_fxnTable, &i2cTivaObjects[1], &i2cTivaHWAttrs[1]},
    {NULL, NULL, NULL}
};
 
/*
 *  ======== Project_initI2C ========
 */
Void Project_initI2C(Void)
{
    /* I2C1 Init */
    /* Enable the peripheral */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1);
 
    /* Configure the appropriate pins to be I2C instead of GPIO. */
    GPIOPinConfigure(GPIO_PA6_I2C1SCL);
    GPIOPinConfigure(GPIO_PA7_I2C1SDA);
    GPIOPinTypeI2CSCL(GPIO_PORTA_BASE, GPIO_PIN_6);
    GPIOPinTypeI2C(GPIO_PORTA_BASE, GPIO_PIN_7);
 
    /* I2C3 Init */
    /* Enable the peripheral */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
 
    /* Configure the appropriate pins to be I2C instead of GPIO. */
    GPIOPinConfigure(GPIO_PD0_I2C3SCL);
    GPIOPinConfigure(GPIO_PD1_I2C3SDA);
    GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);
    GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);
 
    I2C_init();
}
#endif /* TI_DRIVERS_I2C_INCLUDED */

Examine the custom development board's schematics and adjust the code snippet in your Project.c to accommodate the changes needed. This process needs to be performed for each TI-RTOS driver you plan to use in your application.

The Driver_config[] data structure configures TI-RTOS drivers as documented in the TI-RTOS User's guide and init_Driver function addresses changes may include but items such as:

  • Peripheral power-up requirements
  • Peripheral pin assignments
  • Pad configurations
  • Pin [Un]Locking

Update Project.cmd

TI-RTOS examples provide a linker command file as part of the board files. These linker command files are taken from example TI-RTOS kernel projects and/or taken from TI-Ware specific examples (MSP430Ware, TivaWare, MWare, etc...).

Rebuild Project

The last step is to Rebuild and debug Project.
Tirtos porting rebuild.jpg