Drivers

The TI-RTOS provides a suite of CC26x2 peripheral drivers that can be added to an application. The drivers provide a mechanism for the application to interface with the CC26x2 onboard peripherals and communicate with external devices. These drivers make use of DriverLib to abstract register access.

There is significant documentation relating to each TI-RTOS driver located in the SimpleLink CC26x2 SDK. Refer to the SimpleLink CC26x2 SDK release notes for the specific location. This section only provides an overview of how drivers fit into the software ecosystem. For a description of available features and driver APIs, refer to the TI-RTOS API Reference.

Adding a Driver

Some of the drivers are added to the project as source files in their respective folder under the Drivers folder in the project workspace.

The driver source files can be found in their respective folder at $DRIVER_LOC\ti\drivers.

The $DRIVER_LOC argument variable refers to the installation location and can be viewed in the Project Options\ Resource\Linked Resources, Path Variables tab of CCS.

To add a driver to a project, include the C and include file of the respective driver in the application file (or files) where the driver APIs are referenced.

For example, to add the PIN driver for reading or controlling an output I/O pin, add the following:

#include <ti/drivers/pin/PINCC26XX.h>

Also add the following TI-RTOS driver files to the project under the Drivers\PIN folder:

  • PINCC26XX.c
  • PINCC26XX.h
  • PIN.h

This is described in more detail in the following sections.

Board File

The board file sets the parameters of the fixed driver configuration for a specific board configuration, such as configuring the GPIO table for the PIN driver or defining which pins are allocated to the I2C, SPI, or UART driver.

The board files for the CC26X2R1 LaunchPad are in the following path: <SDK_INSTALL_DIR>\source\ti\boards\<Board_Type>

TI 15.4-Stack uses board files found here:

C:\ti\simplelink_CC26x2_sdk_x_xx_xx_xx\examples\CC1350_LAUNCHXL\ti154stack\common\boards

<Board_Type> is the actual device. To view the actual path to the board files, see the following:

  • CCS: Project Options→ Resources→ Linked Resources, Path Variables tab

In the path above, the <Board_Type> is selected based on a preprocessor symbol in the application project.

The top-level board file (board.c) then uses this symbol to include the correct board file into the project. This top-level board file can be found at <SDK_INSTALL_DIR>\examples\rtos\CC13x0_LAUNCHXL\ti154stack\common\boards\board.c, and is located under the Startup folder in the project workspace:

../_images/image178.jpeg

Board Level Drivers

There are also several board driver files which are a layer of abstraction on top of TI-RTOS drivers, to function for a specific board, for example Board_key.c. If desired, these files can be adapted to work for a custom board.

Creating a Custom Board File

A custom board file must be created to design a project for a custom hardware board. TI recommends starting with an existing board file and modifying it as needed. The easiest way to add a custom board file to a project is to replace the top-level board file. If flexibility is desired to switch back to an included board file, the linking scheme defined in Adding a Driver should be used.

At minimum, the board file must contain a PIN_Config structure that places all configured and unused pins in a default, safe state and defines the state when the pin is used. This structure is used to initialize the pins in main() as described in Start-Up in main(). The board schematic layout must match the pin table for the custom board file Improper pin configurations can lead to run-time exceptions:

PIN_init(BoardGpioInitTable);

See the PIN driver documentation for more information on configuring this table.

Available Drivers

This section describes each available driver and provide a basic example of adding the driver to the simple_peripheral project. For more detailed information on each driver, see the TI-RTOS API Reference.

PIN

The PIN driver allows control of the I/O pins for software-controlled general-purpose I/O (GPIO) or connections to hardware peripherals. As stated in the Board File section, the pins must first be initialized to a safe state (configured in the board file) in main(). After this initialization, any module can use the PIN driver to configure a set of pins for use.

Other Drivers

The other drivers included with TI-RTOS are: Crypto (AES), I2C, PDM, Power, UART, SPI, RF, and UDMA. The stack makes use of the power, RF, and UDMA, so extra care must be taken if using these. As with the other drivers, these are well-documented, and examples are provided in the SimpleLink CC26x2 SDK.