2023-08-21 10:18 AM
if i use static UART_HandleTypeDef huart8; in main.c . when i want to run it in fpvisionai.c HAL_UART_Transmit(&huart8,etc) say huart8 undeclared , should i use include <main.h> in this file,o how to set UART_HandleTypeDef huart8 as global variable
Solved! Go to Solution.
2023-08-21 10:54 AM - edited 2023-08-21 10:54 AM
>> should be fp_vision_app.h?
It NEEDS to be in something that's INCLUDED, could be main.h, or a file both share, or you put extern UART_HandleTypeDef huart8; in the .C file you're using it from, provided you've also defined what UART_HandleTypeDef is
2023-08-21 10:21 AM - edited 2023-08-21 10:22 AM
Using "static" means its not visible outside of main.c
Use this in main.h
extern UART_HandleTypeDef huart8;
And this in main.c
UART_HandleTypeDef huart8;
2023-08-21 10:31 AM - edited 2023-08-21 10:49 AM
still have this trouble fp_vision_app.c:280:25: error: 'huart8' undeclared (first use in this function), should be fp_vision_app.h?
2023-08-21 10:54 AM - edited 2023-08-21 10:54 AM
>> should be fp_vision_app.h?
It NEEDS to be in something that's INCLUDED, could be main.h, or a file both share, or you put extern UART_HandleTypeDef huart8; in the .C file you're using it from, provided you've also defined what UART_HandleTypeDef is
2023-08-21 11:03 AM
means Use this in main.h
"extern UART_HandleTypeDef huart8;"
And this in main.c
UART_HandleTypeDef huart8;
and in the fp_vision_app.c
include ''main.h" no ?