Using IAR to create a library and how to use the library

Source: Internet
Author: User

In the use of STM32 firmware library, you need to add to the project the use of the corresponding source files, such as: STM32F10X_GPIO.C and so on, add a lot of trouble not to say, each time in rebuild to compile these basic unchanged files.

and by using the library can solve these problems, first only need to add a library file, the second rebuild only compile our own write the source files

Process for creating a library (in IAR):

Create a new Dlib project, stm32f10x_xxx.c such files and corresponding header files are copied to the project folder (do not copy also can), and then add, and core_cm3.c, MISC.C, SYSTEM_STM32F10X.C, These are all added in. (Note: Do not add the. h header file, which is not the same as Keil, the IAR does not have to add a header file, only the source file can be # # #.)

The. s boot file can be added according to the actual needs, of course you can also create a corresponding library for each model. Then choose different libraries according to the different films in the actual project.

Once added, open the project properties settings.

General Option:

Select the chip in the Target property box;

Select the library in output file in the Output property box (This is the default if the new project is Dlib);

The library option in the Library configuration property box selects none; (note here)

Compile/C + +:

Optimizations can choose to optimize the level.

Preprocessor, add the path to the include file in the additional Include Directories column. The path to the head file is added as in general engineering.

OK, set as above. After compiling, it will be converted into a. a file.

The above is the debug mode generated in the library file, the settings under release ibid. The difference between the two is that the debug option defaults to output debugging information, while release does not. At the same time, we can adjust the optimization level to a point in release. Finally, The library file generated in release mode is a little bit smaller.

How to use the library:

Build a project as usual, or open your own STM32 project. Then add the library, two ways to add a library:

1. You can right-->add files in the project just as you would add a source file, and then add the. a file.

2. Right-click Properties, added in additional libraries: In the Library tab of the linker option. And you can add the library generated by the debug mode in the Debug property. Release to add a library generated by release mode. Note that you cannot just add a path, but also write the file name. For example: E:/IAR_LIB/STM32/STM32_D.A

OK, then you can remove a file like stm32f10x_gpio.c from the project.

(using libraries) and (without using libraries to manually add STM32F10X_GPIO.C), the size of the resulting executable file is the same in the actual project.

Finally, in the actual project:

Just copy the stm32f10x_conf.h, Stm32f10x_it.h, stm32f10x_it.c to the project folder and add the stm32f10x_it.c to the project (of course, as mentioned earlier, whether in arm engineering or library engineering , IAR does not need to add a header file, added instead will compile an error, only need to source files include #)

In addition, the above three files are best not to create a library, because they are different projects are not the same, this does not need me to say. :)

The above three files are in the STM32 Library of Stm32f10x_stdperiph_lib_v3.3.0/project/stm32f10x_stdperiph_template, of course, there are examples, often people can not find out where these three files ....


Transferred from: http://blog.csdn.net/conterc/article/details/5709938


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.