I’m using Code Composer Studio 6.1.0.00104 and Gnome Ubuntu 14.04. First create a new CCS project: File>New>CCS Project. In ‘Advanced Settings’ drop-down menu select ‘Static Library’ as ‘output type’. In ‘Project Template’ select the empty project template. Then, click on finish.createclib01

I use to create two main folders in libraries projects: include and src. Include contain all header files (.h) and src contains implementation files (.c)

Screenshot from 2015-07-28 08:29:51

We have to add include folder to include path: Project properties > CCS Build > MSP430 Compiler > Include Options. In section “Add dir to #include search path” add this: “${workspace_loc:/${ProjName}/include}”

Screenshot from 2015-07-28 08:29:42

Let’s create some example file with a simple function: misc.h and misc.c.

/*
 * misc.h
 *
 *  Created on: Jul 28, 2015
 *      Author: gustavo
 */

#ifndef INCLUDE_MISC_H_
#define INCLUDE_MISC_H_

#include <stdio.h>

void print_hex(int data);

#endif /* INCLUDE_MISC_H_ */
/*
 * misc.c
 *
 *  Created on: Jul 28, 2015
 *      Author: gustavo
 */

#include "misc.h"


void print_hex(int data)
{
	printf("%04X",data);
}

Now, when the project is built,  a .lib file is generated within “Debug” folder. In this case the file is “my_c_lib.lib”. This file could be linked from other new projects.

Screenshot from 2015-07-28 08:45:49

Feel free to leave any question or suggestion in the comments section.

Advertisements