Click the above “Chuangxue Electronics” to follow with one click, making it easy to learn electronic knowledge.
What is the use of the LIB library? A simple example is the USBXpress LIB library provided by Silicon Labs for the C8051F microcontroller, which includes functions for sending and receiving USB data that are very versatile. However, due to confidentiality reasons, users do not know how these functions are written; only the API functions are provided, and users can call these functions to complete the corresponding functionalities.
Below, I will demonstrate the generation and invocation of the LIB library using the driver program I developed for the NOKIA5110 LCD.
In the target’s “Options for Target ‘Target1′”, select “Create Library” under output.
(Here, there can be no main function and some pin definitions, just the NOKIA5110 driver functions).
Click “Rebuild all the target files” to generate the .lib file.
Place the .LIB file generated from the above project into a new folder, and write a program to call the LIB library in this folder. Add the .LIB file to the project, and declare the functions in NOKIA5110.LIB in the project’s header files, so that the main function can call the NOKIA5110 driver functions in the .LIB file.
LIB library file generation invocation demonstration program (download link): http://www.eeskill.com/file/id/27026.
BTW: The method of calling the USBXpress functions in Keil C is the same as above, but if using the Silicon Laboratories IDE compiler, note that the steps to add the .LIB library are different.
This Silicon Labs IDE is essentially just a shell, and before compiling the program, you need to set the path for calling the Keil compilation core.
Project——Tool Chain Integration
Invocation of LIB library files in Silicon Laboratories IDE
1. Project -> Target Build Configuration -> Customize -> Files to Link -> Add External OBJ
2. In the ‘List files of type’ drop-down box from ‘Object Files’, select ‘All files’ type, and choose the LIB file to add.
3. Click OK.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
==> Visit www.eeskill.com to learn more!