Skip to main content
russ
Associate III
July 11, 2008
Question

Easy Library Implementation Question

  • July 11, 2008
  • 11 replies
  • 1318 views
Posted on July 11, 2008 at 13:40

Easy Library Implementation Question

    This topic has been closed for replies.

    11 replies

    russ
    russAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    Also, a handful of the source files have conflicting defines. Have you encountered these? For example:

    Both stm32f10x_adc.c and stm32f10x_usart.c have conflicting defines for CR1_CLEAR_MASK.

    [ This message was edited by: russ1 on 10-07-2008 21:18 ]

    russ
    russAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    Okay, I'm retarded...

    I just started working with the STM32 library today and I'm not sure what the protocol is for including C files. I could go through and include all of the C files from the library that I am using, but this seems like a lot of legwork.

    On the firmware library datasheet it says that ''The header file stm32f10x_lib.h includes all the peripheral header files. This is the only file that needs to be included in the user application to interface with the library.''

    If this is true, then how are the source files for library referenced? Is it up to me to include all of the source files individually?

    How do you all go about organizing your #include's and overall file structure?

    russ
    russAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    Thanks. I wasn't aware of the ability of my IDE to specify different search paths. It works. This will help the overall organization of my code.

    I'm still curious about those conflicting defines though.

    st3
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    Your questions are about general 'C' programming issues - nothing specifically to do with the STM32.

    Therefore, you should start with a good 'C' textbook.

    Quote:

    When you organize your files do you separate the source and include files into separate folders in the main program directory?

    That is entirely a matter of prefernce.

    Quote:

    When you do this, don't you have to go back through and change all the #include's to point to the folder location?

    You can if you like to make work for yourself, but most (all?) tools provide a way for you to specify a list of locations to search for headers - see the documentation for your particular tools.

    russ
    russAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    Okay, it looks like you include the primary library header file, then all of the .c source files utilized by the program.

    When you organize your files do you separate the source and include files into separate folders in the main program directory? When you do this, don't you have to go back through and change all the #include's to point to the folder location?

    Example:

    #include ''library\source\stm32f10x_RCC.c''

    I'm learning.

    jj_it
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    Gotta love another 'tard...

    Nearly ALL of your questions are answered in the read.me

    text files which accompany every example. (at least this

    is true for the IAR/Keil versions) The exact files to be

    included are clearly listed.

    Start very simply - try to blink ONE led - many more ''set-ups''

    are demanded in the ARM eco-system. It will seem like much work

    at first - but the flexibility & capability of these devices

    demand this - and reward you with unmatched performance & functionality.

    Lastly - don't promise your boss/partner/professor anything ''over-night.''

    There is a rich pool of Ap Notes - as an educator I find most learn

    best by ACTIVELY DOING - run the simplest programs and change ONE thing

    at a time...

    miles
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    You are not supposed to #include .c files in other .c files. You should only #include .h (header) files in .c files. .c files need to be compiled individually to produce .o (object) files, and then object files are linked (using a linker) to produce a single binary.

    Like st7 mentioned, this isn't stm32 related, it's just how C programming works on any platform.

    russ
    russAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    That's strange because my linker didn't have a problem with the .c files being included. I'll go back and double check the outputs, but it looks right.

    jj_it
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    SysTck is great - simple, flexible and faster to learn/master.

    Look for examples and read up in RM0008.

    russ
    russAuthor
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 12:39

    Okay. I got everything linked and compiling the way that it should. Thank you all for the help and gentle insights. :)

    Now to conquer timers!