cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with folder .c and .h configuration

JJoao.1
Associate III

Hello everybody,

I'm a newbie in stm32 IDE. I come from microchip 8bit PIC world :)

For a small personal project I would like to use a SIM800 GSM module with an STM32F303.

in order to make my code clear I would have liked to break it down into several parts. But I admit that I don't really understand how to do things right.

For example I would like to make a gsm.c file and therefore a gsm.h only for the GSM part. In order to put the functions concerning the gsm part.

But here I need to use the UART library in the main.c and also in the gsm.c, is this possible and how to do it and declare it?.

In addition I would like to have variables that can be common to both .c files, is this possible?

Thank you for reading me

2 REPLIES 2
Piranha
Chief II

This has nothing to do with STM32 - you just have to learn the C language, compilers and software development in general.

https://stackoverflow.com/questions/47919/organization-of-c-files

S.Ma
Principal

True, the base C coding will be required to get the job done.

In C, there are header file (the name and constant/define declarations), which will be shared (included) among source code C files. And for USART, I would suggest to look at LL (low layer) code example for the nucleo F303 to start from a compiling project.

As for global variables, you declare them in a C file and you can use them wherever you declare them as "extern uint32_t myVar;"

One piece of advice : If you use a global variable in a function, pass the global variable as function passing parameter. Your function will remain reentrant and multi-core/multi-thread safer.