2008-07-11 04:40 AM
Easy Library Implementation Question
2011-05-17 03:39 AM
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?2011-05-17 03:39 AM
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 ]2011-05-17 03:39 AM
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.2011-05-17 03:39 AM
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.2011-05-17 03:39 AM
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.2011-05-17 03:39 AM
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.
2011-05-17 03:39 AM
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.2011-05-17 03:39 AM
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...2011-05-17 03:39 AM
Speaking of timers... for basic timing applications (~1ms period) do you use the SysTck or TIM peripheral? I don't really want to use the TIM library because it takes up about 16k of flash in my poor 32k processor.