cancel
Showing results for 
Search instead for 
Did you mean: 

How to properly use HandleTypeDef in librairies

Matthieu Tanguay
Associate II
Posted on July 02, 2017 at 17:09

Hello,

I have a temperature sensor connected to the I2C1 bus of my board. To help me with basic configuration I use STM32 Cube to generate the base of my code. I usually then go on to write my own libraires to use at later time. It is probably not the most optimal, but helps my understanding quite a bit. Somewhere close to the top of the code there is multiple (I2C,TIM,USAT)_HandleTypeDef. How to I go around using these in other files? Do I need to redefine them in all the file I write them in or simply pass them around as arguments to functions?

Thank you in advance

MT

1 REPLY 1
Posted on July 02, 2017 at 17:59

Decide which ones actually need global scope, instead of GPIO or TIM initializations which occur once.

Use 'extern' in secondary use cases.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..