# Libraries¶

C2000Ware supports multiple libraries for different category of processing. Details are mentioned in the sections below. The figure below shows the directory structure for Libraries.

## DSP Libraries¶

To enable users who want to optimize performance of their real-time control applications while integrating DSP functionality into their system, C2000Ware provides the multiple optimized DSP libraries.

The following libraries are part of DSP Lib:

Fixed Point DSP Software Library – A collection of C28x assembly optimized fixed-point DSP functions (e.g. 16-bit and 32-bit Real and Complex FFTs, 32-bit FIR and IIR filters). Assembly source, benchmarking information, as well as examples to quickly get started are provided.

FPU DSP Software Library – A collection of assembly optimized floating-point DSP functions written for C2000 devices that contain either a single precision Floating Point Unit (FPU), an FPU with Trigonometric Math Unit (TMU type 0), or a double precision FPU (FPU64). Functions supported include single-precision and double-precision Real and Complex FFTs, FIR and IIR filters, Vector Math operations, as well as a single-precision fast square root math function. Assembly source, benchmarking information, as well as examples to quickly get started are provided.

Viterbi, Complex Math, CRC Libraries – A collection of assembly optimized fixed-point DSP functions written specifically for devices containing a VCU accelerator. These functions include Real and Complex FFTs, CRC, Viterbi decoding, Reed-Solomon decoding and De-interleaving. Please note that on newer devices, the VCU accelerator is replaced with an accelerator containing only CRC functionality, hence termed the VCRC. Assembly source, benchmarking information, as well as examples to quickly get started are provided.

## Math Libraries¶

Similar to the DSP functionality provided above, Math focused operations are supported through the optimized Math libraries.

The following libraries are part of the Math Lib:

CLA math library – A collection of assembly optimized floating-point Math functions for devices containing a CLA. The functions include single-precision Trigonometric functions, and intensive math operations such as Division, Square root (and Inverse), Logarithm (and inverse i.e. Exponent). Assembly source, benchmarking information, as well as examples to quickly get started are provided.

Fast Integer Division – The TI C28x Compiler supports C-callable intrinsics that execute on the HWINTDIV, an accelerator that supports specialized instructions to perform fast 16-bit, 32-bit and 64-bit fixed-point integer divisions. Examples of intrinsics usage are provided, but also note that additional methods of invoking the accelerator supported instructions include using the standard division operators as well as the standard library functions.

FPUFastRTS library – A collection of assembly optimized floating-point Math functions written for C2000 devices that contain either a single precision Floating Point Unit (FPU), an FPU with Trigonometric Math Unit (TMU type 0), or a double precision FPU (FPU64). Functions supported include single-precision and double-precision Trigonometric functions, and intensive math operations such as Division, Square root (and Inverse), Logarithm (and inverse i.e. Exponent). Some of these are functions that are natively supported by the C standard (and implemented in the TI compiler provided RTS library), whereas some are not. In both cases, this library provides faster implementations of the respective math functions, at the expense of accuracy. Assembly source, benchmarking information, as well as examples to quickly get started are provided.

IQMath library – A collection of assembly optimized fixed-point mathematical functions for C/C++ programmers to seamlessly port a floating-point algorithm into fixed point code on fixed-point devices. By enabling users to write “floating-point like” code on fixed-point devices, the IQMath library appears to the user to be a virtual floating-point engine. This enables easy to write code (avoiding difficult fixed-point code development involving keeping track of scaling). It also achieves execution speeds considerably faster than equivalent code written in standard ANSI C language. An additional benefit is that code written in IQMath can be ported over seamlessly (through just a Macro switch) from a fixed-point device (where the fixed-point version of the algorithm runs) to a floating-point device (where the native floating-point version of the algorithm runs). Examples are provided to quickly get started.

## Digital Control Library¶

The Digital Control Library (DCL) is a suite of over two hundred functions which enable high performance closed loop control on C2000. The library can be applied to any closed loop control application in which C2000 is used, including digital power supplies, motor control, motion control, and solar inverters. DCL functions support the fixed point C28x, FPU, FPU64, and the CLA. The library comprises two components: controllers and utilities.

Among the controllers are linear PID, PI, double integrating PI, and direct form compensators such as the 2-pole, 2-zero type. The library also contains nonlinear PID and PI controllers which offer superior transient performance. Each controller is supported by functions to load and update parameters safely. Functions to load controller parameters from a pole-zero description are also included.

Utilities include data loggers, a transient capture module, and signal clamps. Data loggers allow users to conveniently capture important signals in the control loop, such as the loop error or control effort. The Transient Capture Module is a triggered data logger, which can capture a transient event such as a step response together with the conditions immediately preceding the event. Transient response data can be graded using one of three performance index functions in the library. Clamps are useful in situations where loop saturation must be managed to avoid integrator wind-up.

DCL functions are supplied entirely in the form of source code. Most time critical controllers are coded in both inline C and in either assembly for best efficiency and determinism. The library also includes a set of code examples illustrating how to apply the controllers, a small block-set of Simulink models, a library user’s manual, and a PID tuning guide.

The Digital Control Library can be found in the `/libraries/control`

sub-directory of the C2000Ware installation. A series of training videos on the DCL is available at Digital Control Library - Training series page.

A 4-part technical seminar offering an introduction to control theory can be found on the C2000 MCU workshops page.

## Crypto Library¶

Cryptography is set of algorithms used in protecting data at rest and transit in computer systems,
communication equipments and IoT devices. Cryptography has become indispensable tool in protection
information in modern day computer/electronic systems. The previous AES library in the C2KWare has now been renamed as
Crypto library, it can be found in the `/libraries/security`

. The Crypto library has support for algorithms - AES and SHA256.
The library also provides examples for usage of different Crypto API supported.

The Advance Encryption Standard(AES) algorithm supports Electronic Code Book (ECB), Cipher Block Chaining (CBC), Counter mode (CTR), Cipher based Message Authentication Code (CMAC) modes. The AES CMAC mode specifically can be used for assurance of data integrity, other modes can be used for data confidentiality. There are space optimized and speed optimized implementation of the algorithm available for all modes. The key sizes of 128 and 256 bit are currently supported for AES.

The Secure Hashing Algorithm (SHA) is one type of cryptographic hashing function. It maps data of an arbitrary size to a bit array of fixed size. It is a one way function, that is, a function for which is practically infeasible to invert or reverse the computation. Some of the applications of it are verifying the integrity of messages, signature generation and verification, password verification etc. The crypto library provides support for SHA256 algorithm.

The C2000_Crypto_Library_User_Guide in `/libraries/security/crypto/c28/docs`

provides more information on Application Programming Interface(API)
supported for different algorithms. The user guide also provides benchmarking information of the API.